Search in sources :

Example 76 with Listener

use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.

the class RenameConnectionDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label label1 = new Label(composite, SWT.LEFT);
    label1.setText(Messages.lblName);
    GridData data = new GridData();
    data.widthHint = 60;
    data.horizontalSpan = 1;
    data.verticalSpan = 1;
    label1.setLayoutData(data);
    newNameText = new Text(composite, SWT.BORDER);
    data = new GridData();
    data.horizontalSpan = 2;
    data.verticalSpan = 1;
    data.grabExcessHorizontalSpace = true;
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    newNameText.setLayoutData(data);
    newNameText.setText(database.getName());
    newNameText.selectAll();
    newNameText.setFocus();
    newNameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            setErrorMessage(null);
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            if (!valid()) {
                return;
            }
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
    newNameText.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            if (e.type == SWT.KeyDown && e.character == SWT.CR) {
                buttonPressed(IDialogConstants.OK_ID);
            }
        }
    });
    setTitle(Messages.bind(Messages.renameMSGTitle, database.getName()));
    setMessage(Messages.bind(Messages.renameDialogMSG, database.getName()));
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 77 with Listener

use of org.eclipse.swt.widgets.Listener in project bndtools by bndtools.

the class NewWrappingBndFileWizardPage method createAdvancedControls.

@Override
protected void createAdvancedControls(Composite parent) {
    // Override the existing advanced controls
    Composite composite = new Composite(parent, SWT.NONE);
    new Label(composite, SWT.NONE).setText(Messages.NewWrappingBndFileWizardPage_labelBSN);
    txtBSN = new Text(composite, SWT.BORDER);
    new Label(composite, SWT.NONE).setText(Messages.NewWrappingBndFileWizardPage_labelVersion);
    txtVersion = new Text(composite, SWT.BORDER);
    txtBSN.setText(bsn);
    txtVersion.setText(version.toString());
    txtBSN.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            bsn = txtBSN.getText();
            getContainer().updateButtons();
            getContainer().updateMessage();
        }
    });
    txtVersion.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            try {
                version = Version.parseVersion(txtVersion.getText());
                error = null;
            } catch (IllegalArgumentException e) {
                version = null;
                error = Messages.NewWrappingBndFileWizardPage_errorInvalidVersion;
            }
            getContainer().updateButtons();
            getContainer().updateMessage();
        }
    });
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    txtBSN.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    super.createAdvancedControls(parent);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 78 with Listener

use of org.eclipse.swt.widgets.Listener in project bndtools by bndtools.

the class ProjectLaunchTabPiece method createControl.

@Override
@SuppressWarnings("unused")
public Control createControl(Composite parent) {
    Group projectGroup = new Group(parent, SWT.NONE);
    projectGroup.setText("Launch:");
    launchTargetTxt = new Text(projectGroup, SWT.BORDER);
    Button projectNameBrowseBtn = new Button(projectGroup, SWT.PUSH);
    projectNameBrowseBtn.setText("Browse Projects");
    // Spacer
    new Label(projectGroup, SWT.NONE);
    Button bndrunBrowseBtn = new Button(projectGroup, SWT.PUSH);
    bndrunBrowseBtn.setText("Browse Run Files");
    enableTraceBtn = new Button(projectGroup, SWT.CHECK);
    enableTraceBtn.setText("Enable launcher tracing.");
    // LISTENERS
    projectNameBrowseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doBrowseProject();
        }
    });
    bndrunBrowseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doBrowseBndrun();
        }
    });
    launchTargetTxt.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(Event event) {
            String oldName = targetName;
            targetName = launchTargetTxt.getText();
            setDirty(true);
            firePropertyChange(PROP_LAUNCH_TARGET, oldName, targetName);
        }
    });
    enableTraceBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean oldValue = enableTrace;
            enableTrace = enableTraceBtn.getSelection();
            setDirty(true);
            firePropertyChange(PROP_ENABLE_TRACE, oldValue, enableTrace);
        }
    });
    // LAYOUT
    GridLayout layout = new GridLayout(2, false);
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    projectGroup.setLayout(layout);
    launchTargetTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    projectNameBrowseBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    bndrunBrowseBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    return projectGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 79 with Listener

use of org.eclipse.swt.widgets.Listener in project azure-tools-for-java by Microsoft.

the class DropDownHandler method pullDropdown.

