Search in sources :

Example 1 with PreferenceNode

use of org.eclipse.jface.preference.PreferenceNode in project cubrid-manager by CUBRID.

the class PreferenceNodeComparator method compare.

/**
	 * Compare object
	 * 
	 * @param o1 Object
	 * @param o2 Object
	 * 
	 * @return int
	 */
public int compare(Object o1, Object o2) {
    PreferenceNode node1 = null;
    PreferenceNode node2 = null;
    if (o1 instanceof PreferenceNode) {
        node1 = (PreferenceNode) o1;
    }
    if (o2 instanceof PreferenceNode) {
        node2 = (PreferenceNode) o2;
    }
    int retValue = compareNullObj(node1, node2);
    if (retValue != 2) {
        return retValue;
    }
    String id1 = node1.getId();
    String id2 = node2.getId();
    retValue = compareNullObj(id1, id2);
    if (retValue != 2) {
        return retValue;
    }
    return compareId(id1, id2);
}
Also used : PreferenceNode(org.eclipse.jface.preference.PreferenceNode)

Example 2 with PreferenceNode

use of org.eclipse.jface.preference.PreferenceNode in project translationstudio8 by heartsome.

the class ProjectSettingHandler method execute.

/**
	 * (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    runWizardPageExtension();
    ISelection curSelection = HandlerUtil.getCurrentSelection(event);
    if (curSelection != null && !curSelection.isEmpty() && curSelection instanceof IStructuredSelection) {
        IStructuredSelection selection = (IStructuredSelection) curSelection;
        Object obj = selection.getFirstElement();
        if (obj instanceof IProject) {
            IProject project = (IProject) obj;
            ProjectConfiger cfg = ProjectConfigerFactory.getProjectConfiger(project);
            final ProjectInfoBean cfgBean = cfg.getCurrentProjectConfig();
            cfgBean.setProjectName(project.getName());
            ProjectSettingBaseInfoPage infoPage = new ProjectSettingBaseInfoPage(cfgBean);
            ProjectSettingLanguagePage langPag = new ProjectSettingLanguagePage(cfgBean);
            final PreferenceManager mgr = new PreferenceManager();
            IPreferenceNode infoNode = new PreferenceNode("infoPage", infoPage);
            IPreferenceNode langNode = new PreferenceNode("langPag", langPag);
            mgr.addToRoot(infoNode);
            mgr.addTo("infoPage", langNode);
            AbstractProjectSettingPage pageTm = getPageByType("TM");
            if (pageTm != null) {
                pageTm.setProjectInfoBean(cfgBean);
                IPreferenceNode extensionNode = new PreferenceNode("tmInfo", pageTm);
                mgr.addTo("infoPage", extensionNode);
            }
            AbstractProjectSettingPage pageTb = getPageByType("TB");
            if (pageTb != null) {
                pageTb.setProjectInfoBean(cfgBean);
                IPreferenceNode extensionNode = new PreferenceNode("tbInfo", pageTb);
                mgr.addTo("infoPage", extensionNode);
            }
            for (AbstractProjectSettingPage page : extensionPages) {
                page.setProjectInfoBean(cfgBean);
                IPreferenceNode extensionNode = new PreferenceNode("tbInfo", page);
                mgr.addTo("infoPage", extensionNode);
            }
            ProjectSettingDialog dialog = new ProjectSettingDialog(window.getShell(), mgr);
            dialog.create();
            dialog.setMessage(infoPage.getTitle());
            if (dialog.open() == 0) {
                cfg.updateProjectConfig(cfgBean);
                try {
                    project.refreshLocal(IResource.DEPTH_INFINITE, null);
                } catch (CoreException e) {
                    logger.error("", e);
                }
            }
        } else {
            MessageDialog.openError(window.getShell(), Messages.getString("handlers.ProjectSettingHandler.msgTitle"), Messages.getString("handlers.ProjectSettingHandler.msg1"));
            return null;
        }
    } else {
        MessageDialog.openError(window.getShell(), Messages.getString("handlers.ProjectSettingHandler.msgTitle"), Messages.getString("handlers.ProjectSettingHandler.msg1"));
        return null;
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ProjectSettingBaseInfoPage(net.heartsome.cat.ts.ui.projectsetting.ProjectSettingBaseInfoPage) ProjectSettingDialog(net.heartsome.cat.ts.ui.projectsetting.ProjectSettingDialog) ProjectSettingLanguagePage(net.heartsome.cat.ts.ui.projectsetting.ProjectSettingLanguagePage) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AbstractProjectSettingPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractProjectSettingPage) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) IProject(org.eclipse.core.resources.IProject) ProjectInfoBean(net.heartsome.cat.common.bean.ProjectInfoBean) CoreException(org.eclipse.core.runtime.CoreException) ProjectConfiger(net.heartsome.cat.ts.core.file.ProjectConfiger) ISelection(org.eclipse.jface.viewers.ISelection)

Example 3 with PreferenceNode

use of org.eclipse.jface.preference.PreferenceNode in project cubrid-manager by CUBRID.

the class PreferenceUtil method createPropertyDialog.

/**
	 * Create property dialog related with CUBRID node
	 *
	 * @param parentShell the parent shell
	 * @param node the ICubridNode object
	 * @return the Dialog object
	 */
