Java Code Examples for org.eclipse.swt.SWT#SHIFT

The following examples show how to use org.eclipse.swt.SWT#SHIFT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeGraphTooltipHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void fill(Control control, MouseEvent event, Point pt) {
    TimeGraphControl timeGraphControl = (TimeGraphControl) control;
    if ((event.stateMask & SWT.MODIFIER_MASK) != SWT.SHIFT) {
        ILinkEvent linkEvent = timeGraphControl.getArrow(pt);
        if (linkEvent != null) {
            fillValues(linkEvent);
        }
    }
    if (getTipComposite().getChildren().length == 0) {
        ITimeGraphEntry entry = timeGraphControl.getEntry(pt);
        if (entry == null) {
            return;
        }
        fillValues(pt, timeGraphControl, entry);
        Iterable<IMarkerEvent> markers = getMarkers(timeGraphControl, entry, pt);
        int i = 0;
        for (IMarkerEvent marker : markers) {
            fillValues(MARKER_CATEGORY_PREFIX + i, marker);
            i++;
        }
    }
}
 
Example 2
Source File: GuiMenuWidgets.java    From hop with Apache License 2.0 6 votes vote down vote up
public static int getAccelerator( KeyboardShortcut shortcut ) {
  int a = 0;
  a += shortcut.getKeyCode();
  if ( shortcut.isControl() ) {
    a += SWT.CONTROL;
  }
  if ( shortcut.isShift() ) {
    a += SWT.SHIFT;
  }
  if ( shortcut.isAlt() ) {
    a += SWT.ALT;
  }
  if ( shortcut.isCommand() ) {
    a += SWT.COMMAND;
  }
  return a;
}
 
Example 3
Source File: PeerCharacterCloser.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private boolean isModifierKey(int keyCode)
{
	// TODO Add more non alphanumeric keys we should skip!
	switch (keyCode)
	{
		case SWT.SHIFT:
		case SWT.BS:
		case SWT.CR:
		case SWT.DEL:
		case SWT.ESC:
		case SWT.LF:
		case SWT.TAB:
		case SWT.CTRL:
		case SWT.COMMAND:
		case SWT.ALT:
		case SWT.ARROW_DOWN:
		case SWT.ARROW_LEFT:
		case SWT.ARROW_RIGHT:
		case SWT.ARROW_UP:
			return true;
	}
	return false;
}
 
Example 4
Source File: PyAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the modifier string for the given SWT modifier
 * modifier bits.
 *
 * @param stateMask the SWT modifier bits
 * @return the modifier string
 */
public static String getModifierString(int stateMask) {
    String modifierString = ""; //$NON-NLS-1$
    if ((stateMask & SWT.CTRL) == SWT.CTRL) {
        modifierString = appendModifierString(modifierString, SWT.CTRL);
    }
    if ((stateMask & SWT.ALT) == SWT.ALT) {
        modifierString = appendModifierString(modifierString, SWT.ALT);
    }
    if ((stateMask & SWT.SHIFT) == SWT.SHIFT) {
        modifierString = appendModifierString(modifierString, SWT.SHIFT);
    }
    if ((stateMask & SWT.COMMAND) == SWT.COMMAND) {
        modifierString = appendModifierString(modifierString, SWT.COMMAND);
    }

    return modifierString;
}
 
Example 5
Source File: SceneGrip.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
public void keyReleased(KeyEvent e) {
  switch (e.keyCode) {
    case SWT.SHIFT:
      this.keyShiftState = false;
      break;
    case SWT.CTRL:
      this.keyCtrlState = false;
      break;
    case SWT.ALT:
      this.keyAltState = false;
      break;
    default:
      break;
  }
}
 
Example 6
Source File: XViewerMultiEditAdapter.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
boolean handleEditEvent(Event event) {
   IStructuredSelection temp = (IStructuredSelection) xv.getSelection();
   oldSelection = currentSelection;
   currentSelection = temp;

   if (oldSelection == null || oldSelection.toList().size() == 1 || !oldSelection.toList().contains(
      currentSelection.getFirstElement())) {
      oldSelection = null;
   }

   if ((event.stateMask & SWT.CTRL) == SWT.CTRL || (event.stateMask & SWT.SHIFT) == SWT.SHIFT) {
      return false;
   }
   boolean handled = super.handleEditEvent(event);

   if (handled && oldSelection != null) {
      xv.setSelection(oldSelection);
      currentSelection = oldSelection;
   }
   return handled;
}
 
