org.eclipse.swt.events.KeyListener Java Examples

The following examples show how to use org.eclipse.swt.events.KeyListener. 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: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private KeyListener createKeyListener() {
	return new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent event) {
			if (event.stateMask == 0) {
				if (event.keyCode == SWT.F5) {
					ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
					if (hierarchy != null) {
						fHierarchyLifeCycle.typeHierarchyChanged(hierarchy);
						doTypeHierarchyChangedOnViewers(null);
					}
					updateHierarchyViewer(false);
					return;
				}
				}
		}
	};
}
 
Example #2
Source File: MonthCalendar.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/** 
 * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
 */
public void keyReleased(KeyEvent e) {
	Day day = (Day) e.widget;
	Point coordinates = day.getMonthPosition();
	e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);

	for (Iterator<KeyListener> keyListenersIter = keyListeners.iterator(); keyListenersIter.hasNext();) {
		KeyListener listener = (KeyListener) keyListenersIter.next();
		listener.keyReleased(e);
	}

	// No need for this logic here yet, but leaving it commented
	// as a reminder...

	// if (!e.doit) return;
}
 
Example #3
Source File: FillViewer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * TODO summary sentence for createControl ...
 *
 * @param parent
 * @param kListener
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener kListener) {
	final Composite part = SimpleConfigurator.subpart(parent, "Fill:");

	this.on = new Button(part, SWT.CHECK);
	this.on.addSelectionListener(this.sync);

	this.chooser = new StolenColorEditor(part, this.sync);

	this.percent = new Combo(part, SWT.DROP_DOWN);
	this.percent.setItems(new String[] { "0%", "25%", "50%", "75%", "100%" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
	this.percent.setTextLimit(4);
	this.percent.addKeyListener(kListener);
	this.percent.setToolTipText("Fill opacity");
	return part;
}
 
Example #4
Source File: StrokeViewer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * TODO summary sentence for createControl ...
 *
 * @param parent
 * @param klisten
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener klisten) {
	final Composite part = SimpleConfigurator.subpart(parent, "Line");

	this.on = new Button(part, SWT.CHECK);

	this.chooser = new StolenColorEditor(part, this.sync);

	this.size = new Combo(part, SWT.DROP_DOWN);
	this.size.setItems(new String[] { "1", "2", "3", "5", "10" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
	this.size.setTextLimit(2);
	this.size.addKeyListener(klisten);
	this.size.setToolTipText("Line width");

	this.percent = new Combo(part, SWT.DROP_DOWN);
	this.percent.setItems(new String[] { "0%", "25%", "50%", "75%", "100%" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
	this.percent.setTextLimit(3);
	this.percent.addKeyListener(klisten);
	this.percent.setToolTipText("Line opacity");
	return part;
}
 
Example #5
Source File: GraphicViewer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * TODO summary sentence for createControl ...
 *
 * @param parent
 * @param klisten
 * @param build
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener klisten, final StyleBuilder build) {
	final Composite part = SimpleConfigurator.subpart(parent, "Point");

	this.on = new Button(part, SWT.CHECK);

	this.size = new Combo(part, SWT.DROP_DOWN);
	this.size.setItems(new String[] { "1", "2", "3", "5", "10", "15" });
	this.size.setTextLimit(2);
	this.size.addKeyListener(klisten);
	this.size.setToolTipText("Graphic size");

	this.name = new Combo(part, SWT.DROP_DOWN);
	this.name.setItems(build.getWellKnownMarkNames());
	this.name.setTextLimit(9);
	this.name.addKeyListener(klisten);
	this.name.setToolTipText("Shape type");
	return part;
}
 
Example #6
Source File: ContentAssistSubjectControlAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#removeKeyListener(org.eclipse.swt.events.KeyListener)
 */
public void removeKeyListener(KeyListener keyListener)
{
	if (fContentAssistSubjectControl != null)
	{
		fContentAssistSubjectControl.removeKeyListener(keyListener);
	}
	else
	{
		StyledText textWidget = fViewer.getTextWidget();
		
		if (Helper.okToUse(textWidget))
		{
			textWidget.removeKeyListener(keyListener);
		}
	}
}
 
Example #7
Source File: ContentAssistSubjectControlAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#addKeyListener(org.eclipse.swt.events.KeyListener)
 */
public void addKeyListener(KeyListener keyListener)
{
	if (fContentAssistSubjectControl != null)
	{
		fContentAssistSubjectControl.addKeyListener(keyListener);
	}
	else
	{
		fViewer.getTextWidget().addKeyListener(keyListener);
	}
}
 
Example #8
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
	typesViewer.getControl().setVisible(false);
	typesViewer.getControl().addKeyListener(keyListener);
	typesViewer.initContextMenu(new IMenuListener() {
		public void menuAboutToShow(IMenuManager menu) {
			fillTypesViewerContextMenu(typesViewer, menu);
		}
	}, cotextHelpId,	getSite());
	typesViewer.addPostSelectionChangedListener(fSelectionChangedListener);
	typesViewer.setQualifiedTypeName(isQualifiedTypeNamesEnabled());
	typesViewer.setWorkingSetFilter(fWorkingSetActionGroup.getWorkingSetFilter());
}
 
Example #9
Source File: RichTextEditor.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void removeKeyListener(KeyListener listener) {
	checkWidget();
	if (listener == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	this.keyListener.remove(listener);
}
 
Example #10
Source File: RichTextEditor.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addKeyListener(KeyListener listener) {
	checkWidget();
	if (listener == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	this.keyListener.add(listener);
}
 
Example #11
Source File: TimeSlice.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void removeKeyListener(KeyListener listener) {
	super.removeKeyListener(listener);
	for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
		TimeSlot cell = (TimeSlot) columnsIter.next();
		cell.removeKeyListener(listener);
	}
}
 
Example #12
Source File: TimeSlice.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void addKeyListener(KeyListener listener) {
	super.addKeyListener(listener);
	for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
		TimeSlot cell = (TimeSlot) columnsIter.next();
		cell.addKeyListener(listener);
	}
}
 
Example #13
Source File: DayEditor.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void keyReleased(KeyEvent e) {
	for (Iterator<KeyListener> i = keyListeners.iterator(); i.hasNext();) {
		KeyListener keyListener = i.next();
		keyListener.keyReleased(e);
		if (!e.doit)
			return;
	}
}
 
Example #14
Source File: ScrollView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Remove the local Listener and add the new listener.
 *
 * @param nlistener the new listener
 */
public void replaceKeyListener(KeyListener nlistener) {
    if (fLocalKeyListener != null) {
        removeKeyListener(fLocalKeyListener);
        fLocalKeyListener = null;
    }
    addKeyListener(nlistener);
}
 
Example #15
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void removeKeyListener(KeyListener listener) {
	// XXX: The workaround for JDK-8159227 requires that the typed key
	// listener, registered by the superclass, is ignored.
	if (listener.getClass().getName()
			.startsWith(FXCanvas.class.getName() + "$")) {
		superKeyListener = null;
	} else {
		super.removeKeyListener(listener);
	}
}
 
Example #16
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addKeyListener(KeyListener listener) {
	// XXX: The workaround for JDK-8159227 requires that the typed key
	// listener, registered by the superclass, is ignored.
	if (listener.getClass().getName()
			.startsWith(FXCanvas.class.getName() + "$")) {
		superKeyListener = listener;
	} else {
		super.addKeyListener(listener);
	}
}
 
Example #17
Source File: ChartComposite.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Hook an SWT listener on the canvas where the chart is drawn.
     * The purpose of this method is to allow some degree of customization.
     *
     * @param listener The SWT listener to attach to the canvas.
     */
    public void addSWTListener(EventListener listener) {
        if (listener instanceof ControlListener) {
            this.canvas.addControlListener((ControlListener) listener);
        }
        else if (listener instanceof DisposeListener) {
            this.canvas.addDisposeListener((DisposeListener) listener);
//      }
//      else if (listener instanceof DragDetectListener) {
//          this.canvas.addDragDetectListener((DragDetectListener) listener);
        }
        else if (listener instanceof FocusListener) {
            this.canvas.addFocusListener((FocusListener) listener);
        }
        else if (listener instanceof HelpListener) {
            this.canvas.addHelpListener((HelpListener) listener);
        }
        else if (listener instanceof KeyListener) {
            this.canvas.addKeyListener((KeyListener) listener);
//      }
//      else if (listener instanceof MenuDetectListener) {
//          this.canvas.addMenuDetectListener((MenuDetectListener) listener);
        }
        else if (listener instanceof MouseListener) {
            this.canvas.addMouseListener((MouseListener) listener);
        }
        else if (listener instanceof MouseMoveListener) {
            this.canvas.addMouseMoveListener((MouseMoveListener) listener);
        }
        else if (listener instanceof MouseTrackListener) {
            this.canvas.addMouseTrackListener((MouseTrackListener) listener);
//      } else if (listener instanceof MouseWheelListener) {
//          this.canvas.addMouseWheelListener((MouseWheelListener) listener);
        }
        else if (listener instanceof PaintListener) {
            this.canvas.addPaintListener((PaintListener) listener);
        }
        else if (listener instanceof TraverseListener) {
            this.canvas.addTraverseListener((TraverseListener) listener);
        }
    }
 
Example #18
Source File: CheckBoxVar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void addKeyListener( KeyListener lsKey ) {
  wBox.addKeyListener( lsKey );
}
 
Example #19
Source File: ElexisText.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void removeKeyListener(KeyListener listener){
	text.removeKeyListener(listener);
}
 
Example #20
Source File: ElexisText.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void addKeyListener(KeyListener listener){
	text.addKeyListener(listener);
}
 
Example #21
Source File: WarningText.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void addKeyListener( KeyListener lsKey ) {
  wText.addKeyListener( lsKey );
}
 
Example #22
Source File: ComboVar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void addKeyListener( KeyListener lsKey ) {
  wCombo.addKeyListener( lsKey );
}
 
Example #23
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Hook an SWT listener on the canvas where the chart is drawn.
     * The purpose of this method is to allow some degree of customization.
     *
     * @param listener The SWT listener to attach to the canvas.
     */
    public void addSWTListener(EventListener listener) {
        if (listener instanceof ControlListener) {
            this.canvas.addControlListener((ControlListener) listener);
        }
        else if (listener instanceof DisposeListener) {
            this.canvas.addDisposeListener((DisposeListener) listener);
//      }
//      else if (listener instanceof DragDetectListener) {
//          this.canvas.addDragDetectListener((DragDetectListener) listener);
        }
        else if (listener instanceof FocusListener) {
            this.canvas.addFocusListener((FocusListener) listener);
        }
        else if (listener instanceof HelpListener) {
            this.canvas.addHelpListener((HelpListener) listener);
        }
        else if (listener instanceof KeyListener) {
            this.canvas.addKeyListener((KeyListener) listener);
//      }
//      else if (listener instanceof MenuDetectListener) {
//          this.canvas.addMenuDetectListener((MenuDetectListener) listener);
        }
        else if (listener instanceof MouseListener) {
            this.canvas.addMouseListener((MouseListener) listener);
        }
        else if (listener instanceof MouseMoveListener) {
            this.canvas.addMouseMoveListener((MouseMoveListener) listener);
        }
        else if (listener instanceof MouseTrackListener) {
            this.canvas.addMouseTrackListener((MouseTrackListener) listener);
//      } else if (listener instanceof MouseWheelListener) {
//          this.canvas.addMouseWheelListener((MouseWheelListener) listener);
        }
        else if (listener instanceof PaintListener) {
            this.canvas.addPaintListener((PaintListener) listener);
        }
        else if (listener instanceof TraverseListener) {
            this.canvas.addTraverseListener((TraverseListener) listener);
        }
    }
 
Example #24
Source File: TextVar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void addKeyListener( KeyListener lsKey ) {
  wText.addKeyListener( lsKey );
}
 
Example #25
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private Control createTypeViewerControl(Composite parent) {
	fViewerbook= new PageBook(parent, SWT.NULL);

	KeyListener keyListener= createKeyListener();

	// Create the viewers
	TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle);
	initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);

	TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle);
	initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);

	TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle);
	initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);

	fAllViewers= new TypeHierarchyViewer[3];
	fAllViewers[HIERARCHY_MODE_SUPERTYPES]= superTypesViewer;
	fAllViewers[HIERARCHY_MODE_SUBTYPES]= subTypesViewer;
	fAllViewers[HIERARCHY_MODE_CLASSIC]= vajViewer;

	int currViewerIndex;
	try {
		currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
		if (currViewerIndex < 0 || currViewerIndex > 2) {
			currViewerIndex= HIERARCHY_MODE_CLASSIC;
		}
	} catch (NumberFormatException e) {
		currViewerIndex= HIERARCHY_MODE_CLASSIC;
	}

	fEmptyTypesViewer= new Label(fViewerbook, SWT.TOP | SWT.LEFT | SWT.WRAP);

	for (int i= 0; i < fAllViewers.length; i++) {
		fAllViewers[i].setInput(fAllViewers[i]);
	}

	// force the update
	fCurrentViewerIndex= -1;
	setHierarchyMode(currViewerIndex);

	return fViewerbook;
}
 
