Author: DartPeng
Date: 2009-02-24 11:27:17 -0500 (Tue, 24 Feb 2009)
New Revision: 13775
Added:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/MultiPageEditorContributor.java
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/SmooksTestMultiPageEditor.java
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
Removed:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestResultView.java
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.testui/.classpath
workspace/dart/plugins/org.jboss.tools.smooks.testui/.settings/org.eclipse.jdt.core.prefs
workspace/dart/plugins/org.jboss.tools.smooks.testui/META-INF/MANIFEST.MF
workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/AbstractNode.java
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestProjectsView.java
Log:
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/.classpath
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/.classpath 2009-02-24 16:15:44
UTC (rev 13774)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/.classpath 2009-02-24 16:27:17
UTC (rev 13775)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="libs/antlr-2.7.2.jar"/>
@@ -37,5 +36,6 @@
<classpathentry kind="lib"
path="libs/xmlbeans-jsr173-api-2.0-dev.jar"/>
<classpathentry kind="lib"
path="libs/xpp3_min-1.1.3.4.O.jar"/>
<classpathentry kind="lib" path="libs/xstream-1.2.2.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.testui/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/.settings/org.eclipse.jdt.core.prefs 2009-02-24
16:15:44 UTC (rev 13774)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/.settings/org.eclipse.jdt.core.prefs 2009-02-24
16:27:17 UTC (rev 13775)
@@ -1,7 +1,12 @@
-#Fri Feb 20 17:23:05 CST 2009
+#Wed Feb 25 07:20:13 HKT 2009
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.5
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/META-INF/MANIFEST.MF
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/META-INF/MANIFEST.MF 2009-02-24
16:15:44 UTC (rev 13774)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/META-INF/MANIFEST.MF 2009-02-24
16:27:17 UTC (rev 13775)
@@ -8,10 +8,13 @@
org.eclipse.core.runtime,
org.jboss.tools.smooks.core,
org.jboss.tools.smooks.ui,
- org.eclipse.core.resources;bundle-version="3.4.1",
- org.eclipse.jdt.core;bundle-version="3.4.2"
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: libs/antlr-2.7.2.jar,
libs/commons-lang-2.1.jar,
libs/commons-logging-1.1.jar,
@@ -47,3 +50,5 @@
libs/xpp3_min-1.1.3.4.O.jar,
libs/xstream-1.2.2.jar,
.
+Export-Package: org.smooks.tools.testui,
+ org.smooks.tools.testui.views
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml 2009-02-24 16:15:44
UTC (rev 13774)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml 2009-02-24 16:27:17
UTC (rev 13775)
@@ -5,15 +5,15 @@
<extension
point="org.eclipse.ui.views">
<category
- name="Sample Category"
+ name="Smooks"
id="org.smooks.tools.testui">
</category>
<view
- name="Sample View"
+ name="Smooks Test View"
icon="icons/sample.gif"
category="org.smooks.tools.testui"
class="org.smooks.tools.testui.views.TestProjectsView"
- id="org.smooks.tools.testui.views.SampleView">
+ id="org.smooks.tools.testui.views.TestProjectView1">
</view>
</extension>
<extension
@@ -34,5 +34,15 @@
file="contexts.xml">
</contexts>
</extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.smooks.tools.testui.editors.SmooksTestMultiPageEditor"
+
contributorClass="org.smooks.tools.testui.editors.MultiPageEditorContributor"
+ icon="icons/sample.gif"
+ id="org.smooks.tools.testui.editors.MultiPageEditor"
+ name="Smooks Test Editor">
+ </editor>
+ </extension>
</plugin>
Added:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/MultiPageEditorContributor.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/MultiPageEditorContributor.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/MultiPageEditorContributor.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -0,0 +1,103 @@
+package org.smooks.tools.testui.editors;
+
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+/**
+ * Manages the installation/deinstallation of global actions for multi-page editors.
+ * Responsible for the redirection of global actions to the active editor.
+ * Multi-page contributor replaces the contributors for the individual editors in the
multi-page editor.
+ */
+public class MultiPageEditorContributor extends MultiPageEditorActionBarContributor {
+ private IEditorPart activeEditorPart;
+ private Action sampleAction;
+ /**
+ * Creates a multi-page contributor.
+ */
+ public MultiPageEditorContributor() {
+ super();
+ createActions();
+ }
+ /**
+ * Returns the action registed with the given text editor.
+ * @return IAction or null if editor is null.
+ */
+ protected IAction getAction(ITextEditor editor, String actionID) {
+ return (editor == null ? null : editor.getAction(actionID));
+ }
+ /* (non-JavaDoc)
+ * Method declared in AbstractMultiPageEditorActionBarContributor.
+ */
+
+ public void setActivePage(IEditorPart part) {
+ if (activeEditorPart == part)
+ return;
+
+ activeEditorPart = part;
+
+ IActionBars actionBars = getActionBars();
+ if (actionBars != null) {
+
+ ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
+
+ actionBars.setGlobalActionHandler(
+ ActionFactory.DELETE.getId(),
+ getAction(editor, ITextEditorActionConstants.DELETE));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.UNDO.getId(),
+ getAction(editor, ITextEditorActionConstants.UNDO));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.REDO.getId(),
+ getAction(editor, ITextEditorActionConstants.REDO));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.CUT.getId(),
+ getAction(editor, ITextEditorActionConstants.CUT));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.COPY.getId(),
+ getAction(editor, ITextEditorActionConstants.COPY));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.PASTE.getId(),
+ getAction(editor, ITextEditorActionConstants.PASTE));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.SELECT_ALL.getId(),
+ getAction(editor, ITextEditorActionConstants.SELECT_ALL));
+ actionBars.setGlobalActionHandler(
+ ActionFactory.FIND.getId(),
+ getAction(editor, ITextEditorActionConstants.FIND));
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.BOOKMARK.getId(),
+ getAction(editor, IDEActionFactory.BOOKMARK.getId()));
+ actionBars.updateActionBars();
+ }
+ }
+ private void createActions() {
+ sampleAction = new Action() {
+ public void run() {
+ MessageDialog.openInformation(null, "SmooksTestUIPlug-in", "Sample
Action Executed");
+ }
+ };
+ sampleAction.setText("Sample Action");
+ sampleAction.setToolTipText("Sample Action tool tip");
+ sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
+ }
+ public void contributeToMenu(IMenuManager manager) {
+ IMenuManager menu = new MenuManager("Editor &Menu");
+ manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
+ menu.add(sampleAction);
+ }
+ public void contributeToToolBar(IToolBarManager manager) {
+ manager.add(new Separator());
+ manager.add(sampleAction);
+ }
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/MultiPageEditorContributor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/SmooksTestMultiPageEditor.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/SmooksTestMultiPageEditor.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/SmooksTestMultiPageEditor.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -0,0 +1,240 @@
+package org.smooks.tools.testui.editors;
+
+
+import java.io.StringWriter;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+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.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FontDialog;
+import org.eclipse.ui.*;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.ide.IDE;
+import org.smooks.tools.testui.views.SmooksTestEditor;
+
+/**
+ * An example showing how to create a multi-page editor.
+ * This example has 3 pages:
+ * <ul>
+ * <li>page 0 contains a nested text editor.
+ * <li>page 1 allows you to change the font used in page 2
+ * <li>page 2 shows the words in page 0 in sorted order
+ * </ul>
+ */
+public class SmooksTestMultiPageEditor extends MultiPageEditorPart implements
IResourceChangeListener{
+
+ /** The text editor used in page 0. */
+ private TextEditor editor;
+
+ /** The font chosen in page 1. */
+ private Font font;
+
+ /** The text widget used in page 2. */
+ private StyledText text;
+
+ private SmooksTestEditor testEditor;
+ /**
+ * Creates a multi-page editor example.
+ */
+ public SmooksTestMultiPageEditor() {
+ super();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ }
+ /**
+ * Creates page 0 of the multi-page editor,
+ * which contains a text editor.
+ */
+ void createPage0() {
+ testEditor = new SmooksTestEditor();
+ int index;
+ try {
+ index = addPage(testEditor, getEditorInput());
+ setPageText(index, "Test");
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ /**
+ * Creates page 1 of the multi-page editor,
+ * which allows you to change the font used in page 2.
+ */
+ void createPage1() {
+
+ Composite composite = new Composite(getContainer(), SWT.NONE);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ layout.numColumns = 2;
+
+ Button fontButton = new Button(composite, SWT.NONE);
+ GridData gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 2;
+ fontButton.setLayoutData(gd);
+ fontButton.setText("Change Font...");
+
+ fontButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ setFont();
+ }
+ });
+
+ int index = addPage(composite);
+ setPageText(index, "Properties");
+ }
+ /**
+ * Creates page 2 of the multi-page editor,
+ * which shows the sorted text.
+ */
+ void createPage2() {
+ Composite composite = new Composite(getContainer(), SWT.NONE);
+ FillLayout layout = new FillLayout();
+ composite.setLayout(layout);
+ text = new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL);
+ text.setEditable(false);
+
+ int index = addPage(composite);
+ setPageText(index, "Preview");
+ }
+ /**
+ * Creates the pages of the multi-page editor.
+ */
+ protected void createPages() {
+ createPage0();
+ createPage1();
+// createPage2();
+ }
+ /**
+ * The <code>MultiPageEditorPart</code> implementation of this
+ * <code>IWorkbenchPart</code> method disposes all nested editors.
+ * Subclasses may extend.
+ */
+ public void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ super.dispose();
+ }
+ /**
+ * Saves the multi-page editor's document.
+ */
+ public void doSave(IProgressMonitor monitor) {
+ getEditor(0).doSave(monitor);
+ }
+ /**
+ * Saves the multi-page editor's document as another file.
+ * Also updates the text for page 0's tab, and updates this multi-page editor's
input
+ * to correspond to the nested editor's.
+ */
+ public void doSaveAs() {
+ IEditorPart editor = getEditor(0);
+ editor.doSaveAs();
+ setPageText(0, editor.getTitle());
+ setInput(editor.getEditorInput());
+ }
+ /* (non-Javadoc)
+ * Method declared on IEditorPart
+ */
+ public void gotoMarker(IMarker marker) {
+ setActivePage(0);
+ IDE.gotoMarker(getEditor(0), marker);
+ }
+ /**
+ * The <code>MultiPageEditorExample</code> implementation of this method
+ * checks that the input is an instance of <code>IFileEditorInput</code>.
+ */
+ public void init(IEditorSite site, IEditorInput editorInput)
+ throws PartInitException {
+ if (!(editorInput instanceof IFileEditorInput))
+ throw new PartInitException("Invalid Input: Must be IFileEditorInput");
+ super.init(site, editorInput);
+ }
+ /* (non-Javadoc)
+ * Method declared on IEditorPart.
+ */
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+ /**
+ * Calculates the contents of page 2 when the it is activated.
+ */
+ protected void pageChange(int newPageIndex) {
+ super.pageChange(newPageIndex);
+ if (newPageIndex == 2) {
+ sortWords();
+ }
+ }
+ /**
+ * Closes all project files on project close.
+ */
+ public void resourceChanged(final IResourceChangeEvent event){
+ if(event.getType() == IResourceChangeEvent.PRE_CLOSE){
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run(){
+ IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+ for (int i = 0; i<pages.length; i++){
+ if(((FileEditorInput)editor.getEditorInput()).getFile().getProject().equals(event.getResource())){
+ IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
+ pages[i].closeEditor(editorPart,true);
+ }
+ }
+ }
+ });
+ }
+ }
+ /**
+ * Sets the font related data to be applied to the text in page 2.
+ */
+ void setFont() {
+ FontDialog fontDialog = new FontDialog(getSite().getShell());
+ fontDialog.setFontList(text.getFont().getFontData());
+ FontData fontData = fontDialog.open();
+ if (fontData != null) {
+ if (font != null)
+ font.dispose();
+ font = new Font(text.getDisplay(), fontData);
+ text.setFont(font);
+ }
+ }
+ /**
+ * Sorts the words in page 0, and shows them in page 2.
+ */
+ void sortWords() {
+
+ String editorText =
+ editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
+
+ StringTokenizer tokenizer =
+ new StringTokenizer(editorText, "
\t\n\r\f!@#\u0024%^&*()-_=+`~[]{};:'\",.<>/?|\\");
+ ArrayList editorWords = new ArrayList();
+ while (tokenizer.hasMoreTokens()) {
+ editorWords.add(tokenizer.nextToken());
+ }
+
+ Collections.sort(editorWords, Collator.getInstance());
+ StringWriter displayText = new StringWriter();
+ for (int i = 0; i < editorWords.size(); i++) {
+ displayText.write(((String) editorWords.get(i)));
+ displayText.write(System.getProperty("line.separator"));
+ }
+ text.setText(displayText.toString());
+ }
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/editors/SmooksTestMultiPageEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/AbstractNode.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/AbstractNode.java 2009-02-24
16:15:44 UTC (rev 13774)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/AbstractNode.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -53,17 +53,14 @@
support.removePropertyChangeListener(listener);
}
- @Override
public Object adapte(Class type) {
return null;
}
- @Override
public boolean hasChildren() {
return true;
}
- @Override
public void refresh() {
// TODO Auto-generated method stub
Added:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -0,0 +1,182 @@
+/**
+ *
+ */
+package org.smooks.tools.testui.views;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
+import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
+import org.jboss.tools.smooks.ui.editors.SmooksFileEditorInput;
+import org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard;
+import org.jboss.tools.smooks.xml2java.analyzer.AbstractXMLModelAnalyzer;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksTestEditor extends EditorPart {
+
+ private GraphInformations graphInformations;
+ private String inputSource;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
+ * IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ if (!(input instanceof SmooksFileEditorInput)) {
+ throw new PartInitException("Error!");
+ }
+ this.setInput(input);
+ setSite(site);
+ GraphicalInformationSaver saver = new GraphicalInformationSaver(input);
+ try {
+ graphInformations = saver.doLoad();
+ String sourceId = graphInformations.getMappingType()
+ .getSourceTypeID();
+ String targetId = graphInformations.getMappingType()
+ .getTargetTypeID();
+ if (!targetId
+ .equals("org.jboss.tools.smooks.ui.viewerInitor.javabean")) {
+ throw new PartInitException(
+ "can't support this target data type : " + targetId);
+ }
+ if (!sourceId.equals("org.jboss.tools.smooks.xml.viewerInitor.xml")) {
+ throw new PartInitException(
+ "can't support this source data type : " + sourceId);
+ }
+
+ Params params = graphInformations.getParams();
+ if (params != null) {
+ List list = params.getParam();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Param param = (Param) iterator.next();
+ if (SmooksConfigFileNewWizard.PRO_SOURCE_DATA_PATH
+ .equals(param.getName())) {
+ String p = param.getValue();
+ try {
+ String filePath = AbstractXMLModelAnalyzer
+ .parseFilePath(p);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(
+ new FileInputStream(filePath)));
+ String line = reader.readLine();
+ StringBuffer buffer = new StringBuffer();
+ while (line != null) {
+ buffer.append(line);
+ line = reader.readLine();
+ buffer.append("\n");
+ }
+ inputSource = buffer.toString();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ throw new PartInitException(e.toString());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#isDirty()
+ */
+ @Override
+ public boolean isDirty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ parent.setLayout(new FillLayout());
+ StyledText text = new StyledText(parent, SWT.NONE);
+ if (inputSource != null) {
+ text.setText(inputSource);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestProjectsView.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestProjectsView.java 2009-02-24
16:15:44 UTC (rev 13774)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestProjectsView.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -32,26 +32,25 @@
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.ViewPart;
+import org.jboss.tools.smooks.ui.editors.SmooksFileEditorInput;
-
/**
- * This sample class demonstrates how to plug-in a new
- * workbench view. The view shows data obtained from the
- * model. The sample creates a dummy model on the fly,
- * but a real implementation would connect to the model
- * available either in this or another plug-in (e.g. the workspace).
- * The view is connected to the model using a content provider.
+ * This sample class demonstrates how to plug-in a new workbench view. The view
+ * shows data obtained from the model. The sample creates a dummy model on the
+ * fly, but a real implementation would connect to the model available either in
+ * this or another plug-in (e.g. the workspace). The view is connected to the
+ * model using a content provider.
* <p>
- * The view uses a label provider to define how model
- * objects should be presented in the view. Each
- * view can present the same model objects using
- * different labels and icons, if needed. Alternatively,
- * a single label provider can be shared between views
- * in order to ensure that objects of the same type are
- * presented in the same way everywhere.
+ * The view uses a label provider to define how model objects should be
+ * presented in the view. Each view can present the same model objects using
+ * different labels and icons, if needed. Alternatively, a single label provider
+ * can be shared between views in order to ensure that objects of the same type
+ * are presented in the same way everywhere.
* <p>
*/
@@ -63,106 +62,123 @@
private Action doubleClickAction;
/*
- * The content provider class is responsible for
- * providing objects to the view. It can wrap
- * existing objects in adapters or simply return
- * objects as-is. These objects may be sensitive
- * to the current input of the view, or ignore
- * it and always show the same content
- * (like Task List, for example).
+ * The content provider class is responsible for providing objects to the
+ * view. It can wrap existing objects in adapters or simply return objects
+ * as-is. These objects may be sensitive to the current input of the view,
+ * or ignore it and always show the same content (like Task List, for
+ * example).
*/
-
+
class TreeObject implements IAdaptable {
private String name;
private TreeParent parent;
-
+
public TreeObject(String name) {
this.name = name;
}
+
public String getName() {
return name;
}
+
public void setParent(TreeParent parent) {
this.parent = parent;
}
+
public TreeParent getParent() {
return parent;
}
+
public String toString() {
return getName();
}
+
public Object getAdapter(Class key) {
return null;
}
}
-
+
class TreeParent extends TreeObject {
private ArrayList children;
+
public TreeParent(String name) {
super(name);
children = new ArrayList();
}
+
public void addChild(TreeObject child) {
children.add(child);
child.setParent(this);
}
+
public void removeChild(TreeObject child) {
children.remove(child);
child.setParent(null);
}
- public TreeObject [] getChildren() {
- return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+
+ public TreeObject[] getChildren() {
+ return (TreeObject[]) children.toArray(new TreeObject[children
+ .size()]);
}
+
public boolean hasChildren() {
- return children.size()>0;
+ return children.size() > 0;
}
}
- class ViewContentProvider implements IStructuredContentProvider,
- ITreeContentProvider {
+ class ViewContentProvider implements IStructuredContentProvider,
+ ITreeContentProvider {
private TreeParent invisibleRoot;
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
}
+
public void dispose() {
}
+
public Object[] getElements(Object parent) {
- if(parent instanceof List){
- return ((List)parent).toArray();
+ if (parent instanceof List) {
+ return ((List) parent).toArray();
}
return new Object[0];
}
+
public Object getParent(Object child) {
return null;
}
- public Object [] getChildren(Object parent) {
+
+ public Object[] getChildren(Object parent) {
if (parent instanceof Node) {
- return ((Node)parent).getChildren().toArray();
+ return ((Node) parent).getChildren().toArray();
}
return new Object[0];
}
+
public boolean hasChildren(Object parent) {
if (parent instanceof Node)
- return ((Node)parent).hasChildren();
+ return ((Node) parent).hasChildren();
return false;
}
}
+
class ViewLabelProvider extends LabelProvider {
public String getText(Object obj) {
- if (obj instanceof Node)
- {
- return ((Node)obj).getName();
+ if (obj instanceof Node) {
+ return ((Node) obj).getName();
}
return obj.toString();
}
+
public Image getImage(Object obj) {
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
if (obj instanceof ProjectNode)
- imageKey = ISharedImages.IMG_OBJ_FOLDER;
- return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ imageKey);
}
}
+
class NameSorter extends ViewerSorter {
}
@@ -173,50 +189,50 @@
}
/**
- * This is a callback that will allow us
- * to create the viewer and initialize it.
+ * This is a callback that will allow us to create the viewer and initialize
+ * it.
*/
public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
drillDownAdapter = new DrillDownAdapter(viewer);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
-
+
viewer.setSorter(new NameSorter());
- viewer.setInput(loadResources());
// Create the help context id for the viewer's control
- PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
"org.smooks.tools.testui.viewer");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "org.smooks.tools.testui.viewer");
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
}
-
- private List<Node> loadResources(){
+
+ private List<Node> loadResources() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
List<Node> list = new ArrayList<Node>();
for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
- if(isJavaProject(project)){
+ if (isJavaProject(project)) {
ProjectNode pn = new ProjectNode(project);
list.add(pn);
}
}
return list;
}
-
- private boolean isJavaProject(IProject p){
- boolean isJavaProject =false;
- if( p != null){
- try{
- if( p.hasNature(JavaCore.NATURE_ID)){
+
+ private boolean isJavaProject(IProject p) {
+ boolean isJavaProject = false;
+ if (p != null) {
+ try {
+ if (p.hasNature(JavaCore.NATURE_ID)) {
isJavaProject = true;
}
- }catch(Exception e){
-
- }finally{
+ } catch (Exception e) {
+
+ } finally {
return isJavaProject;
}
}
@@ -256,7 +272,7 @@
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
-
+
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(action1);
manager.add(action2);
@@ -273,9 +289,9 @@
};
action1.setText("Load Smooks issues");
action1.setToolTipText("Load Smooks issues and show them");
- action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
- getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
-
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+
action2 = new Action() {
public void run() {
showMessage("Action 2 executed");
@@ -283,13 +299,26 @@
};
action2.setText("Action 2");
action2.setToolTipText("Action 2 tooltip");
- action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
- getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
doubleClickAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- showMessage("Double-click detected on "+obj.toString());
+ Object obj = ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (obj instanceof SmooksNode) {
+ SmooksFileEditorInput input = new SmooksFileEditorInput(
+ ((SmooksNode) obj).getConfigFile());
+ try {
+ getSite()
+ .getWorkbenchWindow()
+ .getActivePage()
+ .openEditor(input,
+ "org.smooks.tools.testui.editors.MultiPageEditor");
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
}
};
}
@@ -301,11 +330,10 @@
}
});
}
+
private void showMessage(String message) {
- MessageDialog.openInformation(
- viewer.getControl().getShell(),
- "Sample View",
- message);
+ MessageDialog.openInformation(viewer.getControl().getShell(),
+ "Sample View", message);
}
/**
Deleted:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestResultView.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestResultView.java 2009-02-24
16:15:44 UTC (rev 13774)
+++
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/TestResultView.java 2009-02-24
16:27:17 UTC (rev 13775)
@@ -1,31 +0,0 @@
-/**
- *
- */
-package org.smooks.tools.testui.views;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * @author Dart
- *
- */
-public class TestResultView extends ViewPart {
-
- /* (non-Javadoc)
- * @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- @Override
- public void setFocus() {
-
- }
-
-}