Example usage for org.eclipse.jface.dialogs IDialogConstants VERTICAL_SPACING

List of usage examples for org.eclipse.jface.dialogs IDialogConstants VERTICAL_SPACING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants VERTICAL_SPACING.

Prototype

int VERTICAL_SPACING

To view the source code for org.eclipse.jface.dialogs IDialogConstants VERTICAL_SPACING.

Click Source Link

Document

Vertical spacing in dialog units (value 4).

Usage

From source file:org.eclipse.e4.ui.internal.progress.DetailedProgressViewer.java

License:Open Source License

@Override
protected void internalRefresh(Object element) {
    if (element == null) {
        return;// w w  w  . ja v a 2s .c om
    }

    if (element.equals(getRoot())) {
        refreshAll();
        return;
    }
    Widget widget = findItem(element);
    if (widget == null) {
        add(new Object[] { element });
        return;
    }
    ((ProgressInfoItem) widget).refresh();

    // Update the minimum size
    Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    size.x += IDialogConstants.HORIZONTAL_SPACING;
    size.y += IDialogConstants.VERTICAL_SPACING;

    scrolled.setMinSize(size);
}

From source file:org.eclipse.e4.ui.internal.progress.ProgressInfoItem.java

License:Open Source License

/**
 * Create the child widgets of the receiver.
 *///from   w  ww .  j  a  v a2 s . c  om
protected void createChildren() {

    FormLayout layout = new FormLayout();
    setLayout(layout);

    jobImageLabel = new Label(this, SWT.NONE);
    Image infoImage = getInfoImage();
    jobImageLabel.setImage(infoImage);
    FormData imageData = new FormData();
    if (infoImage != null) {
        // position it in the center
        imageData.top = new FormAttachment(50, -infoImage.getBounds().height / 2);
    } else {
        imageData.top = new FormAttachment(0, IDialogConstants.VERTICAL_SPACING);
    }
    imageData.left = new FormAttachment(0, IDialogConstants.HORIZONTAL_SPACING / 2);
    jobImageLabel.setLayoutData(imageData);

    progressLabel = new Label(this, SWT.NONE);
    setMainText();

    actionBar = new ToolBar(this, SWT.FLAT);
    actionBar.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));

    // set cursor to overwrite any busy cursor we might have

    actionButton = new ToolItem(actionBar, SWT.NONE);
    actionButton.setToolTipText(ProgressMessages.NewProgressView_CancelJobToolTip);
    actionButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            actionButton.setEnabled(false);
            cancelOrRemove();
        }
    });
    actionBar.addListener(SWT.Traverse, new Listener() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.
         * widgets.Event)
         */
        public void handleEvent(Event event) {
            if (indexListener == null) {
                return;
            }
            int detail = event.detail;
            if (detail == SWT.TRAVERSE_ARROW_NEXT) {
                indexListener.selectNext();
            }
            if (detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
                indexListener.selectPrevious();
            }

        }
    });
    updateToolBarValues();

    FormData progressData = new FormData();
    progressData.top = new FormAttachment(0, IDialogConstants.VERTICAL_SPACING);
    progressData.left = new FormAttachment(jobImageLabel, IDialogConstants.HORIZONTAL_SPACING / 2);
    progressData.right = new FormAttachment(actionBar, IDialogConstants.HORIZONTAL_SPACING * -1);
    progressLabel.setLayoutData(progressData);

    mouseListener = new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            if (indexListener != null) {
                indexListener.select();
            }
        }
    };
    addMouseListener(mouseListener);
    jobImageLabel.addMouseListener(mouseListener);
    progressLabel.addMouseListener(mouseListener);

    setLayoutsForNoProgress();

    refresh();
}

From source file:org.eclipse.e4.ui.internal.progress.ProgressInfoItem.java

License:Open Source License

/**
 * Set the text of the link to the taskString.
 * //from w  w w.  j a v a 2  s  .  c om
 * @param taskString
 */
