/** * Create an instance of the AboutDialog for the given window. * * @param parentShell * The parent of the dialog. */ public CustomAboutDialog(Shell parentShell) { super(parentShell); this.parentShell = parentShell; setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.WRAP); product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { productName = WorkbenchMessages.AboutDialog_defaultProductName; } // setDialogHelpAvailable(true); }
/** * Stores dialog settings. * * @param settings * settings used to store dialog */ protected void storeDialog(IDialogSettings settings) { settings.put(SHOW_STATUS_LINE, toggleStatusLineAction.isChecked()); XMLMemento memento = XMLMemento.createWriteRoot(HISTORY_SETTINGS); this.contentProvider.saveHistory(memento); StringWriter writer = new StringWriter(); try { memento.save(writer); settings.put(HISTORY_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // Simply don't store the settings StatusManager .getManager() .handle( new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_storeError, e)); } }
/** * Hook that allows to add actions to the context menu. * <p> * Subclasses may extend in order to add other actions.</p> * * @param menuManager the context menu manager * @since 3.5 */ protected void fillContextMenu(IMenuManager menuManager) { List selectedElements= ((StructuredSelection)list.getSelection()).toList(); Object item= null; for (Iterator it= selectedElements.iterator(); it.hasNext();) { item= it.next(); if (item instanceof ItemsListSeparator || !isHistoryElement(item)) { return; } } if (selectedElements.size() > 0) { removeHistoryItemAction.setText(WorkbenchMessages.FilteredItemsSelectionDialog_removeItemsFromHistoryAction); menuManager.add(removeHistoryActionContributionItem); } }
/** * Refreshes the details field according to the current selection in the * items list. */ private void refreshDetails() { StructuredSelection selection = getSelectedItems(); switch (selection.size()) { case 0: details.setInput(null); break; case 1: details.setInput(selection.getFirstElement()); break; default: details .setInput(NLS .bind( WorkbenchMessages.FilteredItemsSelectionDialog_nItemsSelected, new Integer(selection.size()))); break; } }
/** * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#updateOKStatus() */ @SuppressWarnings("restriction") @Override protected void updateOKStatus() { Status status; if (validate()) { status = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, UICoreConstant.EMPTY_STRING, null); } else { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.ElementTreeSelectionDialog_nothing_available, null); } updateStatus(status); }
/** * updateStatus * void */ protected void updateStatus() { Status status; if (validate()) { status = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, UICoreConstant.EMPTY_STRING, null); } else { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.ElementTreeSelectionDialog_nothing_available, null); } updateStatus(status); }
public ProjectSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider, ILabelProvider labelProvider, String message, String unifiedDiff) { super(parentShell); this.unifiedDiff = unifiedDiff; featureController.getFeatures(VariantSyncPlugin.getDefault() .getSupportProjectList()); setTitle(WorkbenchMessages.ListSelection_title); inputElement = input; projectSelectionDiaglog = this; this.projectContentProvider = contentProvider; this.featureContentProvider = new FeatureListViewerContentProvider(); this.projectLabelProvider = labelProvider; this.featureLabelProvider = new LabelProvider(); if (message != null) { setMessage(message); } else { setMessage(WorkbenchMessages.ListSelection_message); } }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), WorkbenchMessages.Workbench_copy); action.setToolTipText(WorkbenchMessages.Workbench_copyToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), WorkbenchMessages.Workbench_cut); action.setToolTipText(WorkbenchMessages.Workbench_cutToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), WorkbenchMessages.Workbench_delete); action.setToolTipText(WorkbenchMessages.Workbench_deleteToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); action.enableAccelerator(false); window.getWorkbench() .getHelpSystem() .setHelp(action, IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), WorkbenchMessages.Workbench_findReplace); action.setToolTipText(WorkbenchMessages.Workbench_findReplaceToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); // Find's images are commented out due to a conflict with Search. // See bug 16412. // // action.setImageDescriptor(WorkbenchImages // .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC)); // // // action.setDisabledImageDescriptor(WorkbenchImages // .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), WorkbenchMessages.Workbench_paste); action.setToolTipText(WorkbenchMessages.Workbench_pasteToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } LabelRetargetAction action = new LabelRetargetAction(getId(), WorkbenchMessages.Workbench_redo); action.setToolTipText(WorkbenchMessages.Workbench_redoToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_REDO)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED)); return action; }
public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } LabelRetargetAction action = new LabelRetargetAction(getId(), WorkbenchMessages.Workbench_undo); action.setToolTipText(WorkbenchMessages.Workbench_undoToolTip); window.getPartService().addPartListener(action); action.setActionDefinitionId(getCommandId()); ISharedImages sharedImages = window.getWorkbench() .getSharedImages(); action.setImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)); action.setDisabledImageDescriptor(sharedImages .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED)); return action; }
@Override protected void createControl(Composite parent, int styles) { super.createControl(parent, styles); final StyledText styledText = getTextWidget(); IMenuListener menuListener = new IMenuListener() { @Override public void menuAboutToShow(IMenuManager menu) { Action copyAction = createAction(ITextOperationTarget.COPY, IWorkbenchCommandConstants.EDIT_COPY); copyAction.setText(WorkbenchMessages.Workbench_copy); copyAction.setToolTipText(WorkbenchMessages.Workbench_copyToolTip); ISharedImages sharedImages = AppUtils.getActiveWorkbenchWindow().getWorkbench().getSharedImages(); copyAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); menu.add(copyAction); } }; MenuManager manager = new MenuManager(CONTEXT_MENU_ID, CONTEXT_MENU_ID); manager.setRemoveAllWhenShown(true); Menu contextMenu = manager.createContextMenu(styledText); styledText.setMenu(contextMenu); manager.addMenuListener(menuListener); }
/** * The Plugins button was pressed. Open an about dialog on the plugins for * the selected feature. */ private void handlePluginInfoPressed() { final TableItem[] items = table.getSelection(); if (items.length <= 0) { return; } final AboutBundleGroupData info = (AboutBundleGroupData) items[0] .getData(); final IBundleGroup bundleGroup = info.getBundleGroup(); final Bundle[] bundles = bundleGroup == null ? new Bundle[0] : bundleGroup.getBundles(); final AboutPluginsDialog d = new AboutPluginsDialog(getShell(), getProductName(), bundles, WorkbenchMessages.AboutFeaturesDialog_pluginInfoTitle, NLS.bind( WorkbenchMessages.AboutFeaturesDialog_pluginInfoMessage, bundleGroup.getIdentifier()), IWorkbenchHelpContextIds.ABOUT_FEATURES_PLUGINS_DIALOG); d.open(); }
/** * Update the info area */ private void updateInfoArea(AboutBundleGroupData info) { if (info == null) { imageLabel.setImage(null); text.setText(""); //$NON-NLS-1$ return; } final ImageDescriptor desc = info.getFeatureImage(); Image image = (Image) cachedImages.get(desc); if (image == null && desc != null) { image = desc.createImage(); cachedImages.put(desc, image); } imageLabel.setImage(image); final String aboutText = info.getAboutText(); textManager.setItem(null); if (aboutText != null) { textManager.setItem(AboutUtils.scan(aboutText)); } if (textManager.getItem() == null) { text.setText(WorkbenchMessages.AboutFeaturesDialog_noInformation); } }
/** * The More Info button was pressed. Open a browser with the license for the * selected item or an information dialog if there is no license, or the * browser cannot be opened. */ private void handleMoreInfoPressed() { final TableItem[] items = table.getSelection(); if (items.length <= 0) { return; } final AboutBundleGroupData info = (AboutBundleGroupData) items[0] .getData(); if (info == null || !AboutUtils.openBrowser(getShell(), info.getLicenseUrl())) { MessageDialog.openInformation(getShell(), WorkbenchMessages.AboutFeaturesDialog_noInfoTitle, WorkbenchMessages.AboutFeaturesDialog_noInformation); } }
/** * @param shell */ public AboutDialog(Shell shell) { super(shell); product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { productName = WorkbenchMessages.AboutDialog_defaultProductName; } // create a descriptive object for each BundleGroup final IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); final LinkedList<AboutBundleGroupData> groups = new LinkedList<AboutBundleGroupData>(); if (providers != null) { for (final IBundleGroupProvider provider : providers) { final IBundleGroup[] bundleGroups = provider.getBundleGroups(); for (final IBundleGroup bundleGroup : bundleGroups) { groups.add(new AboutBundleGroupData(bundleGroup)); } } } bundleGroupInfos = groups.toArray(new AboutBundleGroupData[0]); }
/** * Constructor for AboutFeaturesDialog. * * @param parentShell * the parent shell * @param productName * the product name * @param bundleGroupInfos * the bundle info */ public AboutFeaturesDialog(Shell parentShell, String productName, AboutBundleGroupData[] bundleGroupInfos, AboutBundleGroupData initialSelection) { super(parentShell); final AboutFeaturesPage page = new AboutFeaturesPage(); page.setProductName(productName); page.setBundleGroupInfos(bundleGroupInfos); page.setInitialSelection(initialSelection); String title; if (productName != null) { title = NLS.bind(WorkbenchMessages.AboutFeaturesDialog_shellTitle, productName); } else { title = WorkbenchMessages.AboutFeaturesDialog_SimpleTitle; } initializeDialog(page, title, IWorkbenchHelpContextIds.ABOUT_FEATURES_DIALOG); }
@Override protected void configureShell(Shell newShell) { super.configureShell(newShell); String productName = ""; //$NON-NLS-1$ IProduct product = Platform.getProduct(); if (product != null && product.getName() != null) productName = product.getName(); newShell.setText(NLS.bind( WorkbenchMessages.InstallationDialog_ShellTitle, productName)); }
/** * Creates a new instance of the class. * * @param shell * shell to parent the dialog on * @param multi * indicates whether dialog allows to select more than one * position in its list of items */ public FilteredItemsSelectionDialog(Shell shell, boolean multi) { super(shell); this.multi = multi; filterHistoryJob = new FilterHistoryJob(); filterJob = new FilterJob(); contentProvider = new ContentProvider(); refreshCacheJob = new RefreshCacheJob(); itemsListSeparator = new ItemsListSeparator( WorkbenchMessages.FilteredItemsSelectionDialog_separatorLabel); selectionMode = NONE; }
/** * Restores dialog using persisted settings. The default implementation * restores the status of the details line and the selection history. * * @param settings * settings used to restore dialog */ protected void restoreDialog(IDialogSettings settings) { boolean toggleStatusLine = true; if (settings.get(SHOW_STATUS_LINE) != null) { toggleStatusLine = settings.getBoolean(SHOW_STATUS_LINE); } toggleStatusLineAction.setChecked(toggleStatusLine); details.setVisible(toggleStatusLine); String setting = settings.get(HISTORY_SETTINGS); if (setting != null) { try { IMemento memento = XMLMemento.createReadRoot(new StringReader( setting)); this.contentProvider.loadHistory(memento); } catch (WorkbenchException e) { // Simply don't restore the settings StatusManager .getManager() .handle( new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_restoreError, e)); } } }
/** * Create a new header which is labelled by headerLabel. * * @param parent * @return Label the label of the header */ private Label createHeader(Composite parent) { Composite header = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; header.setLayout(layout); Label headerLabel = new Label(header, SWT.NONE); headerLabel.setText((getMessage() != null && getMessage().trim() .length() > 0) ? getMessage() : WorkbenchMessages.FilteredItemsSelectionDialog_patternLabel); headerLabel.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { e.detail = SWT.TRAVERSE_NONE; pattern.setFocus(); } } }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); headerLabel.setLayoutData(gd); createViewMenu(header); header.setLayoutData(gd); return headerLabel; }
/** * Create the labels for the list and the progress. Return the list label. * * @param parent * @return Label */ private Label createLabels(Composite parent) { Composite labels = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; labels.setLayout(layout); Label listLabel = new Label(labels, SWT.NONE); listLabel .setText(WorkbenchMessages.FilteredItemsSelectionDialog_listLabel); listLabel.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { e.detail = SWT.TRAVERSE_NONE; list.getTable().setFocus(); } } }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); listLabel.setLayoutData(gd); progressLabel = new Label(labels, SWT.RIGHT); progressLabel.setLayoutData(gd); labels.setLayoutData(gd); return listLabel; }
/** * Creates a new instance of the class. */ public RefreshJob() { super(FilteredItemsSelectionDialog.this.getParentShell() .getDisplay(), WorkbenchMessages.FilteredItemsSelectionDialog_refreshJob); setSystem(true); }
/** * Creates a new instance of the class. */ public RefreshProgressMessageJob() { super( FilteredItemsSelectionDialog.this.getParentShell() .getDisplay(), WorkbenchMessages.FilteredItemsSelectionDialog_progressRefreshJob); setSystem(true); }
private String getMessage() { if (done) return ""; //$NON-NLS-1$ String message; if (name == null) { message = subName == null ? "" : subName; //$NON-NLS-1$ } else { message = subName == null ? name : NLS .bind( WorkbenchMessages.FilteredItemsSelectionDialog_subtaskProgressMessage, new Object[] { name, subName }); } if (totalWork == 0) return message; return NLS .bind( WorkbenchMessages.FilteredItemsSelectionDialog_taskProgressMessage, new Object[] { message, new Integer( (int) ((worked * 100) / totalWork)) }); }
/** * Executes job using the given filtering progress monitor. A hook for * subclasses. * * @param monitor * progress monitor * @return result of the execution */ protected IStatus doRun(GranualProgressMonitor monitor) { try { internalRun(monitor); } catch (CoreException e) { cancel(); return new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_jobError, e); } return Status.OK_STATUS; }
/** * Main method responsible for getting the filtered items and checking * for duplicates. It is based on the * {@link FilteredItemsSelectionDialog.ContentProvider#getFilteredItems(Object, IProgressMonitor)}. * * @param checkDuplicates * <code>true</code> if data concerning elements * duplication should be computed - it takes much more time * than standard filtering * * @param monitor * progress monitor */ public void reloadCache(boolean checkDuplicates, IProgressMonitor monitor) { reset = false; if (monitor != null) { // the work is divided into two actions of the same length int totalWork = checkDuplicates ? 200 : 100; monitor .beginTask( WorkbenchMessages.FilteredItemsSelectionDialog_cacheRefreshJob, totalWork); } // the TableViewer's root (the input) is treated as parent lastFilteredItems = Arrays.asList(getFilteredItems(list.getInput(), monitor != null ? new SubProgressMonitor(monitor, 100) : null)); if (reset || (monitor != null && monitor.isCanceled())) { if (monitor != null) monitor.done(); return; } if (checkDuplicates) { checkDuplicates(monitor); } if (monitor != null) monitor.done(); }
private void addSelectionButtons(Composite composite) { Composite buttonComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 0; layout.marginWidth = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); buttonComposite.setLayout(layout); buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false)); Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, WorkbenchMessages.SelectionDialog_selectLabel, false); SelectionListener listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { projectsListViewer.setAllChecked(true); } }; selectButton.addSelectionListener(listener); Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, WorkbenchMessages.SelectionDialog_deselectLabel, false); listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { projectsListViewer.setAllChecked(false); } }; deselectButton.addSelectionListener(listener); }
private IContributionItem getCutItem() { return getItem(ActionFactory.CUT.getId(), ActionFactory.CUT.getCommandId(), ISharedImages.IMG_TOOL_CUT, ISharedImages.IMG_TOOL_CUT_DISABLED, WorkbenchMessages.Workbench_cut, WorkbenchMessages.Workbench_cutToolTip, null); }
private IContributionItem getCopyItem() { return getItem(ActionFactory.COPY.getId(), ActionFactory.COPY.getCommandId(), ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED, WorkbenchMessages.Workbench_copy, WorkbenchMessages.Workbench_copyToolTip, null); }
private IContributionItem getPasteItem() { return getItem(ActionFactory.PASTE.getId(), ActionFactory.PASTE.getCommandId(), ISharedImages.IMG_TOOL_PASTE, ISharedImages.IMG_TOOL_PASTE_DISABLED, WorkbenchMessages.Workbench_paste, WorkbenchMessages.Workbench_pasteToolTip, null); }
private IContributionItem getPrintItem() { return getItem(ActionFactory.PRINT.getId(), ActionFactory.PRINT.getCommandId(), ISharedImages.IMG_ETOOL_PRINT_EDIT, ISharedImages.IMG_ETOOL_PRINT_EDIT_DISABLED, WorkbenchMessages.Workbench_print, WorkbenchMessages.Workbench_printToolTip, null); }
private IContributionItem getDeleteItem() { return getItem(ActionFactory.DELETE.getId(), ActionFactory.DELETE.getCommandId(), ISharedImages.IMG_TOOL_DELETE, ISharedImages.IMG_TOOL_DELETE_DISABLED, WorkbenchMessages.Workbench_delete, WorkbenchMessages.Workbench_deleteToolTip, IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION); }
OpenPreferencesAction() { super(WorkbenchMessages.OpenPreferences_text); setId("preferences"); setText("Preferences"); setToolTipText("Open GAMA preferences"); setImageDescriptor(icons.desc("menu.open.preferences2")); window.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.OPEN_PREFERENCES_ACTION); }
private IContributionItem getResetPerspectiveItem() { return getItem(ActionFactory.RESET_PERSPECTIVE.getId(), ActionFactory.RESET_PERSPECTIVE.getCommandId(), null, null, WorkbenchMessages.ResetPerspective_text, WorkbenchMessages.ResetPerspective_toolTip, IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION); }