Java 类org.eclipse.jface.preference.PreferenceManager 实例源码

项目:vsDiaryWriter    文件:ViperfishEncryptionProvider.java   
@Override
public void registerConfig() {
    ConfigurationGUISetup setup = new ConfigurationGUISetup() {

        @Override
        public void proccess(PreferenceManager mger) {
            PreferenceNode encryption = new PreferenceNode("compressMac", "Encryption", null,
                    CompressMacPreference.class.getCanonicalName());
            PreferenceNode blockCipher = new PreferenceNode("blockcipher", "Block Cipher", null,
                    BlockCipherPreferencePage.class.getCanonicalName());
            PreferenceNode streamCipher = new PreferenceNode("streamcipher", "Stream Cipher", null,
                    StreamCipherPreferencePage.class.getCanonicalName());
            encryption.add(blockCipher);
            encryption.add(streamCipher);
            mger.addToRoot(encryption);
        }
    };

    PreferenceGUIManager.add(setup);
}
项目:bts    文件:E4PreferencesHandler.java   
@Execute
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,  E4PreferenceRegistry prefReg, 
            @Optional @Named("preferencePageId") String pageId)
    {
        PreferenceManager pm = prefReg.getPreferenceManager();
        PreferenceDialog dialog = new PreferenceDialog(shell, pm);
        if (pageId != null)
        {
            dialog.setSelectedNode(pageId);
        }

        dialog.create();
        dialog.getTreeViewer().setComparator(new ViewerComparator());
//      dialog.getTreeViewer().expandAll();
        dialog.open();

    }
项目:jsweet-eclipse-plugin    文件:FieldEditorProjectPreferencePage.java   
private void configureWorkspaceSettings() {
    String preferenceNodeId = this.getPreferenceNodeId();
    IPreferencePage preferencePage = newPreferencePage();
    final IPreferenceNode preferenceNode = new PreferenceNode(preferenceNodeId, preferencePage);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(preferenceNode);
    final PreferenceDialog dialog = new PreferenceDialog(this.getControl().getShell(), manager);
    BusyIndicator.showWhile(this.getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(preferenceNode.getLabelText());
            dialog.open();
        }
    });
}
项目:scouter    文件:RCPUtil.java   
public static void hidePreference(String[] ids){
//      List<String> list = Arrays.asList(ids);
        PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
//        @SuppressWarnings("unchecked")
//        List<IPreferenceNode> preferenceNodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER);
//        for (Iterator<IPreferenceNode> it = preferenceNodes.iterator(); it.hasNext();) {
//            IPreferenceNode preferenceNode = (IPreferenceNode)it.next();
//            if (list.contains(preferenceNode.getId())) {
//                preferenceManager.remove(preferenceNode);
//            }
//        }

        for(String id : ids){
            preferenceManager.remove(id);
        }

    }