void setLinkText(Job linkJob, String taskString, int index) {

    if (index >= taskEntries.size()) {// Is it new?
        link = new Link(this, SWT.NONE);

        FormData linkData = new FormData();
        if (index == 0 || taskEntries.size() == 0) {
            Control top = progressBar;
            if (top == null) {
                top = progressLabel;
            }
            linkData.top = new FormAttachment(top, IDialogConstants.VERTICAL_SPACING);
            linkData.left = new FormAttachment(top, 0, SWT.LEFT);
            linkData.right = new FormAttachment(top, 0, SWT.RIGHT);
            // Give an initial value so as to constrain the link shortening
            linkData.width = IDialogConstants.INDENT;
        } else {
            Link previous = (Link) taskEntries.get(index - 1);
            linkData.top = new FormAttachment(previous, IDialogConstants.VERTICAL_SPACING);
            linkData.left = new FormAttachment(previous, 0, SWT.LEFT);
            linkData.right = new FormAttachment(previous, 0, SWT.RIGHT);
            // Give an initial value so as to constrain the link shortening
            linkData.width = IDialogConstants.INDENT;
        }

        link.setLayoutData(linkData);

        link.addSelectionListener(new SelectionAdapter() {
            /*
             * (non-Javadoc)
             * 
             * @see
             * org.eclipse.swt.events.SelectionListener#widgetSelected(org
             * .eclipse.swt.events.SelectionEvent)
             */
            public void widgetSelected(SelectionEvent e) {
                executeTrigger();
            }
        });

        link.addListener(SWT.Resize, new Listener() {
            /*
             * (non-Javadoc)
             * 
             * @see
             * org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.
             * swt.widgets.Event)
             */
            public void handleEvent(Event event) {

                Object text = link.getData(TEXT_KEY);
                if (text == null)
                    return;

                updateText((String) text, link);

            }
        });
        taskEntries.add(link);
    } else {
        link = (Link) taskEntries.get(index);
    }

    // check for action property
    Object actionProperty = linkJob.getProperty(IProgressConstants.ACTION_PROPERTY);
    Object commandProperty = linkJob.getProperty(IProgressConstants2.COMMAND_PROPERTY);

    if (actionProperty != null && commandProperty != null) {
        // if both are specified, then use neither
        updateTrigger(null, link);
    } else {
        Object property = actionProperty != null ? actionProperty : commandProperty;
        updateTrigger(property, link);
    }

    if (link.getData(TRIGGER_KEY) == null && (taskString == null || taskString.equals(getMainTitle()))) {
        // workaround for https://bugs.eclipse.org/383570
        taskString = ""; //$NON-NLS-1$
    }
    link.setToolTipText(taskString);
    link.setData(TEXT_KEY, taskString);

    updateText(taskString, link);

}

From source file:org.eclipse.e4.ui.internal.progress.ProgressMonitorJobsDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size./*from   w ww  .ja  v a  2 s .co  m*/
    GridLayout layout = new GridLayout();
    layout.numColumns = 1; // this is incremented by createButton
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    data.horizontalAlignment = GridData.END;
    data.grabExcessHorizontalSpace = true;
    composite.setLayoutData(data);
    composite.setFont(parent.getFont());
    // Add the buttons to the button bar.
    if (arrowCursor == null) {
        arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
    }
    createButtonsForButtonBar(composite);
    return composite;
}

From source file:org.eclipse.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Create the child widgets of the receiver.
 *///  w ww  .  jav  a 2  s . c om
