Index: plugin.xml
===================================================================
--- plugin.xml (revision 21244)
+++ plugin.xml (working copy)
@@ -1529,6 +1529,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/org/jbpm/gd/common/editor/ActionBarContributor.java
===================================================================
--- src/org/jbpm/gd/common/editor/ActionBarContributor.java (revision 21244)
+++ src/org/jbpm/gd/common/editor/ActionBarContributor.java (working copy)
@@ -22,15 +22,10 @@
package org.jbpm.gd.common.editor;
import org.eclipse.gef.ui.actions.ActionRegistry;
-import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -39,7 +34,7 @@
public class ActionBarContributor extends
MultiPageEditorActionBarContributor {
- ActionRegistry actionRegistry = new ActionRegistry();
+// ActionRegistry actionRegistry = new ActionRegistry();
private static final String[] WORKBENCH_ACTION_IDS = {
ActionFactory.PRINT.getId(),
@@ -75,8 +70,8 @@
hookGlobalGraphicalEditorActions((GraphPage)activeEditor, actionBars);
} else if (activeEditor instanceof StructuredTextEditor) {
hookGlobalXmlEditorActions((StructuredTextEditor)activeEditor, actionBars);
- } else {
- actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, null);
+// } else {
+// actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, null);
}
actionBars.updateActionBars();
}
@@ -88,7 +83,7 @@
WORKBENCH_ACTION_IDS[i],
part.getAction(TEXTEDITOR_ACTION_IDS[i]));
}
- actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_GRID_VISIBILITY, null);
+// actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_GRID_VISIBILITY, null);
}
private void hookGlobalGraphicalEditorActions(
@@ -100,38 +95,38 @@
WORKBENCH_ACTION_IDS[i],
action);
}
- IAction action = registry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY);
- actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_GRID_VISIBILITY, action);
+// IAction action = registry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY);
+// actionBars.setGlobalActionHandler( GEFActionConstants.TOGGLE_GRID_VISIBILITY, action);
}
- protected void addRetargetAction(RetargetAction action) {
- actionRegistry.registerAction(action);
- getPage().addPartListener(action);
- }
+// protected void addRetargetAction(RetargetAction action) {
+// actionRegistry.registerAction(action);
+// getPage().addPartListener(action);
+// }
- public void init(IActionBars bars) {
- buildActions();
- super.init(bars);
- }
+// public void init(IActionBars bars) {
+// buildActions();
+// super.init(bars);
+// }
- public void dispose() {
- RetargetAction action = (RetargetAction)actionRegistry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY);
- getPage().removePartListener(action);
- action.dispose();
- actionRegistry.dispose();
- super.dispose();
- }
+// public void dispose() {
+// RetargetAction action = (RetargetAction)actionRegistry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY);
+// getPage().removePartListener(action);
+// action.dispose();
+// actionRegistry.dispose();
+// super.dispose();
+// }
- protected void buildActions() {
- addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY,
- "Show Grid", IAction.AS_CHECK_BOX));
- }
+// protected void buildActions() {
+// addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY,
+// "Show Grid", IAction.AS_CHECK_BOX));
+// }
- public void contributeToMenu(IMenuManager menubar) {
- super.contributeToMenu(menubar);
- MenuManager viewMenu = new MenuManager("View");
- viewMenu.add(actionRegistry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));
- menubar.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu);
- }
+// public void contributeToMenu(IMenuManager menubar) {
+// super.contributeToMenu(menubar);
+// MenuManager viewMenu = new MenuManager("View");
+// viewMenu.add(actionRegistry.getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));
+// menubar.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu);
+// }
}
Index: src/org/jbpm/gd/jpdl/util/ProcessDeployer.java
===================================================================
--- src/org/jbpm/gd/jpdl/util/ProcessDeployer.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/util/ProcessDeployer.java (working copy)
@@ -44,6 +44,7 @@
Shell shell;
IFolder processFolder;
+ IFile processFile;
String serverName;
String serverPort;
String serverDeployer;
@@ -62,6 +63,10 @@
this.processFolder = processFolder;
}
+ public void setProcessFile(IFile file) {
+ this.processFile = file;
+ }
+
public void setServerName(String serverName) {
this.serverName = serverName;
}
@@ -362,11 +367,15 @@
}
private URL[] getProjectClasspathUrls() throws CoreException, MalformedURLException {
+ URL[] urls = new URL[0];
IProject project = processFolder.getProject();
IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null) {
+ return urls;
+ }
String[] pathArray = JavaRuntime
.computeDefaultRuntimeClassPath(javaProject);
- URL[] urls = new URL[pathArray.length];
+ urls = new URL[pathArray.length];
for (int i = 0; i < pathArray.length; i++) {
urls[i] = new File(pathArray[i]).toURI().toURL();
}
Index: src/org/jbpm/gd/jpdl/wizard/ConfigureRuntimePage.java
===================================================================
--- src/org/jbpm/gd/jpdl/wizard/ConfigureRuntimePage.java (revision 22171)
+++ src/org/jbpm/gd/jpdl/wizard/ConfigureRuntimePage.java (working copy)
@@ -32,13 +32,11 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.program.Program;
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.Link;
import org.eclipse.swt.widgets.Text;
public class ConfigureRuntimePage extends WizardPage {
Index: src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java
===================================================================
--- src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java (working copy)
@@ -74,10 +74,9 @@
public boolean performFinish() {
try {
IFolder folder = page.getProcessFolder();
- folder.create(true, true, null);
- IFile processDefinitionFile = folder.getFile("processdefinition.xml");
+ IFile processDefinitionFile = folder.getFile(page.getProcessName() + ".jpdl.xml");
processDefinitionFile.create(createInitialProcessDefinition(), true, null);
- IFile gpdFile = folder.getFile("gpd.xml");
+ IFile gpdFile = folder.getFile("." + page.getProcessName() + ".gpd.xml");
gpdFile.create(createInitialGpdInfo(), true, null);
IDE.openEditor(getActivePage(), processDefinitionFile);
openPropertiesView();
@@ -108,13 +107,11 @@
}
private ByteArrayInputStream createInitialProcessDefinition() throws JavaModelException {
- String parName = page.getProcessFolder().getName();
- String processName = parName; //.substring(0, parName.indexOf(".par"));
StringBuffer buffer = new StringBuffer();
buffer.append("");
buffer.append("\n");
buffer.append("\n");
- buffer.append("");
+ buffer.append("");
return new ByteArrayInputStream(buffer.toString().getBytes());
}
Index: src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizardPage.java
===================================================================
--- src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizardPage.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizardPage.java (working copy)
@@ -24,13 +24,12 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -55,11 +54,11 @@
public class NewProcessDefinitionWizardPage extends WizardPage {
private Text containerText;
- private Text processText;
+ private Text processNameText;
private Button browseButton;
-
+
private IWorkspaceRoot workspaceRoot;
- private String containerName;
+ private String containerName;
public NewProcessDefinitionWizardPage() {
super("Process Definition");
@@ -77,6 +76,12 @@
} else if (IContainer.class.isInstance(object)) {
container = (IContainer)object;
}
+ } else {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = workspaceRoot.getProjects();
+ if (projects != null && projects.length != 0) {
+ container = projects[0];
+ }
}
initContainerName(container);
}
@@ -84,23 +89,13 @@
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = createClientArea(parent);
-// createLabel(composite);
+ createProcessNameField(composite);
createContainerField(composite);
- createProcessField(composite);
setControl(composite);
Dialog.applyDialogFont(composite);
- setPageComplete(false);
+ checkPage();
}
-// private void createLabel(Composite composite) {
-// Label label= new Label(composite, SWT.WRAP);
-// label.setText("Choose a source folder and a process definition name.");
-// GridData gd= new GridData();
-// gd.widthHint= convertWidthInCharsToPixels(80);
-// gd.horizontalSpan= 3;
-// label.setLayoutData(gd);
-// }
-
private Composite createClientArea(Composite parent) {
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
@@ -113,12 +108,12 @@
private void createContainerField(Composite parent) {
Label label = new Label(parent, SWT.NONE);
- label.setText("Source folder : ");
+ label.setText("Source Folder: ");
containerText = new Text(parent, SWT.BORDER);
containerText.setText(containerName);
containerText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- verifyContentsValid();
+ checkPage();
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -132,20 +127,39 @@
});
gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(15);
+ gd.heightHint = 18;
browseButton.setLayoutData(gd);
}
- private void createProcessField(Composite parent) {
+ private void createProcessNameField(Composite parent) {
Label label = new Label(parent, SWT.NONE);
- label.setText("Process name : ");
- processText = new Text(parent, SWT.BORDER);
- processText.addModifyListener(new ModifyListener() {
+ label.setText("Process Name: ");
+ processNameText = new Text(parent, SWT.BORDER);
+ processNameText.setText(findInitialProcessName());
+ processNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- verifyContentsValid();
+ checkPage();
}
});
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- processText.setLayoutData(gd);
+ processNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ new Label(parent, SWT.NONE);
+ }
+
+ private String findInitialProcessName() {
+ String baseName = "process";
+ String result = baseName;
+ if (processExists(result)) {
+ int runner = 1;
+ do {
+ result = baseName + "-" + runner;
+ } while (processExists(result));
+ }
+ return result;
+ }
+
+ private boolean processExists(String name) {
+ IResource resource = workspaceRoot.findMember(new Path(containerName).append(name + ".jpdl.xml"));
+ return resource != null && resource.exists();
}
private void chooseContainer() {
@@ -164,16 +178,7 @@
private ViewerFilter createViewerFilter() {
ViewerFilter filter= new ViewerFilter() {
public boolean select(Viewer viewer, Object parent, Object element) {
- if (!(element instanceof IContainer)) {
- return false;
- }
- boolean isJavaProjectMember = false;
- try {
- isJavaProjectMember = ((IContainer)element).getProject().hasNature(JavaCore.NATURE_ID);
- } catch (CoreException ce) {
- // Ignore
- }
- return isJavaProjectMember;
+ return element instanceof IContainer;
}
};
return filter;
@@ -184,54 +189,51 @@
containerName = (elem == null) ? "" : elem.getFullPath().makeRelative().toString();
}
- private void verifyContentsValid() {
- if (!checkContainerPathValid()) {
- setErrorMessage("Source folder is not valid.");
- setPageComplete(false);
- } else if (isProcessNameEmpty()) {
- setErrorMessage("Enter a name for the process.");
- setPageComplete(false);
- } else if (processExists()){
- setErrorMessage("A process with this name already exists.");
+ private void checkPage() {
+ if (!checkProcessNameText()) return;
+ if (!checkContainerText()) return;
+ }
+
+ private boolean checkContainerText() {
+ if ("".equals(containerText.getText())) {
+ setMessage("Select the source folder or enter its name.");
setPageComplete(false);
+ return false;
+ } else if (!containerExists()) {
+ setMessage("The source folder does not exist and will be created.");
+ setPageComplete(true);
+ return true;
} else {
- setErrorMessage(null);
+ setMessage(null);
setPageComplete(true);
+ return true;
}
}
- private boolean processExists() {
- IPath path = new Path(containerText.getText()).append(getProcessName());
- return workspaceRoot.getFolder(path).exists();
- }
-
- private boolean isProcessNameEmpty() {
- String str = processText.getText();
- return str == null || "".equals(str);
+ private boolean containerExists() {
+ IPath path = new Path(containerText.getText());
+ IResource resource = workspaceRoot.findMember(path);
+ return resource != null && resource.exists();
}
- private boolean checkContainerPathValid() {
- if ("".equals(containerText.getText())) {
+ private boolean checkProcessNameText() {
+ if ("".equals(processNameText.getText())) {
+ setMessage("Enter a name for the process.");
+ setPageComplete(false);
return false;
- }
- IPath path = new Path(containerText.getText());
- IResource resource = workspaceRoot.findMember(path);
- boolean isJavaProject = false;
- try {
- isJavaProject = resource.getProject().hasNature(JavaCore.NATURE_ID);
- } catch (CoreException ce) {
- // Ignore
+ } else {
+ setMessage(null);
+ setPageComplete(true);
+ return true;
}
- return resource.exists() && isJavaProject;
}
- private String getProcessName() {
- return processText.getText(); // + ".par";
+ public IFolder getProcessFolder() {
+ return workspaceRoot.getFolder(new Path(containerText.getText()));
}
- public IFolder getProcessFolder() {
- IPath path = new Path(containerText.getText()).append(getProcessName());
- return workspaceRoot.getFolder(path);
+ public String getProcessName() {
+ return processNameText.getText();
}
}
Index: src/org/jbpm/gd/jpdl/editor/JpdlDeploymenEditorPage.java
===================================================================
--- src/org/jbpm/gd/jpdl/editor/JpdlDeploymenEditorPage.java (revision 0)
+++ src/org/jbpm/gd/jpdl/editor/JpdlDeploymenEditorPage.java (revision 0)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.gd.jpdl.editor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.layout.GridLayout;
+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.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.part.EditorPart;
+import org.jbpm.gd.jpdl.deployment.DeploymentForm;
+
+public class JpdlDeploymenEditorPage extends EditorPart {
+
+ JpdlEditor editor;
+ DeploymentForm deploymentInfoForm;
+
+ public JpdlDeploymenEditorPage(JpdlEditor editor) {
+ this.editor = editor;
+ }
+
+ public void createPartControl(Composite parent) {
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+ ScrolledForm form = toolkit.createScrolledForm(parent);
+ form.setText("Deployment");
+ setPartLayout(form);
+ createForm(toolkit, form.getBody());
+ }
+
+ private void setPartLayout(ScrolledForm form) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ form.getBody().setLayout(layout);
+ }
+
+ private void createForm(FormToolkit toolkit, Composite form) {
+ deploymentInfoForm = new DeploymentForm(toolkit, form, editor);
+ deploymentInfoForm.create();
+ deploymentInfoForm.refresh();
+ }
+
+ public void setFocus() {
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ }
+
+ public void doSaveAs() {
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ setSite(site);
+ setInput(input);
+ }
+
+}
Index: src/org/jbpm/gd/jpdl/editor/JpdlContentProvider.java
===================================================================
--- src/org/jbpm/gd/jpdl/editor/JpdlContentProvider.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/editor/JpdlContentProvider.java (working copy)
@@ -22,7 +22,6 @@
package org.jbpm.gd.jpdl.editor;
import java.io.InputStreamReader;
-import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -32,14 +31,15 @@
import org.dom4j.io.SAXReader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.IFileEditorInput;
import org.jbpm.gd.common.editor.AbstractContentProvider;
import org.jbpm.gd.common.model.SemanticElement;
import org.jbpm.gd.common.notation.Edge;
@@ -47,12 +47,14 @@
import org.jbpm.gd.common.notation.NodeContainer;
import org.jbpm.gd.common.notation.NotationElement;
import org.jbpm.gd.common.notation.RootContainer;
+import org.jbpm.gd.jpdl.Plugin;
import org.jbpm.gd.jpdl.deployment.DeploymentInfo;
import org.jbpm.gd.jpdl.model.NodeElement;
import org.jbpm.gd.jpdl.model.NodeElementContainer;
import org.jbpm.gd.jpdl.model.Transition;
+import org.jbpm.gd.jpdl.prefs.PreferencesConstants;
-public class JpdlContentProvider extends AbstractContentProvider{
+public class JpdlContentProvider extends AbstractContentProvider implements PreferencesConstants {
JpdlEditor jpdlEditor;
@@ -63,6 +65,9 @@
public String getNotationInfoFileName(String semanticInfoFileName) {
if ("processdefinition.xml".equals(semanticInfoFileName)) {
return "gpd.xml";
+ } else if (semanticInfoFileName.endsWith("jpdl.xml")) {
+ int index = semanticInfoFileName.indexOf("jpdl.xml");
+ return "." + semanticInfoFileName.substring(0, index) + "gpd.xml";
} else {
return super.getNotationInfoFileName(semanticInfoFileName);
}
@@ -71,6 +76,9 @@
public String getDiagramImageFileName(String semanticInfoFileName) {
if ("processdefinition.xml".equals(semanticInfoFileName)) {
return "processimage.jpg";
+ } else if (semanticInfoFileName.endsWith("jpdl.xml")) {
+ int index = semanticInfoFileName.indexOf("jpdl.xml");
+ return semanticInfoFileName.substring(0, index) + "jpg";
} else {
return super.getDiagramImageFileName(semanticInfoFileName);
}
@@ -121,43 +129,66 @@
}
private void writeDeploymentInfo(DeploymentInfo deploymentInfo, Element element) {
+ if (deploymentInfo.isEmpty()) return;
Element deploymentElement = addElement(element, "deployment");
- addAttribute(deploymentElement, "serverName", deploymentInfo.getServerName());
- addAttribute(deploymentElement, "serverPort", deploymentInfo.getServerPort());
- addAttribute(deploymentElement, "serverDeployer", deploymentInfo.getServerDeployer());
- Element classesAndResourcesElement = addElement(deploymentElement, "classesAndResources");
+ if (deploymentInfo.getGraphicalInfoFile() != null) {
+ addAttribute(deploymentElement, "graphicalInfoFile", deploymentInfo.getGraphicalInfoFile().getFullPath().toString());
+ }
+ if (deploymentInfo.getImageFile() != null) {
+ addAttribute(deploymentElement, "imageFile", deploymentInfo.getImageFile().getFullPath().toString());
+ }
+ if (deploymentInfo.getServerName() != null) {
+ addAttribute(deploymentElement, "serverName", deploymentInfo.getServerName());
+ }
+ if (deploymentInfo.getServerPort() != null) {
+ addAttribute(deploymentElement, "serverPort", deploymentInfo.getServerPort());
+ }
+ if (deploymentInfo.getServerDeployer() != null) {
+ addAttribute(deploymentElement, "serverDeployer", deploymentInfo.getServerDeployer());
+ }
Object[] classesAndResources = deploymentInfo.getClassesAndResources();
- for (int i = 0; i < classesAndResources.length; i++) {
- Object object = classesAndResources[i];
- String value = null;
- if (object instanceof ICompilationUnit) {
- value = ((ICompilationUnit)object).getResource().getFullPath().toString();
- } else if (object instanceof IResource) {
- value = ((IResource)object).getFullPath().toString();
- }
- if (value != null) {
- Element el = addElement(classesAndResourcesElement, "element");
- addAttribute(el, "value", value);
+ if (classesAndResources.length > 0) {
+ Element classesAndResourcesElement = addElement(deploymentElement, "classesAndResources");
+ for (int i = 0; i < classesAndResources.length; i++) {
+ String value = null;
+ String type = null;
+ if (classesAndResources[i] instanceof ICompilationUnit) {
+ value = ((ICompilationUnit)classesAndResources[i]).getPath().toString();
+ type = "java";
+ } else if (classesAndResources[i] instanceof IClassFile) {
+ value = ((IClassFile)classesAndResources[i]).getHandleIdentifier();
+ type = "class";
+ } else if (classesAndResources[i] instanceof IFile) {
+ value = ((IFile)classesAndResources[i]).getFullPath().toString();
+ type = "file";
+ }
+ if (value != null) {
+ Element el = addElement(classesAndResourcesElement, "element");
+ addAttribute(el, "type", type);
+ addAttribute(el, "value", value);
+ }
}
}
- Element filesAndFoldersElement = addElement(deploymentElement, "filesAndFolders");
- Object[] filesAndFolders = deploymentInfo.getFilesAndFolders();
- for (int i = 0; i < filesAndFolders.length; i++) {
- Object object = filesAndFolders[i];
- if (object instanceof IFile) {
- Element el = addElement(filesAndFoldersElement, "element");
- addAttribute(el, "value", ((IFile)object).getFullPath().toString());
+ Object[] additionalFiles = deploymentInfo.getAdditionalFiles();
+ if (additionalFiles.length > 0) {
+ Element filesAndFoldersElement = addElement(deploymentElement, "additionalFiles");
+ for (int i = 0; i < additionalFiles.length; i++) {
+ if (additionalFiles[i] instanceof IFile) {
+ IFile file = (IFile)additionalFiles[i];
+ Element el = addElement(filesAndFoldersElement, "element");
+ addAttribute(el, "value", file.getFullPath().toString());
+ }
}
}
}
- protected void addDeploymentInfo(DeploymentInfo deploymentInfo, IEditorInput editorInput) {
+ protected void initializeDeploymentInfo(DeploymentInfo deploymentInfo, IEditorInput editorInput) {
try {
- IFile file = getNotationInfoFile(((FileEditorInput)editorInput).getFile());
+ IFile file = getNotationInfoFile(((IFileEditorInput)editorInput).getFile());
// the file should exist as this is performed by the addNotationInfo previously
InputStreamReader reader = new InputStreamReader(file.getContents());
Element rootElement = new SAXReader().read(reader).getRootElement();
- processDeploymentInfo(deploymentInfo, rootElement);
+ processDeploymentInfo(deploymentInfo, rootElement, (IFileEditorInput)editorInput);
} catch (DocumentException e) {
e.printStackTrace();
throw new RuntimeException(e);
@@ -167,66 +198,130 @@
}
}
- protected void processDeploymentInfo(DeploymentInfo deploymentInfo, Element element) {
+ protected void processDeploymentInfo(DeploymentInfo deploymentInfo, Element element, IFileEditorInput editorInput) {
Element deploymentElement = element.element("deployment");
+ processProcessInfoFile(deploymentInfo, deploymentElement, editorInput);
+ processGraphicalInfoFile(deploymentInfo, deploymentElement, editorInput);
+ processImageFile(deploymentInfo, deploymentElement, editorInput);
+ processClassesAndResources(deploymentInfo, deploymentElement, editorInput);
+ processAdditionalFiles(deploymentInfo, deploymentElement, editorInput);
+ processServerInfo(deploymentInfo, deploymentElement, editorInput);
+ }
+
+ protected void processServerInfo(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
if (deploymentElement == null) return;
- processServerName(deploymentInfo, deploymentElement.attribute("serverName"));
- processServerPort(deploymentInfo, deploymentElement.attribute("serverPort"));
- processServerDeployer(deploymentInfo, deploymentElement.attribute("serverDeployer"));
- processClassesAndResources(deploymentInfo, deploymentElement.element("classesAndResources"));
- processFilesAndFolders(deploymentInfo, deploymentElement.element("filesAndFolders"));
+ IPreferenceStore prefs = Plugin.getDefault().getPreferenceStore();
+ processServerName(deploymentInfo, deploymentElement.attribute("serverName"), prefs);
+ processServerPort(deploymentInfo, deploymentElement.attribute("serverPort"), prefs);
+ processServerDeployer(deploymentInfo, deploymentElement.attribute("serverDeployer"), prefs);
+
+ }
+
+ private void processServerName(DeploymentInfo deploymentInfo, Attribute attribute, IPreferenceStore prefs) {
+ if (attribute == null) {
+ deploymentInfo.setServerName(prefs.getString(SERVER_NAME));
+ } else {
+ deploymentInfo.setServerName(attribute.getValue());
+ }
+ }
+
+ private void processServerPort(DeploymentInfo deploymentInfo, Attribute attribute, IPreferenceStore prefs) {
+ if (attribute == null) {
+ deploymentInfo.setServerPort(prefs.getString(SERVER_PORT));
+ } else {
+ deploymentInfo.setServerPort(attribute.getValue());
+ }
+ }
+
+ private void processServerDeployer(DeploymentInfo deploymentInfo, Attribute attribute, IPreferenceStore prefs) {
+ if (attribute == null) {
+ deploymentInfo.setServerDeployer(prefs.getString(SERVER_DEPLOYER));
+ } else {
+ deploymentInfo.setServerDeployer(attribute.getValue());
+ }
}
- protected void processServerName(DeploymentInfo deploymentInfo, Attribute attribute) {
- if (attribute == null) return;
- String value = attribute.getValue();
- if (value == null) return;
- deploymentInfo.setServerName(value);
+ protected void processProcessInfoFile(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
+ deploymentInfo.setProcessInfoFile(editorInput.getFile());
}
- protected void processServerPort(DeploymentInfo deploymentInfo, Attribute attribute) {
- if (attribute == null) return;
- String value = attribute.getValue();
- if (value == null) return;
- deploymentInfo.setServerPort(value);
+ protected void processGraphicalInfoFile(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
+ if (deploymentElement == null) return;
+ Attribute attribute = deploymentElement.attribute("graphicalInfoFile");
+ if (attribute == null) {
+ attribute = deploymentElement.attribute("gpdFile");
+ }
+ IFile graphicalInfoFile = null;
+ if (attribute != null && attribute.getValue() != null) {
+ IResource resource = editorInput.getFile().getWorkspace().getRoot().findMember(new Path(attribute.getValue()));
+ if (resource instanceof IFile) {
+ graphicalInfoFile = (IFile)resource;
+ }
+ }
+ deploymentInfo.setGraphicalInfoFile(graphicalInfoFile);
}
- protected void processServerDeployer(DeploymentInfo deploymentInfo, Attribute attribute) {
- if (attribute == null) return;
- String value = attribute.getValue();
- if (value == null) return;
- deploymentInfo.setServerDeployer(value);
+ protected void processImageFile(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
+ if (deploymentElement == null) return;
+ Attribute attribute = deploymentElement.attribute("imageFile");
+ IFile imageFile = null;
+ if (attribute != null && attribute.getValue() != null) {
+ IResource resource = editorInput.getFile().getWorkspace().getRoot().findMember(new Path(attribute.getValue()));
+ if (resource instanceof IFile) {
+ imageFile = (IFile)resource;
+ }
+ }
+ deploymentInfo.setImageFile(imageFile);
}
- protected void processClassesAndResources(DeploymentInfo deploymentInfo, Element element) {
- if (element == null) return;
- ArrayList classesAndResources = new ArrayList();
- List elements = element.elements("element");
+ @SuppressWarnings("unchecked")
+ protected void processClassesAndResources(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
+ if (deploymentElement == null) return;
+ Element classesAndResourcesElement = deploymentElement.element("classesAndResources");
+ if (classesAndResourcesElement == null) return;
+ List elements = classesAndResourcesElement.elements("element");
for (int i = 0; i < elements.size(); i++) {
- String value = ((Element)elements.get(i)).attributeValue("value");
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(value));
- if (!file.exists()) continue;
- IJavaElement javaElement = JavaCore.create(file);
- if (javaElement != null) {
- classesAndResources.add(javaElement);
- } else {
- classesAndResources.add(file);
+ Element element = (Element)elements.get(i);
+ String type = element.attributeValue("type");
+ String value = element.attributeValue("value");
+ if ("java".equals(type)) {
+ IResource resource = editorInput.getFile().getWorkspace().getRoot().findMember(new Path(value));
+ if (resource instanceof IFile) {
+ IJavaElement javaElement = JavaCore.create((IFile)resource);
+ if (javaElement instanceof ICompilationUnit) {
+ deploymentInfo.addToClassesAndResources(javaElement);
+ }
+ }
+ } else if ("class".equals(type)) {
+ IJavaElement javaElement = JavaCore.create(value);
+ if (javaElement instanceof IClassFile) {
+ deploymentInfo.addToClassesAndResources(javaElement);
+ }
+ } else if ("file".equals(type)) {
+ IResource resource = editorInput.getFile().getWorkspace().getRoot().findMember(new Path(value));
+ if (resource instanceof IFile) {
+ deploymentInfo.addToClassesAndResources(resource);
+ }
}
}
- deploymentInfo.setClassesAndResources(classesAndResources.toArray());
}
- protected void processFilesAndFolders(DeploymentInfo deploymentInfo, Element element) {
- if (element == null) return;
- ArrayList filesAndFolders = new ArrayList();
- List elements = element.elements("element");
+ @SuppressWarnings("unchecked")
+ protected void processAdditionalFiles(DeploymentInfo deploymentInfo, Element deploymentElement, IFileEditorInput editorInput) {
+ if (deploymentElement == null) return;
+ Element additionalFilesElement = deploymentElement.element("additionalFiles");
+ if (additionalFilesElement == null) {
+ additionalFilesElement = deploymentElement.element("filesAndFolders");
+ }
+ if (additionalFilesElement == null) return;
+ List elements = additionalFilesElement.elements("element");
for (int i = 0; i < elements.size(); i++) {
String value = ((Element)elements.get(i)).attributeValue("value");
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(value));
- if (!file.exists()) continue;
- filesAndFolders.add(file);
+ IResource resource = editorInput.getFile().getWorkspace().getRoot().findMember(new Path(value));
+ if (resource instanceof IFile) {
+ deploymentInfo.addToAdditionalFiles(resource);
+ }
}
- deploymentInfo.setFilesAndFolders(filesAndFolders.toArray());
}
Index: src/org/jbpm/gd/jpdl/editor/JpdlDeploymentEditorPage.java
===================================================================
--- src/org/jbpm/gd/jpdl/editor/JpdlDeploymentEditorPage.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/editor/JpdlDeploymentEditorPage.java (working copy)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.gd.jpdl.editor;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.part.EditorPart;
-import org.jbpm.gd.jpdl.deployment.DeploymentForm;
-import org.jbpm.gd.jpdl.deployment.DeploymentInfo;
-
-public class JpdlDeploymentEditorPage extends EditorPart {
-
- JpdlEditor editor;
- DeploymentForm deploymentForm;
-
- public JpdlDeploymentEditorPage(JpdlEditor editor) {
- this.editor = editor;
- }
-
- public void createPartControl(Composite parent) {
- FormToolkit toolkit = new FormToolkit(parent.getDisplay());
- ScrolledForm form = toolkit.createScrolledForm(parent);
- form.setText("Deployment");
- setPartLayout(form);
- createForm(toolkit, form.getBody());
- }
-
- private void setPartLayout(ScrolledForm form) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- form.getBody().setLayout(layout);
- }
-
- private void createForm(FormToolkit toolkit, Composite form) {
- IFolder folder = getProcessFolder();
- deploymentForm = new DeploymentForm(toolkit, form, folder, editor);
- deploymentForm.create();
-// folder.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
-// public void resourceChanged(IResourceChangeEvent event) {
-// deploymentForm.refresh();
-// }
-// });
- }
-
- private IFolder getProcessFolder() {
- IFile file = ((IFileEditorInput)editor.getEditorInput()).getFile();
- if (file.getParent() instanceof IFolder) {
- return (IFolder)file.getParent();
- }
- return null;
- }
-
- public void setFocus() {
- }
-
- public void doSave(IProgressMonitor monitor) {
- }
-
- public DeploymentInfo getDeploymentInfo() {
- return deploymentForm.getDeploymentInfo();
- }
-
- public void setDeploymentInfo(DeploymentInfo deploymentInfo) {
- deploymentForm.setDeploymentInfo(deploymentInfo);
- }
-
- public void doSaveAs() {
- }
-
- public boolean isDirty() {
- return false;
- }
-
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- setSite(site);
- setInput(input);
- }
-
-}
Index: src/org/jbpm/gd/jpdl/editor/JpdlEditor.java
===================================================================
--- src/org/jbpm/gd/jpdl/editor/JpdlEditor.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/editor/JpdlEditor.java (working copy)
@@ -21,20 +21,9 @@
*/
package org.jbpm.gd.jpdl.editor;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.FileEditorInput;
import org.jbpm.gd.common.editor.ContentProvider;
@@ -50,58 +39,28 @@
public class JpdlEditor extends Editor {
- private IResourceChangeListener resourceChangeListener;
- private JpdlDeploymentEditorPage deploymentEditorPage;
+ private JpdlDeploymenEditorPage deploymentInfoEditorPage;
+ private DeploymentInfo deploymentInfo;
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
- initResourceChangeListener();
initPartName();
}
- private void initResourceChangeListener() {
- resourceChangeListener = new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- handleResourceChange(event);
- }
- };
- getWorkspace().addResourceChangeListener(resourceChangeListener);
- }
-
-
- private void handleResourceChange(IResourceChangeEvent event) {
- if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
- IFile file = ((IFileEditorInput)getEditorInput()).getFile();
- if (!file.exists()) {
- deleteProcessFolder(file);
- }
- }
- }
-
- private void deleteProcessFolder(IFile file) {
- final IContainer processFolder = getWorkspace().getRoot().getFolder(file.getFullPath().removeLastSegments(1));
- if (processFolder != null && processFolder.exists()) {
- WorkspaceJob job = new WorkspaceJob("delete") {
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- processFolder.delete(true, null);
- return Status.OK_STATUS;
- }
- };
- job.setRule(getWorkspace().getRuleFactory().deleteRule(processFolder));
- job.schedule();
- }
- }
-
- private IWorkspace getWorkspace() {
- return ((IFileEditorInput)getEditorInput()).getFile().getWorkspace();
- }
-
private void initPartName() {
FileEditorInput fileInput = (FileEditorInput) getEditorInput();
- IPath path = fileInput.getPath().removeLastSegments(1);
- path = path.removeFirstSegments(path.segmentCount() - 1);
- setPartName(path.lastSegment());
+ String fileName = fileInput.getFile().getName();
+ String processName = fileName;
+ if ("processdefinition.xml".equals(fileName)) {
+ IPath path = fileInput.getPath().removeLastSegments(1);
+ path = path.removeFirstSegments(path.segmentCount() - 1);
+ processName = path.lastSegment();
+ } else if (fileName.endsWith(".jpdl.xml")){
+ int index = fileName.indexOf(".jpdl.xml");
+ processName = fileName.substring(0, index);
+ }
+ setPartName(processName);
}
protected SelectionSynchronizer createSelectionSynchronizer() {
@@ -130,15 +89,13 @@
protected void createPages() {
super.createPages();
- initDeploymentPage();
+ initDeploymentInfoPage();
}
- protected void initDeploymentPage() {
- deploymentEditorPage = new JpdlDeploymentEditorPage(this);
- addPage(1, deploymentEditorPage, "Deployment");
- DeploymentInfo deploymentInfo = getDeploymentInfo();
- ((JpdlContentProvider)getContentProvider()).addDeploymentInfo(deploymentInfo, getEditorInput());
- deploymentEditorPage.setDeploymentInfo(deploymentInfo);
+ protected void initDeploymentInfoPage() {
+ ((JpdlContentProvider)getContentProvider()).initializeDeploymentInfo(getDeploymentInfo(), getEditorInput());
+ deploymentInfoEditorPage = new JpdlDeploymenEditorPage(this);
+ addPage(1, deploymentInfoEditorPage, "DeploymentInfo");
}
protected SemanticElement createMainElement() {
@@ -150,12 +107,15 @@
}
public DeploymentInfo getDeploymentInfo() {
- return deploymentEditorPage.getDeploymentInfo();
+ if (deploymentInfo == null) {
+ deploymentInfo = new DeploymentInfo();
+ }
+ return deploymentInfo;
}
-
- public void dispose() {
- getWorkspace().removeResourceChangeListener(resourceChangeListener);
- super.dispose();
+
+ @SuppressWarnings("restriction")
+ public boolean isSaveOnCloseNeeded() {
+ return isDirty() || super.isSaveOnCloseNeeded();
}
}
Index: src/org/jbpm/gd/jpdl/deployment/IncludeFilesTreeContentProvider.java
===================================================================
--- src/org/jbpm/gd/jpdl/deployment/IncludeFilesTreeContentProvider.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/deployment/IncludeFilesTreeContentProvider.java (working copy)
@@ -1,67 +0,0 @@
-package org.jbpm.gd.jpdl.deployment;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.jbpm.gd.jpdl.Logger;
-
-public class IncludeFilesTreeContentProvider implements ITreeContentProvider {
-
- public Object[] getElements(Object parent) {
- if (parent instanceof IFolder) {
- try {
- return ((IFolder) parent).members();
- } catch (CoreException e) {
- Logger.logError(e);
- }
- }
- return new Object[0];
- }
-
- public Object[] getChildren(Object parent) {
- try {
- if (parent instanceof IFolder)
- return ((IFolder) parent).members();
- } catch (CoreException e) {
- Logger.logError(e);
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- if (element != null && element instanceof IResource) {
- return ((IResource) element).getParent();
- }
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof IFolder)
- return getChildren(element).length > 0;
- return false;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- asyncRefresh(viewer);
- }
-
- private void asyncRefresh(final Viewer viewer) {
- Control control = viewer.getControl();
- if (!control.isDisposed()) {
- control.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!viewer.getControl().isDisposed()) {
- viewer.refresh();
- }
- }
- });
- }
- }
-
-}
Index: src/org/jbpm/gd/jpdl/deployment/IncludeInDeploymentTreeViewer.java
===================================================================
--- src/org/jbpm/gd/jpdl/deployment/IncludeInDeploymentTreeViewer.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/deployment/IncludeInDeploymentTreeViewer.java (working copy)
@@ -1,159 +0,0 @@
-package org.jbpm.gd.jpdl.deployment;
-
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.swt.widgets.Tree;
-
-public class IncludeInDeploymentTreeViewer extends CheckboxTreeViewer {
-
- public IncludeInDeploymentTreeViewer(Tree tree) {
- super(tree);
- addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- handleCheckStateChanged(event);
- }
- });
- }
-
- private void handleCheckStateChanged(CheckStateChangedEvent event) {
- updateChecks(event.getElement(), event.getChecked());
- }
-
-// private void handleCheckStateChangedForChildren(Object object, boolean checked) {
-// expandToLevel(object, ALL_LEVELS);
-// setGrayed(object, false);
-// ITreeContentProvider provider = (ITreeContentProvider)getContentProvider();
-// Object[] children = provider.getChildren(object);
-// for (int i = 0; i < children.length; i++) {
-// setChecked(children[i], checked);
-// handleCheckStateChangedForChildren(children[i], checked);
-// }
-// }
-
-// private void handleCheckStateChangedForParent(Object object) {
-// ITreeContentProvider provider = (ITreeContentProvider)getContentProvider();
-// Object parent = provider.getParent(object);
-// if (parent != null) {
-// Object[] children = provider.getChildren(parent);
-// int numberChecked = 0;
-// boolean grayedChildren = false;
-// for (int i = 0; i < children.length; i++) {
-// if (getChecked(children[i])) numberChecked++;
-// if (getGrayed(children[i])) grayedChildren = true;
-// }
-// setChecked(parent, numberChecked > 0);
-// setGrayed(parent, (numberChecked > 0 && numberChecked < children.length) || grayedChildren);
-// handleCheckStateChangedForParent(parent);
-// }
-// }
-
- public boolean setChecked(final Object element, final boolean state) {
- boolean result = super.setChecked(element, state);
- if (result) {
- updateChecks(element, state);
- }
- return result;
- }
-
- public void setCheckedElements(final Object[] elements) {
- super.setCheckedElements(elements);
- for (int i = 0; i < elements.length; i++) {
- updateChecks(elements[i], true);
- }
- }
-
- private void updateChecks(Object object, boolean state) {
- updateChecksForChildren(object, state);
- updateChecksForParents(object, state);
- }
-
- private void updateChecksForChildren(Object object, boolean state) {
- setGrayed(object, false);
- Object[] children = ((ITreeContentProvider)getContentProvider()).getChildren(object);
- for (int i = 0; i < children.length; i++) {
- if (getChecked(children[i]) != state) {
- super.setChecked(children[i], state);
- updateChecksForChildren(children[i], state);
- }
- }
- }
-
- private void updateChecksForParents(Object object, boolean state) {
- ITreeContentProvider provider = (ITreeContentProvider)getContentProvider();
- Object child = object;
- Object parent = provider.getParent(child);
- boolean change = true;
- while (parent != null && change) {
- Object[] siblings = provider.getChildren(parent);
- int numberChecked = 0;
- boolean grayed = false;
- change = false;
- for (int i = 0; i < siblings.length; i++) {
- if (getChecked(siblings[i])) numberChecked++;
- if (getGrayed(siblings[i])) grayed = true;
- }
- if (numberChecked == 0) {
- if (getChecked(parent) || getGrayed(parent)) change = true;
- setGrayChecked(parent, false);
- }
- else if (numberChecked == siblings.length) {
- if (!getChecked(parent) || getGrayed(parent) != grayed) change = true;
- setGrayed(parent, false);
- setChecked(parent, true);
- }
- else {
- if (!getChecked(parent) || !getGrayed(parent)) change = true;
- setGrayChecked(parent, true);
- }
- child = parent;
- parent = provider.getParent(child);
- }
-
- }
-
-// public void updateChecks() {
-// getControl().getDisplay().asyncExec(new Runnable() {
-// public void run() {
-// ITreeContentProvider provider = (ITreeContentProvider)getContentProvider();
-// Object[] elements = provider.getElements(getInput());
-// for (int i = 0; i < elements.length; i++) {
-// updateChecks(provider, elements[i]);
-// }
-// }
-// });
-// }
-
-
-
-// private int[] updateChecks(ITreeContentProvider provider, Object object) {
-// int[] result = new int[2]; // result[0] contains the number of checked, result[1] the number of grayed elements
-// int[] updates = new int[2];
-// Object[] children = provider.getChildren(object);
-// if ((children == null || children.length == 0)) {
-// if (getChecked(object)) result[0]++;
-// } else {
-// for (int i = 0; i < children.length; i++) {
-// int[] runner = updateChecks(provider, children[i]);
-// updates[0] += runner[0];
-// updates[1] += runner[1];
-// }
-// if (updates[0] == children.length && updates[1] == 0) {
-// setChecked(object, true);
-// result[0]++;
-// setGrayed(object, false);
-// } else if (updates[0] > 0 || updates[1] > 0) {
-// setChecked(object, true);
-// result[0]++;
-// setGrayed(object, true);
-// result[1]++;
-// } else {
-// setChecked(object, false);
-// setGrayed(object, false);
-// }
-// }
-// return result;
-// }
-
-}
\ No newline at end of file
Index: src/org/jbpm/gd/jpdl/deployment/DeploymentForm.java
===================================================================
--- src/org/jbpm/gd/jpdl/deployment/DeploymentForm.java (revision 22326)
+++ src/org/jbpm/gd/jpdl/deployment/DeploymentForm.java (working copy)
@@ -21,33 +21,19 @@
*/
package org.jbpm.gd.jpdl.deployment;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
+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.events.SelectionListener;
@@ -55,73 +41,71 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.jbpm.gd.jpdl.Logger;
import org.jbpm.gd.jpdl.Plugin;
import org.jbpm.gd.jpdl.editor.JpdlEditor;
-import org.jbpm.gd.jpdl.util.JavaClassNameCollector;
-import org.jbpm.gd.jpdl.util.ProcessDeployer;
public class DeploymentForm {
-
- public static final int NONE = 0;
- public static final int EXPRESSION = 1;
- public static final int HANDLER = 2;
+ private static ILabelProvider LABELPROVIDER = new WorkbenchLabelProvider();
+
private FormToolkit toolkit;
private Composite composite;
- private IFolder processFolder;
private JpdlEditor editor;
private DeploymentInfo deploymentInfo;
- private Form form;
- private Text nameText;
- private Text portText;
- private Text deployerText;
- private Text locationText;
- private Text usernameText;
- private Text passwordText;
- private Button deployButton;
- private Button saveButton;
- private Button locationButton;
- private Button testConnectionButton;
- private Button saveLocallyButton;
+ private ScrolledForm form;
+
+ private Button includeProcessInfoFileButton;
+ private Text processInfoFileText;
+ private Button includeGraphicalInfoFileButton;
+ private Text graphicalInfoFileText;
+ private Button browseGraphicalInfoFileButton;
+ private Button includeImageFileButton;
+ private Text imageFileText;
+ private Button browseImageFileButton;
+ private Button additionalFilesAddButton;
+ private Button additionalFilesRemoveButton;
+ private Table additionalFilesList;
+ private Button classesAndResourcesAddButton;
+ private Button classesAndResourcesRemoveButton;
+ private Table classesAndResourcesList;
+ private Text serverNameText;
+ private Text serverPortText;
+ private Text serverDeployerText;
private Button useCredentialsButton;
-
- private IncludeInDeploymentTreeViewer includeFilesTreeViewer;
- private IncludeInDeploymentTreeViewer includeClassesTreeViewer;
+ private Text userNameText;
+ private Text passwordText;
- public DeploymentForm(FormToolkit toolkit, Composite composite, IFolder processFolder, JpdlEditor editor) {
+ public DeploymentForm(FormToolkit toolkit, Composite composite, JpdlEditor editor) {
this.toolkit = toolkit;
this.composite = composite;
- this.processFolder = processFolder;
this.editor = editor;
+ deploymentInfo = editor.getDeploymentInfo();
}
public void create() {
createMainForm();
- createIncludeFilesSection();
- createIncludeClassesSection();
- createLocalSaveSection();
+ createMainFilesSection();
+ createAdditionalFilesSection();
+ createClassesAndResourcesSection();
+ createUserCredentialsSection();
createServerInfoSection();
- toolkit.createForm(form.getBody()); // Create an empty grid cell
- createDeployButton();
}
private void createMainForm() {
- form = toolkit.createForm(composite);
+ form = toolkit.createScrolledForm(composite);
GridData layoutData = new GridData(GridData.FILL_BOTH);
form.setLayoutData(layoutData);
GridLayout layout = new GridLayout();
@@ -130,631 +114,546 @@
form.getBody().setLayout(layout);
form.getBody().setLayoutData(new GridData(GridData.FILL_BOTH));
}
-
- private void createDeployButton() {
- deployButton = toolkit.createButton(form.getBody(), "Deploy Process Archive...", SWT.PUSH);
- deployButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- deployButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (cancelOrSaveAndContinue()) {
- createProcessDeployer().deploy();
- }
- }
- });
- }
-
- private IPreferenceStore getPreferenceStore() {
- return Plugin.getDefault().getPreferenceStore();
- }
-
- public DeploymentInfo getDeploymentInfo() {
- if (deploymentInfo == null) {
- deploymentInfo = new DeploymentInfo();
- String serverName = getPreferenceStore().getString("server name");
- deploymentInfo.setServerName(serverName == null ? "localhost" : serverName);
- String serverPort = getPreferenceStore().getString("server port");
- deploymentInfo.setServerPort(serverPort == null ? "8080" : serverPort);
- String serverDeployer = getPreferenceStore().getString("server deployer");
- deploymentInfo.setServerDeployer(serverDeployer == null ? "/jbpm-console/upload" : serverDeployer);
- final IJavaProject project = JavaCore.create(processFolder.getProject());
- deploymentInfo.setClassesAndResources(new ArrayList(getElementsToCheckFor(project)).toArray());
- deploymentInfo.setFilesAndFolders(getElementsToCheckFor(processFolder).toArray());
- }
- return deploymentInfo;
- }
- public void setDeploymentInfo(DeploymentInfo deploymentInfo) {
- this.deploymentInfo = deploymentInfo;
- refresh();
- }
-
- private ProcessDeployer createProcessDeployer() {
- ProcessDeployer result = new ProcessDeployer();
- String location = null;
- if (saveButton.isEnabled()) {
- location = locationText.getText();
- }
- result.setTargetLocation(location);
- result.setServerName(nameText.getText());
- result.setServerPort(portText.getText());
- result.setServerDeployer(deployerText.getText());
- result.setUseCredentials(useCredentialsButton.getSelection());
- if (useCredentialsButton.getSelection()) {
- result.setUsername(usernameText.getText() == null ? "" : usernameText.getText());
- result.setPassword(passwordText.getText() == null ? "" : passwordText.getText());
- }
- result.setShell(form.getShell());
- result.setProcessFolder(processFolder);
- result.setFilesAndFolders(getIncludedFiles());
- result.setClassesAndResources(getClassesAndResources());
- return result;
- }
-
- private ArrayList getIncludedFiles() {
- ArrayList result = new ArrayList();
- Object[] objects = includeFilesTreeViewer.getCheckedElements();
- for (int i = 0; i < objects.length; i++) {
- result.add(objects[i]);
- }
- return result;
- }
-
- private ArrayList getClassesAndResources() {
- ArrayList result = new ArrayList();
- Object[] objects = includeClassesTreeViewer.getCheckedElements();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof ICompilationUnit) {
- String string = getResourceName(((ICompilationUnit)objects[i]).getResource());
- result.add(string.substring(0, string.lastIndexOf(".java")) + ".class");
- } else if (objects[i] instanceof IFile) {
- result.add(getResourceName((IFile)objects[i]));
- }
- }
- return result;
- }
-
- private String getResourceName(IResource resource) {
- IPackageFragmentRoot root = getPackageFragmentRoot(resource);
- if (root == null) {
- return null;
- } else {
- int index = root.getResource().getProjectRelativePath().toString().length() + 1;
- return resource.getProjectRelativePath().toString().substring(index);
- }
- }
-
- private IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
- IPackageFragmentRoot root = null;
- IResource r = resource;
- while (r != null) {
- IJavaElement javaElement = JavaCore.create(r);
- if (javaElement != null && javaElement instanceof IPackageFragmentRoot) {
- root = (IPackageFragmentRoot)javaElement;
- break;
- }
- r = r.getParent();
- }
- return root;
- }
-
- private Composite createServerInfoFormClient() {
- Section serverInfoDetails = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
- serverInfoDetails.marginWidth = 5;
- serverInfoDetails.setText("Deployment Server Settings");
+ private void createMainFilesSection() {
+ Section mainFilesSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
+ mainFilesSection.marginWidth = 5;
+ mainFilesSection.setText("Main Process Files");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.verticalAlignment = GridData.BEGINNING;
- serverInfoDetails.setLayoutData(gridData);
+ gridData.horizontalSpan = 2;
+ mainFilesSection.setLayoutData(gridData);
- Composite infoFormClient = toolkit.createComposite(serverInfoDetails);
- serverInfoDetails.setClient(infoFormClient);
- serverInfoDetails.setDescription("Specify the settings of the server you wish to deploy to.");
- toolkit.paintBordersFor(infoFormClient);
+ Composite mainFilesClient = toolkit.createComposite(mainFilesSection);
+ mainFilesSection.setClient(mainFilesClient);
+ mainFilesSection.setDescription("Check and select the files to be included in the deployment.");
+ toolkit.paintBordersFor(mainFilesClient);
GridLayout layout = new GridLayout();
layout.marginWidth = 2;
layout.marginHeight = 2;
layout.numColumns = 3;
- infoFormClient.setLayout(layout);
- return infoFormClient;
+ mainFilesClient.setLayout(layout);
+ createProcessInfoFileField(mainFilesClient);
+ createGraphicalInfoFileField(mainFilesClient);
+ createImageFileField(mainFilesClient);
}
- private void createServerInfoSection() {
- Composite serverInfoFormClient = createServerInfoFormClient();
- createServerNameField(serverInfoFormClient);
- createServerPortField(serverInfoFormClient);
- createServerDeployerField(serverInfoFormClient);
- createUseCredentialsButton(serverInfoFormClient);
- createUseCredentialsGroup(serverInfoFormClient);
- createTestConnectionButton(serverInfoFormClient);
+ private void createProcessInfoFileField(Composite parent) {
+ includeProcessInfoFileButton = toolkit.createButton(parent, "Process Info File:", SWT.CHECK);
+ includeProcessInfoFileButton.setSelection(true);
+ includeProcessInfoFileButton.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ processInfoFileText = toolkit.createText(parent, "");
+ processInfoFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ processInfoFileText.setEditable(false);
+ toolkit.createLabel(parent, "");
}
-
- private void createLocalSaveSection() {
- Composite localSaveFormClient = createLocalSaveFormClient();
- createSaveLocallyCheckBox(localSaveFormClient);
- createSaveLocationField(localSaveFormClient);
- createSaveButton(localSaveFormClient);
+
+ private void createGraphicalInfoFileField(Composite parent) {
+ includeGraphicalInfoFileButton = toolkit.createButton(parent, "Graphical Info File:", SWT.CHECK);
+ includeGraphicalInfoFileButton.setSelection(true);
+ includeGraphicalInfoFileButton.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ graphicalInfoFileText = toolkit.createText(parent, "");
+ graphicalInfoFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ graphicalInfoFileText.setEditable(false);
+ browseGraphicalInfoFileButton = toolkit.createButton(parent, "Browse...", SWT.NONE);
}
- private void createServerNameField(Composite infoFormClient) {
- Label nameLabel = toolkit.createLabel(infoFormClient, "Server Name:");
- nameLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- nameText = toolkit.createText(infoFormClient, "");
- String nameString = getDeploymentInfo().getServerName();
- nameText.setText(nameString == null ? "localhost" : nameString);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- nameText.setLayoutData(gridData);
- nameText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- updateTestConnectionAndDeployButtons();
- getDeploymentInfo().setServerName(nameText.getText());
- editor.setDirty(true);
- }
- });
- }
-
- private void createServerPortField(Composite infoFormClient) {
- Label portLabel = toolkit.createLabel(infoFormClient, "Server Port:");
- portLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- portText = toolkit.createText(infoFormClient, "");
- String portString = getDeploymentInfo().getServerPort();
- portText.setText(portString == null ? "8080" : portString);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- portText.setLayoutData(gridData);
- portText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- updateTestConnectionAndDeployButtons();
- getDeploymentInfo().setServerPort(portText.getText());
- editor.setDirty(true);
- }
- });
+ private void createImageFileField(Composite parent) {
+ includeImageFileButton = toolkit.createButton(parent, "Image File:", SWT.CHECK);
+ includeImageFileButton.setSelection(true);
+ includeImageFileButton.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ imageFileText = toolkit.createText(parent, "");
+ imageFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ imageFileText.setEditable(false);
+ browseImageFileButton = toolkit.createButton(parent, "Browse...", SWT.NONE);
}
- private void createServerDeployerField(Composite infoFormClient) {
- Label deployerLabel = toolkit.createLabel(infoFormClient, "Server Deployer:");
- deployerLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- deployerText = toolkit.createText(infoFormClient, "");
- String deployerString = deploymentInfo.getServerDeployer();
- deployerText.setText(deployerString == null ? "/jbpm-console/upload" : deployerString);
+ private void createAdditionalFilesSection() {
+ Section additionalFilesSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
+ additionalFilesSection.marginWidth = 5;
+ additionalFilesSection.setText("Additional Files");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- deployerText.setLayoutData(gridData);
- deployerText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- updateTestConnectionAndDeployButtons();
- getDeploymentInfo().setServerDeployer(deployerText.getText());
- editor.setDirty(true);
- }
- });
- }
-
- private void createUserNameField(Composite composite) {
- Label usernameLabel = toolkit.createLabel(composite, "Username:");
- usernameLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- usernameText = toolkit.createText(composite, "", SWT.BORDER);
- String usernameString = Plugin.getDefault().getPreferenceStore().getString("user name");
- usernameText.setText(usernameString == null ? "" : usernameString);
- usernameText.setEnabled(useCredentialsButton.getSelection());
- usernameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// gridData.verticalAlignment = GridData.BEGINNING;
+ additionalFilesSection.setLayoutData(gridData);
+
+ Composite additionalFilesClient = toolkit.createComposite(additionalFilesSection);
+ additionalFilesSection.setClient(additionalFilesClient);
+ additionalFilesSection.setDescription("Add additional files such as forms that need to be included in the deployment.");
+ toolkit.paintBordersFor(additionalFilesClient);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ additionalFilesClient.setLayout(layout);
+ createAdditionalFilesList(additionalFilesClient);
+ createAdditionalFilesButtons(additionalFilesClient);
}
- private void createPasswordField(Composite composite) {
- Label passwordLabel = toolkit.createLabel(composite, "Password:");
- passwordLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- passwordText = toolkit.createText(composite, "", SWT.PASSWORD | SWT.BORDER);
- String passwordString = Plugin.getDefault().getPreferenceStore().getString("password");
- passwordText.setText(passwordString == null ? "" : passwordString);
- passwordText.setEnabled(useCredentialsButton.getSelection());
- passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ private void createAdditionalFilesList(Composite parent) {
+ additionalFilesList = toolkit.createTable(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 70;
+ gridData.widthHint = 100;
+ additionalFilesList.setLayoutData(gridData);
}
- private void createUseCredentialsButton(Composite infoFormClient) {
- useCredentialsButton = toolkit.createButton(infoFormClient, "Use credentials", SWT.CHECK);
- useCredentialsButton.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- useCredentialsButton.setSelection(Plugin.getDefault().getPreferenceStore().getBoolean("use credentials"));
- GridData gridData = new GridData();
- gridData.horizontalSpan = 3;
- useCredentialsButton.setLayoutData(gridData);
- useCredentialsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- usernameText.setEnabled(useCredentialsButton.getSelection());
- passwordText.setEnabled(useCredentialsButton.getSelection());
- }
- });
+ private void createAdditionalFilesButtons(Composite parent) {
+ Composite composite = toolkit.createComposite(parent);
+ composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ composite.setLayout(gridLayout);
+ additionalFilesAddButton = toolkit.createButton(composite, "Add...", SWT.NONE);
+ additionalFilesAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ additionalFilesRemoveButton = toolkit.createButton(composite, "Remove", SWT.NONE);
+ additionalFilesRemoveButton.setEnabled(false);
}
- private void createUseCredentialsGroup(Composite infoFormClient) {
- Composite useCredentialsGroup = toolkit.createComposite(infoFormClient, SWT.BORDER);
+ private void createClassesAndResourcesSection() {
+ Section classesAndResourcesSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
+ classesAndResourcesSection.marginWidth = 5;
+ classesAndResourcesSection.setText("Classes and Resources");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- useCredentialsGroup.setLayoutData(gridData);
- useCredentialsGroup.setLayout(new GridLayout(2, false));
- createUserNameField(useCredentialsGroup);
- createPasswordField(useCredentialsGroup);
- }
-
- private void createTestConnectionButton(Composite infoFormClient) {
- testConnectionButton = toolkit.createButton(infoFormClient, "Test Connection...", SWT.PUSH);
- testConnectionButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- createProcessDeployer().pingServer();
- }
- });
- }
-
- private Composite createIncludeFilesSection() {
- Section includeFilesDetails = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
- includeFilesDetails.marginWidth = 5;
- includeFilesDetails.setText("Files and Folders");
- includeFilesDetails.setLayoutData(new GridData(GridData.FILL_BOTH));
+ classesAndResourcesSection.setLayoutData(gridData);
- Composite includeFilesFormClient = toolkit.createComposite(includeFilesDetails);
- includeFilesDetails.setClient(includeFilesFormClient);
- includeFilesDetails.setDescription("Select the files and folders to include in the process archive.");
- toolkit.paintBordersFor(includeFilesFormClient);
+ Composite classesAndResourcesClient = toolkit.createComposite(classesAndResourcesSection);
+ classesAndResourcesSection.setClient(classesAndResourcesClient);
+ classesAndResourcesSection.setDescription("Add classes and/or resources that need to be included in the deployment.");
+ toolkit.paintBordersFor(classesAndResourcesClient);
GridLayout layout = new GridLayout();
- layout.marginWidth = 2;
- layout.marginHeight = 2;
- layout.numColumns = 1;
- includeFilesFormClient.setLayout(layout);
-
- Tree tree = toolkit.createTree(includeFilesFormClient, SWT.CHECK);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- includeFilesTreeViewer = new IncludeInDeploymentTreeViewer(tree);
- includeFilesTreeViewer.setContentProvider(new IncludeFilesTreeContentProvider());
- includeFilesTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
- includeFilesTreeViewer.setInput(processFolder);
- tree.getDisplay().asyncExec(new Runnable() {
- public void run() {
- includeFilesTreeViewer.setCheckedElements(getDeploymentInfo().getFilesAndFolders());
- }
- });
- includeFilesTreeViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- getDeploymentInfo().setFilesAndFolders(includeFilesTreeViewer.getCheckedElements());
- editor.setDirty(true);
- }
- });
-
- final Button includeFilesDefaultButton = toolkit.createButton(includeFilesFormClient, "Reset Defaults", SWT.PUSH);
- includeFilesDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- includeFilesDefaultButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- includeFilesDefaultButton.getDisplay().asyncExec(new Runnable() {
- public void run() {
- includeFilesTreeViewer.setCheckedElements(getDeploymentInfo().getFilesAndFolders());
- }
- });
- }
- });
-
-
- return includeFilesFormClient;
+ layout.numColumns = 2;
+ classesAndResourcesClient.setLayout(layout);
+ createClassesAndResourcesList(classesAndResourcesClient);
+ createClassesAndResourcesButtons(classesAndResourcesClient);
}
-
- private ArrayList getElementsToCheckFor(IFolder folder) {
- ArrayList list = new ArrayList();
- try {
- IResource[] members = folder.members();
- for (int i = 0; i < members.length; i++) {
- list.add(members[i]);
- if (members[i] instanceof IFolder) {
- list.addAll(getElementsToCheckFor((IFolder)members[i]));
- }
- }
- } catch(CoreException e) {
- Logger.logError(e);
- }
- return list;
+
+ private void createClassesAndResourcesList(Composite parent) {
+ classesAndResourcesList = toolkit.createTable(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
+ gridData.heightHint = 70;
+ gridData.widthHint = 100;
+ classesAndResourcesList.setLayoutData(gridData);
}
- private Set getElementsToCheckFor(IJavaProject project) {
- Set result = new HashSet();
- try {
- if (project != null) {
- Set javaClassNames = JavaClassNameCollector.getJavaClassNames(editor.getProcessDefinition());
- Iterator iterator = javaClassNames.iterator();
- while (iterator.hasNext()) {
- IType type = project.findType((String)iterator.next());
- if (type != null) {
- result.add(type.getCompilationUnit());
- }
- }
- }
- }
- catch (JavaModelException e) {
- Logger.logError(e);
- }
- return result;
+ private void createClassesAndResourcesButtons(Composite parent) {
+ Composite composite = toolkit.createComposite(parent);
+ composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ composite.setLayout(gridLayout);
+
+ classesAndResourcesAddButton = toolkit.createButton(composite, "Add", SWT.NONE);
+ classesAndResourcesAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ classesAndResourcesRemoveButton = toolkit.createButton(composite, "Remove", SWT.NONE);
+ classesAndResourcesRemoveButton.setEnabled(false);
}
- private Composite createIncludeClassesSection() {
- Section includeClassesDetails = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
- includeClassesDetails.marginWidth = 5;
- includeClassesDetails.setText("Java Classes and Resources");
- includeClassesDetails.setLayoutData(new GridData(GridData.FILL_BOTH));
+ private void createUserCredentialsSection() {
+ Section userCredentialsSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
+ userCredentialsSection.marginWidth = 5;
+ userCredentialsSection.setText("User Credentials");
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ userCredentialsSection.setLayoutData(gridData);
- Composite includeClassesFormClient = toolkit.createComposite(includeClassesDetails);
- includeClassesDetails.setClient(includeClassesFormClient);
- includeClassesDetails.setDescription("Select the Java classes and resources to include in the process archive.");
- toolkit.paintBordersFor(includeClassesFormClient);
+ Composite userCredentialsClient = toolkit.createComposite(userCredentialsSection);
+ userCredentialsSection.setClient(userCredentialsClient);
+ userCredentialsSection.setDescription("Specify the user credentials for the chosen server.");
+ toolkit.paintBordersFor(userCredentialsClient);
GridLayout layout = new GridLayout();
- layout.marginWidth = 2;
- layout.marginHeight = 2;
- layout.numColumns = 1;
- includeClassesFormClient.setLayout(layout);
-
- Tree tree = toolkit.createTree(includeClassesFormClient, SWT.CHECK);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ layout.numColumns = 2;
+ userCredentialsClient.setLayout(layout);
- includeClassesTreeViewer = new IncludeInDeploymentTreeViewer(tree);
- includeClassesTreeViewer.setContentProvider(new IncludeClassesTreeContentProvider());
- includeClassesTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
- final IJavaProject project = JavaCore.create(processFolder.getProject());
- if (project != null) {
- includeClassesTreeViewer.setInput(project);
- }
- composite.getDisplay().asyncExec(new Runnable() {
- public void run() {
- includeClassesTreeViewer.setCheckedElements(getDeploymentInfo().getClassesAndResources());
- }
- });
- includeClassesTreeViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- getDeploymentInfo().setClassesAndResources(includeClassesTreeViewer.getCheckedElements());
- editor.setDirty(true);
- }
- });
-
- final Button includeClassesDefaultButton = toolkit.createButton(includeClassesFormClient, "Reset Defaults", SWT.PUSH);
- includeClassesDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- includeClassesDefaultButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- composite.getDisplay().asyncExec(new Runnable() {
- public void run() {
- includeClassesTreeViewer.setCheckedElements(getDeploymentInfo().getClassesAndResources());
- }
- });
- }
- });
+ useCredentialsButton = toolkit.createButton(userCredentialsClient, "Use credentials", SWT.CHECK);
+ useCredentialsButton.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ GridData buttonData = new GridData();
+ buttonData.horizontalSpan = 2;
+ useCredentialsButton.setLayoutData(buttonData);
- return includeClassesFormClient;
+ Label userNameLabel = toolkit.createLabel(userCredentialsClient, "Username:");
+ userNameLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ userNameText = toolkit.createText(userCredentialsClient, "");
+ userNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label passwordLabel = toolkit.createLabel(userCredentialsClient, "Password:");
+ passwordLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ passwordText = toolkit.createText(userCredentialsClient, "", SWT.PASSWORD);
+ passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
- private Composite createLocalSaveFormClient() {
- Section httpInfoDetails = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
- httpInfoDetails.marginWidth = 5;
- httpInfoDetails.setText("Local Save Settings");
+ private void createServerInfoSection() {
+ Section serverInfoSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.DESCRIPTION);
+ serverInfoSection.marginWidth = 5;
+ serverInfoSection.setText("Server Settings");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.verticalAlignment = GridData.BEGINNING;
- httpInfoDetails.setLayoutData(gridData);
+ serverInfoSection.setLayoutData(gridData);
- Composite detailClient = toolkit.createComposite(httpInfoDetails);
- httpInfoDetails.setClient(detailClient);
- httpInfoDetails.setDescription("Choose if and where you wish to save the process archive locally.");
- toolkit.paintBordersFor(detailClient);
+ Composite serverInfoClient = toolkit.createComposite(serverInfoSection);
+ serverInfoSection.setClient(serverInfoClient);
+ serverInfoSection.setDescription("Specify the settings of the server you wish to deploy to.");
+ toolkit.paintBordersFor(serverInfoClient);
GridLayout layout = new GridLayout();
- layout.marginWidth = 2;
- layout.marginHeight = 2;
- layout.numColumns = 3;
- detailClient.setLayout(layout);
- return detailClient;
+ layout.numColumns = 2;
+ serverInfoClient.setLayout(layout);
+
+ Label serverNameLabel = toolkit.createLabel(serverInfoClient, "Server Name:");
+ serverNameLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ serverNameText = toolkit.createText(serverInfoClient, "");
+ serverNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label serverPortLabel = toolkit.createLabel(serverInfoClient, "Server Port:");
+ serverPortLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ serverPortText = toolkit.createText(serverInfoClient, "");
+ serverPortText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label serverDeployerLabel = toolkit.createLabel(serverInfoClient, "Server Deployer:");
+ serverDeployerLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ serverDeployerText = toolkit.createText(serverInfoClient, "");
+ serverDeployerText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
-
- private void createSaveLocallyCheckBox(Composite localSaveFormclient) {
- saveLocallyButton = toolkit.createButton(localSaveFormclient, "Save Process Archive Locally", SWT.CHECK);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- saveLocallyButton.setLayoutData(gridData);
- saveLocallyButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean selection = ((Button)e.widget).getSelection();
- locationText.setEditable(selection);
- locationButton.setEnabled(selection);
- updateSaveAndDeployButtons(selection);
- }
- });
+
+ public void refresh() {
+ unhookListeners();
+ updateControls();
+ hookListeners();
+ }
+
+ private void unhookListeners() {
+ includeGraphicalInfoFileButton.removeSelectionListener(includeGraphicalInfoFileButtonSelectionListener);
+ browseGraphicalInfoFileButton.removeSelectionListener(browseGraphicalInfoFileButtonSelectionListener);
+ includeImageFileButton.removeSelectionListener(includeImageFileButtonSelectionListener);
+ browseImageFileButton.removeSelectionListener(browseImageFileButtonSelectionListener);
+ additionalFilesList.removeSelectionListener(additionalFilesListSelectionListener);
+ additionalFilesAddButton.removeSelectionListener(additionaFilesAddButtonSelectionListener);
+ additionalFilesRemoveButton.removeSelectionListener(additionaFilesRemoveButtonSelectionListener);
+ classesAndResourcesList.removeSelectionListener(classesAndResourcesListSelectionListener);
+ classesAndResourcesAddButton.removeSelectionListener(classesAndResourcesAddButtonSelectionListener);
+ classesAndResourcesRemoveButton.removeSelectionListener(classesAndResourcesRemoveButtonSelectionListener);
+ serverNameText.removeModifyListener(serverNameTextListener);
+ serverPortText.removeModifyListener(serverPortTextListener);
+ serverDeployerText.removeModifyListener(serverDeployerTextListener);
}
- private void updateSaveAndDeployButtons(boolean selection) {
- if (!selection) {
- deployButton.setEnabled(testConnectionButton.isEnabled());
- saveButton.setEnabled(false);
- } else {
- if (notEmpty(locationText)) {
- saveButton.setEnabled(true);
- deployButton.setEnabled(testConnectionButton.isEnabled());
- } else {
- saveButton.setEnabled(false);
- deployButton.setEnabled(false);
- }
+ private void updateControls() {
+ updateProcessInfoFileControls();
+ updateGraphicalInfoFileControls();
+ updateImageFileControls();
+ updateAdditionalFilesControls();
+ updateClassesAndResourcesControls();
+ updateUseCredentialsControls();
+ updateServerInfoControls();
+ }
+
+ private void updateProcessInfoFileControls() {
+ IFile processInfoFile = deploymentInfo.getProcessInfoFile();
+ String value = "";
+ if (processInfoFile != null) {
+ value = processInfoFile.getFullPath().toString();
}
+ includeProcessInfoFileButton.setSelection(!"".equals(value));
+ includeProcessInfoFileButton.setEnabled(false);
+ processInfoFileText.setText(value);
}
- private boolean notEmpty(Text text) {
- String string = text.getText();
- return string != null && !"".equals(string);
+ private void updateGraphicalInfoFileControls() {
+ IFile graphicalInfoFile = deploymentInfo.getGraphicalInfoFile();
+ String value = "";
+ if (graphicalInfoFile != null) {
+ value = graphicalInfoFile.getFullPath().toString();
+ }
+ includeGraphicalInfoFileButton.setSelection(graphicalInfoFile != null);
+ graphicalInfoFileText.setText(value);
+ browseGraphicalInfoFileButton.setEnabled(graphicalInfoFile != null);
}
- private void updateTestConnectionAndDeployButtons() {
- if (notEmpty(nameText) && notEmpty(portText) && notEmpty(deployerText)) {
- testConnectionButton.setEnabled(true);
- if (saveLocallyButton.getSelection()) {
- deployButton.setEnabled(saveButton.isEnabled());
- } else {
- deployButton.setEnabled(true);
+ private void updateImageFileControls() {
+ IFile imageFile = deploymentInfo.getImageFile();
+ String value = "";
+ if (imageFile != null) {
+ value = imageFile.getFullPath().toString();
+ }
+ includeImageFileButton.setSelection(imageFile != null);
+ imageFileText.setText(value);
+ browseImageFileButton.setEnabled(imageFile != null);
+ }
+
+ private void updateAdditionalFilesControls() {
+ Object[] additionalFiles = deploymentInfo.getAdditionalFiles();
+ for (Object object : additionalFiles) {
+ if (object instanceof IFile) {
+ IFile file = (IFile)object;
+ TableItem tableItem = new TableItem(additionalFilesList, SWT.NULL);
+ tableItem.setText(LABELPROVIDER.getText(file) + " (" + file.getFullPath() + ")");
+ tableItem.setImage(LABELPROVIDER.getImage(file));
+ tableItem.setData(object);
}
- } else {
- testConnectionButton.setEnabled(false);
- deployButton.setEnabled(false);
}
}
- private void createSaveLocationField(Composite localSaveFormclient) {
- Label locationLabel = toolkit.createLabel(localSaveFormclient, "Location:");
- locationLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- locationText = toolkit.createText(localSaveFormclient, "");
- locationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- locationText.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- updateSaveAndDeployButtons(true);
+ private void updateClassesAndResourcesControls() {
+ Object[] classesAndResources = deploymentInfo.getClassesAndResources();
+ for (Object object : classesAndResources) {
+ IPath path = null;
+ if (object instanceof IFile) {
+ path = ((IFile)object).getFullPath();
+ } else if (object instanceof ICompilationUnit) {
+ path = ((ICompilationUnit)object).getPath();
+ } else if (object instanceof IClassFile) {
+ path = ((IClassFile)object).getPath();
}
- });
- locationText.setEditable(false);
- locationButton = toolkit.createButton(localSaveFormclient, "Search...", SWT.PUSH);
- locationButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- searchLocation();
+ if (path != null) {
+ TableItem tableItem = new TableItem(classesAndResourcesList, SWT.NULL);
+ tableItem.setData(object);
+ tableItem.setText(LABELPROVIDER.getText(object) + " (" + path + ")");
+ tableItem.setImage(LABELPROVIDER.getImage(object));
}
- });
- locationButton.setEnabled(false);
+ }
}
- private void searchLocation() {
- FileDialog dialog = new FileDialog(form.getShell(), SWT.OPEN);
- String result = dialog.open();
- if (result != null) {
- locationText.setText(result);
- updateSaveAndDeployButtons(true);
+ private void updateUseCredentialsControls() {
+ boolean useCredentials = deploymentInfo.getUseCredentials();
+ useCredentialsButton.setSelection(useCredentials);
+ String userName = deploymentInfo.getUserName();
+ if (userName != null) {
+ userNameText.setText(userName);
+ }
+ userNameText.setEnabled(useCredentials);
+ String password = deploymentInfo.getPassword();
+ if (password != null) {
+ passwordText.setText(password);
+ }
+ passwordText.setEnabled(useCredentials);
+ }
+
+ private void updateServerInfoControls() {
+ String serverName = deploymentInfo.getServerName();
+ if (serverName != null) {
+ serverNameText.setText(serverName);
+ }
+ String serverPort = deploymentInfo.getServerPort();
+ if (serverPort != null) {
+ serverPortText.setText(serverPort);
+ }
+ String serverDeployer = deploymentInfo.getServerDeployer();
+ if (serverDeployer != null) {
+ serverDeployerText.setText(serverDeployer);
}
}
- private void createSaveButton(Composite localSaveFormClient) {
- saveButton = toolkit.createButton(localSaveFormClient, "Save Without Deploying...", SWT.PUSH);
- GridData gridData = new GridData();
- gridData.horizontalSpan = 3;
- gridData.horizontalAlignment = SWT.BEGINNING;
- saveButton.setLayoutData(gridData);
- saveButton.setEnabled(false);
- saveButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- if (cancelOrSaveAndContinue()) {
- createProcessDeployer().saveWithoutDeploying();
- }
- }
- });
+ private void hookListeners() {
+ includeGraphicalInfoFileButton.addSelectionListener(includeGraphicalInfoFileButtonSelectionListener);
+ browseGraphicalInfoFileButton.addSelectionListener(browseGraphicalInfoFileButtonSelectionListener);
+ includeImageFileButton.addSelectionListener(includeImageFileButtonSelectionListener);
+ browseImageFileButton.addSelectionListener(browseImageFileButtonSelectionListener);
+ additionalFilesList.addSelectionListener(additionalFilesListSelectionListener);
+ additionalFilesAddButton.addSelectionListener(additionaFilesAddButtonSelectionListener);
+ additionalFilesRemoveButton.addSelectionListener(additionaFilesRemoveButtonSelectionListener);
+ classesAndResourcesList.addSelectionListener(classesAndResourcesListSelectionListener);
+ classesAndResourcesAddButton.addSelectionListener(classesAndResourcesAddButtonSelectionListener);
+ classesAndResourcesRemoveButton.addSelectionListener(classesAndResourcesRemoveButtonSelectionListener);
+ serverNameText.addModifyListener(serverNameTextListener);
+ serverPortText.addModifyListener(serverPortTextListener);
+ serverDeployerText.addModifyListener(serverDeployerTextListener);
+ useCredentialsButton.addSelectionListener(useCredentialsButtonSelectionListener);
}
-// public void refresh(final ArrayList objectsToRefresh) {
-// form.getDisplay().asyncExec(new Runnable() {
-// public void run() {
-// refreshIncludeClassesTreeViewer(objectsToRefresh);
-// refreshIncludeFilesTreeViewer(objectsToRefresh);
-// }
-// });
-// }
+ private SelectionListener useCredentialsButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ userNameText.setEnabled(useCredentialsButton.getSelection());
+ passwordText.setEnabled(useCredentialsButton.getSelection());
+ }
+ };
+
+ private ModifyListener serverNameTextListener = new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ deploymentInfo.setServerName(serverNameText.getText());
+ editor.setDirty(true);
+ }
+ };
+
+ private ModifyListener serverPortTextListener = new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ deploymentInfo.setServerPort(serverPortText.getText());
+ editor.setDirty(true);
+ }
+ };
-// private void refreshIncludeFilesTreeViewer(ArrayList objectsToRefresh) {
-// Object[] elements = includeFilesTreeViewer.getCheckedElements();
-// includeFilesTreeViewer.refresh();
-// includeFilesTreeViewer.setCheckedElements(elements);
-// IWorkspaceRoot root = processFolder.getWorkspace().getRoot();
-// for (int i = 0; i < objectsToRefresh.size(); i++) {
-// IPath path = (IPath)objectsToRefresh.get(i);
-// if (root.getFile(path).exists()) {
-// includeFilesTreeViewer.setChecked(root.getFile(path), true);
-// } else if (root.getFolder(path).exists()) {
-// includeFilesTreeViewer.setChecked(root.getFolder(path), true);
-// }
-// }
-// }
+ private ModifyListener serverDeployerTextListener = new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ deploymentInfo.setServerDeployer(serverDeployerText.getText());
+ editor.setDirty(true);
+ }
+ };
-// private void refreshIncludeClassesTreeViewer(ArrayList objectsToRefresh) {
-// Set referencedJavaClassNames = null;
-// Object[] elements = includeClassesTreeViewer.getCheckedElements();
-// includeClassesTreeViewer.refresh();
-// includeClassesTreeViewer.setCheckedElements(elements);
-// IWorkspaceRoot root = processFolder.getWorkspace().getRoot();
-// for (int i = 0; i < objectsToRefresh.size(); i++) {
-// IPath path = (IPath)objectsToRefresh.get(i);
-// IJavaElement javaElement = JavaCore.create(root.getFile(path));
-// if (javaElement != null && javaElement instanceof ICompilationUnit) {
-// if (referencedJavaClassNames == null) {
-// referencedJavaClassNames = JavaClassNameCollector.getJavaClassNames(editor.getProcessDefinition());
-// }
-// String name = getTypeName((ICompilationUnit)javaElement);
-// boolean checkNeeded = referencedJavaClassNames.contains(name);
-// includeClassesTreeViewer.setChecked(javaElement, checkNeeded);
-// }
-// }
-// }
+ private SelectionListener includeGraphicalInfoFileButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ boolean include = includeGraphicalInfoFileButton.getSelection();
+ browseGraphicalInfoFileButton.setEnabled(include);
+ if (include && graphicalInfoFileText.getData() != null) {
+ deploymentInfo.setGraphicalInfoFile((IFile)graphicalInfoFileText.getData());
+ } else {
+ deploymentInfo.setGraphicalInfoFile(null);
+ }
+ editor.setDirty(true);
+ }
+ };
- private String getTypeName(ICompilationUnit unit) {
- try {
- IType[] types = unit.getTypes();
- if (types.length > 0) {
- return types[0].getFullyQualifiedName();
- }
- } catch (JavaModelException e) {
- Logger.logError(e);
+ private SelectionListener includeImageFileButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ boolean include = includeImageFileButton.getSelection();
+ browseImageFileButton.setEnabled(include);
+ if (include && imageFileText.getData() != null) {
+ deploymentInfo.setImageFile((IFile)imageFileText.getData());
+ } else {
+ deploymentInfo.setImageFile(null);
}
- return null;
- }
+ editor.setDirty(true);
+ }
+ };
- private boolean cancelOrSaveAndContinue() {
- IEditorPart editor = getEditorPart();
- boolean result = true;
- if (editor.isDirty()) {
- int saveProceedCancel = openSaveProceedCancelDialog();
- if (saveProceedCancel == 2) {
- result = false;
- } else if (saveProceedCancel == 0) {
- editor.doSave(null);
+ private SelectionListener browseGraphicalInfoFileButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(null, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle("Graphical Info File Selection");
+ dialog.setMessage("Select the graphical info file.");
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setValidator(fileSelectionStatusValidator);
+ dialog.open();
+ if (dialog.getFirstResult() != null && dialog.getFirstResult() instanceof IFile) {
+ IFile file = (IFile)dialog.getFirstResult();
+ graphicalInfoFileText.setText(file.getFullPath().toString());
+ graphicalInfoFileText.setData(file);
+ deploymentInfo.setGraphicalInfoFile(file);
+ editor.setDirty(true);
}
}
- return result;
- }
-
- private int openSaveProceedCancelDialog() {
- MessageDialog dialog = new MessageDialog(
- getWorkBenchWindow().getShell(),
- "Save Resource",
- null,
- "'" + processFolder.getName() + "' has been modified. Save changes before deploying?",
- MessageDialog.QUESTION,
- new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL},
- 0);
- return dialog.open();
-
- }
+ };
- private IWorkbenchWindow getWorkBenchWindow() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- }
+ private SelectionListener browseImageFileButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(null, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle("Image File Selection");
+ dialog.setMessage("Select the image file.");
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setValidator(fileSelectionStatusValidator);
+ dialog.open();
+ if (dialog.getFirstResult() != null && dialog.getFirstResult() instanceof IFile) {
+ IFile file = (IFile)dialog.getFirstResult();
+ imageFileText.setText(file.getFullPath().toString());
+ imageFileText.setData(file);
+ deploymentInfo.setImageFile(file);
+ editor.setDirty(true);
+ }
+ }
+ };
- private IEditorPart getEditorPart() {
- return getWorkBenchWindow().getActivePage().getActiveEditor();
- }
+ private SelectionListener additionalFilesListSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ additionalFilesRemoveButton.setEnabled(additionalFilesList.getSelectionCount() > 0);
+ }
+ };
- public void refresh() {
- if (composite.isDisposed()) return;
- nameText.setText(getDeploymentInfo().getServerName());
- portText.setText(getDeploymentInfo().getServerPort());
- deployerText.setText(getDeploymentInfo().getServerDeployer());
- composite.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!includeClassesTreeViewer.getTree().isDisposed()) {
- includeClassesTreeViewer.refresh();
- includeClassesTreeViewer.setCheckedElements(getDeploymentInfo().getClassesAndResources());
+ private SelectionListener additionaFilesAddButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(null, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle("Additional File Selection");
+ dialog.setMessage("Select the additional file.");
+ dialog.setAllowMultiple(false);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setValidator(fileSelectionStatusValidator);
+ dialog.open();
+ if (dialog.getFirstResult() != null && dialog.getFirstResult() instanceof IFile) {
+ IFile file = (IFile)dialog.getFirstResult();
+ TableItem tableItem = new TableItem(additionalFilesList, SWT.NULL);
+ tableItem.setText(LABELPROVIDER.getText(file) + " (" + file.getFullPath() + ")");
+ tableItem.setImage(LABELPROVIDER.getImage(file));
+ deploymentInfo.addToAdditionalFiles(file);
+ editor.setDirty(true);
+ }
+ }
+ };
+
+ private ISelectionStatusValidator fileSelectionStatusValidator =
+ new ISelectionStatusValidator() {
+ public IStatus validate(Object[] arg0) {
+ if (arg0.length == 1 && arg0[0] instanceof IFile) {
+ return new Status(IStatus.OK, Plugin.getDefault().getBundle().getSymbolicName(), "Press OK to confirm.");
+ } else {
+ return new Status(IStatus.ERROR, Plugin.getDefault().getBundle().getSymbolicName(), "Select a single file.");
}
- }
- });
- composite.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!includeFilesTreeViewer.getTree().isDisposed()) {
- includeFilesTreeViewer.refresh();
- includeFilesTreeViewer.setCheckedElements(getDeploymentInfo().getFilesAndFolders());
+ }
+ };
+
+ private SelectionListener additionaFilesRemoveButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ int[] indices = additionalFilesList.getSelectionIndices();
+ if (indices.length > 0) {
+ TableItem tableItem = additionalFilesList.getItem(indices[0]);
+ Object object = tableItem.getData();
+ deploymentInfo.removeFromAdditionalFiles(object);
+ additionalFilesList.remove(indices[0]);
+ editor.setDirty(true);
+ }
+ }
+ };
+
+ private SelectionListener classesAndResourcesListSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ classesAndResourcesRemoveButton.setEnabled(classesAndResourcesList.getSelectionCount() > 0);
+ }
+ };
+
+ private SelectionListener classesAndResourcesAddButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(null, new JavaElementLabelProvider(), new ClassesAndResourcesContentProvider());
+ dialog.setTitle("Classes and Resources Selection");
+ dialog.setAllowMultiple(false);
+ dialog.setMessage("Select a class or resouce.");
+ dialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
+ dialog.setValidator(classesAndResourcesSelectionStatusValidator);
+ dialog.open();
+ if (dialog.getFirstResult() != null) { //&& dialog.getFirstResult() instanceof IFile) {
+ IPath path = null;
+ if (dialog.getFirstResult() instanceof IFile) {
+ path = ((IFile)dialog.getFirstResult()).getFullPath();
+ } else if (dialog.getFirstResult() instanceof ICompilationUnit) {
+ path = ((ICompilationUnit)dialog.getFirstResult()).getPath();
+ } else if (dialog.getFirstResult() instanceof IClassFile) {
+ path = ((IClassFile)dialog.getFirstResult()).getPath();
}
- }
- });
- }
+ if (path != null) {
+ TableItem tableItem = new TableItem(classesAndResourcesList, SWT.NULL);
+ tableItem.setData(dialog.getFirstResult());
+ tableItem.setText(LABELPROVIDER.getText(dialog.getFirstResult()) + " (" + path + ")");
+ tableItem.setImage(LABELPROVIDER.getImage(dialog.getFirstResult()));
+ deploymentInfo.addToClassesAndResources(dialog.getFirstResult());
+ editor.setDirty(true);
+ }
+ }
+ }
+ };
+
+ private ISelectionStatusValidator classesAndResourcesSelectionStatusValidator =
+ new ISelectionStatusValidator() {
+ public IStatus validate(Object[] arg0) {
+ if (arg0.length == 1 && (arg0[0] instanceof IFile || arg0[0] instanceof ICompilationUnit || arg0[0] instanceof IClassFile)) {
+ return new Status(IStatus.OK, Plugin.getDefault().getBundle().getSymbolicName(), "Press OK to confirm.");
+ } else {
+ return new Status(IStatus.ERROR, Plugin.getDefault().getBundle().getSymbolicName(), "Select a single file.");
+ }
+ }
+ };
+
+ private SelectionListener classesAndResourcesRemoveButtonSelectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ int[] indices = classesAndResourcesList.getSelectionIndices();
+ if (indices.length > 0) {
+ TableItem tableItem = classesAndResourcesList.getItem(indices[0]);
+ Object object = tableItem.getData();
+ deploymentInfo.removeFromClassesAndResources(object);
+ classesAndResourcesList.remove(indices[0]);
+ }
+ }
+ };
}
Index: src/org/jbpm/gd/jpdl/deployment/DeploymentInfo.java
===================================================================
--- src/org/jbpm/gd/jpdl/deployment/DeploymentInfo.java (revision 21244)
+++ src/org/jbpm/gd/jpdl/deployment/DeploymentInfo.java (working copy)
@@ -2,16 +2,48 @@
import java.util.ArrayList;
-import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.jbpm.gd.jpdl.Plugin;
+import org.jbpm.gd.jpdl.prefs.PreferencesConstants;
-public class DeploymentInfo {
+public class DeploymentInfo implements PreferencesConstants {
+ private IFile processInfoFile = null;
+ private IFile graphicalInfoFile = null;
+ private IFile imageFile = null;
private String serverName = null;
private String serverPort = null;
private String serverDeployer = null;
- private IFolder processFolder = null;
- private Object[] classesAndResources = null;
- private Object[] filesAndFolders = null;
+ private ArrayList