Skip to content

Commit

Permalink
GLSP-1029: Introducing accessible tool palette, node and edge creatio…
Browse files Browse the repository at this point in the history
…n via keyboard (#279)

-  Introduce tool and handler for Grid and Pointer for node creation

-  Introduce tool and handler for edge creation with autocomplete feature

-  Introduce tool and handler zooming via grid

Part of eclipse-glsp/glsp#1029
  • Loading branch information
aylin-sarioglu authored Oct 3, 2023
1 parent 5435240 commit 9f38884
Show file tree
Hide file tree
Showing 35 changed files with 2,213 additions and 21 deletions.
12 changes: 10 additions & 2 deletions examples/workflow-standalone/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ import {
IDiagramOptions,
LogLevel,
STANDALONE_MODULE_CONFIG,
TYPES
TYPES,
toolPaletteModule
} from '@eclipse-glsp/client';
import { Container } from 'inversify';
import '../css/diagram.css';
export default function createContainer(options: IDiagramOptions): Container {
const container = createWorkflowDiagramContainer(createDiagramOptionsModule(options), accessibilityModule, STANDALONE_MODULE_CONFIG);
const container = createWorkflowDiagramContainer(
createDiagramOptionsModule(options),
{
add: accessibilityModule,
remove: toolPaletteModule
},
STANDALONE_MODULE_CONFIG
);
bindOrRebind(container, TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
bindOrRebind(container, TYPES.LogLevel).toConstantValue(LogLevel.warn);
container.bind(TYPES.IMarqueeBehavior).toConstantValue({ entireEdge: true, entireElement: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/client/css/glsp-sprotty.css
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
}

.search-hidden {
opacity: 0.2;
opacity: 0.4;
}

.search-highlighted .sprotty-node,
Expand Down
66 changes: 66 additions & 0 deletions packages/client/css/keyboard-tool-palette.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

.accessibility-tool-palette.tool-palette {
top: 48px;
width: 240px;
}

.accessibility-tool-palette .header-tools i {
margin-right: 0.5em;
position: relative;
}

.accessibility-tool-palette .tool-button .key-shortcut,
.accessibility-tool-palette .header-tools .key-shortcut {
display: none;
position: absolute;

border-radius: 50%;
width: 0.5rem;
height: 0.5rem;
padding: 0.5rem;

background: #fff;
border: 2px solid #666;
color: black;
text-align: center;

font: bold 0.8rem Arial, sans-serif;
line-height: 0.5rem;
}

.accessibility-tool-palette .tool-button .key-shortcut {
left: -2rem;
}

.accessibility-tool-palette .header-tools .key-shortcut {
top: -2.5rem;
right: -0.3rem;
}

.accessibility-show-shortcuts:focus-within .header-tools .key-shortcut,
.accessibility-show-shortcuts:focus-within .tool-button .key-shortcut {
display: block;
}

.accessibility-tool-palette.collapsible-palette {
overflow: visible;
}

.accessibility-tool-palette.collapsible-palette + .minimize-palette-button {
top: 50px;
}
50 changes: 50 additions & 0 deletions packages/client/css/keyboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

.grid-container {
display: grid;
position: absolute;
top: 0.5rem;
bottom: 0.5rem;
left: 0.5rem;
right: 0.5rem;
grid-template-columns: auto auto auto;
}

.grid-container:focus {
opacity: 1 !important;
}

.grid-item {
border: 1px solid rgba(0, 0, 0, 0.6);
padding: 1rem;
/* Fix overlapping borders */
margin: 0 -1px -1px 0;
}

.grid-item-number {
border-radius: 50%;
width: 1.5rem;
height: 1.5rem;
padding: 0.5rem;

background: #fff;
border: 2px solid #666;
color: black;
text-align: center;

font: bold 1.3rem Arial, sans-serif;
}
76 changes: 68 additions & 8 deletions packages/client/src/features/accessibility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,63 @@ To activate and use only specific accessibility features, the respective module

Below is a list of the keyboard only accessibility features:<br>

| Feature | Description | Shortcut | Module |
| ------- | :----------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: | :-------------------: |
| Search | Search for elements or edges using labels, types, etc. <br> with respective diagram highlighting | <kbd>CTRL</kbd>+<kbd>F</kbd> | `searchPaletteModule` |
| Move | Move elements, edges or viewport into the directions | <kbd>←</kbd> \|\| <kbd>↑</kbd> \|\| <kbd>→</kbd> \|\| <kbd>↓</kbd> | `moveZoomModule` |
| Zoom | Zoom in or out gradually to elements or viewport or reset to default zoom level. | <kbd>+</kbd> \|\| <kbd>-</kbd> \|\| <kbd>CTRL</kbd>+<kbd>0</kbd> | `moveZoomModule` |
| Resize | Increase or decrease element sizes gradually or reset to default element size. | <kbd>ALT</kbd>+<kbd>A</kbd> then <kbd>+</kbd> \|\| <kbd>-</kbd> \|\| <kbd>CTRL</kbd>+<kbd>0</kbd> | `resizeKeyModule` |
| Feature | Description | Shortcut | Module |
| -------------------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------: | :---------------------------: |
| Tool Palette | Accessible tool palette | <kbd>ALT</kbd>+<kbd>P</kbd> | `keyboardToolPaletteModule` |
| Graph | Focus on the graph | <kbd>ALT</kbd>+<kbd>G</kbd> | `-` |
| Grid & Pointer | Used for positioning on the canvas for creating new elements | activated through selected _Tool Palette_ entry | `keyboardControlModule` |
| Search | Search for elements or edges using labels, types, etc. <br> with respective diagram highlighting | <kbd>CTRL</kbd>+<kbd>F</kbd> | `searchPaletteModule` |
| Move | Move elements, edges or viewport into the directions | <kbd>←</kbd> \|\| <kbd>↑</kbd> \|\| <kbd>→</kbd> \|\| <kbd>↓</kbd> | `moveZoomModule` |
| Zoom | Zoom in or out gradually to elements or viewport or reset to default zoom level. | <kbd>+</kbd> \|\| <kbd>-</kbd> \|\| <kbd>CTRL</kbd>+<kbd>0</kbd> | `moveZoomModule` |
| Zoom via Grid | Zoom in gradually according to the direction of the selected grid box. | <kbd>CTRL</kbd>+<kbd>+</kbd> then <kbd>+</kbd> \|\| <kbd>-</kbd> \|\| <kbd>CTRL</kbd>+<kbd>0</kbd> | `moveZoomModule` |
| Resize | Increase or decrease element sizes gradually or reset to default element size. | <kbd>ALT</kbd>+<kbd>A</kbd> then <kbd>+</kbd> \|\| <kbd>-</kbd> \|\| <kbd>CTRL</kbd>+<kbd>0</kbd> | `resizeKeyModule` |
| Element Navigation | Navigate through the elements of the diagram (**Default** or **Position-based** Navigation). | <kbd>N</kbd> or <kbd>ALT</kbd>+<kbd>N</kbd> then use arrow keys to iterate | `glspElementNavigationModule` |
| Help | Display list of existing keyboard shortcuts | <kbd>ALT</kbd>+<kbd>H</kbd> | `glspShortcutHelpModule` |
| Focus Tracker | Display the current focused element on the canvas | no key needed | `glspFocusTrackerModule` |
| User Notifications (Toast) | Displaying user notifications | no key needed | `glspToastModule` |

## Usage

### CRUD Modeling Operations

#### Focus on the Graph

- <kbd>ALT</kbd>+<kbd>G</kbd>: Use to set the focus on the graph.

#### Tool Palette

The shortcut <kbd>ALT</kbd> + <kbd>P</kbd> sets the focus on the tool palette. Afterward, the characters <kbd>a</kbd> - <kbd>z</kbd> select an element or <kbd>1</kbd> - <kbd>5</kbd> for the header menu options.

#### Grid + Pointer

After selecting a node in the tool palette, the grid gets visible. The grid is for positioning the _pointer_ in the screen.

The following shortcuts are usable:

- <kbd>1</kbd>- <kbd>9</kbd>: Position the pointer in the grid
- Use arrow keys (<kbd>←</kbd> || <kbd>↑</kbd> || <kbd>→</kbd> || <kbd>↓</kbd>) to move the pointer to a direction
- <kbd>ENTER</kbd>: Create the node
- <kbd>CTRL</kbd> + <kbd>ENTER</kbd>: Create multiple nodes

#### Create Nodes

1. <kbd>ALT</kbd> + <kbd>P</kbd>: Focus the tool palette
2. <kbd>a</kbd> - <kbd>z</kbd>: Select a node
3. <kbd>1</kbd> - <kbd>9</kbd>: Position the pointer in a cell
4. Use arrow keys (<kbd>←</kbd> || <kbd>↑</kbd> || <kbd>→</kbd> || <kbd>↓</kbd>) to move the pointer to the correct position
5. Create the node by using either
- <kbd>ENTER</kbd>: Create the node und finishes the operation
- <kbd>CTRL</kbd> + <kbd>ENTER</kbd>: Create multiple nodes

#### Create Edges

1. <kbd>ALT</kbd> + <kbd>P</kbd>: Focus the tool palette
2. <kbd>a</kbd> - <kbd>z</kbd>: Select an edge
3. Type in either **type** or **name** of node for **source**
4. <kbd>ENTER</kbd>: Make selection
5. Type in either **type** or **name** of node for **target**
6. <kbd>ENTER</kbd>: Make selection

#### Search

The search palette allows to search labelled elements or edges that have a labelled node as source or target. The result set will be highlighted accordingly, to also be able to visually distinguish between the searched and the remaining parts of the given diagram.
Expand Down Expand Up @@ -52,7 +100,17 @@ viewport.
2. Use <kbd>+</kbd> or <kbd>-</kbd> to zoom in or out gradually.
3. <kbd>CTRL</kbd>+<kbd>0</kbd>: Set the zoom level to default.

### Resize element
#### Zoom via Grid

This zoom functionality via Grid can be used to gradually adapt the zoom level according to the direction of the selected _Grid Box_.

#### Steps

1. <kbd>CTRL</kbd>+<kbd>+</kbd>: Display the grid.
2. <kbd>1</kbd>- <kbd>9</kbd>: Position the pointer in a cell to zoom.
3. Repeat **2.)** to reach the desired zoom level.

#### Resize element

The resize functionality helps to set the size of the nodes, by either increasing or decreasing the size of the nodes’ shape gradually.

Expand All @@ -66,11 +124,13 @@ The resize functionality helps to set the size of the nodes, by either increasin

### Model Navigation

For navigating through the elements of the diagram two navigation algorithms are provided.

#### Default Navigation (following directions of relations)

1. Select element as starting point.
2. <kbd>N</kbd>: Activate default navigation.
3. Use arrow keys to iterate through model according to the directions of the given relations.
3. Use arrow keys (<kbd>←</kbd> || <kbd>↑</kbd> || <kbd>→</kbd> || <kbd>↓</kbd>) to iterate through model according to the directions of the given relations.

#### Position-based Navigation (following x and y coordinates)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import { configureMoveZoom } from './move-zoom/move-zoom-module';
import { configureResizeTools } from './resize-key-tool/resize-key-module';
import { configureSearchPaletteModule } from './search/search-palette-module';
import { configureViewKeyTools } from './view-key-tools/view-key-tools-module';
import { configureKeyboardToolPaletteTool } from './keyboard-tool-palette/keyboard-tool-palette-module';
import { configureKeyboardControlTools } from './keyboard-pointer/keyboard-pointer-module';
import { configureElementNavigationTool } from './element-navigation/element-navigation-module';
import { configureFocusTrackerTool } from './focus-tracker/focus-tracker-module';
import { configureToastTool } from './toast/toast-module';

/**
* Enables the accessibility tools for a keyboard-only-usage
*/
Expand All @@ -33,6 +36,8 @@ export const accessibilityModule = new FeatureModule((bind, unbind, isBound, reb
configureMoveZoom(context);
configureSearchPaletteModule(context);
configureShortcutHelpTool(context);
configureKeyboardToolPaletteTool(context);
configureKeyboardControlTools(context);
configureElementNavigationTool(context);
configureFocusTrackerTool(context);
configureToastTool(context);
Expand Down
33 changes: 33 additions & 0 deletions packages/client/src/features/accessibility/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, hasStringProp } from '~glsp-sprotty';

export interface FocusDomAction extends Action {
kind: typeof FocusDomAction.KIND;
id: string;
}

export namespace FocusDomAction {
export const KIND = 'focusDomAction';

export function is(object: any): object is FocusDomAction {
return Action.hasKind(object, KIND) && hasStringProp(object, 'id');
}

export function create(id: string): FocusDomAction {
return { kind: KIND, id };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, hasObjectProp, hasStringProp } from '~glsp-sprotty';

export interface SetEdgeTargetSelectionAction extends Action {
kind: typeof SetEdgeTargetSelectionAction.KIND;
elementId: string;
context: string;
}

export namespace SetEdgeTargetSelectionAction {
export const KIND = 'setEdgeTargetSelectionAction';

export function is(object: any): object is SetEdgeTargetSelectionAction {
return Action.hasKind(object, KIND) && hasStringProp(object, 'elementId') && hasObjectProp(object, 'context');
}

export function create(elementId: string, context: string): SetEdgeTargetSelectionAction {
return { kind: KIND, elementId, context };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { TriggerEdgeCreationAction } from '~glsp-sprotty';

export interface EdgeAutocompleteContext {
role: 'source' | 'target';
trigger: TriggerEdgeCreationAction;
sourceId?: string;
targetId?: string;
}
Loading

0 comments on commit 9f38884

Please sign in to comment.