List of usage examples for org.eclipse.jface.dialogs IDialogSettings getInt
int getInt(String key) throws NumberFormatException;
From source file:at.kolli.automation.client.LayoutLoader.java
License:Open Source License
protected void execInitialize() { String check;//from w w w .j av a2 s .c om Menu menuBar; MsgTranslator trans = MsgTranslator.instance(); FillLayout mainLayout = new FillLayout(); FillLayout treeLayout = new FillLayout(); IDialogSettings login; //final Composite mainComposite; final Group treeComposite; int sashWeight[] = { 200, 800 }; Rectangle monitor; int xLocation; int yLocation; // create menu if (HtmTags.nomenu) //&& //!HtmTags.notree ) { menuBar = null; } else { menuBar = new Menu(m_oTopLevelShell, SWT.BAR); m_oTopLevelShell.setMenuBar(menuBar); } if (!HtmTags.nomenu) { MenuItem menuTitle = new MenuItem(menuBar, SWT.CASCADE); Menu menuList1 = new Menu(m_oTopLevelShell, SWT.DROP_DOWN); MenuItem refreshItem = new MenuItem(menuList1, SWT.NULL); MenuItem changeUserItem = new MenuItem(menuList1, SWT.NULL); new MenuItem(menuList1, SWT.SEPARATOR); MenuItem exitItem = new MenuItem(menuList1, SWT.NULL); menuTitle.setText(trans.translate("menu_top_app")); // first menu list menuTitle.setMenu(menuList1); refreshItem.setText(trans.translate("menu_app_refresh")); changeUserItem.setText(trans.translate("menu_app_changeUser")); exitItem.setText(trans.translate("menu_app_exit")); // event-handling for MenuItem's refreshItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { LayoutLoader loader = LayoutLoader.instance(); DialogThread dialog = DialogThread.instance(m_oTopLevelShell); MsgTranslator trans = MsgTranslator.instance(); super.widgetSelected(e); synchronized (TreeNodes.m_DISPLAYLOCK) { loader.setState(LayoutLoader.REFRESH); dialog.needProgressBar(); dialog.needUserVerificationFields(); dialog.show(trans.translate("dialogChangeUser"), trans.translate("dialogUserVerification")); dialog.produceDialog(REFRESH); loader.setState(LayoutLoader.WAIT); } } }); changeUserItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { LayoutLoader loader = LayoutLoader.instance(); DialogThread dialog = DialogThread.instance(m_oTopLevelShell); MsgTranslator trans = MsgTranslator.instance(); super.widgetSelected(e); synchronized (TreeNodes.m_DISPLAYLOCK) { loader.setState(LayoutLoader.UPDATE); dialog.needProgressBar(); dialog.needUserVerificationFields(); dialog.show(trans.translate("dialogChangeUser"), trans.translate("dialogUserVerification")); dialog.produceDialog(UPDATE); } if (HtmTags.debug) System.out.println("change user to '" + TreeNodes.m_sUser + "'"); } }); exitItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { LayoutLoader loader = LayoutLoader.instance(); super.widgetSelected(e); m_oTopLevelShell.close(); } }); } // create composites to display login = TreeNodes.m_Settings.getSection(TreeNodes.m_sLayoutStyle); if (login == null) { login = new DialogSettings(TreeNodes.m_sLayoutStyle); TreeNodes.m_Settings.addSection(login); } monitor = Display.getDefault().getPrimaryMonitor().getBounds(); if (HtmTags.fullscreen) { m_nWidth = monitor.width; m_nHeight = monitor.height; } else { check = login.get("xLocation"); if (check != null) { xLocation = login.getInt("xLocation"); yLocation = login.getInt("yLocation"); m_nWidth = login.getInt("mainwidth"); m_nHeight = login.getInt("mainheight"); } else { m_nWidth = 0; m_nHeight = 0; xLocation = monitor.width / 2; yLocation = monitor.height / 2; monitor = m_oTopLevelShell.getBounds(); xLocation -= (monitor.width / 2); yLocation -= (monitor.height / 2); } m_oTopLevelShell.setLocation(xLocation, yLocation); } mainComposite = new Composite(m_oTopLevelShell, SWT.NONE); mainComposite.setBackground(HtmTags.systemColor); if (HtmTags.notree) { FillLayout fill = new FillLayout(); RowLayout popupLayout = new RowLayout(); m_shellForm = new SashForm(mainComposite, SWT.VERTICAL); m_oPopupIn = new Composite(m_shellForm, SWT.NONE); m_oPopupComposite = new Composite(m_oPopupIn, SWT.NONE); m_oMainComposite = new Composite(m_shellForm, SWT.NONE); m_shellForm.setBackground(HtmTags.systemColor); m_oPopupIn.setBackground(HtmTags.systemColor); m_oPopupComposite.setBackground(HtmTags.systemColor); m_oMainComposite.setBackground(HtmTags.systemColor); fill.marginHeight = 0; fill.marginWidth = 0; popupLayout.marginHeight = HtmTags.popupPadding; popupLayout.marginWidth = HtmTags.popupPadding; popupLayout.marginBottom = 0; popupLayout.marginTop = 0; popupLayout.marginLeft = 0; popupLayout.marginRight = 0; mainComposite.setLayout(mainLayout); m_oPopupIn.setLayout(fill); m_oPopupComposite.setLayout(popupLayout); treeComposite = null; m_oTree = null; } else { m_shellForm = new SashForm(mainComposite, SWT.HORIZONTAL); treeComposite = new Group(m_shellForm, SWT.SHADOW_ETCHED_IN); m_oMainComposite = new Composite(m_shellForm, SWT.NONE); m_oTree = new Tree(treeComposite, SWT.SINGLE); treeComposite.setBackground(HtmTags.systemColor); m_oMainComposite.setBackground(HtmTags.systemColor); mainLayout.marginHeight = 0; mainLayout.marginWidth = 0; mainComposite.setLayout(mainLayout); check = login.get("sashwidth"); if (check != null) { sashWeight[0] = login.getInt("sashwidth"); sashWeight[1] = login.getInt("sashheight"); } m_shellForm.setWeights(sashWeight); m_shellForm.setLayout(new FillLayout()); } if (!HtmTags.notree) { treeLayout.marginWidth = 1; treeLayout.marginHeight = 1; treeComposite.setLayout(treeLayout); treeComposite.setVisible(true); } m_StackLayout.marginHeight = HtmTags.mainPadding; m_StackLayout.marginWidth = HtmTags.mainPadding; m_oMainComposite.setLayout(m_StackLayout); m_oTopLevelShell.setLayout(new FillLayout()); m_oTopLevelShell.setText("ppi-client (physical port interface client)"); if (!HtmTags.notree) {// add listeners for tree m_oTree.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { synchronized (TreeNodes.m_DISPLAYLOCK) { ArrayList<TreeNodes> searchNodes; ArrayList<TreeItem> itemTree = new ArrayList<TreeItem>(); TreeItem existItems[] = m_oTree.getItems(); TreeItem items[] = m_oTree.getSelection(); TreeItem curItem = null; int pos, count; String name = ""; if (items.length > 0) curItem = items[0]; else return; while (curItem != null) { itemTree.add(0, curItem); curItem = curItem.getParentItem(); } searchNodes = m_aTreeNodes; do { curItem = itemTree.get(0); itemTree.remove(0); pos = 0; for (TreeItem s : existItems) { if (s == curItem) { existItems = s.getItems(); break; } ++pos; } count = -1; for (TreeNodes node : searchNodes) { if (node.treeDisplay()) ++count; if (count == pos) { name += "/" + node.getName(); searchNodes = node.getChilds(); break; } } } while (itemTree.size() > 0 && searchNodes != null); if (name.length() > 1) name = name.substring(1); if (HtmTags.debug) System.out.println("Treenode " + name + " is selected"); m_sAktFolder = name; setCurrentSideVisible(/*inform server by no body*/true); } } }); if (HtmTags.debug) { m_oTree.addTreeListener(new TreeAdapter() { public void treeCollapsed(TreeEvent e) { if (HtmTags.debug) System.out.println("collapsed node: " + ((TreeItem) e.item).getText()); } public void treeExpanded(TreeEvent e) { if (HtmTags.debug) System.out.println("expanded node: " + ((TreeItem) e.item).getText()); } }); } } }
From source file:ca.mcgill.sable.soot.launching.SavedConfigManager.java
License:Open Source License
private void remove(String name) { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); int count = 0; try {//from www . j av a 2 s .c om count = settings.getInt("config_count"); } catch (NumberFormatException e) { } String[] pointers = new String[count]; for (int i = 1; i <= count; i++) { pointers[i - 1] = settings.get("soot_run_config_" + i); } int i = 1; int j = 0; while (j < count) { if (!pointers[j].equals(name)) { settings.put("soot_run_config_" + i, pointers[j]); i++; } j++; } settings.put("soot_run_config_" + count, (String) null); count--; if (count < 0) { count = 0; } settings.put("config_count", count); settings.put(name, (String) null); }
From source file:ca.mcgill.sable.soot.launching.SavedConfigManager.java
License:Open Source License
private boolean alreadyInList(String name) { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); int count = 0; try {//from www. j a v a2 s . c o m count = settings.getInt("config_count"); } catch (NumberFormatException e) { } for (int i = 1; i <= count; i++) { if (settings.get("soot_run_config_" + i).equals(name)) { return true; } } return false; }
From source file:ca.mcgill.sable.soot.launching.SavedConfigManager.java
License:Open Source License
private void add(String name, ArrayList val) { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); int count = 0; try {//w w w . j av a 2s .co m count = settings.getInt("config_count"); } catch (NumberFormatException e) { } count++; settings.put("config_count", count); settings.put("soot_run_config_" + count, name); update(name, val); }
From source file:ca.mcgill.sable.soot.launching.SavedConfigManager.java
License:Open Source License
private void add(String name, String val) { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); int count = 0; try {//from ww w . j av a 2 s.c om count = settings.getInt("config_count"); } catch (NumberFormatException e) { } count++; settings.put("config_count", count); settings.put("soot_run_config_" + count, name); update(name, val); }
From source file:ca.mcgill.sable.soot.ui.SootConfigManagerDialog.java
License:Open Source License
private SootConfiguration getInitialInput() { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); int numConfig = 0; try {/*from w w w .ja v a 2s. co m*/ numConfig = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$ } catch (NumberFormatException e) { } SootConfiguration root = new SootConfiguration(""); //$NON-NLS-1$ if (numConfig != 0) { String[] configNames = new String[numConfig]; for (int i = 0; i < numConfig; i++) { configNames[i] = settings .get(Messages.getString("SootConfigManagerDialog.soot_run_config") + (i + 1)); //$NON-NLS-1$ root.addChild(new SootConfiguration(configNames[i])); } } setTreeRoot(root); return root; }
From source file:ca.mcgill.sable.soot.ui.SootConfigManagerDialog.java
License:Open Source License
private void newPressed() { IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); // gets current number of configurations before adding any int config_count = 0; try {/*from w ww .j a v a 2s . com*/ config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$ } catch (NumberFormatException e) { } ArrayList currentNames = new ArrayList(); for (int i = 1; i <= config_count; i++) { currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config") + i)); //$NON-NLS-1$ } // sets validator to know about already used names - but it doesn't use // them because then editing a file cannot use same file name SootConfigNameInputValidator validator = new SootConfigNameInputValidator(); validator.setAlreadyUsed(currentNames); // create dialog to get name InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Saving_Configuration_Name"), //$NON-NLS-1$ Messages.getString("SootConfigManagerDialog.Enter_name_to_save_configuration_with"), "", validator); //$NON-NLS-1$ //$NON-NLS-2$ nameDialog.open(); if (nameDialog.getReturnCode() == Dialog.OK) { setEditDefs(null); int returnCode = displayOptions(nameDialog.getValue(), "soot.Main"); //handle selection of main class here if (returnCode != Dialog.CANCEL) { getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue())); refreshTree(); } } else { // cancel and do nothing } }
From source file:ca.mcgill.sable.soot.ui.SootConfigManagerDialog.java
License:Open Source License
private void renamePressed() { if (getSelected() == null) return;/* w w w. j a v a2 s . c o m*/ String result = this.getSelected(); IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); // gets current number of configurations int config_count = 0; int oldNameCount = 0; try { config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$ } catch (NumberFormatException e) { } ArrayList currentNames = new ArrayList(); for (int i = 1; i <= config_count; i++) { currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config") + i)); //$NON-NLS-1$ if (((String) currentNames.get(i - 1)).equals(result)) { oldNameCount = i; } } // sets validator to know about already used names SootConfigNameInputValidator validator = new SootConfigNameInputValidator(); validator.setAlreadyUsed(currentNames); InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Rename_Saved_Configuration"), //$NON-NLS-1$ Messages.getString("SootConfigManagerDialog.Enter_new_name"), "", validator); //$NON-NLS-1$ //$NON-NLS-2$ nameDialog.open(); if (nameDialog.getReturnCode() == Dialog.OK) { settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config") + oldNameCount, //$NON-NLS-1$ nameDialog.getValue()); settings.put(nameDialog.getValue(), settings.getArray(result)); getTreeRoot().renameChild(result, nameDialog.getValue()); saveMainClass(nameDialog.getValue(), settings.get(result + "_mainClass")); } refreshTree(); }
From source file:ca.mcgill.sable.soot.ui.SootConfigManagerDialog.java
License:Open Source License
private void clonePressed() { if (getSelected() == null) return;/*w w w . ja v a 2 s . c o m*/ String result = this.getSelected(); IDialogSettings settings = SootPlugin.getDefault().getDialogSettings(); // gets current number of configurations int config_count = 0; try { config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$ } catch (NumberFormatException e) { } ArrayList currentNames = new ArrayList(); for (int i = 1; i <= config_count; i++) { currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config") + i)); //$NON-NLS-1$ } // sets validator to know about already used names SootConfigNameInputValidator validator = new SootConfigNameInputValidator(); validator.setAlreadyUsed(currentNames); InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Clone_Saved_Configuration"), //$NON-NLS-1$ Messages.getString("SootConfigManagerDialog.Enter_new_name"), result, validator); //$NON-NLS-1$ //$NON-NLS-3$ nameDialog.open(); if (nameDialog.getReturnCode() == Dialog.OK) { config_count++; settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config") + config_count, //$NON-NLS-1$ nameDialog.getValue()); settings.put(nameDialog.getValue(), settings.getArray(result)); settings.put(Messages.getString("SootConfigManagerDialog.config_count"), config_count); //$NON-NLS-1$ getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue())); saveMainClass(nameDialog.getValue(), settings.get(result + "_mainClass")); } refreshTree(); }
From source file:ch.qos.logback.beagle.view.TableMediator.java
License:Open Source License
int getColumnSizeDialogSetting(String columnName, int defaultValue) { if (Activator.INSTANCE == null) return defaultValue; IDialogSettings dialogSettings = Activator.INSTANCE.getDialogSettings(); try {/*from w ww. j a v a 2s. co m*/ int val = dialogSettings.getInt(Constants.COLUMN_SIZE_DIALOG_SETTINGS_PREFIX + columnName); return val; } catch (NumberFormatException e) { return defaultValue; } }