Example 7
Source File: GraphCanvas.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
protected void onClick(MouseEvent event) {
	// update selection
	final Node mNode = getNodeAt(event.x, event.y);
	final boolean shiftPressed = (event.stateMask & SWT.SHIFT) != 0;
	if (!shiftPressed) {
		if (mNode == null) {
			clearSelection();
		} else {
			setSelectedNodes(mNode);
		}
	} else {
		if (mNode == null) {
			// do nothing
		} else {
			toggleSelection(mNode);
		}
	}
}
 
Example 8
Source File: KeyHandlerMinibuffer.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
private KeyStroke getKey(int state, int keyCode,int character) {
	int result = keyCode;
	if (state ==0 && keys.size() == 0) {
		result = keyCode;
	} else if (state == SWT.SHIFT) {
		// handle characters with different shift values
		state = 0;
		result = character;
	} else {
		result = Character.toUpperCase(keyCode);  
	}
	return KeyStroke.getInstance(state,result);
}
 
Example 9
Source File: MouseEditAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void run(NatTable natTable, MouseEvent event) {
	int columnPosition = natTable.getColumnPositionByX(event.x);
	int rowPosition = natTable.getRowPositionByY(event.y);

	boolean withShiftMask = (event.stateMask & SWT.SHIFT) != 0;
	boolean withCtrlMask = (event.stateMask & SWT.CTRL) != 0;

	natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));

	natTable.doCommand(
			new EditCellCommand(
					natTable,
					natTable.getConfigRegistry(),
					natTable.getCellByPosition(columnPosition, rowPosition)));
}
 
Example 10
Source File: MouseEditAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void run(NatTable natTable, MouseEvent event) {
	int columnPosition = natTable.getColumnPositionByX(event.x);
	int rowPosition = natTable.getRowPositionByY(event.y);

	boolean withShiftMask = (event.stateMask & SWT.SHIFT) != 0;
	boolean withCtrlMask = (event.stateMask & SWT.CTRL) != 0;
	natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
	if(columnPosition == 1 || columnPosition == 2){
		natTable.doCommand(new EditCellCommand(null, null, null));
	} else {
		TeActiveCellEditor.commit();
	}
}
 
Example 11
Source File: MovablePanningSelectionTool.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean handleKeyUp(KeyEvent event) {
	if (event.keyCode == SWT.SHIFT) {
		shift = true;
	}

	return super.handleKeyUp(event);
}
 
Example 12
Source File: TableCellKeyDelegate.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
boolean acceptScroll( KeyEvent event )
{
	return ( ( event.stateMask & SWT.CTRL ) != 0
			&& ( event.stateMask & SWT.SHIFT ) != 0 && ( event.keyCode == SWT.ARROW_DOWN
			|| event.keyCode == SWT.ARROW_LEFT
			|| event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP ) );
}
 
Example 13
Source File: BrowseKillRingHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.execute.IEmacsPlusConsoleKey#handleKey(org.eclipse.swt.events.VerifyEvent, org.eclipse.ui.console.TextConsoleViewer)
 */
public void handleKey(VerifyEvent event, TextConsoleViewer viewer) {

	// mask away any extraneous modifier characters for any direct equality tests. see SWT.MODIFIER_MASK
	int sm = event.stateMask & SWT.MODIFIER_MASK;
	if (viewer != null && (sm == 0 || sm == SWT.SHIFT)) {// && 'i' == event.character) {
		int offset;
		boolean reactivate = false;
		switch (event.character){
		case 'i':	// insert
		case 'y':
		case ' ':
			reactivate = true;
		case '\r':
		case '\n':
			event.doit = false;
			offset = getLineOffset(viewer);
			if (offset >= 0) {
				KilledText kill = offsetHash.get(offset);
				if (kill != null) {
					insertFromBrowseRing(kill.text);
				}
			}
			if (reactivate) {
				EmacsPlusConsole.getInstance().setFocus(false);
			}
			break;
		case 'n':	// next
			event.doit = false;
			browseRing(viewer,FORWARD);
			break;
		case 'p':	// previous
			event.doit = false;
			browseRing(viewer,BACKWARD);
			break;
		case 'g':	// refresh
			event.doit = false;
			updateBrowseRing();
			break;
		case 'q':	// quit
			activateEditor();
			break;
		case 'U':	// undo
			event.doit = false;
			undoEditor();
			break;
		}
	}
}
 
