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();
}
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);
}
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());
});
}
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;
}
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;
}
Aggregations