Java 类org.eclipse.swt.events.KeyListener 实例源码

项目:gama    文件:FillViewer.java   
/**
 * TODO summary sentence for createControl ...
 * 
 * @param parent
 * @param kListener
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener kListener) {
    final Composite part = AbstractSimpleConfigurator.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;
}
项目:gama    文件:ScaleViewer.java   
/**
 * TODO summary sentence for createControl ...
 * 
 * @param parent
 * @param kListener
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener kListener) {
    final String labelId = type == MIN ? "Min scale:" : "Max scale:";
    final Composite part = AbstractSimpleConfigurator.subpart(parent, labelId);

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

    this.scaleEditor = new Combo(part, SWT.DROP_DOWN);
    this.scaleEditor.setItems(new String[] { "100", "1000", "10000", "100000", "1000000", "10000000" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    this.scaleEditor.setTextLimit(10);
    this.scaleEditor.addKeyListener(kListener);
    final String tooltip = type == MIN ? "Minimum scale denominator" : "Maximum scale denominator";
    this.scaleEditor.setToolTipText(tooltip);
    return part;
}
项目:gama    文件:StrokeViewer.java   
/**
 * TODO summary sentence for createControl ...
 * 
 * @param parent
 * @param klisten
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener klisten) {
    final Composite part = AbstractSimpleConfigurator.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;
}
项目:gama    文件:GraphicViewer.java   
/**
 * 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 = AbstractSimpleConfigurator.subpart(parent, "Point");

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

    this.size = new Combo(part, SWT.DROP_DOWN);
    this.size.setItems(new String[] { "1", "2", "3", "5", "10", "15" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    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;
}
项目:APICloud-Studio    文件:ContentAssistSubjectControlAdapter.java   
/**
 * @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);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
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;
                }
                }
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeHierarchyViewPart.java   
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;
                }
                }
        }
    };
}
项目:NK-VirtualGlobe    文件:SWTDeviceFactory.java   
/**
 * Return the array of DeviceManagers that are available per the
 * constructor parameters. The InputDevices instantiated will be
 * initialized with SWT UI toolkit event listeners.
 *
 * @return the array of DeviceManagers. If no DeviceManagers are
 * available, an empty (size 0) array is returned.
 */
public DeviceManager[] getDeviceManagers( ) {
    List managerList = createDevices( );
    DeviceManager[] manager =
        (DeviceManager[])managerList.toArray( new DeviceManager[managerList.size( )] );
    Control control = (Control)canvas;
    for ( int i = 0; i < manager.length; i++ ) {
        InputDevice[] device = manager[i].getDevices( );
        for ( int j = 0; j < device.length; j++ ) {
            InputDevice dev = device[j];
            if ( dev instanceof MouseListener ) {
                control.addMouseListener( (MouseListener)dev );
            }
            if ( dev instanceof MouseMoveListener ) {
                control.addMouseMoveListener( (MouseMoveListener)dev );
            }
            if ( dev instanceof Listener ) {
                control.addListener( SWT.MouseWheel, (Listener)dev );
            }
            if ( dev instanceof KeyListener ) {
                control.addKeyListener( (KeyListener)dev );
            }
        }
    }
    return( manager );
}
项目:rxswt    文件:SwtObservers.java   
public static Observable<KeyEvent> fromKeyListener(Control control) {
    Observable<KeyEvent> observable = Observable.create(subscriber -> {
        KeyListener keyListener = new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                subscriber.onNext(e);
            }
        };
        control.addKeyListener(keyListener);
        subscriber.setDisposable(Disposables.fromAction(() -> control.removeKeyListener(keyListener)));
    });
    return wrap(control, observable);
}
项目:PDFReporter-Studio    文件:I18NEntry.java   
@Override
KeyListener getKeyListener() {
    return new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            // Text field has changed: make editor dirty if not already
            if (!BabelUtils.equals(focusGainedText, textBox.getText())) {
                // Make the editor dirty if not already. If it is,
                // we wait until field focus lost (or save) to
                // update it completely.
                if (!editor.isDirty()) {
                    // textEditor.isDirty();
                    updateModel();
                    // int caretPosition = eventBox.getCaretPosition();
                    // updateBundleOnChanges();
                    // eventBox.setSelection(caretPosition);
                }
                // autoDetectRequiredFont(eventBox.getText());
            }
        }
    };
    // Eric Fettweis : new listener to automatically change the font
    // textBox.addModifyListener(new ModifyListener() {
    //
    // public void modifyText(ModifyEvent e) {
    // String text = textBox.getText();
    // Font f = textBox.getFont();
    // String fontName = getBestFont(f.getFontData()[0].getName(), text);
    // if(fontName!=null){
    // f = getSWTFont(f, fontName);
    // textBox.setFont(f);
    // }
    // }
    //
    // });
    // }
}
项目:gama    文件:OpacityViewer.java   
/**
 * TODO summary sentence for createControl ...
 * 
 * @param parent
 * @param listener1
 * @return Generated composite
 */
