List of usage examples for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING
int HORIZONTAL_SPACING
To view the source code for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING.
Click Source Link
From source file:org.eclipse.ui.ide.dialogs.ImportTypeDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { boolean linkIsOnlyChoice = hasFlag(IMPORT_LINK) && !(hasFlag(IMPORT_COPY | IMPORT_MOVE) || (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS) && !hasFlag(IMPORT_FILES_ONLY))); if (!linkIsOnlyChoice) createMessageArea(parent);/*from w w w . j a va2s . co m*/ Composite composite = new Composite(parent, 0); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(gridData); composite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); int indent = linkIsOnlyChoice ? 0 : convertWidthInCharsToPixels(3); layout.marginWidth += indent; composite.setLayout(layout); SelectionListener listener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { currentSelection = ((Integer) e.widget.getData()).intValue(); refreshSelection(); } public void widgetSelected(SelectionEvent e) { currentSelection = ((Integer) e.widget.getData()).intValue(); refreshSelection(); } }; if (hasFlag(IMPORT_COPY)) { copyButton = new Button(composite, SWT.RADIO); copyButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_copyFiles : IDEWorkbenchMessages.ImportTypeDialog_copyFilesAndDirectories); gridData = new GridData(GridData.FILL_HORIZONTAL); copyButton.setLayoutData(gridData); copyButton.setData(new Integer(IMPORT_COPY)); copyButton.addSelectionListener(listener); copyButton.setFont(parent.getFont()); } if (hasFlag(IMPORT_MOVE)) { moveButton = new Button(composite, SWT.RADIO); moveButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_moveFiles : IDEWorkbenchMessages.ImportTypeDialog_moveFilesAndDirectories); gridData = new GridData(GridData.FILL_HORIZONTAL); moveButton.setLayoutData(gridData); moveButton.setData(new Integer(IMPORT_MOVE)); moveButton.addSelectionListener(listener); moveButton.setFont(parent.getFont()); } if (hasFlag(IMPORT_LINK) && !linkIsOnlyChoice) { linkButton = new Button(composite, SWT.RADIO); linkButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_linkFiles : IDEWorkbenchMessages.ImportTypeDialog_createLinks); gridData = new GridData(GridData.FILL_HORIZONTAL); linkButton.setLayoutData(gridData); linkButton.setData(new Integer(IMPORT_LINK)); linkButton.addSelectionListener(listener); linkButton.setFont(parent.getFont()); } if (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS) && !hasFlag(IMPORT_FILES_ONLY)) { shadowCopyButton = new Button(composite, SWT.RADIO); shadowCopyButton.setText(IDEWorkbenchMessages.ImportTypeDialog_recreateFilesAndDirectories); gridData = new GridData(GridData.FILL_HORIZONTAL); shadowCopyButton.setLayoutData(gridData); shadowCopyButton.setData(new Integer(IMPORT_VIRTUAL_FOLDERS_AND_LINKS)); shadowCopyButton.addSelectionListener(listener); shadowCopyButton.setFont(parent.getFont()); } if (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS | IMPORT_LINK)) { relativePathVariableGroup = new RelativePathVariableGroup(new RelativePathVariableGroup.IModel() { public IResource getResource() { return receivingResource; } public void setVariable(String string) { variable = string; } public String getVariable() { return variable; } }); int groupIndent = 0; if (!linkIsOnlyChoice) { Button tmp = new Button(composite, SWT.CHECK); tmp.setText("."); //$NON-NLS-1$ groupIndent = tmp.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; tmp.dispose(); Label tmpLabel = new Label(composite, SWT.NONE); tmpLabel.setText("."); //$NON-NLS-1$ groupIndent -= tmpLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; tmpLabel.dispose(); } Composite variableGroup = new Composite(composite, 0); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.horizontalIndent = groupIndent; variableGroup.setLayoutData(gridData); variableGroup.setFont(parent.getFont()); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; variableGroup.setLayout(layout); relativePathVariableGroup.createContents(variableGroup); relativePathVariableGroup.setSelection(variable != null); if (variable != null) relativePathVariableGroup.selectVariable(variable); else relativePathVariableGroup.selectVariable(preferredVariable); } if (linkIsOnlyChoice) { currentSelection = IMPORT_LINK; parent.getShell().setText(IDEWorkbenchMessages.ImportTypeDialog_titleFilesLinking); } createLinkControl(parent); refreshSelection(); return composite; }
From source file:org.eclipse.ui.ide.markers.compatibility.internal.QuickFixPage.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);//from w ww .ja v a 2 s .c o m // Create a new composite as there is the title bar seperator // to deal with Composite control = new Composite(parent, SWT.NONE); control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); setControl(control); FormLayout layout = new FormLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); control.setLayout(layout); Label resolutionsLabel = new Label(control, SWT.NONE); resolutionsLabel.setText(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title); resolutionsLabel.setLayoutData(new FormData()); createResolutionsList(control); FormData listData = new FormData(); listData.top = new FormAttachment(resolutionsLabel, 0); listData.left = new FormAttachment(0); listData.right = new FormAttachment(100, 0); listData.height = convertHeightInCharsToPixels(10); resolutionsList.getControl().setLayoutData(listData); Label title = new Label(control, SWT.NONE); title.setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Title); FormData labelData = new FormData(); labelData.top = new FormAttachment(resolutionsList.getControl(), 0); labelData.left = new FormAttachment(0); title.setLayoutData(labelData); Composite buttons = createTableButtons(control); FormData buttonData = new FormData(); buttonData.top = new FormAttachment(title, 0); buttonData.right = new FormAttachment(100); buttonData.height = convertHeightInCharsToPixels(10); buttons.setLayoutData(buttonData); createMarkerTable(control); FormData tableData = new FormData(); tableData.top = new FormAttachment(buttons, 0, SWT.TOP); tableData.left = new FormAttachment(0); tableData.bottom = new FormAttachment(100); tableData.right = new FormAttachment(buttons, 0); tableData.height = convertHeightInCharsToPixels(10); markersTable.getControl().setLayoutData(tableData); Dialog.applyDialogFont(control); resolutionsList.setSelection(new StructuredSelection(resolutionsList.getElementAt(0))); markersTable.setAllChecked(true); }
From source file:org.eclipse.ui.ide.markers.compatibility.internal.QuickFixPage.java
License:Open Source License
/** * Create the table buttons for the receiver. * /* w ww . j a v a2 s . c om*/ * @param control * @return {@link Composite} */ private Composite createTableButtons(Composite control) { Composite buttonComposite = new Composite(control, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); buttonComposite.setLayout(layout); Button selectAll = new Button(buttonComposite, SWT.PUSH); selectAll.setText(MarkerMessages.selectAllAction_title); selectAll.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); selectAll.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent arg0) { markersTable.setAllChecked(true); setPageComplete(!resolutionsList.getSelection().isEmpty()); } }); Button deselectAll = new Button(buttonComposite, SWT.PUSH); deselectAll.setText(MarkerMessages.filtersDialog_deselectAll); deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); deselectAll.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent arg0) { markersTable.setAllChecked(false); setPageComplete(false); } }); return buttonComposite; }
From source file:org.eclipse.ui.internal.activities.ws.ActivityEnabler.java
License:Open Source License
private GridLayout createGridLayoutWithoutMargins(int nColumns, FontMetrics fontMetrics) { GridLayout layout = new GridLayout(nColumns, false); layout.marginHeight = 0;//from w w w . j a va2 s . c o m layout.marginWidth = 0; layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); return layout; }
From source file:org.eclipse.ui.internal.cheatsheets.dialogs.CheatSheetCategoryBasedSelectionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);//from w w w.j a va 2 s. com IDialogSettings workbenchSettings = CheatSheetPlugin.getPlugin().getDialogSettings(); IDialogSettings dialogSettings = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION); if (dialogSettings == null) dialogSettings = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION); setDialogSettings(dialogSettings); // top level group Composite outerContainer = (Composite) super.createDialogArea(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, CHEAT_SHEET_SELECTION_HELP_ID); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); outerContainer.setLayout(gridLayout); outerContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create label createMessageArea(outerContainer); // Create radio button selectRegisteredRadio = new Button(outerContainer, SWT.RADIO); selectRegisteredRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_REGISTERED); SashForm sform = new SashForm(outerContainer, SWT.VERTICAL); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = 300; sform.setLayoutData(data); // category tree pane treeViewer = new TreeViewer(sform, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); treeViewer.getTree().setLayoutData(data); treeViewer.setContentProvider(getCheatSheetProvider()); treeViewer.setLabelProvider(new CheatsheetLabelProvider()); treeViewer.setComparator(CheatSheetCollectionSorter.INSTANCE); treeViewer.addFilter(activityViewerFilter); treeViewer.addSelectionChangedListener(this); treeViewer.setInput(cheatsheetCategories); desc = new Text(sform, SWT.MULTI | SWT.WRAP); desc.setEditable(false); sform.setWeights(new int[] { 10, 2 }); if (activityViewerFilter.getHasEncounteredFilteredItem()) createShowAllButton(outerContainer); // Add double-click listener treeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object obj = selection.getFirstElement(); if (obj instanceof CheatSheetCollectionElement) { boolean state = treeViewer.getExpandedState(obj); treeViewer.setExpandedState(obj, !state); } else { okPressed(); } } }); // RAP [if] Selecting the file from the local machine is not supported // // Create radio button for select from file // selectFileRadio = new Button(outerContainer, SWT.RADIO); // selectFileRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_FROM_FILE); // // Composite selectFileComposite = new Composite(outerContainer, SWT.NULL); // GridLayout selectFileLayout = new GridLayout(); // selectFileLayout.marginWidth = 0; // selectFileLayout.marginHeight = 0; // selectFileLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // selectFileLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); // selectFileLayout.numColumns = 2; // selectFileComposite.setLayout(selectFileLayout); // GridData sfCompositeData = new GridData(GridData.FILL_HORIZONTAL); // sfCompositeData.widthHint = 300; // selectFileComposite.setLayoutData(sfCompositeData); // selectFileCombo = new Combo(selectFileComposite, SWT.BORDER); // GridData sfTextData = new GridData(GridData.FILL_HORIZONTAL); // selectFileCombo.setLayoutData(sfTextData); // browseFileButton = new Button(selectFileComposite, SWT.NULL); // browseFileButton.setText(Messages.get().SELECTION_DIALOG_FILEPICKER_BROWSE); // setButtonLayoutData(browseFileButton); // Create radio button for select from URL selectUrlRadio = new Button(outerContainer, SWT.RADIO); selectUrlRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_FROM_URL); selectUrlCombo = new Combo(outerContainer, SWT.BORDER); GridData suTextData = new GridData(GridData.FILL_HORIZONTAL); selectUrlCombo.setLayoutData(suTextData); restoreWidgetValues(); restoreFileSettings(); if (!treeViewer.getSelection().isEmpty()) // we only set focus if a selection was restored treeViewer.getTree().setFocus(); Dialog.applyDialogFont(outerContainer); // RAP [if] Selecting the file from the local machine is not supported // selectFileCombo.addModifyListener(new FileAndUrlListener()); // browseFileButton.addSelectionListener(new BrowseListener()); selectRegisteredRadio.addSelectionListener(new RadioSelectionListener()); selectUrlRadio.addSelectionListener(new RadioSelectionListener()); selectUrlCombo.addModifyListener(new FileAndUrlListener()); checkRadioButtons(); return outerContainer; }
From source file:org.eclipse.ui.internal.dialogs.AbstractWorkingSetDialog.java
License:Open Source License
/** * Add the select/deselect buttons./*from w ww . j a v a 2 s . co m*/ * * @param composite Composite to add the buttons to */ protected void addSelectionButtons(Composite composite) { Composite buttonComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = layout.marginWidth = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); buttonComposite.setLayout(layout); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); buttonComposite.setLayoutData(data); selectAllButton = createButton(buttonComposite, ID_SELECTALL, WorkbenchMessages.SelectionDialog_selectLabel, false); selectAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectAllSets(); } }); deselectAllButton = createButton(buttonComposite, ID_DESELECTALL, WorkbenchMessages.SelectionDialog_deselectLabel, false); deselectAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { deselectAllSets(); } }); }
From source file:org.eclipse.ui.internal.dialogs.PerspectivesPreferencePage.java
License:Open Source License
/** * Creates and returns the vertical button bar. * /*from ww w.j ava2 s. c om*/ * @param parent * the parent composite to contain the button bar * @return the button bar control */ protected Control createVerticalButtonBar(Composite parent) { // Create composite. Composite composite = new Composite(parent, SWT.NULL); // create a layout with spacing and margins appropriate for the font // size. GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginWidth = 5; layout.marginHeight = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); composite.setLayout(layout); composite.setFont(parent.getFont()); // Add the buttons to the button bar. setDefaultButton = createVerticalButton(composite, WorkbenchMessages.PerspectivesPreference_MakeDefault, false); setDefaultButton.setToolTipText(WorkbenchMessages.PerspectivesPreference_MakeDefaultTip); revertButton = createVerticalButton(composite, WorkbenchMessages.PerspectivesPreference_Reset, false); revertButton.setToolTipText(WorkbenchMessages.PerspectivesPreference_ResetTip); deleteButton = createVerticalButton(composite, WorkbenchMessages.PerspectivesPreference_Delete, false); deleteButton.setToolTipText(WorkbenchMessages.PerspectivesPreference_DeleteTip); updateButtons(); return composite; }
From source file:org.eclipse.ui.internal.dialogs.SimpleWorkingSetSelectionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/*from w ww . j a v a 2s. com*/ Composite composite = (Composite) super.createDialogArea(parent); Composite viewerComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = layout.marginWidth = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); viewerComposite.setLayout(layout); viewerComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); viewer = CheckboxTableViewer.newCheckList(viewerComposite, SWT.BORDER); viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); viewer.setLabelProvider(new WorkingSetLabelProvider()); viewer.setContentProvider(new ArrayContentProvider()); viewer.addFilter(new WorkingSetFilter(null)); IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets(); viewer.setInput(workingSets); viewer.setFilters(new ViewerFilter[] { new Filter() }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged(); } }); viewer.setCheckedElements(initialSelection); GridData viewerData = new GridData(GridData.FILL_BOTH); viewerData.widthHint = convertWidthInCharsToPixels(50); viewer.getControl().setLayoutData(viewerData); addModifyButtons(viewerComposite); addSelectionButtons(composite); availableWorkingSetsChanged(); Dialog.applyDialogFont(composite); viewerData.heightHint = viewer.getTable().getItemHeight() * Math.min(30, Math.max(10, workingSets.length)); return composite; }
From source file:org.eclipse.ui.internal.dialogs.WorkbenchEditorsDialog.java
License:Open Source License
/** * Creates the contents of this dialog, initializes the * listener and the update thread./*from w ww .j a v a2 s . co m*/ */ protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Font font = parent.getFont(); Composite dialogArea = new Composite(parent, SWT.NONE); CellLayout dialogAreaLayout = new CellLayout(1) .setMargins(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .setSpacing(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .setRow(1, Row.growing()); dialogArea.setLayout(dialogAreaLayout); dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH)); //Label over the table Label l = new Label(dialogArea, SWT.NONE); l.setText(WorkbenchMessages.WorkbenchEditorsDialog_label); l.setFont(font); l.setLayoutData(new CellData().align(SWT.FILL, SWT.CENTER)); //Table showing the editors name, full path and perspective editorsTable = new Table(dialogArea, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); editorsTable.setLinesVisible(true); editorsTable.setHeaderVisible(true); editorsTable.setFont(font); final int height = 16 * editorsTable.getItemHeight(); final int width = (int) (2.5 * height); CellData tableData = new CellData().align(SWT.FILL, SWT.FILL).setHint(CellData.OVERRIDE, width, height); editorsTable.setLayoutData(tableData); editorsTable.setLayout(new Layout() { protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { return new Point(width, height); } protected void layout(Composite composite, boolean flushCache) { TableColumn c[] = editorsTable.getColumns(); if (columnsWidth == null) { int w = editorsTable.getClientArea().width; c[0].setWidth(w * 1 / 3); c[1].setWidth(w - c[0].getWidth()); } else { c[0].setWidth(columnsWidth[0]); c[1].setWidth(columnsWidth[1]); } editorsTable.setLayout(null); } }); //Name column TableColumn tc = new TableColumn(editorsTable, SWT.NONE); tc.setResizable(true); tc.setText(WorkbenchMessages.WorkbenchEditorsDialog_name); tc.addSelectionListener(headerListener); //Full path column tc = new TableColumn(editorsTable, SWT.NONE); tc.setResizable(true); tc.setText(WorkbenchMessages.WorkbenchEditorsDialog_path); tc.addSelectionListener(headerListener); // A composite for selection option buttons Composite selectionButtons = new Composite(dialogArea, SWT.NULL); Label compLabel = new Label(selectionButtons, SWT.NULL); compLabel.setFont(font); GridLayout layout = new GridLayout(); layout.numColumns = 4; selectionButtons.setLayout(layout); //Select clean editors button selectClean = new Button(selectionButtons, SWT.PUSH); selectClean.setText(WorkbenchMessages.WorkbenchEditorsDialog_selectClean); selectClean.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editorsTable.setSelection(selectClean(editorsTable.getItems())); updateButtons(); } }); selectClean.setFont(font); setButtonLayoutData(selectClean); //Invert selection button invertSelection = new Button(selectionButtons, SWT.PUSH); invertSelection.setText(WorkbenchMessages.WorkbenchEditorsDialog_invertSelection); invertSelection.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editorsTable.setSelection(invertedSelection(editorsTable.getItems(), editorsTable.getSelection())); updateButtons(); } }); invertSelection.setFont(font); setButtonLayoutData(invertSelection); //Select all button allSelection = new Button(selectionButtons, SWT.PUSH); allSelection.setText(WorkbenchMessages.WorkbenchEditorsDialog_allSelection); allSelection.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editorsTable.setSelection(editorsTable.getItems()); updateButtons(); } }); allSelection.setFont(font); setButtonLayoutData(allSelection); // A composite for selected editor action buttons Composite actionButtons = new Composite(dialogArea, SWT.NULL); Label actLabel = new Label(actionButtons, SWT.NULL); actLabel.setFont(font); GridLayout actLayout = new GridLayout(); actLayout.numColumns = 4; actionButtons.setLayout(actLayout); // Activate selected editor button createButton(actionButtons, IDialogConstants.OK_ID, WorkbenchMessages.WorkbenchEditorsDialog_activate, true); //Close selected editors button closeSelected = new Button(actionButtons, SWT.PUSH); closeSelected.setText(WorkbenchMessages.WorkbenchEditorsDialog_closeSelected); closeSelected.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { closeItems(editorsTable.getSelection()); } }); closeSelected.setFont(font); setButtonLayoutData(closeSelected); //Save selected editors button saveSelected = new Button(actionButtons, SWT.PUSH); saveSelected.setText(WorkbenchMessages.WorkbenchEditorsDialog_saveSelected); saveSelected.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { saveItems(editorsTable.getSelection()); } }); saveSelected.setFont(font); setButtonLayoutData(saveSelected); //Show only active perspective button final Button showAllPerspButton = new Button(dialogArea, SWT.CHECK); showAllPerspButton.setText(WorkbenchMessages.WorkbenchEditorsDialog_showAllPersp); showAllPerspButton.setSelection(showAllPersp); showAllPerspButton.setFont(font); setButtonLayoutData(showAllPerspButton); showAllPerspButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showAllPersp = showAllPerspButton.getSelection(); updateItems(); } }); //Create the items and update buttons state updateItems(); updateButtons(); editorsTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateButtons(); } public void widgetDefaultSelected(SelectionEvent e) { okPressed(); } }); editorsTable.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { for (Iterator images = imageCache.values().iterator(); images.hasNext();) { Image i = (Image) images.next(); i.dispose(); } for (Iterator images = disabledImageCache.values().iterator(); images.hasNext();) { Image i = (Image) images.next(); i.dispose(); } } }); editorsTable.setFocus(); applyDialogFont(dialogArea); return dialogArea; }
From source file:org.eclipse.ui.internal.dialogs.WorkingSetSelectionDialog.java
License:Open Source License
/** * Overrides method from Dialog./*from w w w. j a v a 2 s . c o m*/ * Create the dialog widgets. * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) */ protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Composite composite = (Composite) super.createDialogArea(parent); createMessageArea(composite); SelectionListener listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateButtonAvailability(); } }; buttonWindowSet = new Button(composite, SWT.RADIO); buttonWindowSet.setText(WorkbenchMessages.WindowWorkingSets); buttonWindowSet.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); buttonWindowSet.addSelectionListener(listener); buttonNoSet = new Button(composite, SWT.RADIO); buttonNoSet.setText(WorkbenchMessages.NoWorkingSet); buttonNoSet.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); buttonNoSet.addSelectionListener(listener); buttonSelectedSets = new Button(composite, SWT.RADIO); buttonSelectedSets.setText(WorkbenchMessages.SelectedWorkingSets); buttonSelectedSets.addSelectionListener(listener); switch (getInitialRadioSelection()) { case 0: buttonWindowSet.setSelection(true); break; case 1: buttonNoSet.setSelection(true); break; case 2: buttonSelectedSets.setSelection(true); break; } buttonSelectedSets.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite viewerComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = layout.marginWidth = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); viewerComposite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT; data.widthHint = SIZING_SELECTION_WIDGET_WIDTH + 300; // fudge? I like fudge. viewerComposite.setLayoutData(data); listViewer = CheckboxTableViewer.newCheckList(viewerComposite, SWT.BORDER | SWT.MULTI); data = new GridData(GridData.FILL_BOTH); data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT; data.widthHint = SIZING_SELECTION_WIDGET_WIDTH; listViewer.getTable().setLayoutData(data); listViewer.setLabelProvider(labelProvider); listViewer.setContentProvider(contentProvider); listViewer.setComparator(new WorkbenchViewerComparator()); listViewer.addFilter(new WorkingSetFilter(getSupportedWorkingSetIds())); listViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged(); } }); listViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object obj = ((IStructuredSelection) listViewer.getSelection()).getFirstElement(); listViewer.setCheckedElements(new Object[] { obj }); buttonWindowSet.setSelection(false); buttonNoSet.setSelection(false); buttonSelectedSets.setSelection(true); okPressed(); } }); listViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { // implicitly select the third radio button buttonWindowSet.setSelection(false); buttonNoSet.setSelection(false); buttonSelectedSets.setSelection(true); } }); addModifyButtons(viewerComposite); addSelectionButtons(composite); listViewer.setInput(Arrays.asList(WorkbenchPlugin.getDefault().getWorkingSetManager().getWorkingSets())); List initialElementSelections = getInitialElementSelections(); if (multiSelect) { listViewer.setCheckedElements(initialElementSelections.toArray()); } else if (!initialElementSelections.isEmpty()) { IWorkingSet set = (IWorkingSet) initialElementSelections.get(0); if (set instanceof AggregateWorkingSet) { AggregateWorkingSet aggregate = (AggregateWorkingSet) set; listViewer.setCheckedElements(aggregate.getComponents()); } else { listViewer.setCheckedElements(initialElementSelections.toArray()); } } availableWorkingSetsChanged(); Dialog.applyDialogFont(composite); return composite; }