Example #26
Source File: CallHierarchyViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
void addKeyListener(KeyListener keyListener) {
    getControl().addKeyListener(keyListener);
}
 
Example #27
Source File: TmfVirtualTable.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Method addKeyListener.
 * @param listener KeyListener
 */
@Override
public void addKeyListener(KeyListener listener) {
    fTable.addKeyListener(listener);
}
 
Example #28
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
     * Hook an SWT listener on the canvas where the chart is drawn.
     * The purpose of this method is to allow some degree of customization.
     *
     * @param listener The SWT listener to attach to the canvas.
     */
    public void addSWTListener(EventListener listener) {
        if (listener instanceof ControlListener) {
            this.canvas.addControlListener((ControlListener) listener);
        }
        else if (listener instanceof DisposeListener) {
            this.canvas.addDisposeListener((DisposeListener) listener);
//      }
//      else if (listener instanceof DragDetectListener) {
//          this.canvas.addDragDetectListener((DragDetectListener) listener);
        }
        else if (listener instanceof FocusListener) {
            this.canvas.addFocusListener((FocusListener) listener);
        }
        else if (listener instanceof HelpListener) {
            this.canvas.addHelpListener((HelpListener) listener);
        }
        else if (listener instanceof KeyListener) {
            this.canvas.addKeyListener((KeyListener) listener);
//      }
//      else if (listener instanceof MenuDetectListener) {
//          this.canvas.addMenuDetectListener((MenuDetectListener) listener);
        }
        else if (listener instanceof MouseListener) {
            this.canvas.addMouseListener((MouseListener) listener);
        }
        else if (listener instanceof MouseMoveListener) {
            this.canvas.addMouseMoveListener((MouseMoveListener) listener);
        }
        else if (listener instanceof MouseTrackListener) {
            this.canvas.addMouseTrackListener((MouseTrackListener) listener);
//      } else if (listener instanceof MouseWheelListener) {
//          this.canvas.addMouseWheelListener((MouseWheelListener) listener);
        }
        else if (listener instanceof PaintListener) {
            this.canvas.addPaintListener((PaintListener) listener);
        }
        else if (listener instanceof TraverseListener) {
            this.canvas.addTraverseListener((TraverseListener) listener);
        }
    }
 
