Search in sources :

Example 76 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project jbosstools-hibernate by jbosstools.

the class KnownConfigurationsView method createPartControl.

public void createPartControl(Composite parent) {
    // viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer = new MTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    /*viewer.setContentProvider(new ConfigurationsContentProvider() );*/
    /*viewer.setLabelProvider(new ConfigurationsLabelProvider() );*/
    viewer.setLabelProvider(new AnyAdaptableLabelProvider());
    final KnownConfigurationsProvider cp = new KnownConfigurationsProvider();
    viewer.setContentProvider(cp);
    getDebugUIPlugin().getPreferenceStore().addPropertyChangeListener(cp);
    viewer.getTree().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            getDebugUIPlugin().getPreferenceStore().removePropertyChangeListener(cp);
        }
    });
    // viewer.setInput(KnownConfigurations.getInstance().getRootNode() );
    viewer.setInput(KnownConfigurations.getInstance());
    makeActions();
    createContextMenu();
    hookDoubleClick();
    provideSelection();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MTreeViewer(org.hibernate.eclipse.console.viewers.xpl.MTreeViewer) AnyAdaptableLabelProvider(org.hibernate.eclipse.console.workbench.xpl.AnyAdaptableLabelProvider)

Example 77 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project nebula.widgets.nattable by eclipse.

the class HorizontalResizeCursorAction method run.

@Override
public void run(NatTable natTable, MouseEvent event) {
    if (this.resizeCursor == null) {
        // $NON-NLS-1$
        this.resizeCursor = new Cursor(Display.getDefault(), GUIHelper.getImage("horizontal_resize").getImageData(), 15, 15);
        natTable.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                HorizontalResizeCursorAction.this.resizeCursor.dispose();
            }
        });
    }
    natTable.setCursor(this.resizeCursor);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 78 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project org.csstudio.display.builder by kasemir.

the class WaveformView method doCreatePartControl.

/**
 * {@inheritDoc}
 */
@Override
protected void doCreatePartControl(final Composite parent) {
    // Arrange disposal
    parent.addDisposeListener((DisposeEvent e) -> {
        // Ignore current model after this view is disposed.
        if (model != null) {
            model.removeListener(model_listener);
            removeAnnotation();
        }
    });
    final GridLayout layout = new GridLayout(4, false);
    parent.setLayout(layout);
    // PV: .pvs..... [Refresh]
    // =====================
    // ======= Plot ========
    // =====================
    // <<<<<< Slider >>>>>>
    // Timestamp: __________ Sevr./Status: __________
    // PV: .pvs..... [Refresh]
    Label l = new Label(parent, 0);
    l.setText(Messages.SampleView_Item);
    l.setLayoutData(new GridData());
    pv_name = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    pv_name.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 2, 1));
    pv_name.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    final Button refresh = new Button(parent, SWT.PUSH);
    refresh.setText(Messages.SampleView_Refresh);
    refresh.setToolTipText(Messages.SampleView_RefreshTT);
    refresh.setLayoutData(new GridData());
    refresh.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    // =====================
    // ======= Plot ========
    // =====================
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        plot = new RTValuePlot(true);
        plot.getXAxis().setName(Messages.WaveformIndex);
        plot.getYAxes().get(0).setName(Messages.WaveformAmplitude);
        plot.getYAxes().get(0).setAutoscale(true);
        return new Scene(plot);
    });
    final Control plot_canvas = wrapper.getFXCanvas();
    plot_canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
    // <<<<<< Slider >>>>>>
    sample_index = new Slider(parent, SWT.HORIZONTAL);
    sample_index.setToolTipText(Messages.WaveformTimeSelector);
    sample_index.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns, 1));
    sample_index.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showSelectedSample();
        }
    });
    // Timestamp: __________ Sevr./Status: __________
    l = new Label(parent, 0);
    l.setText(Messages.WaveformTimestamp);
    l.setLayoutData(new GridData());
    timestamp = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    timestamp.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    l = new Label(parent, 0);
    l.setText(Messages.WaveformStatus);
    l.setLayoutData(new GridData());
    status = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    status.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    // Context Menu
    final MenuManager mm = new MenuManager();
    mm.setRemoveAllWhenShown(true);
    final Menu menu = mm.createContextMenu(plot_canvas);
    plot_canvas.setMenu(menu);
    getSite().registerContextMenu(mm, null);
    mm.addMenuListener(manager -> {
        mm.add(new ToggleToolbarAction(plot, true));
        mm.add(new ToggleLegendAction(plot, true));
        mm.add(new Separator());
        mm.add(new ToggleYAxisAction());
    });
}
Also used : Slider(org.eclipse.swt.widgets.Slider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Scene(javafx.scene.Scene) ToggleToolbarAction(org.csstudio.trends.databrowser3.editor.ToggleToolbarAction) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) RTValuePlot(org.csstudio.javafx.rtplot.RTValuePlot) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener) ToggleLegendAction(org.csstudio.trends.databrowser3.editor.ToggleLegendAction)