Example 14
Source File: AbstractKeySelectAction.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void run(NatTable natTable, KeyEvent event) {
	if (!isStateMaskSpecified) {
		this.shiftMask = (event.stateMask & SWT.SHIFT) != 0;
		this.controlMask = (event.stateMask & SWT.CTRL) != 0;
	}
}
 
Example 15
Source File: TimeGraphMarkerAxis.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Handle a mouseDown event.
 *
 * @param e
 *            the mouse event
 * @param bounds
 *            the bounds of the marker axis in the mouse event's coordinates
 * @param nameSpace
 *            the width of the marker name area
 */
public void mouseDown(MouseEvent e, Rectangle bounds, int nameSpace) {
    if (bounds.isEmpty()) {
        return;
    }
    if (fCollapsed || (e.x < bounds.x + Math.min(nameSpace, EXPANDED.getBounds().width))) {
        fCollapsed = !fCollapsed;
        getParent().layout();
        redraw();
        return;
    }
    if (e.x < bounds.x + nameSpace) {
        String category = getHiddenCategoryForEvent(e, bounds);
        if (category != null) {
            for (IMarkerAxisListener listener : fListeners) {
                listener.setMarkerCategoryVisible(category, false);
            }
        }
        return;
    }
    IMarkerEvent marker = getMarkerForEvent(e);
    if (marker != null) {
        if ((e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
            /* Extend current selection */
            long selectionBegin = fTimeProvider.getSelectionBegin();
            long selectionEnd = fTimeProvider.getSelectionEnd();
            long markerBegin = marker.getTime();
            long markerEnd = marker.getTime() + marker.getDuration();
            /* If marker end is outside selection, extend closest boundary */
            if (((markerEnd - selectionBegin) > 0) == ((markerEnd - selectionEnd) > 0)) {
                if (Math.abs(markerEnd - selectionBegin) < Math.abs(markerEnd - selectionEnd)) {
                    selectionBegin = markerEnd;
                } else {
                    selectionEnd = markerEnd;
                }
            }
            /* If marker begin is outside selection, extend closest boundary */
            if (((markerBegin - selectionBegin) > 0) == ((markerBegin - selectionEnd) > 0)) {
                if (Math.abs(markerBegin - selectionBegin) < Math.abs(markerBegin - selectionEnd)) {
                    selectionBegin = markerBegin;
                } else {
                    selectionEnd = markerBegin;
                }
            }
            fTimeProvider.setSelectionRangeNotify(selectionBegin, selectionEnd, false);
        } else {
            /* Replace current selection */
            fTimeProvider.setSelectionRangeNotify(marker.getTime(), marker.getTime() + marker.getDuration(), false);
        }
    }
}
 
Example 16
Source File: JaretTable.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Handle any key presses.
     * 
     * @param event key event
     */
    private void handleKeyPressed(KeyEvent event) {
        if ((event.stateMask & SWT.SHIFT) != 0 && Character.isISOControl(event.character)) {
            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                selectRight();
                break;
            case SWT.ARROW_LEFT:
                selectLeft();
                break;
            case SWT.ARROW_DOWN:
                selectDown();
                break;
            case SWT.ARROW_UP:
                selectUp();
                break;

            default:
                // do nothing
                break;
            }
        } else if ((event.stateMask & SWT.CONTROL) != 0 && Character.isISOControl(event.character)) {
            // TODO keybindings hard coded is ok for now
            // System.out.println("keycode "+event.keyCode);
            switch (event.keyCode) {
            case 'c':
                copy();
                break;
            case 'x':
                cut();
                break;
            case 'v':
                paste();
                break;
            case 'a':
                selectAll();
                break;

            default:
                // do nothing
                break;
            }

        } else {
            _lastKeySelect = null;
            _firstKeySelect = null;

            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                focusRight();
                break;
            case SWT.ARROW_LEFT:
                focusLeft();
                break;
            case SWT.ARROW_DOWN:
                focusDown();
                break;
            case SWT.ARROW_UP:
                focusUp();
                break;
            case SWT.TAB:
                focusRight();
                break;
            case SWT.F2:
//                startEditing(_focussedRow, _focussedColumn, (char) 0);
                break;

            default:
                if (event.character == ' ' && isHierarchyColumn(_focussedRow, _focussedColumn)) {
                    toggleExpanded(_focussedRow);
                } else if (!Character.isISOControl(event.character)) {
//                    startEditing(event.character);
                }
                // do nothing
                break;
            }
        }

    }
 
Example 17
Source File: CTree.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
protected void handleMouseEvents(Event event) {
		CTreeItem item = null;
		if (event.widget == body) {
			item = getItem(event.x, event.y);
		} else if (event.item instanceof CTreeItem) {
			item = (CTreeItem) event.item;
		}
		
		switch (event.type) {
		case SWT.MouseDoubleClick:
			if(item != null && (selectOnToggle || !item.isToggle(event.x, event.y))) {
				fireSelectionEvent(true);
			}
			break;
		case SWT.MouseDown:
			if(!hasFocus) setFocus();
			if(item == null) {
				if(event.widget == body) {
					item = getItem(event.x, event.y);
				} else if(event.item instanceof CTreeItem) {
					item = (CTreeItem) event.item;
				}
			}
			switch(event.button) {
			// TODO - popup menu: not just for mouse down events!
			case 3:
				Menu menu = getMenu();
				if ((menu != null) && ((menu.getStyle() & SWT.POP_UP) != 0)) {
					menu.setVisible(true);
				}
			case 1:
				if(selectOnToggle || !item.isToggle(event.x, event.y)) {
					if(selectOnTreeToggle || !item.isTreeToggle(event.x,event.y)) {
						if((event.stateMask & SWT.SHIFT) != 0) {
							if(shiftSel == null) {
								if(selection.isEmpty()) selection.add(item);
								shiftSel = (CTreeItem) selection.get(selection.size() - 1);
							}
							setSelection(shiftSel, item);
						} else if((event.stateMask & SWT.CONTROL) != 0) {
							toggleSelection(item);
							shiftSel = null;
						} else {
							setSelection(item);
							shiftSel = null;
						}
					}
				}
				break;
			}
			break;
		case SWT.MouseMove:
			// TODO: make toggles more dynamic
			break;
		case SWT.MouseUp:
			if(item.isToggle(event.x,event.y)) {
				boolean open = item.isOpen(event.x,event.y);
				if(item.isTreeToggle(event.x,event.y)) {
//					visibleItems = null;
					item.setExpanded(!open);
					fireTreeEvent(item, !open);
				} else {
					item.getCell(event.x, event.y).setOpen(!open);
				}
			}
			break;
		}

	}
 
Example 18
Source File: ColumnReorderDragMode.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected void selectDragFocusColumn(ILayer natLayer, MouseEvent event, int focusedColumnPosition) {
	boolean shiftMask = (SWT.SHIFT & event.stateMask) != 0;
	boolean controlMask = (SWT.CONTROL & event.stateMask) != 0;

	natLayer.doCommand(new ViewportSelectColumnCommand(natLayer, focusedColumnPosition, shiftMask, controlMask));
}
 
Example 19
Source File: AbstractKeySelectAction.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void run(NatTable natTable, KeyEvent event) {
	if (!isStateMaskSpecified) {
		this.shiftMask = (event.stateMask & SWT.SHIFT) != 0;
		this.controlMask = (event.stateMask & SWT.CTRL) != 0;
	}
}
 
Example 20
Source File: KbdMacroExecuteHandler.java    From e4macs with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Check if this is one of the manually CTRL/ALT/Command/Shift keys from the .post call above
 * keyCode is a simple state key and is included in contained event's stateMask
 * 
 * @param keyCode from the verify key event
 * @return true if it is ours
 */
private boolean isSpecial(int keyCode) {
	return (((keyCode == SWT.ALT ) || (keyCode == SWT.COMMAND ) || (keyCode == SWT.CTRL) || (keyCode == SWT.SHIFT)) && ((keyCode & stateMask) != 0));
}