public void pullDropdown(Event event) {
    Widget widget = event.widget;
    if (widget instanceof ToolItem) {
        ToolItem toolItem = (ToolItem) widget;
        Listener[] listeners = toolItem.getListeners(SWT.Selection);
        if (listeners.length > 0) {
            Listener listener = listeners[0];
            Event eve = new Event();
            eve.type = SWT.Selection;
            eve.widget = toolItem;
            eve.detail = SWT.DROP_DOWN;
            eve.x = toolItem.getBounds().x;
            eve.y = toolItem.getBounds().height;
            listener.handleEvent(eve);
        }
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Widget(org.eclipse.swt.widgets.Widget) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 80 with Listener

use of org.eclipse.swt.widgets.Listener in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method createPartControl.

/**
 * The <code>AbstractTextEditor</code> implementation of this
 * <code>IWorkbenchPart</code> method creates the vertical ruler and
 * source viewer.
 * <p>
 * Subclasses may extend this method. Besides extending this method, the
 * behavior of <code>createPartControl</code> may be customized by
 * calling, extending or replacing the following methods: <br>
 * Subclasses may supply customized implementations for some members using
 * the following methods before <code>createPartControl</code> is invoked:
 * <ul>
 * <li>
 * {@linkplain #setSourceViewerConfiguration(SourceViewerConfiguration) setSourceViewerConfiguration}
 * to supply a custom source viewer configuration,</li>
 * <li>{@linkplain #setRangeIndicator(Annotation) setRangeIndicator} to
 * provide a range indicator,</li>
 * <li>{@linkplain #setHelpContextId(String) setHelpContextId} to provide a
 * help context id,</li>
 * <li>{@linkplain #setEditorContextMenuId(String) setEditorContextMenuId}
 * to set a custom context menu id,</li>
 * <li>{@linkplain #setRulerContextMenuId(String) setRulerContextMenuId} to
 * set a custom ruler context menu id.</li>
 * </ul>
 * <br>
 * Subclasses may replace the following methods called from within
 * <code>createPartControl</code>:
 * <ul>
 * <li>{@linkplain #createVerticalRuler() createVerticalRuler} to supply a
 * custom vertical ruler,</li>
 * <li>{@linkplain #createSourceViewer(Composite, IVerticalRuler, int) createSourceViewer}
 * to supply a custom source viewer,</li>
 * <li>{@linkplain #getSelectionProvider() getSelectionProvider} to supply
 * a custom selection provider.</li>
 * </ul>
 * <br>
 * Subclasses may extend the following methods called from within
 * <code>createPartControl</code>:
 * <ul>
 * <li>
 * {@linkplain #initializeViewerColors(ISourceViewer) initializeViewerColors}
 * to customize the viewer color scheme (may also be replaced),</li>
 * <li>
 * {@linkplain #initializeDragAndDrop(ISourceViewer) initializeDragAndDrop}
 * to customize drag and drop (may also be replaced),</li>
 * <li>{@linkplain #createNavigationActions() createNavigationActions} to
 * add navigation actions,</li>
 * <li>{@linkplain #createActions() createActions} to add text editor
 * actions.</li>
 * </ul>
 * </p>
 *
 * @param parent the parent composite
 */
@Override
public void createPartControl(Composite parent) {
    fVerticalRuler = createVerticalRuler();
    int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
    fSourceViewer = createSourceViewer(parent, fVerticalRuler, styles);
    if (fConfiguration == null)
        fConfiguration = new SourceViewerConfiguration();
    fSourceViewer.configure(fConfiguration);
    if (fSourceViewer instanceof ISourceViewerExtension4)
        fKeyBindingSupportForContentAssistant = new KeyBindingSupportForAssistant(((ISourceViewerExtension4) fSourceViewer));
    if (fSourceViewer instanceof ISourceViewerExtension3) {
        IQuickAssistAssistant assistant = ((ISourceViewerExtension3) fSourceViewer).getQuickAssistAssistant();
        if (assistant != null)
            fKeyBindingSupportForQuickAssistant = new KeyBindingSupportForAssistant(assistant);
    }
    if (fRangeIndicator != null)
        fSourceViewer.setRangeIndicator(fRangeIndicator);
    fSourceViewer.addTextListener(fTextListener);
    fSourceViewer.addTextInputListener(fTextListener);
    getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
    initializeViewerFont(fSourceViewer);
    initializeViewerColors(fSourceViewer);
    initializeFindScopeColor(fSourceViewer);
    initializeDragAndDrop(fSourceViewer);
    StyledText styledText = fSourceViewer.getTextWidget();
    styledText.addMouseListener(getCursorListener());
    styledText.addKeyListener(getCursorListener());
    // Disable orientation switching until we fully support it.
    styledText.addListener(SWT.OrientationChange, new Listener() {

        @Override
        public void handleEvent(Event event) {
            event.doit = false;
        }
    });
    if (getHelpContextId() != null)
        PlatformUI.getWorkbench().getHelpSystem().setHelp(styledText, getHelpContextId());
    String id = fEditorContextMenuId != null ? fEditorContextMenuId : DEFAULT_EDITOR_CONTEXT_MENU_ID;
    MenuManager manager = new MenuManager(id, id);
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(getContextMenuListener());
    fTextContextMenu = manager.createContextMenu(styledText);
    styledText.setMenu(fTextContextMenu);
    if (fEditorContextMenuId != null)
        getEditorSite().registerContextMenu(fEditorContextMenuId, manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
    else if (fCompatibilityMode)
        getEditorSite().registerContextMenu(DEFAULT_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
    if ((fEditorContextMenuId != null && fCompatibilityMode) || fEditorContextMenuId == null) {
        String partId = getEditorSite().getId();
        if (partId != null)
            // $NON-NLS-1$
            getEditorSite().registerContextMenu(partId + ".EditorContext", manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
    }
    getEditorSite().registerContextMenu(COMMON_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
    if (fEditorContextMenuId == null)
        fEditorContextMenuId = DEFAULT_EDITOR_CONTEXT_MENU_ID;
    id = fRulerContextMenuId != null ? fRulerContextMenuId : DEFAULT_RULER_CONTEXT_MENU_ID;
    manager = new MenuManager(id, id);
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(getContextMenuListener());
    Control rulerControl = fVerticalRuler.getControl();
    fRulerContextMenu = manager.createContextMenu(rulerControl);
    rulerControl.setMenu(fRulerContextMenu);
    rulerControl.addMouseListener(getRulerMouseListener());
    if (fRulerContextMenuId != null)
        getEditorSite().registerContextMenu(fRulerContextMenuId, manager, getSelectionProvider(), false);
    else if (fCompatibilityMode)
        getEditorSite().registerContextMenu(DEFAULT_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
    if ((fRulerContextMenuId != null && fCompatibilityMode) || fRulerContextMenuId == null) {
        String partId = getSite().getId();
        if (partId != null)
            // $NON-NLS-1$
            getEditorSite().registerContextMenu(partId + ".RulerContext", manager, getSelectionProvider(), false);
    }
    getEditorSite().registerContextMenu(COMMON_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
    if (fRulerContextMenuId == null)
        fRulerContextMenuId = DEFAULT_RULER_CONTEXT_MENU_ID;
    initializeZoomGestures(rulerControl, fSourceViewer);
    getSite().setSelectionProvider(getSelectionProvider());
    fSelectionListener = new SelectionListener();
    fSelectionListener.install(getSelectionProvider());
    fSelectionListener.setDocument(getDocumentProvider().getDocument(getEditorInput()));
    initializeActivationCodeTrigger();
    createNavigationActions();
    createAccessibilityActions();
    createActions();
    initializeSourceViewer(getEditorInput());
    /* since 3.2 - undo redo actions should be created after
		 * the source viewer is initialized, so that the undo manager
		 * can obtain its undo context from its document.
		 */
    createUndoRedoActions();
    JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
    IVerticalRuler ruler = getVerticalRuler();
    if (ruler instanceof CompositeRuler)
        updateContributedRulerColumns((CompositeRuler) ruler);
    if (isWordWrapSupported()) {
        setWordWrap(getInitialWordWrapStatus());
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ITextListener(org.eclipse.jface.text.ITextListener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) ISaveablesLifecycleListener(org.eclipse.ui.ISaveablesLifecycleListener) IPartListener(org.eclipse.ui.IPartListener) KeyListener(org.eclipse.swt.events.KeyListener) GestureListener(org.eclipse.swt.events.GestureListener) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Listener(org.eclipse.swt.widgets.Listener) ITextInputListener(org.eclipse.jface.text.ITextInputListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) VerifyListener(org.eclipse.swt.events.VerifyListener) MouseListener(org.eclipse.swt.events.MouseListener) IWindowListener(org.eclipse.ui.IWindowListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) ISourceViewerExtension3(org.eclipse.jface.text.source.ISourceViewerExtension3) ISourceViewerExtension4(org.eclipse.jface.text.source.ISourceViewerExtension4) Point(org.eclipse.swt.graphics.Point) SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) Control(org.eclipse.swt.widgets.Control) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SaveablesLifecycleEvent(org.eclipse.ui.SaveablesLifecycleEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) TextEvent(org.eclipse.jface.text.TextEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) GestureEvent(org.eclipse.swt.events.GestureEvent) DocumentEvent(org.eclipse.jface.text.DocumentEvent) Event(org.eclipse.swt.widgets.Event) VerifyEvent(org.eclipse.swt.events.VerifyEvent) IQuickAssistAssistant(org.eclipse.jface.text.quickassist.IQuickAssistAssistant)

Aggregations

Listener (org.eclipse.swt.widgets.Listener)214 Event (org.eclipse.swt.widgets.Event)199 SelectionEvent (org.eclipse.swt.events.SelectionEvent)101 GridData (org.eclipse.swt.layout.GridData)95 Composite (org.eclipse.swt.widgets.Composite)82 GridLayout (org.eclipse.swt.layout.GridLayout)78 Point (org.eclipse.swt.graphics.Point)60 SelectionListener (org.eclipse.swt.events.SelectionListener)58 Button (org.eclipse.swt.widgets.Button)58 Label (org.eclipse.swt.widgets.Label)53 Text (org.eclipse.swt.widgets.Text)49 Table (org.eclipse.swt.widgets.Table)46 DisposeListener (org.eclipse.swt.events.DisposeListener)37 DisposeEvent (org.eclipse.swt.events.DisposeEvent)36 Rectangle (org.eclipse.swt.graphics.Rectangle)35 FocusEvent (org.eclipse.swt.events.FocusEvent)34 TableColumn (org.eclipse.swt.widgets.TableColumn)34 Shell (org.eclipse.swt.widgets.Shell)31 KeyEvent (org.eclipse.swt.events.KeyEvent)30 Group (org.eclipse.swt.widgets.Group)30