use of org.eclipse.swt.events.ShellListener 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;
}
use of org.eclipse.swt.events.ShellListener in project tdi-studio-se by Talend.
the class MapperUI method createWindow.
public Shell createWindow(final Display display) {
Shell activeShell = display.getActiveShell();
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);
}
mapperShell.addShellListener(new ShellListener() {
@Override
public void shellActivated(ShellEvent e) {
}
@Override
public void shellClosed(ShellEvent e) {
if (editor != null && editor.isDirty() && !closeWithoutPrompt) {
boolean closeWindow = MessageDialog.openConfirm(mapperShell, "Close without save", Messages.getString("MapperUI.CloseWindow.Message"));
if (!closeWindow) {
e.doit = false;
} else {
prepareClosing(SWT.CANCEL);
}
}
}
@Override
public void shellDeactivated(ShellEvent e) {
}
@Override
public void shellDeiconified(ShellEvent e) {
}
@Override
public void shellIconified(ShellEvent e) {
}
});
mapperShell.setMaximized(true);
mapperShell.setImage(CoreImageProvider.getComponentIcon(mapperComponent.getComponent(), ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
mapperShell.setText(productName + " - " + mapperComponent.getComponent().getName() + " - " + //$NON-NLS-1$
mapperComponent.getUniqueName());
GridLayout parentLayout = new GridLayout(1, true);
mapperShell.setLayout(parentLayout);
// Composite composite = new Composite(mapperShell, SWT.NONE);
// composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
mainSashForm = new SashForm(mapperShell, SWT.SMOOTH | SWT.VERTICAL);
GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
mainSashForm.setLayoutData(mainSashFormGridData);
datasViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
editor = new XmlMapEditor(mapperManager);
editor.createPartControl(datasViewSashForm);
if (copyOfMapData.getVarTables().isEmpty()) {
VarTable varTable1 = XmlmapFactory.eINSTANCE.createVarTable();
varTable1.setName("Var");
varTable1.setMinimized(true);
copyOfMapData.getVarTables().add(varTable1);
}
editor.setContent(copyOfMapData);
tabFolderEditors = new TabFolderEditors(mainSashForm, mapperManager, SWT.BORDER);
// selectFirstInOutTree();
mainSashForm.setWeights(new int[] { 70, 30 });
footerComposite = new FooterComposite(mapperShell, this);
footerComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mapperShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
ColorProviderMapper.releaseColors();
FontProviderMapper.releaseFonts();
ImageProviderMapper.releaseImages();
}
});
editor.makeDefaultSelection();
mapperShell.open();
return mapperShell;
}
use of org.eclipse.swt.events.ShellListener in project cubrid-manager by CUBRID.
the class TuneModeResultWindow method open.
public void open() {
shell = new Shell(SWT.RESIZE | SWT.DIALOG_TRIM | SWT.MAX | SWT.MIN);
shell.setLayout(new GridLayout());
shell.setLayoutData(new GridData(GridData.FILL_BOTH));
shell.setText(Messages.lblTuneModeResult);
shell.setImage(CommonUIPlugin.getImage("icons/queryeditor/tune_mode.png"));
shell.setSize(800, 600);
shell.setMaximized(true);
tuneModeResult = new TuneModeResultComposite(shell, SWT.NONE);
tuneModeResult.setLayout(new GridLayout());
tuneModeResult.setLayoutData(new GridData(GridData.FILL_BOTH));
tuneModeResult.initialize();
DatabaseInfo databaseInfo = (editor == null || editor.getSelectedDatabase() == null) ? null : editor.getSelectedDatabase().getDatabaseInfo();
tuneModeResult.setDatabaseInfo(databaseInfo);
shell.addShellListener(new ShellListener() {
public void shellIconified(ShellEvent e) {
editor.hideTuneModeResult();
}
public void shellDeiconified(ShellEvent e) {
}
public void shellDeactivated(ShellEvent e) {
}
public void shellClosed(ShellEvent e) {
disposed = true;
if (tuneModeResult != null && !tuneModeResult.isDisposed()) {
tuneModeResult.dispose();
tuneModeResult = null;
}
if (shell != null && !shell.isDisposed()) {
shell.dispose();
shell.close();
}
}
public void shellActivated(ShellEvent e) {
}
});
shell.open();
}
Aggregations