Example 79 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project org.csstudio.display.builder by kasemir.

the class TextAreaFieldEditor method getTextControl.

/**
 * Returns this field editor's text control.
 * <p>
 * The control is created if it does not yet exist
 * </p>
 *
 * @param parent the parent
 * @return the text control
 */
public Text getTextControl(Composite parent) {
    if (textField == null) {
        textField = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP);
        textField.setFont(parent.getFont());
        // case VALIDATE_ON_KEY_STROKE:
        textField.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                valueChanged();
            }
        });
        textField.addFocusListener(new FocusAdapter() {

            // Ensure that the value is checked on focus loss in case we
            // missed a keyRelease or user hasn't released key.
            // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=214716
            @Override
            public void focusLost(FocusEvent e) {
                valueChanged();
            }
        });
        textField.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent event) {
                textField = null;
            }
        });
    } else {
        checkParent(textField, parent);
    }
    return textField;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) FocusAdapter(org.eclipse.swt.events.FocusAdapter) DisposeListener(org.eclipse.swt.events.DisposeListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 80 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project mylyn.docs by eclipse.

the class MarkupTaskEditorExtension method createEditor.

@SuppressWarnings("unchecked")
@Override
public SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style, IAdaptable context) {
    final MarkupLanguageType markupLanguageCopy = createRepositoryMarkupLanguage(taskRepository);
    configureMarkupLanguage(taskRepository, markupLanguageCopy);
    SourceViewer viewer = new MarkupSourceViewer(parent, null, style | SWT.WRAP, markupLanguageCopy);
    // configure the viewer
    MarkupSourceViewerConfiguration configuration = createSourceViewerConfiguration(taskRepository, viewer, context);
    configuration.setEnableSelfContainedIncrementalFind(true);
    configuration.setMarkupLanguage(markupLanguageCopy);
    configuration.setShowInTarget(new ShowInTargetBridge(viewer));
    viewer.configure(configuration);
    // we want the viewer to show annotations
    viewer.showAnnotations(true);
    DefaultMarkerAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
    MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences();
    // configure viewer annotation/decoration support
    final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, null, annotationAccess, EditorsUI.getSharedTextColors());
    // hook the support up to the preference store
    Iterator<AnnotationPreference> e = annotationPreferences.getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference preference = e.next();
        support.setAnnotationPreference(preference);
    }
    support.setCursorLinePainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
    support.setMarginPainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
    support.install(new EditorExtensionPreferenceStore(EditorsUI.getPreferenceStore(), viewer.getControl()));
    viewer.getControl().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            support.dispose();
        }
    });
    IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
    if (focusService != null) {
        focusService.addFocusTracker(viewer.getTextWidget(), MarkupEditor.EDITOR_SOURCE_VIEWER);
    }
    viewer.getTextWidget().setData(MarkupLanguage.class.getName(), markupLanguageCopy);
    viewer.getTextWidget().setData(ISourceViewer.class.getName(), viewer);
    return viewer;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupSourceViewer(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IFocusService(org.eclipse.ui.swt.IFocusService) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) MarkupSourceViewer(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) ShowInTargetBridge(org.eclipse.mylyn.wikitext.ui.editor.ShowInTargetBridge) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupSourceViewerConfiguration(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewerConfiguration)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)366 DisposeListener (org.eclipse.swt.events.DisposeListener)363 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)75 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)70 Image (org.eclipse.swt.graphics.Image)53 Cursor (org.eclipse.swt.graphics.Cursor)49 Label (org.eclipse.swt.widgets.Label)42 ToolBar (org.eclipse.swt.widgets.ToolBar)42 Point (org.eclipse.swt.graphics.Point)38 Control (org.eclipse.swt.widgets.Control)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 Color (org.eclipse.swt.graphics.Color)34 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31