Author: Grid.Qian
Date: 2008-09-12 01:37:31 -0400 (Fri, 12 Sep 2008)
New Revision: 10214
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnPoolsChoicePage.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizard.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizardDialog.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/ErrorMessagesPage.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/GeneratedFileLocationPage.java
Modified:
workspace/grid/org.jboss.tools.bpmnTo/.classpath
workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
workspace/grid/org.jboss.tools.bpmnTo/plugin.xml
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/action/BpmnToAction.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/translate/BPMNTranslator.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/util/BPMNToUtil.java
Log:
add a wizard for translate and remove those dialogs
Modified: workspace/grid/org.jboss.tools.bpmnTo/.classpath
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/.classpath 2008-09-12 03:36:51 UTC (rev 10213)
+++ workspace/grid/org.jboss.tools.bpmnTo/.classpath 2008-09-12 05:37:31 UTC (rev 10214)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib"
path="bin/"/>
+ <classpathentry exported="true" kind="lib" path="bin/"
sourcepath="src/org/jboss/tools/b2j/messages"/>
<classpathentry exported="true" kind="lib"
path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
Modified: workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF 2008-09-12 03:36:51 UTC
(rev 10213)
+++ workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF 2008-09-12 05:37:31 UTC
(rev 10214)
@@ -15,10 +15,7 @@
bin/
Bundle-Vendor: %PLUGIN_PROVIDER
Import-Package: org.eclipse.core.resources
-Export-Package: org.jboss.tools.b2j.action,
- org.jboss.tools.b2j.messages,
- org.jboss.tools.b2j.translate,
- org.jboss.tools.bpmnto,
+Export-Package: org.jboss.tools.bpmnto,
org.jboss.tools.bpmnto.action,
org.jboss.tools.bpmnto.translate,
org.jboss.tools.bpmnto.util
Modified: workspace/grid/org.jboss.tools.bpmnTo/plugin.xml
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/plugin.xml 2008-09-12 03:36:51 UTC (rev 10213)
+++ workspace/grid/org.jboss.tools.bpmnTo/plugin.xml 2008-09-12 05:37:31 UTC (rev 10214)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
-<plugin>
- <extension
+<plugin>
+<extension
point="org.eclipse.ui.popupMenus">
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties 2008-09-12
05:37:31 UTC (rev 10214)
@@ -9,6 +9,9 @@
Height_Attribute_Name=height
X_Attribute_Name=x
Y_Attribute_Name=y
+Label_Select_All=Select All
+Label_Deselect_All=Deselect All
+Label_Button_Browse=Browse...
Bpmn_Diagram_Name_Suffix=_diagram
Bpmn_Pool_Element_Name=pools
Bpmn_Vertice_Element_Name=vertices
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -33,6 +33,9 @@
public static String Height_Attribute_Name;
public static String X_Attribute_Name;
public static String Y_Attribute_Name;
+ public static String Label_Select_All;
+ public static String Label_Deselect_All;
+ public static String Label_Button_Browse;
public static String Bpmn_Diagram_Name_Suffix;
public static String Bpmn_Pool_Element_Name;
public static String Bpmn_Element_ID;
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -115,10 +115,8 @@
if (bpmnID != null) {
// when translate bpmn loop activity, we create a mock
// structure and when translate bpmn transaction, we create a
- // mock
- // structure too. For these reason, we need to give a (x,y)
- // increment to avoid
- // two element overlap
+ // mock structure too. For these reason, we need to give a (x,y)
+ // increment to avoid two element overlap
int xIncre = 0;
int yIncre = 0;
Element bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/action/BpmnToAction.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/action/BpmnToAction.java 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/action/BpmnToAction.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.bpmnto.action;
import java.util.ArrayList;
@@ -2,5 +13,2 @@
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
@@ -12,119 +20,69 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.dialogs.ListDialog;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.jboss.tools.b2j.messages.B2JMessages;
import org.jboss.tools.bpmnto.util.BPMNToUtil;
+import org.jboss.tools.bpmnto.wizard.BpmnToWizard;
+import org.jboss.tools.bpmnto.wizard.BpmnToWizardDialog;
+/**
+ * @author Grid Qian
+ *
+ * a abstract action class of translate bpmn
+ * the subclass should realize the method: translateBpmn to do a translation
+ * from bpmn to anything
+ *
+ */
public abstract class BpmnToAction implements IObjectActionDelegate {
public IFile bpmnFile;
+ public List<String> errorList = new ArrayList<String>();
public void setActivePart(IAction arg0, IWorkbenchPart part) {
// myPart = part;
}
- public void run(IAction arg0) {
+ public void run(IAction action) {
String bpmnFileName = bpmnFile.getName();
String bpmnFileParentPath = bpmnFile.getParent().getLocation()
.toOSString();
-
- List<String> list = new ArrayList<String>();
- List<String> poolIdList = null;
+
+ BpmnToWizard wizard = null;
try {
- poolIdList = selectPoolElement(BPMNToUtil
- .getPoolIDsFromDocument(getDocument(bpmnFileParentPath,
- bpmnFileName)));
- } catch (Exception e) {
- list.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
+ wizard = new
BpmnToWizard(action.getText(),BPMNToUtil.getPoolIDsFromDocument(getDocument(bpmnFileParentPath,bpmnFileName)));
+ } catch (Exception e1) {
+ errorList.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
bpmnFileName));
+ e1.printStackTrace();
}
+
+ BpmnToWizardDialog dialog = new
BpmnToWizardDialog(Display.getCurrent().getActiveShell(), wizard, this);
+
+ dialog.open();
- if (poolIdList.size() == 0) {
- return;
- }
- String location = getGeneratedFileLocation();
- if (location == null) {
- location = bpmnFileParentPath;
- }
-
- list.addAll(translateBpmn(bpmnFileParentPath, bpmnFileName, poolIdList,
- location));
-
- showErrors(list);
refreshWorkspace();
}
+
+
+ /**
+ * a abstract method to be used to realize the translation
+ *
+ * @param bpmnFileParentPath the bpmn file parent folder
+ * @param bpmnFileName the bpmn file name
+ * @param poolIdList the bpmn id list that are needed to translate
+ * @param location the generated files location
+ * @return the warning and error message when translate
+ */
public abstract List<String> translateBpmn(String bpmnFileParentPath,
String bpmnFileName, List<String> poolIdList, String location);
- public void showErrors(List<String> list) {
- if (list.size() == 0) {
- return;
- }
-
- ListDialog dialog = new ListDialog(Display.getCurrent()
- .getActiveShell());
- dialog.setTitle(B2JMessages.Bpmn_Translate_Message_Dialog_Title);
- dialog.setMessage(B2JMessages.Bpmn_Translate_Message_Dialog_Message);
-
- dialog.setInput(list);
- ILabelProvider labelProvider = new LabelProvider();
- ArrayContentProvider contentProvider = new ArrayContentProvider();
- dialog.setContentProvider(contentProvider);
- dialog.setLabelProvider(labelProvider);
- dialog.open();
- }
-
- public String getGeneratedFileLocation() {
- DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent()
- .getActiveShell());
- dialog.setText(B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Title);
- dialog
- .setMessage(B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Message);
- String path = dialog.open();
- return path;
- }
-
- /*
- * choose some bpmn pool ids from a ids array
- */
- @SuppressWarnings("unchecked")
- public List<String> selectPoolElement(Set<Map.Entry<String, String>>
idSet) {
- Shell shell = Display.getCurrent().getActiveShell();
- ILabelProvider labelProvider = new LabelProvider();
- ArrayContentProvider contentProvider = new ArrayContentProvider();
- ListSelectionDialog dialog = new ListSelectionDialog(shell, idSet,
- contentProvider, labelProvider, null);
- dialog.setMessage(B2JMessages.Bpmn_Pool_Choose_Dialog_Message);
- dialog.setTitle(B2JMessages.Bpmn_Pool_Choose_Dialog_Title);
- Object[] selected = null;
- if (dialog.open() == Window.OK) {
- selected = dialog.getResult();
- }
- List<String> list = new ArrayList<String>();
- if (selected == null) {
- return list;
- }
- for (Object entry : selected) {
- list.add(((Entry<String, String>) entry).getKey());
- }
- return list;
- }
-
public Document getDocument(String bpmnFileParentPath, String bpmnFileName)
throws Exception {
Document bpmnDocument = null;
@@ -144,4 +102,6 @@
public void selectionChanged(IAction arg0, ISelection selection) {
bpmnFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
}
+
+
}
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/translate/BPMNTranslator.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/translate/BPMNTranslator.java 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/translate/BPMNTranslator.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -17,7 +17,8 @@
/**
* @author Grid Qian
*
- * this is a root translator
+ * this is a root translator. You should extend it and realize the
+ * method: translateDiagram.
*/
public abstract class BPMNTranslator {
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/util/BPMNToUtil.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/util/BPMNToUtil.java 2008-09-12
03:36:51 UTC (rev 10213)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/util/BPMNToUtil.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -20,7 +20,6 @@
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -136,7 +135,7 @@
/*
* get bpmn pool id list from a dom document
*/
- public static Set<Map.Entry<String, String>> getPoolIDsFromDocument(
+ public static Map<String, String> getPoolIDsFromDocument(
Document document) {
Map<String, String> poolIDMap = new HashMap<String, String>();
Element diagram = document.getRootElement();
@@ -148,6 +147,6 @@
.attributeValue(B2JMessages.Dom_Element_Name));
}
}
- return poolIDMap.entrySet();
+ return poolIDMap;
}
}
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnPoolsChoicePage.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnPoolsChoicePage.java
(rev 0)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnPoolsChoicePage.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.bpmnto.wizard;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage used by user to choose the bpmn pool from a bpmn diagram
+ */
+public class BpmnPoolsChoicePage extends WizardPage {
+
+ CheckboxTableViewer listViewer;
+ String listTitle;
+ private Map<String, String> idMap;
+ private IWizard wizard;
+
+ public BpmnPoolsChoicePage(String pageName, String listTitle,
+ Map<String, String> idMap) {
+ super(pageName);
+ this.listTitle = listTitle;
+ this.idMap = idMap;
+ this.setTitle(pageName);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ createListTitleArea(composite);
+
+ createListViewer(composite);
+
+ addSelectionButtons(composite);
+
+ setControl(composite);
+ initializePage();
+ initializeViewerSelection();
+ }
+
+ private void initializeViewerSelection() {
+ wizard = this.getWizard();
+ List<String> poolIdList = ((BpmnToWizard) wizard).getPoolIdList();
+ if (poolIdList.size() == 0) {
+ listViewer.setAllChecked(false);
+ } else {
+ for (String id : poolIdList) {
+ Set<Entry<String, String>> set = idMap.entrySet();
+ Entry<String, String> selectedEntry = null;
+ for (Entry<String, String> entry : set) {
+ if (entry.getKey().equals(id)) {
+ selectedEntry = entry;
+ break;
+ }
+ }
+ listViewer.setChecked(selectedEntry, true);
+ }
+ }
+ }
+
+ private void initializePage() {
+ setPageComplete(false);
+ listViewer.setInput(idMap.entrySet());
+ }
+
+ private void addSelectionButtons(Composite composite) {
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 4;
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true,
+ false));
+
+ Button selectButton = createButton(buttonComposite, B2JMessages.Label_Select_All,
+ false);
+
+ SelectionListener listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(true);
+ (((BpmnToWizard) wizard)).getPoolIdList()
+ .addAll(idMap.keySet());
+ changeComplete();
+ }
+ };
+ selectButton.addSelectionListener(listener);
+
+ Button deselectButton = createButton(buttonComposite,
+ B2JMessages.Label_Deselect_All, false);
+
+ listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(false);
+ (((BpmnToWizard) wizard)).getPoolIdList().clear();
+ changeComplete();
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+ }
+
+ private Button createButton(Composite parent, String label,
+ boolean defaultButton) {
+ // increment the number of columns in the button bar
+ ((GridLayout) parent.getLayout()).numColumns++;
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(label);
+ if (defaultButton) {
+ Shell shell = parent.getShell();
+ if (shell != null) {
+ shell.setDefaultButton(button);
+ }
+ }
+ setButtonLayoutData(button);
+ return button;
+ }
+
+ private void createListViewer(Composite composite) {
+ listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 250;
+ data.widthHint = 300;
+ listViewer.getTable().setLayoutData(data);
+
+ listViewer.setLabelProvider(new LabelProvider());
+ listViewer.setContentProvider(new ArrayContentProvider());
+ listViewer.addCheckStateListener(new ICheckStateListener() {
+ @SuppressWarnings("unchecked")
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) {
+ (((BpmnToWizard) wizard)).getPoolIdList().add(
+ ((Entry<String, String>) event.getElement())
+ .getKey());
+ } else {
+ (((BpmnToWizard) wizard)).getPoolIdList().remove(
+ ((Entry<String, String>) event.getElement())
+ .getKey());
+ }
+ changeComplete();
+ }
+ });
+ }
+
+ private Label createListTitleArea(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(listTitle);
+ label.setFont(composite.getFont());
+ return label;
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public void changeComplete() {
+ if (listViewer.getCheckedElements().length != 0) {
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ }
+
+}
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizard.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizard.java
(rev 0)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizard.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.bpmnto.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizard for bpmn translation
+ */
+public class BpmnToWizard extends Wizard{
+
+ BpmnPoolsChoicePage poolsPage;
+ GeneratedFileLocationPage locationPage;
+ ErrorMessagesPage errorPage;
+
+ // bpmn pool id:name map
+ Map<String, String> idMap;
+ List<String> poolIdList = new ArrayList<String>();
+ String location;
+ List<String> errorList = new ArrayList<String>();
+
+ public BpmnToWizard(String title,Map<String, String> idMap){
+ super();
+ super.setWindowTitle(title);
+ this.idMap = idMap;
+ }
+
+ public void addPages(){
+ super.addPages();
+ poolsPage = new BpmnPoolsChoicePage(B2JMessages.Bpmn_Pool_Choose_Dialog_Title,
B2JMessages.Bpmn_Pool_Choose_Dialog_Message,idMap);
+ locationPage = new
GeneratedFileLocationPage(B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Title,B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Message);
+ errorPage = new
ErrorMessagesPage(B2JMessages.Bpmn_Translate_Message_Dialog_Title,B2JMessages.Bpmn_Translate_Message_Dialog_Message);
+ addPage(poolsPage);
+ addPage(locationPage);
+ addPage(errorPage);
+ }
+ public boolean performFinish() {
+
+ return true;
+ }
+
+
+ public List<String> getPoolIdList() {
+ return poolIdList;
+ }
+
+ public void setPoolIdList(List<String> poolIdList) {
+ this.poolIdList = poolIdList;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public List<String> getErrorList() {
+ return errorList;
+ }
+
+ public void setErrorList(List<String> errorList) {
+ this.errorList = errorList;
+ }
+
+}
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizardDialog.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizardDialog.java
(rev 0)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/BpmnToWizardDialog.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.bpmnto.wizard;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.jboss.tools.bpmnto.action.BpmnToAction;
+
+/**
+ * @author Grid Qian
+ *
+ * wizard dialog for bpmn tranlation
+ */
+public class BpmnToWizardDialog extends WizardDialog {
+
+ IActionDelegate action;
+
+ public BpmnToWizardDialog(Shell parentShell, IWizard newWizard,
+ IActionDelegate action) {
+ super(parentShell, newWizard);
+ this.action = action;
+ }
+
+ public void nextPressed() {
+ IWizardPage page = this.getCurrentPage();
+ if (page instanceof GeneratedFileLocationPage) {
+ List<String> list = ((BpmnToAction) action).errorList;
+ String location = ((BpmnToWizard) this.getWizard()).getLocation();
+ if (location == null || "".equals(location)) {
+ location = ((BpmnToAction) action).bpmnFile.getParent()
+ .getLocation().toOSString();
+ }
+ list.addAll(((BpmnToAction) action).translateBpmn(
+ ((BpmnToAction) action).bpmnFile.getParent().getLocation()
+ .toOSString(), ((BpmnToAction) action).bpmnFile
+ .getName(), ((BpmnToWizard) this.getWizard())
+ .getPoolIdList(), location));
+ ((BpmnToWizard) this.getWizard()).setErrorList(list);
+ ((ErrorMessagesPage) page.getNextPage()).listViewer
+ .setInput(((BpmnToWizard) this.getWizard()).getErrorList());
+ }
+ showPage(page.getNextPage());
+ }
+
+}
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/ErrorMessagesPage.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/ErrorMessagesPage.java
(rev 0)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/ErrorMessagesPage.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.bpmnto.wizard;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage for showing the error and warning messages from translating
+ */
+public class ErrorMessagesPage extends WizardPage{
+
+ TableViewer listViewer;
+ String listTitle;
+
+ protected ErrorMessagesPage(String pageName, String listTitle) {
+ super(pageName);
+ this.listTitle = listTitle;
+ this.setTitle(pageName);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+
+ createListTitleArea(composite);
+ createListViewer(composite);
+ setControl(composite);
+
+ initializeViewer();
+
+ }
+
+ private void initializeViewer() {
+ listViewer.setInput(((BpmnToWizard)this.getWizard()).getErrorList());
+ }
+
+ private void createListViewer(Composite composite) {
+ listViewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 250;
+ data.widthHint = 300;
+ listViewer.getTable().setLayoutData(data);
+
+ listViewer.setLabelProvider(new LabelProvider());
+ listViewer.setContentProvider(new ArrayContentProvider());
+ }
+
+ private Label createListTitleArea(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(listTitle);
+ label.setFont(composite.getFont());
+ return label;
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public boolean isPageComplete() {
+ return true;
+ }
+
+}
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/GeneratedFileLocationPage.java
===================================================================
---
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/GeneratedFileLocationPage.java
(rev 0)
+++
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnto/wizard/GeneratedFileLocationPage.java 2008-09-12
05:37:31 UTC (rev 10214)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.bpmnto.wizard;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage for the generated file location
+ */
+public class GeneratedFileLocationPage extends WizardPage{
+
+ String message;
+ Text pathText;
+ private IWizard wizard;
+
+ protected GeneratedFileLocationPage(String pageName, String message) {
+ super(pageName);
+ this.message = message;
+ this.setTitle(pageName);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ createMessageArea(composite);
+ createLocationArea(composite);
+
+ setControl(composite);
+
+ }
+
+ private void createLocationArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Location:");
+ label.setFont(parent.getFont());
+
+
+ pathText = new Text(composite, SWT.BORDER);
+ pathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ pathText.setEditable(false);
+
+ Button browse = new Button(composite, SWT.PUSH);
+ browse.setText(B2JMessages.Label_Button_Browse);
+ browse.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+ dialog.setText(B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Title);
+ dialog.setMessage(B2JMessages.Bpmn_GeneratedFile_Location_Dialog_Message);
+ String path = dialog.open();
+ if (path != null && path.length() > 0) {
+ pathText.setText(path);
+ ((BpmnToWizard)wizard).setLocation(path);
+ }
+ }
+ });
+
+ initializePage();
+
+
+ }
+
+ private void initializePage() {
+ wizard = this.getWizard();
+ pathText.setText(((BpmnToWizard)wizard).getLocation() == null ?"" :
((BpmnToWizard)wizard).getLocation());
+
+ }
+
+ private Label createMessageArea(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(message);
+ label.setFont(parent.getFont());
+ return label;
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public boolean isPageComplete() {
+ return true;
+ }
+
+}