Author: koen.aers(a)jboss.com
Date: 2009-05-19 15:36:41 -0400 (Tue, 19 May 2009)
New Revision: 15351
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/Jbpm4LocationsPage.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TextFieldPropertySection.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java
Log:
- added preference pages for the runtime locations (more work needed) GPD-288
- save process definition image GPD-320
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-05-19 16:58:17
UTC (rev 15350)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-05-19 19:36:41
UTC (rev 15351)
@@ -11,7 +11,8 @@
org.eclipse.ui;bundle-version="3.4.1",
org.eclipse.core.runtime;bundle-version="3.4.0",
org.eclipse.ui.ide;bundle-version="3.4.1",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.1"
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.1",
+ org.jboss.tools.jbpm.common;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.flow.jpdl4.Activator
Export-Package: org.jboss.tools.flow.jpdl4.editor,
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-05-19 16:58:17 UTC (rev
15350)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-05-19 19:36:41 UTC (rev
15351)
@@ -493,4 +493,17 @@
</menuContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page class="org.jboss.tools.jbpm.preferences.DefaultPage"
+ id="org.jboss.tools.flow.jpdl4"
+ name="jBPM 4"
+ category="org.jboss.tools.jbpm"/>
+ <page
+ class="org.jboss.tools.flow.jpdl4.preferences.Jbpm4LocationsPage"
+ id="org.jboss.tools.flow.jpdl4.locations"
+ name="Runtime Locations"
+ category="org.jboss.tools.flow.jpdl4"/>
+ </extension>
+
</plugin>
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java 2009-05-19
16:58:17 UTC (rev 15350)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java 2009-05-19
19:36:41 UTC (rev 15351)
@@ -1,17 +1,44 @@
package org.jboss.tools.flow.jpdl4.editor;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.editparts.LayerManager;
import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.jboss.tools.flow.common.editor.GenericModelEditor;
import org.jboss.tools.flow.common.registry.ElementRegistry;
import org.jboss.tools.flow.common.wrapper.Wrapper;
+import org.jboss.tools.flow.jpdl4.Logger;
import org.jboss.tools.flow.jpdl4.editpart.JpdlGraphicalEditPartFactory;
import org.jboss.tools.flow.jpdl4.properties.JpdlPropertySheetPage;
import org.jboss.tools.flow.jpdl4.view.DetailsPage;
@@ -21,9 +48,18 @@
public static String ID = "org.jboss.tools.flow.jpdl4.editor";
-// protected SelectionSynchronizer selectionSynchronizer;
private DetailsPage detailsPage;
+ public void doSave(IProgressMonitor monitor) {
+ super.doSave(monitor);
+ writeImage();
+ }
+
+ public void doSaveAs() {
+ super.doSaveAs();
+ writeImage();
+ }
+
protected PaletteRoot createPalette() {
return new JpdlPaletteFactory().createPalette();
}
@@ -43,7 +79,60 @@
}
}
- protected void createModel(InputStream is) {
+ protected void writeImage() {
+ // TODO repair doSave method
+ SWTGraphics g = null;
+ GC gc = null;
+ Image image = null;
+
+ LayerManager lm =
(LayerManager)getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
+ IFigure figure = lm.getLayer(LayerConstants.PRINTABLE_LAYERS);
+
+ try {
+
+ Rectangle r = figure.getBounds();
+ image = new Image(Display.getDefault(), r.width, r.height);
+ gc = new GC(image);
+ g = new SWTGraphics(gc);
+ g.translate(r.x * -1, r.y * -1);
+ figure.paint(g);
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[] {image.getImageData()};
+ imageLoader.save(getImageSavePath(), SWT.IMAGE_JPEG);
+ refreshProcessFolder();
+
+ } finally {
+ if (g != null) {
+ g.dispose();
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+ if (image != null) {
+ image.dispose();
+ }
+ }
+ }
+
+ private String getImageSavePath() {
+ IFile file = getFile();
+ IPath path = file.getRawLocation();
+ if ("xml".equals(path.getFileExtension())) path =
path.removeFileExtension();
+ if ("jpdl".equals(path.getFileExtension())) path =
path.removeFileExtension();
+ path = path.addFileExtension("png");
+ return path.toOSString();
+ }
+
+ private void refreshProcessFolder() {
+ try {
+ IFile file = ((FileEditorInput)getEditorInput()).getFile();
+ file.getParent().refreshLocal(1, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void createModel(InputStream is) {
boolean empty = true;
try {
empty = is.available() == 0;
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/Jbpm4LocationsPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/Jbpm4LocationsPage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/Jbpm4LocationsPage.java 2009-05-19
19:36:41 UTC (rev 15351)
@@ -0,0 +1,38 @@
+/*
+ * 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.flow.jpdl4.preferences;
+
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.jbpm.preferences.AddJbpmInstallationDialog;
+import org.jboss.tools.jbpm.preferences.JbpmLocationsPage;
+
+public class Jbpm4LocationsPage extends JbpmLocationsPage {
+
+ protected AddJbpmInstallationDialog createAddJbpmInstallationDialog(Shell shell) {
+ return new AddJbpmInstallationDialog(getShell()) {
+ public String getVersion() {
+ return "4.0";
+ }
+ };
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/preferences/Jbpm4LocationsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TextFieldPropertySection.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TextFieldPropertySection.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TextFieldPropertySection.java 2009-05-19
19:36:41 UTC (rev 15351)
@@ -0,0 +1,69 @@
+package org.jboss.tools.flow.jpdl4.properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.jboss.tools.flow.jpdl4.model.EventListener;
+
+public class TextFieldPropertySection extends JpdlPropertySection {
+
+ private Text classNameText;
+ private CLabel classNameLabel;
+
+ private ModifyListener textModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent arg0) {
+ changeProperty(EventListener.CLASS_NAME,
getValueNullsAllowed(classNameText.getText()));
+ }
+ };
+
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ Composite composite = getFlatFormComposite();
+ createEventTypeLabel(composite);
+ createEventTypeText(composite);
+ }
+
+
+ private void createEventTypeLabel(Composite parent) {
+ classNameLabel = getWidgetFactory().createCLabel(parent, "Class");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 5);
+ classNameLabel.setLayoutData(data);
+ }
+
+ private void createEventTypeText(Composite parent) {
+ classNameText = getWidgetFactory().createText(parent, "");
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(classNameLabel, 0, SWT.RIGHT);
+ data.right = new FormAttachment(100, 0);
+ classNameText.setLayoutData(data);
+ }
+
+ protected void hookListeners() {
+ classNameText.addModifyListener(textModifyListener);
+ }
+
+ protected void unhookListeners() {
+ classNameText.removeModifyListener(textModifyListener);
+ }
+
+ protected void updateValues() {
+ IPropertySource input = getInput();
+ if (input != null) {
+ classNameText.setText(getValueNotNull((String)input.getPropertyValue(EventListener.CLASS_NAME)));
+ } else {
+ classNameText.setText("");
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TextFieldPropertySection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain