List of usage examples for org.eclipse.jface.preference PreferenceStore setDefault
@Override public void setDefault(String name, boolean value)
From source file:org.eclipse.wst.jsdt.debug.internal.ui.launching.JavaScriptConnectTab.java
License:Open Source License
/** * Handles creating the UI for the connector selected *///from w w w . j a v a 2 s .c o m void handleConnectorSelected() { Connector connect = getSelectedConnector(); if (connect == null || connect.equals(this.selectedconnector)) { //nothing changed return; } this.selectedconnector = connect; String desc = this.selectedconnector.description(); if (desc != null) { this.description.setText(desc); } else { this.description.setText(Messages.no_description_provided); } this.editormap.clear(); //get rid of the old controls Control[] children = this.argumentsgroup.getChildren(); for (int i = 0; i < children.length; i++) { children[i].dispose(); } PreferenceStore store = new PreferenceStore(); Entry entry = null; Argument argument = null; FieldEditor editor = null; String key = null; for (Iterator iter = this.selectedconnector.defaultArguments().entrySet().iterator(); iter.hasNext();) { entry = (Entry) iter.next(); key = (String) entry.getKey(); argument = (Argument) entry.getValue(); if (argument instanceof IntegerArgument) { //create an int editor store.setDefault(argument.name(), ((IntegerArgument) argument).intValue()); editor = new IntegerFieldEditor(argument.name(), argument.label(), this.argumentsgroup); } else if (argument instanceof BooleanArgument) { //create boolean editor store.setDefault(argument.name(), ((BooleanArgument) argument).booleanValue()); editor = new BooleanFieldEditor(argument.name(), argument.label(), this.argumentsgroup); editor.fillIntoGrid(argumentsgroup, 2); } else if (argument instanceof StringArgument) { //create String editor store.setDefault(argument.name(), argument.value()); editor = new StringFieldEditor(argument.name(), argument.label(), this.argumentsgroup); } else if (argument instanceof SelectedArgument) { //create list selection editor List choices = ((SelectedArgument) argument).choices(); String[][] namesAndValues = new String[choices.size()][2]; int count = 0; for (Iterator iter2 = choices.iterator(); iter2.hasNext();) { String choice = (String) iter2.next(); namesAndValues[count][0] = choice; namesAndValues[count][1] = choice; count++; } store.setDefault(argument.name(), argument.value()); editor = new ComboFieldEditor(argument.name(), argument.label(), namesAndValues, this.argumentsgroup); } if (editor != null) { editor.setPreferenceStore(store); editor.loadDefault(); editor.setPropertyChangeListener(this); this.editormap.put(key, editor); editor = null; } } //reset margins to undo FieldEditor bogosity GridLayout gd = (GridLayout) this.argumentsgroup.getLayout(); gd.marginHeight = 5; gd.marginWidth = 5; this.argumentsgroup.getParent().layout(true); this.argumentsgroup.setVisible(true); this.argumentsgroup.layout(true); updateLaunchConfigurationDialog(); }
From source file:org.rubypeople.rdt.debug.ui.launchConfigurations.RubyConnectTab.java
License:Open Source License
/** * Update the argument area to show the selected connector's arguments *///from w w w . j av a 2 s .com private void handleConnectorComboModified() { int index = fConnectorCombo.getSelectionIndex(); if ((index < 0) || (index >= fConnectors.length)) { return; } IVMConnector vm = fConnectors[index]; if (vm.equals(fConnector)) { return; // selection did not change } fConnector = vm; try { fArgumentMap = vm.getDefaultArguments(); } catch (CoreException e) { RdtDebugUiPlugin.statusDialog(LauncherMessages.RubyConnectTab_Unable_to_display_connection_arguments__2, e.getStatus()); return; } // Dispose of any current child widgets in the tab holder area Control[] children = fArgumentComposite.getChildren(); for (int i = 0; i < children.length; i++) { children[i].dispose(); } fFieldEditorMap.clear(); PreferenceStore store = new PreferenceStore(); // create editors Iterator<String> keys = vm.getArgumentOrder().iterator(); while (keys.hasNext()) { String key = keys.next(); Object arg = fArgumentMap.get(key); FieldEditor field = null; if (arg instanceof Integer) { store.setDefault(key, ((Integer) arg).intValue()); field = new IntegerFieldEditor(key, key, fArgumentComposite); } else if (arg instanceof String) { store.setDefault(key, (String) arg); field = new StringFieldEditor(key, key, fArgumentComposite); } // if (arg instanceof Connector.IntegerArgument) { // store.setDefault(arg.name(), ((Connector.IntegerArgument) arg) // .intValue()); // field = new IntegerFieldEditor(arg.name(), arg.label(), // fArgumentComposite); // } else if (arg instanceof Connector.SelectedArgument) { // List choices = ((Connector.SelectedArgument) arg).choices(); // String[][] namesAndValues = new String[choices.size()][2]; // Iterator iter = choices.iterator(); // int count = 0; // while (iter.hasNext()) { // String choice = (String) iter.next(); // namesAndValues[count][0] = choice; // namesAndValues[count][1] = choice; // count++; // } // store.setDefault(arg.name(), arg.value()); // field = new ComboFieldEditor(arg.name(), arg.label(), // namesAndValues, fArgumentComposite); // } else if (arg instanceof Connector.StringArgument) { // store.setDefault(arg.name(), arg.value()); // field = new StringFieldEditor(arg.name(), arg.label(), // fArgumentComposite); // } else if (arg instanceof Connector.BooleanArgument) { // store.setDefault(arg.name(), ((Connector.BooleanArgument) arg) // .booleanValue()); // field = new BooleanFieldEditor(arg.name(), arg.label(), // fArgumentComposite); // } if (field != null) { field.setPreferenceStore(store); field.loadDefault(); field.setPropertyChangeListener(this); fFieldEditorMap.put(key, field); } } fArgumentComposite.getParent().getParent().layout(); fArgumentComposite.layout(true); updateLaunchConfigurationDialog(); }