Example #29
Source File: ReferenceSearchViewPage.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	pagebook = new PageBook(parent, SWT.NULL);
	pagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
	busyLabel = new Table(pagebook, SWT.NONE);
	TableItem item = new TableItem(busyLabel, SWT.NONE);
	item.setText(Messages.ReferenceSearchViewPage_busyLabel);
	busyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	control = new Composite(pagebook, SWT.NULL);
	control.setLayoutData(new GridData(GridData.FILL_BOTH));
	control.setSize(100, 100);
	control.setLayout(new FillLayout());
	viewer = new TreeViewer(control, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(contentProvider);
	viewer.setLabelProvider(labelProvider);
	viewer.setComparator(sorter);
	createOpenAndLinkWithEditorHandler();
	IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
	fillToolbar(tbm);
	tbm.update(true);
	pagebook.showPage(control);
	isBusyShowing = false;
	queryListener = createQueryListener();
	NewSearchUI.addQueryListener(queryListener);

	menu = new MenuManager("#PopUp"); //$NON-NLS-1$
	menu.setRemoveAllWhenShown(true);
	menu.setParent(getSite().getActionBars().getMenuManager());
	menu.addMenuListener(mgr -> {
		fillContextMenu(mgr);
		part.fillContextMenu(mgr);
	});

	viewer.getControl().setMenu(menu.createContextMenu(viewer.getControl()));
	viewer.getControl().addKeyListener(KeyListener.keyPressedAdapter(e -> {
		if (e.keyCode == SWT.DEL) {
			removeSelectedMatchesAction.run();
		} else if ((e.stateMask | SWT.COMMAND) != 0 && e.keyCode == 'c') {
			copyAction.run();
		}
	}));
}
 
