use of org.eclipse.swt.events.DisposeEvent in project pentaho-kettle by pentaho.
the class TransGridDelegate method addTransGrid.
/**
* Add a grid with the execution metrics per step in a table view
*/
public void addTransGrid() {
//
if (transGraph.extraViewComposite == null || transGraph.extraViewComposite.isDisposed()) {
transGraph.addExtraView();
} else {
if (transGridTab != null && !transGridTab.isDisposed()) {
// just set this one active and get out...
//
transGraph.extraViewTabFolder.setSelection(transGridTab);
return;
}
}
transGridTab = new CTabItem(transGraph.extraViewTabFolder, SWT.NONE);
transGridTab.setImage(GUIResource.getInstance().getImageShowGrid());
transGridTab.setText(BaseMessages.getString(PKG, "Spoon.TransGraph.GridTab.Name"));
transGridComposite = new Composite(transGraph.extraViewTabFolder, SWT.NONE);
transGridComposite.setLayout(new FormLayout());
addToolBar();
Control toolbarControl = (Control) toolbar.getManagedObject();
toolbarControl.setLayoutData(new FormData());
FormData fd = new FormData();
// First one in the left top corner
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
toolbarControl.setLayoutData(fd);
toolbarControl.setParent(transGridComposite);
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Stepname"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Copynr"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Read"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Written"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Input"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Output"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Updated"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Rejected"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Errors"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Active"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Time"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.Speed"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "TransLog.Column.PriorityBufferSizes"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
colinf[1].setAllignement(SWT.RIGHT);
colinf[2].setAllignement(SWT.RIGHT);
colinf[3].setAllignement(SWT.RIGHT);
colinf[4].setAllignement(SWT.RIGHT);
colinf[5].setAllignement(SWT.RIGHT);
colinf[6].setAllignement(SWT.RIGHT);
colinf[7].setAllignement(SWT.RIGHT);
colinf[8].setAllignement(SWT.RIGHT);
colinf[9].setAllignement(SWT.LEFT);
colinf[10].setAllignement(SWT.RIGHT);
colinf[11].setAllignement(SWT.RIGHT);
colinf[12].setAllignement(SWT.RIGHT);
transGridView = new TableView(transGraph.getManagedObject(), transGridComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, // readonly!
true, // Listener
null, spoon.props);
FormData fdView = new FormData();
fdView.left = new FormAttachment(0, 0);
fdView.right = new FormAttachment(100, 0);
fdView.top = new FormAttachment((Control) toolbar.getManagedObject(), 0);
fdView.bottom = new FormAttachment(100, 0);
transGridView.setLayoutData(fdView);
// Add a timer to update this view every couple of seconds...
//
final Timer tim = new Timer("TransGraph: " + transGraph.getMeta().getName());
final AtomicBoolean busy = new AtomicBoolean(false);
TimerTask timtask = new TimerTask() {
public void run() {
if (!spoon.getDisplay().isDisposed()) {
spoon.getDisplay().asyncExec(new Runnable() {
public void run() {
if (!busy.get()) {
busy.set(true);
refreshView();
busy.set(false);
}
}
});
}
}
};
// schedule to repeat a couple of times per second to get fast feedback
tim.schedule(timtask, 0L, REFRESH_TIME);
transGridTab.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent disposeEvent) {
tim.cancel();
}
});
transGridTab.setControl(transGridComposite);
transGraph.extraViewTabFolder.setSelection(transGridTab);
}
use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.
the class SaveCanvasAsTemplateWizardPage method createControl.
@Override
public void createControl(Composite parent) {
GridData gd;
Label label;
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout());
setControl(container);
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, HELP_ID);
Group fileComposite = new Group(container, SWT.NULL);
fileComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout layout = new GridLayout(3, false);
fileComposite.setLayout(layout);
label = new Label(fileComposite, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_2);
fFileTextField = new Text(fileComposite, SWT.BORDER | SWT.SINGLE);
fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
File newFile = new File(CURRENT_FOLDER, Messages.SaveCanvasAsTemplateWizardPage_3 + CanvasTemplateManager.CANVAS_TEMPLATE_FILE_EXTENSION);
fFileTextField.setText(newFile.getPath());
// Single text control so strip CRLFs
UIUtils.conformSingleTextControl(fFileTextField);
fFileTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateFields();
}
});
Button fileButton = new Button(fileComposite, SWT.PUSH);
fileButton.setText(Messages.SaveCanvasAsTemplateWizardPage_4);
fileButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
File file = chooseFile();
if (file != null) {
fFileTextField.setText(file.getPath());
CURRENT_FOLDER = file.getParentFile();
}
}
});
Group fieldGroup = new Group(container, SWT.NULL);
fieldGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
layout = new GridLayout(2, false);
fieldGroup.setLayout(layout);
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_5);
fNameTextField = new Text(fieldGroup, SWT.BORDER | SWT.SINGLE);
fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (StringUtils.isSet(fCanvasModel.getName())) {
fNameTextField.setText(fCanvasModel.getName());
}
// Single text control so strip CRLFs
UIUtils.conformSingleTextControl(fNameTextField);
fNameTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateFields();
}
});
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_6);
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fDescriptionTextField = new Text(fieldGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
fDescriptionTextField.setLayoutData(gd);
if (StringUtils.isSet(fCanvasModel.getDocumentation())) {
fDescriptionTextField.setText(fCanvasModel.getDocumentation());
}
// Thumbnail
Group thumbsGroup = new Group(container, SWT.NULL);
thumbsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
layout = new GridLayout(2, false);
thumbsGroup.setLayout(layout);
fButtonIncludeThumbnail = new Button(thumbsGroup, SWT.CHECK);
fButtonIncludeThumbnail.setText(Messages.SaveCanvasAsTemplateWizardPage_7);
fButtonIncludeThumbnail.setSelection(true);
fButtonIncludeThumbnail.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fPreviewLabel.setEnabled(fButtonIncludeThumbnail.getSelection());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fButtonIncludeThumbnail.setLayoutData(gd);
label = new Label(thumbsGroup, SWT.NULL);
// $NON-NLS-1$
label.setText(Messages.SaveCanvasAsTemplateWizardPage_8 + " ");
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fPreviewLabel = new Label(thumbsGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
gd.widthHint = 150;
fPreviewLabel.setLayoutData(gd);
// Dispose of the image here not in the main dispose() method because if the help system is showing then
// the TrayDialog is resized and this label is asked to relayout.
fPreviewLabel.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposePreviewImage();
}
});
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
}
});
fPreviewLabel.addControlListener(new ControlAdapter() {
int oldTime;
@Override
public void controlResized(ControlEvent e) {
if (e.time - oldTime > 10) {
disposePreviewImage();
TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
}
oldTime = e.time;
}
});
validateFields();
}
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;
}
Aggregations