Search in sources :

Example 1 with SimpleWorkingSetSelectionDialog

use of org.eclipse.ui.internal.dialogs.SimpleWorkingSetSelectionDialog in project eclipse.platform.ui by eclipse-platform.

the class WorkingSetConfigurationBlock method createContent.

/**
 * Add this block to the <code>parent</code>
 *
 * @param parent the parent to add the block to
 */
public void createContent(final Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    composite.setLayout(new GridLayout(3, false));
    enableButton = new Button(composite, SWT.CHECK);
    enableButton.setText(enableButtonLabel);
    GridData enableData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    enableData.horizontalSpan = 2;
    enableButton.setLayoutData(enableData);
    enableButton.setSelection(selectedWorkingSets.length > 0);
    newButton = new Button(composite, SWT.PUSH);
    newButton.setText(this.newButtonLabel);
    setButtonLayoutData(newButton);
    newButton.addSelectionListener(widgetSelectedAdapter(e -> createNewWorkingSet(newButton.getShell())));
    workingSetLabel = new Label(composite, SWT.NONE);
    workingSetLabel.setText(comboLabel);
    workingSetCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    textData.horizontalIndent = 0;
    workingSetCombo.setLayoutData(textData);
    selectButton = new Button(composite, SWT.PUSH);
    selectButton.setText(selectLabel);
    setButtonLayoutData(selectButton);
    selectButton.addSelectionListener(widgetSelectedAdapter(e -> {
        SimpleWorkingSetSelectionDialog dialog = new SimpleWorkingSetSelectionDialog(parent.getShell(), workingSetTypeIds, selectedWorkingSets, false);
        dialog.setMessage(WorkbenchMessages.WorkingSetGroup_WorkingSetSelection_message);
        if (dialog.open() == Window.OK) {
            IWorkingSet[] result = dialog.getSelection();
            if (result != null && result.length > 0) {
                selectedWorkingSets = result;
                PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(result[0]);
            } else {
                selectedWorkingSets = EMPTY_WORKING_SET_ARRAY;
            }
            updateWorkingSetSelection();
        }
    }));
    enableButton.addSelectionListener(widgetSelectedAdapter(e -> updateEnableState(enableButton.getSelection())));
    updateEnableState(enableButton.getSelection());
    workingSetCombo.addSelectionListener(widgetSelectedAdapter(e -> updateSelectedWorkingSets()));
    workingSetCombo.setItems(getHistoryEntries());
    if (selectedWorkingSets.length == 0 && selectionHistory.size() > 0) {
        workingSetCombo.select(historyIndex(selectionHistory.get(0)));
        updateSelectedWorkingSets();
    } else {
        updateWorkingSetSelection();
    }
}
Also used : Arrays(java.util.Arrays) WorkbenchPlugin(org.eclipse.ui.internal.WorkbenchPlugin) IWizardPage(org.eclipse.jface.wizard.IWizardPage) SimpleWorkingSetSelectionDialog(org.eclipse.ui.internal.dialogs.SimpleWorkingSetSelectionDialog) FontMetrics(org.eclipse.swt.graphics.FontMetrics) JFaceResources(org.eclipse.jface.resource.JFaceResources) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) IWorkbenchHelpContextIds(org.eclipse.ui.internal.IWorkbenchHelpContextIds) StringTokenizer(java.util.StringTokenizer) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Collator(java.text.Collator) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) WorkbenchMessages(org.eclipse.ui.internal.WorkbenchMessages) Collection(java.util.Collection) Assert(org.eclipse.core.runtime.Assert) Set(java.util.Set) IWorkingSet(org.eclipse.ui.IWorkingSet) List(java.util.List) Window(org.eclipse.jface.window.Window) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SWT(org.eclipse.swt.SWT) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) SimpleWorkingSetSelectionDialog(org.eclipse.ui.internal.dialogs.SimpleWorkingSetSelectionDialog)

Aggregations

Collator (java.text.Collator)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 StringTokenizer (java.util.StringTokenizer)1 Assert (org.eclipse.core.runtime.Assert)1 Dialog (org.eclipse.jface.dialogs.Dialog)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 JFaceResources (org.eclipse.jface.resource.JFaceResources)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Window (org.eclipse.jface.window.Window)1 IWizardPage (org.eclipse.jface.wizard.IWizardPage)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 SWT (org.eclipse.swt.SWT)1 SelectionListener.widgetSelectedAdapter (org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter)1 FontMetrics (org.eclipse.swt.graphics.FontMetrics)1