Example #30
Source File: ChartComposite.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Hook an SWT listener on the canvas where the chart is drawn.
     * The purpose of this method is to allow some degree of customization.
     *
     * @param listener The SWT listener to attach to the canvas.
     */
    public void addSWTListener(EventListener listener) {
        if (listener instanceof ControlListener) {
            this.canvas.addControlListener((ControlListener) listener);
        }
        else if (listener instanceof DisposeListener) {
            this.canvas.addDisposeListener((DisposeListener) listener);
//      }
//      else if (listener instanceof DragDetectListener) {
//          this.canvas.addDragDetectListener((DragDetectListener) listener);
        }
        else if (listener instanceof FocusListener) {
            this.canvas.addFocusListener((FocusListener) listener);
        }
        else if (listener instanceof HelpListener) {
            this.canvas.addHelpListener((HelpListener) listener);
        }
        else if (listener instanceof KeyListener) {
            this.canvas.addKeyListener((KeyListener) listener);
//      }
//      else if (listener instanceof MenuDetectListener) {
//          this.canvas.addMenuDetectListener((MenuDetectListener) listener);
        }
        else if (listener instanceof MouseListener) {
            this.canvas.addMouseListener((MouseListener) listener);
        }
        else if (listener instanceof MouseMoveListener) {
            this.canvas.addMouseMoveListener((MouseMoveListener) listener);
        }
        else if (listener instanceof MouseTrackListener) {
            this.canvas.addMouseTrackListener((MouseTrackListener) listener);
//      } else if (listener instanceof MouseWheelListener) {
//          this.canvas.addMouseWheelListener((MouseWheelListener) listener);
        }
        else if (listener instanceof PaintListener) {
            this.canvas.addPaintListener((PaintListener) listener);
        }
        else if (listener instanceof TraverseListener) {
            this.canvas.addTraverseListener((TraverseListener) listener);
        }
    }