/** * Handles the button pressed event on the filter criteria. Move the items between the lists based * on the selection and but button pressed. */ private void buttonPressed(int buttonId) { String[] items = {}; switch (buttonId) { case ADD_TO_ID: items = filterList.getSelection(); for (int i = 0; i < items.length; i++) { filters.add(items[i]); filterList.remove(items[i]); } addTo.setEnabled(false); break; case REMOVE_FROM_ID: items = filters.getSelection(); for (int i = 0; i < items.length; i++) { filterList.add(items[i]); filters.remove(items[i]); } removeFrom.setEnabled(false); break; case ADD_ALL_TO_ID: items = filterList.getItems(); for (int i = 0; i < items.length; i++) { filters.add(items[i]); filterList.remove(items[i]); } break; case REMOVE_ALL_FROM_ID: items = filters.getItems(); for (int i = 0; i < items.length; i++) { filters.remove(items[i]); filterList.add(items[i]); } break; } updateFilteringKeysFromControls(); if (pageType == CHILD_PAGE) { refreshList(); } else if (pageType == ROOT_PAGE) { PreferenceManager preferenceManager = ((SortFilterDialog) getContainer()).getPreferenceManager(); Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { PreferenceNode node = (PreferenceNode) nodes.next(); SortFilterPage page = (SortFilterPage) node.getPage(); if (page == this) { continue; } if (Arrays.equals(filterStrings, page.getFilterList())) { page._filteringKeys = new ArrayList(_filteringKeys.size()); page._filteringKeys.addAll(_filteringKeys); page._filtering = _filtering; page.populateFilterLists(); page.refreshList(); page.updateApplyButton(); } } } updateApplyButton(); }
public boolean openConfigDialog(Shell parentShell, String pageId) { PreferenceManager manager = new PreferenceManager(); PreferenceNode profile = new PreferenceNode(UserProfilePage.PAGE_ID, new UserProfilePage(iniUserProfile)); manager.addToRoot(profile); PreferenceNode setting = new PreferenceNode(MiscSettingPage.PAGE_ID, new MiscSettingPage(iniSettings)); manager.addToRoot(setting); PreferenceNode appearance = new PreferenceNode(AppearancePage.PAGE_ID, new AppearancePage(this)); manager.addToRoot(appearance); for (IPreferenceNodeProvider p : preferenceNodeProviders) manager.addToRoot(p.createPreferenceNode()); PreferenceDialog dialog = new PreferenceDialog(parentShell, manager) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("設定"); newShell.setImage(imageRegistry.get(ICON_TOOLBAR_CONFIG)); } @Override protected Composite createTitleArea(Composite parent) { Composite composite = super.createTitleArea(parent); FormLayout layout = (FormLayout) composite.getLayout(); layout.marginTop = 4; return composite; } }; if (pageId != null) dialog.setSelectedNode(pageId); switch (dialog.open()) { case IDialogConstants.OK_ID: try { iniSettingFile.saveToIni(); wlanLibrary = iniSettings.getWlanLibrary(); updateWlanLibraryStatus(); return true; } catch (IOException e) { arenaWindow.appendToSystemLog(Utility.stackTraceToString(e), true); e.printStackTrace(); } } return false; }
private void addPreferencePages(PreferenceManager manager) { for (Iterator i = preferencePages.iterator(); i.hasNext(); ) { PreferencePageNode node = (PreferencePageNode) i.next(); manager.addToRoot( new PreferenceNode(node.id, node.name, node.image, node.preferencePageClassName)); } }
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); }
/** * Create Network group * * @param parent parent composite */ @SuppressWarnings("unchecked") private void createNetworkGroup(Composite parent) { // Makes the network preferences dialog manager PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode networkNode = null; for (IPreferenceNode node : (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) { if (node.getId().equals(PROXY_PREFERENCE_PAGE_ID)) { networkNode = node; break; } } prefMan = new PreferenceManager(); if (networkNode != null) { prefMan.addToRoot(networkNode); } Link downloadText = new Link(parent, SWT.WRAP); downloadText.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // Do nothing } public void widgetSelected(SelectionEvent e) { openNetworkPreferencesPage(); } }); String linkText = Messages.bind(Messages.NetworkLinkText, Messages.NetworkLinkText, Messages.NetworkLinkLink); downloadText.setText(linkText); downloadText.update(); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); downloadText.setLayoutData(gridData); }
private PreferenceManager createPreferenceManager() { final PreferenceManager pm = new PreferenceManager(PM_SEPARATOR); final PreferenceNodeElement[] elements = getElements(); for (PreferenceNodeElement element : elements) { PreferenceNode node = new WorkbenchPreferenceNode( element.id, element.name, null, element.bundleID, element.className); final String category = element.category; if (category == null || category.length() == 0) { pm.addToRoot(node); } else { final IPreferenceNode categoryNode = pm.find(category); if (categoryNode == null) { pm.addToRoot(node); } else { categoryNode.add(node); } } } return pm; }
/** * Selects the saved item in the tree of preference pages. If it cannot do this it saves the first * one. */ protected void selectSavedItem() { IPreferenceNode node = findNodeMatching(getSelectedNodePreference()); if (node == null) { IPreferenceNode[] nodes = preferenceManager.getRootSubNodes(); ViewerComparator comparator = getTreeViewer().getComparator(); if (comparator != null) { comparator.sort(null, nodes); } for (int i = 0; i < nodes.length; i++) { IPreferenceNode selectedNode = nodes[i]; if (selectedNode != null) { node = selectedNode; break; } } } if (node != null) { getTreeViewer().setSelection(new StructuredSelection(node), true); // Keep focus in tree. See bugs 2692, 2621, and 6775. getTreeViewer().getControl().setFocus(); boolean expanded = getTreeViewer().getExpandedState(node); getTreeViewer().setExpandedState(node, !expanded); } }
/** * Method creates tree structure of windows azure property pages. and opens property dialog with * desired property page selected & active. * * @param windowsAzureRole : worker role * @param pageToDisplay : property page Id which should be active after opening dialog * @return integer */ public static int openRolePropertyDialog( WindowsAzureRole windowsAzureRole, String pageToDisplay) { int retVal = Window.CANCEL; // value corresponding to cancel try { // Node creation PreferenceNode nodeGeneral = new PreferenceNode( Messages.cmhIdGeneral, Messages.cmhLblGeneral, null, WARGeneral.class.toString()); nodeGeneral.setPage(new WARGeneral()); nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral); PreferenceNode nodeCache = new PreferenceNode( Messages.cmhIdCach, Messages.cmhLblCach, null, WARCaching.class.toString()); nodeCache.setPage(new WARCaching()); nodeCache.getPage().setTitle(Messages.cmhLblCach); PreferenceNode nodeCmpnts = new PreferenceNode( Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null, WARComponents.class.toString()); nodeCmpnts.setPage(new WARComponents()); nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts); PreferenceNode nodeDebugging = new PreferenceNode( Messages.cmhIdDbg, Messages.cmhLblDbg, null, WARDebugging.class.toString()); nodeDebugging.setPage(new WARDebugging()); nodeDebugging.getPage().setTitle(Messages.cmhLblDbg); PreferenceNode nodeEndPts = new PreferenceNode( Messages.cmhIdEndPts, Messages.cmhLblEndPts, null, WAREndpoints.class.toString()); nodeEndPts.setPage(new WAREndpoints()); nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts); PreferenceNode nodeEnvVars = new PreferenceNode( Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null, WAREnvVars.class.toString()); nodeEnvVars.setPage(new WAREnvVars()); nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars); PreferenceNode nodeLdBlnc = new PreferenceNode( Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null, WARLoadBalance.class.toString()); nodeLdBlnc.setPage(new WARLoadBalance()); nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc); PreferenceNode nodeLclStg = new PreferenceNode( Messages.cmhIdLclStg, Messages.cmhLblLclStg, null, WARLocalStorage.class.toString()); nodeLclStg.setPage(new WARLocalStorage()); nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg); PreferenceNode nodeSrvCnfg = new PreferenceNode( Messages.cmhIdSrvCnfg, Messages.cmhLblSrvCnfg, null, WAServerConfiguration.class.toString()); nodeSrvCnfg.setPage(new WAServerConfiguration()); nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg); /* * Tree structure creation. * Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeGeneral.add(nodeCache); nodeGeneral.add(nodeCmpnts); nodeGeneral.add(nodeDebugging); nodeGeneral.add(nodeEndPts); nodeGeneral.add(nodeEnvVars); nodeGeneral.add(nodeLdBlnc); nodeGeneral.add(nodeLclStg); nodeGeneral.add(nodeSrvCnfg); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeGeneral); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, windowsAzureRole.getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception ex) { PluginUtil.displayErrorDialogAndLog( new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex); } return retVal; }