List of usage examples for org.eclipse.jface.preference FieldEditor fillIntoGrid
public void fillIntoGrid(Composite parent, int numColumns)
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 *//* w w w . j av a 2 s . co 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.evolizer.changedistiller.preferences.ChangeDistillerPreferencePage.java
License:Apache License
/** * {@inheritDoc}/*from ww w . j ava2 s .c om*/ */ @Override protected void createFieldEditors() { fLeafStringSims = new ComboFieldEditor(IChangeDistillerPreferenceConstants.LEAF_STRING_SIM, Messages.sLeafStringSim, new String[][] { { Messages.sStringSimLevenshtein, IChangeDistillerPreferenceConstants.PREF_STRING_SIM_LEVENSHTEIN }, { Messages.sStringSimNGrams, IChangeDistillerPreferenceConstants.PREF_STRING_SIM_NGRAMS } }, getFieldEditorParent()); addField(fLeafStringSims); fLeafNGramsValue = new IntegerFieldEditor(IChangeDistillerPreferenceConstants.LEAF_NGRAMS_VALUE, Messages.sNGramsValue, getFieldEditorParent(), 2); getPreferenceStore(); addField(fLeafNGramsValue); addField(new DoubleFieldEditor(IChangeDistillerPreferenceConstants.LEAF_STRING_SIM_THRESHOLD, Messages.sLeafStringSimThreshold, getFieldEditorParent(), TEXT_LIMIT)); fNodeStringSimEnablement = new BooleanFieldEditor( IChangeDistillerPreferenceConstants.NODE_STRING_SIM_ENABLEMENT, Messages.sNodeStringSimEnablement, getFieldEditorParent()); addField(fNodeStringSimEnablement); fNodeStringSimilarity = createGroup(getFieldEditorParent(), "", 1, 2, GridData.FILL_HORIZONTAL); fNodeStringSimSpacer = createComposite(fNodeStringSimilarity, 1, 1, GridData.FILL_HORIZONTAL); fNodeStringSim = new ComboFieldEditor(IChangeDistillerPreferenceConstants.NODE_STRING_SIM, Messages.sNodeStringSim, new String[][] { { Messages.sStringSimLevenshtein, IChangeDistillerPreferenceConstants.PREF_STRING_SIM_LEVENSHTEIN }, { Messages.sStringSimNGrams, IChangeDistillerPreferenceConstants.PREF_STRING_SIM_NGRAMS } }, fNodeStringSimSpacer); fNodeStringSim.fillIntoGrid(fNodeStringSimSpacer, 2); addField(fNodeStringSim); fNodeNGramsValue = new IntegerFieldEditor(IChangeDistillerPreferenceConstants.NODE_STRING_SIM_NGRAMS_VALUE, Messages.sNGramsValue, fNodeStringSimSpacer, 2); fNodeNGramsValue.fillIntoGrid(fNodeStringSimSpacer, 2); addField(fLeafNGramsValue); FieldEditor editor = new DoubleFieldEditor(IChangeDistillerPreferenceConstants.NODE_STRING_SIM_THRESHOLD, Messages.sNodeStringSimThreshold, fNodeStringSimSpacer, TEXT_LIMIT); editor.fillIntoGrid(fNodeStringSimSpacer, 2); addField(editor); addField(new ComboFieldEditor(IChangeDistillerPreferenceConstants.NODE_SIM, Messages.sNodeSim, new String[][] { { Messages.sNodeSimChawathe, IChangeDistillerPreferenceConstants.PREF_NODE_SIM_CHAWATHE }, { Messages.sNodeSimDice, IChangeDistillerPreferenceConstants.PREF_NODE_SIM_DICE } }, getFieldEditorParent())); addField(new DoubleFieldEditor(IChangeDistillerPreferenceConstants.NODE_SIM_THRESHOLD, Messages.sNodeSimThreshold, getFieldEditorParent(), TEXT_LIMIT)); fDynamicThresholdEnablement = new BooleanFieldEditor( IChangeDistillerPreferenceConstants.DYNAMIC_THRESHOLD_ENABLEMENT, Messages.sDynamicThresholdEnablement, getFieldEditorParent()); addField(fDynamicThresholdEnablement); fDynamicThreshold = createGroup(getFieldEditorParent(), "", 1, 2, GridData.FILL_HORIZONTAL); Composite spacer = createComposite(fDynamicThreshold, 1, 1, GridData.FILL_HORIZONTAL); editor = new IntegerFieldEditor(IChangeDistillerPreferenceConstants.DEPTH_VALUE, Messages.sDepthValue, spacer, 2); editor.fillIntoGrid(spacer, 2); addField(editor); editor = new DoubleFieldEditor(IChangeDistillerPreferenceConstants.DYNAMIC_THRESHOLD, Messages.sDynamicThreshold, spacer, TEXT_LIMIT); editor.fillIntoGrid(spacer, 2); addField(editor); addField(new ComboFieldEditor(IChangeDistillerPreferenceConstants.LEAF_MATCHING, Messages.sLeafMatching, new String[][] { { Messages.sLeafMatchingFirst, IChangeDistillerPreferenceConstants.PREF_LEAF_MATCHING_FIRST }, { Messages.sLeafMatchingBest, IChangeDistillerPreferenceConstants.PREF_LEAF_MATCHING_BEST } }, getFieldEditorParent())); fStore = ChangeDistillerPlugin.getDefault().getPreferenceStore(); }
From source file:org.jboss.tools.common.model.ui.attribute.XAttributeSupport.java
License:Open Source License
public Control[] fillComposite(Composite composite, FieldEditor fieldEditor, boolean greedy) { composite.setBackgroundMode(SWT.INHERIT_DEFAULT); if (fieldEditor instanceof IFieldEditor) { Control control;/* ww w .j a va 2 s . c om*/ GridData gd; Control[] controls = ((IFieldEditor) fieldEditor).getControls(composite); if (controls.length == 2) { // layout 2 element control = controls[0]; gd = new GridData(); control.setLayoutData(gd); control = controls[1]; if (greedy) { gd.verticalAlignment = GridData.BEGINNING; if (editors.size() == 1) gd.horizontalSpan = 2; gd = new GridData(GridData.FILL_BOTH); if (editors.size() == 1) gd.horizontalSpan = 2; } else { gd = new GridData(GridData.FILL_HORIZONTAL); } if (greedy) { int h = control.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; if (h > 300) gd.heightHint = 300; if (fieldEditor instanceof NoteFieldEditor) { gd.heightHint = 100; } } control.setLayoutData(gd); } else if (controls.length == 1) { // layout 1st element control = controls[0]; gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; control.setLayoutData(gd); } return controls; } else { fieldEditor.fillIntoGrid(composite, 2); return null; } }
From source file:org.jboss.tools.jsf.ui.editor.form.ApplicationConfigForm.java
License:Open Source License
protected Control createClientArea(Composite parent, IWidgetSettings settings) { Composite composite = new Composite(parent, SWT.NONE); settings.setupControl(composite);// ww w. jav a 2 s. c o m GridLayout layout = new GridLayout(2, Boolean.FALSE.booleanValue()); layout.horizontalSpacing = 5; layout.verticalSpacing = 5; layout.marginHeight = 5; layout.marginWidth = 5; composite.setLayout(layout); GridData gd; String description = FacesConfigEditorMessages.APPLICATIONCONFIGFORM_DESCRIPTION; if (description != null && description.length() > 0) { Label label = new Label(composite, SWT.WRAP); settings.setupControl(label); label.setText(description); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); } String[] attributes = new String[] { "action-listener", "navigation-handler", "view-handler", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ "state-manager" }; //$NON-NLS-1$ if (xmo == null) return composite; for (int i = 0; i < attributes.length; i++) { IPropertyEditor editor = support.getPropertyEditorByName(attributes[i]); putFieldEditorInToComposit(composite, editor); } IPropertyEditor editor = support.getPropertyEditorByName("default-render-kit-id"); //$NON-NLS-1$ FieldEditor f = editor.getFieldEditor(composite); f.fillIntoGrid(composite, 2); support.registerFieldEditor(editor.getAttributeName(), f); if (messageBundleTable != null) messageBundleTable.fill(composite); if (resourceBundleTable != null) resourceBundleTable.fill(composite); return composite; }
From source file:org.jboss.tools.jst.web.ui.wizards.project.NewWebProjectWizardPage.java
License:Open Source License
private void createControlImpl(Composite parent) { GridData gd;//from w w w . j a v a 2s . co m FieldEditor editor; composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 10; layout.verticalSpacing = 10; layout.marginHeight = 4; layout.marginWidth = 4; composite.setLayout(layout); // nameEditor editor = nameEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); // useDefaultPathEditor editor = useDefaultPathEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); // locationEditor editor = locationEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); // versionEditor editor = versionEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); // templateEditor editor = templateEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); gd = new GridData(GridData.FILL_BOTH); //gd.heightHint = 400; composite.setLayoutData(gd); this.setControl(composite); ///Preference.USE_DEFAULT_PROJECT_ROOT.getValue() // init default values nameAdapter.setValue(""); //$NON-NLS-1$ useDefaultPathAdapter.setValue((getProjectRootOption() != null) ? "false" : "true"); //$NON-NLS-1$ //$NON-NLS-2$ // locationAdapter.setValue(defaultPath.toOSString()); if (getProjectRootOption() == null) locationAdapter.setValue(defaultPath.toOSString()); else locationAdapter.setValue(getProjectRootOption()); versionAdapter.setValue(template.getDefaultVersion()); templateAdapter.setValue(template.getDefaultTemplate(template.getDefaultVersion())); // setPageComplete(false); }
From source file:org.jboss.tools.struts.ui.wizard.adopt.AdoptProjectStepModulesView.java
License:Open Source License
public Control createControl(Composite parent) { GridData gd;/*from ww w . jav a 2 s . c o m*/ Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 10; layout.verticalSpacing = 10; layout.marginHeight = 10; layout.marginWidth = 10; composite.setLayout(layout); // table FieldEditor editor = tableSelectionEditor.getFieldEditor(composite); editor.fillIntoGrid(composite, 2); // separator Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; separator.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 400; composite.setLayoutData(gd); Control c2 = moduleTable.createControl(composite, support.getTarget()); GridLayout l = (GridLayout) ((Composite) c2).getLayout(); l.marginWidth = 0; GridData d = new GridData(GridData.FILL_BOTH); d.horizontalSpan = 2; c2.setLayoutData(d); return composite; }
From source file:org.soyatec.tooling.gef.properties.ViewPropertyTab.java
License:Open Source License
public Control createControl(final FormToolkit factory, final Composite parent) { control = factory.createComposite(parent, SWT.NONE); final int numColumns = 2; control.setLayout(new GridLayout(numColumns, false)); for (final EStructuralFeature sf : common_features) { final FieldEditor editor = createFieldEditor(control, sf); if (editor != null) { editorMap.put(sf, editor);//from ww w . j av a 2s. co m } } gradientGroup = new Group(control, SWT.NONE); gradientGroup.setText(ResourcesFactory.getString("properties_gradient")); //$NON-NLS-1$ gradientGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, numColumns, 1)); for (final EStructuralFeature sf : gradient_features) { final FieldEditor editor = createFieldEditor(gradientGroup, sf); if (editor != null) { editorMap.put(sf, editor); } } gradientGroup.setLayout(new GridLayout(numColumns, false)); final Set<Entry<EStructuralFeature, FieldEditor>> entrySet = editorMap.entrySet(); for (final Entry<EStructuralFeature, FieldEditor> entry : entrySet) { final EStructuralFeature feature = entry.getKey(); final FieldEditor editor = entry.getValue(); editor.fillIntoGrid(getEditorParent(feature), numColumns); editor.setPreferenceStore(store); editor.setPropertyChangeListener(this); } final Control[] children = control.getChildren(); for (final Control child : children) { factory.adapt(child, true, true); } // control.layout(); refresh(); return control; }
From source file:org.universaal.tools.packaging.tool.preferences.GroupFieldEditor.java
License:Apache License
@Override protected void doFillIntoGrid(Composite parentParam, int numColumns) { GridLayout gridLayout = new GridLayout(); gridLayout.marginLeft = GROUP_PADDING; gridLayout.marginRight = GROUP_PADDING; gridLayout.marginTop = GROUP_PADDING; gridLayout.marginBottom = GROUP_PADDING; this.group.setLayout(gridLayout); this.parent.layout(); this.parent.redraw(); if (members != null) { for (FieldEditor editor : members) { editor.fillIntoGrid(getFieldEditorParent(), 2); editor.setPropertyChangeListener(this); }//from w w w .java2s. c om } }