Author: koen.aers(a)jboss.com
Date: 2009-05-19 15:40:06 -0400 (Tue, 19 May 2009)
New Revision: 15353
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.classpath
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.project
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/org.eclipse.jdt.core.prefs
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/build.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Constants.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/DefaultPage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallation.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationLabelProvider.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationTableContentProvider.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementDialog.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementLabelProvider.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationTableContentProvider.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/AutoResizeTableLayout.java
Log:
plugin to hold commonalities between jbpm 3 and jbpm 4 tools
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.classpath
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.classpath (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.classpath 2009-05-19 19:40:06 UTC (rev
15353)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.project
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.project (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.project 2009-05-19 19:40:06 UTC (rev
15353)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.jbpm.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/org.eclipse.jdt.core.prefs 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,7 @@
+#Thu May 14 20:44:34 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: jPDL Integration Tools
+Bundle-SymbolicName: org.jboss.tools.jbpm.common;singleton:=true
+Bundle-Version: 1.0.0.CR1
+Bundle-Vendor: JBoss, a Division of Red Hat
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.jface;bundle-version="3.4.2",
+ org.eclipse.ui;bundle-version="3.4.2",
+ org.eclipse.core.runtime;bundle-version="3.4.0"
+Export-Package: org.jboss.tools.jbpm.preferences,
+ org.jboss.tools.jbpm.util
+Bundle-Activator: org.jboss.tools.jbpm.Activator
+Bundle-ActivationPolicy: lazy
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/build.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/build.properties
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/build.properties 2009-05-19 19:40:06
UTC (rev 15353)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/plugin.xml (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/plugin.xml 2009-05-19 19:40:06 UTC (rev
15353)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.jboss.tools.jbpm.preferences.DefaultPage"
+ id="org.jboss.tools.jbpm"
+ name="JBoss jBPM"/>
+ </extension>
+
+</plugin>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,18 @@
+package org.jboss.tools.jbpm;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class Activator extends AbstractUIPlugin {
+
+ private static Activator activator;
+
+ public static Activator getDefault() {
+ return activator;
+ }
+
+ public Activator() {
+ super();
+ activator = this;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Constants.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Constants.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Constants.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,29 @@
+/*
+ * 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.jboss.tools.jbpm;
+
+
+public interface Constants {
+
+ public static final String JBPM_NAME = "jbpm-name";
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Constants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,237 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.swt.SWT;
+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.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.jbpm.Activator;
+
+public abstract class AddJbpmInstallationDialog extends StatusDialog {
+
+ private static final String pluginId =
Activator.getDefault().getBundle().getSymbolicName();
+
+ private static final IStatus enterNameStatus = new Status(
+ Status.INFO, pluginId, 0, "Enter the name of the jBPM installation.",
null);
+ private static final IStatus enterLocationStatus = new Status(
+ Status.INFO, pluginId, 0, "Enter the location of the jBPM installation.",
null);
+ private static final IStatus unExistingLocationStatus = new Status(
+ Status.ERROR, pluginId, 0, "The location does not exist.", null);
+ private static final IStatus nameAlreadyUsedStatus = new Status(
+ Status.ERROR, pluginId, 0, "The name is already used.", null);
+ private static final IStatus inValidJbpmInstallationStatus = new Status(
+ Status.ERROR, pluginId, 0, "This is not a valid jBPM installation.", null);
+
+ String title;
+ Text nameText, locationText;
+ Button locationButton;
+
+ IStatus currentStatus = enterNameStatus;
+
+ String name, location;
+ IStatus status;
+
+ public AddJbpmInstallationDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public void initialize(String t, String n, String l) {
+ this.title = t;
+ this.name = n;
+ this.location = l;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite area = (Composite)super.createDialogArea(parent);
+ getShell().setText(title);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ area.setLayout(gridLayout);
+ createNameLabel(area);
+ createNameText(area);
+ createFillLabel(area);
+ createLocationLabel(area);
+ createLocationText(area);
+ createLocationButton(area);
+ getShell().setText(title);
+ return area;
+ }
+
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+ updateStatus(currentStatus);
+ return result;
+ }
+
+ private void createLocationText(Composite area) {
+ locationText = new Text(area, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = convertWidthInCharsToPixels(40);
+ locationText.setLayoutData(gridData);
+ locationText.setText(location == null ? "" : location);
+ locationText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleLocationChanged();
+ }
+ });
+ }
+
+ private void handleLocationChanged() {
+ location = locationText.getText();
+ updateCurrentStatus();
+ updateStatus(currentStatus);
+ }
+
+ private void createLocationButton(Composite area) {
+ locationButton = new Button(area, SWT.PUSH);
+ locationButton.setText("Search...");
+ locationButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ searchLocation();
+ }
+ });
+ }
+
+ private void searchLocation() {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+ String result = dialog.open();
+ if (result != null) {
+ locationText.setText(result);
+ }
+ }
+
+ private void createLocationLabel(Composite area) {
+ Label label = new Label(area, SWT.NONE);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ label.setLayoutData(gridData);
+ label.setText("Location :");
+ }
+
+ private void createFillLabel(Composite area) {
+ new Label(area, SWT.NONE);
+ }
+
+ private void createNameText(Composite area) {
+ nameText = new Text(area, SWT.BORDER);
+ GridData gridData = new GridData();
+ gridData.verticalIndent = 10;
+ gridData.widthHint = convertWidthInCharsToPixels(40);
+ nameText.setLayoutData(gridData);
+ nameText.setText(name == null ? "" : name);
+ nameText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleNameChanged();
+ }
+ });
+ }
+
+ private void handleNameChanged() {
+ name = nameText.getText();
+ updateCurrentStatus();
+ updateStatus(currentStatus);
+ }
+
+ private void updateCurrentStatus() {
+ if (isNameEmpty() && isLocationEmpty()) {
+ currentStatus = enterNameStatus;
+ } else if (isNameAlreadyUsed() && !"Edit Location".equals(title)) {
+ currentStatus = nameAlreadyUsedStatus;
+ } else if (isLocationEmpty()) {
+ currentStatus = enterLocationStatus;
+ } else if (!isLocationExisting()) {
+ currentStatus = unExistingLocationStatus;
+ } else if (!isValidJbpmInstallation()) {
+ currentStatus = inValidJbpmInstallationStatus;
+ } else if (isNameEmpty()) {
+ currentStatus = enterNameStatus;
+ } else {
+ currentStatus = Status.OK_STATUS;
+ }
+ }
+
+ private boolean isNameAlreadyUsed() {
+ return PreferencesManager.INSTANCE.getJbpmInstallation(nameText.getText()) != null;
+ }
+
+ private boolean isLocationExisting() {
+ return new Path(location).toFile().exists();
+ }
+
+ private boolean isNameEmpty() {
+ return name == null || "".equals(name);
+ }
+
+ private boolean isLocationEmpty() {
+ return location == null || "".equals(location);
+ }
+
+ private boolean isValidJbpmInstallation() {
+ return getJbpmVersionInfoFile().exists();
+ }
+
+ private File getJbpmVersionInfoFile() {
+ return new
Path(location).append("/src/resources/gpd/version.info.xml").toFile();
+ }
+
+ protected void updateButtonsEnableState(IStatus status) {
+ Button ok = getButton(IDialogConstants.OK_ID);
+ if (ok != null && !ok.isDisposed())
+ ok.setEnabled(status.getSeverity() == IStatus.OK);
+ }
+
+ private void createNameLabel(Composite area) {
+ Label label = new Label(area, SWT.NONE);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ label.setLayoutData(gridData);
+ label.setText("Name :");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public abstract String getVersion();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/DefaultPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/DefaultPage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/DefaultPage.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,44 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class DefaultPage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ public DefaultPage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ protected Control createContents(Composite parent) {
+ return null;
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/DefaultPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallation.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallation.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallation.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,30 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+public class JbpmInstallation {
+
+ public String location;
+ public String version;
+ public String name;
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationLabelProvider.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationLabelProvider.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationLabelProvider.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,45 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class JbpmInstallationLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ JbpmInstallation installation = (JbpmInstallation)element;
+ switch (columnIndex) {
+ case 0: return installation.name;
+ case 1: return installation.version;
+ case 2: return installation.location;
+ default: return null;
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationTableContentProvider.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationTableContentProvider.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationTableContentProvider.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,42 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class JbpmInstallationTableContentProvider implements IStructuredContentProvider
{
+
+ PreferencesManager inputManager;
+
+ public Object[] getElements(Object inputElement) {
+ return inputManager.getJbpmInstallationMap().values().toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ inputManager = (PreferencesManager)newInput;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmInstallationTableContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,330 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.jbpm.Activator;
+import org.jboss.tools.jbpm.Constants;
+import org.jboss.tools.jbpm.util.AutoResizeTableLayout;
+
+public abstract class JbpmLocationsPage extends PreferencePage implements
IWorkbenchPreferencePage {
+
+ private TableViewer tableViewer;
+ private Button addButton, editButton, removeButton;
+
+ public JbpmLocationsPage() {
+ super();
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ }
+
+ protected abstract AddJbpmInstallationDialog createAddJbpmInstallationDialog(Shell
shell);
+
+ protected Control createContents(Composite parent) {
+ Composite clientArea = createClientArea(parent);
+ createLabels(clientArea);
+ createJbpmHomeListTable(clientArea);
+ createButtons(clientArea);
+ return null;
+ }
+
+ private void createButtons(Composite parent) {
+ GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
+ gridData.widthHint = 80;
+ addButton = new Button(parent, SWT.PUSH);
+ addButton.setText("Add...");
+ addButton.setLayoutData(gridData);
+ addButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ addNewLocation();
+ }
+ });
+ editButton = new Button(parent, SWT.PUSH);
+ editButton.setText("Edit...");
+ editButton.setLayoutData(gridData);
+ editButton.setEnabled(false);
+ editButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ editLocation();
+ }
+ });
+ removeButton = new Button(parent, SWT.PUSH);
+ removeButton.setText("Remove");
+ removeButton.setLayoutData(gridData);
+ removeButton.setEnabled(false);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ removeLocation();
+ }
+ });
+ }
+
+ private void removeLocation() {
+ TableItem item = tableViewer.getTable().getSelection()[0];
+ String name = item.getText(0);
+ PreferencesManager inputManager =
+ (PreferencesManager)tableViewer.getInput();
+ JbpmInstallation installation = inputManager.getJbpmInstallation(name);
+ inputManager.getJbpmInstallationMap().remove(name);
+ tableViewer.remove(installation);
+ updateButtons();
+ updateStatus();
+ }
+
+ private void editLocation() {
+ TableItem item = tableViewer.getTable().getSelection()[0];
+ String name = item.getText(0);
+ PreferencesManager inputManager =
+ (PreferencesManager)tableViewer.getInput();
+ JbpmInstallation jbpmInstallation = inputManager.getJbpmInstallation(name);
+ AddJbpmInstallationDialog dialog = createAddJbpmInstallationDialog(getShell());
+ dialog.initialize("Edit Location", jbpmInstallation.name,
jbpmInstallation.location);
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ jbpmInstallation.name = dialog.getName();
+ jbpmInstallation.version = dialog.getVersion();
+ jbpmInstallation.location = dialog.getLocation();
+ tableViewer.update(jbpmInstallation, null);
+ if (name != dialog.getName()) {
+ inputManager.getJbpmInstallationMap().remove(name);
+ inputManager.getJbpmInstallationMap().put(dialog.getName(), jbpmInstallation);
+ }
+ }
+ updateButtons();
+ }
+
+ private void addNewLocation() {
+ AddJbpmInstallationDialog dialog = createAddJbpmInstallationDialog(getShell());
+ dialog.initialize("Add Location", "", "");
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ PreferencesManager inputManager =
+ (PreferencesManager)tableViewer.getInput();
+ JbpmInstallation jbpmInstallation = getJbpmInstallation(dialog);
+ inputManager.getJbpmInstallationMap().put(jbpmInstallation.name, jbpmInstallation);
+ tableViewer.add(jbpmInstallation);
+ }
+ updateButtons();
+ }
+
+ private JbpmInstallation getJbpmInstallation(AddJbpmInstallationDialog dialog) {
+ JbpmInstallation jbpmInstallation = new JbpmInstallation();
+ jbpmInstallation.name = dialog.getName();
+ jbpmInstallation.location = dialog.getLocation();
+ jbpmInstallation.version = dialog.getVersion();
+ return jbpmInstallation;
+ }
+
+ private Composite createClientArea(Composite parent) {
+ Composite clientArea = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ clientArea.setLayout(layout);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ clientArea.setLayoutData(gridData);
+ return clientArea;
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+ private void createJbpmHomeListTable(Composite parent) {
+ tableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION |
SWT.CHECK);
+ tableViewer.setContentProvider(new JbpmInstallationTableContentProvider());
+ tableViewer.setLabelProvider(new JbpmInstallationLabelProvider());
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.verticalSpan = 3;
+ gridData.heightHint = 200;
+ tableViewer.getControl().setLayoutData(gridData);
+ initializeTable(tableViewer);
+ createTableColumns(tableViewer);
+ initializeInput(tableViewer);
+ }
+
+ private void initializeInput(TableViewer viewer) {
+ viewer.setInput(PreferencesManager.INSTANCE);
+ checkItemToCheck(viewer);
+ }
+
+ private void checkItemToCheck(TableViewer viewer) {
+ String name = getPreferences().getString(Constants.JBPM_NAME);
+ if (name != null) {
+ TableItem tableItem = getItemToCheck(viewer, name);
+ if (tableItem != null) {
+ tableItem.setChecked(true);
+ }
+ }
+ }
+
+ private TableItem getItemToCheck(TableViewer viewer, String name) {
+ TableItem[] items = viewer.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ if (name.equals(items[i].getText(0))) return items[i];
+ }
+ return null;
+ }
+
+ private void createTableColumns(TableViewer viewer) {
+ Table table = viewer.getTable();
+ TableColumn nameColumn = new TableColumn(table, SWT.LEFT);
+ nameColumn.setText("Name");
+ ColumnWeightData nameColumnData = new ColumnWeightData(30);
+ AutoResizeTableLayout layout = (AutoResizeTableLayout)table.getLayout();
+ layout.addColumnData(nameColumnData);
+ TableColumn versionColumn = new TableColumn(table, SWT.LEFT);
+ versionColumn.setText("Version");
+ ColumnWeightData versionColumnData = new ColumnWeightData(30);
+ layout.addColumnData(versionColumnData);
+ TableColumn locationColumn = new TableColumn(table, SWT.LEFT);
+ locationColumn.setText("Location");
+ ColumnWeightData locationColumnData = new ColumnWeightData(40);
+ layout.addColumnData(locationColumnData);
+ }
+
+ private void initializeTable(TableViewer viewer) {
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setLayout(new AutoResizeTableLayout(table));
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateSelection(e);
+ }
+ });
+ }
+
+ private void updateSelection(SelectionEvent e) {
+ if (e.detail == SWT.CHECK) {
+ updateChecks(e);
+ } else {
+ updateButtons();
+ }
+ updateStatus();
+ }
+
+ private void updateChecks(SelectionEvent e) {
+ Table table = tableViewer.getTable();
+ TableItem[] items = table.getItems();
+ for (int i = 0; i < items.length; i++) {
+ if (e.item != items[i]) {
+ items[i].setChecked(false);
+ }
+ }
+ }
+
+ private void updateStatus() {
+ TableItem item = getCheckedItem();
+ if (item != null) {
+ setErrorMessage(null);
+ setValid(true);
+ } else {
+ setErrorMessage("Select a default jBPM installation.");
+ setValid(false);
+ }
+ }
+
+ private TableItem getCheckedItem() {
+ TableItem[] items = tableViewer.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getChecked()) {
+ return items[i];
+ }
+ }
+ return null;
+ }
+
+ private void updateButtons() {
+ Table table = tableViewer.getTable();
+ TableItem[] selection = table.getSelection();
+ editButton.setEnabled(selection.length == 1);
+ removeButton.setEnabled(selection.length == 1 && table.getItemCount() > 1);
+ }
+
+ private void createLabels(Composite parent) {
+ GridData infoLabelGridData = new GridData(GridData.FILL_HORIZONTAL);
+ infoLabelGridData.horizontalSpan = 2;
+ Label infoLabel = new Label(parent, SWT.NONE);
+ infoLabel.setText(
+ "Add, remove or edit JBoss jBPM installation locations.\n" +
+ "The checked location will be used by the jBPM creation wizards.");
+ infoLabel.setLayoutData(infoLabelGridData);
+ GridData tableLabelGridData = new GridData(SWT.BEGINNING, SWT.END, false, false);
+ tableLabelGridData.horizontalSpan = 2;
+ Label tableLabel = new Label(parent, SWT.NONE);
+ tableLabel.setText("jBPM Installation Locations:");
+ tableLabel.setLayoutData(tableLabelGridData);
+ }
+
+ public boolean performOk() {
+ String name = "";
+ PreferencesManager inputManager =
+ (PreferencesManager)tableViewer.getInput();
+ inputManager.saveInstallations();
+ TableItem item = getCheckedItem(tableViewer);
+ if (item != null) {
+ name = item.getText(0);
+ }
+ getPreferences().setValue(Constants.JBPM_NAME, name);
+ return true;
+ }
+
+ private TableItem getCheckedItem(TableViewer viewer) {
+ TableItem[] items = viewer.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getChecked()) return items[i];
+ }
+ return null;
+ }
+
+ public void performDefaults() {
+ getPreferences().setToDefault(Constants.JBPM_NAME);
+ PreferencesManager inputManager =
+ (PreferencesManager)tableViewer.getInput();
+ inputManager.getJbpmInstallationMap().clear();
+ tableViewer.setInput(inputManager);
+ checkItemToCheck(tableViewer);
+ setMessage("");
+ updateButtons();
+ setValid(true);
+ }
+
+ private Preferences getPreferences() {
+ return Activator.getDefault().getPluginPreferences();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementDialog.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementDialog.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementDialog.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,189 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+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.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class LocationElementDialog extends Dialog {
+
+ String title;
+ Text nameText, locationText;
+ Button locationButton;
+
+ String name, location;
+
+ public LocationElementDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public void initialize(String t, String n, String l) {
+ this.title = t;
+ this.name = n;
+ this.location = l;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite area = (Composite)super.createDialogArea(parent);
+ getShell().setText(title);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ area.setLayout(gridLayout);
+ createMessageLabel(area);
+ createNameLabel(area);
+ createNameText(area);
+ createFillLabel(area);
+ createLocationLabel(area);
+ createLocationText(area);
+ createLocationButton(area);
+ createSeparator(area);
+ getShell().setText(title);
+ return area;
+ }
+
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+ updateOkButton();
+ return result;
+ }
+
+ private void createSeparator(Composite area) {
+ Label separator = new Label(area, SWT.SEPARATOR | SWT.HORIZONTAL);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ gridData.verticalIndent = 15;
+ separator.setLayoutData(gridData);
+ }
+
+ private void createLocationText(Composite area) {
+ locationText = new Text(area, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = convertWidthInCharsToPixels(40);
+ locationText.setLayoutData(gridData);
+ locationText.setText(location == null ? "" : location);
+ locationText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ location = locationText.getText();
+ updateOkButton();
+ }
+ });
+ }
+
+ private void createLocationButton(Composite area) {
+ locationButton = new Button(area, SWT.PUSH);
+ locationButton.setText("Search...");
+ locationButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ searchLocation();
+ }
+ });
+ }
+
+ private void searchLocation() {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+ String result = dialog.open();
+ if (result != null) {
+ locationText.setText(result);
+ }
+ }
+
+ private void createLocationLabel(Composite area) {
+ Label label = new Label(area, SWT.NONE);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ label.setLayoutData(gridData);
+ label.setText("Location :");
+ }
+
+ private void createFillLabel(Composite area) {
+ new Label(area, SWT.NONE);
+ }
+
+ private void createNameText(Composite area) {
+ nameText = new Text(area, SWT.BORDER);
+ GridData gridData = new GridData();
+ gridData.widthHint = convertWidthInCharsToPixels(40);
+ nameText.setLayoutData(gridData);
+ nameText.setText(name == null ? "" : name);
+ nameText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ name = nameText.getText();
+ updateOkButton();
+ }
+ });
+ }
+
+ private void updateOkButton() {
+ getButton(IDialogConstants.OK_ID).setEnabled(isValid());
+ }
+
+ private boolean isValid() {
+ if (name == null || location == null) {
+ return false;
+ }
+ if ("".equals(name) || "".equals(location)) {
+ return false;
+ }
+ return true;
+ }
+
+ private void createNameLabel(Composite area) {
+ Label label = new Label(area, SWT.NONE);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ label.setLayoutData(gridData);
+ label.setText("Name :");
+ }
+
+ private void createMessageLabel(Composite area) {
+ Label label = new Label(area, SWT.NONE);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.horizontalSpan = 3;
+ gridData.verticalIndent = 10;
+ label.setLayoutData(gridData);
+ label.setText("Enter a name and choose the location : ");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementLabelProvider.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementLabelProvider.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementLabelProvider.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,48 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import java.util.Map;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class LocationElementLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getColumnText(Object element, int columnIndex) {
+ JbpmInstallation installation = (JbpmInstallation)((Map.Entry)element).getValue();
+ switch (columnIndex) {
+ case 0: return installation.name;
+ case 1: return installation.version;
+ case 2: return installation.location;
+ default: return null;
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationElementLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationTableContentProvider.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationTableContentProvider.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationTableContentProvider.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,42 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class LocationTableContentProvider implements IStructuredContentProvider {
+
+ PreferencesManager inputManager;
+
+ public Object[] getElements(Object inputElement) {
+ return inputManager.getJbpmInstallationMap().values().toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ inputManager = (PreferencesManager)newInput;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/LocationTableContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,176 @@
+/*
+ * 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.jboss.tools.jbpm.preferences;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.XMLMemento;
+import org.jboss.tools.jbpm.Activator;
+import org.jboss.tools.jbpm.Constants;
+
+public class PreferencesManager {
+
+ public static final PreferencesManager INSTANCE = new PreferencesManager();
+
+ private Map<String, JbpmInstallation> jbpmInstallations = null;
+ private File installationsFile = null;
+
+ private PreferencesManager() {
+ initializeInstallations();
+ }
+
+ private File getInstallationFile() {
+ if (installationsFile == null) {
+ initializeInstallations();
+ }
+ return installationsFile;
+ }
+
+ private Map<String, JbpmInstallation> getJbpmInstallations() {
+ if (jbpmInstallations == null) {
+ jbpmInstallations = new HashMap<String, JbpmInstallation>();
+ }
+ return jbpmInstallations;
+ }
+
+ private static Preferences getPreferences() {
+ return Activator.getDefault().getPluginPreferences();
+ }
+
+ private void initializeInstallations() {
+ installationsFile =
+ Activator.getDefault().getStateLocation().append("jbpm-installations.xml").toFile();
+ if (!installationsFile.exists()) {
+ createInstallationsFile();
+ } else {
+ loadInstallations();
+ }
+ }
+
+ private void createInstallationsFile() {
+ try {
+ installationsFile.createNewFile();
+ saveInstallations();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void loadInstallations() {
+ Reader reader = null;
+ try {
+ reader = new FileReader(getInstallationFile());
+ XMLMemento memento = XMLMemento.createReadRoot(reader);
+ IMemento[] children = memento.getChildren("installation");
+ for (int i = 0; i < children.length; i++) {
+ JbpmInstallation installation = new JbpmInstallation();
+ installation.name = children[i].getString("name");
+ installation.location = children[i].getString("location");
+ installation.version = children[i].getString("version");
+ getJbpmInstallations().put(installation.name, installation);
+ }
+ } catch (WorkbenchException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void saveInstallations() {
+ XMLMemento memento = XMLMemento.createWriteRoot("installations");
+ Iterator<String> iterator = getJbpmInstallations().keySet().iterator();
+ while (iterator.hasNext()) {
+ String name = (String)iterator.next();
+ JbpmInstallation installation = (JbpmInstallation)getJbpmInstallations().get(name);
+ IMemento child = memento.createChild("installation");
+ child.putString("name", installation.name);
+ child.putString("location", installation.location);
+ child.putString("version", installation.version);
+ }
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(getInstallationFile());
+ memento.save(writer);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ if (writer != null) {
+ writer.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Map<String, JbpmInstallation> getJbpmInstallationMap() {
+ return getJbpmInstallations();
+ }
+
+ public JbpmInstallation getJbpmInstallation(String name) {
+ return (JbpmInstallation)getJbpmInstallations().get(name);
+ }
+
+ public String getPreferredJbpmName() {
+ return getPreferences().getString(Constants.JBPM_NAME);
+ }
+
+ public void setPreferredJbpmName(String name) {
+ getPreferences().setDefault(Constants.JBPM_NAME, name);
+ }
+
+ public void addJbpmInstallation(String name, String location, String version) {
+ JbpmInstallation installation = new JbpmInstallation();
+ installation.name = name;
+ installation.location = location;
+ installation.version = version;
+ getJbpmInstallationMap().put(name, installation);
+ }
+
+ public void initializeDefaultJbpmInstallation(String name, String location, String
version) {
+ setPreferredJbpmName(name);
+ addJbpmInstallation(name, location, version);
+ saveInstallations();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/AutoResizeTableLayout.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/AutoResizeTableLayout.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/AutoResizeTableLayout.java 2009-05-19
19:40:06 UTC (rev 15353)
@@ -0,0 +1,140 @@
+/*
+ * 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.jboss.tools.jbpm.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class AutoResizeTableLayout extends TableLayout implements
+ ControlListener {
+
+ private final Table table;
+ private List<ColumnLayoutData> columns = new
ArrayList<ColumnLayoutData>();
+ private boolean autosizing = false;
+
+ public AutoResizeTableLayout(Table table) {
+ this.table = table;
+ table.addControlListener(this);
+ }
+
+ public void addColumnData(ColumnLayoutData data) {
+ columns.add(data);
+ super.addColumnData(data);
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (autosizing) {
+ return;
+ }
+ autosizing = true;
+ try {
+ autoSizeColumns();
+ } finally {
+ autosizing = false;
+ }
+ }
+
+ private void autoSizeColumns() {
+ int width = table.getClientArea().width;
+ if (width <= 1) {
+ return;
+ }
+
+ TableColumn[] tableColumns = table.getColumns();
+ int size =
+ Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
+
+ // First calc space occupied by fixed columns.
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnPixelData) {
+ int pixels = ((ColumnPixelData)col).width;
+ widths[i] = pixels;
+ fixedWidth += pixels;
+ } else if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ numberOfWeightColumns++;
+ int weight = cw.weight;
+ totalWeight += weight;
+ } else {
+ throw new IllegalStateException("Unknown column layout data");
+ }
+ }
+
+ // Do we have columns that have a weight?
+ if (numberOfWeightColumns > 0) {
+ // Now, distribute the rest
+ // to the columns with weight.
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ totalDistributed += pixels;
+ widths[i] = pixels;
+ }
+ }
+
+ // Distribute any remaining pixels
+ // to columns with weight.
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; i++) {
+ if (i == size) {
+ i = 0;
+ }
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ++widths[i];
+ --diff;
+ }
+ }
+ }
+
+ for (int i = 0; i < size; i++) {
+ if (tableColumns[i].getWidth() != widths[i]) {
+ tableColumns[i].setWidth(widths[i]);
+ }
+
+ }
+
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/util/AutoResizeTableLayout.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain