use of org.eclipse.swt.events.DisposeListener in project eclipse.platform.text by eclipse.
the class AbstractInformationControlManager method getInformationControl.
/**
* Returns the information control. If the information control has not been created yet,
* it is automatically created.
*
* @return the information control
*/
protected IInformationControl getInformationControl() {
if (fDisposed)
return fInformationControl;
IInformationControlCreator creator = null;
if (fCustomInformationControlCreator == null) {
creator = fInformationControlCreator;
if (fIsCustomInformationControl && fInformationControl != null) {
if (fInformationControl instanceof IInformationControlExtension5)
fSizeConstraints = null;
fInformationControl.dispose();
fInformationControl = null;
}
fIsCustomInformationControl = false;
} else {
creator = fCustomInformationControlCreator;
if (creator instanceof IInformationControlCreatorExtension) {
IInformationControlCreatorExtension extension = (IInformationControlCreatorExtension) creator;
if (fInformationControl != null && extension.canReuse(fInformationControl))
return fInformationControl;
}
if (fInformationControl != null) {
if (fInformationControl instanceof IInformationControlExtension5)
fSizeConstraints = null;
fInformationControl.dispose();
fInformationControl = null;
}
fIsCustomInformationControl = true;
}
if (fInformationControl == null) {
fInformationControl = creator.createInformationControl(fSubjectControl.getShell());
fInformationControl.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handleInformationControlDisposed();
}
});
if (fInformationControlCloser != null)
fInformationControlCloser.setInformationControl(fInformationControl);
}
return fInformationControl;
}
use of org.eclipse.swt.events.DisposeListener in project eclipse.platform.text by eclipse.
the class AnnotationRulerColumn method createControl.
@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
fParentRuler = parentRuler;
fCachedTextViewer = parentRuler.getTextViewer();
fCachedTextWidget = fCachedTextViewer.getTextWidget();
fHitDetectionCursor = parentControl.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
fCanvas = createCanvas(parentControl);
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event) {
if (fCachedTextViewer != null)
doubleBufferPaint(event.gc);
}
});
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handleDispose();
fCachedTextViewer = null;
fCachedTextWidget = null;
}
});
fMouseListener = new MouseListener() {
@Override
public void mouseUp(MouseEvent event) {
int lineNumber;
if (isPropagatingMouseListener()) {
fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
} else
lineNumber = fParentRuler.toDocumentLineNumber(event.y);
if (1 == event.button)
mouseClicked(lineNumber);
}
@Override
public void mouseDown(MouseEvent event) {
int lineNumber;
if (isPropagatingMouseListener()) {
fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
} else
lineNumber = fParentRuler.toDocumentLineNumber(event.y);
if (1 == event.button)
AnnotationRulerColumn.this.mouseDown(lineNumber);
}
@Override
public void mouseDoubleClick(MouseEvent event) {
int lineNumber;
if (isPropagatingMouseListener()) {
fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
} else
lineNumber = fParentRuler.toDocumentLineNumber(event.y);
if (1 == event.button)
mouseDoubleClicked(lineNumber);
}
};
fCanvas.addMouseListener(fMouseListener);
fCanvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
handleMouseMove(e);
}
});
fCanvas.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
handleMouseScrolled(e);
}
});
if (fCachedTextViewer != null) {
VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
fCachedTextViewer.addTextListener(fLineListener);
// on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
fCachedTextWidget.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (fCachedTextWidget != null && fCachedTextWidget.getWordWrap()) {
redraw();
}
}
});
}
return fCanvas;
}
use of org.eclipse.swt.events.DisposeListener in project eclipse.platform.text by eclipse.
the class LineNumberRulerColumn method createControl.
@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
fParentRuler = parentRuler;
fCachedTextViewer = parentRuler.getTextViewer();
fCachedTextWidget = fCachedTextViewer.getTextWidget();
// on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the line ruler
fCachedTextWidget.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (fCachedTextWidget != null && fCachedTextWidget.getWordWrap()) {
postRedraw();
}
}
});
// track when StyledText is redrawn to check if some line height changed. In this case, the ruler must be redrawn
// to draw line number with well height.
VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
fCanvas = new Canvas(parentControl, SWT.NO_FOCUS) {
@Override
public void addMouseListener(MouseListener listener) {
// see bug 40889, bug 230073 and AnnotationRulerColumn#isPropagatingMouseListener()
if (listener == fMouseHandler)
super.addMouseListener(listener);
else {
TypedListener typedListener = null;
if (listener != null)
typedListener = new TypedListener(listener);
addListener(SWT.MouseDoubleClick, typedListener);
}
}
};
fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
fCanvas.setForeground(fForeground);
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event) {
if (fCachedTextViewer != null)
doubleBufferPaint(event.gc);
}
});
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handleDispose();
fCachedTextViewer = null;
fCachedTextWidget = null;
}
});
fMouseHandler = new MouseHandler();
fCanvas.addMouseListener(fMouseHandler);
fCanvas.addMouseMoveListener(fMouseHandler);
fCanvas.addMouseWheelListener(fMouseHandler);
if (fCachedTextViewer != null) {
VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
fCachedTextViewer.addTextListener(fInternalListener);
if (fFont == null) {
if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
fFont = fCachedTextWidget.getFont();
}
}
if (fFont != null)
fCanvas.setFont(fFont);
updateNumberOfDigits();
computeIndentations();
return fCanvas;
}
use of org.eclipse.swt.events.DisposeListener in project knime-core by knime.
the class SubnodeLayoutJSONEditorPage method createControl.
/**
* {@inheritDoc}
*/
@Override
public void createControl(final Composite parent) {
TabFolder tabs = new TabFolder(parent, SWT.BORDER);
TabItem usageTab = new TabItem(tabs, SWT.NONE);
usageTab.setText("Node Usage");
m_nodeUsageComposite = new NodeUsageComposite(tabs, m_viewNodes, m_subNodeContainer);
usageTab.setControl(m_nodeUsageComposite);
usageTab.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(final DisposeEvent e) {
m_nodeUsageComposite = null;
}
});
TabItem basicTab = new TabItem(tabs, SWT.NONE);
basicTab.setText("Basic Layout");
basicTab.setControl(createBasicComposite(tabs));
TabItem jsonTab = new TabItem(tabs, SWT.NONE);
jsonTab.setText("Advanced Layout");
jsonTab.setControl(createJSONEditorComposite(tabs));
setControl(tabs);
}
use of org.eclipse.swt.events.DisposeListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Widget method test_addDisposeListenerLorg_eclipse_swt_events_DisposeListener.
@Test
public void test_addDisposeListenerLorg_eclipse_swt_events_DisposeListener() {
DisposeListener listener = e -> {
};
widget.addDisposeListener(listener);
widget.removeDisposeListener(listener);
}
Aggregations