protected void createChildren() {

    FormLayout layout = new FormLayout();
    setLayout(layout);

    jobImageLabel = new Label(this, SWT.NONE);
    Image infoImage = getInfoImage();
    jobImageLabel.setImage(infoImage);
    FormData imageData = new FormData();
    if (infoImage != null) {
        // position it in the center
        imageData.top = new FormAttachment(50, -infoImage.getBounds().height / 2);
    } else {
        imageData.top = new FormAttachment(0, IDialogConstants.VERTICAL_SPACING);
    }
    imageData.left = new FormAttachment(0, IDialogConstants.HORIZONTAL_SPACING / 2);
    jobImageLabel.setLayoutData(imageData);

    progressLabel = new Label(this, SWT.NONE);
    setMainText();

    actionBar = new ToolBar(this, SWT.FLAT);
    actionBar.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));

    // set cursor to overwrite any busy cursor we might have

    actionButton = new ToolItem(actionBar, SWT.NONE);
    actionButton.setToolTipText(ProgressMessages.NewProgressView_CancelJobToolTip);
    actionButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            actionButton.setEnabled(false);
            cancelOrRemove();
        }
    });
    actionBar.addListener(SWT.Traverse, new Listener() {
        @Override
        public void handleEvent(Event event) {
            if (indexListener == null) {
                return;
            }
            int detail = event.detail;
            if (detail == SWT.TRAVERSE_ARROW_NEXT) {
                indexListener.selectNext();
            }
            if (detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
                indexListener.selectPrevious();
            }

        }
    });
    updateToolBarValues();

    FormData progressData = new FormData();
    progressData.top = new FormAttachment(0, IDialogConstants.VERTICAL_SPACING);
    progressData.left = new FormAttachment(jobImageLabel, IDialogConstants.HORIZONTAL_SPACING / 2);
    progressData.right = new FormAttachment(actionBar, IDialogConstants.HORIZONTAL_SPACING * -1);
    progressLabel.setLayoutData(progressData);

    mouseListener = new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            if (indexListener != null) {
                indexListener.select();
            }
        }
    };
    addMouseListener(mouseListener);
    jobImageLabel.addMouseListener(mouseListener);
    progressLabel.addMouseListener(mouseListener);

    setLayoutsForNoProgress();

    refresh();
}

From source file:org.eclipse.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Set the layout of the widgets for the no progress case.
 *
 *//*  ww w. j a  v a2  s  . c  o m*/
private void setLayoutsForNoProgress() {

    FormData buttonData = new FormData();
    buttonData.top = new FormAttachment(progressLabel, 0, SWT.TOP);
    buttonData.right = new FormAttachment(100, IDialogConstants.HORIZONTAL_SPACING * -1);

    actionBar.setLayoutData(buttonData);
    if (taskEntries.size() > 0) {
        FormData linkData = new FormData();
        linkData.top = new FormAttachment(progressLabel, IDialogConstants.VERTICAL_SPACING);
        linkData.left = new FormAttachment(progressLabel, 0, SWT.LEFT);
        linkData.right = new FormAttachment(actionBar, 0, SWT.LEFT);
        taskEntries.get(0).setLayoutData(linkData);

    }
}

From source file:org.eclipse.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Create the progress bar and apply any style bits from style.
 *
 * @param style//from  w  w  w.  j av a  2 s  .  co  m
 */
void createProgressBar(int style) {

    FormData buttonData = new FormData();
    buttonData.top = new FormAttachment(progressLabel, 0);
    buttonData.right = new FormAttachment(100, IDialogConstants.HORIZONTAL_SPACING * -1);

    actionBar.setLayoutData(buttonData);

    progressBar = new ProgressBar(this, SWT.HORIZONTAL | style);
    FormData barData = new FormData();
    barData.top = new FormAttachment(actionBar, IDialogConstants.VERTICAL_SPACING, SWT.TOP);
    barData.left = new FormAttachment(progressLabel, 0, SWT.LEFT);
    barData.right = new FormAttachment(actionBar, IDialogConstants.HORIZONTAL_SPACING * -1);
    barData.height = MAX_PROGRESS_HEIGHT;
    barData.width = 0;// default is too large
    progressBar.setLayoutData(barData);

    if (taskEntries.size() > 0) {
        // Reattach the link label if there is one
        FormData linkData = new FormData();
        linkData.top = new FormAttachment(progressBar, IDialogConstants.VERTICAL_SPACING);
        linkData.left = new FormAttachment(progressBar, 0, SWT.LEFT);
        linkData.right = new FormAttachment(progressBar, 0, SWT.RIGHT);
        // Give an initial value so as to constrain the link shortening
        linkData.width = 20;

        taskEntries.get(0).setLayoutData(linkData);
    }
}

From source file:org.eclipse.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Set the text of the link to the taskString.
 *
 * @param taskString/*  w  w  w.  jav a  2 s .c  om*/
 */
