List of usage examples for org.eclipse.jface.preference PreferenceDialog open
public int open()
From source file:uk.ac.diamond.scisoft.analysis.rcp.preference.PreferencesHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "uk.ac.diamond.scisoft.analysis.rcp.preferencePage", null, null); if (pref != null) pref.open(); return Boolean.TRUE; }
From source file:uk.ac.diamond.scisoft.analysis.rcp.preference.PrintSettingsPreferenceHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), PRINTSETTINGS_PAGE_ID, null, null); if (pref != null) pref.open(); return Boolean.TRUE; }
From source file:uk.ac.diamond.scisoft.analysis.rcp.views.ImageExplorerView.java
License:Open Source License
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { init(site);// w w w. ja va2 s . c o m String storedExtensions = ""; if (memento != null) { // Open dir path this.dirPath = memento.getString("DIR"); storedExtensions = memento.getString("FILTERS"); if (storedExtensions == null) storedExtensions = ""; } // Filter Extensions imgExtensions = new Action[ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length]; MenuManager filterMenu = new MenuManager("File Filters"); for (int i = 0; i < ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length; i++) { final int number = i; imgExtensions[i] = new Action("", IAction.AS_CHECK_BOX) { @Override public void run() { if (this.isChecked()) { filter.remove(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]); } else { filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]); } // reload the directory updateDirectory.setUser(true); updateDirectory.setPriority(Job.DECORATE); updateDirectory.schedule(1000); } }; imgExtensions[i].setText(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]); imgExtensions[i] .setDescription("Filter " + ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i] + " on/off"); if (storedExtensions.contains(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i])) { imgExtensions[i].setChecked(false); filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]); } else imgExtensions[i].setChecked(true); filterMenu.add(imgExtensions[i]); } site.getActionBars().getMenuManager().add(filterMenu); //color submenus actions final IPaletteService pservice = (IPaletteService) PlatformUI.getWorkbench() .getService(IPaletteService.class); final Collection<String> names = pservice.getColorSchemes(); String schemeName = getPreferenceColourMapChoice(); colorMenu = new MenuAction("Color"); colorMenu.setId(getClass().getName() + colorMenu.getText()); colorMenu.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/color_wheel.png")); final Map<String, IAction> paletteActions = new HashMap<String, IAction>(11); CheckableActionGroup group = new CheckableActionGroup(); for (final String paletteName : names) { final Action action = new Action(paletteName, IAction.AS_CHECK_BOX) { @Override public void run() { try { setPreferenceColourMapChoice(paletteName); IPlottingSystem system = PlottingFactory.getPlottingSystem(getPreferencePlaybackView()); if (system != null) { final Collection<ITrace> traces = system.getTraces(); if (traces != null) for (ITrace trace : traces) { if (trace instanceof IPaletteTrace) { IPaletteTrace paletteTrace = (IPaletteTrace) trace; paletteTrace.setPalette(paletteName); } } } } catch (Exception ne) { logger.error("Cannot create palette data!", ne); } } }; action.setId(paletteName); group.add(action); colorMenu.add(action); action.setChecked(paletteName.equals(schemeName)); paletteActions.put(paletteName, action); } colorMenu.setToolTipText("Histogram"); site.getActionBars().getMenuManager().add(colorMenu); // ImageExplorer preferences final Action openPreferences = new Action("Image Explorer Preferences...") { @Override public void run() { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ImageExplorerPreferencePage.ID, null, null); if (pref != null) pref.open(); } }; site.getActionBars().getMenuManager().add(openPreferences); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.views.nexus.DataSetPlotView.java
License:Apache License
private void createRightClickMenu() { final MenuManager menuManager = new MenuManager(); dataViewer.getControl().setMenu(menuManager.createContextMenu(dataViewer.getControl())); if (getSite() != null) getSite().registerContextMenu(menuManager, dataViewer); createDimensionalActions(menuManager, false); menuManager.add(new Separator(getClass().getName() + "sep1")); menuManager.add(new Action("Preferences...") { @Override// w w w .ja v a2 s . co m public void run() { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "uk.ac.diamond.scisoft.analysis.rcp.preferencePage", null, null); if (pref != null) pref.open(); } }); }
From source file:uk.ac.diamond.sda.navigator.actions.ShowLabelDecoratorPreferencesHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "org.eclipse.ui.preferencePages.Decorators", null, null); if (pref != null) pref.open(); return Boolean.TRUE; }
From source file:uk.ac.diamond.sda.navigator.views.FileView.java
License:Open Source License
@Override public void showPreferences() { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "uk.ac.diamond.sda.navigator.fileNavigatorPreferencePage", null, null); if (pref != null) { pref.open(); }/*w w w .ja va 2 s . c o m*/ }
From source file:uk.ac.gda.client.scripting.PreferencesHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), JythonPreferencePage.ID, null, null);/*from ww w.j a va 2 s.com*/ if (pref != null) pref.open(); return Boolean.TRUE; }
From source file:uk.ac.gda.views.baton.action.PreferencesAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), BatonPreferencePage.ID, null, null);/*from w ww.j ava2s . co m*/ if (pref != null) pref.open(); return Boolean.TRUE; }
From source file:ummisco.gama.ui.views.GamaPreferencesView.java
private void buildButtons() { final Label doc = new Label(shell, SWT.NONE); doc.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1)); doc.setFont(GamaFonts.boldHelpFont); doc.setText(//from w w w.ja v a 2 s. com "Some preferences can also be set in GAML, using 'gama.pref_name <- new_value;'. 'pref_name' is displayed in the contextual menu of each preference"); final Composite group1 = new Composite(shell, SWT.NONE); group1.setLayout(new FillLayout()); final GridData gridDataGroup1 = new GridData(GridData.BEGINNING, GridData.END, true, false); gridDataGroup1.widthHint = 300; group1.setLayoutData(gridDataGroup1); final Button buttonRevert = new Button(group1, SWT.PUSH | SWT.FLAT); buttonRevert.setText("Revert to defaults"); buttonRevert.setImage(GamaIcons.create(IGamaIcons.ACTION_REVERT).image()); buttonRevert.setToolTipText("Restore default values for all preferences"); final Button buttonAdvanced = new Button(group1, SWT.PUSH | SWT.FLAT); buttonAdvanced.setText("Advanced..."); buttonAdvanced.setToolTipText("Access to advanced preferences"); final Button buttonImport = new Button(group1, SWT.PUSH | SWT.FLAT); buttonImport.setText("Import..."); buttonImport.setToolTipText("Import preferences from a file..."); buttonImport.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final FileDialog fd = new FileDialog(shell, SWT.OPEN); fd.setFilterExtensions(new String[] { "*.prefs" }); final String path = fd.open(); if (path == null) { return; } GamaPreferences.applyPreferencesFrom(path, modelValues); for (final IParameterEditor ed : editors.values()) { ed.updateValue(true); } } }); final Button buttonExport = new Button(group1, SWT.PUSH | SWT.FLAT); buttonExport.setText("Export..."); buttonExport.setToolTipText("Export preferences to a model that can be run to restore or share them..."); buttonExport.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final FileDialog fd = new FileDialog(shell, SWT.SAVE); fd.setFileName("Preferences.gaml"); fd.setFilterExtensions(new String[] { "*.gaml" }); fd.setOverwrite(false); final String path = fd.open(); if (path == null) { return; } GamaPreferences.savePreferencesTo(path); } }); final Composite group2 = new Composite(shell, SWT.NONE); group2.setLayout(new FillLayout()); final GridData gridDataGroup2 = new GridData(GridData.END, GridData.END, true, false); gridDataGroup2.widthHint = 200; group2.setLayoutData(gridDataGroup2); final Button buttonCancel = new Button(group2, SWT.PUSH); buttonCancel.setText("Cancel"); buttonCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { close(); } }); final Button buttonOK = new Button(group2, SWT.PUSH); buttonOK.setText("Save"); buttonOK.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { GamaPreferences.setNewPreferences(modelValues); if (restartRequired) { restartRequired = false; final boolean restart = Messages.confirm("Restart ?", "Restart GAMA now ?"); if (restart) { close(); PlatformUI.getWorkbench().restart(true); } } else { close(); } } }); this.shell.setDefaultButton(buttonOK); buttonRevert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { GamaPreferences.revertToDefaultValues(modelValues); for (final IParameterEditor ed : editors.values()) { ed.updateValue(true); } } }); buttonAdvanced.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { close(); WorkbenchHelper.asyncRun(() -> { final PreferenceDialog pd = WorkbenchPreferenceDialog.createDialogOn(parentShell, null); pd.open(); shell.setVisible(true); }); } }); shell.addDisposeListener(e -> { saveDialogProperties(); }); shell.addControlListener(new ControlListener() { @Override public void controlResized(final ControlEvent e) { for (final IParameterEditor ed : editors.values()) { ((AbstractEditor) ed).resizeLabel(shell.getSize().x / (NB_DIVISIONS * 2)); ((AbstractEditor) ed).getLabel().update(); } for (final ParameterExpandBar bar : contents) { for (final ParameterExpandItem item : bar.getItems()) { item.setHeight(item.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y); } bar.redraw(); } shell.layout(true, true); } @Override public void controlMoved(final ControlEvent e) { } }); }
From source file:x10dt.ui.cheatsheet.actions.OpenX10PreferencesAction.java
License:Open Source License
public void run(String[] params, ICheatSheetManager manager) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); PreferenceManager prefMgr = PlatformUI.getWorkbench().getPreferenceManager(); PreferenceDialog prefsDialog = new PreferenceDialog(shell, prefMgr); prefsDialog.setSelectedNode("x10dt.core.preferences.X10PreferencePage"); prefsDialog.open(); }