public static Dialog createPropertyDialog(Shell parentShell, ICubridNode node) {
    PreferenceManager mgr = new PreferenceManager();
    String type = node.getType();
    ServerType serverType = node.getServer().getServerInfo().getServerType();
    if (CubridNodeType.SERVER.equals(type)) {
        // cubrid manager server property
        ServerConfigPropertyPage cmServerPropertyPage = new ServerConfigPropertyPage(node, Messages.msgCmServerPropertyPageName);
        PreferenceNode cmServerNode = new PreferenceNode(Messages.msgCmServerPropertyPageName);
        cmServerNode.setPage(cmServerPropertyPage);
        mgr.addToRoot(cmServerNode);
        PreferenceNode categoryNode = createCategoryNode(Messages.msgConfigureParameterPageName, Messages.msgConfigureParameterPageName, Messages.msgDetailConfigureParameter);
        mgr.addToRoot(categoryNode);
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            // service node
            ServicePropertyPage servicePorpertyPage = new ServicePropertyPage(node, Messages.msgServicePropertyPageName);
            PreferenceNode serviceNode = new PreferenceNode(Messages.msgServicePropertyPageName);
            serviceNode.setPage(servicePorpertyPage);
            categoryNode.add(serviceNode);
            // database server node
            DatabaseConfigPropertyPage databaseServerPorpertyPage = new DatabaseConfigPropertyPage(node, Messages.msgDatabaseServerCommonPropertyPageName, true);
            PreferenceNode databaseServerNode = new PreferenceNode(Messages.msgDatabaseServerCommonPropertyPageName);
            databaseServerNode.setPage(databaseServerPorpertyPage);
            categoryNode.add(databaseServerNode);
            // HA configuraiton
            if (CompatibleUtil.isSupportNewHAConfFile(node.getServer().getServerInfo())) {
                HAPropertyPage haPropertyPage = new HAPropertyPage(node, Messages.msgHAPropertyPageName);
                PreferenceNode haNode = new PreferenceNode(Messages.msgHAPropertyPageName);
                haNode.setPage(haPropertyPage);
                categoryNode.add(haNode);
            }
        }
        if (serverType == ServerType.BOTH || serverType == ServerType.BROKER) {
            // brokers node
            BrokersParameterPropertyPage brokersParameterPorpertyPage = new BrokersParameterPropertyPage(node, Messages.msgBrokerPropertyPageName);
            PreferenceNode brokersParameterNode = new PreferenceNode(Messages.msgBrokerPropertyPageName);
            brokersParameterNode.setPage(brokersParameterPorpertyPage);
            categoryNode.add(brokersParameterNode);
        }
        // mananger node
        ManagerServerPropertyPage managerPorpertyPage = new ManagerServerPropertyPage(node, Messages.msgManagerPropertyPageName);
        PreferenceNode managerNode = new PreferenceNode(Messages.msgManagerPropertyPageName);
        managerNode.setPage(managerPorpertyPage);
        categoryNode.add(managerNode);
        // query editor node
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            CubridServer server = node.getServer();
            QueryOptionPreferencePage queryEditorPage = new QueryOptionPreferencePage(server);
            PreferenceNode queryEditorNode = new PreferenceNode(Messages.msgQueryPropertyPageName);
            queryEditorNode.setPage(queryEditorPage);
            mgr.addToRoot(queryEditorNode);
        }
    } else if (CubridNodeType.DATABASE_FOLDER.equals(type)) {
        // database server node
        DatabaseConfigPropertyPage databaseServerPorpertyPage = new DatabaseConfigPropertyPage(node, Messages.msgDatabaseServerCommonPropertyPageName, true);
        PreferenceNode databaseServerNode = new PreferenceNode(Messages.msgDatabaseServerCommonPropertyPageName);
        databaseServerNode.setPage(databaseServerPorpertyPage);
        mgr.addToRoot(databaseServerNode);
    } else if (CubridNodeType.DATABASE.equals(type)) {
        // database parameter
        DatabaseConfigPropertyPage databaseParameterPorpertyPage = new DatabaseConfigPropertyPage(node, Messages.msgDatabaseServerPropertyPageName, false);
        PreferenceNode databaseParameterNode = new PreferenceNode(Messages.msgDatabaseServerPropertyPageName);
        databaseParameterNode.setPage(databaseParameterPorpertyPage);
        // database query
        CubridDatabase database = (CubridDatabase) node;
        DatabaseConnectionPropertyPage page = new DatabaseConnectionPropertyPage(database, Messages.msgQueryPropertyPageName);
        PreferenceNode queryNode = new PreferenceNode(Messages.msgQueryPropertyPageName);
        queryNode.setPage(page);
        mgr.addToRoot(queryNode);
        mgr.addToRoot(databaseParameterNode);
    } else if (CubridNodeType.BROKER_FOLDER.equals(type)) {
        // brokers node
        BrokersParameterPropertyPage brokersParameterPorpertyPage = new BrokersParameterPropertyPage(node, Messages.msgBrokerPropertyPageName);
        PreferenceNode brokersParameterNode = new PreferenceNode(Messages.msgBrokerPropertyPageName);
        brokersParameterNode.setPage(brokersParameterPorpertyPage);
        mgr.addToRoot(brokersParameterNode);
    }
    if (CubridNodeType.BROKER.equals(type)) {
        BrokerParameterPropertyPage brokerParameterPorpertyPage = new BrokerParameterPropertyPage(node, node.getLabel());
        PreferenceNode brokerParameterNode = new PreferenceNode(node.getLabel());
        brokerParameterNode.setPage(brokerParameterPorpertyPage);
        mgr.addToRoot(brokerParameterNode);
    } else if (CubridNodeType.SHARD_FOLDER.equals(type)) {
        ShardsParameterPropertyPage shardsParameterPorpertyPage = new ShardsParameterPropertyPage(node, node.getName());
        PreferenceNode shardsParameterNode = new PreferenceNode(Messages.msgShardsFolderName);
        shardsParameterNode.setPage(shardsParameterPorpertyPage);
        mgr.addToRoot(shardsParameterNode);
    } else if (CubridNodeType.SHARD.equals(type)) {
        ShardParameterPropertyPage shardParameterPorpertyPage = new ShardParameterPropertyPage(node, node.getName());
        PreferenceNode shardParameterNode = new PreferenceNode(node.getName());
        shardParameterNode.setPage(shardParameterPorpertyPage);
        mgr.addToRoot(shardParameterNode);
    }
    CMPreferenceDialog dlg = new CMPreferenceDialog(parentShell, mgr, Messages.titlePropertiesDialog);
    dlg.setPreferenceStore(CubridManagerUIPlugin.getDefault().getPreferenceStore());
    return dlg;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ShardParameterPropertyPage(com.cubrid.cubridmanager.ui.shard.control.ShardParameterPropertyPage) BrokerParameterPropertyPage(com.cubrid.cubridmanager.ui.broker.control.BrokerParameterPropertyPage) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) BrokersParameterPropertyPage(com.cubrid.cubridmanager.ui.broker.control.BrokersParameterPropertyPage) ShardsParameterPropertyPage(com.cubrid.cubridmanager.ui.shard.control.ShardsParameterPropertyPage) DatabaseConnectionPropertyPage(com.cubrid.cubridmanager.ui.cubrid.database.control.DatabaseConnectionPropertyPage) QueryOptionPreferencePage(com.cubrid.common.ui.query.preference.QueryOptionPreferencePage) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) CMPreferenceDialog(com.cubrid.common.ui.spi.dialog.CMPreferenceDialog) ServerConfigPropertyPage(com.cubrid.cubridmanager.ui.common.control.ServerConfigPropertyPage) ManagerServerPropertyPage(com.cubrid.cubridmanager.ui.common.control.ManagerServerPropertyPage) DatabaseConfigPropertyPage(com.cubrid.cubridmanager.ui.common.control.DatabaseConfigPropertyPage) HAPropertyPage(com.cubrid.cubridmanager.ui.common.control.HAPropertyPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) ServicePropertyPage(com.cubrid.cubridmanager.ui.common.control.ServicePropertyPage)