void setLinkText(Job linkJob, String taskString, int index) {

    if (index >= taskEntries.size()) {// Is it new?
        link = new Link(this, SWT.NONE);

        FormData linkData = new FormData();
        if (index == 0 || taskEntries.size() == 0) {
            Control top = progressBar;
            if (top == null) {
                top = progressLabel;
            }
            linkData.top = new FormAttachment(top, IDialogConstants.VERTICAL_SPACING);
            linkData.left = new FormAttachment(top, 0, SWT.LEFT);
            linkData.right = new FormAttachment(top, 0, SWT.RIGHT);
            // Give an initial value so as to constrain the link shortening
            linkData.width = 20;
        } else {
            Link previous = taskEntries.get(index - 1);
            linkData.top = new FormAttachment(previous, IDialogConstants.VERTICAL_SPACING);
            linkData.left = new FormAttachment(previous, 0, SWT.LEFT);
            linkData.right = new FormAttachment(previous, 0, SWT.RIGHT);
            // Give an initial value so as to constrain the link shortening
            linkData.width = 20;
        }

        link.setLayoutData(linkData);

        link.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                executeTrigger();
            }
        });

        link.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event event) {

                Object text = link.getData(TEXT_KEY);
                if (text == null)
                    return;

                updateText((String) text, link);

            }
        });
        taskEntries.add(link);
    } else {
        link = taskEntries.get(index);
    }

    // check for action property
    Object actionProperty = linkJob.getProperty(IProgressConstants.ACTION_PROPERTY);
    Object commandProperty = linkJob.getProperty(IProgressConstants.COMMAND_PROPERTY);

    if (actionProperty != null && commandProperty != null) {
        // if both are specified, then use neither
        updateTrigger(null, link);
    } else {
        Object property = actionProperty != null ? actionProperty : commandProperty;
        updateTrigger(property, link);
    }

    if (link.getData(TRIGGER_KEY) == null && (taskString == null || taskString.equals(getMainTitle()))) {
        // workaround for https://bugs.eclipse.org/383570
        taskString = ""; //$NON-NLS-1$
    }
    link.setToolTipText(taskString);
    link.setData(TEXT_KEY, taskString);

    updateText(taskString, link);

}

From source file:org.eclipse.eatop.workspace.ui.wizards.pages.EastADLProjectWizardFirstPage.java

License:Open Source License

private Layout initGridLayout(GridLayout gridLayout, boolean margins) {

    gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    if (margins) {
        gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    } else {/*from   w  w  w  . j  av a  2  s.  c  om*/
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
    }
    return gridLayout;
}

From source file:org.eclipse.edt.ide.ui.internal.formatting.ui.CreateProfileDialog.java

License:Open Source License

public Control createDialogArea(Composite parent) {

    final int numColumns = 2;

    GridData gd;/*w w  w  . j ava2s.c o  m*/

    final GridLayout layout = new GridLayout(numColumns, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);

    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(layout);

    // Create "Profile name:" label
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = numColumns;
    gd.widthHint = convertWidthInCharsToPixels(60);
    final Label nameLabel = new Label(composite, SWT.WRAP);
    nameLabel.setText(NewWizardMessages.ProfileName);
    nameLabel.setLayoutData(gd);

    // Create text field to enter name
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = numColumns;
    fNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
    fNameText.setLayoutData(gd);
    fNameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            doValidation();
        }
    });

    // Create "Initialize settings ..." label
    gd = new GridData();
    gd.horizontalSpan = numColumns;
    Label profileLabel = new Label(composite, SWT.WRAP);
    profileLabel.setText(NewWizardMessages.InitProfileSetting);
    profileLabel.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = numColumns;
    fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    fProfileCombo.setLayoutData(gd);

    // "Open the edit dialog now" checkbox
    gd = new GridData();
    gd.horizontalSpan = numColumns;
    fEditCheckbox = new Button(composite, SWT.CHECK);
    fEditCheckbox.setText(NewWizardMessages.OpenEditDlg);
    fEditCheckbox.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            fOpenEditDialog = ((Button) e.widget).getSelection();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    final IDialogSettings dialogSettings = EDTUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
    if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) {
        fOpenEditDialog = dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
    } else {
        fOpenEditDialog = true;
    }
    fEditCheckbox.setSelection(fOpenEditDialog);

    fProfileCombo.setItems(fSortedNames);
    fProfileCombo.setText(fSortedNames[0]);
    updateStatus(fEmpty);

    applyDialogFont(composite);

    fNameText.setFocus();

    return composite;
}