public Composite createControl(final Composite parent, final KeyListener listener1) {
    final Composite part = AbstractSimpleConfigurator.subpart(parent, "Raster");

    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(listener1);
    this.percent.setToolTipText("Percent opacity");
    return part;
}
项目:gama    文件:LabelViewer.java   
public Composite createControl(final Composite parent, final KeyListener klisten) {
    this.part = AbstractSimpleConfigurator.subpart(parent, "Label:");
    this.klisten = klisten;

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

    this.field = new Combo(part, SWT.DROP_DOWN | SWT.READ_ONLY);
    this.field.addKeyListener(klisten);
    if ( this.schema != null ) {
        final List<AttributeDescriptor> types = this.schema.getAttributeDescriptors();
        final List<String> typeStrings = new ArrayList<String>();
        for ( final AttributeDescriptor attributeDescriptor : types ) {
            typeStrings.add(attributeDescriptor.getLocalName());
        }
        this.field.setItems(typeStrings.toArray(new String[0]));
    }
    this.field.setToolTipText("Label field");

    this.fonter = new FontEditor(part);

    // determine which placement to use
    if ( schema != null ) {
        if ( SLDs.isLine(schema) ) {
            pointPlacement = false;
        } else {
            pointPlacement = true;
        }
        if ( pointPlacement ) {
            // point placement (3 combos: AnchorPoint (Horiz, Vert) + Rotation)
            initPlacementContentsPoint();
        } else {
            // line placement (1 combo: Perpendicular Offset)
            initPlacementContentsLine();
        }
    }

    listen(true);

    return part;
}
项目:APICloud-Studio    文件:ContentAssistSubjectControlAdapter.java   
/**
 * @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);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
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());
}
项目:translationstudio8    文件:DoubleCellEditor.java   
/**
 * Create and setup the control.
 * 
 * @param table parent for the control
 */
private void createControl(JaretTable table) {
    if (_text == null) {
        _table = table;
        _text = new Text(table, SWT.BORDER | SWT.RIGHT);
        _doubleField = new DoubleField();
        _doubleField.setText(_text);

        _text.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }

        });

        _text.addFocusListener(this);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeHierarchyViewPart.java   
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());
}
项目:data-mapper    文件:MappingRow.java   
private Text createText(final Composite parent,
        final FocusListener focusListener,
        final KeyListener keyListener) {
    final Text text = new Text(parent, SWT.BORDER);
    text.setEditable(false);
    text.addFocusListener(focusListener);
    text.addKeyListener(keyListener);
    return text;
}
项目:tmxeditor8    文件:DoubleCellEditor.java   
/**
 * Create and setup the control.
 * 
 * @param table parent for the control
 */
private void createControl(JaretTable table) {
    if (_text == null) {
        _table = table;
        _text = new Text(table, SWT.BORDER | SWT.RIGHT);
        _doubleField = new DoubleField();
        _doubleField.setText(_text);

        _text.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }

        });

        _text.addFocusListener(this);
    }
}
项目:fullsync    文件:NiceListView.java   
public NiceListView(Composite parent) {
    super(parent, SWT.TRANSPARENT);
    Display display = getDisplay();
    colorDefault = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
    colorHover = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
    colorSelected = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
    colorForeground = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
    colorSelectedForegroud = display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);

    addKeyListener(KeyListener.keyPressedAdapter(this::keyPressed));
    initGUI();
}
项目:openaudible    文件:GridComposite.java   
public void setKeyListener(KeyListener keyListener) {
    this.keyListener = keyListener;
}
项目:ccu-historian    文件:ChartComposite.java   
/**
     * 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);
        }
    }
项目:aya-lang    文件:ChartComposite.java   
/**
     * 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);
        }
    }
项目:scenarioo-example-swtbot-e4    文件:PositionDetailView.java   
public void addChangeListeners(final ModifyListener modifyListener, final KeyListener keyListner) {
    this.articleCombo.addModifyListener(modifyListener);
    this.positionAmountText.addKeyListener(keyListner);
}
项目:scenarioo-example-swtbot-e4    文件:OrderDetailView.java   
public void addOrderNumberKeyListener(final KeyListener keyListener) {
    orderNumberText.addKeyListener(keyListener);
}
项目:PDFReporter-Studio    文件:NullableText.java   
/**
 * @see org.eclipse.swt.widgets.Control#addKeyListener(org.eclipse.swt.events.KeyListener)
 */
