use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.
the class WindowsStartup method hookWindow.
private void hookWindow(IWorkbenchWindow window) {
Shell shell = window.getShell();
if (shell != null && !shell.isDisposed()) {
Number hWnd = getShellWindowHandle(shell);
logPrimaryWindow(hWnd);
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
WindowState.get(WindowState.WINDOW).delete();
e.display.asyncExec(new Runnable() {
public void run() {
checkRemainingWindow();
}
});
}
});
}
}
use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.
the class FloatingPalette method createShell.
private void createShell() {
fShell = new Shell(fParentShell, SWT.TOOL | SWT.RESIZE | SWT.CLOSE);
if (fPaletteState.isTranslucent) {
fShell.setAlpha(210);
}
checkSafeBounds(fParentShell);
fShell.setBounds(fPaletteState.bounds);
fShell.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_APP));
fShell.setText(Messages.FloatingPalette_0);
// Disposed by system
fShell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (fClient != null) {
fClient.dispose();
}
if (fPalettePage != null) {
fPalettePage.dispose();
}
fShell = null;
}
});
// Closed by user
fShell.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
fPaletteState.isOpen = false;
// Don't call this in DisposeListener as on Linux getBounds() returns bogus info
saveState(fShell);
}
});
fShell.setLayout(new FillLayout());
fClient = new Composite(fShell, SWT.NONE);
fClient.setLayout(new FillLayout());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
fClient.setLayoutData(gd);
fPalettePage = fEditor.getAdapter(PalettePage.class);
fPalettePage.createControl(fClient);
}
use of org.eclipse.swt.events.DisposeEvent in project xtext-eclipse by eclipse.
the class CheckBoxGroupFieldEditor method getCheckBoxControl.
private Control getCheckBoxControl(Composite parent) {
if (checkBoxBox == null) {
Font font = parent.getFont();
if (useGroup) {
Group group = new Group(parent, SWT.NONE);
group.setFont(font);
String text = getLabelText();
if (text != null) {
group.setText(text);
}
checkBoxBox = group;
GridLayout layout = new GridLayout();
layout.horizontalSpacing = HORIZONTAL_GAP;
layout.numColumns = numColumns;
checkBoxBox.setLayout(layout);
} else {
checkBoxBox = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.horizontalSpacing = HORIZONTAL_GAP;
layout.numColumns = numColumns;
checkBoxBox.setLayout(layout);
checkBoxBox.setFont(font);
}
checkBoxButtons = new Button[labelsAndValues.length];
for (int i = 0; i < labelsAndValues.length; i++) {
Button checkBox = new Button(checkBoxBox, SWT.CHECK | SWT.LEFT);
checkBoxButtons[i] = checkBox;
String[] labelAndValue = labelsAndValues[i];
checkBox.setText(labelAndValue[0]);
checkBox.setData(labelAndValue[1]);
checkBox.setFont(font);
checkBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setPresentsDefaultValue(false);
String oldResult = result;
result = gatherSettings();
fireValueChanged(VALUE, oldResult, result);
}
});
}
checkBoxBox.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
checkBoxBox = null;
checkBoxButtons = null;
}
});
} else {
checkParent(checkBoxBox, parent);
}
return checkBoxBox;
}
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));
}
Aggregations