Search in sources :

Example 6 with PreferenceManager

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

the class ApplicationWorkbenchAdvisor method postStartup.

@Override
public void postStartup() {
    super.postStartup();
    /*Remove the help content in preference*/
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
    pm.remove("org.eclipse.help.ui.browsersPreferencePage");
}
Also used : PreferenceManager(org.eclipse.jface.preference.PreferenceManager)

Example 7 with PreferenceManager

use of org.eclipse.jface.preference.PreferenceManager 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 8 with PreferenceManager

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

the class ApplicationWorkbenchWindowAdvisor method removePlatformDependencyActions.

private void removePlatformDependencyActions() {
    // remove some menu items
    IMenuManager mm = getWindowConfigurer().getActionBarConfigurer().getMenuManager();
    for (IContributionItem item : mm.getItems()) {
        if (item == null) {
            continue;
        }
        if (item instanceof MenuManager) {
            MenuManager sm = (MenuManager) item;
            for (IContributionItem sitem : sm.getItems()) {
                if (sitem == null || sitem.getId() == null) {
                    continue;
                }
                if (sitem.getId().equals("org.eclipse.ui.actions.showKeyAssistHandler") || sitem.getId().equals("com.cubrid.common.update.p2.menu.install") || sitem.getId().equals("converstLineDelimitersTo") || sitem.getId().equals("save.ext") || sitem.getId().equals("org.eclipse.ui.openLocalFile") || sitem.getId().equals("new.ext")) {
                    sm.remove(sitem.getId());
                    sm.update(true);
                    mm.update(true);
                }
            }
        }
    }
    // remove some tool bar items
    ICoolBarManager cm = getWindowConfigurer().getActionBarConfigurer().getCoolBarManager();
    for (IContributionItem item : cm.getItems()) {
        if (item == null || item.getId() == null) {
            continue;
        }
        if (item.getId().equals("org.eclipse.ui.edit.text.actionSet.annotationNavigation") || item.getId().equals("org.eclipse.ui.edit.text.actionSet.navigation")) {
            cm.remove(item.getId());
            cm.update(true);
        }
    }
    // remove some preference items
    PreferenceManager pm = getWindowConfigurer().getWindow().getWorkbench().getPreferenceManager();
    for (IPreferenceNode item : pm.getRootSubNodes()) {
        if (item.getId().equals("org.eclipse.help.ui.browsersPreferencePage") || item.getId().equals("org.eclipse.ui.preferencePages.Workbench")) {
            pm.remove(item.getId());
        }
    }
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager)

Example 9 with PreferenceManager

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

the class OpenPreferenceAction method run.

/**
	 * Open preference dialog
	 */
@SuppressWarnings("restriction")
public void run() {
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
    //Delete the security storage category
    preferenceManager.remove("org.eclipse.equinox.security.ui.category");
    String title = this.getText().replaceAll("&", "").replaceAll("\\.", "");
    CMPreferenceDialog dialog = new CMPreferenceDialog(shell, preferenceManager, title);
    dialog.create();
    dialog.open();
}
Also used : CMPreferenceDialog(com.cubrid.common.ui.spi.dialog.CMPreferenceDialog) PreferenceManager(org.eclipse.jface.preference.PreferenceManager)

Example 10 with PreferenceManager

use of org.eclipse.jface.preference.PreferenceManager in project azure-tools-for-java by Microsoft.

the class PluginUtil method openPropertyPageDialog.

/**
	 * Method opens property dialog with only desired property page.
	 *
	 * @param nodeId
	 *            : Node ID of property page
	 * @param nodeLbl
	 *            : Property page name
	 * @param classObj
	 *            : Class object of property page
	 * @return
	 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    // value corresponding to cancel
    int retVal = Window.CANCEL;
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);
        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
			 * If showing storage accounts preference page, don't show
			 * properties for title as its common repository.
			 */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName());
        }
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(PluginUtil.getParentShell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e);
    }
    return retVal;
}
Also used : PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

PreferenceManager (org.eclipse.jface.preference.PreferenceManager)13 IPreferenceNode (org.eclipse.jface.preference.IPreferenceNode)6 PreferenceNode (org.eclipse.jface.preference.PreferenceNode)4 CMPreferenceDialog (com.cubrid.common.ui.spi.dialog.CMPreferenceDialog)3 ArrayList (java.util.ArrayList)3 CoreException (org.eclipse.core.runtime.CoreException)3 QueryOptionPreferencePage (com.cubrid.common.ui.query.preference.QueryOptionPreferencePage)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 List (java.util.List)2 HsPreferenceDialog (net.heartsome.cat.common.ui.dialog.HsPreferenceDialog)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 MenuManager (org.eclipse.jface.action.MenuManager)2 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2 PreferenceLabelProvider (org.eclipse.jface.preference.PreferenceLabelProvider)2 Image (org.eclipse.swt.graphics.Image)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)1