public void addKeyListener(KeyListener listener) {
    text.addKeyListener(listener);
}
项目:PDFReporter-Studio    文件:NullableText.java   
/**
 * @see org.eclipse.swt.widgets.Control#removeKeyListener(org.eclipse.swt.events.KeyListener)
 */
public void removeKeyListener(KeyListener listener) {
    text.removeKeyListener(listener);
}
项目:OpenSPIFe    文件:ProfileMinMaxValueWizardPage.java   
private Composite createTimeControl(Composite parent) {
    Composite timeComposite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(0, 15)
                                    .applyTo(timeComposite);
    timeGridDataFactory = GridDataFactory.fillDefaults();
    timeGridDataFactory.applyTo(timeComposite);

    TemporalExtent extent = PlanEditorUtil.getPlanExportExtentPropertyValue(plan);
    timeStart = createDateTimeEditor(timeComposite, Messages.ProfileMinMaxValueWizardPage_StartTimeLabel, extent.getStart());
    GridDataFactory.swtDefaults().indent(10, 5)
                                 .hint(FIELD_HINT_LENGTH, SWT.DEFAULT)
                                 .applyTo(timeStart.getEditorControl());
    timeEnd = createDateTimeEditor(timeComposite, Messages.ProfileMinMaxValueWizardPage_EndTimeLabel, extent.getEnd());
    GridDataFactory.swtDefaults().indent(7, 5)
                                 .hint(FIELD_HINT_LENGTH, SWT.DEFAULT)
                                 .applyTo(timeEnd.getEditorControl());

    KeyListener dateSequenceKeyListener = new KeyListener() {

        @Override
        public void keyReleased(KeyEvent ke) {
            try {
                Date start = (Date) timeStart.getObjectRaw();
                Date end = (Date) timeEnd.getObjectRaw();
                clearError(ProfileMinMaxValueWizardPage.class);

                if (start == null || end == null) {
                    return;
                }
                if (!start.before(end)) {
                    setError(ProfileMinMaxValueWizardPage.class, Messages.ProfileMinMaxValueWizardPage_EndTimeLaterThanStartTime_Error_Message);
                } else {
                    clearError(ProfileMinMaxValueWizardPage.class);
                }
            } catch (ParseException e1) {
                // The format is incorrect
                setError(ProfileMinMaxValueWizardPage.class, Messages.ProfileMinMaxValueWizardPage_TimeFormatInvalid_Error_Message);
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
            // inspect on keyReleased event instead.
        }
    };

    timeStart.getEditorControl().addKeyListener(dateSequenceKeyListener);
    timeEnd.getEditorControl().addKeyListener(dateSequenceKeyListener);

    return timeComposite;
}
项目:OpenSPIFe    文件:SimpleSpinner.java   
public void addTextKeyListener(KeyListener listener) {
    if (listener == null)
        throw new SWTError(SWT.ERROR_NULL_ARGUMENT);
    text.addKeyListener(listener);
}
项目:Eclipse-Postfix-Code-Completion    文件:CallHierarchyViewer.java   
void addKeyListener(KeyListener keyListener) {
    getControl().addKeyListener(keyListener);
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
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;
}
项目:translationstudio8    文件:TextCellEditor.java   
/**
 * Create the control to be used when editing.
 * 
 * @param table table is the parent control
 */
private void createControl(JaretTable table) {
    if (_text == null) {
        _table = table;
        if (!_multi) {
            _text = new Text(table, SWT.BORDER);
        } else {
            _text = new Text(table, SWT.BORDER | SWT.MULTI | SWT.WRAP);
        }
        _text.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if ((event.stateMask & SWT.ALT) != 0 && event.keyCode == SWT.CR) {
                    event.doit = false;
                    _text.insert("\n");
                } else if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                   _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                } else {
                    if (_multi) {
                        // System.out.println("lines "+_text.getLineCount());
                        // System.out.println("lineheight "+_text.getLineHeight());
                        // int lheight = _text.getLineHeight();
                        // int lcount = _text.getLineCount();
                        // TODO
                        if (true || _text.getLineCount() * _text.getLineHeight() < _text.getSize().y) {
                            Point newSize = new Point(_text.getSize().x, getPreferredHeight());
                            _text.setSize(newSize);
                        }
                    }
                }

            }

            public void keyReleased(KeyEvent arg0) {
            }

        });

        _text.addFocusListener(this);
    }
}
项目:translationstudio8    文件:IntegerCellEditor.java   
/**
 * Create the control.
 * 
 * @param table parent table
 */
