List of usage examples for org.eclipse.jface.preference FieldEditor VALUE
String VALUE
To view the source code for org.eclipse.jface.preference FieldEditor VALUE.
Click Source Link
"field_editor_value"
) to signal a change in the value of this field editor. From source file:eu.esdihumboldt.hale.ui.io.source.URLSource.java
License:Open Source License
/** * @see ImportSource#createControls(Composite) *//*from www . j a v a 2 s . c o m*/ @Override public void createControls(Composite parent) { parent.setLayout(new GridLayout(3, false)); detectImage = HALEUIPlugin.getImageDescriptor("icons/find_obj.gif").createImage(); // source file sourceURL = new URLSourceURIFieldEditor("sourceURL", "Source URL:", parent) { @Override protected void onHistorySelected(URI location, IContentType contentType) { // select the content type associated with the recent URL types.setSelection(new StructuredSelection(contentType)); updateState(false); } }; sourceURL.setPage(getPage()); // set content types for file field Collection<IOProviderDescriptor> factories = getConfiguration().getFactories(); supportedTypes = new HashSet<IContentType>(); for (IOProviderDescriptor factory : factories) { supportedTypes.addAll(factory.getSupportedTypes()); } sourceURL.setContentTypes(supportedTypes); sourceURL.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { getPage().setMessage(null); updateState(false); } else if (event.getProperty().equals(FieldEditor.VALUE)) { getPage().setMessage(null); updateState(false); } } }); // content type selection // label Label typesLabel = new Label(parent, SWT.NONE); typesLabel.setText("Content type"); // types combo Composite group = new Composite(parent, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY); types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); types.setContentProvider(ArrayContentProvider.getInstance()); types.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IContentType) { return ((IContentType) element).getName(); } return super.getText(element); } }); types.setInput(supportedTypes); // process selection changes types.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateState(true); } }); // detect button detect = new Button(group, SWT.PUSH); detect.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); detect.setText("Detect"); detect.setImage(detectImage); detect.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { runDetectContentType(); } }); // provider selection // label Label providerLabel = new Label(parent, SWT.NONE); providerLabel.setText("Import as"); // create provider combo ComboViewer providers = createProviders(parent); providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); // initial state update updateState(true); }
From source file:eu.esdihumboldt.hale.ui.io.target.FileTarget.java
License:Open Source License
@Override public void createControls(Composite parent) { getPage().setDescription("Please select a destination file for the export"); parent.setLayout(new GridLayout(3, false)); targetFile = new SaveFileFieldEditor("targetFile", "Target file:", true, FileFieldEditor.VALIDATE_ON_KEY_STROKE, parent); targetFile.setEmptyStringAllowed(false); targetFile.setAllowUri(true);/* w ww. ja v a2 s. co m*/ targetFile.setPage(getPage()); targetFile.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { updateState(); } else if (event.getProperty().equals(FieldEditor.VALUE)) { updateContentType(); } } }); updateState(); }
From source file:eu.esdihumboldt.hale.ui.io.target.URLTarget.java
License:Open Source License
/** * @see eu.esdihumboldt.hale.ui.io.ExportTarget#createControls(org.eclipse.swt.widgets.Composite) *//*from ww w .ja v a2 s . com*/ @Override public void createControls(Composite parent) { parent.setLayout(new GridLayout(3, false)); // source file targetURL = new URLTargetURIFieldEditor("targetURL", "Target URL", parent) { @Override protected void onHistorySelected(URI location) { updateState(); } }; targetURL.setPage(getPage()); targetURL.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { getPage().setMessage(null); updateState(); } else if (event.getProperty().equals(FieldEditor.VALUE)) { getPage().setMessage(null); updateState(); } } }); // content type selection // label Label typesLabel = new Label(parent, SWT.NONE); typesLabel.setText("Content type"); // types combo Composite group = new Composite(parent, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY); types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); types.setContentProvider(ArrayContentProvider.getInstance()); types.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IContentType) { return ((IContentType) element).getName(); } return super.getText(element); } }); // process selection changes types.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // update content type ISelection sel = event.getSelection(); if (sel.isEmpty() || !(sel instanceof IStructuredSelection)) { setContentType(null); } else { setContentType((IContentType) ((IStructuredSelection) sel).getFirstElement()); } } }); }
From source file:eu.numberfour.n4js.ui.binaries.BinariesPreferencePage.java
License:Open Source License
@Override protected Control createContents(final Composite parent) { Composite body = new Composite(parent, NONE); body.setLayout(GridLayoutFactory.fillDefaults().create()); body.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).align(FILL, FILL).create()); final Iterable<Binary> binaries = binariesProvider.getRegisteredBinaries(); for (final Binary binary : binaries) { final Group binaryGroup = new Group(body, SWT.SHADOW_ETCHED_IN); binaryGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).create()); binaryGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(FILL, TOP).create()); binaryGroup.setText(binary.getLabel()); final DirectoryFieldEditor editor = new DirectoryFieldEditor("", "Path:", binaryGroup); final URI path = store.getPath(binary); if (null != path) { final File file = new File(path); editor.setStringValue(file.getAbsolutePath()); }/*from w w w. j av a 2 s.c om*/ editor.setPropertyChangeListener(event -> { if (null != event) { if (FieldEditor.VALUE.equals(event.getProperty())) { updateStoreState(binary, event.getNewValue()); } } }); final Text text = editor.getTextControl(binaryGroup); final ModifyListener modifyListener = new ModifyListener() { private Timer timer; @Override public void modifyText(ModifyEvent e) { if (null != timer) { timer.cancel(); timer = null; } timer = new Timer("'" + binary.getLabel() + "' binary validation thread"); final String newValue = text.getText(); timer.schedule(new TimerTask() { @Override public void run() { updateStoreState(binary, newValue); } }, VALIDATION_DELAY_MS); } }; text.addModifyListener(modifyListener); text.addDisposeListener(e -> text.removeModifyListener(modifyListener)); final String description = binary.getDescription(); if (null != description) { final Label descriptionLabel = new Label(binaryGroup, WRAP); descriptionLabel.setText(description); final GridData gridData = new GridData(FILL, TOP, true, false, 3, 1); gridData.widthHint = DESCRIPTION_H_HINT; descriptionLabel.setLayoutData(gridData); } } for (final Binary binary : binaries) { final IStatus status = binary.validate(); if (!status.isOK()) { setErrorMessage(status.getMessage()); break; } } return body; }
From source file:gov.nasa.ensemble.core.detail.emf.binding.IPathBindingFactory.java
License:Open Source License
@Override public Binding createBinding(DetailProviderParameter p) { FormToolkit toolkit = p.getDetailFormToolkit(); Composite parent = p.getParent(); parent.setBackgroundMode(SWT.INHERIT_FORCE); final Composite rootComposite = new Composite(parent, SWT.NONE); {//from www . j a v a 2s .c o m GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(rootComposite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1) .applyTo(rootComposite); } Composite composite = new Composite(rootComposite, SWT.NONE); { GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(composite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(composite); } EObject target = p.getTarget(); IItemPropertyDescriptor pd = p.getPropertyDescriptor(); boolean isEditable = pd.canSetProperty(target); EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target); if (feature == null) { return null; } String labelText = EMFDetailUtils.getDisplayName(target, pd); baseURI = target.eResource().getURI(); String preferenceName = (feature.getName() == null) ? "" : feature.getName(); String type = EMFUtils.getAnnotation(feature, EMFDetailUtils.ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_TYPE); String extensionFilter = EMFUtils.getAnnotation(feature, EMFDetailUtils.ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_EXTENSIONFILTER); boolean enableNewFile = Boolean.parseBoolean(EMFUtils.getAnnotation(feature, EMFDetailUtils.ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_ENABLE_NEW_FILE)); List<String> fileExtensionFilter; if (extensionFilter != null) { fileExtensionFilter = prefixExtensions( Collections.unmodifiableList(Arrays.asList(extensionFilter.split("\\s*,\\s*"))), "*."); } else { fileExtensionFilter = Collections.emptyList(); } ExtendedStringButtonFieldEditor fileFieldEditor; if ("IFile".equalsIgnoreCase(type)) { IFileFieldEditor editor = new IFileFieldEditor(preferenceName, labelText, composite); editor.setBaseURI(baseURI); if ((fileExtensionFilter != null) && (fileExtensionFilter.size() > 0)) { editor.setFileExtensions(fileExtensionFilter.toArray(new String[fileExtensionFilter.size()])); } if (enableNewFile) { editor.setFileChooserStyle(SWT.SAVE); } fileFieldEditor = editor; } else if ("IPath".equalsIgnoreCase(type) || "IContainer".equalsIgnoreCase(type) || "IFolder".equalsIgnoreCase(type)) { IDirectoryFieldEditor editor = new IDirectoryFieldEditor(preferenceName, labelText, composite); editor.setBaseURI(baseURI); fileFieldEditor = editor; } else if ("Directory".equalsIgnoreCase(type)) { fileFieldEditor = new DirectoryFieldEditor(preferenceName, labelText, composite); } else { if (!isEditable) { ButtonFieldEditor editor = new ButtonFieldEditor(preferenceName, labelText, composite); fileFieldEditor = editor; } else { FileFieldEditor editor = new FileFieldEditor(preferenceName, labelText, composite); if (enableNewFile) { editor.setFileChooserStyle(SWT.SAVE); } if ((fileExtensionFilter != null) && (fileExtensionFilter.size() > 0)) { editor.setFileExtensions(fileExtensionFilter.toArray(new String[fileExtensionFilter.size()])); } fileFieldEditor = editor; } } fileFieldEditor.setChangeButtonText("..."); boolean editable = pd.canSetProperty(target); fileFieldEditor.setEnabled(editable, composite); // disables the entire row fileFieldEditor.getLabelControl(composite).setEnabled(true); // re-enables the label Label label = fileFieldEditor.getLabel(); EMFDetailUtils.addDescriptionTooltip(pd, target, label); Control control = fileFieldEditor.getTextControl(composite); toolkit.adapt(control, true, true); EMFDetailUtils.addDescriptionTooltip(pd, target, control); Button changeButton = fileFieldEditor.getChangeButton(); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .hint(Activator.CONTROL_WIDTH_HINT, SWT.DEFAULT).applyTo(control); EMFDetailUtils.bindValidatorDecoration(p, control); EMFDetailUtils.bindControlViability(p, new Control[] { control, changeButton }); IObservableValue targetObservableValue = observeText(control); PathUpdateValueStrategy targetToModel = new PathUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); PathUpdateValueStrategy modelToTarget = new PathUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); final Binding binding = EMFDetailUtils.bindEMFUndoable(p, targetObservableValue, targetToModel, modelToTarget); EMFDetailUtils.bindTextModifyUndoable((Text) control, target, labelText); fileFieldEditor.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.VALUE)) { binding.updateTargetToModel(); Button openButton = (Button) rootComposite.getData(OPEN_BUTTON); if (openButton != null) openButton.setEnabled(!event.getNewValue().toString().trim().equals("")); } } }); if ("File".equalsIgnoreCase(type) || "IFile".equalsIgnoreCase(type)) { String enableOpen = EMFUtils.getAnnotation(feature, EMFDetailUtils.ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_ENABLE_OPEN); if (Boolean.parseBoolean(enableOpen)) { Button openButton = createOpenButton(rootComposite, labelText, (Text) control); openButton.setEnabled(!fileFieldEditor.getStringValue().trim().equals("")); rootComposite.setData(OPEN_BUTTON, openButton); } } return binding; }
From source file:gov.nasa.ensemble.core.plan.advisor.preferences.PlanAdvisorPreferencePage.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent event) { if ((event.getProperty() == FieldEditor.VALUE) && (event.getSource() == fixViolationWizard) && (event.getNewValue() instanceof Boolean)) { Boolean bool = (Boolean) event.getNewValue(); updateAutoStartFixing(bool.booleanValue()); }//from w ww .j a va 2 s.co m super.propertyChange(event); }
From source file:mmrnmhrm.ui.preferences.pages.DeeAppearancePreferencePage.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getProperty().equals(FieldEditor.VALUE) && event.getSource() == iconStyleEditor) { Object newValue = event.getNewValue(); if (newValue != null && newValue instanceof String) { selectedIconStyle = ElementIconsStyle.fromString((String) newValue, null); }/*from ww w. ja v a2 s .co m*/ previewGroup.refreshPreview(); } }
From source file:net.ostis.scpdev.preferences.ScpEnviromentPreferencePage.java
License:Open Source License
public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getProperty().equals(FieldEditor.VALUE)) { calculateEnabled();//from ww w . ja v a 2s.co m checkState(); } }
From source file:net.sf.eclipse.tomcat.TomcatPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { final Composite composite = parent; oldVersion = TomcatLauncherPlugin.getDefault().getTomcatVersion(); version = new RadioGroupFieldEditor(TomcatLauncherPlugin.TOMCAT_PREF_VERSION_KEY, PREF_PAGE_CHOOSEVERSION_LABEL, 1, new String[][] { { PREF_PAGE_VERSION3_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION3 }, { PREF_PAGE_VERSION4_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION4 }, { PREF_PAGE_VERSION4_1_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION41 }, { PREF_PAGE_VERSION5_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION5 }, { PREF_PAGE_VERSION6_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION6 }, { PREF_PAGE_VERSION7_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION7 }, { PREF_PAGE_VERSION8_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION8 }, { PREF_PAGE_VERSION9_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION9 } }, composite, true);//from w w w. j a v a 2 s . c o m Group homeGroup = new Group(composite, SWT.NONE); homeGroup.setToolTipText("You can use ${workspace_loc} for a workspace relative path."); home = new VariableAwareDirectoryFieldEditor(TomcatLauncherPlugin.TOMCAT_PREF_HOME_KEY, PREF_PAGE_HOME_LABEL, homeGroup); Group modeGroup = new Group(composite, SWT.NONE); modeGroup.setLayout(new GridLayout(1, false)); Composite configGroup = new Composite(modeGroup, SWT.NULL); configMode = new RadioGroupFieldEditor(TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY, PREF_PAGE_CHOOSECONFMODE_LABEL, 1, new String[][] { { PREF_PAGE_SERVERXML_LABEL, TomcatLauncherPlugin.SERVERXML_MODE }, { PREF_PAGE_CONTEXTFILES_LABEL, TomcatLauncherPlugin.CONTEXTFILES_MODE }, }, configGroup, false); new Label(composite, SWT.NULL); //blank final Composite configLocationGroup = new Composite(modeGroup, SWT.NULL); configFile = new TomcatFileFieldEditor(TomcatLauncherPlugin.TOMCAT_PREF_CONFIGFILE_KEY, PREF_PAGE_CONFIGFILE_LABEL, configLocationGroup); contextsDir = new TomcatDirectoryFieldEditor(TomcatLauncherPlugin.TOMCAT_PREF_CONTEXTSDIR_KEY, PREF_PAGE_CONTEXTSDIR_LABEL, configLocationGroup); home.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.VALUE)) { computeConfigFile(); computeContextsDir(); } } }); new Label(composite, SWT.NULL); //blank initLayoutAndData(homeGroup, 3); initLayoutAndData(modeGroup, 1); initLayoutAndData(configLocationGroup, 3); this.initField(version); version.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.VALUE)) { String value = (String) event.getNewValue(); versionChanged(value); } } }); this.initField(home); this.initField(configMode); modeChanged(configLocationGroup, getPreferenceStore().getString(TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY)); configMode.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.VALUE)) { String value = (String) event.getNewValue(); modeChanged(configLocationGroup, value); } } }); this.initField(configFile); if (configFile.getStringValue().length() == 0) { computeConfigFile(); } this.initField(contextsDir); if (contextsDir.getStringValue().length() == 0) { computeContextsDir(); } return parent; }
From source file:net.sourceforge.eclipseccase.ui.preferences.DecoratorPreferencePage.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent event) { if (FieldEditor.VALUE.equals(event.getProperty())) { previewTree.refresh(true /* update labels */); }//from w w w. jav a 2 s .c o m // call super super.propertyChange(event); }