List of usage examples for org.eclipse.jface.preference PreferenceDialog getTreeViewer
public TreeViewer getTreeViewer()
From source file:au.gov.ga.earthsci.application.handlers.ShowPreferencesHandler.java
License:Apache License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) throws InvocationTargetException, InterruptedException { PreferenceManager pm = PreferenceUtil.createLegacyPreferenceManager(context, registry); PreferenceDialog dialog = new PreferenceDialog(shell, pm); dialog.setPreferenceStore(/*w w w . j a va 2 s .co m*/ new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.QUALIFIER_ID)); dialog.create(); dialog.getTreeViewer().setComparator(new ViewerComparator()); dialog.getTreeViewer().expandAll(); dialog.open(); }
From source file:cc.warlock.rcp.menu.PreferencesHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { //IWarlockClient activeClient; GameView inFocus = GameView.getGameViewInFocus(); //if (inFocus != null) //{//from w ww . j a v a2s . c o m IWarlockClient activeClient = inFocus.getWarlockClient(); //} PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(Display.getDefault().getActiveShell(), new WarlockClientAdaptable(activeClient), null, null, null); dialog.getTreeViewer().expandToLevel(2); int response = dialog.open(); return null; }
From source file:cc.warlock.rcp.util.RCPUtil.java
License:Open Source License
public static int openPreferences(String pageId) { GameView inFocus = GameView.getGameViewInFocus(); IWarlockClient client = inFocus == null ? null : inFocus.getClient(); WarlockClientAdaptable clientAdapter = new WarlockClientAdaptable(client); PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(Display.getDefault().getActiveShell(), clientAdapter, pageId, null, null); if (dialog == null) return 0; dialog.getShell().setText("Warlock Preferences"); dialog.getTreeViewer().expandToLevel(2); return dialog.open(); }
From source file:com.googlecode.goclipse.ui.GoUIPlugin.java
License:Open Source License
protected void checkPrefPageIdIsValid(String prefId) { Shell shell = WorkbenchUtils.getActiveWorkbenchShell(); PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(shell, prefId, null, null); assertNotNull(prefDialog); // Don't create, just eagerly check that it exits, that the ID is correct ISelection selection = prefDialog.getTreeViewer().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.getFirstElement() instanceof IPreferenceNode) { IPreferenceNode prefNode = (IPreferenceNode) ss.getFirstElement(); if (prefNode.getId().equals(prefId)) { return; // Id exists }//from ww w . j a v a 2 s .c o m } } assertFail(); }
From source file:com.nokia.s60tools.ui.preferences.PreferenceUtils.java
License:Open Source License
/** * Open a preference page tab by ID introduced in <code>plugin.xml</code> * //from w ww . j av a 2 s. c o m * If the preference page contains tabs, and one tab is wanted to open, use this. * * @param preferencePageID ID for preference page * @param preferencePageTabID ID for preference page tab under preference page with ID <preferencePageID> * @param shell {@link Shell} */ // Warning comes from org.eclipse.jface.preference.PreferenceManager.getElements(int) because it uses raw List type as return value @SuppressWarnings("unchecked") public static void openPreferencePage(String preferencePageID, String preferencePageTabID, Shell shell) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, preferencePageID, null, null); List<IPreferenceNode> elemns = dialog.getPreferenceManager().getElements(PreferenceManager.PRE_ORDER); IPreferenceNode preferenceNode = null; //check all preference pages, if required is found for (Iterator<IPreferenceNode> iterator = elemns.iterator(); iterator.hasNext();) { preferenceNode = iterator.next(); if (preferenceNode.getId().equals(preferencePageTabID)) { break; } } //If required preference page tab was found, set that as selection if (preferenceNode != null) { dialog.getTreeViewer().setSelection(new StructuredSelection(preferenceNode)); } dialog.open(); }
From source file:com.nokia.traceviewer.view.TraceViewerView.java
License:Open Source License
public boolean openPreferencePage(TVPreferencePage TVpage) { boolean ret = false; PreferenceManager mgr = new PreferenceManager(); // Create general preference page IPreferencePage generalPage = new TraceViewerPreferencesPage(); generalPage.setTitle(TRACE_VIEWER_TITLE); IPreferenceNode generalNode = new PreferenceNode("1", generalPage); //$NON-NLS-1$ mgr.addToRoot(generalNode);/*ww w.j a va 2s.c o m*/ // Create advanced preference page IPreferencePage advancedPage = new TraceViewerAdvancedPreferencesPage(); advancedPage.setTitle(Messages.getString("TraceViewerView.AdvancedPageTitle")); //$NON-NLS-1$ IPreferenceNode advancedNode = new PreferenceNode("2", advancedPage); //$NON-NLS-1$ mgr.addTo("1", advancedNode); //$NON-NLS-1$ // Create connection preference page IPreferencePage connectionPage = new TraceViewerConnectionPreferencesPage(); connectionPage.setTitle(Messages.getString("TraceViewerView.ConnectionPageTitle")); //$NON-NLS-1$ IPreferenceNode connectionNode = new PreferenceNode("3", connectionPage); //$NON-NLS-1$ mgr.addTo("1", connectionNode); //$NON-NLS-1$ PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr); dialog.create(); dialog.getTreeViewer().expandAll(); // Switch the page switch (TVpage) { case GENERAL: dialog.getTreeViewer().setSelection(new StructuredSelection(generalNode)); break; case ADVANCED: dialog.getTreeViewer().setSelection(new StructuredSelection(advancedNode)); break; case CONNECTION: dialog.getTreeViewer().setSelection(new StructuredSelection(connectionNode)); break; default: break; } // Open dialog and get return value int ok = dialog.open(); if (ok == Window.OK) { ret = true; } return ret; }
From source file:com.nsn.squirrel.preferences.handlers.E4PreferencesHandler.java
License:Open Source License
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg) { PreferenceManager pm = prefReg.getPreferenceManager(); PreferenceDialog dialog = new PreferenceDialog(shell, pm); dialog.create();// www . j a v a2 s. com dialog.getTreeViewer().setComparator(new ViewerComparator()); dialog.getTreeViewer().expandAll(); dialog.open(); }
From source file:com.opcoach.e4.preferences.handlers.E4PreferencesHandler.java
License:Open Source License
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg) { PreferenceManager pm = prefReg.getPreferenceManager(); PreferenceDialog dialog = new PreferenceDialog(shell, pm); dialog.create();/*from w w w. j av a 2 s . c o m*/ dialog.getTreeViewer().setComparator(new ViewerComparator()); dialog.getTreeViewer().expandAll(); dialog.open(); }
From source file:io.sloeber.ui.actions.OpenPreferencesHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String pageId = event.getParameter(PreferenceUtils.PREFERENCE_PARAMETER1); String[] pages = PreferenceUtils.getPreferencePages("io.sloeber"); //$NON-NLS-1$ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, pageId, pages, null); try {/* www .j av a 2 s .c o m*/ dialog.getTreeViewer().getTree().getItems()[1].setExpanded(true); } catch (RuntimeException e) { /* swallow */} dialog.open(); return null; }
From source file:org.eclipse.cdt.debug.ui.breakpoints.CBreakpointPropertyDialogAction.java
License:Open Source License
public void run() { CBreakpointContext bpContext = getCBreakpointContext(); if (bpContext != null) { PreferenceDialog dialog = createDialog(bpContext); if (dialog != null) { TreeViewer viewer = dialog.getTreeViewer(); if (viewer != null) { viewer.setComparator(new ViewerComparator() { @Override//from w ww . j a v a 2 s . c om public int category(Object element) { if (element instanceof IPreferenceNode) { IPreferenceNode node = (IPreferenceNode) element; if (PAGE_ID_COMMON.equals(node.getId())) { return 0; } else if (node.getSubNodes() == null || node.getSubNodes().length == 0) { // Pages without children (not categories) return super.category(element) + 1; } } // Categories last. return super.category(element) + 2; } }); // Expand all categories viewer.expandToLevel(TreeViewer.ALL_LEVELS); } dialog.open(); } } }