use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.
the class FindReplaceDialog method configureShell.
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.FindReplaceDialog_1);
loadParameter();
startListeningToPartChanges();
newShell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
saveParameter();
stopListeningToPartChanges();
}
});
}
use of org.eclipse.swt.events.DisposeEvent in project xtext-eclipse by eclipse.
the class EmbeddedEditorActions method initialize.
protected void initialize() {
final List<IHandlerActivation> handlerActivations = Lists.newArrayListWithExpectedSize(3);
final IHandlerService handlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class);
final IContextService contextService = (IContextService) workbench.getAdapter(IContextService.class);
Shell shell = viewer.getTextWidget().getShell();
final ActiveShellExpression expression = new ActiveShellExpression(shell);
final IContextActivation contextActivation = contextService.activateContext(EMBEDDED_TEXT_EDITOR_SCOPE, expression);
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handlerService.deactivateHandlers(handlerActivations);
contextService.deactivateContext(contextActivation);
}
});
viewer.getTextWidget().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
handlerService.deactivateHandlers(handlerActivations);
handlerActivations.clear();
}
@Override
public void focusGained(FocusEvent e) {
for (final IAction action : allActions.values()) {
handlerActivations.add(handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action), expression, true));
}
}
});
createActions();
// create context menu
MenuManager manager = new MenuManager(null, null);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
fillContextMenu(mgr);
}
});
StyledText text = viewer.getTextWidget();
Menu menu = manager.createContextMenu(text);
text.setMenu(menu);
List<ActionActivationCode> activationCodes = Lists.newArrayList();
setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_RIGHT_TAB, '\t', -1, SWT.NONE);
setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
viewer.getTextWidget().addVerifyKeyListener(new ActivationCodeTrigger(allActions, activationCodes));
}
use of org.eclipse.swt.events.DisposeEvent in project cubrid-manager by CUBRID.
the class FontGroup method createChangeControl.
/**
* create change color button
*
* @param parent the parent container
* @return button the instance of Button
*/
private Button createChangeControl(Composite parent) {
if (changeFontButton == null) {
changeFontButton = new Button(parent, SWT.PUSH);
}
if (changeButtonText != null) {
changeFontButton.setText(changeButtonText);
}
changeFontButton.addSelectionListener(new ChangeSelectListen());
changeFontButton.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
changeFontButton = null;
}
});
changeFontButton.setFont(parent.getFont());
return changeFontButton;
}
use of org.eclipse.swt.events.DisposeEvent in project eclipse.platform.text by eclipse.
the class OverviewRuler method createControl.
@Override
public Control createControl(Composite parent, ITextViewer textViewer) {
fTextViewer = textViewer;
fHitDetectionCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
fHeader = new Canvas(parent, SWT.NONE);
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
fHeader.addMouseTrackListener(new MouseTrackAdapter() {
/*
* @see org.eclipse.swt.events.MouseTrackAdapter#mouseHover(org.eclipse.swt.events.MouseEvent)
* @since 3.3
*/
@Override
public void mouseEnter(MouseEvent e) {
updateHeaderToolTipText();
}
});
}
fCanvas = new Canvas(parent, SWT.NO_BACKGROUND);
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event) {
if (fTextViewer != null)
doubleBufferPaint(event.gc);
}
});
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
handleDispose();
fTextViewer = null;
}
});
fCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
});
fCanvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
fCanvas.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
handleMouseScrolled(e);
}
});
if (fTextViewer != null) {
fTextViewer.addTextListener(fInternalListener);
// on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
fTextViewer.getTextWidget().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (fTextViewer == null) {
return;
}
StyledText textWidget = fTextViewer.getTextWidget();
if (textWidget != null && textWidget.getWordWrap()) {
redraw();
}
}
});
}
return fCanvas;
}
use of org.eclipse.swt.events.DisposeEvent in project eclipse.platform.text by eclipse.
the class DefaultRangeIndicator method getImage.
/**
* Returns the image of this range indicator.
*
* @param control the control
* @param rangeIndicatorColor the color to be used to paint the range indicator
* @return an image
*/
private Image getImage(Control control, Color rangeIndicatorColor) {
if (fImage == null) {
fImage = createImage(control.getDisplay(), control.getSize(), rangeIndicatorColor);
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (fImage != null && !fImage.isDisposed()) {
fImage.dispose();
fImage = null;
}
}
});
} else {
Rectangle imageRectangle = fImage.getBounds();
Point controlSize = control.getSize();
if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y || !rangeIndicatorColor.equals(fLastRangeIndicatorColor)) {
fImage.dispose();
fImage = createImage(control.getDisplay(), controlSize, rangeIndicatorColor);
}
}
return fImage;
}
Aggregations