Author: DartPeng
Date: 2009-04-17 03:59:01 -0400 (Fri, 17 Apr 2009)
New Revision: 14785
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CurrentProjecViewerFilter.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/OpenFileHyperLinkListener.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
Log:
JBIDE-4192
Add a button to select workspace/filesystem file
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -0,0 +1,70 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class ClassPathFileProcessor implements IFilePathProcessor {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.IFilePathProcessor#
+ * processFileSystemPath(java.lang.String)
+ */
+ public String processFileSystemPath(String filePath) {
+ return filePath;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.IFilePathProcessor#
+ * processWorkBenchPath(org.eclipse.core.resources.IFile)
+ */
+ public String processWorkBenchPath(IFile file) {
+ IProject project = file.getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+ String path = null;
+ if (javaProject != null) {
+ try {
+ IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
+ for (int i = 0; i < classpathEntries.length; i++) {
+ IClasspathEntry entry = classpathEntries[i];
+// if(entry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
+ IPath sourcePath = entry.getPath();
+ if(sourcePath.isPrefixOf(file.getFullPath())){
+ IPath filePath = file.getFullPath();
+ String sp = sourcePath.toPortableString();
+ String fp = filePath.toPortableString();
+ path = fp.substring(0, sp.length());
+ break;
+ }
+// }
+ }
+ } catch (JavaModelException e) {
+// e.printStackTrace();
+ // ignore
+ }
+ }
+ if(path == null){
+ path = file.getFullPath().removeFirstSegments(1).toPortableString();
+ }
+ if(path.charAt(0) != '\\' || path.charAt(0) != '/' ){
+ path = "/" + path;
+ }
+ return path;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CurrentProjecViewerFilter.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CurrentProjecViewerFilter.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CurrentProjecViewerFilter.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class CurrentProjecViewerFilter extends ViewerFilter {
+
+ private IResource referenceResource;
+
+ public CurrentProjecViewerFilter(IResource referenceResource) {
+ this.referenceResource = referenceResource;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers
+ * .Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ IProject project = null;
+ if (referenceResource != null) {
+ project = referenceResource.getProject();
+ }
+ if (project == null) {
+ return true;
+ }
+ IResource resource = null;
+ if (element instanceof IResource) {
+ resource = (IResource)element;
+ } else {
+ if (element instanceof IAdaptable) {
+ resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
+ }
+ }
+ if (resource != null) {
+ if(project == resource.getProject()){
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CurrentProjecViewerFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizard.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizard.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -33,6 +33,8 @@
private Object[] initSelections = null;
private boolean multiSelect = false;
+
+ private IFilePathProcessor filePathProcessor = null;
@Override
public void addPages() {
@@ -40,6 +42,7 @@
fileSelectionWizardPage.setFilters(viewerFilters);
fileSelectionWizardPage.setInitSelections(getInitSelections());
fileSelectionWizardPage.setMultiSelect(isMultiSelect());
+ fileSelectionWizardPage.setFilePathProcessor(getFilePathProcessor());
this.addPage(fileSelectionWizardPage);
}
@@ -90,7 +93,12 @@
public void setViewerFilters(List<ViewerFilter> viewerFilters) {
this.viewerFilters = viewerFilters;
}
-
-
+ public void setFilePathProcessor(IFilePathProcessor filePathProcessor) {
+ this.filePathProcessor = filePathProcessor;
+ }
+
+ public IFilePathProcessor getFilePathProcessor() {
+ return filePathProcessor;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -11,49 +11,68 @@
package org.jboss.tools.smooks.configuration.editors;
import org.eclipse.core.resources.IFile;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage;
/**
- * @author Dart Peng (dpeng(a)redhat.com)
- * Date Apr 13, 2009
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 13, 2009
*/
public class FileSelectionWizardPage extends AbstractFileSelectionWizardPage {
-
+
+ private ProtableFileStringProcessor processor = null;
+
public FileSelectionWizardPage(String pageName) {
super(pageName);
- // TODO Auto-generated constructor stub
+ processor = new ProtableFileStringProcessor();
+ setFilePathProcessor(processor);
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
*/
@Override
protected Object loadedTheObject(String path) throws Exception {
// TODO Auto-generated method stub
return null;
}
-
-
+
@Override
- protected Composite createFileSelectionComposite(Composite parent) {
- Composite composite = super.createFileSelectionComposite(parent);
- GridData gd = new GridData();
- gd.widthHint = 0;
- fileSystemBrowseButton.setLayoutData(gd);
- this.fileSystemBrowseButton.setVisible(false);
- return composite;
+ protected String processFileSystemFilePath(String path) {
+ if(getFilePathProcessor() != null){
+ String s = getFilePathProcessor().processFileSystemPath(path);
+ if(s != null){
+ return s;
+ }
+ }
+ return this.processor.processFileSystemPath(path);
}
@Override
protected String processWorkSpaceFilePath(IFile file) {
- String s = file.getFullPath().toPortableString();
- return s;
+ if(getFilePathProcessor() != null){
+ String s = getFilePathProcessor().processWorkBenchPath(file);
+ if(s != null){
+ return s;
+ }
+ }
+ return this.processor.processWorkBenchPath(file);
}
-
-
+ private class ProtableFileStringProcessor implements IFilePathProcessor{
+
+ public String processWorkBenchPath(IFile file) {
+ String s = file.getFullPath().toPortableString();
+ return s;
+ }
+
+ public String processFileSystemPath(String filePath) {
+ return filePath;
+ }
+
+ }
+
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * @author DartPeng
+ *
+ */
+public interface IFilePathProcessor {
+ String processWorkBenchPath(IFile file);
+
+ String processFileSystemPath(String filePath);
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/OpenFileHyperLinkListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/OpenFileHyperLinkListener.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/OpenFileHyperLinkListener.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class OpenFileHyperLinkListener implements IHyperlinkListener {
+
+ private int type = SmooksUIUtils.VALUE_TYPE_VALUE;
+ private IItemPropertyDescriptor itemPropertyDescriptor;
+ private String editorID = null;
+ private Object model;
+
+ public OpenFileHyperLinkListener(int type, IItemPropertyDescriptor
itemPropertyDescriptor, Object model, String editorID) {
+ this.type = type;
+ this.itemPropertyDescriptor = itemPropertyDescriptor;
+ this.model = model;
+ this.editorID = editorID;
+ }
+
+ public void linkActivated(HyperlinkEvent e) {
+ String path = null;
+ if (type == SmooksUIUtils.VALUE_TYPE_VALUE) {
+ Object obj = SmooksUIUtils.getEditValue(itemPropertyDescriptor, model);
+ if (obj != null) {
+ path = obj.toString();
+ }
+ }
+ if (type == SmooksUIUtils.VALUE_TYPE_CDATA && model instanceof AnyType) {
+ path = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
+ }
+ if (type == SmooksUIUtils.VALUE_TYPE_TEXT && model instanceof AnyType) {
+ path = SmooksModelUtils.getAnyTypeText((AnyType) model);
+ }
+ if (type == SmooksUIUtils.VALUE_TYPE_COMMENT && model instanceof AnyType) {
+ path = SmooksModelUtils.getAnyTypeComment((AnyType) model);
+ }
+ try {
+ IResource resource = SmooksUIUtils.getResource((EObject) model);
+ SmooksUIUtils.openFile(path, resource.getProject(), editorID);
+ } catch (Exception e1) {
+
+ }
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void linkExited(HyperlinkEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/OpenFileHyperLinkListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -195,7 +195,7 @@
if (model instanceof EObject) {
SmooksResourceListType smooksResourceList = getSmooksResourceList((EObject) model);
if (smooksResourceList != null) {
- SmooksUIUtils.createFiledEditorLabel(parent, toolkit, propertyDescriptor, model,
false);
+ SmooksUIUtils.createFieldEditorLabel(parent, toolkit, propertyDescriptor, model,
false);
final Combo combo = new Combo(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
combo.setLayoutData(gd);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -23,7 +23,6 @@
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
@@ -57,7 +56,6 @@
private IFormPart formPart;
private Section section;
private SmooksMultiFormEditor formEditor;
- private AdapterFactoryLabelProvider labelProvider = null;
private AdapterFactoryEditingDomain editingDomain = null;
private IItemPropertySource itemPropertySource = null;
@@ -71,7 +69,6 @@
super();
this.formEditor = formEditor;
editingDomain = (AdapterFactoryEditingDomain) formEditor.getEditingDomain();
- labelProvider = new AdapterFactoryLabelProvider(editingDomain.getAdapterFactory());
}
public void createContents(Composite parent) {
@@ -235,39 +232,12 @@
protected Text createStringFieldEditor(final Composite propertyComposite, EAttribute
feature, FormToolkit formToolKit,
final IItemPropertyDescriptor itemPropertyDescriptor) {
- SmooksUIUtils.createFiledEditorLabel(propertyComposite, formToolKit,
itemPropertyDescriptor, getModel(), false);
- final Text text = formToolKit.createText(propertyComposite, "", SWT.NONE);
- Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null)
- text.setText(editValue.toString());
- }
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null) {
- if (!editValue.equals(text.getText())) {
- itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
- }
- } else {
- itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
- }
- } else {
- itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
- }
- }
- });
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- text.setLayoutData(gd);
- return text;
+ return SmooksUIUtils.createStringFieldEditor(propertyComposite, formToolKit,
itemPropertyDescriptor, getModel(), false, false, null);
}
protected void createIntegerFieldEditor(final Composite propertyComposite, EAttribute
feature, FormToolkit formToolKit,
final IItemPropertyDescriptor itemPropertyDescriptor) {
- SmooksUIUtils.createFiledEditorLabel(propertyComposite, formToolKit,
itemPropertyDescriptor, getModel(), false);
+ SmooksUIUtils.createFieldEditorLabel(propertyComposite, formToolKit,
itemPropertyDescriptor, getModel(), false);
final Spinner spinner = new Spinner(propertyComposite, SWT.BORDER);
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
if (value != null && value instanceof PropertyValueWrapper) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -10,14 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.edireader;
-import org.eclipse.core.resources.IResource;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
@@ -32,20 +27,6 @@
public EDIReaderUICreator() {
}
- private void openFile(IItemPropertyDescriptor propertyDescriptor, Object model) {
- Object path = SmooksUIUtils.getEditValue(propertyDescriptor, model);
- String p = null;
- if (path != null && path instanceof String) {
- p = ((String) path).trim();
- }
- try {
- IResource resource = SmooksUIUtils.getResource((EObject) model);
- SmooksUIUtils.openFile(p, resource.getProject(), SmooksMultiFormEditor.EDITOR_ID);
- } catch (Exception e) {
-
- }
- }
-
/*
* (non-Javadoc)
*
@@ -60,25 +41,8 @@
if (feature == EdiPackage.eINSTANCE.getEDIReader_Encoding()) {
}
if (feature == EdiPackage.eINSTANCE.getEDIReader_MappingModel()) {
- final Object fm = model;
- final IItemPropertyDescriptor fpd = propertyDescriptor;
- IHyperlinkListener listener = new IHyperlinkListener() {
-
- public void linkActivated(HyperlinkEvent e) {
- openFile(fpd, fm);
- }
-
- public void linkEntered(HyperlinkEvent e) {
-
- }
-
- public void linkExited(HyperlinkEvent e) {
-
- }
-
- };
- SmooksUIUtils.createLinkTextValueFieldEditor("Mapping Model",
(AdapterFactoryEditingDomain) formEditor.getEditingDomain(), propertyDescriptor,
- toolkit, parent, model, false, 0, true, listener);
+ SmooksUIUtils.createFileSelectionTextFieldEditor(null, parent, null, toolkit,
propertyDescriptor, model, SmooksUIUtils.VALUE_TYPE_VALUE,
+ SmooksMultiFormEditor.EDITOR_ID);
return parent;
}
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor);
@@ -86,9 +50,9 @@
@Override
public boolean isFileSelectionFeature(EAttribute attribute) {
-// if (attribute == EdiPackage.eINSTANCE.getEDIReader_MappingModel()) {
-// return true;
-// }
+ // if (attribute == EdiPackage.eINSTANCE.getEDIReader_MappingModel()) {
+ // return true;
+ // }
return super.isFileSelectionFeature(attribute);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -10,21 +10,15 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.freemarker;
-import org.eclipse.core.resources.IResource;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.freemarker.FreemarkerPackage;
-import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 10, 2009
@@ -53,33 +47,8 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
- final Object path = SmooksModelUtils.getAnyTypeText((AnyType)model);
- final Object fm = model;
- IHyperlinkListener listener = new IHyperlinkListener() {
-
- public void linkActivated(HyperlinkEvent e) {
- String p = null;
- if (path != null && path instanceof String) {
- p = ((String) path).trim();
- }
- try {
- IResource resource = SmooksUIUtils.getResource((EObject) fm);
- SmooksUIUtils.openFile(p, resource.getProject(),null);
- } catch (Exception e1) {
-
- }
- }
-
- public void linkEntered(HyperlinkEvent e) {
-
- }
-
- public void linkExited(HyperlinkEvent e) {
-
- }
-
- };
- SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain,
toolkit, parent, model,true,listener);
+ SmooksUIUtils.createFileSelectionTextFieldEditor("Text Value", parent,
editingdomain, toolkit, null, model, SmooksUIUtils.VALUE_TYPE_TEXT,
+ null);
SmooksUIUtils.createCDATAFieldEditor("Template Contents(CDATA)",
editingdomain, toolkit, parent, model);
SmooksUIUtils.createCommentFieldEditor("Template Contents(Comment)",
editingdomain, toolkit, parent, model);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -10,14 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.smooks;
-import org.eclipse.core.resources.IResource;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
@@ -38,37 +33,11 @@
* org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
* org.eclipse.emf.ecore.EAttribute)
*/
- public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
IItemPropertyDescriptor propertyDescriptor, Object model,
+ EAttribute feature, SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getImportType_File()) {
- final Object fm = model;
- final Object path = SmooksUIUtils.getEditValue(propertyDescriptor, model);
- IHyperlinkListener listener = new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- String p = null;
- if (path != null && path instanceof String) {
- p = ((String) path).trim();
- }
- try {
- IResource resource = SmooksUIUtils.getResource((EObject) fm);
- SmooksUIUtils.openFile(p, resource.getProject(),null);
- } catch (Exception e1) {
-
- }
- }
-
- public void linkEntered(HyperlinkEvent e) {
-
- }
-
- public void linkExited(HyperlinkEvent e) {
-
- }
-
- };
- SmooksUIUtils.createLinkTextValueFieldEditor(null, (AdapterFactoryEditingDomain)
formEditor.getEditingDomain(), propertyDescriptor,
- toolkit, parent, model, false, 0, true, listener);
-
+ SmooksUIUtils.createFileSelectionTextFieldEditor(null, parent, null, toolkit,
propertyDescriptor, model, SmooksUIUtils.VALUE_TYPE_VALUE,
+ SmooksMultiFormEditor.EDITOR_ID);
return parent;
}
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -46,7 +46,7 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
Composite parent, Object model, SmooksMultiFormEditor formEditor) {
- SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain,
toolkit, parent, model , false , 500,false,null);
+ SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain,
toolkit, parent, model , false , 500,false,false,null);
SmooksUIUtils.createCDATAFieldEditor("CDATA Value", editingdomain, toolkit,
parent, model);
}
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -31,6 +31,7 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -42,12 +43,17 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -66,7 +72,11 @@
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.ClassPathFileProcessor;
+import org.jboss.tools.smooks.configuration.editors.CurrentProjecViewerFilter;
+import org.jboss.tools.smooks.configuration.editors.FileSelectionWizard;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.configuration.editors.OpenFileHyperLinkListener;
import org.jboss.tools.smooks.configuration.editors.SelectorAttributes;
import org.jboss.tools.smooks.configuration.editors.SelectoreSelectionDialog;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaMethodsSelectionDialog;
@@ -93,87 +103,30 @@
public static final String XSL_NAMESPACE = "
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" ";
+ public static int VALUE_TYPE_VALUE = 1;
+
+ public static int VALUE_TYPE_TEXT = 2;
+
+ public static int VALUE_TYPE_COMMENT = 3;
+
+ public static int VALUE_TYPE_CDATA = 0;
+
public static void createMixedTextFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
- Object model,boolean linkLabel, IHyperlinkListener listener) {
- createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, false,
0,linkLabel,listener);
+ Object model, boolean linkLabel, IHyperlinkListener listener) {
+ createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, false, 0,
linkLabel, false, listener);
}
public static void createMultiMixedTextFieldEditor(String label,
AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
Composite parent, Object model, int height) {
- createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, true,
height,false,null);
+ createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, true, height,
false, false, null);
}
public static void createMixedTextFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
- Object model, boolean multiText, int height, boolean linkLabel, IHyperlinkListener
listener) {
- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- Section section = null;
- Composite textContainer = null;
- if (multiText) {
- Composite space = toolkit.createComposite(parent);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.heightHint = 10;
- space.setLayoutData(gd);
-
- section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE);
- FillLayout layout = new FillLayout();
- section.setLayout(layout);
- section.setText(label);
-
- Composite textComposite = toolkit.createComposite(section);
- section.setClient(textComposite);
- textComposite.setLayout(new GridLayout());
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- section.setLayoutData(gd);
- textContainer = textComposite;
- } else {
- if (linkLabel) {
- Hyperlink link = toolkit.createHyperlink(parent, label + " :", SWT.NONE);
- if (listener != null) {
- link.addHyperlinkListener(listener);
- }
- } else {
- toolkit.createLabel(parent, label + "
:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- }
- textContainer = parent;
- }
- gd = new GridData(GridData.FILL_HORIZONTAL);
- int textType = SWT.FLAT;
- if (multiText) {
- textType = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
- }
- final Text valueText = toolkit.createText(textContainer, "", textType);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- if (multiText && height > 0) {
- gd.heightHint = height;
- }
- valueText.setLayoutData(gd);
- if (model instanceof AnyType) {
- String text = SmooksModelUtils.getAnyTypeText((AnyType) model);
- if (text != null) {
- valueText.setText(text);
- if (text.length() > 0 && section != null) {
- section.setExpanded(true);
- }
- }
- }
- final Object fm = model;
- final AdapterFactoryEditingDomain fEditingDomain = editingdomain;
- valueText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (!(fm instanceof AnyType)) {
- return;
- }
- String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
- if (!valueText.getText().equals(text)) {
- SmooksModelUtils.setTextToSmooksType(fEditingDomain, (AnyType) fm,
valueText.getText());
- }
- }
- });
+ Object model, boolean multiText, int height, boolean linkLabel, boolean openFile,
IHyperlinkListener listener) {
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, multiText,
linkLabel, openFile, height, listener, VALUE_TYPE_TEXT);
}
- public static Control createFiledEditorLabel(Composite parent, FormToolkit formToolKit,
IItemPropertyDescriptor itemPropertyDescriptor,
+ public static Control createFieldEditorLabel(Composite parent, FormToolkit formToolKit,
IItemPropertyDescriptor itemPropertyDescriptor,
Object model, boolean isLink) {
String displayName = itemPropertyDescriptor.getDisplayName(model);
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
@@ -249,13 +202,13 @@
public static void createLinkTextValueFieldEditor(String label,
AdapterFactoryEditingDomain editingdomain,
IItemPropertyDescriptor propertyDescriptor, FormToolkit toolkit, Composite parent,
Object model, boolean multiText, int height,
boolean linkLabel, IHyperlinkListener listener) {
- Control control = createFiledEditorLabel(parent, toolkit, propertyDescriptor, model,
linkLabel);
+ Control control = createFieldEditorLabel(parent, toolkit, propertyDescriptor, model,
linkLabel);
if (linkLabel) {
- Hyperlink link = (Hyperlink)control;
+ Hyperlink link = (Hyperlink) control;
if (listener != null) {
link.addHyperlinkListener(listener);
}
- }
+ }
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
int textType = SWT.FLAT;
if (multiText) {
@@ -309,6 +262,194 @@
return path;
}
+ public static Text createStringFieldEditor(final Composite parent, FormToolkit toolkit,
final IItemPropertyDescriptor itemPropertyDescriptor,
+ Object model, boolean linkLabel, boolean openFile, IHyperlinkListener listener) {
+ return createStringFieldEditor(null, parent, null, toolkit, itemPropertyDescriptor,
model, false, linkLabel, openFile, 0, listener,
+ VALUE_TYPE_VALUE);
+ }
+
+ public static Text createFileSelectionTextFieldEditor(String label, final Composite
parent, EditingDomain editingdomain, FormToolkit toolkit,
+ final IItemPropertyDescriptor itemPropertyDescriptor, final Object model, int
valueType , String editorID) {
+ OpenFileHyperLinkListener listener = new
OpenFileHyperLinkListener(valueType,itemPropertyDescriptor,model,editorID);
+ return createStringFieldEditor(label, parent, editingdomain, toolkit,
itemPropertyDescriptor, model, false, true, true, 0, listener,
+ valueType);
+ }
+
+ public static Text createStringFieldEditor(String label, final Composite parent,
EditingDomain editingdomain, FormToolkit toolkit,
+ final IItemPropertyDescriptor itemPropertyDescriptor, Object model, boolean multiText,
boolean linkLabel, boolean openFile, int height,
+ IHyperlinkListener listener, int valueType) {
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ Section section = null;
+ Composite textContainer = null;
+ final Object fm = model;
+ final EditingDomain fEditingDomain = editingdomain;
+ if(label == null && itemPropertyDescriptor != null){
+ label = itemPropertyDescriptor.getDisplayName(model);
+ EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
+ if (feature.isRequired()) {
+ label = "*" + label;
+ }
+ }
+ if (multiText) {
+ Composite space = toolkit.createComposite(parent);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 10;
+ space.setLayoutData(gd);
+
+ section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE);
+ FillLayout layout = new FillLayout();
+ section.setLayout(layout);
+ section.setText(label);
+
+ Composite textComposite = toolkit.createComposite(section);
+ section.setClient(textComposite);
+ textComposite.setLayout(new GridLayout());
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ section.setLayoutData(gd);
+ textContainer = textComposite;
+ } else {
+ if (linkLabel) {
+ Hyperlink link = toolkit.createHyperlink(parent, label + " :", SWT.NONE);
+ if (listener != null) {
+ link.addHyperlinkListener(listener);
+ }
+ } else {
+ toolkit.createLabel(parent, label + "
:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ }
+ if (openFile) {
+ Composite fileSelectionComposite = toolkit.createComposite(parent);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileSelectionComposite.setLayoutData(gd);
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ fileSelectionComposite.setLayout(gl);
+ textContainer = fileSelectionComposite;
+ } else {
+ textContainer = parent;
+ }
+ }
+ String editValue = null;
+ if (valueType == VALUE_TYPE_TEXT && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeText((AnyType) model);
+ }
+ if (valueType == VALUE_TYPE_COMMENT && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeComment((AnyType) model);
+ }
+ if (valueType == VALUE_TYPE_CDATA && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
+ }
+ if (valueType == VALUE_TYPE_VALUE) {
+ Object value = getEditValue(itemPropertyDescriptor, model);
+ if (value != null) {
+ editValue = value.toString();
+ }
+ }
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ int textType = SWT.FLAT;
+ if (multiText) {
+ textType = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
+ }
+ final Text valueText = toolkit.createText(textContainer, "", textType);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ if (multiText && height > 0) {
+ gd.heightHint = height;
+ }
+ valueText.setLayoutData(gd);
+ toolkit.paintBordersFor(textContainer);
+ if (openFile) {
+ Button fileBrowseButton = toolkit.createButton(textContainer, "Browse",
SWT.NONE);
+ fileBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ FileSelectionWizard wizard = new FileSelectionWizard();
+ IResource resource = getResource((EObject) fm);
+ Object[] initSelections = new Object[] {};
+ if (resource != null) {
+ initSelections = new Object[] { resource };
+ }
+ wizard.setFilePathProcessor(new ClassPathFileProcessor());
+ wizard.setInitSelections(initSelections);
+ List<ViewerFilter> filterList = new ArrayList<ViewerFilter>();
+ filterList.add(new CurrentProjecViewerFilter(resource));
+ wizard.setViewerFilters(filterList);
+ WizardDialog dialog = new WizardDialog(parent.getShell(), wizard);
+ if (dialog.open() == Dialog.OK) {
+ valueText.setText(wizard.getFilePath());
+ }
+ }
+
+ });
+ }
+ if (editValue != null) {
+ valueText.setText(editValue);
+ if (editValue.length() > 0 && section != null) {
+ section.setExpanded(true);
+ }
+ }
+ if (valueType == VALUE_TYPE_TEXT && model instanceof AnyType &&
fEditingDomain != null) {
+ valueText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (!(fm instanceof AnyType)) {
+ return;
+ }
+ String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
+ if (!valueText.getText().equals(text)) {
+ SmooksModelUtils.setTextToSmooksType(fEditingDomain, (AnyType) fm,
valueText.getText());
+ }
+ }
+ });
+ }
+ if (valueType == VALUE_TYPE_COMMENT && model instanceof AnyType &&
fEditingDomain != null) {
+ valueText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (!(fm instanceof AnyType)) {
+ return;
+ }
+ String text = SmooksModelUtils.getAnyTypeComment((AnyType) fm);
+ if (!valueText.getText().equals(text)) {
+ SmooksModelUtils.setCommentToSmooksType(fEditingDomain, (AnyType) fm,
valueText.getText());
+ }
+ }
+ });
+ }
+ if (valueType == VALUE_TYPE_CDATA && model instanceof AnyType &&
fEditingDomain != null) {
+ valueText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (!(fm instanceof AnyType)) {
+ return;
+ }
+ String text = SmooksModelUtils.getAnyTypeCDATA((AnyType) fm);
+ if (!valueText.getText().equals(text)) {
+ SmooksModelUtils.setCDATAToSmooksType(fEditingDomain, (AnyType) fm,
valueText.getText());
+ }
+ }
+ });
+ }
+ if (valueType == VALUE_TYPE_VALUE) {
+ if (itemPropertyDescriptor != null) {
+ valueText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ Object editValue = getEditValue(itemPropertyDescriptor, fm);
+ if (editValue != null) {
+ if (!editValue.equals(valueText.getText())) {
+ itemPropertyDescriptor.setPropertyValue(fm, valueText.getText());
+ }
+ } else {
+ itemPropertyDescriptor.setPropertyValue(fm, valueText.getText());
+ }
+
+ }
+ });
+ }
+ }
+ return valueText;
+ }
+
public static Composite createSelectorFieldEditor(FormToolkit toolkit, Composite parent,
final IItemPropertyDescriptor propertyDescriptor,
Object model, final SmooksGraphicsExtType extType) {
return createDialogFieldEditor(parent, toolkit, propertyDescriptor, "Browse",
new IFieldDialog() {
@@ -351,101 +492,12 @@
public static void createCDATAFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
Object model) {
- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- Composite space = toolkit.createComposite(parent);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.heightHint = 10;
- space.setLayoutData(gd);
-
- Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.DESCRIPTION);
- FillLayout layout = new FillLayout();
- section.setLayout(layout);
- section.setText(label);
-
- Composite textComposite = toolkit.createComposite(section);
- section.setClient(textComposite);
- textComposite.setLayout(new GridLayout());
- final Text cdataText = toolkit.createText(textComposite, "", SWT.MULTI |
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- section.setLayoutData(gd);
- toolkit.paintBordersFor(textComposite);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = 300;
- cdataText.setLayoutData(gd);
-
- if (model instanceof AnyType) {
- String cdata = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
- if (cdata != null) {
- cdataText.setText(cdata);
- if (cdata.length() > 0) {
- section.setExpanded(true);
- }
- }
- }
-
- final Object fm = model;
- final AdapterFactoryEditingDomain fEditingDomain = editingdomain;
- cdataText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (!(fm instanceof AnyType)) {
- return;
- }
- String text = SmooksModelUtils.getAnyTypeCDATA((AnyType) fm);
- if (!cdataText.getText().equals(text)) {
- SmooksModelUtils.setCDATAToSmooksType(fEditingDomain, (AnyType) fm,
cdataText.getText());
- }
- }
- });
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_CDATA);
}
public static void createCommentFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
Object model) {
- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- Composite space = toolkit.createComposite(parent);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.heightHint = 10;
- space.setLayoutData(gd);
-
- Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.DESCRIPTION);
- FillLayout layout = new FillLayout();
- section.setLayout(layout);
- section.setText(label);
-
- Composite textComposite = toolkit.createComposite(section);
- section.setClient(textComposite);
- textComposite.setLayout(new GridLayout());
- final Text cdataText = toolkit.createText(textComposite, "", SWT.MULTI |
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- section.setLayoutData(gd);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = 300;
- cdataText.setLayoutData(gd);
-
- if (model instanceof AnyType) {
- String comment = SmooksModelUtils.getAnyTypeComment((AnyType) model);
- if (comment != null) {
- cdataText.setText(comment);
- if (comment.length() > 0)
- section.setExpanded(true);
- }
- }
- final Object fm = model;
- final AdapterFactoryEditingDomain fEditingDomain = editingdomain;
- cdataText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (!(fm instanceof AnyType)) {
- return;
- }
- String text = SmooksModelUtils.getAnyTypeCDATA((AnyType) fm);
- if (!cdataText.getText().equals(text)) {
- SmooksModelUtils.setCommentToSmooksType(fEditingDomain, (AnyType) fm,
cdataText.getText());
- }
- }
- });
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_COMMENT);
}
public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit, final IItemPropertyDescriptor propertyDescriptor,
@@ -458,7 +510,7 @@
String path = uri.toPlatformString(true);
workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(path));
JavaTypeFieldDialog dialog = new JavaTypeFieldDialog(workspaceResource);
- Hyperlink link = (Hyperlink) createFiledEditorLabel(parent, toolkit,
propertyDescriptor, model, true);
+ Hyperlink link = (Hyperlink) createFieldEditorLabel(parent, toolkit,
propertyDescriptor, model, true);
final Composite classTextComposite = toolkit.createComposite(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
classTextComposite.setLayoutData(gd);
@@ -666,7 +718,7 @@
public static Control createChoiceFieldEditor(Composite parent, FormToolkit formToolkit,
IItemPropertyDescriptor itemPropertyDescriptor,
Object model, String[] items, IModelProcsser processer, boolean readOnly) {
- SmooksUIUtils.createFiledEditorLabel(parent, formToolkit, itemPropertyDescriptor,
model, false);
+ SmooksUIUtils.createFieldEditorLabel(parent, formToolkit, itemPropertyDescriptor,
model, false);
Object editValue = getEditValue(itemPropertyDescriptor, model);
if (processer != null) {
editValue = processer.unwrapValue(editValue);
@@ -740,7 +792,7 @@
public static Composite createDialogFieldEditor(Composite parent, FormToolkit toolkit,
final IItemPropertyDescriptor propertyDescriptor,
String buttonName, IFieldDialog dialog, final EObject model, boolean labelLink,
IHyperlinkListener listener) {
- Control label = createFiledEditorLabel(parent, toolkit, propertyDescriptor, model,
labelLink);
+ Control label = createFieldEditorLabel(parent, toolkit, propertyDescriptor, model,
labelLink);
if (label instanceof Hyperlink && listener != null) {
((Hyperlink) label).addHyperlinkListener(listener);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -26,6 +26,7 @@
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.configuration.editors.IFilePathProcessor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
/**
@@ -47,6 +48,8 @@
protected List<ViewerFilter> filters = null;
protected boolean multiSelect =false;
+ private IFilePathProcessor filePathProcessor = null;
+
public AbstractFileSelectionWizardPage(String pageName,boolean multiSelect , Object[]
initSelections,List<ViewerFilter> filters) {
super(pageName);
this.initSelections = initSelections;
@@ -74,6 +77,16 @@
public String getFilePath(){
return filePath;
}
+
+
+ public IFilePathProcessor getFilePathProcessor() {
+ return filePathProcessor;
+ }
+
+ public void setFilePathProcessor(IFilePathProcessor filePathProcessor) {
+ this.filePathProcessor = filePathProcessor;
+ }
+
/*
* (non-Javadoc)
*
@@ -174,11 +187,23 @@
}
protected String processFileSystemFilePath(String path){
+ if(filePathProcessor != null){
+ String s = filePathProcessor.processFileSystemPath(path);
+ if(s != null){
+ return s;
+ }
+ }
path = SmooksUIUtils.FILE_PRIX + path;
return path;
}
protected String processWorkSpaceFilePath(IFile file){
+ if(filePathProcessor != null){
+ String s = filePathProcessor.processWorkBenchPath(file);
+ if(s != null){
+ return s;
+ }
+ }
String s = file.getFullPath().toPortableString();
s = SmooksUIUtils.WORKSPACE_PRIX + s;
return s;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-04-17
06:42:42 UTC (rev 14784)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-04-17
07:59:01 UTC (rev 14785)
@@ -10,21 +10,15 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.xsl;
-import org.eclipse.core.resources.IResource;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.xsl.XslPackage;
-import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 10, 2009
@@ -68,33 +62,7 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
- final Object path = SmooksModelUtils.getAnyTypeText((AnyType) model);
- final Object fm = model;
- IHyperlinkListener listener = new IHyperlinkListener() {
-
- public void linkActivated(HyperlinkEvent e) {
- String p = null;
- if (path != null && path instanceof String) {
- p = ((String) path).trim();
- }
- try {
- IResource resource = SmooksUIUtils.getResource((EObject) fm);
- SmooksUIUtils.openFile(p, resource.getProject(), null);
- } catch (Exception e1) {
-
- }
- }
-
- public void linkEntered(HyperlinkEvent e) {
-
- }
-
- public void linkExited(HyperlinkEvent e) {
-
- }
-
- };
- SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain,
toolkit, parent, model, true, listener);
+ SmooksUIUtils.createFileSelectionTextFieldEditor("Text Value", parent,
editingdomain, toolkit, null, model, SmooksUIUtils.VALUE_TYPE_TEXT, null);
SmooksUIUtils.createCDATAFieldEditor("Template Contents (CDATA)",
editingdomain, toolkit, parent, model);
SmooksUIUtils.createCommentFieldEditor("Template Contents (Comment)",
editingdomain, toolkit, parent, model);
}