项目:PDFReporter-Studio    文件:FieldEditorOverlayPage.java   
/**
 * Show a single preference pages
 * 
 * @param id
 *          - the preference page identification
 * @param page
 *          - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page, final IProject project) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    Shell shell = getControl().getShell();
    final PreferenceDialog dialog = project == null ? new PreferenceDialog(shell, manager) : new PropertyDialog(shell,
            manager, new StructuredSelection(project));
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:JFaceUtils    文件:EnhancedPreferenceDialog.java   
@Override
protected void handleSave() {
    final Iterator<IPreferenceNode> nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator();
    while (nodes.hasNext()) {
        final IPreferenceNode node = nodes.next();
        final IPreferencePage page = node.getPage();
        if (page instanceof PreferencePage) {
            final IPreferenceStore store = ((PreferencePage) page).getPreferenceStore();
            if (store != null && store.needsSaving() && store instanceof IPersistentPreferenceStore) {
                try {
                    ((IPersistentPreferenceStore) store).save();
                }
                catch (final IOException ioe) {
                    final String message = JFaceMessages.get("err.preferences.save");
                    logger.log(Level.SEVERE, message, ioe);
                    EnhancedErrorDialog.openError(getShell(), title, message, IStatus.ERROR, ioe, new Image[] { Display.getCurrent().getSystemImage(SWT.ICON_ERROR) });
                }
            }
        }
    }
}
项目:JFaceUtils    文件:Preferences.java   
protected PreferenceManager createPreferenceManager() {
    final PreferenceManager manager = new PreferenceManager();

    // Pages creation...
    final Map<IPageDefinition, PreferenceNode> preferenceNodes = new HashMap<IPageDefinition, PreferenceNode>();
    for (final IPageDefinition page : pageDefinitions) {
        final PreferenceNode preferenceNode = new ConfigurationNode(page, preferences, preferencesCallback);
        if (page.getParent() != null) {
            preferenceNodes.get(page.getParent()).add(preferenceNode);
        }
        else {
            manager.addToRoot(preferenceNode);
        }
        preferenceNodes.put(page, preferenceNode);
    }
    return manager;
}
项目:APICloud-Studio    文件:PropertyLinkArea.java   
@SuppressWarnings("rawtypes")
private IPreferenceNode getPreferenceNode(String pageId)
{
    /*
     * code pulled from org.eclipse.ui.internal.dialogs.PropertyDialog - i'm not sure why this type of class doesn't
     * already exist for property pages like it does for preference pages since it seems it would be very useful -
     * guess we're breaking new ground :)
     */
    PropertyPageManager pageManager = new PropertyPageManager();
    PropertyPageContributorManager.getManager().contribute(pageManager, element);

    Iterator pages = pageManager.getElements(PreferenceManager.PRE_ORDER).iterator();

    while (pages.hasNext())
    {
        IPreferenceNode node = (IPreferenceNode) pages.next();
        if (node.getId().equals(pageId))
        {
            return node;
        }
    }

    return null;
}
项目:APICloud-Studio    文件:SWTUtil.java   
/**
 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
 * 
 * @param id
 *            the id of pref page to show
 * @param page
 *            the actual page to show Copied from org.eclipse.debug.internal.ui.SWTUtil
 */