Example 4 with PreferenceNode

use of org.eclipse.jface.preference.PreferenceNode in project whole by wholeplatform.

the class PreferencesHandler method execute.

@Execute
public void execute(Shell shell) {
    PreferenceManager manager = new PreferenceManager();
    PreferenceNode wholeNode = new PreferenceNode(IE4UIConstants.WHOLE_PREFERENCE_PAGE_ID, new WholePreferencePage());
    PreferenceNode editorNode = new PreferenceNode(IE4UIConstants.EDITOR_PREFERENCE_PAGE_ID, new EditorPreferencePage());
    manager.addToRoot(wholeNode);
    wholeNode.add(editorNode);
    PreferenceDialog dialog = new PreferenceDialog(null, manager);
    dialog.setSelectedNode(IE4UIConstants.EDITOR_PREFERENCE_PAGE_ID);
    dialog.open();
}
Also used : PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) WholePreferencePage(org.whole.lang.e4.ui.preferences.WholePreferencePage) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) EditorPreferencePage(org.whole.lang.e4.ui.preferences.EditorPreferencePage) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 5 with PreferenceNode

use of org.eclipse.jface.preference.PreferenceNode in project portfolio by buchen.

the class OpenPreferenceDialogHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
    PreferenceManager pm = new PreferenceManager();
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".updates", new UpdatePreferencePage()));
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".language", new LanguagePreferencePage()));
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".proxy", new ProxyPreferencePage()));
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".presentation", new PresentationPreferencePage()));
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".general", new GeneralPreferencePage()));
    // $NON-NLS-1$
    pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".apikeys", new APIKeysPreferencePage()));
    PreferenceDialog dialog = new PreferenceDialog(shell, pm);
    dialog.setPreferenceStore(PortfolioPlugin.getDefault().getPreferenceStore());
    dialog.create();
    dialog.getTreeViewer().setComparator(new ViewerComparator());
    dialog.getTreeViewer().expandAll();
    dialog.open();
}
Also used : UpdatePreferencePage(name.abuchen.portfolio.ui.preferences.UpdatePreferencePage) LanguagePreferencePage(name.abuchen.portfolio.ui.preferences.LanguagePreferencePage) ProxyPreferencePage(name.abuchen.portfolio.ui.preferences.ProxyPreferencePage) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) APIKeysPreferencePage(name.abuchen.portfolio.ui.preferences.APIKeysPreferencePage) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) PresentationPreferencePage(name.abuchen.portfolio.ui.preferences.PresentationPreferencePage) GeneralPreferencePage(name.abuchen.portfolio.ui.preferences.GeneralPreferencePage) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

PreferenceNode (org.eclipse.jface.preference.PreferenceNode)14 PreferenceManager (org.eclipse.jface.preference.PreferenceManager)11 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)6 IPreferenceNode (org.eclipse.jface.preference.IPreferenceNode)5 QueryOptionPreferencePage (com.cubrid.common.ui.query.preference.QueryOptionPreferencePage)2 CMPreferenceDialog (com.cubrid.common.ui.spi.dialog.CMPreferenceDialog)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 File (java.io.File)2 IOException (java.io.IOException)2 ConfigurationGUISetup (net.viperfish.journal.framework.provider.ConfigurationGUISetup)2 CoreException (org.eclipse.core.runtime.CoreException)2 Execute (org.eclipse.e4.core.di.annotations.Execute)2 IPreferencePage (org.eclipse.jface.preference.IPreferencePage)2 Model (abs.frontend.ast.Model)1 ApetShellCommand (apet.console.ApetShellCommand)1 ApetPreferences (apet.preferences.ApetPreferences)1 ApetTestSuite (apet.testCases.ApetTestSuite)1 NullCategoryPreferencePage (com.cubrid.common.ui.common.preference.NullCategoryPreferencePage)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)1