Commit b2abc6df authored by Kai-Holger Brassel's avatar Kai-Holger Brassel
Browse files

First public version as of Verena Weilers Dissertation

parent 2c40014f
# Created by https://www.gitignore.io/api/java,maven,macos,linux,eclipse,windows,netbeans,intellij
# Edit at https://www.gitignore.io/?templates=java,maven,macos,linux,eclipse,windows,netbeans,intellij
### User specific ###
.sonarlint/
Servers/
RemoteSystemsTempFiles/
farFieldObstructions.txt
farFieldOcclPatchFraction.txt
/tmpdeploy/
/SimStadtTestReports/
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Annotation Processing
.apt_generated
.sts4-cache/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### NetBeans ###
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/java,maven,macos,linux,eclipse,windows,netbeans,intellij
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>de.hftstuttgart.energycomponents.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>
<?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.energycomponents.app.application" bindingContexts="_6wlLecgZEeSyMNYR5xypkQ">
<children xsi:type="basic:TrimmedWindow" xmi:id="_6wlLccgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.window.main" label="Energy Components Catalog" width="500" height="400">
<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="_6wlLi8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handleditem.file.new" label="New" iconURI="" command="_CqNHQBeZEeudKqin_4DG9g"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_RhHRIBeZEeudKqin_4DG9g" elementId="de.hftstuttgart.energycomponents.app.handleditem.file.open" label="Open" iconURI="platform:/plugin/de.hftstuttgart.energycomponents.app/icons/open_in_app.png" command="_6wlLgMgZEeSyMNYR5xypkQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handleditem.save" label="Save" iconURI="platform:/plugin/de.hftstuttgart.energycomponents.app/icons/save_edit.png" command="_6wlLg8gZEeSyMNYR5xypkQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.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.energycomponents.app.handleditem.about" label="About" command="_6wlLhsgZEeSyMNYR5xypkQ"/>
</children>
</mainMenu>
<trimBars xmi:id="_6wlLlcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.trimbar.top">
<children xsi:type="menu:ToolBar" xmi:id="_6wlLlsgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.main.toolbar">
<children xsi:type="menu:HandledToolItem" xmi:id="_hhBDYBeZEeudKqin_4DG9g" elementId="de.hftstuttgart.energycomponents.app.handleditem.trimbar.top.open" label="New" iconURI="" command="_CqNHQBeZEeudKqin_4DG9g"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_6wlLl8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handleditem.trimbar.top.open" iconURI="platform:/plugin/de.hftstuttgart.energycomponents.app/icons/open_in_app.png" command="_6wlLgMgZEeSyMNYR5xypkQ"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_6wlLmMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handleditem.trimbar.top.save" iconURI="platform:/plugin/de.hftstuttgart.energycomponents.app/icons/save_edit.png" command="_6wlLg8gZEeSyMNYR5xypkQ"/>
</children>
</trimBars>
</children>
<handlers xmi:id="_Fn8DsBeZEeudKqin_4DG9g" elementId="de.hftstuttgart.energycomponents.app.handler.newCommand" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.handlers.NewHandler" command="_CqNHQBeZEeudKqin_4DG9g"/>
<handlers xmi:id="_6wlLgcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handler.openCommand" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.handlers.OpenHandler" command="_6wlLgMgZEeSyMNYR5xypkQ"/>
<handlers xmi:id="_6wlLhMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handler.saveCommand" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.handlers.SaveHandler" command="_6wlLg8gZEeSyMNYR5xypkQ"/>
<handlers xmi:id="_6wlLh8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handler.aboutCommand" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.handlers.AboutHandler" command="_6wlLhsgZEeSyMNYR5xypkQ"/>
<handlers xmi:id="_6wlLfcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.handler.quitCommand" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.handlers.QuitHandler" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
<bindingTables xmi:id="_6wlLfsgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.bindingtable" bindingContext="_6wlLecgZEeSyMNYR5xypkQ">
<bindings xmi:id="_6wlLf8gZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.keybinding.m1q" keySequence="M1+Q" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
<bindings xmi:id="_6wlLgsgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.keybinding.m1o" keySequence="M1+O" command="_6wlLgMgZEeSyMNYR5xypkQ"/>
<bindings xmi:id="_6wlLhcgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.keybinding.m1s" keySequence="M1+S" command="_6wlLg8gZEeSyMNYR5xypkQ"/>
<bindings xmi:id="_6wlLiMgZEeSyMNYR5xypkQ" elementId="de.hftstuttgart.energycomponents.app.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="_JPM6kBdzEeuSnr5xc-g2BA" elementId="de.hftstuttgart.energycomponents.app.partdescriptor.catalog" iconURI="platform:/plugin/de.hftstuttgart.energycomponents.app/icons/home.png" allowMultiple="true" closeable="true" contributionURI="bundleclass://de.hftstuttgart.energycomponents.app/de.hftstuttgart.energycomponents.app.parts.CatalogPart"/>
<commands xmi:id="_CqNHQBeZEeudKqin_4DG9g" 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>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Energy Components Catalog App
Bundle-SymbolicName: de.hftstuttgart.energycomponents.app;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: HfT Stuttgart
Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="[3.9.100,4.0.0)",
org.eclipse.emf.ecp.edit;bundle-version="0.0.0",
org.eclipse.swt;bundle-version="[3.102.1,4.0.0)",
org.eclipse.e4.ui.model.workbench;bundle-version="[1.0.1,3.0.0)",
org.eclipse.jface;bundle-version="[3.9.1,4.0.0)",
org.eclipse.e4.ui.services;bundle-version="[1.0.1,2.0.0)",
org.eclipse.e4.ui.workbench;bundle-version="[1.0.2,2.0.0)",
org.eclipse.e4.core.di;bundle-version="[1.3.0,2.0.0)",
org.eclipse.e4.ui.di;bundle-version="[1.0.0,2.0.0)",
org.eclipse.e4.core.contexts;bundle-version="[1.3.1,2.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.8.0,3.0.0)",
org.eclipse.emf.ecp.ui.view.swt;bundle-version="0.0.0",
org.eclipse.emf.ecp.ui.view;bundle-version="0.0.0",
de.hftstuttgart.energycomponents;bundle-version="0.0.0",
de.hftstuttgart.energycomponents.edit;bundle-version="0.0.0",
de.hftstuttgart.energycomponents.viewmodel;bundle-version="0.0.0",
de.hftstuttgart.indriya.osgiplugin;bundle-version="0.0.0",
de.hftstuttgart.units;bundle-version="0.0.0",
de.hftstuttgart.units.ui.renderer;bundle-version="0.0.0"
Import-Package: javax.annotation;version="1.3.5"
Automatic-Module-Name: de.hftstuttgart.energycomponents.app
Export-Package: de.hftstuttgart.energycomponents.app.handlers,
de.hftstuttgart.energycomponents.app.parts;x-internal:=true
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
css/default.css,\
Application.e4xmi
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="Energy Components Catalog" uid="de.hftstuttgart.energycomponents.app.product" id="de.hftstuttgart.energycomponents.app.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>
<launcherArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>
<windowImages/>
<launcher name="EnergCatalog">
<macosx icon="/de.hftstuttgart.energycomponents.app/icons/cyberduck-application.icns"/>
<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.energycomponents.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>
<cssInfo>
</cssInfo>
</product>
<?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="Energy Components Catalog">
<property
name="appName"
value="Energy Components Catalog">
</property>
</product>
</extension>
</plugin>
package de.hftstuttgart.energycomponents.app.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", "Energy Components Catalog");
}
}
package de.hftstuttgart.energycomponents.app.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.energycomponents.app.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 [] {"Energy Component Catalog", "All Files (*)"});
dialog.setFilterExtensions(new String [] {"*.encomp", "*"});
return dialog.open();
}
static void createNewPartWithCatalog(IEclipseContext context, EPartService partService, Resource energyCatalogResource) {
context.set(Resource.class, energyCatalogResource);
MPart catalogPart = partService.createPart(CATALOG_PARTDESCRIPTOR_ID);
catalogPart.setDirty(true); // must listen to adapter!
catalogPart.setLabel(energyCatalogResource.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;
}
}
package de.hftstuttgart.energycomponents.app.handlers;
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.ecore.xmi.XMLResource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.swt.widgets.Shell;
import de.hftstuttgart.energycomponents.EnCompPackage;
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 = (XMLResource)domain.createResource("file://" + pathToNewCatalog);
// assume default XMI factory was used to create an XML resource
if (energyCatalogResource instanceof XMLResource) {
((XMLResource)energyCatalogResource).setEncoding("UTF-8");
}
final EObject energyCatalog = EcoreUtil.create(EnCompPackage.eINSTANCE.getEnergyComponentsCatalog());
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
package de.hftstuttgart.energycomponents.app.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.IEclipseContext;
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.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.widgets.Shell;
import de.hftstuttgart.energycomponents.EnergyComponentsCatalog;
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 energyCatalogResource = domain.loadResource("file://" + pathToCatalog);
HandlerUtils.createNewPartWithCatalog(application.getContext(), partService, energyCatalogResource);
}
}
}
\ No newline at end of file
package de.hftstuttgart.energycomponents.app.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();
}
}
}
package de.hftstuttgart.energycomponents.app.handlers;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
public class SaveHandler {
@CanExecute
public boolean canExecute(EPartService partService) {
// TODO isDirty() is not updated yet.
if (partService != null) {
MPart catalogPart = partService.findPart(HandlerUtils.CATALOG_PARTDESCRIPTOR_ID);
return catalogPart != null && catalogPart.isDirty();
}
return false;
}
@Execute
public void execute(EPartService partService) {
MPart activeCatalog = partService.getActivePart();
if (activeCatalog != null) {
partService.savePart(activeCatalog, false);
}
}
}
\ No newline at end of file
package de.hftstuttgart.energycomponents.app.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.common.command.BasicCommandStack;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecp.ui.view.ECPRendererException;
import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import de.hftstuttgart.energycomponents.EnCompPackage;
import de.hftstuttgart.energycomponents.EnergyComponentsCatalog;
/**
* Part for displaying a Forms Editor for an EnergyComponentsCatalog.
* See https://www.vogella.com/tutorials/Eclipse4Services/article.html#implementing-editor-like-behavior
* Reuse ECPModelView? https://www.eclipse.org/forums/index.php/t/1070750/
*/
//TODO: Selection context/adapter for MPart to enable/disable Save command
//TODO: Update Dirty state of MPart
//TODO: resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("encomp", new XMIResourceFactoryImpl());
//TODO: Resource energyCatalogResource = resourceSet.getResource(URI.createURI("file://" + pathToCatalog), true);
public class CatalogPart {
private Resource energyCatalogResource;
@PostConstruct
public void createComposite(MApplication application, Composite parent) {
energyCatalogResource = application.getContext().get(Resource.class);
EObject energyCatalog = energyCatalogResource.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 " + energyCatalogResource);
try {
energyCatalogResource.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment