diff --git a/README.md b/README.md index 1ede2285110570bbc5e0e2eb9ba78aca33e73bdd..6d3e13c375d915c47a0fc42a3062d1479534c53b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ -# Building Physics Catalog Editor +# Building Physics Catalog Data Model and Editor +**Important: This is a prototype and work in progress!!** + +## How to Use + +1. Ensure Java 11 or higher is available (if not, install AdoptOpenJDK 15) +2. Install Eclipse Modeling Tools, version 2020-09 or higher +3. Import all Eclipse projects in this GIT repository via `File -> Import... -> Projects from GIT -> Clone URI` +4. Refresh and clean/build projects +5. Open `de.hftstuttgart.buildingphysics.application.product` and in `Overview`, section `Testing` press `Synchronize` first and `Launch an Eclipse Application` second +6. Press `New...` to ceate a new empty Building Physics Catalog; Save and Load buttons are also available. + +## How to Create + +Find background information about parameter catalogs for simulation and a tutorial on how to create them at [https://transfer.hft-stuttgart.de/gitlab/neqmodplus/parameter-catalogs-for-simulation](https://transfer.hft-stuttgart.de/gitlab/neqmodplus/parameter-catalogs-for-simulation). diff --git a/de.hftstuttgart.buildingphysics.application/.classpath b/de.hftstuttgart.buildingphysics.application/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..1fa3e6803d3b22e055b735220510616c4e35f2fc --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/de.hftstuttgart.buildingphysics.application/.project b/de.hftstuttgart.buildingphysics.application/.project new file mode 100644 index 0000000000000000000000000000000000000000..b37826e853383e4883a26aa3c5bab85cd94d85c6 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>de.hftstuttgart.buildingphysics.application</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/de.hftstuttgart.buildingphysics.application/Application.e4xmi b/de.hftstuttgart.buildingphysics.application/Application.e4xmi new file mode 100644 index 0000000000000000000000000000000000000000..c902850ed8b501626d1c8ec1057c9408628e2035 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/Application.e4xmi @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_6wlLcMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.application" bindingContexts="_6wlLecgZEeSyMNYR5xypkQ"> + <children xsi:type="basic:TrimmedWindow" xmi:id="_6wlLccgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.window.main" label="HfT Stuttgart - Building Physics Catalog" width="800" height="600"> + <mainMenu xmi:id="_6wlLicgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.main.menu"> + <children xsi:type="menu:Menu" xmi:id="_6wlLisgZEeSyMNYR5xypkQ" elementId="file" label="File"> + <children xsi:type="menu:HandledMenuItem" xmi:id="_y6FesCWUEeux0PTSTJn6xg" elementId="de.hftstuttgart.buildingphysics.application.handleditem.file.new" label="New..." command="_PnX_ACWUEeux0PTSTJn6xg"/> + <children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLi8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.file.open" label="Open" iconURI="platform:/plugin/de.hftstuttgart.buildingphysics.application/icons/open_in_app.png" command="_6wlLgMgZEeSyMNYR5xypkQ"/> + <children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.save" label="Save" iconURI="platform:/plugin/de.hftstuttgart.buildingphysics.application/icons/save_edit.png" command="_6wlLg8gZEeSyMNYR5xypkQ"/> + <children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.quit" label="Quit" command="_6wlLfMgZEeSyMNYR5xypkQ"/> + </children> + <children xsi:type="menu:Menu" xmi:id="_6wlLjsgZEeSyMNYR5xypkQ" elementId="help" label="Help"> + <children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLj8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.about" label="About" command="_6wlLhsgZEeSyMNYR5xypkQ"/> + </children> + </mainMenu> + <trimBars xmi:id="_6wlLlcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.trimbar.top"> + <children xsi:type="menu:ToolBar" xmi:id="_6wlLlsgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.main.toolbar"> + <children xsi:type="menu:HandledToolItem" xmi:id="_rXiTQCWUEeux0PTSTJn6xg" elementId="de.hftstuttgart.buildingphysics.application.handleditem.trimbar.top.new" label="New..." command="_PnX_ACWUEeux0PTSTJn6xg"/> + <children xsi:type="menu:HandledToolItem" xmi:id="_6wlLl8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.trimbar.top.open" iconURI="platform:/plugin/de.hftstuttgart.buildingphysics.application/icons/open_in_app.png" command="_6wlLgMgZEeSyMNYR5xypkQ"/> + <children xsi:type="menu:HandledToolItem" xmi:id="_6wlLmMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handleditem.trimbar.top.save" iconURI="platform:/plugin/de.hftstuttgart.buildingphysics.application/icons/save_edit.png" command="_6wlLg8gZEeSyMNYR5xypkQ"/> + </children> + </trimBars> + </children> + <handlers xmi:id="_LmGh8CWUEeux0PTSTJn6xg" elementId="de.hftstuttgart.buildingphysics.application.handler.newCommand" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.handlers.NewHandler" command="_PnX_ACWUEeux0PTSTJn6xg"/> + <handlers xmi:id="_6wlLgcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handler.openCommand" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.handlers.OpenHandler" command="_6wlLgMgZEeSyMNYR5xypkQ"/> + <handlers xmi:id="_6wlLhMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handler.saveCommand" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.handlers.SaveHandler" command="_6wlLg8gZEeSyMNYR5xypkQ"/> + <handlers xmi:id="_6wlLfcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handler.quitCommand" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.handlers.QuitHandler" command="_6wlLfMgZEeSyMNYR5xypkQ"/> + <handlers xmi:id="_6wlLh8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.handler.aboutCommand" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.handlers.AboutHandler" command="_6wlLhsgZEeSyMNYR5xypkQ"/> + <bindingTables xmi:id="_6wlLfsgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.bindingtable" bindingContext="_6wlLecgZEeSyMNYR5xypkQ"> + <bindings xmi:id="_6wlLf8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.keybinding.m1q" keySequence="M1+Q" command="_6wlLfMgZEeSyMNYR5xypkQ"/> + <bindings xmi:id="_6wlLgsgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.keybinding.m1o" keySequence="M1+O" command="_6wlLgMgZEeSyMNYR5xypkQ"/> + <bindings xmi:id="_6wlLhcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.keybinding.m1s" keySequence="M1+S" command="_6wlLg8gZEeSyMNYR5xypkQ"/> + <bindings xmi:id="_6wlLiMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.buildingphysics.application.keybinding.m1a" keySequence="M1+A" command="_6wlLhsgZEeSyMNYR5xypkQ"/> + </bindingTables> + <rootContext xmi:id="_6wlLecgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows"> + <children xmi:id="_6wlLesgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.window" name="In Windows"/> + <children xmi:id="_6wlLe8gZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/> + </rootContext> + <descriptors xmi:id="_d_8I0CUMEeux0PTSTJn6xg" elementId="de.hftstuttgart.buildingphysics.application.partdescriptor.catalog" allowMultiple="true" closeable="true" contributionURI="bundleclass://de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.parts.CatalogPart"/> + <commands xmi:id="_PnX_ACWUEeux0PTSTJn6xg" elementId="org.eclipse.ui.file.new" commandName="newCommand"/> + <commands xmi:id="_6wlLgMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.file.open" commandName="openCommand"/> + <commands xmi:id="_6wlLg8gZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.file.save" commandName="saveCommand"/> + <commands xmi:id="_6wlLhsgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.help.aboutAction" commandName="aboutCommand"/> + <commands xmi:id="_6wlLfMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.file.exit" commandName="quitCommand"/> + <addons xmi:id="_6wlLcsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/> + <addons xmi:id="_6wlLc8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/> + <addons xmi:id="_6wlLdMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/> + <addons xmi:id="_6wlLdcgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/> + <addons xmi:id="_6wlLdsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/> + <addons xmi:id="_6wlLd8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/> + <addons xmi:id="_6wlLeMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/> +</application:Application> diff --git a/de.hftstuttgart.buildingphysics.application/META-INF/MANIFEST.MF b/de.hftstuttgart.buildingphysics.application/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..91061feb32b820e625f0a84bfba41dab1952d4dd --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Application +Bundle-SymbolicName: de.hftstuttgart.buildingphysics.application;singleton:=true +Bundle-Version: 1.0.0.qualifier +Require-Bundle: javax.inject;bundle-version="0.0.0", + org.eclipse.core.runtime;bundle-version="0.0.0", + org.eclipse.swt;bundle-version="0.0.0", + org.eclipse.e4.ui.model.workbench;bundle-version="0.0.0", + org.eclipse.jface;bundle-version="0.0.0", + org.eclipse.e4.ui.services;bundle-version="0.0.0", + org.eclipse.e4.ui.workbench;bundle-version="0.0.0", + org.eclipse.e4.core.di;bundle-version="0.0.0", + org.eclipse.e4.ui.di;bundle-version="0.0.0", + org.eclipse.e4.core.contexts;bundle-version="0.0.0", + org.eclipse.emf.ecore, + org.eclipse.emf.edit, + org.eclipse.emf.ecp.ui.view.swt +Import-Package: de.hftstuttgart.buildingphysics, + javax.annotation;version="0.0.0" +Automatic-Module-Name: de.hftstuttgart.buildingphysics.application diff --git a/de.hftstuttgart.buildingphysics.application/build.properties b/de.hftstuttgart.buildingphysics.application/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..04ab1e9b8f3cd4339dc61f93907610aecbd48895 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + css/default.css,\ + Application.e4xmi diff --git a/de.hftstuttgart.buildingphysics.application/css/default.css b/de.hftstuttgart.buildingphysics.application/css/default.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.product b/de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.product new file mode 100644 index 0000000000000000000000000000000000000000..bf6b6aab1c67cce6837306c0ed9261e5debb7787 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/de.hftstuttgart.buildingphysics.application.product @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="de.hftstuttgart.buildingphysics.application" uid="de.hftstuttgart.buildingphysics.application.product" id="de.hftstuttgart.buildingphysics.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <programArgs>-clearPersistedState + </programArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + </vmArgsMac> + </launcherArgs> + + <windowImages/> + + <launcher> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14</macos> + </vm> + + <plugins> + </plugins> + + <features> + <feature id="de.hftstuttgart.buildingphysics.feature"/> + <feature id="org.eclipse.e4.rcp"/> + <feature id="org.eclipse.emf.ecp.emfforms.runtime.feature"/> + <feature id="org.eclipse.emf.common"/> + <feature id="org.eclipse.emf.common.ui"/> + <feature id="org.eclipse.emf.databinding"/> + <feature id="org.eclipse.emf.databinding.edit"/> + <feature id="org.eclipse.emf.ecore"/> + <feature id="org.eclipse.emf.ecore.edit"/> + <feature id="org.eclipse.emf.edit"/> + <feature id="org.eclipse.emf.edit.ui"/> + </features> + + + <preferencesInfo> + <targetfile overwrite="false"/> + </preferencesInfo> + +</product> diff --git a/de.hftstuttgart.buildingphysics.application/icons/home.png b/de.hftstuttgart.buildingphysics.application/icons/home.png new file mode 100644 index 0000000000000000000000000000000000000000..e9ace41c655fcbe6450482aa21e4de88f6905b04 Binary files /dev/null and b/de.hftstuttgart.buildingphysics.application/icons/home.png differ diff --git a/de.hftstuttgart.buildingphysics.application/icons/open_in_app.png b/de.hftstuttgart.buildingphysics.application/icons/open_in_app.png new file mode 100644 index 0000000000000000000000000000000000000000..9df4eeb7c3b8e6d1ff41f77b6032062a0edb4695 Binary files /dev/null and b/de.hftstuttgart.buildingphysics.application/icons/open_in_app.png differ diff --git a/de.hftstuttgart.buildingphysics.application/icons/save_edit.png b/de.hftstuttgart.buildingphysics.application/icons/save_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..b17caf5a984540e8b1448057feeecc5183c58eaa Binary files /dev/null and b/de.hftstuttgart.buildingphysics.application/icons/save_edit.png differ diff --git a/de.hftstuttgart.buildingphysics.application/plugin.xml b/de.hftstuttgart.buildingphysics.application/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..4c0f3c1a487ecb2ed59b7509f5fbdd9bac2087a3 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/plugin.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + id="product" + point="org.eclipse.core.runtime.products"> + <product + application="org.eclipse.e4.ui.workbench.swt.E4Application" + name="de.hftstuttgart.buildingphysics.application"> + <property + name="appName" + value="de.hftstuttgart.buildingphysics.application"> + </property> + </product> + </extension> + +</plugin> diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/AboutHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/AboutHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..e848482850ce4d1c0e2d155c586fe079ae361445 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/AboutHandler.java @@ -0,0 +1,12 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + +public class AboutHandler { + @Execute + public void execute(Shell shell) { + MessageDialog.openInformation(shell, "About", "HfT Stuttgart - Building Physics Catalog"); + } +} diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/HandlerUtils.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/HandlerUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..b302a2e56fba5a9644b13d875ceff0dcb0fcb36f --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/HandlerUtils.java @@ -0,0 +1,50 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; +import org.eclipse.emf.common.command.BasicCommandStack; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + +class HandlerUtils { + static final String CATALOG_PARTDESCRIPTOR_ID = "de.hftstuttgart.buildingphysics.application.partdescriptor.catalog"; + + public static String openFileDialog(Shell shell) { + return invokeFileDialog(new FileDialog(shell, SWT.OPEN)); + } + + public static String newFileDialog(Shell shell) { + return invokeFileDialog(new FileDialog(shell, SWT.SAVE)); + } + + private static String invokeFileDialog(FileDialog dialog) { + dialog.setFilterPath(System.getProperty("user.home")); + dialog.setFilterNames(new String [] {"Building Physics Catalog", "All Files (*)"}); + dialog.setFilterExtensions(new String [] {"*.buildphys", "*"}); + return dialog.open(); + } + + static void createNewPartWithCatalog(IEclipseContext context, EPartService partService, Resource resource) { + context.set(Resource.class, resource); + MPart catalogPart = partService.createPart(CATALOG_PARTDESCRIPTOR_ID); + catalogPart.setDirty(true); // must listen to adapter! + catalogPart.setLabel(resource.getURI().lastSegment()); + partService.showPart(catalogPart, PartState.ACTIVATE); + } + + static AdapterFactoryEditingDomain createEditingDomain() { + final AdapterFactory composedAdapterFactory = new ComposedAdapterFactory( + ComposedAdapterFactory.Descriptor.Registry.INSTANCE); // no dispose required? + final AdapterFactoryEditingDomain domain = new AdapterFactoryEditingDomain(composedAdapterFactory, + new BasicCommandStack()); + return domain; + } + +} diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..30ccd9c3c23593eb71c38145875e965e975fd2de --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java @@ -0,0 +1,45 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import de.hftstuttgart.buildingphysics.BuildingPhysicsPackage; +import java.io.IOException; + +import javax.inject.Named; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.swt.widgets.Shell; + + +public class NewHandler { + + @Execute + public void execute(MApplication application, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, + EPartService partService) { + + final String pathToNewCatalog = HandlerUtils.newFileDialog(shell); + + if (pathToNewCatalog != null) { + // create new catalog with resource at above path + final AdapterFactoryEditingDomain domain = HandlerUtils.createEditingDomain(); + final Resource energyCatalogResource = domain.createResource("file://" + pathToNewCatalog); + final EObject energyCatalog = EcoreUtil.create(BuildingPhysicsPackage.eINSTANCE.getBuildingPhysicsCatalog()); + energyCatalogResource.getContents().add(energyCatalog); + + // store new (empty) resource at selected path + try { + energyCatalogResource.save(null); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + HandlerUtils.createNewPartWithCatalog(application.getContext(), partService, energyCatalogResource); + } + } +} \ No newline at end of file diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/OpenHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/OpenHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..7639f7972acfa931732c2b2760cc96841a15b2cc --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/OpenHandler.java @@ -0,0 +1,28 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import javax.inject.Named; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.swt.widgets.Shell; + + +public class OpenHandler { + @Execute + public void execute(MApplication application, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, + EPartService partService) { + + final String pathToCatalog = HandlerUtils.openFileDialog(shell); + + if (pathToCatalog != null) { + final AdapterFactoryEditingDomain domain = HandlerUtils.createEditingDomain(); + System.out.println("Open catalog: " + pathToCatalog); + final Resource catalogResource = domain.loadResource("file://" + pathToCatalog); + HandlerUtils.createNewPartWithCatalog(application.getContext(), partService, catalogResource); + } + } +} \ No newline at end of file diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/QuitHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/QuitHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..a2419140d1bebbeb69e1e63824758599cc935a19 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/QuitHandler.java @@ -0,0 +1,17 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.workbench.IWorkbench; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + + +public class QuitHandler { + @Execute + public void execute(IWorkbench workbench, Shell shell){ + if (MessageDialog.openConfirm(shell, "Confirmation", + "Do you want to exit?")) { + workbench.close(); + } + } +} diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/SaveHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/SaveHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..6d1aba58af55eb5ff5589be18ce0952fad486dc0 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/SaveHandler.java @@ -0,0 +1,21 @@ +package de.hftstuttgart.buildingphysics.application.handlers; + +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.workbench.modeling.EPartService; + +public class SaveHandler { + + @CanExecute + public boolean canExecute(EPartService partService) { + if (partService != null) { + return !partService.getDirtyParts().isEmpty(); + } + return false; + } + + @Execute + public void execute(EPartService partService) { + partService.saveAll(false); + } +} \ No newline at end of file diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/parts/CatalogPart.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/parts/CatalogPart.java new file mode 100644 index 0000000000000000000000000000000000000000..6dbd106122e14991dbf31f5457cef22068d8933e --- /dev/null +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/parts/CatalogPart.java @@ -0,0 +1,50 @@ +package de.hftstuttgart.buildingphysics.application.parts; + +import java.io.IOException; + +import javax.annotation.PostConstruct; + +import org.eclipse.e4.ui.di.Persist; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecp.ui.view.ECPRendererException; +import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +/** + * Part for displaying a Forms Editor for a Building Physics Catalog. + */ +public class CatalogPart { + private Resource catalogResource; + + @PostConstruct + public void createComposite(MApplication application, Composite parent) { + catalogResource = application.getContext().get(Resource.class); + EObject energyCatalog = catalogResource.getContents().get(0); + try { + final Composite content = new Composite(parent, SWT.NONE); + content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + content.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create()); + ECPSWTViewRenderer.INSTANCE.render(content, energyCatalog); + content.layout(); + } catch (final ECPRendererException e) { + e.printStackTrace(); + } + parent.layout(); + } + + @Persist + public void save() { + System.out.println("Saved " + catalogResource); + try { + catalogResource.save(null); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/de.hftstuttgart.buildingphysics.feature/.project b/de.hftstuttgart.buildingphysics.feature/.project new file mode 100644 index 0000000000000000000000000000000000000000..1daa0375d8cea49ae383990053e6246ecdbbad35 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.feature/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>de.hftstuttgart.buildingphysics.feature</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.FeatureBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.FeatureNature</nature> + </natures> +</projectDescription> diff --git a/de.hftstuttgart.buildingphysics.feature/build.properties b/de.hftstuttgart.buildingphysics.feature/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..64f93a9f0b7328eb563aa5ad6cec7f828020e124 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/de.hftstuttgart.buildingphysics.feature/feature.xml b/de.hftstuttgart.buildingphysics.feature/feature.xml new file mode 100644 index 0000000000000000000000000000000000000000..251cd37cc3ff160bad9a3e0c5124e0719cec75fa --- /dev/null +++ b/de.hftstuttgart.buildingphysics.feature/feature.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="de.hftstuttgart.buildingphysics.feature" + label="Feature" + version="1.0.0.qualifier" + provider-name="HfT Stuttgart"> + + <description url="http://www.example.com/description"> + [Enter Feature Description here.] + </description> + + <copyright url="http://www.example.com/copyright"> + [Enter Copyright Description here.] + </copyright> + + <license url="http://www.example.com/license"> + [Enter License Description here.] + </license> + + <plugin + id="de.hftstuttgart.buildingphysics.application" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.ui" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.ui.views" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.ui.workbench" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.help" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.core.resources" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.core.filesystem" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.jface.text" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.text" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="de.hftstuttgart.buildingphysics" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="de.hftstuttgart.buildingphysics.edit" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="de.hftstuttgart.buildingphysics.viewmodel" + download-size="0" + install-size="0" + version="0.0.0"/> + +</feature> diff --git a/de.hftstuttgart.buildingphysics.viewmodel/plugin.xml b/de.hftstuttgart.buildingphysics.viewmodel/plugin.xml index 24c828da2f66db5a9775c631ee205c40785f1a3d..ba7c6927c017ce7cd637119cda76705fe2a5ba7e 100644 --- a/de.hftstuttgart.buildingphysics.viewmodel/plugin.xml +++ b/de.hftstuttgart.buildingphysics.viewmodel/plugin.xml @@ -1,16 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> - <extension - point="org.eclipse.emf.ecp.view.model.provider.xmi.file"> - - - - - - -<file filePath="viewmodels/BuildingPhysicsCatalog.view"/> - + <extension point="org.eclipse.emf.ecp.view.model.provider.xmi.file"> + <file filePath="viewmodels/MaterialCategory.view"/> + <file filePath="viewmodels/BuildingPhysicsCatalog.view"/> </extension> - -</plugin> \ No newline at end of file +</plugin> diff --git a/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/BuildingPhysicsCatalog.view b/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/BuildingPhysicsCatalog.view index 0efb39290d53b91a0c147577ab30f8c057aa1b65..2ced4bedc183696205dda481d332df94c094471c 100644 --- a/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/BuildingPhysicsCatalog.view +++ b/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/BuildingPhysicsCatalog.view @@ -41,7 +41,7 @@ </categorizations> <categorizations xsi:type="org.eclipse.emf.ecp.view.categorization.model:Category" xmi:id="_jpOWECTLEeuaK-RhvCx2-Q" name="WindowTypes"> <composite xsi:type="org.eclipse.emf.ecp.view.group.model:Group" xmi:id="_zXAdkCTLEeuaK-RhvCx2-Q"> - <children xsi:type="org.eclipse.emf.ecp.view.group.model:Group" xmi:id="_cAtaoCTNEeuaK-RhvCx2-Q" name="Catalog Info"> + <children xsi:type="org.eclipse.emf.ecp.view.group.model:Group" xmi:id="_cAtaoCTNEeuaK-RhvCx2-Q" name="Catalog Info" groupType="Embedded"> <children xsi:type="org.eclipse.emf.ecp.view.model:Control" xmi:id="_fSCBcCTNEeuaK-RhvCx2-Q" name="Name"> <domainModelReference xsi:type="org.eclipse.emf.ecp.view.model:FeaturePathDomainModelReference" xmi:id="_g8RbHCTNEeuaK-RhvCx2-Q"> <domainModelEFeature xsi:type="ecore:EAttribute" href="http://www.hftstuttgart.de/buildingphysics#//Catalog/name"/> diff --git a/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/MaterialCategory.view b/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/MaterialCategory.view new file mode 100644 index 0000000000000000000000000000000000000000..a973780f6b4ee456dc4936646e172fd8c1b45a71 --- /dev/null +++ b/de.hftstuttgart.buildingphysics.viewmodel/viewmodels/MaterialCategory.view @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<org.eclipse.emf.ecp.view.model:View xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:org.eclipse.emf.ecp.view.model="http://org/eclipse/emf/ecp/view/model/1180" xmlns:org.eclipse.emf.ecp.view.table.model="http://org/eclipse/emf/ecp/view/table/model/150" xmi:id="_ZY8TECUNEeux0PTSTJn6xg" name="MaterialCategory"> + <rootEClass href="http://www.hftstuttgart.de/buildingphysics#//MaterialCategory"/> + <children xsi:type="org.eclipse.emf.ecp.view.table.model:TableControl" xmi:id="_cQS6sCUNEeux0PTSTJn6xg" detailEditing="WithPanel"> + <domainModelReference xsi:type="org.eclipse.emf.ecp.view.table.model:TableDomainModelReference" xmi:id="_gQbIQCUNEeux0PTSTJn6xg"> + <domainModelReference xsi:type="org.eclipse.emf.ecp.view.model:FeaturePathDomainModelReference" xmi:id="_gQbIQSUNEeux0PTSTJn6xg"> + <domainModelEFeature xsi:type="ecore:EReference" href="http://www.hftstuttgart.de/buildingphysics#//MaterialCategory/material"/> + </domainModelReference> + </domainModelReference> + </children> + <ecorePaths>/de.hftstuttgart.buildingphysics/model/buildingphysics.ecore</ecorePaths> +</org.eclipse.emf.ecp.view.model:View>