private void createControl(JaretTable table) {
    if (_spinner == null) {
        _table = table;
        _spinner = new Spinner(table, SWT.BORDER);

        _spinner.setMaximum(_max);
        _spinner.setMinimum(_min);

        _spinner.addTraverseListener(new TraverseListener() {
            public void keyTraversed(TraverseEvent e) {
                e.doit = false;
            }
        });

        _spinner.addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }

            }

            public void keyReleased(KeyEvent arg0) {
            }

        });

        _spinner.addFocusListener(this);
    }
}
项目:translationstudio8    文件:EnumComboEditor.java   
/**
 * {@inheritDoc}
 */
public Control getEditorControl(JaretTable table, IRow row, IColumn column, char typedKey) {
    super.getEditorControl(table, row, column, typedKey);

    _items = new Object[] {};

    if (_combo == null) {
        _combo = new Combo(table, SWT.BORDER | SWT.READ_ONLY);
        _combo.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }

        });
        _combo.addFocusListener(this);

    }
    Class<?> clazz = column.getContentClass(row);

    if (clazz != null && Enum.class.isAssignableFrom(clazz)) {
        _items = clazz.getEnumConstants();
    } else {
        _items = new Object[] {};
    }

    Object value = column.getValue(row);
    _oldVal = value;

    int selIdx = -1;
    String[] stringItems = new String[_items.length];
    for (int i = 0; i < _items.length; i++) {
        stringItems[i] = _items[i].toString();
        if (value != null && value.equals(_items[i])) {
            selIdx = i;
        }
    }
    _combo.setItems(stringItems);

    if (selIdx != -1) {
        _combo.select(selIdx);
    }

    return _combo;
}
项目:translationstudio8    文件:ObjectComboEditor.java   
/**
 * {@inheritDoc}
 */
public Control getEditorControl(JaretTable table, IRow row, IColumn column, char typedKey) {
    super.getEditorControl(table, row, column, typedKey);

    if (_combo == null) {
        _combo = new Combo(table, SWT.BORDER | SWT.READ_ONLY);
        _combo.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }

        });
        _combo.addFocusListener(this);
        _combo.setItems(_stringItems);
    }

    Object value = column.getValue(row);
    _oldVal = value;

    int selIdx = -1;
    if (_allowNull && value == null) {
        selIdx = 0;
    } else {
        selIdx = _itemList.indexOf(value);
        selIdx = _allowNull ? selIdx + 1 : selIdx;
    }

    if (selIdx != -1) {
        _combo.select(selIdx);
    }

    return _combo;
}
项目:translationstudio8    文件:NatCombo.java   
@Override
public void addKeyListener(KeyListener listener) {
    text.addKeyListener(listener);
    dropdownList.addKeyListener(listener);
}
项目:ECG-Viewer    文件:ChartComposite.java   
/**
     * 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);
        }
    }
项目:astor    文件:ChartComposite.java   
/**
 * 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);
    }
}
项目:gef-gwt    文件:Widget.java   
protected void dispatchKeyPressed(KeyEvent ke) {
    List<KeyListener> copy = new ArrayList<KeyListener>(keyListeners);
    for (KeyListener keyListener : copy) {
        keyListener.keyPressed(ke);
    }
}
项目:gef-gwt    文件:Widget.java   
public void addKeyListener(KeyListener listener, int i) {
    this.keyListeners.add(listener);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CallHierarchyViewer.java   
void addKeyListener(KeyListener keyListener) {
    getControl().addKeyListener(keyListener);
}