use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToOutputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToOutputButtons() {
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
outputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
}
}
if (removeButton != null) {
final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
for (TableItem item : tableViewerCreator.getTable().getSelection()) {
if (item.getData() instanceof MetadataColumn) {
MetadataColumn column = (MetadataColumn) item.getData();
removeButton.getButton().setEnabled(!column.isCustom());
break;
}
}
}
});
}
this.addDisposeListener(new DisposeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
}
}
});
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class SQLResultComposite method createTabItem.
/**
*
* DOC dev Comment method "createTabItem".
*
* @throws Exception throw all exception
*/
private void createTabItem() throws Exception {
lastTabNumber = lastTabNumber + 1;
final CTabItem tabItem = new CTabItem(tabFolder, SWT.NULL);
String labelText = Messages.getString("SQLResultComposite.Result") + ": " + lastTabNumber;
tabItem.setText(labelText);
//$NON-NLS-1$
tabItem.setData("tabLabel", labelText);
tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
Composite composite = new Composite(tabFolder, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginLeft = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
tabItem.setControl(composite);
tabItem.setData(sqlExecution);
tabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(final DisposeEvent e) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
CTabItem tabItem = (CTabItem) e.getSource();
AbstractSQLExecution sqlExe = (AbstractSQLExecution) tabItem.getData();
sqlExe.stop();
tabItem.setData(null);
if (tabFolder != null && !tabFolder.isDisposed()) {
if (tabFolder.getItemCount() == 0) {
// this is last tab..
clearParent();
setDefaultMessage();
}
} else if (tabFolder.isDisposed()) {
clearParent();
setDefaultMessage();
}
}
});
}
});
createHeaderComposite(composite, tabItem);
createDetailComposite(composite, tabItem);
// refresh view
composite.layout();
tabFolder.layout();
tabFolder.redraw();
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class TableField method getButtonBoxControl.
/**
* Returns this field editor's button box containing the Add, Remove, Up, and Down button.
*
* @param parent the parent control
* @return the button box
*/
public Composite getButtonBoxControl(Composite parent) {
buttonBox = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 5;
layout.marginTop = 0;
buttonBox.setLayout(layout);
createButtons(buttonBox);
buttonBox.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
addButton = null;
removeButton = null;
upButton = null;
downButton = null;
buttonBox = null;
}
});
selectionChanged();
return buttonBox;
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class MapperUI method addParentListeners.
private void addParentListeners(final UIManager uiManager, final ExternalDbMapUiProperties uiProperties) {
mapperUIParent.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
release();
}
});
mapperUIParent.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
if (uiManager.getMapperResponse() == SWT.NONE) {
uiManager.setMapperResponse(SWT.CANCEL);
}
}
});
mapperUIParent.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (mapperUIParent instanceof Shell) {
((Shell) mapperUIParent).addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.events.DisposeListener 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;
}
Aggregations