use of org.eclipse.swt.events.ShellEvent in project cogtool by cogtool.
the class FrameEditorUI method addEventListeners.
/**
* Add the important event listeners to the contents.
*
* Includes both the Mouse & Mouse Motion listeners as well as the Keyboard
*
*/
protected void addEventListeners() {
// Add them to the contents.
InteractionFigure interactionLayer = view.getEditor().getInteractionFigure();
// let mouseState handle delete key events
interactionLayer.addKeyListener(mouseState);
getShell().addShellListener(new ShellAdapter() {
@Override
public void shellDeactivated(ShellEvent e) {
mouseState.cancelDynamicOperation();
}
});
}
use of org.eclipse.swt.events.ShellEvent in project translationstudio8 by heartsome.
the class ColumnRenameDialog method initComponents.
@Override
protected void initComponents(final Shell shell) {
GridLayout shellLayout = new GridLayout();
shell.setLayout(shellLayout);
shell.setText("Rename column");
// Closing the window is the same as canceling the form
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
doFormCancel(shell);
}
});
// Tabs panel
Composite panel = new Composite(shell, SWT.NONE);
panel.setLayout(new GridLayout());
GridData fillGridData = new GridData();
fillGridData.grabExcessHorizontalSpace = true;
fillGridData.horizontalAlignment = GridData.FILL;
panel.setLayoutData(fillGridData);
columnLabelPanel = new ColumnLabelPanel(panel, columnLabel, renamedColumnLabel);
try {
columnLabelPanel.edit(renamedColumnLabel);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
use of org.eclipse.swt.events.ShellEvent in project translationstudio8 by heartsome.
the class TmDbManagerDialog method configureShell.
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("dialog.TmDbManagerDialog.title"));
newShell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
if (lastShellSize == null) {
lastShellSize = getShell().getSize();
}
}
});
}
use of org.eclipse.swt.events.ShellEvent in project tdi-studio-se by Talend.
the class TalendEditPartTipHelper method hookShellListeners.
@Override
protected void hookShellListeners() {
/*
* If the cursor leaves the tip window, hide the tooltip and dispose of its shell
*/
getShell().addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
getShell().setCapture(false);
dispose();
}
});
/*
* If the mouseExit listener does not get called, dispose of the shell if the cursor is no longer in the
* tooltip. This occurs in the rare case that a mouseEnter is not received on the tooltip when it appears.
*/
getShell().addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
Point eventPoint = getShell().toDisplay(new Point(e.x, e.y));
if (!getShell().getBounds().contains(eventPoint)) {
if (isShowing()) {
getShell().setCapture(false);
}
dispose();
}
}
});
// window.
if (shellListener == null) {
shellListener = new ShellAdapter() {
@Override
public void shellDeactivated(ShellEvent event) {
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
Shell active = Display.getCurrent().getActiveShell();
if (getShell() == active || control.getShell() == active || getShell().isDisposed()) {
return;
}
if (isShowing()) {
getShell().setCapture(false);
}
dispose();
}
});
}
};
control.getShell().addShellListener(shellListener);
getShell().addShellListener(shellListener);
}
/*
* Workaround for GTK Bug - Control.setCapture(boolean) not implemented: If the cursor is not over the shell
* when it is first painted, hide the tooltip and dispose of the shell.
*/
if (SWT.getPlatform().equals("gtk")) {
//$NON-NLS-1$
getShell().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event) {
Point cursorLoc = Display.getCurrent().getCursorLocation();
if (!getShell().getBounds().contains(cursorLoc)) {
// This must be run asynchronously. If not, other paint
// listeners may attempt to paint on a disposed control.
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
if (isShowing()) {
getShell().setCapture(false);
}
dispose();
}
});
}
}
});
}
}
use of org.eclipse.swt.events.ShellEvent in project tdi-studio-se by Talend.
the class MapperUI method createWindow.
/**
* DOC amaumont Comment method "createUI".
*
* @param display
*/
public Shell createWindow(final Display display, MapperModel model) {
Shell activeShell = display.getActiveShell();
Shell mapperShell = null;
int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
if (activeShell == null) {
mapperShell = new Shell(mapperShell, style);
} else {
mapperShell = new Shell(activeShell, style);
}
this.mapperUIParent = mapperShell;
final Shell mapperShellFinal = mapperShell;
mapperShell.addShellListener(new ShellListener() {
public void shellActivated(ShellEvent e) {
}
public void shellClosed(ShellEvent e) {
UIManager uiManager = mapperManager.getUiManager();
if (uiManager.getMapperResponse() == SWT.NONE) {
for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
dataMapTableView.notifyFocusLost();
}
uiManager.setMapperResponse(SWT.CANCEL);
uiManager.prepareClosing(uiManager.getMapperResponse());
}
if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
if (!closeWindow) {
e.doit = false;
} else {
mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
}
}
}
public void shellDeactivated(ShellEvent e) {
}
public void shellDeiconified(ShellEvent e) {
}
public void shellIconified(ShellEvent e) {
}
});
MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
component.getUniqueName()));
Rectangle boundsMapper = uiProperties.getBoundsMapper();
if (uiProperties.isShellMaximized()) {
mapperShell.setMaximized(uiProperties.isShellMaximized());
} else {
if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
mapperShell.setMaximized(true);
// boundsMapper = display.getBounds(); //no need this, will cause the full problems.
} else {
// // move shell at outer of display zone to avoid visual effect on loading
// Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
// boundsMapper.height);
// shell.setBounds(tmpBoundsMapper);
boundsMapper = uiProperties.getBoundsMapper();
if (boundsMapper.x < 0) {
boundsMapper.x = 0;
}
if (boundsMapper.y < 0) {
boundsMapper.y = 0;
}
mapperShell.setBounds(boundsMapper);
}
}
createCompositeContent(model);
mapperShell.open();
return mapperShell;
}
Aggregations