Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorExporter.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/plugin.xml2
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java79
-rw-r--r--plugins/org.eclipse.etrice.ui.common/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/DiagramExporter.java18
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/ETricePreferencePage.java30
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceConstants.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceInitializer.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java2
9 files changed, 133 insertions, 20 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorExporter.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorExporter.java
index 49f6e1519..2c42e10cf 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorExporter.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorExporter.java
@@ -25,7 +25,7 @@ import org.eclipse.ui.PlatformUI;
public class BehaviorExporter {
- private static final String SUFFIX = "_behavior.jpg";
+ private static final String SUFFIX = "_behavior";
public static void export(ActorClass ac, String folder) {
DiagramAccess da = new DiagramAccess();
diff --git a/plugins/org.eclipse.etrice.ui.commands/plugin.xml b/plugins/org.eclipse.etrice.ui.commands/plugin.xml
index 5240833c2..824e6802d 100644
--- a/plugins/org.eclipse.etrice.ui.commands/plugin.xml
+++ b/plugins/org.eclipse.etrice.ui.commands/plugin.xml
@@ -188,7 +188,7 @@
locationURI="popup:org.eclipse.etrice.core.room.outline?after=additions">
<command
commandId="org.eclipse.etrice.core.room.ui.exportDiagrams"
- label="Export Diagrams..."
+ label="Export Diagrams"
style="push">
<visibleWhen
checkEnabled="true">
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
index b5dc55d37..1448666de 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
@@ -12,26 +12,34 @@
package org.eclipse.etrice.ui.commands.handlers;
+import java.io.ByteArrayInputStream;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
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.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.ui.RoomUiModule;
import org.eclipse.etrice.ui.behavior.editor.BehaviorExporter;
+import org.eclipse.etrice.ui.common.Activator;
+import org.eclipse.etrice.ui.common.preferences.PreferenceConstants;
import org.eclipse.etrice.ui.structure.editor.StructureExporter;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@@ -63,12 +71,15 @@ public class ExportDiagramsHandler extends AbstractHandler {
@Inject
protected IResourceValidator resourceValidator;
+ private IPreferenceStore store;
public ExportDiagramsHandler() {
super();
Injector injector = RoomUiModule.getInjector();
injector.injectMembers(this);
+
+ this.store = Activator.getDefault().getPreferenceStore();
}
// TODO: code copied from org.eclipse.etrice.ui.commands.handlers.AbstractEditHandler - refactor
@@ -108,26 +119,68 @@ public class ExportDiagramsHandler extends AbstractHandler {
}
protected void exportDiagrams(RoomModel model, IPath modelPath, Shell shell) {
-// IProject project = ResourcesPlugin.getWorkspace().getRoot().getFile(modelPath).getProject();
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(modelPath.removeLastSegments(1));
- IProject project = container.getProject();
- IFolder file = project.getFolder("doc-gen/images");
- if (file!=null) {
- String folder = file.getLocation().toOSString();
+ String relPath = store.getString(PreferenceConstants.EXPORT_DIAGRAM_PATH);
+ boolean projectRelative = PreferenceConstants.PATH_REL_TO_PROJECT.equals(
+ store.getString(PreferenceConstants.EXPORT_DIAGRAM_PATH_RELATIVE_TO));
- for (ActorClass ac : model.getActorClasses()) {
- if (ac.getStateMachine()!=null)
- BehaviorExporter.export(ac, folder);
-
- StructureExporter.export(ac, folder);
- }
+ IFolder folder;
+ if (projectRelative) {
+ IProject project = container.getProject();
+ folder = project.getFolder(relPath);
+ }
+ else {
+ folder = container.getFolder(new Path(relPath));
+ }
+ if (folder!=null) {
+ if (!folder.exists())
+ try {
+ create(folder);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
- for (SubSystemClass ssc : model.getSubSystemClasses()) {
- StructureExporter.export(ssc, folder);
+ if (folder.exists()) {
+ String folderPath = folder.getLocation().toOSString();
+
+ for (ActorClass ac : model.getActorClasses()) {
+ if (ac.getStateMachine()!=null)
+ BehaviorExporter.export(ac, folderPath);
+
+ StructureExporter.export(ac, folderPath);
+ }
+
+ for (SubSystemClass ssc : model.getSubSystemClasses()) {
+ StructureExporter.export(ssc, folderPath);
+ }
+
+ try {
+ folder.refreshLocal(IResource.DEPTH_ONE, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
}
}
+ protected void create(final IResource resource) throws CoreException {
+ if (resource == null || resource.exists())
+ return;
+ if (!resource.getParent().exists())
+ create(resource.getParent());
+ switch (resource.getType()) {
+ case IResource.FILE:
+ ((IFile) resource).create(new ByteArrayInputStream(new byte[0]), true, null);
+ break;
+ case IResource.FOLDER:
+ ((IFolder) resource).create(IResource.NONE, true, null);
+ break;
+ case IResource.PROJECT:
+ ((IProject) resource).create(null);
+ ((IProject) resource).open(null);
+ break;
+ }
+ }
// TODO: code copied from org.eclipse.etrice.ui.commands.handlers.AbstractEditHandler - refactor
protected boolean checkPrerequisites(XtextEditor xtextEditor,
IXtextDocument document, final String fragment) {
diff --git a/plugins/org.eclipse.etrice.ui.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.common/META-INF/MANIFEST.MF
index 92d3c874c..0f4ac7a49 100644
--- a/plugins/org.eclipse.etrice.ui.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.common/META-INF/MANIFEST.MF
@@ -5,11 +5,11 @@ Bundle-SymbolicName: org.eclipse.etrice.ui.common;singleton:=true
Bundle-Version: 0.2.0.qualifier
Bundle-Vendor: eTrice (Incubation)
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.eclipse.core.databinding;bundle-version="1.3.100",
+Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
+ org.eclipse.core.databinding;bundle-version="1.3.100",
org.eclipse.core.databinding.beans;bundle-version="1.2.100",
org.eclipse.jface.databinding;bundle-version="1.4.0",
org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
org.eclipse.graphiti;bundle-version="0.8.0",
org.eclipse.ui.ide;bundle-version="3.6.0",
org.eclipse.graphiti.ui;bundle-version="0.7.0",
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/DiagramExporter.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/DiagramExporter.java
index 2e396f463..74dc08fef 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/DiagramExporter.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/DiagramExporter.java
@@ -20,7 +20,9 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.SWTGraphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.ui.common.Activator;
import org.eclipse.etrice.ui.common.DiagramAccessBase;
+import org.eclipse.etrice.ui.common.preferences.PreferenceConstants;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.GraphicalViewer;
@@ -29,6 +31,7 @@ import org.eclipse.gef.editparts.LayerManager;
import org.eclipse.graphiti.ui.internal.fixed.FixedScaledGraphics;
import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -58,18 +61,29 @@ public class DiagramExporter {
// code copied from org.eclipse.graphiti.ui.internal.action.SaveImageAction
// and org.eclipse.graphiti.ui.internal.util.ui.print.ExportDiagramDialog
public static void export(RoomDiagramEditor editor, final String filename) {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String format = store.getString(PreferenceConstants.EXPORT_DIAGRAM_FORMAT);
+ int fmt = SWT.IMAGE_JPEG;
+ if (format.equals(PreferenceConstants.FORMAT_BMP))
+ fmt = SWT.IMAGE_BMP;
+ else if (format.equals(PreferenceConstants.FORMAT_PNG))
+ fmt = SWT.IMAGE_PNG;
+ else if (format.equals(PreferenceConstants.FORMAT_GIF))
+ fmt = SWT.IMAGE_GIF;
+
+ final String fname = filename+"."+format;
GraphicalViewer viewer = (GraphicalViewer) editor.getAdapter(GraphicalViewer.class);
Image image = createImage(viewer, 1.0d, 3000.0d);
if (image!=null) {
try {
- final byte[] imgData = GraphitiUiInternal.getUiService().createImage(image, SWT.IMAGE_JPEG);
+ final byte[] imgData = GraphitiUiInternal.getUiService().createImage(image, fmt);
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException {
FileOutputStream outputStream = null;
try {
- outputStream = new FileOutputStream(filename);
+ outputStream = new FileOutputStream(fname);
outputStream.write(imgData);
} catch (Exception e) {
e.printStackTrace();
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/ETricePreferencePage.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/ETricePreferencePage.java
index a1f478e2e..eb7ad8fa0 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/ETricePreferencePage.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/ETricePreferencePage.java
@@ -15,6 +15,7 @@ package org.eclipse.etrice.ui.common.preferences;
import org.eclipse.etrice.ui.common.Activator;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -63,6 +64,35 @@ public class ETricePreferencePage
getFieldEditorParent());
addField(autoSave);
+ StringFieldEditor exportPath = new StringFieldEditor(PreferenceConstants.EXPORT_DIAGRAM_PATH, "&Export Diagram Path:", getFieldEditorParent());
+ addField(exportPath);
+
+ RadioGroupFieldEditor exportRelTo = new RadioGroupFieldEditor(
+ PreferenceConstants.EXPORT_DIAGRAM_PATH_RELATIVE_TO,
+ "Export Path Relative to",
+ 2,
+ new String[][] {
+ {"Project", PreferenceConstants.PATH_REL_TO_PROJECT},
+ {"Model", PreferenceConstants.PATH_REL_TO_MODEL}
+ },
+ getFieldEditorParent(),
+ true);
+ addField(exportRelTo);
+
+ RadioGroupFieldEditor imgFormat = new RadioGroupFieldEditor(
+ PreferenceConstants.EXPORT_DIAGRAM_FORMAT,
+ "Image Format for Export:",
+ 4,
+ new String[][] {
+ {"BMP", PreferenceConstants.FORMAT_BMP},
+ {"GIF", PreferenceConstants.FORMAT_GIF},
+ {"JPG", PreferenceConstants.FORMAT_JPG},
+ {"PNG", PreferenceConstants.FORMAT_PNG}
+ },
+ getFieldEditorParent(),
+ true);
+ addField(imgFormat);
+
BooleanFieldEditor useGrid = new BooleanFieldEditor(
PreferenceConstants.USE_GRID,
"Use &Grid (grid settings apply to new diagrams only)",
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceConstants.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceConstants.java
index ccd17a0dc..a36a50563 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceConstants.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceConstants.java
@@ -23,4 +23,17 @@ public class PreferenceConstants extends org.eclipse.etrice.core.ui.editor.Prefe
public static final String VER_GRID_UNIT = "VerGridUnit";
public static final String CONFIRM_DELETE = "ConfirmDelete";
public static final String SAVE_DIAG_ON_FOCUS_LOST = "SaveDiagOnFocusLost";
+ public static final String EXPORT_DIAGRAM_PATH = "ExportDiagramPath";
+ public static final String EXPORT_DIAGRAM_FORMAT = "ExportDiagramFormat";
+ public static final String EXPORT_DIAGRAM_PATH_RELATIVE_TO = "ExportDiagramPathRelativeTo";
+
+ // possible values for EXPORT_DIAGRAM_PATH_RELATIVE_TO
+ public static final String PATH_REL_TO_PROJECT = "project";
+ public static final String PATH_REL_TO_MODEL = "model";
+
+ // possible values for EXPORT_DIAGRAM_FORMAT
+ public static final String FORMAT_BMP = "bmp";
+ public static final String FORMAT_JPG = "jpg";
+ public static final String FORMAT_PNG = "png";
+ public static final String FORMAT_GIF = "gif";
}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceInitializer.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceInitializer.java
index c63f8f581..b019f71cf 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceInitializer.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/preferences/PreferenceInitializer.java
@@ -35,6 +35,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(PreferenceConstants.VER_GRID_UNIT, 10);
store.setDefault(PreferenceConstants.CONFIRM_DELETE, true);
store.setDefault(PreferenceConstants.SAVE_DIAG_ON_FOCUS_LOST, false);
+ store.setDefault(PreferenceConstants.EXPORT_DIAGRAM_PATH, "doc-gen/images");
+ store.setDefault(PreferenceConstants.EXPORT_DIAGRAM_PATH_RELATIVE_TO, PreferenceConstants.PATH_REL_TO_PROJECT);
+ store.setDefault(PreferenceConstants.EXPORT_DIAGRAM_FORMAT, PreferenceConstants.FORMAT_JPG);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
index 067a85a2e..b2f9f779e 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
@@ -20,7 +20,7 @@ import org.eclipse.etrice.ui.structure.DiagramAccess;
public class StructureExporter {
- private static final String SUFFIX = "_structure.jpg";
+ private static final String SUFFIX = "_structure";
public static void export(StructureClass ac, String folder) {
DiagramAccess da = new DiagramAccess();

Back to the top