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

The following examples show how to use org.eclipse.swt.SWT#F2 . 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: FileViewerWindow.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The toolbar command handler contains the global toolbar
 * actions. The intent is that the listener is then added to 
 * multiple visual components.
 */
public Listener createToolbarCommandHandler() {
	return new Listener() {
		public void handleEvent(Event event) {
			if (event.type == SWT.KeyUp) {
				if ((event.stateMask & SWT.CTRL) != 0) {	// CTRL+key
					switch (event.character) {
						case CTRL_C:
							getContentTypeAdapter().copy();
							break;
						case CTRL_A:
							getContentTypeAdapter().selectAll();
							break;
						case CTRL_P:
							getContentTypeAdapter().print();
							break;
					}
				} else if ((event.stateMask & SWT.ALT) == 0) { // key alone
					switch (event.keyCode) {
						case SWT.F2:	// the "native" file format (image, text, etc)
							getNativeFilterAdapter().display();
							setFilterToolItemSelection(true, false, false);
							break;
						case SWT.F3:	// Hex format
							getHexFilterAdapter().display();
							setFilterToolItemSelection(false, true, false);
							break;
						case SWT.F4:	// "Raw" hex format
							getRawDumpFilterAdapter().display();
							setFilterToolItemSelection(false, false, true);
							break;
					}
				}
			}
		}
	};
}
 
Example 2
Source File: SBC_TagsOverview.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (e.keyCode == SWT.F2 && (e.stateMask & SWT.MODIFIER_MASK) == 0) {
		Object[] selectedDataSources = tv.getSelectedDataSources(true);
		if (selectedDataSources.length == 1 && (selectedDataSources[0] instanceof Tag)) {
			Tag tag = (Tag) selectedDataSources[0];
			if (!tag.getTagType().isTagTypeAuto()) {
				TagUIUtils.openRenameTagDialog(tag);
				e.doit = false;
			}
		}
	}
}
 
Example 3
Source File: FilesView.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (e.keyCode == SWT.F2 && (e.stateMask & SWT.MODIFIER_MASK) == 0) {
		FilesViewMenuUtil.rename(tv, tv.getSelectedDataSources(true), true, false,false);
		e.doit = false;
	}
}
 
Example 4
Source File: RefactorActionProvider.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void handleKeyPressed(final KeyEvent event) {
	if (event.keyCode == SWT.F2 && event.stateMask == 0) {
		if (renameAction.isEnabled()) {
			renameAction.run();
		}
		// Swallow the event.
		event.doit = false;
	}
}
 
Example 5
Source File: RefactorActionGroup.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles a key pressed event by invoking the appropriate action.
 * 
 * @param event
 *            The Key Event
 */
public void handleKeyPressed(KeyEvent event) {

	if (event.keyCode == SWT.F2 && event.stateMask == 0) {
		if (renameAction.isEnabled()) {
			renameAction.run();
		}

		// Swallow the event.
		event.doit = false;
	}
}
 
Example 6
Source File: RefactorActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles a key pressed event by invoking the appropriate action.
 * 
 * @param event
 *            The Key Event
 */
public void handleKeyPressed(KeyEvent event) {

	if (event.keyCode == SWT.F2 && event.stateMask == 0) {
		if (renameAction.isEnabled()) {
			renameAction.run();
		}

		// Swallow the event.
		event.doit = false;
	}
}
 
Example 7
Source File: RenameListener.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void keyReleased( KeyEvent e )
{
	cancelTimer( );
	if ( e.keyCode == SWT.F2 && e.stateMask == 0 )
	{
		if ( selectedItem != null )
		{
			RenameAction action = new RenameAction( sourceViewer );
			if ( action.isEnabled( ) && action.isHandled( ) )
				action.run( );
		}
	}
}
 
Example 8
Source File: GuiMenuWidgets.java    From hop with Apache License 2.0 4 votes vote down vote up
public static String getShortcutString( KeyboardShortcut shortcut ) {
  String s = shortcut.toString();
  if ( StringUtils.isEmpty( s ) || s.endsWith( "-" ) ) {
    // Unknown characters from the SWT library
    // We'll handle the special cases here.
    //
    int keyCode = shortcut.getKeyCode();
    if ( keyCode == SWT.BS ) {
      return s + "Backspace";
    }
    if ( keyCode == SWT.ESC ) {
      return s + "Esc";
    }
    if ( keyCode == SWT.ARROW_LEFT ) {
      return s + "LEFT";
    }
    if ( keyCode == SWT.ARROW_RIGHT ) {
      return s + "RIGHT";
    }
    if ( keyCode == SWT.ARROW_UP ) {
      return s + "UP";
    }
    if ( keyCode == SWT.ARROW_DOWN ) {
      return s + "DOWN";
    }
    if ( keyCode == SWT.HOME ) {
      return s + "HOME";
    }
    if ( keyCode == SWT.F1 ) {
      return s + "F1";
    }
    if ( keyCode == SWT.F2 ) {
      return s + "F2";
    }
    if ( keyCode == SWT.F3 ) {
      return s + "F3";
    }
    if ( keyCode == SWT.F4 ) {
      return s + "F4";
    }
    if ( keyCode == SWT.F5 ) {
      return s + "F5";
    }
    if ( keyCode == SWT.F6 ) {
      return s + "F6";
    }
    if ( keyCode == SWT.F7 ) {
      return s + "F7";
    }
    if ( keyCode == SWT.F8 ) {
      return s + "F8";
    }
    if ( keyCode == SWT.F9 ) {
      return s + "F9";
    }
    if ( keyCode == SWT.F10 ) {
      return s + "F10";
    }
    if ( keyCode == SWT.F11 ) {
      return s + "F11";
    }
    if ( keyCode == SWT.F12 ) {
      return s + "F12";
    }
  }
  return s;
}
 
Example 9
Source File: JaretTable.java    From translationstudio8 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 10
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;
            }
        }

    }