List of usage examples for org.eclipse.jface.preference StringButtonFieldEditor StringButtonFieldEditor
protected StringButtonFieldEditor()
From source file:org.eclipse.umlgen.gen.c.ui.UML2CPropertyPage.java
License:Open Source License
/** * Creates the second group on which access paths to models must be specified. * * @param parent/*ww w .j a va2 s . c o m*/ * The composite parent */ private void createModelsGroup(Composite parent) { final Group mainGroup = new Group(parent, SWT.NONE); mainGroup.setText(Messages.getString("UML2CPropertyPage.0")); //$NON-NLS-1$ mainGroup.setLayout(new GridLayout()); mainGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); // FIXME MIGRATION // Composite for the diagram path // final Composite diagramComposite = new Composite(mainGroup, SWT.NONE); // diagramComposite.setLayout(new GridLayout()); // diagramComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, // true, 0, 0)); // FIXME MIGRATION reference to facilities // Access to UMLDI Model path // diagramPath = new ResourceFieldEditor(BundleConstants.UMLDI_MODEL_PATH, Messages.getString("UML2CPropertyPage.1"), diagramComposite); //$NON-NLS-1$ // diagramPath.setPreferenceStore(getPreferenceStore()); // diagramPath.setPage(this); // diagramPath.setEmptyStringAllowed(false); // diagramPath.setPropertyChangeListener(new IPropertyChangeListener() // { // /** // * @see // org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) // */ // public void propertyChange(PropertyChangeEvent event) // { // if (FieldEditor.VALUE.equals(event.getProperty())) // { // // deduce and set a default value into the next field. // URI uri = URI.createURI(diagramPath.getStringValue(), false); // try // { // Resource rsc = rscSet.getResource(uri, true); // EObject root = rsc.getContents().get(0); // // FIXME MIGRATION reference to modeler // // if (root instanceof Diagrams) // // { // // EObject model = ((Diagrams) root).getModel(); // // URI modelURI = EcoreUtil.getURI(model); // // // modelPath.setStringValue(URI.decode(modelURI.trimFragment().toString())); // // } // } // catch (Exception e) // { // modelPath.setStringValue(""); //$NON-NLS-1$ // } // } // } // }); // Composite for the model path final Composite modelComposite = new Composite(mainGroup, SWT.NONE); modelComposite.setLayout(new GridLayout()); modelComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0)); // Access to UML Model path // CHECKSTYLE:OFF modelPath = new StringButtonFieldEditor() { // CHECKSTYLE:ON { init(BundleConstants.UML_MODEL_PATH, Messages.getString("C2UMLPropertyPage.3")); //$NON-NLS-1$ createControl(modelComposite); } ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider()); @Override protected String changePressed() { IFile d = null; dialog.setInput(getElement()); if (dialog.open() == Window.OK) { Object[] result = dialog.getResult(); // sanity check if (result.length == 1) { if (result[0] instanceof IFile) { d = (IFile) result[0]; } } } if (d == null) { return null; } URI uri = URI.createPlatformResourceURI(d.getFullPath().toString(), false); return URI.decode(uri.toString()); } }; modelPath.setPreferenceName(BundleConstants.UML_MODEL_PATH); modelPath.setLabelText(Messages.getString("UML2CPropertyPage.3")); //$NON-NLS-1$ modelPath.setEnabled(true, modelComposite); // FIXME MIGRATION // modelPath = new ResourceFieldEditor(BundleConstants.UML_MODEL_PATH, // Messages.getString("UML2CPropertyPage.3"), modelComposite); //$NON-NLS-1$ // modelPath.setEnabled(false, modelComposite); // modelPath.getLabelControl(modelComposite).setEnabled(true); modelPath.setPreferenceStore(getPreferenceStore()); modelPath.setPage(this); modelPath.setEmptyStringAllowed(false); modelPath.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (FieldEditor.VALUE.equals(event.getProperty())) { resetPathFields(); extractPackagesFromModel(); } } }); }