Author: DartPeng
Date: 2009-04-17 06:33:53 -0400 (Fri, 17 Apr 2009)
New Revision: 14788
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/OpenEditorEditInnerContentsAction.java
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/freemarker/TemplateUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.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/xsl/TemplateUICreator.java
Log:
JBIDE-4192
Add a action on Section toolbar to open a editor to edit inner template contents
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/OpenEditorEditInnerContentsAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/OpenEditorEditInnerContentsAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/OpenEditorEditInnerContentsAction.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -0,0 +1,300 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.actions;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+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.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class OpenEditorEditInnerContentsAction extends Action {
+
+ private AnyType model;
+
+ private int textType = SmooksUIUtils.VALUE_TYPE_TEXT;
+
+ private String fileExtensionName = "txt";
+
+ private String editorID = null;
+
+ private IResource resource = null;
+
+ private IEditorPart tempEditor = null;
+
+ private TempFileChangeListener tempFileListener = null;
+
+ private IPartListener tempEditorlistener = null;
+
+ private EditingDomain editingDomain;
+
+ private IFile tempFile;
+
+ public OpenEditorEditInnerContentsAction(EditingDomain domain, AnyType model, int
textType, String fileExtensionName, String editorID) {
+ super();
+ this.model = model;
+ this.editingDomain = domain;
+ this.textType = textType;
+ this.fileExtensionName = fileExtensionName;
+ this.editorID = editorID;
+ tempFileListener = new TempFileChangeListener();
+
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
+ setDescription("Open an editor to edit inner contents");
+ setText("Open Editor");
+ }
+
+ public OpenEditorEditInnerContentsAction(EditingDomain domain, AnyType model, int
textType, String fileExtensionName) {
+ this(domain, model, textType, fileExtensionName, null);
+ }
+
+ private void setContent(AnyType model, String contents, int textType) {
+ String editValue = null;
+ if (textType == SmooksUIUtils.VALUE_TYPE_TEXT && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeText((AnyType) model);
+ if (!contents.equals(editValue)) {
+ SmooksModelUtils.setTextToAnyType((AnyType) model, contents);
+ }
+ }
+ if (textType == SmooksUIUtils.VALUE_TYPE_COMMENT && model instanceof AnyType)
{
+ editValue = SmooksModelUtils.getAnyTypeComment((AnyType) model);
+ if (!contents.equals(editValue)) {
+ SmooksModelUtils.setCommentToSmooksType(editingDomain, (AnyType) model, contents);
+ }
+ }
+ if (textType == SmooksUIUtils.VALUE_TYPE_CDATA && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
+ if (!contents.equals(editValue)) {
+ SmooksModelUtils.setCDATAToSmooksType(editingDomain, (AnyType) model, contents);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ IWorkbenchWindow window =
SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ try {
+ if (tempFile != null && tempFile.exists()) {
+ if (editorID != null) {
+ FileEditorInput editorInput1 = new FileEditorInput(tempFile);
+ tempEditor = window.getActivePage().openEditor(editorInput1, editorID);
+ } else {
+ tempEditor = IDE.openEditor(window.getActivePage(), tempFile);
+ }
+ return ;
+ }
+ if (tempEditorlistener != null) {
+ SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().removePartListener(
+ tempEditorlistener);
+ }
+ if (tempFileListener != null) {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(tempFileListener);
+ }
+ String editValue = null;
+ if (textType == SmooksUIUtils.VALUE_TYPE_TEXT && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeText((AnyType) model);
+ }
+ if (textType == SmooksUIUtils.VALUE_TYPE_COMMENT && model instanceof AnyType)
{
+ editValue = SmooksModelUtils.getAnyTypeComment((AnyType) model);
+ }
+ if (textType == SmooksUIUtils.VALUE_TYPE_CDATA && model instanceof AnyType) {
+ editValue = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
+ }
+ if (editValue != null) {
+ resource = SmooksUIUtils.getResource(model);
+ if (resource != null) {
+ IProject project = resource.getProject();
+ String name = generateFileName();
+ tempFile = project.getFile(name + "." + fileExtensionName);
+ int i = 0;
+ while (tempFile.exists()) {
+ name += String.valueOf(i);
+ tempFile = project.getFile(name + "." + fileExtensionName);
+ i++;
+ }
+ tempFile.create(new ByteArrayInputStream(editValue.getBytes()), true, new
NullProgressMonitor());
+ tempFile.setHidden(true);
+ FileEditorInput editorInput = new FileEditorInput(tempFile);
+ editorInput = new FileEditorInput(tempFile);
+ if (editorID != null) {
+ tempEditor = window.getActivePage().openEditor(editorInput, editorID);
+ } else {
+ tempEditor = IDE.openEditor(window.getActivePage(), tempFile);
+ }
+
+ tempEditorlistener = new IPartListener() {
+
+ public void partActivated(IWorkbenchPart part) {
+
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ if (tempEditor != null && part == tempEditor) {
+ SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .removePartListener(tempEditorlistener);
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(tempFileListener);
+ try {
+ tempFile.delete(true, new NullProgressMonitor());
+ tempFile.refreshLocal(0, null);
+ tempFile = null;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+
+ }
+ };
+ SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(
+ tempEditorlistener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(tempFileListener);
+ }
+ }
+ } catch (Exception e) {
+
+ }
+ }
+
+ private String generateFileName() {
+ int number = (int) System.currentTimeMillis();
+ return "tempFile_" + String.valueOf(number);
+ }
+
+ private class TempFileChangeListener implements IResourceChangeListener {
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResource res = event.getResource();
+ try {
+ switch (event.getType()) {
+ case IResourceChangeEvent.PRE_CLOSE:
+ System.out.print("Project ");
+ System.out.print(res.getFullPath());
+ System.out.println(" is about to close.");
+ break;
+ case IResourceChangeEvent.PRE_DELETE:
+ System.out.print("Project ");
+ System.out.print(res.getFullPath());
+ System.out.println(" is about to be deleted.");
+ break;
+ case IResourceChangeEvent.POST_CHANGE:
+ System.out.println("Resources have changed.");
+ event.getDelta().accept(new DeltaPrinter());
+ break;
+ case IResourceChangeEvent.PRE_BUILD:
+ System.out.println("Build about to run.");
+ event.getDelta().accept(new DeltaPrinter());
+ break;
+ case IResourceChangeEvent.POST_BUILD:
+ System.out.println("Build complete.");
+ event.getDelta().accept(new DeltaPrinter());
+ break;
+ }
+ } catch (Throwable t) {
+
+ }
+ }
+ }
+
+ class DeltaPrinter implements IResourceDeltaVisitor {
+
+ private String getContents() throws IOException {
+ File file = ((IFile) tempFile).getLocation().toFile();
+ FileReader fr = new FileReader(file);
+ BufferedReader reader = new BufferedReader(fr);
+ String line = reader.readLine();
+ String contents = "";
+ while (line != null) {
+ contents += line + "\n";
+ line = reader.readLine();
+ }
+ return contents;
+ }
+
+ public boolean visit(IResourceDelta delta) {
+ IResource res = delta.getResource();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ System.out.print("Resource ");
+ System.out.print(res.getFullPath());
+ System.out.println(" was added.");
+ break;
+ case IResourceDelta.REMOVED:
+ System.out.print("Resource ");
+ System.out.print(res.getFullPath());
+ System.out.println(" was removed.");
+ if (res == resource) {
+ return false;
+ }
+ break;
+ case IResourceDelta.CHANGED:
+ System.out.print("Resource ");
+ System.out.print(delta.getFullPath());
+ System.out.println(" has changed.");
+ if (res instanceof IFile) {
+ if (((IFile) res).getLocation().equals(tempFile.getLocation())) {
+ try {
+ setContent(model, getContents(), textType);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ int flags = delta.getFlags();
+ if ((flags & IResourceDelta.CONTENT) != 0) {
+
+ }
+ if ((flags & IResourceDelta.REPLACED) != 0) {
+ System.out.println("--> Content Replaced");
+ }
+ if ((flags & IResourceDelta.MARKERS) != 0) {
+ System.out.println("--> Marker Change");
+ // IMarkerDelta[] markers = delta.getMarkerDeltas();
+ // if interested in markers, check these deltas
+ }
+ break;
+
+ }
+ return true; // visit the children
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/OpenEditorEditInnerContentsAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -42,7 +42,7 @@
}
if (feature == EdiPackage.eINSTANCE.getEDIReader_MappingModel()) {
SmooksUIUtils.createFileSelectionTextFieldEditor(null, parent, null, toolkit,
propertyDescriptor, model, SmooksUIUtils.VALUE_TYPE_VALUE,
- SmooksMultiFormEditor.EDITOR_ID);
+ SmooksMultiFormEditor.EDITOR_ID,null);
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/freemarker/TemplateUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-04-17
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -11,10 +11,12 @@
package org.jboss.tools.smooks.configuration.editors.freemarker;
import org.eclipse.emf.ecore.EAttribute;
+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.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.actions.OpenEditorEditInnerContentsAction;
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;
@@ -47,10 +49,13 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
+ OpenEditorEditInnerContentsAction action1 = new
OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model,
SmooksUIUtils.VALUE_TYPE_CDATA, "flt");
+ OpenEditorEditInnerContentsAction action2 = new
OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model,
SmooksUIUtils.VALUE_TYPE_COMMENT, "flt");
+
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);
+ null, null);
+ SmooksUIUtils.createCDATAFieldEditor("Template Contents(CDATA)",
editingdomain, toolkit, parent, model, action1);
+ SmooksUIUtils.createCommentFieldEditor("Template Contents(Comment)",
editingdomain, toolkit, parent, model, action2);
}
@Override
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java 2009-04-17
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -11,19 +11,20 @@
package org.jboss.tools.smooks.configuration.editors.groovy;
import org.eclipse.emf.ecore.EAttribute;
+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.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.actions.OpenEditorEditInnerContentsAction;
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;
/**
- * @author Dart Peng (dpeng(a)redhat.com)
- * Date Apr 13, 2009
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 13, 2009
*/
-public class ScriptUICreator extends PropertyUICreator {
+public class ScriptUICreator extends PropertyUICreator {
/*
* (non-Javadoc)
*
@@ -33,16 +34,16 @@
* 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) {
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor);
}
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
- Composite parent, Object model, SmooksMultiFormEditor formEditor) {
- SmooksUIUtils.createCommentFieldEditor("Script Contents",editingdomain,
toolkit, parent, model);
+ public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit, Composite parent, Object model,
+ SmooksMultiFormEditor formEditor) {
+ OpenEditorEditInnerContentsAction action2 = new
OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model,
SmooksUIUtils.VALUE_TYPE_COMMENT, "groovy");
+ SmooksUIUtils.createCommentFieldEditor("Script Contents", editingdomain,
toolkit, parent, model, action2);
}
@Override
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
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -37,7 +37,7 @@
EAttribute feature, SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getImportType_File()) {
SmooksUIUtils.createFileSelectionTextFieldEditor(null, parent, null, toolkit,
propertyDescriptor, model, SmooksUIUtils.VALUE_TYPE_VALUE,
- SmooksMultiFormEditor.EDITOR_ID);
+ SmooksMultiFormEditor.EDITOR_ID,null);
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
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -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,false,null);
- SmooksUIUtils.createCDATAFieldEditor("CDATA Value", editingdomain, toolkit,
parent, model);
+ SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain,
toolkit, parent, model , false , 500,false,false,null,null);
+ SmooksUIUtils.createCDATAFieldEditor("CDATA Value", editingdomain, toolkit,
parent, model,null);
}
}
\ 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
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -40,16 +40,20 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.action.ToolBarManager;
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.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
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.graphics.Cursor;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -61,6 +65,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.IFormColors;
@@ -72,6 +77,7 @@
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.actions.OpenEditorEditInnerContentsAction;
import org.jboss.tools.smooks.configuration.editors.ClassPathFileProcessor;
import org.jboss.tools.smooks.configuration.editors.CurrentProjecViewerFilter;
import org.jboss.tools.smooks.configuration.editors.FileSelectionWizard;
@@ -113,17 +119,17 @@
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, false, listener);
+ createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, false, 0,
linkLabel, false, listener,null);
}
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, false, null);
+ Composite parent, Object model, int height,OpenEditorEditInnerContentsAction action)
{
+ createMixedTextFieldEditor(label, editingdomain, toolkit, parent, model, true, height,
false, false, null,action);
}
public static void createMixedTextFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
- 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);
+ Object model, boolean multiText, int height, boolean linkLabel, boolean openFile,
IHyperlinkListener listener,OpenEditorEditInnerContentsAction action) {
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, multiText,
linkLabel, openFile, height, listener, VALUE_TYPE_TEXT,action);
}
public static Control createFieldEditorLabel(Composite parent, FormToolkit formToolKit,
IItemPropertyDescriptor itemPropertyDescriptor,
@@ -265,25 +271,25 @@
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);
+ VALUE_TYPE_VALUE,null);
}
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);
+ final IItemPropertyDescriptor itemPropertyDescriptor, final Object model, int
valueType, String editorID,OpenEditorEditInnerContentsAction action) {
+ OpenFileHyperLinkListener listener = new OpenFileHyperLinkListener(valueType,
itemPropertyDescriptor, model, editorID);
return createStringFieldEditor(label, parent, editingdomain, toolkit,
itemPropertyDescriptor, model, false, true, true, 0, listener,
- valueType);
+ valueType,action);
}
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) {
+ IHyperlinkListener listener, int valueType,OpenEditorEditInnerContentsAction
openEditorAction) {
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){
+ if (label == null && itemPropertyDescriptor != null) {
label = itemPropertyDescriptor.getDisplayName(model);
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
if (feature.isRequired()) {
@@ -297,10 +303,29 @@
gd.heightHint = 10;
space.setLayoutData(gd);
- section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE);
+ section = toolkit.createSection(parent, Section.TITLE_BAR |Section.TWISTIE);
FillLayout layout = new FillLayout();
section.setLayout(layout);
section.setText(label);
+ if (openEditorAction != null) {
+ ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+
+ ToolBar toolbar = toolBarManager.createControl(section);
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolbar.setCursor(handCursor);
+ // Cursor needs to be explicitly disposed
+ toolbar.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if ((handCursor != null) && (handCursor.isDisposed() == false)) {
+ handCursor.dispose();
+ }
+ }
+ });
+ toolBarManager.add(openEditorAction);
+ toolBarManager.update(true);
+ section.setTextClient(toolbar);
+ section.layout();
+ }
Composite textComposite = toolkit.createComposite(section);
section.setClient(textComposite);
@@ -447,6 +472,7 @@
});
}
}
+ if(section != null ) section.layout();
return valueText;
}
@@ -491,13 +517,13 @@
}
public static void createCDATAFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
- Object model) {
- createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_CDATA);
+ Object model,OpenEditorEditInnerContentsAction action) {
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_CDATA,action);
}
public static void createCommentFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain, FormToolkit toolkit, Composite parent,
- Object model) {
- createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_COMMENT);
+ Object model,OpenEditorEditInnerContentsAction action) {
+ createStringFieldEditor(label, parent, editingdomain, toolkit, null, model, true, true,
false, 300, null, VALUE_TYPE_COMMENT,action);
}
public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit, final IItemPropertyDescriptor propertyDescriptor,
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
09:41:05 UTC (rev 14787)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-04-17
10:33:53 UTC (rev 14788)
@@ -11,10 +11,12 @@
package org.jboss.tools.smooks.configuration.editors.xsl;
import org.eclipse.emf.ecore.EAttribute;
+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.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.actions.OpenEditorEditInnerContentsAction;
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;
@@ -62,9 +64,12 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
- 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);
+ OpenEditorEditInnerContentsAction action1 = new
OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model,
SmooksUIUtils.VALUE_TYPE_CDATA, "xsl");
+ OpenEditorEditInnerContentsAction action2 = new
OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model,
SmooksUIUtils.VALUE_TYPE_COMMENT, "xsl");
+ SmooksUIUtils.createFileSelectionTextFieldEditor("Text Value", parent,
editingdomain, toolkit, null, model, SmooksUIUtils.VALUE_TYPE_TEXT,
+ null, null);
+ SmooksUIUtils.createCDATAFieldEditor("Template Contents (CDATA)",
editingdomain, toolkit, parent, model, action1);
+ SmooksUIUtils.createCommentFieldEditor("Template Contents (Comment)",
editingdomain, toolkit, parent, model, action2);
}
}
\ No newline at end of file