Author: DartPeng
Date: 2008-10-13 06:24:17 -0400 (Mon, 13 Oct 2008)
New Revision: 10786
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
Log:
JBIDE-2837
I add two linkbutton on the wizard page , they allow user to select the data model.
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-13
10:16:38 UTC (rev 10785)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-13
10:24:17 UTC (rev 10786)
@@ -900,6 +900,8 @@
if (dialog.open() == org.eclipse.jface.dialogs.Dialog.OK) {
sourceDataTypeID = wizard.getSourceDataTypeID();
targetDataTypeID = wizard.getTargetDataTypeID();
+ sourceTreeViewerInputModel = wizard.getSourceTreeViewerInputContents();
+ targetTreeViewerInputModel = wizard.getTargetTreeViewerInputContents();
this.getSmooksConfigurationFileGenerateContext()
.setSourceDataTypeID(sourceDataTypeID);
this.getSmooksConfigurationFileGenerateContext()
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java 2008-10-13
10:16:38 UTC (rev 10785)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java 2008-10-13
10:24:17 UTC (rev 10786)
@@ -10,16 +10,22 @@
******************************************************************************/
package org.jboss.tools.smooks.ui.editors;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
/**
* @author Dart Peng<br>
* Date : Sep 5, 2008
*/
-public class TypeIDSelectionWizard extends Wizard {
+public class TypeIDSelectionWizard extends Wizard implements INewWizard {
private String sourceDataTypeID = null;
private String targetDataTypeID = null;
+ private Object sourceTreeViewerInputContents;
+ private Object targetTreeViewerInputContents;
private TypeIDSelectionWizardPage page = null;
+ private IStructuredSelection selection;
public String getSourceDataTypeID() {
return sourceDataTypeID;
}
@@ -36,6 +42,7 @@
public void addPages(){
if(page == null){
page = new TypeIDSelectionWizardPage("TypeID Selection",false);
+ page.setSelection(selection);
this.addPage(page);
}
super.addPages();
@@ -51,7 +58,27 @@
if(sid == null || tid == null) return false;
this.sourceDataTypeID = sid;
this.targetDataTypeID = tid;
+ setSourceTreeViewerInputContents(page.getSourceTreeViewerInputContents());
+ setTargetTreeViewerInputContents(page.getTargetTreeViewerInputContents());
return true;
}
+ public Object getSourceTreeViewerInputContents() {
+ return sourceTreeViewerInputContents;
+ }
+ public void setSourceTreeViewerInputContents(
+ Object sourceTreeViewerInputContents) {
+ this.sourceTreeViewerInputContents = sourceTreeViewerInputContents;
+ }
+ public Object getTargetTreeViewerInputContents() {
+ return targetTreeViewerInputContents;
+ }
+ public void setTargetTreeViewerInputContents(
+ Object targetTreeViewerInputContents) {
+ this.targetTreeViewerInputContents = targetTreeViewerInputContents;
+ }
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ if(page != null) page.setSelection(selection);
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-10-13
10:16:38 UTC (rev 10785)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-10-13
10:24:17 UTC (rev 10786)
@@ -14,6 +14,8 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
@@ -24,8 +26,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardNode;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardSelectionPage;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -34,10 +35,14 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.Hyperlink;
import org.jboss.tools.smooks.analyzer.AnalyzerFactory;
import org.jboss.tools.smooks.analyzer.DataTypeID;
import org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard;
import org.jboss.tools.smooks.ui.IViewerInitor;
+import org.jboss.tools.smooks.ui.StructuredDataCreationWizardDailog;
import org.jboss.tools.smooks.ui.ViewerInitorStore;
import org.jboss.tools.smooks.ui.wizards.TransformSelectWizardNode;
@@ -45,11 +50,21 @@
* @author Dart Peng<br>
* Date : Sep 5, 2008
*/
-public class TypeIDSelectionWizardPage extends WizardSelectionPage {
+public class TypeIDSelectionWizardPage extends WizardPage {
+ /**
+ * @deprecated
+ */
protected IStrucutredDataCreationWizard sourceWizard;
+ /**
+ * @deprecated
+ */
protected IStrucutredDataCreationWizard targetWizard;
+ private Object sourceTreeViewerInputContents;
+
+ private Object targetTreeViewerInputContents;
+
protected CheckboxTableViewer source;
protected CheckboxTableViewer target;
private List sourceList;
@@ -58,6 +73,10 @@
private IStructuredSelection selection;
private boolean showDataSelectPage = false;
+ private Hyperlink sourceDataLink;
+
+ private Hyperlink targetDataLink;
+
public IStructuredSelection getSelection() {
return selection;
}
@@ -87,41 +106,53 @@
this.showDataSelectPage = showDataSelectPage;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.WizardSelectionPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- if (this.getSelectedNode() == null) {
- return null;
- }
+ // public boolean canFlipToNextPage() {
+ // if (!showDataSelectPage) {
+ // return isPageComplete() && getNextPage() != null;
+ // }
+ // return super.canFlipToNextPage();
+ // }
- boolean isCreated = getSelectedNode().isContentCreated();
+ // /*
+ // * (non-Javadoc)
+ // *
+ // * @see org.eclipse.jface.wizard.WizardSelectionPage#getNextPage()
+ // */
+ // public IWizardPage getNextPage() {
+ // if (!showDataSelectPage) {
+ // if (this.getWizard() != null) {
+ // return this.getWizard().getNextPage(this);
+ // }
+ // }
+ // if (this.getSelectedNode() == null) {
+ // return null;
+ // }
+ //
+ // boolean isCreated = getSelectedNode().isContentCreated();
+ //
+ // IWizard wizard = getSelectedNode().getWizard();
+ //
+ // if (wizard == null) {
+ // setSelectedNode(null);
+ // return null;
+ // }
+ // if (!isCreated) {
+ // if (wizard instanceof IStrucutredDataCreationWizard) {
+ // String targetID = getDataTypeID(target);
+ // if (targetID != null) {
+ // ((IStrucutredDataCreationWizard) wizard)
+ // .setNextDataCreationWizardNode(this
+ // .getSourceWizard(targetID));
+ // }
+ // }
+ // if (wizard instanceof INewWizard) {
+ // ((INewWizard) wizard).init(null, selection);
+ // }
+ // wizard.addPages();
+ // }
+ // return wizard.getStartingPage();
+ // }
- IWizard wizard = getSelectedNode().getWizard();
-
- if (wizard == null) {
- setSelectedNode(null);
- return null;
- }
- if (!isCreated) {
- if (wizard instanceof IStrucutredDataCreationWizard) {
- String targetID = getDataTypeID(target);
- if (targetID != null) {
- ((IStrucutredDataCreationWizard) wizard)
- .setNextDataCreationWizardNode(this
- .getSourceWizard(targetID));
- }
- }
- if (wizard instanceof INewWizard) {
- ((INewWizard) wizard).init(null, selection);
- }
- wizard.addPages();
- }
- return wizard.getStartingPage();
- }
-
/*
* (non-Javadoc)
*
@@ -150,9 +181,96 @@
target.setInput(sourceList);
initViewer();
+ sourceDataLink = new Hyperlink(mainComposite, SWT.NONE);
+ sourceDataLink.setText("Source Model Select:Empty");
+ sourceDataLink.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkActivated(HyperlinkEvent e) {
+ openSourceWizard();
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ });
+ targetDataLink = new Hyperlink(mainComposite, SWT.NONE);
+ targetDataLink.setText("Target Model Select:Empty");
+ targetDataLink.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkActivated(HyperlinkEvent e) {
+ openTargetWizard();
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ });
+
this.setControl(mainComposite);
}
+ protected void openTargetWizard() {
+ targetTreeViewerInputContents = getReturnObjectFromWizard(getTargetID());
+ resetLinkText();
+ }
+
+ protected IWizard getWizardViaDataID(String dataID) {
+ if (dataID == null)
+ return null;
+ IWizardNode wn = getSourceWizard(dataID);
+ // setSelectedNode(wn);
+ IWizard sw = wn.getWizard();
+ if (sw instanceof IStrucutredDataCreationWizard) {
+ // ((IStrucutredDataCreationWizard)sw).i
+ }
+ if (sw instanceof INewWizard) {
+ ((INewWizard) sw).init(null, this.getSelection());
+ }
+ return sw;
+ }
+
+ protected Object getReturnObjectFromWizard(String dataID) {
+ IWizard wizard = getWizardViaDataID(dataID);
+ if (wizard != null) {
+ StructuredDataCreationWizardDailog dialog = new StructuredDataCreationWizardDailog(
+ getShell(), wizard);
+ if (dialog.open() == Dialog.OK) {
+ return dialog.getCurrentCreationWizard()
+ .getTreeViewerInputContents();
+ }
+ } else {
+ MessageDialog.openInformation(getShell(), "Info",
+ "Please select the data type first");
+ }
+
+ return null;
+ }
+
+ protected void openSourceWizard() {
+ sourceTreeViewerInputContents = getReturnObjectFromWizard(getSourceID());
+ resetLinkText();
+ }
+
+ private void resetLinkText() {
+ if (sourceTreeViewerInputContents != null) {
+ sourceDataLink.setText("Source Model Select");
+ }
+
+ if (targetTreeViewerInputContents != null) {
+ targetDataLink.setText("Target Model Select");
+ }
+ }
+
protected String getDataTypeID(CheckboxTableViewer viewer) {
Object[] objs = viewer.getCheckedElements();
if (objs == null)
@@ -231,31 +349,35 @@
if (viewer == source) {
String sourceID = getDataTypeID(source);
- IWizardNode wn = getSourceWizard(sourceID);
- setSelectedNode(wn);
setSourceID(sourceID);
- IWizard sw = wn.getWizard();
- if (sw instanceof IStrucutredDataCreationWizard) {
- setSourceWizard((IStrucutredDataCreationWizard) sw);
- }
+ // TODO don't use that to display the source selection
+ // wizard page.
+ // IWizardNode wn = getSourceWizard(sourceID);
+ // setSelectedNode(wn);
+ // IWizard sw = wn.getWizard();
+ // if (sw instanceof IStrucutredDataCreationWizard) {
+ // setSourceWizard((IStrucutredDataCreationWizard) sw);
+ // }
}
if (viewer == target) {
- IWizardNode node = getSelectedNode();
+ // IWizardNode node = getSelectedNode();
String targetID = getDataTypeID(target);
- IWizardNode targetNode = getSourceWizard(targetID);
- IWizard tnw = targetNode.getWizard();
- if (tnw instanceof IStrucutredDataCreationWizard) {
- setTargetWizard((IStrucutredDataCreationWizard) tnw);
- }
- if (node != null) {
- IWizard wizard = node.getWizard();
- if (wizard != null
- && wizard instanceof IStrucutredDataCreationWizard) {
- ((IStrucutredDataCreationWizard) wizard)
- .setNextDataCreationWizardNode(targetNode);
- }
- }
+ // TODO don't use that to display the target selection
+ // wizard page.
+ // IWizardNode targetNode = getSourceWizard(targetID);
+ // IWizard tnw = targetNode.getWizard();
+ // if (tnw instanceof IStrucutredDataCreationWizard) {
+ // setTargetWizard((IStrucutredDataCreationWizard) tnw);
+ // }
+ // if (node != null) {
+ // IWizard wizard = node.getWizard();
+ // if (wizard != null
+ // && wizard instanceof IStrucutredDataCreationWizard) {
+ // ((IStrucutredDataCreationWizard) wizard)
+ // .setNextDataCreationWizardNode(targetNode);
+ // }
+ // }
setTargetID(targetID);
}
}
@@ -327,4 +449,22 @@
public void setTargetWizard(IStrucutredDataCreationWizard targetWizard) {
this.targetWizard = targetWizard;
}
+
+ public Object getSourceTreeViewerInputContents() {
+ return sourceTreeViewerInputContents;
+ }
+
+ public void setSourceTreeViewerInputContents(
+ Object sourceTreeViewerInputContents) {
+ this.sourceTreeViewerInputContents = sourceTreeViewerInputContents;
+ }
+
+ public Object getTargetTreeViewerInputContents() {
+ return targetTreeViewerInputContents;
+ }
+
+ public void setTargetTreeViewerInputContents(
+ Object targetTreeViewerInputContents) {
+ this.targetTreeViewerInputContents = targetTreeViewerInputContents;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-10-13
10:16:38 UTC (rev 10785)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-10-13
10:24:17 UTC (rev 10786)
@@ -59,7 +59,8 @@
page = new SmooksConfigFileNewWizardPage("newSmooksFile1",
getSelection());
addPage(page);
- typeIDPage = new TypeIDSelectionWizardPage("", true);
+ // TODO don't use the WizardSelectionPage
+ typeIDPage = new TypeIDSelectionWizardPage("", false);
typeIDPage.setSelection(selection);
addPage(typeIDPage);
}
@@ -131,29 +132,9 @@
try {
SmooksFileEditorInput input = new SmooksFileEditorInput(
file);
- IStrucutredDataCreationWizard sourceWizard = typeIDPage
- .getSourceWizard();
+ input.setSourceTreeViewerInputContents(typeIDPage.getSourceTreeViewerInputContents());
+ input.setTargetTreeViewerInputContents(typeIDPage.getTargetTreeViewerInputContents());
- IStrucutredDataCreationWizard targetWizard = typeIDPage
- .getTargetWizard();
-
- if (sourceWizard != null) {
- if (((IWizard) sourceWizard).getPageCount() != 0) {
- if (((IWizard) sourceWizard).performFinish())
- input
- .setSourceTreeViewerInputContents(sourceWizard
- .getTreeViewerInputContents());
- }
- }
- if (targetWizard != null) {
- if (((IWizard) targetWizard).getPageCount() != 0) {
- if (((IWizard) targetWizard).performFinish())
- input
- .setTargetTreeViewerInputContents(targetWizard
- .getTreeViewerInputContents());
- }
- }
-
IDE.openEditor(page, input, SmooksFormEditor.EDITOR_ID,
true);// openEditor(page, file, true);
} catch (PartInitException e) {