public static void showPreferencePage(String id, IPreferencePage page)
{
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(UIUtils.getActiveShell(), manager);
    BusyIndicator.showWhile(getStandardDisplay(), new Runnable()
    {
        public void run()
        {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:OpenSPIFe    文件:EnsembleWorkbenchWindowAdvisor.java   
protected final void cleanupPreferencePages() {
    Collection<Pattern> patterns = new HashSet<Pattern>();
    for (String s : getUndesirablePreferencePageIDRegExes())
        patterns.add(Pattern.compile(s));
    if (patterns.size() == 0)
        return;
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    for (IPreferenceNode node : manager.getRootSubNodes()) {
        for (Pattern pattern : patterns) {
            if (pattern.matcher(node.getId()).matches()) {
                manager.remove(node);
                continue;
            }
        }
        cleanupPreferencePages(node, patterns);
    }
}
项目:dazzl    文件:BluetoothPlugin.java   
public void registerPreferenceNodes(PreferenceManager preferenceManager)
{
    String className;

    //System.out.println("BT AVAIL: " + btAvailable + " and asterisk 1.2: "
    //        + asterisk.getVersion().contains("Asterisk 1.2"));

    //if (asterisk.supportsRedirectMode() && btAvailable)
    //TODO fix the detection
    if (btAvailable)
    {
        className = BluetoothPreferencePage.class.getName();
    }
    else
    {
        className = BluetoothDisabledPreferencePage.class.getName();
    }

    PreferenceNode bluetoothNode = new PreferenceNode("bluetooth", //$NON-NLS-1$
            Messages.getString("BluetoothPreferencePage.title"), null, //$NON-NLS-1$
            className);

    preferenceManager.addToRoot(bluetoothNode);
}
项目:JettyWTPPlugin    文件:JettyRuntimeComposite.java   
protected boolean showPreferencePage()
{
    Trace.trace(Trace.CONFIG, "JettyRuntimeComposite: showPreferencePage()");

    String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage";

    // should be using the following API, but it only allows a single
    // preference page instance.
    // see bug 168211 for details
    // PreferenceDialog dialog =
    // PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[]
    // { id }, null);
    // return (dialog.open() == Window.OK);

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage").findSubNode(id);
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(getShell(),manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}
项目:Mailster    文件:ConfigurationDialog.java   
/**
 * Creates and shows the configuration dialog.
 * 
 * @param shell the shell to attach to
 */
public static void run(Shell shell)
{
    /* Create the preference manager */
    PreferenceManager mgr = new PreferenceManager();
    createPreferenceTree(mgr);

    /* Create and open the ConfigurationDialog */
    ConfigurationDialog dlg = new ConfigurationDialog(shell, mgr);

    dlg.setPreferenceStore(ConfigurationManager.CONFIG_STORE);
    dlg.create();
    dlg.getShell().setText(Messages.getString("configurationDialogTitle"));
    dlg.getShell().setImage(SWTHelper.loadImage("config.gif"));
    Point minSize = new Point(690, 480);
    dlg.getShell().setSize(minSize);
    dlg.setMinimumPageSize(minSize);
    dlg.getShell().setMinimumSize(minSize);
    DialogUtils.centerShellOnParentShell(dlg.getShell());
    dlg.getTreeViewer().expandAll();
    dlg.open();
}
项目:vsDiaryWriter    文件:JournalApplication.java   
/**
 * load all providers.
 * 
 * This method loads all provider available.
 */
public static void initModules() {

    // prepare to load modules

    modules = new File("modules");
    CommonFunctions.initDir(modules);
    m = new PF4JModuleLoader();

    // put system configuration first

    ConfigurationGUISetup setup = new ConfigurationGUISetup() {

        @Override
        public void proccess(PreferenceManager mger) {
            PreferenceNode system = new PreferenceNode("system", "System", null,
                    SystemPreferencePage.class.getCanonicalName());
            mger.addToRoot(system);
        }
    };

    PreferenceGUIManager.add(setup);

    // register the providers
    AuthManagers.INSTANCE.registerAuthProvider(new ViperfishAuthProvider());
    EntryDatabases.INSTANCE.registerEntryDatabaseProvider(new ViperfishEntryDatabaseProvider());
    Indexers.INSTANCE.registerIndexerProvider(new ViperfishIndexerProvider());
    JournalTransformers.INSTANCE.registerTransformerProvider(new ViperfishEncryptionProvider());

    // load third party
    m.loadModules(modules);
}
项目:vsDiaryWriter    文件:PreferenceGUIManager.java   
public static PreferenceManager getMger() {
    PreferenceManager mger = new PreferenceManager();
    for (ConfigurationGUISetup i : runners) {
        i.proccess(mger);
    }
    return mger;
}
项目:yamcs-studio    文件:YamcsStudioWorkbenchAdvisor.java   
@Override
public void postStartup() {
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
    pm.remove("org.eclipse.help.ui.browsersPreferencePage");
    pm.remove("org.eclipse.team.ui.TeamPreferences");
    pm.remove("org.csstudio.platform.ui.css.applications");
    pm.remove("org.csstudio.platform.ui.css.platform");
}
项目:bts    文件:E4PreferenceRegistry.java   
private IPreferenceNode findNode(PreferenceManager pm, String categoryId)
{
    for (Object o : pm.getElements(PreferenceManager.POST_ORDER))
    {
        if (o instanceof IPreferenceNode && ((IPreferenceNode) o).getId().equals(categoryId))
        {
            return (IPreferenceNode) o;
        }
    }
    return null;
}
项目:bts    文件:ShowPreferenceDialogHandler.java   
@Execute
public void execute(MApplication app) {
    PreferenceManager pm = configurePreferences();
    PreferenceDialog dialog = new PreferenceDialog(shell, pm);
    dialog.setPreferenceStore(new ScopedPreferenceStore(
            InstanceScope.INSTANCE, "org.bbaw.bts.app"));
    dialog.create();
    dialog.getTreeViewer().setComparator(new ViewerComparator());
    dialog.getTreeViewer().expandAll();
    dialog.open();
}
项目:bts    文件:ShowPreferenceDialogHandler.java   
private IPreferenceNode findNode(PreferenceManager pm, String categoryId) {
    for (Object o : pm.getElements(PreferenceManager.POST_ORDER)) {
        if (o instanceof IPreferenceNode
                && ((IPreferenceNode) o).getId().equals(categoryId)) {
            return (IPreferenceNode) o;
        }
    }
    return null;
}
项目:cppcheclipse    文件:FieldEditorOverlayPage.java   
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl()
            .getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:e4-cookbook-migration-guide    文件:PreferencesHandler.java   
@Execute
public void execute(Shell shell, @PrefMgr PreferenceManager manager) {
    PreferenceDialog dialog = new PreferenceDialog(shell, manager) {
        @Override
        protected TreeViewer createTreeViewer(Composite parent) {
            TreeViewer viewer = super.createTreeViewer(parent);

            viewer.setComparator(new ViewerComparator() {

                @Override
                public int category(Object element) {
                    // this ensures that the General preferences page is always on top
                    // while the other pages are ordered alphabetical
                    if (element instanceof ContributedPreferenceNode
                            && ("general".equals(((ContributedPreferenceNode) element).getId()))) {
                        return -1;
                    }
                    return 0;
                }

            });

            return viewer;
        }
    };

    dialog.open();
}
项目:scouter    文件:RCPUtil.java   
public static void printPreferencePages(){
    System.out.println("=== PreferencePages ===");
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
    @SuppressWarnings("unchecked")
    List<IPreferenceNode> preferenceNodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER);
    for (Iterator<IPreferenceNode> it = preferenceNodes.iterator(); it.hasNext();) {
        IPreferenceNode preferenceNode = (IPreferenceNode)it.next();
        System.out.println(preferenceNode.getId());
    }
}
项目:e4-preferences    文件:PreferenceManagerSupplier.java   
/**
 * 
 * @return The {@link PreferenceManager} managed by this
 *         {@link PreferenceManagerSupplier}
 */
protected PreferenceManager getManager() {
    if (this.mgr == null) {
        this.mgr = new PreferenceManager();
    }
    return mgr;
}
项目:Swiper    文件:FieldEditorOverlayPage.java   
/**
 * Show a single preference pages
 * @param id - the preference page identification
 * @param page - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog =
        new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:Swiper    文件:OverlayPage.java   
/**
 * Show a single preference pages
 * @param id - the preference page identification
 * @param page - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog =
        new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:PDFReporter-Studio    文件:OverlayPage.java   
/**
 * Show a single preference pages
 * 
 * @param id
 *          - the preference page identification
 * @param page
 *          - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:APICloud-Studio    文件:PropToPrefLinkArea.java   
@SuppressWarnings("rawtypes")
private IPreferenceNode getPreferenceNode(String pageId)
{
    Iterator iterator = PlatformUI.getWorkbench().getPreferenceManager().getElements(PreferenceManager.PRE_ORDER)
            .iterator();
    while (iterator.hasNext())
    {
        IPreferenceNode next = (IPreferenceNode) iterator.next();
        if (next.getId().equals(pageId))
        {
            return next;
        }
    }
    return null;
}
项目:dazzl    文件:Main.java   
/**
 * Populate the preference manager with nodes from
 * the running plugins
 *
 * @param preferenceManager the preference manager
 */
public static void populatePreferenceManager(
        PreferenceManager preferenceManager) {
    synchronized (instance.plugins) {
        Iterator pluginIterator;

        pluginIterator = instance.plugins.values().iterator();
        while (pluginIterator.hasNext()) {
            DazzlPlugin plugin;

            plugin = (DazzlPlugin) pluginIterator.next();
            plugin.registerPreferenceNodes(preferenceManager);
        }
    }
}
项目:dazzl    文件:LwrfPlugin.java   
public void registerPreferenceNodes(PreferenceManager preferenceManager) {
    String className;
    className = LwrfPreferencePage.class.getName();
    PreferenceNode lwrfNode = new PreferenceNode("lwrf", //$NON-NLS-1$
            Messages.getString("LwrfPreferencePage.title"), null, //$NON-NLS-1$
            className);
    preferenceManager.addToRoot(lwrfNode);
}
项目:dazzl    文件:PreferencesAction.java   
public PreferenceManager createPreferenceManager()
{
    PreferenceManager preferenceManager = new PreferenceManager();

    Main.populatePreferenceManager(preferenceManager);

    return preferenceManager;
}
项目:osate2-agcl    文件:FieldEditorOverlayPage.java   
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = 
            new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:Rel    文件:Preferences.java   
public Preferences(Shell parent) {
PreferenceManager preferenceManager = new PreferenceManager();

PreferenceNode general = new PreferenceNode("General", new PreferencePageGeneral());
preferenceManager.addToRoot(general);

PreferenceNode cmd = new PreferenceNode("Command line", new PreferencePageCmd());
preferenceManager.addToRoot(cmd);

preferenceDialog = new PreferenceDialog(parent, preferenceManager);
preferenceDialog.setPreferenceStore(preferences);
}
项目:CppStyle    文件:CppStylePropertyPage.java   
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl()
            .getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}
项目:birt    文件:PreviewPreferencePage.java   
private IPreferenceNode getPreferenceNode( String pageId )
{
    Iterator iterator = PlatformUI.getWorkbench( )
            .getPreferenceManager( )
            .getElements( PreferenceManager.PRE_ORDER )
            .iterator( );
    while ( iterator.hasNext( ) )
    {
        IPreferenceNode next = (IPreferenceNode) iterator.next( );
        if ( next.getId( ).equals( pageId ) )
            return next;
    }
    return null;
}
项目:e4Preferences    文件:E4PreferenceRegistry.java   
private IPreferenceNode findNode(PreferenceManager pm, String categoryId)
{
    for (Object o : pm.getElements(PreferenceManager.POST_ORDER))
    {
        if (o instanceof IPreferenceNode && ((IPreferenceNode) o).getId().equals(categoryId))
        {
            return (IPreferenceNode) o;
        }
    }
    return null;
}
项目:e4Preferences    文件:E4PreferencesHandler.java   
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,  E4PreferenceRegistry prefReg)
{
    PreferenceManager pm = prefReg.getPreferenceManager();
    PreferenceDialog dialog = new PreferenceDialog(shell, pm);
    dialog.create();
    dialog.getTreeViewer().setComparator(new ViewerComparator());
    dialog.getTreeViewer().expandAll();
    dialog.open();
}
项目:external-filter    文件:EFToolsDynamicMenu.java   
static void showConfigDialog() {
    IWorkbenchWindow window = EFActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
    IPreferencePage page = new EFPreferencePage();
    PreferenceManager mgr = window.getWorkbench().getPreferenceManager();

    Shell shell = EFActivator.getDefault().getWorkbench().getDisplay().getActiveShell();
    PreferenceDialog dialog = new PreferenceDialog(shell, mgr);
    dialog.setSelectedNode("Externalfilter.preferences.ExternalFilterPreferencePage");
    dialog.create();
    dialog.setMessage(page.getTitle());
    dialog.open();
}
项目:javapasswordsafe    文件:OptionsAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();

    // Create the preference manager
    PreferenceManager mgr = new PreferenceManager();

    // Create the nodes
    PreferenceNode displayPrefs = new PreferenceNode(
            "display", Messages.getString("OptionsAction.DisplayNode"), null, DisplayPreferences.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    PreferenceNode securityPrefs = new PreferenceNode(
            "security", Messages.getString("OptionsAction.SecurityNode"), null, SecurityPreferences.class //$NON-NLS-1$ //$NON-NLS-2$
                    .getName());
    PreferenceNode passwordPolicyPrefs = new PreferenceNode(
            "policy", Messages.getString("OptionsAction.PolicyNode"), null, //$NON-NLS-1$ //$NON-NLS-2$
            PasswordPolicyPreferences.class.getName());
    PreferenceNode usernamePrefs = new PreferenceNode(
            "username", Messages.getString("OptionsAction.UserNameNode"), null, UsernamePreferences.class //$NON-NLS-1$ //$NON-NLS-2$
                    .getName());
    PreferenceNode miscPrefs = new PreferenceNode(
            "misc", Messages.getString("OptionsAction.MiscNode"), null, MiscPreferences.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$

    // Add the nodes
    mgr.addToRoot(displayPrefs);
    mgr.addToRoot(securityPrefs);
    mgr.addToRoot(passwordPolicyPrefs);
    mgr.addToRoot(usernamePrefs);
    mgr.addToRoot(miscPrefs);

    // Create the preferences dialog
    PreferenceDialog dlg = new PreferenceDialog(app.getShell(), mgr);
    Window.setDefaultImage(IOUtils.getImage(PasswordSafeJFace.class,
            "/org/pwsafe/passwordsafeswt/images/clogo.gif")); //$NON-NLS-1$

    // Set the preference store
    dlg.setPreferenceStore(JFacePreferences.getPreferenceStore());

    // Open the dialog
    dlg.open();

    try {
        if (JFacePreferences.getPreferenceStore().needsSaving()) {
            // Be Paranoid - Save the preferences now
            UserPreferences.getInstance().savePreferences();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:tlaplus    文件:UnwantedPreferenceManager.java   
public void initialize()
{
    if (Activator.getDefault().getWorkbench() == null)
    {
        return;
    }
    PreferenceManager pm = Activator.getDefault().getWorkbench().getPreferenceManager();

    if (pm != null)
    {
        /*
         * Subpages need to be removed by calling the remove method
         * on their parent. Pages with no parent can be removed
         * by calling the remove method on the preference manager.
         * 
         * Getting the appropriate id of the page to remove can be done
         * using the code that is commented at the end of this method.
         * It will print out the name followed by the id of every preference page.
         */
        IPreferenceNode generalNode = pm.find("org.eclipse.ui.preferencePages.Workbench");
        if (generalNode != null)
        {
            // these are sub pages of general that we want removed
            generalNode.remove("org.eclipse.ui.preferencePages.Workspace");
            generalNode.remove("org.eclipse.ui.preferencePages.ContentTypes");
            // We no longer want to remove this node.
            // We only want to remove one of its sub nodes.
            // generalNode.remove("org.eclipse.ui.preferencePages.Views");
            // we only want to remove some subnodes of the Editors page
            IPreferenceNode editorsNode = generalNode.findSubNode("org.eclipse.ui.preferencePages.Editors");
            if (editorsNode != null)
            {
                // remove File Associations page
                editorsNode.remove("org.eclipse.ui.preferencePages.FileEditors");
                // want to remove only some subnodes of the Text Editors page
                IPreferenceNode textEditorsNode = editorsNode
                        .findSubNode("org.eclipse.ui.preferencePages.GeneralTextEditor");
                if (textEditorsNode != null)
                {
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.Spelling");
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.QuickDiff");
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage");
                }
            }
            generalNode.remove("org.eclipse.ui.preferencePages.Perspectives");
            generalNode.remove("org.eclipse.equinox.security.ui.category");
            IPreferenceNode appearanceNode = generalNode.findSubNode("org.eclipse.ui.preferencePages.Views");
            if (appearanceNode != null)
            {
                // Removes the label decorators node that is a sub node of
                // the appearance node.
                // We want to keep the other sub node, colors and fonts
                // because it allows for setting the font for
                // the module editor.
                appearanceNode.remove("org.eclipse.ui.preferencePages.Decorators");
            }
        }

        // remove Install/Update
        pm.remove("org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage");

        // remove the sub node of help
        IPreferenceNode helpNode = pm.find("org.eclipse.help.ui.browsersPreferencePage");
        if (helpNode != null)
        {
            helpNode.remove("org.eclipse.help.ui.contentPreferencePage");
        }
    }
}
项目:tlaplus    文件:ApplicationWorkbenchWindowAdvisor.java   
public void postWindowOpen() {
    final PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
    final IPreferenceNode[] rootSubNodes = preferenceManager.getRootSubNodes();

    // @see Bug #191 in general/bugzilla/index.html
    final List<String> filters = new ArrayList<String>();
    filters.add("org.eclipse.compare");
    // The following three preferences are shown because the Toolbox uses
    // the local history feature provided by o.e.team.ui
    filters.add("org.eclipse.team.ui");
    filters.add("org.eclipse.ui.trace");
    filters.add("org.eclipse.jsch.ui");

    // Filter out Pdf4Eclipse preference page.
    filters.add("de.vonloesch.pdf4Eclipse");

    // Filter out GraphViz
    filters.add("com.abstratt.graphviz.ui");

    // Clean the preferences
    final List<IPreferenceNode> elements = preferenceManager.getElements(PreferenceManager.POST_ORDER);
    for (Iterator<IPreferenceNode> iterator = elements.iterator(); iterator.hasNext();) {
        final IPreferenceNode elem = iterator.next();
        if (elem instanceof IPluginContribution) {
            final IPluginContribution aPluginContribution = (IPluginContribution) elem;
            if (filters.contains(aPluginContribution.getPluginId())) {
                final IPreferenceNode node = (IPreferenceNode) elem;

                // remove from root node
                preferenceManager.remove(node);

                // remove from all subnodes
                for (int i = 0; i < rootSubNodes.length; i++) {
                    final IPreferenceNode subNode = rootSubNodes[i];
                    subNode.remove(node);
                }
            }
        }
    }
    super.postWindowOpen();

    // At this point in time we can be certain that the UI is fully
    // instantiated (views, editors, menus...). Thus, register
    // listeners that connect the UI to the workspace resources.
    ToolboxLifecycleParticipantManger.postWorkbenchWindowOpen();
}