Search in sources :

Example 46 with DisposeEvent

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CTabItem(org.eclipse.swt.custom.CTabItem) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Control(org.eclipse.swt.widgets.Control) Timer(java.util.Timer) TimerTask(java.util.TimerTask) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 47 with DisposeEvent

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();
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) File(java.io.File)

Example 48 with DisposeEvent

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();
                    }
                });
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 49 with DisposeEvent

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);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PalettePage(org.eclipse.gef.ui.views.palette.PalettePage) Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 50 with DisposeEvent

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;
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)366 DisposeListener (org.eclipse.swt.events.DisposeListener)363 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)75 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)70 Image (org.eclipse.swt.graphics.Image)53 Cursor (org.eclipse.swt.graphics.Cursor)49 Label (org.eclipse.swt.widgets.Label)42 ToolBar (org.eclipse.swt.widgets.ToolBar)42 Point (org.eclipse.swt.graphics.Point)38 Control (org.eclipse.swt.widgets.Control)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 Color (org.eclipse.swt.graphics.Color)34 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31