From 0c7e01c408c9a0987938cca0d95388cfd7aa88c6 Mon Sep 17 00:00:00 2001 From: tms08012 Date: Wed, 6 Jun 2012 23:41:47 -0400 Subject: [PATCH] VioletProductEclipsePlugin --- .../VioletProduct.eclipse-plugin/.classpath | 17 ++ .../VioletProduct.eclipse-plugin/.project | 17 ++ .../trunk/.classpath | 8 + .../trunk/.project | 28 ++ .../.settings/org.eclipse.jdt.core.prefs | 12 + .../trunk/build.properties | 7 + .../trunk/plugin.xml | 58 ++++ .../violet/eclipseplugin/VioletPlugin.java | 138 ++++++++++ .../eclipseplugin/actions/PrintAction.java | 99 +++++++ .../editors/DiagramComposite.java | 152 +++++++++++ .../editors/EclipseColorPicker.java | 164 ++++++++++++ .../editors/EclipseDialogFactory.java | 141 ++++++++++ .../eclipseplugin/editors/EclipseTheme.java | 187 +++++++++++++ .../editors/FileDropTargetListener.java | 182 +++++++++++++ .../editors/VioletUMLEditor.java | 236 ++++++++++++++++ .../file/EclipseFileChooserService.java | 84 ++++++ .../eclipseplugin/file/EclipseFileOpener.java | 55 ++++ .../eclipseplugin/file/EclipseFileSaver.java | 80 ++++++ .../eclipseplugin/tools/DiagramPrinter.java | 253 ++++++++++++++++++ .../eclipseplugin/tools/EclipseUtils.java | 65 +++++ .../eclipseplugin/tools/JavaFileModel.java | 167 ++++++++++++ .../wizards/NewActivityDiagramWizard.java | 55 ++++ .../wizards/NewClassDiagramWizard.java | 56 ++++ .../wizards/NewObjectDiagramWizard.java | 55 ++++ .../wizards/NewSequenceDiagramWizard.java | 55 ++++ .../wizards/NewStateDiagramWizard.java | 55 ++++ .../wizards/NewUseCaseDiagramWizard.java | 55 ++++ .../eclipseplugin/wizards/NewWizard.java | 236 ++++++++++++++++ .../dedicatedApplicationContext-eclipse.xml | 17 ++ 29 files changed, 2734 insertions(+) create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.classpath create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.project create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.classpath create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.project create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.settings/org.eclipse.jdt.core.prefs create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/build.properties create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/plugin.xml create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/VioletPlugin.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/actions/PrintAction.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/DiagramComposite.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseColorPicker.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseDialogFactory.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseTheme.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/FileDropTargetListener.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/VioletUMLEditor.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileChooserService.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileOpener.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileSaver.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/DiagramPrinter.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/EclipseUtils.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/JavaFileModel.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewActivityDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewClassDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewObjectDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewSequenceDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewStateDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewUseCaseDiagramWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewWizard.java create mode 100644 VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/dedicatedApplicationContext-eclipse.xml diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.classpath b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.classpath new file mode 100644 index 0000000..9906b1f --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.project b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.project new file mode 100644 index 0000000..ac0f2df --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/.project @@ -0,0 +1,17 @@ + + + VioletProduct.eclipse-plugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.classpath b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.classpath new file mode 100644 index 0000000..c46a273 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.project b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.project new file mode 100644 index 0000000..0470b2a --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.project @@ -0,0 +1,28 @@ + + + VioletProduct.eclipse-plugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.settings/org.eclipse.jdt.core.prefs b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b1a7bd9 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Sat Mar 19 01:56:39 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/build.properties b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/build.properties new file mode 100644 index 0000000..74c065a --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + build.properties,\ + lib/ diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/plugin.xml b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/plugin.xml new file mode 100644 index 0000000..b24a04b --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/plugin.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/VioletPlugin.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/VioletPlugin.java new file mode 100644 index 0000000..04cada1 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/VioletPlugin.java @@ -0,0 +1,138 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.horstmann.violet.eclipseplugin.editors.EclipseDialogFactory; +import com.horstmann.violet.eclipseplugin.file.EclipseFileChooserService; +import com.horstmann.violet.framework.dialog.DialogFactory; +import com.horstmann.violet.framework.dialog.DialogFactoryMode; +import com.horstmann.violet.framework.file.chooser.IFileChooserService; +import com.horstmann.violet.framework.file.persistence.IFilePersistenceService; +import com.horstmann.violet.framework.file.persistence.StandardJavaFilePersistenceService; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanFactory; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanInjector; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.InjectedBean; +import com.horstmann.violet.framework.plugin.PluginLoader; +import com.horstmann.violet.framework.theme.ITheme; +import com.horstmann.violet.framework.theme.ThemeManager; +import com.horstmann.violet.framework.userpreferences.DefaultUserPreferencesDao; +import com.horstmann.violet.framework.userpreferences.IUserPreferencesDao; + +/** + * The main plugin class to be used in the desktop. This plugin embeds Violet in Eclipse + * + * @author Alexandre de Pellegrin + */ +public class VioletPlugin extends AbstractUIPlugin +{ + + // The shared instance. + private static VioletPlugin plugin; + + @InjectedBean + private PluginLoader pluginLoader; + + /** + * The constructor. + */ + public VioletPlugin() + { + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception + { + super.start(context); + initBeanFactory(); + BeanInjector.getInjector().inject(this); + EclipseDialogFactory.init(); + installPlugins(); + } + + private void initBeanFactory() { + IUserPreferencesDao userPreferencesDao = new DefaultUserPreferencesDao(); + BeanFactory.getFactory().register(IUserPreferencesDao.class, userPreferencesDao); + + ThemeManager themeManager = new ThemeManager(); + List themeList = new ArrayList(); + themeManager.setInstalledThemes(themeList); + BeanFactory.getFactory().register(ThemeManager.class, themeManager); + + IFilePersistenceService filePersistenceService = new StandardJavaFilePersistenceService(); + BeanFactory.getFactory().register(IFilePersistenceService.class, filePersistenceService); + + DialogFactory dialogFactory = new DialogFactory(DialogFactoryMode.DELEGATED); + BeanFactory.getFactory().register(DialogFactory.class, dialogFactory); + + IFileChooserService fileChooserService = new EclipseFileChooserService(); + BeanFactory.getFactory().register(IFileChooserService.class, fileChooserService); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception + { + super.stop(context); + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static VioletPlugin getDefault() + { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) + { + return AbstractUIPlugin.imageDescriptorFromPlugin("VioletPlugin", path); + } + + /** + * Install plugins + */ + private void installPlugins() + { + + this.pluginLoader.installPlugins(); + } + + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/actions/PrintAction.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/actions/PrintAction.java new file mode 100644 index 0000000..190000d --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/actions/PrintAction.java @@ -0,0 +1,99 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IEditorPart; + +import com.horstmann.violet.eclipseplugin.editors.VioletUMLEditor; +import com.horstmann.violet.eclipseplugin.tools.DiagramPrinter; +import com.horstmann.violet.workspace.IWorkspace; + +/** + * Eclipse plugin print action + * + * @author Alexandre de Pellegrin + * + */ +public class PrintAction implements IEditorActionDelegate +{ + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface .action.IAction, org.eclipse.ui.IEditorPart) + */ + public void setActiveEditor(IAction action, IEditorPart targetEditor) + { + this.setActiveEditor((VioletUMLEditor) targetEditor); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) + { + IWorkspace workspace = this.getActiveEditor().getUMLDiagramPanel(); + Shell shell = this.getActiveEditor().getSite().getShell(); + DiagramPrinter printer = new DiagramPrinter(workspace, shell); + printer.print(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action .IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) + { + // TODO Auto-generated method stub + } + + /** + * @return editor instance + */ + private VioletUMLEditor getActiveEditor() + { + return activeEditor; + } + + /** + * Sets editor instance + * + * @param activeEditor + */ + private void setActiveEditor(VioletUMLEditor activeEditor) + { + this.activeEditor = activeEditor; + } + + /** + * Editor instance + */ + private VioletUMLEditor activeEditor; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/DiagramComposite.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/DiagramComposite.java new file mode 100644 index 0000000..bf0c4d7 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/DiagramComposite.java @@ -0,0 +1,152 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Component; +import java.awt.Frame; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; + +import javax.swing.JScrollPane; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +import com.horstmann.violet.workspace.IWorkspace; +import com.horstmann.violet.workspace.WorkspacePanel; +import com.horstmann.violet.workspace.editorpart.IEditorPart; +import com.horstmann.violet.workspace.sidebar.ISideBar; + +/** + * Main Eclipse plugin GUI component + * + * @author Alexandre de Pellegrin + * + */ +public class DiagramComposite extends Composite +{ + + /** + * Default construcctor + * + * @param parent component + * @param workspacePanel swing panel + */ + public DiagramComposite(final Composite parent, IWorkspace workspacePanel) + { + super(parent, SWT.EMBEDDED | SWT.BORDER); + + this.workspacePanel = workspacePanel; + this.fixLayoutProblem(this.workspacePanel); + this.initializePanel(this.workspacePanel, parent); + this.frame = SWT_AWT.new_Frame(this); + + this.frame.setVisible(true); + this.frame.add(workspacePanel.getAWTComponent()); + this.frame.pack(); + + GridData gridData2 = new GridData(GridData.FILL_BOTH); + this.setLayoutData(gridData2); + + } + + /** + * Retuen UML Graph diagram panel (JPanel) + * + * @return + */ + private void initializePanel(IWorkspace diagramPanel, final Composite parent) + { + final IEditorPart editorPart = diagramPanel.getEditorPart(); + final ISideBar sideBar = diagramPanel.getSideBar(); + this.addListener(SWT.KeyUp, new Listener() + { + public void handleEvent(Event event) + { + if (event.keyCode == SWT.DEL) + { + editorPart.removeSelected(); + } + } + + }); + + /* tms this.addListener(SWT.MouseWheel, new Listener() + { + public void handleEvent(Event event) + { + if (event.count > 0) + { + sideBar.getGraphToolsBar().selectPreviousTool(); + } + if (event.count < 0) + { + sideBar.getGraphToolsBar().selectNextTool(); + } + } + });*/ + + this.addListener(SWT.Activate, new Listener() + { + public void handleEvent(Event e) + { + setFocus(); + } + }); + + } + + /** + * Fixes layout (and repaint problem) on side bar collapsing + * + * @param diagramPanel + */ + private void fixLayoutProblem(IWorkspace diagramPanel) + { + final Component sideBar = diagramPanel.getSideBar().getAWTComponent(); + WorkspacePanel workspacePanel = (WorkspacePanel) diagramPanel.getAWTComponent(); + final JScrollPane scrollPane = workspacePanel.getScrollableEditorPart(); + sideBar.addComponentListener(new ComponentAdapter() + { + public void componentResized(ComponentEvent e) + { + sideBar.validate(); + scrollPane.validate(); + } + }); + } + + /** + * UML diagram panel + */ + private IWorkspace workspacePanel; + + /** + * Diagram Panel + */ + private Frame frame; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseColorPicker.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseColorPicker.java new file mode 100644 index 0000000..bea06a0 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseColorPicker.java @@ -0,0 +1,164 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Color; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +/** + * This class picks Eclipse colors to allow to integrate this software as a plugin. By the way, it will respect as long as possible + * Eclipse look and feel. + * + * @author Alexandre de Pellegrin + * + */ +public class EclipseColorPicker +{ + + /** + * Default constructor + * + * @param display current workspace display instance + */ + public EclipseColorPicker(Display display) + { + this.display = display; + } + + /** + * @return background color + */ + public Color getBackGroundColor() + { + if (this.backgroundColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB(); + this.backgroundColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.backgroundColor; + } + + /** + * @return foreground color + */ + public Color getForeGroundColor() + { + if (this.foregroundColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB(); + this.foregroundColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.foregroundColor; + } + + /** + * @return title background color + */ + public Color getTitleBgColor() + { + if (this.titleBgColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(); + this.titleBgColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.titleBgColor; + } + + /** + * @return title background gradiant color + */ + public Color getTitleBgColorGradient() + { + if (this.titleBgColorGradient == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT).getRGB(); + this.titleBgColorGradient = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.titleBgColorGradient; + } + + /** + * @return title foreground color + */ + public Color getTitleFgColor() + { + if (this.titleFgColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND).getRGB(); + this.titleFgColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.titleFgColor; + } + + /** + * @return border color + */ + public Color getBorderColor() + { + if (this.borderColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_WIDGET_BORDER).getRGB(); + this.borderColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.borderColor; + } + + /** + * @return light shadow color + */ + public Color getLightShadowColor() + { + if (this.lightShadowColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB(); + this.lightShadowColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.lightShadowColor; + } + + /** + * @return normal shadow color + */ + public Color getNormalShadowColor() + { + if (this.normalShadowColor == null) + { + RGB rgb = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW).getRGB(); + this.normalShadowColor = new Color(rgb.red, rgb.green, rgb.blue); + } + return this.normalShadowColor; + } + + private Display display; + private Color backgroundColor; + private Color foregroundColor; + private Color titleBgColor; + private Color titleBgColorGradient; + private Color titleFgColor; + private Color borderColor; + private Color lightShadowColor; + private Color normalShadowColor; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseDialogFactory.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseDialogFactory.java new file mode 100644 index 0000000..ac0d0ff --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseDialogFactory.java @@ -0,0 +1,141 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Container; +import java.awt.Frame; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import com.horstmann.violet.framework.dialog.DialogFactory; +import com.horstmann.violet.framework.dialog.DialogFactoryListener; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanInjector; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.InjectedBean; +import com.horstmann.violet.framework.theme.ThemeManager; + +/** + * The dialog manager has to display dialogs sent by the Violet dialog factory (since Violet cannot display its directly when it is + * embedded in Eclipse) + * + * The manager is a singleton. Only one instance is needed for all editor instances. + * + * @author Alexandre de Pellegrin + * + */ +public class EclipseDialogFactory +{ + /** + * Private constructor (singleton) + */ + private EclipseDialogFactory() + { + BeanInjector.getInjector().inject(this); + dialogFactory.setListener(new DialogFactoryListener() + { + + public void mustDisplayPanel(JOptionPane optionPane, String title, boolean isModal) + { + displayOptionPane(optionPane, title, isModal); + } + }); + } + + /** + * Initializes singleton instance (called on pluhin startup) + */ + public static void init() + { + if (dialogManager == null) + { + dialogManager = new EclipseDialogFactory(); + } + } + + /** + * Displays a swing option pane + * + * @param optionPane + * @param title + * @param parent + */ + private void displayOptionPane(final JOptionPane optionPane, final String title, final boolean isModal) + { + final Display d = Display.getDefault(); + // Note : the asyncrhonous is important to let Eclipse initialize its shell + d.asyncExec(new Runnable() + { + public void run() + { + Shell shell = d.getActiveShell(); + // Add swing frames + final Composite awtContainer = new Composite(shell, SWT.EMBEDDED); + final Frame frame = SWT_AWT.new_Frame(awtContainer); + frame.setVisible(false); + final JDialog dialog = new JDialog(frame); + dialog.setTitle(title); + Container contentPane = dialog.getContentPane(); + contentPane.setBackground(ThemeManager.getInstance().getTheme().getBackgroundColor()); + contentPane.add(optionPane); + dialog.pack(); + int x = shell.getLocation().x + shell.getBounds().width / 2 - dialog.getWidth() / 2; + int y = shell.getLocation().y + shell.getBounds().height / 2 - dialog.getHeight() / 2; + dialog.setLocation(x, y); + dialog.setVisible(true); + optionPane.addPropertyChangeListener(new PropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + if (dialog.isVisible() && (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) + && event.getNewValue() != null && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) + { + dialog.dispose(); + d.syncExec(new Runnable() + { + public void run() + { + awtContainer.dispose(); + } + }); + } + } + }); + } + }); + } + + /** + * Unique class instance + */ + private static EclipseDialogFactory dialogManager; + + @InjectedBean + private DialogFactory dialogFactory; +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseTheme.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseTheme.java new file mode 100644 index 0000000..2c78735 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/EclipseTheme.java @@ -0,0 +1,187 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.plaf.metal.MetalLookAndFeel; + +import com.horstmann.violet.framework.theme.AbstractTheme; +import com.horstmann.violet.framework.theme.ThemeInfo; + + +/** + * Eclipse theme used when the software run as an embedded plugin + * + * @author Alexandre de Pellegrin + * + */ +public class EclipseTheme extends AbstractTheme { + + /** + * Default constructor + * + * @param colorManager + * handles color from the Eclipse environement + */ + public EclipseTheme(EclipseColorPicker colorManager) { + this.colorManager = colorManager; + } + + + @Override + public ThemeInfo getThemeInfo() { + return new ThemeInfo("Eclipse", EclipseTheme.class, MetalLookAndFeel.class); + } + + @Override + protected void configure() { + } + + public Color getBlackColor() { + return Color.BLACK; + } + + public Color getWhiteColor() { + return Color.WHITE; + } + + public Color getGridColor() { + return new Color(240, 240, 240); + } + + public Color getBackgroundColor() { + return colorManager.getBackGroundColor(); + } + + public Font getMenubarFont() { + return MetalLookAndFeel.getMenuTextFont(); + } + + public Color getMenubarBackgroundColor() { + return colorManager.getBackGroundColor(); + } + + public Color getMenubarForegroundColor() { + return colorManager.getForeGroundColor(); + } + + public Color getRolloverButtonDefaultColor() { + return colorManager.getBackGroundColor(); + } + + public Color getRolloverButtonRolloverBorderColor() { + return colorManager.getForeGroundColor(); + } + + public Color getRolloverButtonRolloverColor() { + return colorManager.getBackGroundColor(); + } + + public Color getSidebarBackgroundEndColor() { + return colorManager.getBackGroundColor(); + } + + public Color getSidebarBackgroundStartColor() { + return colorManager.getBackGroundColor(); + } + + public Color getSidebarBorderColor() { + return colorManager.getNormalShadowColor(); + } + + public Color getSidebarElementBackgroundColor() { + return colorManager.getBackGroundColor(); + } + + public Color getSidebarElementTitleBackgroundEndColor() { + return colorManager.getTitleBgColorGradient(); + } + + public Color getSidebarElementTitleBackgroundStartColor() { + return colorManager.getTitleBgColor(); + } + + public Color getSidebarElementForegroundColor() { + return colorManager.getTitleFgColor(); + } + + public Color getSidebarElementTitleOverColor() { + return colorManager.getTitleFgColor().brighter(); + } + + public Color getStatusbarBackgroundColor() { + return colorManager.getBackGroundColor(); + } + + public Color getStatusbarBorderColor() { + return colorManager.getNormalShadowColor(); + } + + public Font getToggleButtonFont() { + return MetalLookAndFeel.getMenuTextFont().deriveFont(Font.PLAIN); + } + + public Color getToggleButtonSelectedBorderColor() { + return new Color(107, 144, 188); + } + + public Color getToggleButtonSelectedColor() { + return new Color(192, 220, 242); + } + + public Color getToggleButtonUnselectedColor() { + return getSidebarElementBackgroundColor(); + } + + public Font getWelcomeSmallFont() { + return MetalLookAndFeel.getWindowTitleFont().deriveFont((float) 12.0) + .deriveFont(Font.PLAIN); + } + + public Font getWelcomeBigFont() { + return MetalLookAndFeel.getWindowTitleFont().deriveFont((float) 28.0); + } + + public Color getWelcomeBackgroundEndColor() { + return getSidebarBackgroundStartColor(); + } + + public Color getWelcomeBackgroundStartColor() { + return getSidebarBackgroundEndColor().brighter(); + } + + public Color getWelcomeBigForegroundColor() { + return Color.WHITE; + } + + public Color getWelcomeBigRolloverForegroundColor() { + return new Color(255, 203, 151); + } + + /** + * Contains Eclipse colors + */ + private EclipseColorPicker colorManager; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/FileDropTargetListener.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/FileDropTargetListener.java new file mode 100644 index 0000000..de314d2 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/FileDropTargetListener.java @@ -0,0 +1,182 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Point; +import java.io.File; + +import org.eclipse.core.resources.IResource; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.DropTargetListener; + +import com.horstmann.violet.eclipseplugin.tools.JavaFileModel; +import com.horstmann.violet.framework.file.IFile; +import com.horstmann.violet.framework.file.LocalFile; +import com.horstmann.violet.product.diagram.abstracts.node.INode; +import com.horstmann.violet.product.diagram.classes.ClassDiagramGraph; +import com.horstmann.violet.product.diagram.common.DiagramLink; +import com.horstmann.violet.product.diagram.common.DiagramLinkNode; +import com.horstmann.violet.product.diagram.sequence.SequenceDiagramGraph; +import com.horstmann.violet.workspace.editorpart.IEditorPart; + +/** + * Class used to manage drag n' drop between Eclipse package explorer and + * Violet's editor instance. In other words, this is the most important class to + * import Java files into diagrams. + * + * @author Alexandre de Pellegrin + */ +public class FileDropTargetListener implements DropTargetListener { + + /** + * Default constructor + * + * @param graphPanel + * containing the target graph + */ + public FileDropTargetListener(IEditorPart graphPanel) { + this.UMLGraphPanel = graphPanel; + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#dragEnter(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void dragEnter(DropTargetEvent event) { + // Nothing to do here + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#dragLeave(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void dragLeave(DropTargetEvent event) { + // Nothing to do here + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void dragOperationChanged(DropTargetEvent event) { + // Nothing to do here + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#dragOver(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void dragOver(DropTargetEvent event) { + // Nothing to do here + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void drop(DropTargetEvent event) { + Point UMLGraphPanelLocationOnScreen = this.UMLGraphPanel.getSwingComponent().getLocationOnScreen(); + Point mouseLocationOnUMLGraphPanel = new Point(event.x - UMLGraphPanelLocationOnScreen.x, event.y - UMLGraphPanelLocationOnScreen.y); + + Object dropObject = event.data; + // A drop has occurred, copy over the data + if (dropObject != null && dropObject instanceof IResource[]) { + IResource rs = ((IResource[]) dropObject)[0]; + this.UMLGraphPanel.getSwingComponent().repaint(); + if (VIOLET_FILE_EXTENSION.equals(rs.getFileExtension().toLowerCase())) { + addVioletLinkNode(event, mouseLocationOnUMLGraphPanel, rs); + return; + } + if (JAVA_FILE_EXTENSION.equals(rs.getFileExtension().toLowerCase())) { + importJavaFile(event, mouseLocationOnUMLGraphPanel, rs); + return; + } + } + event.detail = DND.DROP_NONE; + } + + /** + * Parses a Java file and creates a new node in the current diagram with its + * properties + */ + private void importJavaFile(DropTargetEvent event, Point mouseLocationOnUMLGraphPanel, IResource rs) { + event.detail = DND.DROP_LINK; + File javaFile = rs.getLocation().toFile(); + JavaFileModel jfm = new JavaFileModel(javaFile); + INode node = null; + + boolean added = false; + + // For class diagram + if (this.UMLGraphPanel.getGraph().getClass().equals(ClassDiagramGraph.class)) { + node = jfm.getClassNode(); + added = this.UMLGraphPanel.getGraph().addNode(node, mouseLocationOnUMLGraphPanel); + } + + // For sequence diagram + if (this.UMLGraphPanel.getGraph().getClass().equals(SequenceDiagramGraph.class)) { + node = jfm.getLifelineNode(); + added = this.UMLGraphPanel.getGraph().addNode(node, mouseLocationOnUMLGraphPanel); + } + + if (added) { + this.UMLGraphPanel.selectElement(node); + this.UMLGraphPanel.getSwingComponent().repaint(); + } + } + + /** + * When the dropped file has Violet's extension, creates a diagram link on + * the current one + */ + private void addVioletLinkNode(DropTargetEvent event, Point mouseLocationOnUMLGraphPanel, IResource rs) { + try { + event.detail = DND.DROP_LINK; + File violetFile = rs.getLocation().toFile(); + IFile localFile = new LocalFile(violetFile); + DiagramLink link = new DiagramLink(); + link.setFile(localFile); + DiagramLinkNode linkNode = new DiagramLinkNode(); + linkNode.setDiagramLink(link); + boolean added = this.UMLGraphPanel.getGraph().addNode(linkNode, mouseLocationOnUMLGraphPanel); + if (added) { + this.UMLGraphPanel.selectElement(linkNode); + this.UMLGraphPanel.getSwingComponent().repaint(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * @see org.eclipse.swt.dnd.DropTargetListener#dropAccept(org.eclipse.swt.dnd.DropTargetEvent) + */ + public void dropAccept(DropTargetEvent event) { + // Nothing to do here + } + + /** Java file extension */ + private static final String JAVA_FILE_EXTENSION = "java"; + + /** violet file extension */ + private static final String VIOLET_FILE_EXTENSION = "violet"; + + /** Current UML Graph Panel */ + private IEditorPart UMLGraphPanel; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/VioletUMLEditor.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/VioletUMLEditor.java new file mode 100644 index 0000000..761138e --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/editors/VioletUMLEditor.java @@ -0,0 +1,236 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.editors; + +import java.awt.Component; +import java.io.File; +import java.net.URI; +import java.net.URL; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTarget; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +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.EditorPart; +import org.eclipse.ui.part.ResourceTransfer; + +import com.horstmann.violet.eclipseplugin.file.EclipseFileChooserService; +import com.horstmann.violet.eclipseplugin.tools.EclipseUtils; +import com.horstmann.violet.framework.file.GraphFile; +import com.horstmann.violet.framework.file.IGraphFile; +import com.horstmann.violet.framework.file.LocalFile; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanInjector; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.InjectedBean; +import com.horstmann.violet.framework.theme.ITheme; +import com.horstmann.violet.framework.theme.ThemeManager; +import com.horstmann.violet.workspace.IWorkspace; +import com.horstmann.violet.workspace.IWorkspaceListener; +import com.horstmann.violet.workspace.Workspace; + +/** + * Main Editor Part + * + * @author Alexandre de Pellegrin + * + */ +public class VioletUMLEditor extends EditorPart +{ + + + + /** + * Performs saving + */ + @Override + public void doSave(IProgressMonitor monitor) + { + this.fileChooserService.changeProgressMonitor(monitor); + this.getUMLDiagramPanel().getGraphFile().save(); + firePropertyChange(EditorPart.PROP_DIRTY); + } + + /** + * @see org.eclipse.ui.ISaveablePart#doSaveAs() + */ + @Override + public void doSaveAs() + { + // Nothing to do here. Files are always created with the wizard + } + + /** + * Initializes editor + */ + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException + { + BeanInjector.getInjector().inject(this); + setInput(input); + setSite(site); + // Retreive file input + if (input instanceof IFileEditorInput) + { + IFileEditorInput fe = (IFileEditorInput) input; + IFile file = fe.getFile(); + this.fileChooserService.setEclipseFile(file); + // Update part editor title + this.setPartName(file.getName()); + } + + } + + + + /** + * @see org.eclipse.ui.ISaveablePart#isDirty() + */ + @Override + public boolean isDirty() + { + IWorkspace umlDiagramPanel = this.getUMLDiagramPanel(); + IGraphFile graphFile = umlDiagramPanel.getGraphFile(); + return graphFile.isSaveRequired(); + } + + /** + * @see org.eclipse.ui.IWorkbenchPart#setFocus() + */ + @Override + public void setFocus() + { + // Nothing to do here. + } + + /** + * 'Save As' is disabled + */ + @Override + public boolean isSaveAsAllowed() + { + return false; + } + + /** + * Builds editor with embedded JPanels + */ + @Override + public void createPartControl(Composite parent) + { + // Set parent layout + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + parent.setLayout(gridLayout); + + EclipseColorPicker eclipseColorPicker = new EclipseColorPicker(getSite().getShell().getDisplay()); + ITheme eclipseTheme = new EclipseTheme(eclipseColorPicker); + ThemeManager.getInstance().switchToTheme(eclipseTheme); + + IWorkspace workspacePanel = this.getUMLDiagramPanel(); + Component awtComponent = workspacePanel.getAWTComponent(); + new DiagramComposite(parent, workspacePanel); + + int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; + Transfer[] types = new Transfer[] + { + ResourceTransfer.getInstance() + }; + DropTarget target = new DropTarget(parent, operations); + target.setTransfer(types); + target.addDropListener(new FileDropTargetListener(workspacePanel.getEditorPart())); + + } + + /** + * Return master Violet Frame. Usefull to retreive graph and toolbar + * + * @return + */ + public IWorkspace getUMLDiagramPanel() + { + if (this.UMLWorkspace == null) + { + try { + IGraphFile graphFile = new GraphFile(fileChooserService.chooseAndGetFileReader().getFileDefinition()); + this.UMLWorkspace = new Workspace(graphFile); + this.UMLWorkspace.addListener(new IWorkspaceListener() { + @Override + public void titleChanged(String newTitle) { + } + + @Override + public void mustOpenfile(com.horstmann.violet.framework.file.IFile file) { + try { + IEditorSite site = getEditorSite(); + Display d = site.getShell().getDisplay(); + LocalFile localFile = new LocalFile(file); + File javaFile = localFile.toFile(); + URI uri = javaFile.toURI(); + URL url = uri.toURL(); + EclipseUtils.openUMLDiagram(url, d); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void graphCouldBeSaved() { + IEditorSite site = getEditorSite(); + if (site != null) + { + Display d = site.getShell().getDisplay(); + d.asyncExec(new Runnable() + { + public void run() + { + firePropertyChange(EditorPart.PROP_DIRTY); + } + }); + } + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return this.UMLWorkspace; + } + + public static final String ID = "com.horstmann.violet.eclipseplugin.editors.VioletUMLEditor"; + + /** UML diagram swing panel */ + private IWorkspace UMLWorkspace; + + @InjectedBean + private EclipseFileChooserService fileChooserService; + + + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileChooserService.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileChooserService.java new file mode 100644 index 0000000..aee3269 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileChooserService.java @@ -0,0 +1,84 @@ +package com.horstmann.violet.eclipseplugin.file; + +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com.horstmann.violet.framework.file.IFile; +import com.horstmann.violet.framework.file.chooser.IFileChooserService; +import com.horstmann.violet.framework.file.naming.ExtensionFilter; +import com.horstmann.violet.framework.file.persistence.IFileReader; +import com.horstmann.violet.framework.file.persistence.IFileWriter; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.ManagedBean; + +@ManagedBean(registeredManually=true) +public class EclipseFileChooserService implements IFileChooserService +{ + + private org.eclipse.core.resources.IFile eclipseFile; + + private EclipseFileSaver eclipseFileSaver; + + private IFileReader eclipseFileOpener; + + private EclipseFileSaver getFileSaver() + { + if (this.eclipseFileSaver == null) + { + if (this.eclipseFile == null) throw new RuntimeException("Eclipse file must be set before EclipseFileSaver creation"); + this.eclipseFileSaver = new EclipseFileSaver(this.eclipseFile); + } + return this.eclipseFileSaver; + } + + public void setEclipseFile(org.eclipse.core.resources.IFile eclipseFile) + { + this.eclipseFile = eclipseFile; + } + + public void changeProgressMonitor(IProgressMonitor progressMonitor) + { + getFileSaver().setProgressMonitor(progressMonitor); + } + + @Override + public boolean isWebStart() + { + return false; + } + + @Override + public IFileReader chooseAndGetFileReader() throws IOException + { + if (this.eclipseFileOpener == null) + { + if (this.eclipseFile == null) throw new RuntimeException("Eclipse file must be set before EclipseFileOpener creation"); + this.eclipseFileOpener = new EclipseFileOpener(this.eclipseFile); + } + return this.eclipseFileOpener; + } + + @Override + public IFileReader getFileReader(IFile arg0) throws IOException + { + if (this.eclipseFileOpener == null) + { + if (this.eclipseFile == null) throw new RuntimeException("Eclipse file must be set before EclipseFileOpener creation"); + this.eclipseFileOpener = new EclipseFileOpener(this.eclipseFile); + } + return this.eclipseFileOpener; + } + + @Override + public IFileWriter chooseAndGetFileWriter(ExtensionFilter... arg0) throws IOException + { + return this.getFileSaver(); + } + + @Override + public IFileWriter getFileWriter(IFile arg0) throws IOException + { + return this.getFileSaver(); + } + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileOpener.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileOpener.java new file mode 100644 index 0000000..d274638 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileOpener.java @@ -0,0 +1,55 @@ +package com.horstmann.violet.eclipseplugin.file; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; + +import com.horstmann.violet.framework.file.IFile; +import com.horstmann.violet.framework.file.persistence.IFileReader; + +public class EclipseFileOpener implements IFileReader { + + private org.eclipse.core.resources.IFile eclipseFile; + + private IFile fileDefinition; + + + public EclipseFileOpener(org.eclipse.core.resources.IFile eclipseFile) { + this.eclipseFile = eclipseFile; + } + + @Override + public IFile getFileDefinition() throws IOException { + if (this.fileDefinition == null) { + this.fileDefinition = new IFile() { + @Override + public String getDirectory() { + IContainer parent = eclipseFile.getParent(); + URI parentURI = parent.getLocationURI(); + String directory = parentURI.getPath(); + return directory; + } + + @Override + public String getFilename() { + String name = eclipseFile.getName(); + return name; + } + }; + } + return this.fileDefinition; + } + + @Override + public InputStream getInputStream() throws IOException { + try { + return this.eclipseFile.getContents(); + } catch (CoreException e) { + throw new IOException(e); + } + } + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileSaver.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileSaver.java new file mode 100644 index 0000000..08c56f1 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/file/EclipseFileSaver.java @@ -0,0 +1,80 @@ +package com.horstmann.violet.eclipseplugin.file; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import com.horstmann.violet.framework.file.IFile; +import com.horstmann.violet.framework.file.persistence.IFileWriter; + +public class EclipseFileSaver implements IFileWriter { + + private org.eclipse.core.resources.IFile eclipseFile; + + private IFile fileDefinition; + + private IProgressMonitor progressMonitor; + + + public EclipseFileSaver(org.eclipse.core.resources.IFile eclipseFile) { + this.eclipseFile = eclipseFile; + } + + @Override + public IFile getFileDefinition() throws IOException { + if (this.fileDefinition == null) { + this.fileDefinition = new IFile() { + @Override + public String getDirectory() { + IContainer parent = eclipseFile.getParent(); + URI parentURI = parent.getLocationURI(); + String directory = parentURI.getPath(); + return directory; + } + + @Override + public String getFilename() { + String name = eclipseFile.getName(); + return name; + } + }; + } + return this.fileDefinition; + } + + @Override + public OutputStream getOutputStream() throws IOException { + if (getProgressMonitor() == null) { + throw new RuntimeException("Eclipse progress monitor must be initialized before saving file"); + } + ByteArrayOutputStream bos = new ByteArrayOutputStream() { + @Override + public void close() throws IOException { + super.close(); + byte[] byteArray = toByteArray(); + ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); + try { + eclipseFile.setContents(bis, true, true, getProgressMonitor()); + } catch (CoreException e) { + throw new IOException(e); + } + } + }; + return bos; + } + + public void setProgressMonitor(IProgressMonitor progressMonitor) { + this.progressMonitor = progressMonitor; + } + + private IProgressMonitor getProgressMonitor() { + return this.progressMonitor; + } + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/DiagramPrinter.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/DiagramPrinter.java new file mode 100644 index 0000000..49cebe8 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/DiagramPrinter.java @@ -0,0 +1,253 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.tools; + +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DirectColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.WritableRaster; + +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.PaletteData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.printing.PrintDialog; +import org.eclipse.swt.printing.Printer; +import org.eclipse.swt.printing.PrinterData; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; + +import com.horstmann.violet.framework.file.IGraphFile; +import com.horstmann.violet.framework.file.export.FileExportService; +import com.horstmann.violet.product.diagram.abstracts.IGraph; +import com.horstmann.violet.workspace.IWorkspace; + +/** + * Allows to print a diagram through Eclipse + * + * @author Alexandre de Pellegrin + */ +public class DiagramPrinter +{ + + /** + * Default constructor + * + * @param newDiagramPanel + * @param newShell + */ + public DiagramPrinter(IWorkspace workspace, Shell newShell) + { + this.diagramPanel = workspace; + this.shell = newShell; + } + + /** + * Starts printing + */ + public void print() + { + Display display = this.shell.getDisplay(); + + try + { + IGraphFile graphFile = this.diagramPanel.getGraphFile(); + IGraph graph = graphFile.getGraph(); + FileExportService.getImage(graph); + BufferedImage bufferedImage = FileExportService.getImage(graph); + ImageData imageData = this.convertToSWT(bufferedImage); + + if (imageData == null) + { + throw new Exception("Error while converting AWT BufferedImage to SWT ImageData"); + } + + // Show the Choose Printer dialog + PrintDialog dialog = new PrintDialog(shell, SWT.NULL); + PrinterData printerData = dialog.open(); + + if (printerData != null) + { + // Create the printer object + Printer printer = new Printer(printerData); + // Calculate the scale factor between the screen resolution and + // printer + // resolution in order to correctly size the image for the + // printer + Point screenDPI = display.getDPI(); + Point printerDPI = printer.getDPI(); + int scaleFactor = printerDPI.x / screenDPI.x; + // Determine the bounds of the entire area of the printer + Rectangle trim = printer.computeTrim(0, 0, 0, 0); + + // Start the print job + if (printer.startJob(this.diagramPanel.getFilePath())) + { + if (printer.startPage()) + { + GC gc = new GC(printer); + Image printerImage = new Image(printer, imageData); + // Draw the image + gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor * imageData.width, scaleFactor * imageData.height); + // Clean up + printerImage.dispose(); + gc.dispose(); + printer.endPage(); + } + } + // End the job and dispose the printerIDiagramPanel + printer.endJob(); + printer.dispose(); + } + } + catch (Exception e) + { + MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR); + messageBox.setMessage("Error printing UML Diagram : " + e.getMessage()); + messageBox.open(); + } + } + + public BufferedImage convertToAWT(ImageData data) + { + ColorModel colorModel = null; + PaletteData palette = data.palette; + if (palette.isDirect) + { + colorModel = new DirectColorModel(data.depth, palette.redMask, palette.greenMask, palette.blueMask); + BufferedImage bufferedImage = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(data.width, data.height), false, null); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[3]; + for (int y = 0; y < data.height; y++) + { + for (int x = 0; x < data.width; x++) + { + int pixel = data.getPixel(x, y); + RGB rgb = palette.getRGB(pixel); + pixelArray[0] = rgb.red; + pixelArray[1] = rgb.green; + pixelArray[2] = rgb.blue; + raster.setPixels(x, y, 1, 1, pixelArray); + } + } + return bufferedImage; + } + else + { + RGB[] rgbs = palette.getRGBs(); + byte[] red = new byte[rgbs.length]; + byte[] green = new byte[rgbs.length]; + byte[] blue = new byte[rgbs.length]; + for (int i = 0; i < rgbs.length; i++) + { + RGB rgb = rgbs[i]; + red[i] = (byte) rgb.red; + green[i] = (byte) rgb.green; + blue[i] = (byte) rgb.blue; + } + if (data.transparentPixel != -1) + { + colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel); + } + else + { + colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue); + } + BufferedImage bufferedImage = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(data.width, data.height), false, null); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[1]; + for (int y = 0; y < data.height; y++) + { + for (int x = 0; x < data.width; x++) + { + int pixel = data.getPixel(x, y); + pixelArray[0] = pixel; + raster.setPixel(x, y, pixelArray); + } + } + return bufferedImage; + } + } + + private ImageData convertToSWT(BufferedImage bufferedImage) + { + if (bufferedImage.getColorModel() instanceof DirectColorModel) + { + DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel(); + PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel.getBlueMask()); + ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[3]; + for (int y = 0; y < data.height; y++) + { + for (int x = 0; x < data.width; x++) + { + raster.getPixel(x, y, pixelArray); + int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2])); + data.setPixel(x, y, pixel); + } + } + return data; + } + else if (bufferedImage.getColorModel() instanceof IndexColorModel) + { + IndexColorModel colorModel = (IndexColorModel) bufferedImage.getColorModel(); + int size = colorModel.getMapSize(); + byte[] reds = new byte[size]; + byte[] greens = new byte[size]; + byte[] blues = new byte[size]; + colorModel.getReds(reds); + colorModel.getGreens(greens); + colorModel.getBlues(blues); + RGB[] rgbs = new RGB[size]; + for (int i = 0; i < rgbs.length; i++) + { + rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF, blues[i] & 0xFF); + } + PaletteData palette = new PaletteData(rgbs); + ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette); + data.transparentPixel = colorModel.getTransparentPixel(); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[1]; + for (int y = 0; y < data.height; y++) + { + for (int x = 0; x < data.width; x++) + { + raster.getPixel(x, y, pixelArray); + data.setPixel(x, y, pixelArray[0]); + } + } + return data; + } + return null; + } + + IWorkspace diagramPanel; + Shell shell; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/EclipseUtils.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/EclipseUtils.java new file mode 100644 index 0000000..834d4c1 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/EclipseUtils.java @@ -0,0 +1,65 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.tools; + +import java.net.URL; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; + +public class EclipseUtils +{ + + /** + * Open a UML Diagram file (that will create a new editor instance) + * + * @param arg0 + * @param display + */ + public static void openUMLDiagram(URL arg0, Display display) + { + final IPath path = new Path(arg0.getPath()); + display.asyncExec(new Runnable() + { + public void run() + { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IFile file = IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFileForLocation(path); + try + { + IDE.openEditor(page, file, true); + } + catch (PartInitException e) + { + } + } + }); + } + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/JavaFileModel.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/JavaFileModel.java new file mode 100644 index 0000000..2e6f1eb --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/tools/JavaFileModel.java @@ -0,0 +1,167 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; + +import org.apache.ws.jaxme.js.JavaField; +import org.apache.ws.jaxme.js.JavaMethod; +import org.apache.ws.jaxme.js.JavaSource; +import org.apache.ws.jaxme.js.JavaSourceFactory; +import org.apache.ws.jaxme.js.util.JavaParser; + +import com.horstmann.violet.product.diagram.abstracts.property.MultiLineString; +import com.horstmann.violet.product.diagram.classes.ClassNode; +import com.horstmann.violet.product.diagram.sequence.LifelineNode; + +public class JavaFileModel +{ + + private String className; + + private String[] classMethods; + + private String[] classAttributes; + + public JavaFileModel(File pFile) + { + ArrayList methodsArray = new ArrayList(); + ArrayList attributsArray = new ArrayList(); + try + { + JavaSourceFactory jsf = new JavaSourceFactory(); + JavaParser jp = new JavaParser(jsf); + jp.parse(pFile); + Iterator iter = jsf.getJavaSources(); + if (iter.hasNext()) + { + // Get main class (no inner) + JavaSource js = (JavaSource) iter.next(); + // Get class name + this.setClassName(js.getClassName()); + // Get methods names + JavaMethod[] methods = js.getMethods(); + for (int i = 0; i < methods.length; i++) + { + methodsArray.add(methods[i].getName()); + } + this.setClassMethods((String[]) methodsArray.toArray(new String[methodsArray.size()])); + // Get attributs names + JavaField[] attributs = js.getFields(); + for (int i = 0; i < attributs.length; i++) + { + attributsArray.add(attributs[i].getName()); + } + this.setClassAttributes((String[]) attributsArray.toArray(new String[attributsArray.size()])); + } + } + catch (Exception e) + { + this.setClassName(""); + this.setClassAttributes(new String[] + { + "" + }); + this.setClassMethods(new String[] + { + "" + }); + e.printStackTrace(); + } + } + + public String[] getClassAttributes() + { + return classAttributes; + } + + public void setClassAttributes(String[] classAttributes) + { + this.classAttributes = classAttributes; + } + + public String[] getClassMethods() + { + return classMethods; + } + + public void setClassMethods(String[] classMethods) + { + this.classMethods = classMethods; + } + + public String getClassName() + { + return className; + } + + public void setClassName(String className) + { + this.className = className; + } + + public LifelineNode getLifelineNode() + { + MultiLineString mls; + mls = new MultiLineString(); + mls.setText(this.getClassName()); + LifelineNode seqNode = new LifelineNode(); + seqNode.setName(mls); + return seqNode; + } + + public ClassNode getClassNode() + { + ClassNode classNode = new ClassNode(); + // Set mathods + MultiLineString mls = new MultiLineString(); + StringBuffer text = new StringBuffer(); + for (int i = 0; i < this.getClassMethods().length; i++) + { + text.append(this.getClassMethods()[i]); + text.append("\n"); + } + mls.setText(text.toString()); + mls.setJustification(MultiLineString.LEFT); + classNode.setMethods(mls); + // Set attributs + mls = new MultiLineString(); + text = new StringBuffer(); + for (int i = 0; i < this.getClassAttributes().length; i++) + { + text.append(this.getClassAttributes()[i]); + text.append("\n"); + } + mls.setText(text.toString()); + mls.setJustification(MultiLineString.LEFT); + classNode.setAttributes(mls); + // Set class name + mls = new MultiLineString(); + mls.setText(this.getClassName()); + mls.setSize(MultiLineString.LARGE); + classNode.setName(mls); + return classNode; + } + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewActivityDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewActivityDiagramWizard.java new file mode 100644 index 0000000..0d0cf6a --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewActivityDiagramWizard.java @@ -0,0 +1,55 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.activity.ActivityDiagramGraph; + +/** + * Activity diagram wizard + * + * @author Alexandre de Pellegrin + * + */ +public class NewActivityDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML Activity Diagram"); + this.setUMLGraph(new ActivityDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtension() + */ + public String getFileExtension() + { + return ".activity.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewClassDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewClassDiagramWizard.java new file mode 100644 index 0000000..22a18e0 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewClassDiagramWizard.java @@ -0,0 +1,56 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.classes.ClassDiagramGraph; + +/** + * Class diagram wizard + * + * @author Alexandre de Pellegrin + * + */ + +public class NewClassDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML Class Diagram"); + this.setUMLGraph(new ClassDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtansion() + */ + public String getFileExtension() + { + return ".class.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewObjectDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewObjectDiagramWizard.java new file mode 100644 index 0000000..0195291 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewObjectDiagramWizard.java @@ -0,0 +1,55 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.object.ObjectDiagramGraph; + +/** + * Object diagram wizard + * + * @author Alexandre de Pellegrin + * + */ +public class NewObjectDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML Object Diagram"); + this.setUMLGraph(new ObjectDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtansion() + */ + public String getFileExtension() + { + return ".object.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewSequenceDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewSequenceDiagramWizard.java new file mode 100644 index 0000000..a52a93e --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewSequenceDiagramWizard.java @@ -0,0 +1,55 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.sequence.SequenceDiagramGraph; + +/** + * Sequence diagram wizard + * + * @author Alexandre de Pellegrin + * + */ +public class NewSequenceDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML Sequence Diagram"); + this.setUMLGraph(new SequenceDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtension() + */ + public String getFileExtension() + { + return ".seq.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewStateDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewStateDiagramWizard.java new file mode 100644 index 0000000..2b0c0c7 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewStateDiagramWizard.java @@ -0,0 +1,55 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.state.StateDiagramGraph; + +/** + * State diagram wizard + * + * @author Alexandre de Pellegrin + * + */ +public class NewStateDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML State Diagram"); + this.setUMLGraph(new StateDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtension() + */ + public String getFileExtension() + { + return ".state.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewUseCaseDiagramWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewUseCaseDiagramWizard.java new file mode 100644 index 0000000..fef754c --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewUseCaseDiagramWizard.java @@ -0,0 +1,55 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; + +import com.horstmann.violet.product.diagram.usecase.UseCaseDiagramGraph; + +/** + * Use Case diagram wizard + * + * @author Alexandre de Pellegrin + * + */ +public class NewUseCaseDiagramWizard extends NewWizard +{ + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.setPageTitle("New UML Use Case Diagram"); + this.setUMLGraph(new UseCaseDiagramGraph()); + super.init(workbench, selection); + } + + /* + * (non-Javadoc) + * + * @see com.horstmann.violet.eclipseplugin.wizards.NewWizard#getFileExtension() + */ + public String getFileExtension() + { + return ".ucase.violet"; + } + +} \ No newline at end of file diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewWizard.java b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewWizard.java new file mode 100644 index 0000000..b3fd055 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/wizards/NewWizard.java @@ -0,0 +1,236 @@ +/* + Violet - A program for editing UML diagrams. + + Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) + Alexandre de Pellegrin (http://alexdp.free.fr); + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.horstmann.violet.eclipseplugin.wizards; + +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; +import org.eclipse.ui.ide.IDE; + +import com.horstmann.violet.framework.file.persistence.IFilePersistenceService; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanInjector; +import com.horstmann.violet.framework.injection.bean.ManiocFramework.InjectedBean; +import com.horstmann.violet.product.diagram.abstracts.IGraph; +import com.horstmann.violet.product.diagram.classes.ClassDiagramGraph; + +/** + * Generic diagram creation wizard + * + * @author Alexandre de Pellegrin + * + */ +public abstract class NewWizard extends Wizard implements INewWizard +{ + + private IStructuredSelection selection = null; + + private WizardNewFileCreationPage creationPage = null; + + private String pageTitle; + + private IGraph UMLGraph; + + /** + * Called by eclipse when wizard ends + */ + public boolean performFinish() + { + String fname = creationPage.getFileName(); + if (!fname.toLowerCase().endsWith(getFileExtension())) + { + creationPage.setFileName(fname + getFileExtension()); + } + + if (creationPage.getErrorMessage() != null) return false; + + final IFile file = creationPage.createNewFile(); + + IRunnableWithProgress op = new IRunnableWithProgress() + { + public void run(IProgressMonitor monitor) throws InvocationTargetException + { + try + { + doFinish(file, monitor); + } + catch (CoreException e) + { + throw new InvocationTargetException(e); + } + finally + { + monitor.done(); + } + } + }; + try + { + getContainer().run(true, false, op); + } + catch (InterruptedException e) + { + return false; + } + catch (InvocationTargetException e) + { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + + return true; + + } + + /** + * Called by Eclipse at wizard init + */ + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.selection = selection; + BeanInjector.getInjector().inject(this); + } + + /** + * Construct wizard page (use standard WizardNewFileCreationPage) + */ + public void addPages() + { + creationPage = new WizardNewFileCreationPage(this.getPageTitle(), selection); + creationPage.setTitle(this.getPageTitle()); + creationPage.setDescription("Enter file name."); + addPage(creationPage); + } + + /** + * Get wizard page title + * + * @return + */ + private String getPageTitle() + { + if (this.pageTitle == null) + { + // Return class diagram by default + this.pageTitle = "New UML Class Diagram"; + } + return this.pageTitle; + } + + /** + * Set wizard page title + * + * @param title + */ + public void setPageTitle(String title) + { + this.pageTitle = title; + } + + /** + * Return UML graph diagram model to create + * + * @return class diagram by default if not alredy set + */ + private IGraph getUMLGraph() + { + if (this.UMLGraph == null) + { + this.UMLGraph = new ClassDiagramGraph(); + } + return this.UMLGraph; + } + + /** + * Set UML graph diagram model to create + * + * @param graph + */ + public void setUMLGraph(IGraph graph) + { + this.UMLGraph = graph; + } + + /** + * Called by performFinish(). Create new file wirh default content and then open editor + * + * @param file + * @param monitor + * @throws CoreException + */ + private void doFinish(final IFile file, IProgressMonitor monitor) throws CoreException + { + try + { + IGraph graph = this.getUMLGraph(); + PipedOutputStream pos = new PipedOutputStream(); + PipedInputStream pis = new PipedInputStream(pos); + this.filePersistenceService.write(graph, pos); + file.setContents(pis, true, true, monitor); + } + catch (IOException e) + { + e.printStackTrace(); + } + monitor.worked(1); + monitor.setTaskName("Opening file for editing..."); + getShell().getDisplay().asyncExec(new Runnable() + { + public void run() + { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try + { + IDE.openEditor(page, file, "com.horstmann.violet.eclipseplugin.editors.VioletUMLEditor", true); + } + catch (PartInitException e) + { + } + } + }); + monitor.worked(1); + } + + /** + * @return file extension (.class.violet for example) + */ + public abstract String getFileExtension(); + + @InjectedBean + private IFilePersistenceService filePersistenceService; + +} diff --git a/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/dedicatedApplicationContext-eclipse.xml b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/dedicatedApplicationContext-eclipse.xml new file mode 100644 index 0000000..83881d3 --- /dev/null +++ b/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/dedicatedApplicationContext-eclipse.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file