diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..3c485d45cb9c753d9bd6055d86bc70f021e0b1a6 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,49 @@ +build: + stage: build + image: eclipse-temurin:8 + variables: + GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle" + before_script: + - export DEBIAN_FRONTEND="noninteractive" + - apt-get update + - apt-get install --assume-yes maven + - mvn --version + script: + - ./gradlew prepareMaven + - mvn -Dmaven.repo.local="$CI_PROJECT_DIR/maven_repo_local" -f de.prob.parent/pom.xml install + - cp footer.html de.prob.repository/target/repository/ + cache: + paths: + - .gradle/caches + - .gradle/native + - .gradle/wrapper + - maven_repo_local + artifacts: + paths: + - de.prob.repository/target/repository + +deploy:nightly: + stage: deploy + only: + - develop@general/stups/prob_rodin_plugin + image: alpine:3 + variables: + GIT_STRATEGY: none + before_script: + - apk update + - apk add lftp openssh-client + script: + - LFTP_PASSWORD="${DEPLOY_PASSWORD}" lftp -c "set cmd:fail-exit true; set sftp:auto-confirm true; open --user ${DEPLOY_USERNAME} --env-password sftp://${DEPLOY_HOST}/${DEPLOY_REMOTE_BASEDIR}/rodin/prob1/nightly/; mirror -vvv -R de.prob.repository/target/repository ." + +deploy:release: + stage: deploy + only: + - master@general/stups/prob_rodin_plugin + image: alpine:3 + variables: + GIT_STRATEGY: none + before_script: + - apk update + - apk add lftp openssh-client + script: + - LFTP_PASSWORD="${DEPLOY_PASSWORD}" lftp -c "set cmd:fail-exit true; set sftp:auto-confirm true; open --user ${DEPLOY_USERNAME} --env-password sftp://${DEPLOY_HOST}/${DEPLOY_REMOTE_BASEDIR}/rodin/prob1/; mkdir release-next; mirror -vvv -R de.prob.repository/target/repository release-next; mv release release-prev; mv release-next release" diff --git a/README.md b/README.md index b847cb396215ff7321df13b8c384b276e0309930..d4cfe6fbe9532ea97b2256b5a4ff8f8956749010 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,44 @@ -<img src="https://github.com/bendisposto/prob/raw/develop/logo.png" width="500" align="center"> +<img src="https://github.com/hhu-stups/prob-rodinplugin/raw/develop/logo.png" width="500" align="center"> + +[](https://travis-ci.org/hhu-stups/prob-rodinplugin) # The ProB Model Checker and Animator +[](https://travis-ci.org/hhu-stups/prob-rodinplugin) + The ProB source code is distributed under the EPL license (http://www.eclipse.org/org/documents/epl-v10.html). -(C) 2000-2011 Michael Leuschel and many others. +(C) 2000-2021 Michael Leuschel and many others. -For updates please visit the ProB website: http://www.stups.uni-duesseldorf.de/ProB/ +For updates please visit the ProB website: https://prob.hhu.de/w/ -ProB comes with ABSOLUTELY NO WARRANTY OF ANY KIND ! This software is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY. The author(s) do not accept responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all. No warranty is made about the software or its performance. +ProB comes with ABSOLUTELY NO WARRANTY OF ANY KIND! This software is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY. The author(s) do not accept responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all. No warranty is made about the software or its performance. -The ProB binary and source distributions contain the nauty library (http://cs.anu.edu.au/~bdm/nauty/) which imply further restrictions: the ProB model checker with nauty symmetry reduction cannot be used for applications with nontrivial military significance. +The ProB binary and source distributions contain the nauty library (http://cs.anu.edu.au/~bdm/nauty/) which imply further restrictions: the ProB model checker with nauty symmetry reduction cannot be used for applications with nontrivial military significance. -For availability of commercial support, please contact Formal Mind (http://www.formalmind.com). +For availability of commercial support, please contact Michael Leuschel (http://www.stups.uni-duesseldorf.de/~leuschel). # Bugs -Please report bugs and feature requests at http://jira.cobra.cs.uni-duesseldorf.de/ +Please report bugs and feature requests at the new site https://github.com/hhu-stups/prob-issues # Prolog Source Code -The latest source code of the Prolog binary can be downloaded from http://nightly.cobra.cs.uni-duesseldorf.de/source/. To build the Prolog binaries you require a Sicstus 4 (http://sicstus.sics.se/index.html) licence. - -# ProB 2.0 -The development repository for ProB 2.0 is avaliable from https://github.com/bendisposto/prob2 +The latest source code of the Prolog binary can be downloaded from https://stups.hhu-hosting.de/downloads/prob/source/. +To build the Prolog binaries you require a SICStus 4 (http://sicstus.sics.se/index.html) licence. # Setting up the development environment -- Clone the repository (http://github.com/bendisposto/prob) +- Clone the repository (https://github.com/hhu-stups/prob-rodinplugin) We suggest to fork the project on github (see https://help.github.com/articles/fork-a-repo) -- We use gradle to manage the dependencies to the libraries, thus you will need gradle installed on your computer. +- We use gradle to manage the dependencies to the libraries, thus you will need gradle installed on your computer. (see http://www.gradle.org/) -- In the workspace directory run the completeInstall task (gradle completeInstall), alternatively you can also run the downloadCli and collectDependencies tasks (gradle downloadCli collectDependencies). This will download the latest nightly build of the Prolog binary and the required Java libraries (such as apache commons, etc.) +- In the workspace directory run the completeInstall task (```gradle completeInstall```), alternatively you can also run the downloadCli and collectDependencies tasks (```gradle downloadCli collectDependencies```). This will download the latest nightly build of the Prolog binary and the required Java libraries (such as apache commons, etc.) -- Install Eclipse (Indigo/Juno) for RCP Development +- Install Eclipse for RCP Development - Import the projects into Eclipse. At this point Eclipse will complain about errors, the reason is that the target platform (i.e., Rodin) hasn't been setup yet). -- Open the file prob_target.target from the de.prob.core project and click on "Set as Target Platform". Grab a coffee. +- Open the file prob_target.target from the de.prob.core project and click on "Set as Target Platform". Grab a coffee. - After the target platform was installed and the workspace has been compiled you can run the project as an Eclipse application (use org.rodinp.platform.product as the product in the run configuration) - - - diff --git a/build.gradle b/build.gradle index 2b8fbd8a64a364922cd43b8eb13fa7755ec14d2e..a7a867c5f22d7075d7e152533ff451d4a5994e20 100644 --- a/build.gradle +++ b/build.gradle @@ -1,168 +1,90 @@ // to trigger a full tycho build please use 'gradle deleteFromClassPath completeInstall' -import org.apache.tools.ant.taskdefs.condition.Os -project.ext{ - - targetRepositories = ["http://download.eclipse.org/releases/indigo/", - "http://rodin-b-sharp.sourceforge.net/updates", - "http://rodin-b-sharp.sourceforge.net/core-updates" - , "http://www.stups.uni-duesseldorf.de/ProB/buildlibs/theory/" - ] +project.ext { + targetRepositories = [ + "https://download.eclipse.org/releases/luna/", + "https://rodin-b-sharp.sourceforge.net/updates", + "https://stups.hhu-hosting.de/buildlibs/org.rodinp.dev/", + ] groupID = "de.prob" } apply from: 'tycho_build.gradle' -// Local tasks - - -task bMotionStudioHelpCustumBuild(type: Exec){ - - commandLine 'ant', '-f','de.bmotionstudio.help/customBuild.xml' -} - -install.dependsOn bMotionStudioHelpCustumBuild - -completeInstall.dependsOn bMotionStudioHelpCustumBuild - project(':de.prob.core') { + apply plugin: "java" repositories { - maven { - name "cobra" - url "http://cobra.cs.uni-duesseldorf.de/artifactory/repo" - } + mavenCentral() } - - def parser_version = '2.4.33-SNAPSHOT' + def parser_version = '2.12.4' dependencies { - compile group: "de.prob", name: "answerparser", version: parser_version , changing: true - compile group: "de.prob", name: "bparser", version: parser_version , changing: true - compile group: "de.prob", name: "cliparser", version: parser_version , changing: true - compile group: "de.prob", name: "ltlparser", version: parser_version , changing: true - compile group: "de.prob", name: "parserbase", version: parser_version , changing: true - compile group: "de.prob", name: "prologlib", version: parser_version , changing: true - compile group: "de.prob", name: "unicode", version: parser_version , changing: true - compile group: "de.prob", name: "theorymapping", version: parser_version , changing: true - compile 'commons-lang:commons-lang:2.6' + // Note: After changing/updating dependencies or their versions here, + // you also need to update the corresponding entries in META-INF/MANIFEST.MF! + // To be safe, you should probably also update the Eclipse .classpath file + // (it might be used by the Tycho build - not sure). + implementation group: "de.hhu.stups", name: "answerparser", version: parser_version + implementation group: "de.hhu.stups", name: "bparser", version: parser_version + implementation group: "de.hhu.stups", name: "ltlparser", version: parser_version + implementation group: "de.hhu.stups", name: "parserbase", version: parser_version + implementation group: "de.hhu.stups", name: "prologlib", version: parser_version + implementation group: "de.hhu.stups", name: "unicode", version: parser_version + implementation group: "de.hhu.stups", name: "theorymapping", version: parser_version + implementation 'commons-lang:commons-lang:2.6' + implementation 'commons-codec:commons-codec:1.8' + implementation 'com.thoughtworks.xstream:xstream:1.4.19' + // Current versions of XStream depend on MXParser, but not any specific version of it. + // To avoid the version number changing unexpectedly and breaking the MANIFEST.MF classpath entries, + // hardcode a specific MXParser version here. + // It *should* be safe to update this when a new version is released. + implementation group: 'io.github.x-stream', name: 'mxparser', version: '1.2.2' + implementation group: 'net.java.dev.jna', name: 'jna', version: '3.4.0' + implementation group: 'de.hhu.stups', name: 'ptolemy-jfmi', version: '1.1.0' } - } project(':de.prob.ui') { repositories { - maven { - name "cobra" - url "http://cobra.cs.uni-duesseldorf.de/artifactory/repo" - } + mavenCentral() } dependencies { - compile 'commons-codec:commons-codec:1.6' + implementation 'commons-codec:commons-codec:1.8' } } def download(address,target) { - def file = new FileOutputStream(target) - def out = new BufferedOutputStream(file) - out << new URL(address).openStream() - out.close() + def file = new FileOutputStream(target) + def out = new BufferedOutputStream(file) + out << new URL(address).openStream() + out.close() } -task downloadCli << { - def dir = workspacePath+'de.prob.core/prob/' +task downloadCli { + doLast{ + def dir = workspacePath + 'de.prob.core/prob/' delete file(dir) - new File(dir).mkdirs() - - ['leopard64':'macos','linux32':'linux','linux64':'linux64','win32':'windows'].each { - def n = it.getKey() - - def targetdir = dir+it.getValue() - def targetzip = dir+"probcli_${n}.zip" - def url = "http://nightly.cobra.cs.uni-duesseldorf.de/cli/probcli_${n}.zip" - download(url,targetzip) - FileTree zip = zipTree(targetzip) - copy { - from zip - into targetdir - } - delete file(targetzip) - } - - def targetdir = dir+"windows/" - def targetzip = targetdir+"windowslib32.zip" - download("http://nightly.cobra.cs.uni-duesseldorf.de/cli/windowslib32.zip",targetzip) - FileTree zip = zipTree(targetzip) - copy { - from zip - into targetdir - } - delete file(targetzip) - -} - - - -task downloadCli2 ( type: Exec ) { - - def dir = workspacePath+'de.prob.core/prob/' - delete file(dir) - new File(dir).mkdirs() - - ['leopard64':'macos','linux32':'linux','linux64':'linux64','win32':'windows'].each { - def n = it.getKey() - - def targetdir = dir+it.getValue() - def targetzip = dir+"probcli_${n}.zip" - def url = "http://nightly.cobra.cs.uni-duesseldorf.de/cli/probcli_${n}.zip" - download(url,targetzip) - FileTree zip = zipTree(targetzip) - copy { - from zip - into targetdir - } - delete file(targetzip) - } - - def targetdir = dir+"windows/" - def targetzip = targetdir+"windowslib32.zip" - download("http://nightly.cobra.cs.uni-duesseldorf.de/cli/windowslib32.zip",targetzip) - FileTree zip = zipTree(targetzip) - copy { - from zip - into targetdir - } - delete file(targetzip) - - ['leopard64':'macos','linux32':'linux','linux64':'linux64'].each { - - def n = it.getKey() - targetdir = dir+it.getValue() - - download( "http://nightly.cobra.cs.uni-duesseldorf.de/cspm/cspm-"+n, targetdir+"/cspm" ) + new File(dir).mkdirs() + + ['macos':'macos','linux64':'linux64','win64':'windows'].each { + def n = it.getKey() + + def targetdir = dir + it.getValue() + def targetzip = dir + "probcli_${n}.zip" + def url = "https://stups.hhu-hosting.de/downloads/prob/cli/releases/1.12.1/probcli_${n}.zip" + download(url, targetzip) + FileTree zip = zipTree(targetzip) + copy { + from zip + into targetdir + } + delete file(targetzip) + } } - commandLine 'chmod', 'a+x', dir+'linux'+'/cspm', dir+'linux64'+'/cspm', dir+'macos'+'/cspm' - //commandLine 'chmod', 'a+x', dir+'*'+'/cspm' - - download( "http://nightly.cobra.cs.uni-duesseldorf.de/cspm/cspm-windows", dir+"windows"+"/cspm.exe" ) } - -completeInstall.dependsOn downloadCli -completeInstall.dependsOn subprojects.setClassPath - -task deleteOldArtifacts(type: Delete) { - String updateSite = workspacePath+'updatesite' - delete updateSite -} - -task collectArtifacts(type:Copy) { - from workspacePath + groupID+'.repository/target/repository/' - into workspacePath + 'updatesite' - from workspacePath + "index.html" - into workspacePath + 'updatesite' -} +prepareMaven.dependsOn downloadCli diff --git a/de.bmotionstudio.gef.editor/.classpath b/de.bmotionstudio.gef.editor/.classpath index cb2a56821c95aacfefc3381f5c0fa697013c8516..2d8dd8c20601ecc365cdc33bf1a1a4e6e280e50e 100644 --- a/de.bmotionstudio.gef.editor/.classpath +++ b/de.bmotionstudio.gef.editor/.classpath @@ -3,7 +3,7 @@ <classpathentry exported="true" kind="lib" path="lib/ext/antlr-2.7.7.jar"/> <classpathentry exported="true" kind="lib" path="lib/ext/asm-4.0.jar"/> <classpathentry exported="true" kind="lib" path="lib/ext/groovy-2.0.5.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.bmotionstudio.gef.editor/META-INF/MANIFEST.MF b/de.bmotionstudio.gef.editor/META-INF/MANIFEST.MF index d54bc13d2649b74b914014d7633584c8ba5fea49..3f83bf21d8407ba69ca77f8c5a5665bcd9c9c77c 100644 --- a/de.bmotionstudio.gef.editor/META-INF/MANIFEST.MF +++ b/de.bmotionstudio.gef.editor/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: BMotion Studio Editor Plug-in Bundle-SymbolicName: de.bmotionstudio.gef.editor;singleton:=true -Bundle-Version: 5.5.0.qualifier +Bundle-Version: 5.5.1.qualifier Bundle-Activator: de.bmotionstudio.gef.editor.BMotionEditorPlugin Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", @@ -12,14 +12,14 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.jface.databinding;bundle-version="[1.2.1,2.0.0)", org.eclipse.core.databinding.beans;bundle-version="[1.1.1,2.0.0)", org.eclipse.gef;bundle-version="[3.7.0,4.0.0)";visibility:=reexport, - de.prob.core;bundle-version="[9.4.0,9.5.0)";visibility:=reexport, - org.eventb.core;bundle-version="[3.0.0,3.2.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)";visibility:=reexport, + org.eventb.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.help;bundle-version="3.5.100", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", - org.rodinp.core;bundle-version="[1.7.0,1.8.0)", - org.eventb.core.ast;bundle-version="[3.0.0,3.2.0)" + org.rodinp.core;bundle-version="[1.7.0,2.0.0)", + org.eventb.core.ast;bundle-version="[3.0.0,4.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Eclipse-RegisterBuddy: de.prob.core Bundle-Vendor: HHU Düsseldorf STUPS Group Export-Package: de.bmotionstudio.gef.editor; diff --git a/de.bmotionstudio.gef.editor/build.properties b/de.bmotionstudio.gef.editor/build.properties index a433f56191f5a8f12e1f8259edcce7e36b0298d2..d5ce6d7afe7bbccb90405bf2b465381a9f4fa238 100644 --- a/de.bmotionstudio.gef.editor/build.properties +++ b/de.bmotionstudio.gef.editor/build.properties @@ -1,9 +1,9 @@ -source.. = src/ -output.. = bin/ -bin.includes = plugin.xml,\ - META-INF/,\ - .,\ - icons/,\ - schema/,\ - lib/ext/ - +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + schema/,\ + lib/ext/ + diff --git a/de.bmotionstudio.gef.editor/lib/ext/._antlr-2.7.7.jar1851805142189607825.tmp b/de.bmotionstudio.gef.editor/lib/ext/._antlr-2.7.7.jar1851805142189607825.tmp deleted file mode 100644 index 5e5f14b35584eac2a9f0f888769f0ab93ca6d849..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.gef.editor/lib/ext/._antlr-2.7.7.jar1851805142189607825.tmp and /dev/null differ diff --git a/de.bmotionstudio.gef.editor/plugin.xml b/de.bmotionstudio.gef.editor/plugin.xml index e910bbd05aaade12d33b9e1a78d6c0c9c867b894..8df646d6e305a521b225c7a69aa5b038163b78ff 100644 --- a/de.bmotionstudio.gef.editor/plugin.xml +++ b/de.bmotionstudio.gef.editor/plugin.xml @@ -1,662 +1,662 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.2"?> -<plugin> - <extension-point id="de.bmotionstudio.gef.editor.installActions" name="Install Actions for Editor" schema="schema/de.bmotionstudio.gef.editor.installActions.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.installMenu" name="Context Menu" schema="schema/de.bmotionstudio.gef.editor.installMenu.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.control" name="Control" schema="schema/de.bmotionstudio.gef.editor.control.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.registerImages" name="Register Images" schema="schema/de.bmotionstudio.gef.editor.registerImages.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.language" name="BMotion Studio Language Loader" schema="schema/de.bmotionstudio.gef.editor.language.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.schedulerEvent" name="Scheduler Event" schema="schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.observer" name="BMotion Studio Observer" schema="schema/de.bmotionstudio.gef.editor.observer.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.paletteEntry" name="Add a custom Palette Entry" schema="schema/de.bmotionstudio.gef.editor.paletteEntry.exsd"/> - <extension-point id="de.bmotionstudio.gef.editor.includeObserver" name="Include Observer Extension Point" schema="schema/de.bmotionstudio.gef.editor.includeObserver.exsd"/> - <extension - point="org.eclipse.ui.editors"> - <editor - class="de.bmotionstudio.gef.editor.BMotionStudioEditor" - contributorClass="de.bmotionstudio.gef.editor.BMotionStudioContributor" - default="true" - extensions="bmso" - icon="icons/logo_bmotion.png" - id="de.bmotionstudio.gef.editor.BMotionStudioEditor" - name="BMotion Studio Editor"> - </editor> - </extension> - <extension - point="org.eclipse.ui.newWizards"> - <category - id="de.bmotionstudio.gef.editor.wizards" - name="BMotion Studio"> - </category> - <wizard - category="de.bmotionstudio.gef.editor.wizards" - class="de.bmotionstudio.gef.editor.internal.NewBMotionProjectWizard" - icon="icons/logo_bmotion.png" - id="de.prob.bmotionstudio.NewBMotionProject" - name="BMotion Studio Visualization" - project="false"> - </wizard> - </extension> - <extension - point="org.eclipse.ui.views"> - <category - id="de.bmotionstudio.views" - name="BMotion Studio"> - </category> - <view - allowMultiple="false" - category="de.bmotionstudio.views" - class="de.bmotionstudio.gef.editor.library.LibraryView" - icon="icons/icon_library.gif" - id="de.bmotionstudio.gef.editor.LibraryView" - name="Library" - restorable="true"> - </view> - </extension> - <extension - point="org.eclipse.ui.menus"> - <menuContribution - locationURI="menu:org.eclipse.ui.main.menu"> - <menu - id="de.bmotionstudio.gef.editor.menu" - label="BMotion Studio"> - <command - commandId="de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite" - label="Open website" - style="push"> - </command> - <separator - name="group.filter" - visible="true"> - </separator> - <command - commandId="de.bmotionstudio.command.startVisualizationFromEditor" - icon="icons/icon_run.png" - label="Start Visualization" - style="push"> - <visibleWhen - checkEnabled="true"> - <with - variable="activeEditorId"> - <equals - value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> - </equals> - </with> - </visibleWhen> - </command> - </menu> - </menuContribution> - <menuContribution - locationURI="toolbar:org.eclipse.ui.main.toolbar"> - <toolbar - id="de.bmotionstudio.gef.editor.toolbar"> - <command - commandId="de.bmotionstudio.command.startVisualizationFromEditor" - icon="icons/icon_run.png" - label="Start Visualization" - style="push"> - <visibleWhen - checkEnabled="true"> - <with - variable="activeEditorId"> - <equals - value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> - </equals> - </with> - </visibleWhen> - </command> - </toolbar> - </menuContribution> - </extension> - <extension - point="org.eclipse.ui.commands"> - <command - defaultHandler="de.bmotionstudio.gef.editor.handler.OpenWebsiteHandler" - id="de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite" - name="Open website"> - </command> - <command - id="de.bmotionstudio.command.startVisualizationFromEditor" - name="Start Visualization from Editor"> - </command> - <command - defaultHandler="de.bmotionstudio.gef.editor.handler.StartVisualizationFileHandler" - id="de.bmotionstudio.command.startVisualizationFromFile" - name="Start Visualization from File"> - </command> - </extension> - <extension - point="org.eclipse.ui.handlers"> - <handler - class="de.bmotionstudio.gef.editor.handler.StartVisualizationEditorHandler" - commandId="de.bmotionstudio.command.startVisualizationFromEditor"> - <enabledWhen> - <with - variable="activeEditorId"> - <equals - value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> - </equals> - </with> - </enabledWhen> - </handler> - </extension> - <extension - point="de.prob.core.animation"> - <listener - class="de.bmotionstudio.gef.editor.StaticListenerRegistry"> - </listener> - </extension> - <extension - point="de.prob.core.lifecycle"> - <listener - class="de.bmotionstudio.gef.editor.StaticListenerRegistry"> - </listener> - </extension> - <extension - point="de.bmotionstudio.gef.editor.registerImages"> - <registerImages - class="de.bmotionstudio.gef.editor.EditorImageRegistry"> - </registerImages> - <registerImages - class="de.bmotionstudio.gef.editor.ImageRegistry"> - </registerImages> - </extension> - - <extension - point="de.bmotionstudio.gef.editor.control"> - <group - id="de.bmotionstudio.gef.editor.group.main" - name="Main"> - </group> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/eclipse16/image_obj.gif" - id="de.bmotionstudio.gef.editor.image" - name="Image" - service="de.bmotionstudio.gef.editor.model.service.BImageService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_button.gif" - id="de.bmotionstudio.gef.editor.button" - name="Button" - service="de.bmotionstudio.gef.editor.model.service.BButtonService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_radiobutton_c.gif" - id="de.bmotionstudio.gef.editor.radiobutton" - name="Radiobutton" - service="de.bmotionstudio.gef.editor.model.service.BRadioButtonService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_checked.gif" - id="de.bmotionstudio.gef.editor.checkbox" - name="Checkbox" - service="de.bmotionstudio.gef.editor.model.service.BCheckboxService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/eclipse16/overview_obj.gif" - id="de.bmotionstudio.gef.editor.composite" - name="Composite" - service="de.bmotionstudio.gef.editor.model.service.BCompositeService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_text.gif" - id="de.bmotionstudio.gef.editor.text" - name="Text" - service="de.bmotionstudio.gef.editor.model.service.BTextService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_textfield.gif" - id="de.bmotionstudio.gef.editor.textfield" - name="Textfield" - service="de.bmotionstudio.gef.editor.model.service.BTextfieldService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_rectangle.gif" - id="de.bmotionstudio.gef.editor.rectangle" - name="Rectanlge" - service="de.bmotionstudio.gef.editor.model.service.BRectangleService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_ellipse.gif" - id="de.bmotionstudio.gef.editor.ellipse" - name="Ellipse" - service="de.bmotionstudio.gef.editor.model.service.BEllipseService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/icon_connection16.gif" - id="de.bmotionstudio.gef.editor.connection" - name="Connection" - service="de.bmotionstudio.gef.editor.model.service.BConnectionService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/eclipse16/prop_ps.gif" - id="de.bmotionstudio.gef.editor.table" - name="Table" - service="de.bmotionstudio.gef.editor.model.service.BTableService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/eclipse16/prop_ps2.gif" - id="de.bmotionstudio.gef.editor.tablecolumn" - name="Column" - service="de.bmotionstudio.gef.editor.model.service.BTableColumnService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.group.main" - icon="icons/eclipse16/prop_ps3.gif" - id="de.bmotionstudio.gef.editor.tablecell" - name="Cell" - service="de.bmotionstudio.gef.editor.model.service.BTableCellService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.railway.group" - icon="icons/icon_signal.gif" - id="de.bmotionstudio.gef.editor.signal" - name="Signal" - service="de.bmotionstudio.gef.editor.model.service.SignalService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.railway.group" - icon="icons/eclipse16/smartmode_co.gif" - id="de.bmotionstudio.gef.editor.light" - name="Light" - service="de.bmotionstudio.gef.editor.model.service.LightService"> - </control> - <group - id="de.bmotionstudio.gef.editor.industry.group" - name="Industry"> - </group> - <control - groupid="de.bmotionstudio.gef.editor.industry.group" - icon="icons/icon_tank.gif" - id="de.bmotionstudio.gef.editor.tank" - name="Tank" - service="de.bmotionstudio.gef.editor.model.service.TankService"> - </control> - <group - id="de.bmotionstudio.gef.editor.railway.group" - name="Railway"> - </group> - <control - groupid="de.bmotionstudio.gef.editor.railway.group" - icon="icons/icon_tracknode.gif" - id="de.bmotionstudio.gef.editor.tracknode" - name="Node" - service="de.bmotionstudio.gef.editor.model.service.TrackNodeService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.railway.group" - icon="icons/icon_track.gif" - id="de.bmotionstudio.gef.editor.track" - name="Trac" - service="de.bmotionstudio.gef.editor.model.service.TrackService"> - </control> - <control - groupid="de.bmotionstudio.gef.editor.railway.group" - icon="icons/icon_switch.gif" - id="de.bmotionstudio.gef.editor.switch" - name="Switch" - service="de.bmotionstudio.gef.editor.model.service.SwitchService"> - </control> - </extension> - <extension - point="de.bmotionstudio.gef.editor.observer"> - <observer - class="de.bmotionstudio.gef.editor.observer.SimpleValueDisplay" - description="Observer for setting up the text value" - name="Simple Value Display"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.SwitchImage" - description="Observer for switching the image of the control" - name="Switch Image"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates" - name="Switch Child Coordinates"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.SetAttribute" - description="General observer to set any attribute of the control" - name="Set Attribute"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate" - name="Listen Operation"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.SwitchCoordinates" - description="Observer for switching the coordinates of the control" - name="Switch Coordinates"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.TableObserver" - name="Table Observer"> - </observer> - <observer - class="de.bmotionstudio.gef.editor.observer.ColumnObserver" - name="Column Observer"> - </observer> - </extension> - <extension - point="de.bmotionstudio.gef.editor.schedulerEvent"> - <schedulerEvent - class="de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate" - description="Execute an operation" - menu="true" - name="Execute Operation"> - </schedulerEvent> - <schedulerEvent - class="de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript" - description="Execute an animation script" - menu="true" - name="Execute Scheduler"> - </schedulerEvent> - <schedulerEvent - class="de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti" - description="Execute an operation by a predicate" - menu="true" - name="Execute Operation (Multi)"> - </schedulerEvent> - </extension> - <extension - point="de.bmotionstudio.gef.editor.installActions"> - <action - class="de.bmotionstudio.gef.editor.InstallActions"> - </action> - </extension> - <extension - point="de.bmotionstudio.gef.editor.installMenu"> - <menu - class="de.bmotionstudio.gef.editor.InstallMenu"> - </menu> - </extension> - <extension - point="de.bmotionstudio.gef.editor.language"> - <language - service="de.bmotionstudio.gef.editor.eventb.EventBLanguageService" - id="EventB"> - </language> - </extension> - <extension - point="de.bmotionstudio.gef.editor.includeObserver"> - <include - language="EventB"> - <observer - id="de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.button"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.text"> - </control> - <control - id="de.bmotionstudio.gef.editor.ellipse"> - </control> - <control - id="de.bmotionstudio.gef.editor.rectangle"> - </control> - <control - id="de.bmotionstudio.gef.editor.radiobutton"> - </control> - <control - id="de.bmotionstudio.gef.editor.checkbox"> - </control> - <control - id="de.bmotionstudio.gef.editor.connection"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecell"> - </control> - <control - id="de.bmotionstudio.gef.editor.table"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecolumn"> - </control> - <control - id="de.bmotionstudio.gef.editor.signal"> - </control> - <control - id="de.bmotionstudio.gef.editor.tank"> - </control> - <control - id="de.bmotionstudio.gef.editor.switch"> - </control> - <control - id="de.bmotionstudio.gef.editor.track"> - </control> - <control - id="de.bmotionstudio.gef.editor.light"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SwitchCoordinates"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.button"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.text"> - </control> - <control - id="de.bmotionstudio.gef.editor.rectangle"> - </control> - <control - id="de.bmotionstudio.gef.editor.radiobutton"> - </control> - <control - id="de.bmotionstudio.gef.editor.textfield"> - </control> - <control - id="de.bmotionstudio.gef.editor.checkbox"> - </control> - <control - id="de.bmotionstudio.gef.editor.ellipse"> - </control> - <control - id="de.bmotionstudio.gef.editor.table"> - </control> - <control - id="de.bmotionstudio.gef.editor.signal"> - </control> - <control - id="de.bmotionstudio.gef.editor.tank"> - </control> - <control - id="de.bmotionstudio.gef.editor.switch"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SimpleValueDisplay"> - <control - id="de.bmotionstudio.gef.editor.text"> - </control> - <control - id="de.bmotionstudio.gef.editor.radiobutton"> - </control> - <control - id="de.bmotionstudio.gef.editor.textfield"> - </control> - <control - id="de.bmotionstudio.gef.editor.button"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecell"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SetAttribute"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.button"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.text"> - </control> - <control - id="de.bmotionstudio.gef.editor.rectangle"> - </control> - <control - id="de.bmotionstudio.gef.editor.radiobutton"> - </control> - <control - id="de.bmotionstudio.gef.editor.checkbox"> - </control> - <control - id="de.bmotionstudio.gef.editor.connection"> - </control> - <control - id="de.bmotionstudio.gef.editor.ellipse"> - </control> - <control - id="de.bmotionstudio.gef.editor.textfield"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecell"> - </control> - <control - id="de.bmotionstudio.gef.editor.table"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecolumn"> - </control> - <control - id="de.bmotionstudio.gef.editor.signal"> - </control> - <control - id="de.bmotionstudio.gef.editor.tank"> - </control> - <control - id="de.bmotionstudio.gef.editor.switch"> - </control> - <control - id="de.bmotionstudio.gef.editor.track"> - </control> - <control - id="de.bmotionstudio.gef.editor.light"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates"> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.visualization"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.ExternalObserverScript"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.button"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.text"> - </control> - <control - id="de.bmotionstudio.gef.editor.rectangle"> - </control> - <control - id="de.bmotionstudio.gef.editor.radiobutton"> - </control> - <control - id="de.bmotionstudio.gef.editor.checkbox"> - </control> - <control - id="de.bmotionstudio.gef.editor.connection"> - </control> - <control - id="de.bmotionstudio.gef.editor.ellipse"> - </control> - <control - id="de.bmotionstudio.gef.editor.textfield"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecell"> - </control> - <control - id="de.bmotionstudio.gef.editor.table"> - </control> - <control - id="de.bmotionstudio.gef.editor.tablecolumn"> - </control> - <control - id="de.bmotionstudio.gef.editor.light"> - </control> - <control - id="de.bmotionstudio.gef.editor.signal"> - </control> - <control - id="de.bmotionstudio.gef.editor.switch"> - </control> - <control - id="de.bmotionstudio.gef.editor.track"> - </control> - <control - id="de.bmotionstudio.gef.editor.tracknode"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SwitchImage"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.rectangle"> - </control> - <control - id="de.bmotionstudio.gef.editor.ellipse"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.ColumnObserver"> - <control - id="de.bmotionstudio.gef.editor.tablecolumn"> - </control> - </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.TableObserver"> - <control - id="de.bmotionstudio.gef.editor.table"> - </control> - </observer> - </include> +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension-point id="de.bmotionstudio.gef.editor.installActions" name="Install Actions for Editor" schema="schema/de.bmotionstudio.gef.editor.installActions.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.installMenu" name="Context Menu" schema="schema/de.bmotionstudio.gef.editor.installMenu.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.control" name="Control" schema="schema/de.bmotionstudio.gef.editor.control.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.registerImages" name="Register Images" schema="schema/de.bmotionstudio.gef.editor.registerImages.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.language" name="BMotion Studio Language Loader" schema="schema/de.bmotionstudio.gef.editor.language.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.schedulerEvent" name="Scheduler Event" schema="schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.observer" name="BMotion Studio Observer" schema="schema/de.bmotionstudio.gef.editor.observer.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.paletteEntry" name="Add a custom Palette Entry" schema="schema/de.bmotionstudio.gef.editor.paletteEntry.exsd"/> + <extension-point id="de.bmotionstudio.gef.editor.includeObserver" name="Include Observer Extension Point" schema="schema/de.bmotionstudio.gef.editor.includeObserver.exsd"/> + <extension + point="org.eclipse.ui.editors"> + <editor + class="de.bmotionstudio.gef.editor.BMotionStudioEditor" + contributorClass="de.bmotionstudio.gef.editor.BMotionStudioContributor" + default="true" + extensions="bmso" + icon="icons/logo_bmotion.png" + id="de.bmotionstudio.gef.editor.BMotionStudioEditor" + name="BMotion Studio Editor"> + </editor> + </extension> + <extension + point="org.eclipse.ui.newWizards"> + <category + id="de.bmotionstudio.gef.editor.wizards" + name="BMotion Studio"> + </category> + <wizard + category="de.bmotionstudio.gef.editor.wizards" + class="de.bmotionstudio.gef.editor.internal.NewBMotionProjectWizard" + icon="icons/logo_bmotion.png" + id="de.prob.bmotionstudio.NewBMotionProject" + name="BMotion Studio Visualization" + project="false"> + </wizard> + </extension> + <extension + point="org.eclipse.ui.views"> + <category + id="de.bmotionstudio.views" + name="BMotion Studio"> + </category> + <view + allowMultiple="false" + category="de.bmotionstudio.views" + class="de.bmotionstudio.gef.editor.library.LibraryView" + icon="icons/icon_library.gif" + id="de.bmotionstudio.gef.editor.LibraryView" + name="Library" + restorable="true"> + </view> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + locationURI="menu:org.eclipse.ui.main.menu"> + <menu + id="de.bmotionstudio.gef.editor.menu" + label="BMotion Studio"> + <command + commandId="de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite" + label="Open website" + style="push"> + </command> + <separator + name="group.filter" + visible="true"> + </separator> + <command + commandId="de.bmotionstudio.command.startVisualizationFromEditor" + icon="icons/icon_run.png" + label="Start Visualization" + style="push"> + <visibleWhen + checkEnabled="true"> + <with + variable="activeEditorId"> + <equals + value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> + </equals> + </with> + </visibleWhen> + </command> + </menu> + </menuContribution> + <menuContribution + locationURI="toolbar:org.eclipse.ui.main.toolbar"> + <toolbar + id="de.bmotionstudio.gef.editor.toolbar"> + <command + commandId="de.bmotionstudio.command.startVisualizationFromEditor" + icon="icons/icon_run.png" + label="Start Visualization" + style="push"> + <visibleWhen + checkEnabled="true"> + <with + variable="activeEditorId"> + <equals + value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> + </equals> + </with> + </visibleWhen> + </command> + </toolbar> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + defaultHandler="de.bmotionstudio.gef.editor.handler.OpenWebsiteHandler" + id="de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite" + name="Open website"> + </command> + <command + id="de.bmotionstudio.command.startVisualizationFromEditor" + name="Start Visualization from Editor"> + </command> + <command + defaultHandler="de.bmotionstudio.gef.editor.handler.StartVisualizationFileHandler" + id="de.bmotionstudio.command.startVisualizationFromFile" + name="Start Visualization from File"> + </command> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="de.bmotionstudio.gef.editor.handler.StartVisualizationEditorHandler" + commandId="de.bmotionstudio.command.startVisualizationFromEditor"> + <enabledWhen> + <with + variable="activeEditorId"> + <equals + value="de.bmotionstudio.gef.editor.BMotionStudioEditor"> + </equals> + </with> + </enabledWhen> + </handler> + </extension> + <extension + point="de.prob.core.animation"> + <listener + class="de.bmotionstudio.gef.editor.StaticListenerRegistry"> + </listener> + </extension> + <extension + point="de.prob.core.lifecycle"> + <listener + class="de.bmotionstudio.gef.editor.StaticListenerRegistry"> + </listener> + </extension> + <extension + point="de.bmotionstudio.gef.editor.registerImages"> + <registerImages + class="de.bmotionstudio.gef.editor.EditorImageRegistry"> + </registerImages> + <registerImages + class="de.bmotionstudio.gef.editor.ImageRegistry"> + </registerImages> + </extension> + + <extension + point="de.bmotionstudio.gef.editor.control"> + <group + id="de.bmotionstudio.gef.editor.group.main" + name="Main"> + </group> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/eclipse16/image_obj.gif" + id="de.bmotionstudio.gef.editor.image" + name="Image" + service="de.bmotionstudio.gef.editor.model.service.BImageService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_button.gif" + id="de.bmotionstudio.gef.editor.button" + name="Button" + service="de.bmotionstudio.gef.editor.model.service.BButtonService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_radiobutton_c.gif" + id="de.bmotionstudio.gef.editor.radiobutton" + name="Radiobutton" + service="de.bmotionstudio.gef.editor.model.service.BRadioButtonService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_checked.gif" + id="de.bmotionstudio.gef.editor.checkbox" + name="Checkbox" + service="de.bmotionstudio.gef.editor.model.service.BCheckboxService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/eclipse16/overview_obj.gif" + id="de.bmotionstudio.gef.editor.composite" + name="Composite" + service="de.bmotionstudio.gef.editor.model.service.BCompositeService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_text.gif" + id="de.bmotionstudio.gef.editor.text" + name="Text" + service="de.bmotionstudio.gef.editor.model.service.BTextService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_textfield.gif" + id="de.bmotionstudio.gef.editor.textfield" + name="Textfield" + service="de.bmotionstudio.gef.editor.model.service.BTextfieldService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_rectangle.gif" + id="de.bmotionstudio.gef.editor.rectangle" + name="Rectanlge" + service="de.bmotionstudio.gef.editor.model.service.BRectangleService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_ellipse.gif" + id="de.bmotionstudio.gef.editor.ellipse" + name="Ellipse" + service="de.bmotionstudio.gef.editor.model.service.BEllipseService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_connection16.gif" + id="de.bmotionstudio.gef.editor.connection" + name="Connection" + service="de.bmotionstudio.gef.editor.model.service.BConnectionService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/eclipse16/prop_ps.gif" + id="de.bmotionstudio.gef.editor.table" + name="Table" + service="de.bmotionstudio.gef.editor.model.service.BTableService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/eclipse16/prop_ps2.gif" + id="de.bmotionstudio.gef.editor.tablecolumn" + name="Column" + service="de.bmotionstudio.gef.editor.model.service.BTableColumnService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/eclipse16/prop_ps3.gif" + id="de.bmotionstudio.gef.editor.tablecell" + name="Cell" + service="de.bmotionstudio.gef.editor.model.service.BTableCellService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.railway.group" + icon="icons/icon_signal.gif" + id="de.bmotionstudio.gef.editor.signal" + name="Signal" + service="de.bmotionstudio.gef.editor.model.service.SignalService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.railway.group" + icon="icons/eclipse16/smartmode_co.gif" + id="de.bmotionstudio.gef.editor.light" + name="Light" + service="de.bmotionstudio.gef.editor.model.service.LightService"> + </control> + <group + id="de.bmotionstudio.gef.editor.industry.group" + name="Industry"> + </group> + <control + groupid="de.bmotionstudio.gef.editor.industry.group" + icon="icons/icon_tank.gif" + id="de.bmotionstudio.gef.editor.tank" + name="Tank" + service="de.bmotionstudio.gef.editor.model.service.TankService"> + </control> + <group + id="de.bmotionstudio.gef.editor.railway.group" + name="Railway"> + </group> + <control + groupid="de.bmotionstudio.gef.editor.railway.group" + icon="icons/icon_tracknode.gif" + id="de.bmotionstudio.gef.editor.tracknode" + name="Node" + service="de.bmotionstudio.gef.editor.model.service.TrackNodeService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.railway.group" + icon="icons/icon_track.gif" + id="de.bmotionstudio.gef.editor.track" + name="Trac" + service="de.bmotionstudio.gef.editor.model.service.TrackService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.railway.group" + icon="icons/icon_switch.gif" + id="de.bmotionstudio.gef.editor.switch" + name="Switch" + service="de.bmotionstudio.gef.editor.model.service.SwitchService"> + </control> + </extension> + <extension + point="de.bmotionstudio.gef.editor.observer"> + <observer + class="de.bmotionstudio.gef.editor.observer.SimpleValueDisplay" + description="Observer for setting up the text value" + name="Simple Value Display"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.SwitchImage" + description="Observer for switching the image of the control" + name="Switch Image"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates" + name="Switch Child Coordinates"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.SetAttribute" + description="General observer to set any attribute of the control" + name="Set Attribute"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate" + name="Listen Operation"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.SwitchCoordinates" + description="Observer for switching the coordinates of the control" + name="Switch Coordinates"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.TableObserver" + name="Table Observer"> + </observer> + <observer + class="de.bmotionstudio.gef.editor.observer.ColumnObserver" + name="Column Observer"> + </observer> + </extension> + <extension + point="de.bmotionstudio.gef.editor.schedulerEvent"> + <schedulerEvent + class="de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate" + description="Execute an operation" + menu="true" + name="Execute Operation"> + </schedulerEvent> + <schedulerEvent + class="de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript" + description="Execute an animation script" + menu="true" + name="Execute Scheduler"> + </schedulerEvent> + <schedulerEvent + class="de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti" + description="Execute an event by a predicate" + menu="true" + name="Execute Event (Multi)"> + </schedulerEvent> + </extension> + <extension + point="de.bmotionstudio.gef.editor.installActions"> + <action + class="de.bmotionstudio.gef.editor.InstallActions"> + </action> + </extension> + <extension + point="de.bmotionstudio.gef.editor.installMenu"> + <menu + class="de.bmotionstudio.gef.editor.InstallMenu"> + </menu> + </extension> + <extension + point="de.bmotionstudio.gef.editor.language"> + <language + service="de.bmotionstudio.gef.editor.eventb.EventBLanguageService" + id="EventB"> + </language> + </extension> + <extension + point="de.bmotionstudio.gef.editor.includeObserver"> + <include + language="EventB"> + <observer + id="de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.button"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.text"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.radiobutton"> + </control> + <control + id="de.bmotionstudio.gef.editor.checkbox"> + </control> + <control + id="de.bmotionstudio.gef.editor.connection"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecell"> + </control> + <control + id="de.bmotionstudio.gef.editor.table"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecolumn"> + </control> + <control + id="de.bmotionstudio.gef.editor.signal"> + </control> + <control + id="de.bmotionstudio.gef.editor.tank"> + </control> + <control + id="de.bmotionstudio.gef.editor.switch"> + </control> + <control + id="de.bmotionstudio.gef.editor.track"> + </control> + <control + id="de.bmotionstudio.gef.editor.light"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SwitchCoordinates"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.button"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.text"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.radiobutton"> + </control> + <control + id="de.bmotionstudio.gef.editor.textfield"> + </control> + <control + id="de.bmotionstudio.gef.editor.checkbox"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + <control + id="de.bmotionstudio.gef.editor.table"> + </control> + <control + id="de.bmotionstudio.gef.editor.signal"> + </control> + <control + id="de.bmotionstudio.gef.editor.tank"> + </control> + <control + id="de.bmotionstudio.gef.editor.switch"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SimpleValueDisplay"> + <control + id="de.bmotionstudio.gef.editor.text"> + </control> + <control + id="de.bmotionstudio.gef.editor.radiobutton"> + </control> + <control + id="de.bmotionstudio.gef.editor.textfield"> + </control> + <control + id="de.bmotionstudio.gef.editor.button"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecell"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SetAttribute"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.button"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.text"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.radiobutton"> + </control> + <control + id="de.bmotionstudio.gef.editor.checkbox"> + </control> + <control + id="de.bmotionstudio.gef.editor.connection"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + <control + id="de.bmotionstudio.gef.editor.textfield"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecell"> + </control> + <control + id="de.bmotionstudio.gef.editor.table"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecolumn"> + </control> + <control + id="de.bmotionstudio.gef.editor.signal"> + </control> + <control + id="de.bmotionstudio.gef.editor.tank"> + </control> + <control + id="de.bmotionstudio.gef.editor.switch"> + </control> + <control + id="de.bmotionstudio.gef.editor.track"> + </control> + <control + id="de.bmotionstudio.gef.editor.light"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates"> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.visualization"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.ExternalObserverScript"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.button"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.text"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.radiobutton"> + </control> + <control + id="de.bmotionstudio.gef.editor.checkbox"> + </control> + <control + id="de.bmotionstudio.gef.editor.connection"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + <control + id="de.bmotionstudio.gef.editor.textfield"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecell"> + </control> + <control + id="de.bmotionstudio.gef.editor.table"> + </control> + <control + id="de.bmotionstudio.gef.editor.tablecolumn"> + </control> + <control + id="de.bmotionstudio.gef.editor.light"> + </control> + <control + id="de.bmotionstudio.gef.editor.signal"> + </control> + <control + id="de.bmotionstudio.gef.editor.switch"> + </control> + <control + id="de.bmotionstudio.gef.editor.track"> + </control> + <control + id="de.bmotionstudio.gef.editor.tracknode"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SwitchImage"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.ColumnObserver"> + <control + id="de.bmotionstudio.gef.editor.tablecolumn"> + </control> + </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.TableObserver"> + <control + id="de.bmotionstudio.gef.editor.table"> + </control> + </observer> + </include> </extension> -</plugin> +</plugin> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.control.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.control.exsd index e35e7098e4b05024689df59e940cd48a108b2e91..05e83a3b55c0f3f2274a4c14c5587727b2b65001 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.control.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.control.exsd @@ -1,158 +1,158 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.control" name="BMotion Studio Control"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="0" maxOccurs="unbounded"> - <element ref="group" minOccurs="0" maxOccurs="1"/> - <element ref="control" minOccurs="0" maxOccurs="1"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="group"> - <complexType> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - The id of the group - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - The name of the group. The name will be displayed in the palette - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <element name="control"> - <annotation> - <appInfo> - <meta.element labelAttribute="id" icon="icon"/> - </appInfo> - </annotation> - <complexType> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - The unique id of the control - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - The name of the control. The name will be displayed in the Palette - </documentation> - </annotation> - </attribute> - <attribute name="groupid" type="string"> - <annotation> - <documentation> - The group id defined in the group element - </documentation> - </annotation> - </attribute> - <attribute name="icon" type="string" use="required"> - <annotation> - <documentation> - The icon of control. The icon will be displayed in the Palette - </documentation> - <appInfo> - <meta.attribute kind="resource"/> - </appInfo> - </annotation> - </attribute> - <attribute name="service" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.AbstractBControlService:de.bmotionstudio.gef.editor.IBControlService"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.control" name="BMotion Studio Control"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="0" maxOccurs="unbounded"> + <element ref="group" minOccurs="0" maxOccurs="1"/> + <element ref="control" minOccurs="0" maxOccurs="1"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="group"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + The id of the group + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + The name of the group. The name will be displayed in the palette + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="control"> + <annotation> + <appInfo> + <meta.element labelAttribute="id" icon="icon"/> + </appInfo> + </annotation> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + The unique id of the control + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + The name of the control. The name will be displayed in the Palette + </documentation> + </annotation> + </attribute> + <attribute name="groupid" type="string"> + <annotation> + <documentation> + The group id defined in the group element + </documentation> + </annotation> + </attribute> + <attribute name="icon" type="string" use="required"> + <annotation> + <documentation> + The icon of control. The icon will be displayed in the Palette + </documentation> + <appInfo> + <meta.attribute kind="resource"/> + </appInfo> + </annotation> + </attribute> + <attribute name="service" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.AbstractBControlService:de.bmotionstudio.gef.editor.IBControlService"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="apiInfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.includeObserver.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.includeObserver.exsd index 42a20dc11a1b04d951c27b1e7aff883084d90fa0..636c52307f4e12648581362b8157abe8f4ca2570 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.includeObserver.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.includeObserver.exsd @@ -1,139 +1,139 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.includeObserver" name="Include B-Observer"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence> - <element ref="include" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="control"> - <annotation> - <appInfo> - <meta.element labelAttribute="id"/> - </appInfo> - </annotation> - <complexType> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <element name="observer"> - <annotation> - <appInfo> - <meta.element labelAttribute="observerID"/> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="control"/> - </sequence> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <element name="include"> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="observer"/> - </sequence> - <attribute name="language" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.includeObserver" name="Include B-Observer"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="include" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="control"> + <annotation> + <appInfo> + <meta.element labelAttribute="id"/> + </appInfo> + </annotation> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="observer"> + <annotation> + <appInfo> + <meta.element labelAttribute="observerID"/> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="control"/> + </sequence> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="include"> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="observer"/> + </sequence> + <attribute name="language" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installActions.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installActions.exsd index 814a71e347315556e6eb1263382273366ed010d1..9cf4b40e3728e1226a06dc21cf76a7dfd6bb02ba 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installActions.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installActions.exsd @@ -1,102 +1,102 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.installActions" name="Install Actions for Editor"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence> - <element ref="action" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="action"> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.AbstractInstallActions:de.bmotionstudio.gef.editor.IInstallActions"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.installActions" name="Install Actions for Editor"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="action" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="action"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.AbstractInstallActions:de.bmotionstudio.gef.editor.IInstallActions"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installMenu.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installMenu.exsd index e49de0a993e1b9c4d4f77711d9a075a220716705..1caa39f4d369bf7f0872a21aae981b22069220e9 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installMenu.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.installMenu.exsd @@ -1,102 +1,102 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.installMenu" name="Context Menu"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence> - <element ref="menu" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="menu"> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IInstallMenu"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.installMenu" name="Context Menu"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="menu" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="menu"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IInstallMenu"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.language.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.language.exsd index f9d646d88a2f4811c3b6c34a65440442b8d1b9c3..0db01cf709d6ea9727da1ebff4ffaa184fc03f19 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.language.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.language.exsd @@ -1,109 +1,109 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.languageLoader" name="BMotion Studio Language Loader"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="0" maxOccurs="unbounded"> - <element ref="language"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="language"> - <complexType> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="service" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.ILanguageService"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.languageLoader" name="BMotion Studio Language Loader"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="0" maxOccurs="unbounded"> + <element ref="language"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="language"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="service" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.ILanguageService"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.observer.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.observer.exsd index 87040ac832e0b2bd3fad10f845e379ab0fde437d..7a09099f452fad04aeedd69d2630eed4120bf397 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.observer.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.observer.exsd @@ -1,121 +1,121 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.observer" name="BMotion Studio Observer"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="0" maxOccurs="unbounded"> - <element ref="observer"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="observer"> - <annotation> - <appInfo> - <meta.element labelAttribute="id"/> - </appInfo> - </annotation> - <complexType> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.observer.Observer:"/> - </appInfo> - </annotation> - </attribute> - <attribute name="description" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.observer" name="BMotion Studio Observer"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="0" maxOccurs="unbounded"> + <element ref="observer"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="observer"> + <annotation> + <appInfo> + <meta.element labelAttribute="id"/> + </appInfo> + </annotation> + <complexType> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.observer.Observer:"/> + </appInfo> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.paletteEntry.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.paletteEntry.exsd index 0e0bc598374bed67d3f0a0d11e2ff649c7faf431..1916f428973426971bb115d91c1d27d543640512 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.paletteEntry.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.paletteEntry.exsd @@ -1,102 +1,102 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.paletteEntry" name="Add a custom Palette Entry"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="entry"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="entry"> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IInstallPaletteEntry"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.paletteEntry" name="Add a custom Palette Entry"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="entry"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="entry"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IInstallPaletteEntry"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.registerImages.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.registerImages.exsd index 370a01def4d92b72662740e50c26e08dc4faea5b..c85499b81868cc55c2dbef2f69b8b5b3ab5097ea 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.registerImages.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.registerImages.exsd @@ -1,102 +1,102 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.registerImages" name="BMotion Studio Register Images"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="0" maxOccurs="unbounded"> - <element ref="registerImages"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="registerImages"> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IBMotionStudioImageRegistry"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.registerImages" name="BMotion Studio Register Images"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="0" maxOccurs="unbounded"> + <element ref="registerImages"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="registerImages"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":de.bmotionstudio.gef.editor.IBMotionStudioImageRegistry"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd index fedd15c305bff1b335d997381489a0ae22e7e0c9..9f8c177edae787011b4b1a5da7958eb9a46c00b4 100644 --- a/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd +++ b/de.bmotionstudio.gef.editor/schema/de.bmotionstudio.gef.editor.schedulerEvent.exsd @@ -1,128 +1,128 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.schedulerEvent" name="BMotion Studio Scheduler Event"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="schedulerEvent"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="schedulerEvent"> - <annotation> - <appInfo> - <meta.element labelAttribute="id"/> - </appInfo> - </annotation> - <complexType> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.scheduler.SchedulerEvent:"/> - </appInfo> - </annotation> - </attribute> - <attribute name="description" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="menu" type="boolean" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="de.bmotionstudio.gef.editor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="de.bmotionstudio.gef.editor" id="de.bmotionstudio.gef.editor.schedulerEvent" name="BMotion Studio Scheduler Event"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="schedulerEvent"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="schedulerEvent"> + <annotation> + <appInfo> + <meta.element labelAttribute="id"/> + </appInfo> + </annotation> + <complexType> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="de.bmotionstudio.gef.editor.scheduler.SchedulerEvent:"/> + </appInfo> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="menu" type="boolean" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java index 3f3fd561503b1fa2b0afb3cd0dc629e141ddc594..75dc26f2905fc52dc4db109617adf52c26c665b6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java @@ -1,49 +1,49 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.palette.CombinedTemplateCreationEntry; -import org.eclipse.gef.palette.ToolEntry; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.internal.BControlTemplate; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BControlTreeEditPart; -import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; - -/** - * @author Lukas Ladenberger - * - */ -public abstract class AbstractBControlService { - - public ToolEntry createToolEntry(Visualization visualization, - IConfigurationElement configurationElement) { - String name = configurationElement.getAttribute("name"); - String icon = configurationElement.getAttribute("icon"); - String type = configurationElement.getAttribute("id"); - // Get the source plug-in (from the control extension) - String sourcePluginID = configurationElement.getContributor().getName(); - return new CombinedTemplateCreationEntry(name, "Create " + name, - new BControlTemplate(type), new BControlCreationFactory(type, - visualization), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon)); - } - - public boolean showInPalette() { - return true; - } - - public BMSAbstractTreeEditPart createTreeEditPart() { - return new BControlTreeEditPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.palette.CombinedTemplateCreationEntry; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.internal.BControlTemplate; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BControlTreeEditPart; +import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; + +/** + * @author Lukas Ladenberger + * + */ +public abstract class AbstractBControlService { + + public ToolEntry createToolEntry(Visualization visualization, + IConfigurationElement configurationElement) { + String name = configurationElement.getAttribute("name"); + String icon = configurationElement.getAttribute("icon"); + String type = configurationElement.getAttribute("id"); + // Get the source plug-in (from the control extension) + String sourcePluginID = configurationElement.getContributor().getName(); + return new CombinedTemplateCreationEntry(name, "Create " + name, + new BControlTemplate(type), new BControlCreationFactory(type, + visualization), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon)); + } + + public boolean showInPalette() { + return true; + } + + public BMSAbstractTreeEditPart createTreeEditPart() { + return new BControlTreeEditPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractExpressionControl.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractExpressionControl.java index a08f1e160786898ca1f2c1fa00cd4174398994e2..4c9621338a4710d47484aee24b126ae2288dfb52 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractExpressionControl.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractExpressionControl.java @@ -1,41 +1,41 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.IObserver; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public abstract class AbstractExpressionControl extends BindingObject { - - protected transient String ID; - protected transient String name; - protected transient String description; - - public String getID() { - return this.ID; - } - - public String getName() { - return this.name; - } - - public String getDescription() { - return this.description; - } - - /** - * This method is invoked before the expression control ({@link IObserver} - * or {@link SchedulerEvent}) will be deleted. - * - * @param control - * which holds the expression control - */ - public void beforeDelete(BControl control) { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.IObserver; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public abstract class AbstractExpressionControl extends BindingObject { + + protected transient String ID; + protected transient String name; + protected transient String description; + + public String getID() { + return this.ID; + } + + public String getName() { + return this.name; + } + + public String getDescription() { + return this.description; + } + + /** + * This method is invoked before the expression control ({@link IObserver} + * or {@link SchedulerEvent}) will be deleted. + * + * @param control + * which holds the expression control + */ + public void beforeDelete(BControl control) { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractInstallActions.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractInstallActions.java index e7e9ef1718822ec2e71161e5e48e5245db8d11b0..615c98fb49d339e2eb21bfc8fe843d7334715f2c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractInstallActions.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractInstallActions.java @@ -4,26 +4,26 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor; - -import java.util.HashMap; - -import org.eclipse.jface.action.Action; - -public class AbstractInstallActions { - - HashMap<String, Action> map; - - public AbstractInstallActions() { - this.map = new HashMap<String, Action>(); - } - - public void installAction(String actionID, Action action) { - this.map.put(actionID, action); - } - - public HashMap<String, Action> getActionMap() { - return this.map; - } - -} +package de.bmotionstudio.gef.editor; + +import java.util.HashMap; + +import org.eclipse.jface.action.Action; + +public class AbstractInstallActions { + + HashMap<String, Action> map; + + public AbstractInstallActions() { + this.map = new HashMap<String, Action>(); + } + + public void installAction(String actionID, Action action) { + this.map.put(actionID, action); + } + + public HashMap<String, Action> getActionMap() { + return this.map; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java index 0725ead409ccbc55cc3a602e498d3189b6ba9b9c..20ce33899f0025334cf09c61b96f4680fd9f7d67 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java @@ -1,178 +1,178 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.core.Animator; -import de.prob.core.IAnimationListener; -import de.prob.core.command.EvaluationGetValuesCommand; -import de.prob.core.command.EvaluationInsertFormulaCommand; -import de.prob.core.command.EvaluationInsertFormulaCommand.FormulaType; -import de.prob.core.domainobjects.EvaluationElement; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.State; -import de.prob.exceptions.ProBException; -import de.prob.parserbase.ProBParseException; - -public class Animation implements IAnimationListener { - - private Animator animator; - - private final Map<String, Operation> currentStateOperations; - - private final Map<String, EvaluationElement> cachedEvalElements = new HashMap<String, EvaluationElement>(); - - private State currentState; - - private Visualization visualization; - - private Boolean observerCallBack = true; - - public Animation(Animator anim, Visualization visualization) { - StaticListenerRegistry.registerListener((IAnimationListener) this); - this.currentStateOperations = new HashMap<String, Operation>(); - this.animator = anim; - this.visualization = visualization; - this.visualization.setAnimation(this); - } - - private void setNewState(State state) { - currentState = state; - currentStateOperations.clear(); - for (Operation op : state.getEnabledOperations()) { - this.currentStateOperations.put(op.getName(), op); - } - } - - @Override - public void currentStateChanged(State currentState, Operation operation) { - // set new state and remember old state, if possible - setNewState(currentState); - updateCachedExpressions(currentState); - if (currentState.isInitialized()) { - - if (animator == null) { - animator = Animator.getAnimator(); - } - - checkObserver(); - - } - - } - - /** - * Get values for all used expressions. This should speed up the - * communication between ProB's core and Java. The result is not used, just - * to fill the caches. - * - * @param currentState - */ - private void updateCachedExpressions(State currentState) { - try { - EvaluationGetValuesCommand.getValuesForExpressionsCached( - currentState, cachedEvalElements.values()); - } catch (ProBException e) { - // TODO Log this - } - } - - private void collectAllBControls(List<BControl> allBControls, - BControl control) { - - if (control.getChildrenArray().isEmpty()) - return; - - for (BControl bcontrol : control.getChildrenArray()) { - allBControls.add(bcontrol); - collectAllBControls(allBControls, bcontrol); - } - - } - - public void checkObserver() { - if (visualization.isRunning()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - List<BControl> allBControls = new ArrayList<BControl>(); - allBControls.add(visualization); - collectAllBControls(allBControls, visualization); - for (BControl c : allBControls) - c.checkObserver(Animation.this); - } - }); - } - } - - public State getState() { - return currentState; - } - - public Animator getAnimator() { - return animator; - } - - public Operation getCurrentStateOperation(String operation) { - return currentStateOperations.get(operation); - } - - public Visualization getVisualization() { - return this.visualization; - } - - public void unregister() { - StaticListenerRegistry.unregisterListener((IAnimationListener) this); - } - - public void setObserverCallBack(Boolean observerCallBack) { - this.observerCallBack = observerCallBack; - } - - public boolean isObserverCallBack() { - return observerCallBack; - } - - public EvaluationElement getCachedEvalElement(String expressionStr, - boolean isPredicate) throws UnsupportedOperationException, - ProBException, ProBParseException { - final EvaluationElement evalElement; - if (cachedEvalElements.containsKey(expressionStr)) { - evalElement = cachedEvalElements.get(expressionStr); - } else { - // TODO: exception handling ... - evalElement = createPredicateExpressionElement(expressionStr, - isPredicate); - cachedEvalElements.put(expressionStr, evalElement); - } - return evalElement; - } - - private EvaluationElement createPredicateExpressionElement( - String expressionStr, boolean isPredicate) - throws UnsupportedOperationException, ProBException, - ProBParseException { - final EvaluationInsertFormulaCommand.FormulaType type = isPredicate ? FormulaType.PREDICATE - : FormulaType.EXPRESSION; - final EvaluationElement evaluationElement = EvaluationInsertFormulaCommand - .insertFormula(animator, type, expressionStr); - return evaluationElement; - } - - public Map<String, Operation> getCurrentStateOperations() { - return currentStateOperations; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.core.Animator; +import de.prob.core.IAnimationListener; +import de.prob.core.command.EvaluationGetValuesCommand; +import de.prob.core.command.EvaluationInsertFormulaCommand; +import de.prob.core.command.EvaluationInsertFormulaCommand.FormulaType; +import de.prob.core.domainobjects.EvaluationElement; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.State; +import de.prob.exceptions.ProBException; +import de.prob.parserbase.ProBParseException; + +public class Animation implements IAnimationListener { + + private Animator animator; + + private final Map<String, Operation> currentStateOperations; + + private final Map<String, EvaluationElement> cachedEvalElements = new HashMap<String, EvaluationElement>(); + + private State currentState; + + private Visualization visualization; + + private Boolean observerCallBack = true; + + public Animation(Animator anim, Visualization visualization) { + StaticListenerRegistry.registerListener((IAnimationListener) this); + this.currentStateOperations = new HashMap<String, Operation>(); + this.animator = anim; + this.visualization = visualization; + this.visualization.setAnimation(this); + } + + private void setNewState(State state) { + currentState = state; + currentStateOperations.clear(); + for (Operation op : state.getEnabledOperations()) { + this.currentStateOperations.put(op.getName(), op); + } + } + + @Override + public void currentStateChanged(State currentState, Operation operation) { + // set new state and remember old state, if possible + setNewState(currentState); + updateCachedExpressions(currentState); + if (currentState.isInitialized()) { + + if (animator == null) { + animator = Animator.getAnimator(); + } + + checkObserver(); + + } + + } + + /** + * Get values for all used expressions. This should speed up the + * communication between ProB's core and Java. The result is not used, just + * to fill the caches. + * + * @param currentState + */ + private void updateCachedExpressions(State currentState) { + try { + EvaluationGetValuesCommand.getValuesForExpressionsCached( + currentState, cachedEvalElements.values()); + } catch (ProBException e) { + // TODO Log this + } + } + + private void collectAllBControls(List<BControl> allBControls, + BControl control) { + + if (control.getChildrenArray().isEmpty()) + return; + + for (BControl bcontrol : control.getChildrenArray()) { + allBControls.add(bcontrol); + collectAllBControls(allBControls, bcontrol); + } + + } + + public void checkObserver() { + if (visualization.isRunning()) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + List<BControl> allBControls = new ArrayList<BControl>(); + allBControls.add(visualization); + collectAllBControls(allBControls, visualization); + for (BControl c : allBControls) + c.checkObserver(Animation.this); + } + }); + } + } + + public State getState() { + return currentState; + } + + public Animator getAnimator() { + return animator; + } + + public Operation getCurrentStateOperation(String operation) { + return currentStateOperations.get(operation); + } + + public Visualization getVisualization() { + return this.visualization; + } + + public void unregister() { + StaticListenerRegistry.unregisterListener((IAnimationListener) this); + } + + public void setObserverCallBack(Boolean observerCallBack) { + this.observerCallBack = observerCallBack; + } + + public boolean isObserverCallBack() { + return observerCallBack; + } + + public EvaluationElement getCachedEvalElement(String expressionStr, + boolean isPredicate) throws UnsupportedOperationException, + ProBException, ProBParseException { + final EvaluationElement evalElement; + if (cachedEvalElements.containsKey(expressionStr)) { + evalElement = cachedEvalElements.get(expressionStr); + } else { + // TODO: exception handling ... + evalElement = createPredicateExpressionElement(expressionStr, + isPredicate); + cachedEvalElements.put(expressionStr, evalElement); + } + return evalElement; + } + + private EvaluationElement createPredicateExpressionElement( + String expressionStr, boolean isPredicate) + throws UnsupportedOperationException, ProBException, + ProBParseException { + final EvaluationInsertFormulaCommand.FormulaType type = isPredicate ? FormulaType.PREDICATE + : FormulaType.EXPRESSION; + final EvaluationElement evaluationElement = EvaluationInsertFormulaCommand + .insertFormula(animator, type, expressionStr); + return evaluationElement; + } + + public Map<String, Operation> getCurrentStateOperations() { + return currentStateOperations; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java index 664615ca8d4eb21b522bf5b08cdc3d618283e8b6..ce33dc534acc0402b060d9b88266b68ba0b11fab 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java @@ -1,71 +1,71 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -public final class AttributeConstants { - - public static final String ATTRIBUTE_X = "de.bmotionstudio.gef.editor.attribute.BAttributeX"; - public static final String ATTRIBUTE_Y = "de.bmotionstudio.gef.editor.attribute.BAttributeY"; - public static final String ATTRIBUTE_WIDTH = "de.bmotionstudio.gef.editor.attribute.BAttributeWidth"; - public static final String ATTRIBUTE_HEIGHT = "de.bmotionstudio.gef.editor.attribute.BAttributeHeight"; - public static final String ATTRIBUTE_CUSTOM = "de.bmotionstudio.gef.editor.attribute.BAttributeCustom"; - public static final String ATTRIBUTE_ID = "de.bmotionstudio.gef.editor.attribute.BAttributeID"; - public static final String ATTRIBUTE_VISIBLE = "de.bmotionstudio.gef.editor.attribute.BAttributeVisible"; - - public static final String ATTRIBUTE_COLUMNS = "de.bmotionstudio.gef.editor.attribute.BAttributeColumns"; - public static final String ATTRIBUTE_ROWS = "de.bmotionstudio.gef.editor.attribute.BAttributeRows"; - - public static final String ATTRIBUTE_BACKGROUND_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage"; - public static final String ATTRIBUTE_BACKGROUND_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor"; - public static final String ATTRIBUTE_FOREGROUND_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor"; - public static final String ATTRIBUTE_BACKGROUND_VISIBLE = "de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundVisible"; - public static final String ATTRIBUTE_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage"; - public static final String ATTRIBUTE_TEXT = "de.bmotionstudio.gef.editor.attribute.BAttributeText"; - public static final String ATTRIBUTE_TEXT_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeTextColor"; - public static final String ATTRIBUTE_ALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeAlpha"; - public static final String ATTRIBUTE_OUTLINEALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha"; - public static final String ATTRIBUTE_FONT = "de.bmotionstudio.gef.editor.attribute.BAttributeFont"; - public static final String ATTRIBUTE_ENABLED = "de.bmotionstudio.gef.editor.attribute.BAttributeEnabled"; - public static final String ATTRIBUTE_CHECKED = "de.bmotionstudio.gef.editor.attribute.BAttributeChecked"; - public static final String ATTRIBUTE_VALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeValue"; - public static final String ATTRIBUTE_BUTTONGROUP = "de.bmotionstudio.gef.editor.attribute.BAttributeButtonGroup"; - public static final String ATTRIBUTE_SHAPE = "de.bmotionstudio.gef.editor.attribute.BAttributeShape"; - public static final String ATTRIBUTE_ORIENTATION = "de.bmotionstudio.gef.editor.attribute.BAttributeOrientation"; - public static final String ATTRIBUTE_DIRECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeDirection"; - public static final String ATTRIBUTE_FILLTYPE = "de.bmotionstudio.gef.editor.attribute.BAttributeFillType"; - public static final String ATTRIBUTE_LINEWIDTH = "de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth"; - public static final String ATTRIBUTE_LINESTYLE = "de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle"; - public static final String ATTRIBUTE_TRUEVALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeTrueValue"; - public static final String ATTRIBUTE_FALSEVALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeFalseValue"; - public static final String ATTRIBUTE_LABEL = "de.bmotionstudio.gef.editor.attribute.BAttributeLabel"; - public static final String ATTRIBUTE_OFFSET_H = "de.bmotionstudio.gef.editor.attribute.BAttributeOffsetH"; - public static final String ATTRIBUTE_OFFSET_V = "de.bmotionstudio.gef.editor.attribute.BAttributeOffsetV"; - public static final String ATTRIBUTE_CONNECTION_SOURCE_DECORATION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration"; - public static final String ATTRIBUTE_CONNECTION_TARGET_DECORATION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration"; - - public static final String ATTRIBUTE_SIZE = "de.bmotionstudio.gef.editor.attribute.BAttributeSize"; - public static final String ATTRIBUTE_COORDINATES = "de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates"; - public static final String ATTRIBUTE_MISC = "de.bmotionstudio.gef.editor.attribute.BAttributeMisc"; - public static final String ATTRIBUTE_MAIN = "de.bmotionstudio.gef.editor.attribute.BAttributeMain"; - public static final String ATTRIBUTE_CONNECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnection"; - - public static final String ATTRIBUTE_TRACK_DIRECTION = "de.bmotionstudio.gef.editor.attribute.AttributeTrackDirection"; - public static final String ATTRIBUTE_SWITCH_DIRECTION = "de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection"; - public static final String ATTRIBUTE_SWITCH_POSITION = "de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition"; - public static final String ATTRIBUTE_SIGNAL_COLOR = "de.bmotionstudio.gef.editor.attribute.AttributeSignalColor"; - public static final String ATTRIBUTE_LIGHTS = "de.bmotionstudio.gef.editor.attribute.AttributeLights"; - public static final String ATTRIBUTE_FILL_HEIGHT = "de.bmotionstudio.gef.editor.attribute.AttributeFillHeight"; - public static final String ATTRIBUTE_FILL_COLOR = "de.bmotionstudio.gef.editor.attribute.AttributeFillColor"; - public static final String ATTRIBUTE_SHOWS_MEASURE = "de.bmotionstudio.gef.editor.attribute.AttributeShowMeasure"; - public static final String ATTRIBUTE_MEASURE_MAXPOS = "de.bmotionstudio.gef.editor.attribute.AttributeMeasureMaxPos"; - public static final String ATTRIBUTE_MEASURE_INTERVAL = "de.bmotionstudio.gef.editor.attribute.AttributeMeasureInterval"; - public static final String ATTRIBUTE_BLOCKS = "de.bmotionstudio.gef.editor.attribute.AttributeBlocks"; - - public static final String EVENT_MOUSECLICK = "de.bmotionstudio.gef.editor.event.OnClickEvent"; - public static final String EVENT_MOUSEDBLCLICK = "de.bmotionstudio.gef.editor.event.OnDblClickEvent"; - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +public final class AttributeConstants { + + public static final String ATTRIBUTE_X = "de.bmotionstudio.gef.editor.attribute.BAttributeX"; + public static final String ATTRIBUTE_Y = "de.bmotionstudio.gef.editor.attribute.BAttributeY"; + public static final String ATTRIBUTE_WIDTH = "de.bmotionstudio.gef.editor.attribute.BAttributeWidth"; + public static final String ATTRIBUTE_HEIGHT = "de.bmotionstudio.gef.editor.attribute.BAttributeHeight"; + public static final String ATTRIBUTE_CUSTOM = "de.bmotionstudio.gef.editor.attribute.BAttributeCustom"; + public static final String ATTRIBUTE_ID = "de.bmotionstudio.gef.editor.attribute.BAttributeID"; + public static final String ATTRIBUTE_VISIBLE = "de.bmotionstudio.gef.editor.attribute.BAttributeVisible"; + + public static final String ATTRIBUTE_COLUMNS = "de.bmotionstudio.gef.editor.attribute.BAttributeColumns"; + public static final String ATTRIBUTE_ROWS = "de.bmotionstudio.gef.editor.attribute.BAttributeRows"; + + public static final String ATTRIBUTE_BACKGROUND_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage"; + public static final String ATTRIBUTE_BACKGROUND_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor"; + public static final String ATTRIBUTE_FOREGROUND_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor"; + public static final String ATTRIBUTE_BACKGROUND_VISIBLE = "de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundVisible"; + public static final String ATTRIBUTE_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage"; + public static final String ATTRIBUTE_TEXT = "de.bmotionstudio.gef.editor.attribute.BAttributeText"; + public static final String ATTRIBUTE_TEXT_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeTextColor"; + public static final String ATTRIBUTE_ALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeAlpha"; + public static final String ATTRIBUTE_OUTLINEALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha"; + public static final String ATTRIBUTE_FONT = "de.bmotionstudio.gef.editor.attribute.BAttributeFont"; + public static final String ATTRIBUTE_ENABLED = "de.bmotionstudio.gef.editor.attribute.BAttributeEnabled"; + public static final String ATTRIBUTE_CHECKED = "de.bmotionstudio.gef.editor.attribute.BAttributeChecked"; + public static final String ATTRIBUTE_VALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeValue"; + public static final String ATTRIBUTE_BUTTONGROUP = "de.bmotionstudio.gef.editor.attribute.BAttributeButtonGroup"; + public static final String ATTRIBUTE_SHAPE = "de.bmotionstudio.gef.editor.attribute.BAttributeShape"; + public static final String ATTRIBUTE_ORIENTATION = "de.bmotionstudio.gef.editor.attribute.BAttributeOrientation"; + public static final String ATTRIBUTE_DIRECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeDirection"; + public static final String ATTRIBUTE_FILLTYPE = "de.bmotionstudio.gef.editor.attribute.BAttributeFillType"; + public static final String ATTRIBUTE_LINEWIDTH = "de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth"; + public static final String ATTRIBUTE_LINESTYLE = "de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle"; + public static final String ATTRIBUTE_TRUEVALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeTrueValue"; + public static final String ATTRIBUTE_FALSEVALUE = "de.bmotionstudio.gef.editor.attribute.BAttributeFalseValue"; + public static final String ATTRIBUTE_LABEL = "de.bmotionstudio.gef.editor.attribute.BAttributeLabel"; + public static final String ATTRIBUTE_OFFSET_H = "de.bmotionstudio.gef.editor.attribute.BAttributeOffsetH"; + public static final String ATTRIBUTE_OFFSET_V = "de.bmotionstudio.gef.editor.attribute.BAttributeOffsetV"; + public static final String ATTRIBUTE_CONNECTION_SOURCE_DECORATION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration"; + public static final String ATTRIBUTE_CONNECTION_TARGET_DECORATION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration"; + + public static final String ATTRIBUTE_SIZE = "de.bmotionstudio.gef.editor.attribute.BAttributeSize"; + public static final String ATTRIBUTE_COORDINATES = "de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates"; + public static final String ATTRIBUTE_MISC = "de.bmotionstudio.gef.editor.attribute.BAttributeMisc"; + public static final String ATTRIBUTE_MAIN = "de.bmotionstudio.gef.editor.attribute.BAttributeMain"; + public static final String ATTRIBUTE_CONNECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnection"; + + public static final String ATTRIBUTE_TRACK_DIRECTION = "de.bmotionstudio.gef.editor.attribute.AttributeTrackDirection"; + public static final String ATTRIBUTE_SWITCH_DIRECTION = "de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection"; + public static final String ATTRIBUTE_SWITCH_POSITION = "de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition"; + public static final String ATTRIBUTE_SIGNAL_COLOR = "de.bmotionstudio.gef.editor.attribute.AttributeSignalColor"; + public static final String ATTRIBUTE_LIGHTS = "de.bmotionstudio.gef.editor.attribute.AttributeLights"; + public static final String ATTRIBUTE_FILL_HEIGHT = "de.bmotionstudio.gef.editor.attribute.AttributeFillHeight"; + public static final String ATTRIBUTE_FILL_COLOR = "de.bmotionstudio.gef.editor.attribute.AttributeFillColor"; + public static final String ATTRIBUTE_SHOWS_MEASURE = "de.bmotionstudio.gef.editor.attribute.AttributeShowMeasure"; + public static final String ATTRIBUTE_MEASURE_MAXPOS = "de.bmotionstudio.gef.editor.attribute.AttributeMeasureMaxPos"; + public static final String ATTRIBUTE_MEASURE_INTERVAL = "de.bmotionstudio.gef.editor.attribute.AttributeMeasureInterval"; + public static final String ATTRIBUTE_BLOCKS = "de.bmotionstudio.gef.editor.attribute.AttributeBlocks"; + + public static final String EVENT_MOUSECLICK = "de.bmotionstudio.gef.editor.event.OnClickEvent"; + public static final String EVENT_MOUSEDBLCLICK = "de.bmotionstudio.gef.editor.event.OnDblClickEvent"; + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BControlCreationFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BControlCreationFactory.java index 50024a585311ccce269679ea639f4d451b5ed159..f94182dcb703ac07236ce66209167035b84edd4c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BControlCreationFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BControlCreationFactory.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.gef.requests.CreationFactory; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class BControlCreationFactory implements CreationFactory { - - private Visualization visualization; - private String type; - - public BControlCreationFactory(String type, Visualization visualization) { - this.type = type; - this.visualization = visualization; - } - - @Override - public Object getNewObject() { - BControl control = null; - try { - IBControlService service = (IBControlService) BMotionEditorPlugin - .getControlServices().get(type) - .createExecutableExtension("service"); - control = service.createControl(visualization); - } catch (CoreException e) { - e.printStackTrace(); - } - // TODO: check if control == null - return control; - } - - @Override - public Object getObjectType() { - return BControl.class; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.gef.requests.CreationFactory; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class BControlCreationFactory implements CreationFactory { + + private Visualization visualization; + private String type; + + public BControlCreationFactory(String type, Visualization visualization) { + this.type = type; + this.visualization = visualization; + } + + @Override + public Object getNewObject() { + BControl control = null; + try { + IBControlService service = (IBControlService) BMotionEditorPlugin + .getControlServices().get(type) + .createExecutableExtension("service"); + control = service.createControl(visualization); + } catch (CoreException e) { + e.printStackTrace(); + } + // TODO: check if control == null + return control; + } + + @Override + public Object getObjectType() { + return BControl.class; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSContextMenuProvider.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSContextMenuProvider.java index 2dab8b07fcc578cbc9968ca985229b2536b55225..56c3a11e3069c74bb00ea08158c8fed567019c45 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSContextMenuProvider.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSContextMenuProvider.java @@ -1,317 +1,317 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.editparts.AbstractEditPart; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.ActionFactory; - -import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public class BMSContextMenuProvider extends ContextMenuProvider { - - private ActionRegistry actionRegistry; - - private IExtensionRegistry registry = Platform.getExtensionRegistry(); - - private String[] eventIDs = { AttributeConstants.EVENT_MOUSECLICK }; - - public BMSContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) { - super(viewer); - setActionRegistry(registry); - } - - @Override - public void buildContextMenu(IMenuManager menu) { - - IAction action; - - GEFActionConstants.addStandardActionGroups(menu); - - action = getActionRegistry().getAction(ActionFactory.UNDO.getId()); - menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); - - action = getActionRegistry().getAction(ActionFactory.REDO.getId()); - menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); - - action = getActionRegistry().getAction(ActionFactory.COPY.getId()); - menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); - - action = getActionRegistry().getAction(ActionFactory.PASTE.getId()); - menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); - - action = getActionRegistry().getAction(ActionFactory.DELETE.getId()); - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); - - Object sel = ((IStructuredSelection) getViewer().getSelection()) - .getFirstElement(); - - if (sel instanceof AbstractEditPart) { - AbstractEditPart editPart = (AbstractEditPart) sel; - buildCustomMenu(menu, editPart); - buildObserverMenu(menu, editPart); - buildEventMenu(menu, editPart); - } - - } - - private void buildCustomMenu(IMenuManager menu, AbstractEditPart editPart) { - - Object model = editPart.getModel(); - - if (model instanceof BControl) { - - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.installMenu"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("menu".equals(configurationElement.getName())) { - - try { - - IInstallMenu installMenuClass = (IInstallMenu) configurationElement - .createExecutableExtension("class"); - - installMenuClass.installMenu(menu, - getActionRegistry()); - - } catch (final CoreException e) { - e.printStackTrace(); - } - - } - - } - - } - - } - - } - - private void buildObserverMenu(IMenuManager menu, AbstractEditPart editPart) { - - Object model = editPart.getModel(); - - BControl bcontrol = null; - - if (model instanceof BControl) - bcontrol = (BControl) model; - else - return; - - final MenuManager handleObserverMenu = new MenuManager("Observer", - BMotionStudioImage.getImageDescriptor( - BMotionEditorPlugin.PLUGIN_ID, - "icons/icon_observer.gif"), "observerMenu"); - menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleObserverMenu); - - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.observer"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("observer".equals(configurationElement.getName())) { - - final String observerClassName = configurationElement - .getAttribute("class"); - final String observerName = configurationElement - .getAttribute("name"); - - if (checkIncludeObserver(observerClassName, bcontrol)) { - - IAction action = getActionRegistry().getAction( - "de.bmotionstudio.gef.editor.observerAction." - + observerClassName); - action.setText(observerName); - action.setToolTipText(observerName); - - if (bcontrol.hasObserver(observerClassName)) { - action.setImageDescriptor(BMotionStudioImage - .getImageDescriptor( - BMotionEditorPlugin.PLUGIN_ID, - "icons/icon_chop.gif")); - } else { - action.setImageDescriptor(null); - } - handleObserverMenu.add(action); - - } - - } - - } - - } - - } - - private boolean checkIncludeObserver(String observerID, BControl control) { - - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.includeObserver"); - - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("include".equals(configurationElement.getName())) { - - String langID = configurationElement - .getAttribute("language"); - - if (langID != null - && langID.equals(control.getVisualization() - .getLanguage())) { - - for (IConfigurationElement cObserver : configurationElement - .getChildren("observer")) { - - String oID = cObserver.getAttribute("id"); - - if (observerID.equals(oID)) { - - for (IConfigurationElement configBControl : cObserver - .getChildren("control")) { - - String bID = configBControl - .getAttribute("id"); - - if (control.getType().equals(bID)) { - return true; - } - - } - - } - - } - - } - - } - - } - } - - return false; - - } - - private void buildEventMenu(IMenuManager menu, AbstractEditPart editPart) { - - Object model = editPart.getModel(); - - if (model instanceof BControl && !(model instanceof Visualization)) { - - MenuManager handleEventMenu = new MenuManager("Events", - BMotionStudioImage.getImageDescriptor( - BMotionEditorPlugin.PLUGIN_ID, - "icons/icon_event.png"), "eventMenu"); - menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleEventMenu); - - BControl bcontrol = (BControl) model; - - // Has event - if (bcontrol.hasEvent(eventIDs[0])) { - - SchedulerEvent event = bcontrol.getEvent(eventIDs[0]); - - OpenSchedulerEventAction action = (OpenSchedulerEventAction) getActionRegistry() - .getAction( - "de.bmotionstudio.gef.editor.SchedulerEventAction." - + event.getID()); - action.setEventID(eventIDs[0]); - action.setText(event.getName()); - action.setImageDescriptor(BMotionStudioImage - .getImageDescriptor(BMotionEditorPlugin.PLUGIN_ID, - "icons/icon_chop.gif")); - handleEventMenu.add(action); - - } else { // Has no event - - IExtensionPoint schedulerExtensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.schedulerEvent"); - for (IExtension schedulerExtension : schedulerExtensionPoint - .getExtensions()) { - for (IConfigurationElement configSchedulerElement : schedulerExtension - .getConfigurationElements()) { - - if ("schedulerEvent".equals(configSchedulerElement - .getName())) { - - String sClassName = configSchedulerElement - .getAttribute("class"); - Boolean show = Boolean - .valueOf(configSchedulerElement - .getAttribute("menu")); - - if (show) { - - OpenSchedulerEventAction action = (OpenSchedulerEventAction) getActionRegistry() - .getAction( - "de.bmotionstudio.gef.editor.SchedulerEventAction." - + sClassName); - action.setEventID(eventIDs[0]); - action.setText(configSchedulerElement - .getAttribute("name")); - - // if (bcontrol.hasEvent(eventIDs[0])) { - // action - // .setImageDescriptor(BMotionStudioImage - // .getImageDescriptor( - // BMotionEditorPlugin.PLUGIN_ID, - // "icons/icon_chop.gif")); - // } else { - - action.setImageDescriptor(null); - - // } - - handleEventMenu.add(action); - - } - - } - - } - - } - - } - } - - } - - private ActionRegistry getActionRegistry() { - return actionRegistry; - } - - private void setActionRegistry(ActionRegistry registry) { - actionRegistry = registry; - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.gef.ContextMenuProvider; +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.editparts.AbstractEditPart; +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.actions.ActionFactory; + +import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public class BMSContextMenuProvider extends ContextMenuProvider { + + private ActionRegistry actionRegistry; + + private IExtensionRegistry registry = Platform.getExtensionRegistry(); + + private String[] eventIDs = { AttributeConstants.EVENT_MOUSECLICK }; + + public BMSContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) { + super(viewer); + setActionRegistry(registry); + } + + @Override + public void buildContextMenu(IMenuManager menu) { + + IAction action; + + GEFActionConstants.addStandardActionGroups(menu); + + action = getActionRegistry().getAction(ActionFactory.UNDO.getId()); + menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); + + action = getActionRegistry().getAction(ActionFactory.REDO.getId()); + menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); + + action = getActionRegistry().getAction(ActionFactory.COPY.getId()); + menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); + + action = getActionRegistry().getAction(ActionFactory.PASTE.getId()); + menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); + + action = getActionRegistry().getAction(ActionFactory.DELETE.getId()); + menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); + + Object sel = ((IStructuredSelection) getViewer().getSelection()) + .getFirstElement(); + + if (sel instanceof AbstractEditPart) { + AbstractEditPart editPart = (AbstractEditPart) sel; + buildCustomMenu(menu, editPart); + buildObserverMenu(menu, editPart); + buildEventMenu(menu, editPart); + } + + } + + private void buildCustomMenu(IMenuManager menu, AbstractEditPart editPart) { + + Object model = editPart.getModel(); + + if (model instanceof BControl) { + + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.installMenu"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("menu".equals(configurationElement.getName())) { + + try { + + IInstallMenu installMenuClass = (IInstallMenu) configurationElement + .createExecutableExtension("class"); + + installMenuClass.installMenu(menu, + getActionRegistry()); + + } catch (final CoreException e) { + e.printStackTrace(); + } + + } + + } + + } + + } + + } + + private void buildObserverMenu(IMenuManager menu, AbstractEditPart editPart) { + + Object model = editPart.getModel(); + + BControl bcontrol = null; + + if (model instanceof BControl) + bcontrol = (BControl) model; + else + return; + + final MenuManager handleObserverMenu = new MenuManager("Observer", + BMotionStudioImage.getImageDescriptor( + BMotionEditorPlugin.PLUGIN_ID, + "icons/icon_observer.gif"), "observerMenu"); + menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleObserverMenu); + + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.observer"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("observer".equals(configurationElement.getName())) { + + final String observerClassName = configurationElement + .getAttribute("class"); + final String observerName = configurationElement + .getAttribute("name"); + + if (checkIncludeObserver(observerClassName, bcontrol)) { + + IAction action = getActionRegistry().getAction( + "de.bmotionstudio.gef.editor.observerAction." + + observerClassName); + action.setText(observerName); + action.setToolTipText(observerName); + + if (bcontrol.hasObserver(observerClassName)) { + action.setImageDescriptor(BMotionStudioImage + .getImageDescriptor( + BMotionEditorPlugin.PLUGIN_ID, + "icons/icon_chop.gif")); + } else { + action.setImageDescriptor(null); + } + handleObserverMenu.add(action); + + } + + } + + } + + } + + } + + private boolean checkIncludeObserver(String observerID, BControl control) { + + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.includeObserver"); + + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("include".equals(configurationElement.getName())) { + + String langID = configurationElement + .getAttribute("language"); + + if (langID != null + && langID.equals(control.getVisualization() + .getLanguage())) { + + for (IConfigurationElement cObserver : configurationElement + .getChildren("observer")) { + + String oID = cObserver.getAttribute("id"); + + if (observerID.equals(oID)) { + + for (IConfigurationElement configBControl : cObserver + .getChildren("control")) { + + String bID = configBControl + .getAttribute("id"); + + if (control.getType().equals(bID)) { + return true; + } + + } + + } + + } + + } + + } + + } + } + + return false; + + } + + private void buildEventMenu(IMenuManager menu, AbstractEditPart editPart) { + + Object model = editPart.getModel(); + + if (model instanceof BControl && !(model instanceof Visualization)) { + + MenuManager handleEventMenu = new MenuManager("Events", + BMotionStudioImage.getImageDescriptor( + BMotionEditorPlugin.PLUGIN_ID, + "icons/icon_event.png"), "eventMenu"); + menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleEventMenu); + + BControl bcontrol = (BControl) model; + + // Has event + if (bcontrol.hasEvent(eventIDs[0])) { + + SchedulerEvent event = bcontrol.getEvent(eventIDs[0]); + + OpenSchedulerEventAction action = (OpenSchedulerEventAction) getActionRegistry() + .getAction( + "de.bmotionstudio.gef.editor.SchedulerEventAction." + + event.getID()); + action.setEventID(eventIDs[0]); + action.setText(event.getName()); + action.setImageDescriptor(BMotionStudioImage + .getImageDescriptor(BMotionEditorPlugin.PLUGIN_ID, + "icons/icon_chop.gif")); + handleEventMenu.add(action); + + } else { // Has no event + + IExtensionPoint schedulerExtensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.schedulerEvent"); + for (IExtension schedulerExtension : schedulerExtensionPoint + .getExtensions()) { + for (IConfigurationElement configSchedulerElement : schedulerExtension + .getConfigurationElements()) { + + if ("schedulerEvent".equals(configSchedulerElement + .getName())) { + + String sClassName = configSchedulerElement + .getAttribute("class"); + Boolean show = Boolean + .valueOf(configSchedulerElement + .getAttribute("menu")); + + if (show) { + + OpenSchedulerEventAction action = (OpenSchedulerEventAction) getActionRegistry() + .getAction( + "de.bmotionstudio.gef.editor.SchedulerEventAction." + + sClassName); + action.setEventID(eventIDs[0]); + action.setText(configSchedulerElement + .getAttribute("name")); + + // if (bcontrol.hasEvent(eventIDs[0])) { + // action + // .setImageDescriptor(BMotionStudioImage + // .getImageDescriptor( + // BMotionEditorPlugin.PLUGIN_ID, + // "icons/icon_chop.gif")); + // } else { + + action.setImageDescriptor(null); + + // } + + handleEventMenu.add(action); + + } + + } + + } + + } + + } + } + + } + + private ActionRegistry getActionRegistry() { + return actionRegistry; + } + + private void setActionRegistry(ActionRegistry registry) { + actionRegistry = registry; + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java index 471fb40d71ffa52e5d42c6ab6994b7b4518d6ff8..b3a006c69cd58cda9d9fca8a3fb095eae559c0ce 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java @@ -1,221 +1,216 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -import com.thoughtworks.xstream.XStream; - -import de.bmotionstudio.gef.editor.internal.BControlListConverter; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlList; -import de.bmotionstudio.gef.editor.model.BMotionGuide; -import de.bmotionstudio.gef.editor.model.Visualization; - -/** - * The activator class controls the plug-in life cycle - */ -public class BMotionEditorPlugin extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "de.bmotionstudio.gef.editor"; - - public static final String FILEEXT_STUDIO = "bmso"; - - // The shared instance - private static BMotionEditorPlugin plugin; - - private static HashMap<String, IConfigurationElement> controlExtensions = new HashMap<String, IConfigurationElement>(); - - private static HashMap<String, IConfigurationElement> observerExtensions = new HashMap<String, IConfigurationElement>(); - - private static HashMap<String, IConfigurationElement> schedulerExtensions = new HashMap<String, IConfigurationElement>(); - - private static HashMap<String, IConfigurationElement> controlServices = new HashMap<String, IConfigurationElement>(); - - IExtensionRegistry registry = Platform.getExtensionRegistry(); - - static BMotionStudioEditorPage activeBMotionStudioEditor = null; - - /** - * The constructor - */ - public BMotionEditorPlugin() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - @Override - public void start(final BundleContext context) throws Exception { - super.start(context); - plugin = this; - initExtensionClasses(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - @Override - public void stop(final BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static BMotionEditorPlugin 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(final String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - /** - * Get the active workbench page. - * - * @return current active workbench page - */ - public static IWorkbenchPage getActivePage() { - return getDefault().internalGetActivePage(); - } - - /** - * Get the active editor. - * - * @return current active editor - */ - public static BMotionStudioEditor getActiveEditor() { - if (getActivePage() != null) { - if (getActivePage().getActiveEditor() instanceof BMotionStudioEditor) - return (BMotionStudioEditor) getActivePage().getActiveEditor(); - } - return null; - } - - /** - * Getting the current active page from the active workbench window. - * <p> - * - * @return current active workbench page - */ - private IWorkbenchPage internalGetActivePage() { - return getWorkbench().getActiveWorkbenchWindow().getActivePage(); - } - - private void initExtensionClass(String extensionPointID, - ArrayList<String> elementIDs, String getAttribute, - HashMap<String, IConfigurationElement> hashMap) { - - IExtensionPoint extensionPoint = registry - .getExtensionPoint(extensionPointID); - for (IExtension extension : extensionPoint.getExtensions()) { - - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if (elementIDs.contains(configurationElement.getName())) { - - String atr = configurationElement - .getAttribute(getAttribute); - - hashMap.put(atr, configurationElement); - - } - - } - - } - - } - - private void initExtensionClasses() { - - ArrayList<String> elementIDs = new ArrayList<String>(); - elementIDs.add("control"); - initExtensionClass("de.bmotionstudio.gef.editor.control", elementIDs, - "id", controlExtensions); - - elementIDs.clear(); - elementIDs.add("control"); - initExtensionClass("de.bmotionstudio.gef.editor.control", elementIDs, - "id", controlServices); - - elementIDs.clear(); - elementIDs.add("observer"); - initExtensionClass("de.bmotionstudio.gef.editor.observer", elementIDs, - "class", observerExtensions); - - elementIDs.clear(); - elementIDs.add("schedulerEvent"); - initExtensionClass("de.bmotionstudio.gef.editor.schedulerEvent", - elementIDs, "class", schedulerExtensions); - - } - - public static IConfigurationElement getControlExtension(String ident) { - return controlExtensions.get(ident); - } - - public static IConfigurationElement getObserverExtension(String ident) { - return observerExtensions.get(ident); - } - - public static IConfigurationElement getSchedulerExtension(String ident) { - return schedulerExtensions.get(ident); - } - - public static HashMap<String, IConfigurationElement> getSchedulerExtensions() { - return schedulerExtensions; - } - - public static HashMap<String, IConfigurationElement> getControlServices() { - return controlServices; - } - - public static void setAliases(XStream xstream) { - xstream.registerConverter(new BControlListConverter()); - xstream.alias("control", BControl.class); - xstream.alias("visualization", Visualization.class); - xstream.alias("guide", BMotionGuide.class); - xstream.alias("connection", BConnection.class); - xstream.alias("children", BControlList.class); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.thoughtworks.xstream.XStream; + +import de.bmotionstudio.gef.editor.internal.BControlListConverter; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlList; +import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.model.Visualization; + +/** + * The activator class controls the plug-in life cycle + */ +public class BMotionEditorPlugin extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "de.bmotionstudio.gef.editor"; + + public static final String FILEEXT_STUDIO = "bmso"; + + // The shared instance + private static BMotionEditorPlugin plugin; + + private static HashMap<String, IConfigurationElement> controlExtensions = new HashMap<String, IConfigurationElement>(); + + private static HashMap<String, IConfigurationElement> observerExtensions = new HashMap<String, IConfigurationElement>(); + + private static HashMap<String, IConfigurationElement> schedulerExtensions = new HashMap<String, IConfigurationElement>(); + + private static HashMap<String, IConfigurationElement> controlServices = new HashMap<String, IConfigurationElement>(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + + static BMotionStudioEditorPage activeBMotionStudioEditor = null; + + /** + * The constructor + */ + public BMotionEditorPlugin() { + } + + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + initExtensionClasses(); + } + + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static BMotionEditorPlugin 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(final String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + /** + * Get the active workbench page. + * + * @return current active workbench page + */ + public static IWorkbenchPage getActivePage() { + return getDefault().internalGetActivePage(); + } + + /** + * Get the active editor. + * + * @return current active editor + */ + public static BMotionStudioEditor getActiveEditor() { + if (getActivePage() != null) { + if (getActivePage().getActiveEditor() instanceof BMotionStudioEditor) + return (BMotionStudioEditor) getActivePage().getActiveEditor(); + } + return null; + } + + /** + * Getting the current active page from the active workbench window. + * <p> + * + * @return current active workbench page + */ + private IWorkbenchPage internalGetActivePage() { + return getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } + + private void initExtensionClass(String extensionPointID, + ArrayList<String> elementIDs, String getAttribute, + HashMap<String, IConfigurationElement> hashMap) { + + IExtensionPoint extensionPoint = registry + .getExtensionPoint(extensionPointID); + for (IExtension extension : extensionPoint.getExtensions()) { + + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if (elementIDs.contains(configurationElement.getName())) { + + String atr = configurationElement + .getAttribute(getAttribute); + + hashMap.put(atr, configurationElement); + + } + + } + + } + + } + + private void initExtensionClasses() { + + ArrayList<String> elementIDs = new ArrayList<String>(); + elementIDs.add("control"); + initExtensionClass("de.bmotionstudio.gef.editor.control", elementIDs, + "id", controlExtensions); + + elementIDs.clear(); + elementIDs.add("control"); + initExtensionClass("de.bmotionstudio.gef.editor.control", elementIDs, + "id", controlServices); + + elementIDs.clear(); + elementIDs.add("observer"); + initExtensionClass("de.bmotionstudio.gef.editor.observer", elementIDs, + "class", observerExtensions); + + elementIDs.clear(); + elementIDs.add("schedulerEvent"); + initExtensionClass("de.bmotionstudio.gef.editor.schedulerEvent", + elementIDs, "class", schedulerExtensions); + + } + + public static IConfigurationElement getControlExtension(String ident) { + return controlExtensions.get(ident); + } + + public static IConfigurationElement getObserverExtension(String ident) { + return observerExtensions.get(ident); + } + + public static IConfigurationElement getSchedulerExtension(String ident) { + return schedulerExtensions.get(ident); + } + + public static HashMap<String, IConfigurationElement> getSchedulerExtensions() { + return schedulerExtensions; + } + + public static HashMap<String, IConfigurationElement> getControlServices() { + return controlServices; + } + + public static void allowTypes(XStream xstream) { + xstream.allowTypesByWildcard(new String[] { + "de.bmotionstudio.gef.editor.**", + "org.eclipse.draw2d.geometry.Point", + "org.eclipse.swt.graphics.RGB", + }); + } + + public static void setAliases(XStream xstream) { + xstream.registerConverter(new BControlListConverter()); + xstream.alias("control", BControl.class); + xstream.alias("visualization", Visualization.class); + xstream.alias("guide", BMotionGuide.class); + xstream.alias("connection", BConnection.class); + xstream.alias("children", BControlList.class); + allowTypes(xstream); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionSelectionSynchronizer.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionSelectionSynchronizer.java index 69891a07f7a660d48bd101972cb780b570ce730e..64ef38dceb1729c0be036d877a1ecd0a8d5d6159 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionSelectionSynchronizer.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionSelectionSynchronizer.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.gef.ui.parts.SelectionSynchronizer; -import org.eclipse.gef.ui.parts.TreeViewer; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BMotionSelectionSynchronizer extends SelectionSynchronizer { - - protected EditPart convert(EditPartViewer viewer, EditPart part) { - EditPart p = super.convert(viewer, part); - if (viewer instanceof ScrollingGraphicalViewer - || viewer instanceof TreeViewer) { - Object model = part.getModel(); - if (model instanceof BControl) { - Object temp = viewer.getEditPartRegistry().get(model); - EditPart newPart = null; - if (temp != null) - newPart = (EditPart) temp; - return newPart; - } - } - return p; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; +import org.eclipse.gef.ui.parts.SelectionSynchronizer; +import org.eclipse.gef.ui.parts.TreeViewer; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BMotionSelectionSynchronizer extends SelectionSynchronizer { + + protected EditPart convert(EditPartViewer viewer, EditPart part) { + EditPart p = super.convert(viewer, part); + if (viewer instanceof ScrollingGraphicalViewer + || viewer instanceof TreeViewer) { + Object model = part.getModel(); + if (model instanceof BControl) { + Object temp = viewer.getEditPartRegistry().get(model); + EditPart newPart = null; + if (temp != null) + newPart = (EditPart) temp; + return newPart; + } + } + return p; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioContributor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioContributor.java index 5ad0698027a155b9edb6288be6e889ff5490110a..1a43742694434462a941adf1bfa043f62cd8e57a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioContributor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioContributor.java @@ -1,107 +1,107 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.gef.ui.actions.ActionBarContributor; -import org.eclipse.gef.ui.actions.DeleteRetargetAction; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.RedoRetargetAction; -import org.eclipse.gef.ui.actions.UndoRetargetAction; -import org.eclipse.gef.ui.actions.ZoomComboContributionItem; -import org.eclipse.gef.ui.actions.ZoomInRetargetAction; -import org.eclipse.gef.ui.actions.ZoomOutRetargetAction; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.RetargetAction; - -public class BMotionStudioContributor extends ActionBarContributor { - - @Override - protected void buildActions() { - IWorkbenchWindow iww = getPage().getWorkbenchWindow(); - - addRetargetAction(new UndoRetargetAction()); - addRetargetAction(new RedoRetargetAction()); - - addRetargetAction(new DeleteRetargetAction()); - - addRetargetAction((RetargetAction) ActionFactory.COPY.create(iww)); - addRetargetAction((RetargetAction) ActionFactory.PASTE.create(iww)); - - addRetargetAction(new ZoomInRetargetAction()); - addRetargetAction(new ZoomOutRetargetAction()); - - addRetargetAction(new RetargetAction( - GEFActionConstants.TOGGLE_RULER_VISIBILITY, "Ruler", - IAction.AS_CHECK_BOX)); - - addRetargetAction(new RetargetAction( - GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid", - IAction.AS_CHECK_BOX)); - - addRetargetAction(new RetargetAction( - GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, "Snap to Geometry", - IAction.AS_CHECK_BOX)); - } - - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(getAction(ActionFactory.DELETE.getId())); - toolBarManager.add(getAction(ActionFactory.COPY.getId())); - toolBarManager.add(getAction(ActionFactory.PASTE.getId())); - toolBarManager.add(new Separator()); - toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN)); - toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT)); - toolBarManager.add(new ZoomComboContributionItem(getPage())); - } - - @Override - protected void declareGlobalActionKeys() { - } - - @Override - public void contributeToMenu(IMenuManager menuManager) { - - super.contributeToMenu(menuManager); - - IContributionItem bMenu = menuManager - .find("de.bmotionstudio.gef.editor.menu"); - if (bMenu != null) { - - IMenuManager bmotionMenu = (IMenuManager) bMenu; - MenuManager viewMenu = new MenuManager("Editor"); - viewMenu.add(getAction(GEFActionConstants.ZOOM_IN)); - viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT)); - viewMenu.add(new Separator()); - viewMenu.add(getAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY)); - viewMenu.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); - viewMenu.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY)); - bmotionMenu - .insertAfter( - "de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite", - viewMenu); - - } - - } - - public void setActiveEditor(IEditorPart editor) { - if (editor instanceof BMotionStudioEditor) { - super.setActiveEditor(((BMotionStudioEditor) editor).getEditPage()); - } else { - super.setActiveEditor(editor); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.gef.ui.actions.ActionBarContributor; +import org.eclipse.gef.ui.actions.DeleteRetargetAction; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.gef.ui.actions.RedoRetargetAction; +import org.eclipse.gef.ui.actions.UndoRetargetAction; +import org.eclipse.gef.ui.actions.ZoomComboContributionItem; +import org.eclipse.gef.ui.actions.ZoomInRetargetAction; +import org.eclipse.gef.ui.actions.ZoomOutRetargetAction; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.RetargetAction; + +public class BMotionStudioContributor extends ActionBarContributor { + + @Override + protected void buildActions() { + IWorkbenchWindow iww = getPage().getWorkbenchWindow(); + + addRetargetAction(new UndoRetargetAction()); + addRetargetAction(new RedoRetargetAction()); + + addRetargetAction(new DeleteRetargetAction()); + + addRetargetAction((RetargetAction) ActionFactory.COPY.create(iww)); + addRetargetAction((RetargetAction) ActionFactory.PASTE.create(iww)); + + addRetargetAction(new ZoomInRetargetAction()); + addRetargetAction(new ZoomOutRetargetAction()); + + addRetargetAction(new RetargetAction( + GEFActionConstants.TOGGLE_RULER_VISIBILITY, "Ruler", + IAction.AS_CHECK_BOX)); + + addRetargetAction(new RetargetAction( + GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid", + IAction.AS_CHECK_BOX)); + + addRetargetAction(new RetargetAction( + GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, "Snap to Geometry", + IAction.AS_CHECK_BOX)); + } + + @Override + public void contributeToToolBar(IToolBarManager toolBarManager) { + toolBarManager.add(getAction(ActionFactory.DELETE.getId())); + toolBarManager.add(getAction(ActionFactory.COPY.getId())); + toolBarManager.add(getAction(ActionFactory.PASTE.getId())); + toolBarManager.add(new Separator()); + toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN)); + toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT)); + toolBarManager.add(new ZoomComboContributionItem(getPage())); + } + + @Override + protected void declareGlobalActionKeys() { + } + + @Override + public void contributeToMenu(IMenuManager menuManager) { + + super.contributeToMenu(menuManager); + + IContributionItem bMenu = menuManager + .find("de.bmotionstudio.gef.editor.menu"); + if (bMenu != null) { + + IMenuManager bmotionMenu = (IMenuManager) bMenu; + MenuManager viewMenu = new MenuManager("Editor"); + viewMenu.add(getAction(GEFActionConstants.ZOOM_IN)); + viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT)); + viewMenu.add(new Separator()); + viewMenu.add(getAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY)); + viewMenu.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); + viewMenu.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY)); + bmotionMenu + .insertAfter( + "de.bmotionstudio.gef.editor.command.openBMotionStudioWebsite", + viewMenu); + + } + + } + + public void setActiveEditor(IEditorPart editor) { + if (editor instanceof BMotionStudioEditor) { + super.setActiveEditor(((BMotionStudioEditor) editor).getEditPage()); + } else { + super.setActiveEditor(editor); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java index dd47255931b716b376cf656bbb4905283cc79d93..dea2ce633352ba11e422956260b794eec3fcf239 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java @@ -1,291 +1,291 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.mapper.MapperWrapper; - -import de.bmotionstudio.gef.editor.internal.BMSConverter512; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.core.ILifecycleListener; -import de.prob.logging.Logger; - -public class BMotionStudioEditor extends MultiPageEditorPart implements - ILifecycleListener { - - private BMotionStudioEditorPage editPage; - - private BMotionStudioRunPage runPage; - - private Visualization visualization; - - private Animation animation; - - private ArrayList<IRunPageListener> runPageListener = new ArrayList<IRunPageListener>(); - - @Override - protected void createPages() { - createEditPage(); - } - - private void createEditPage() { - editPage = new BMotionStudioEditorPage(getVisualization(), this); - try { - int index = addPage(editPage, getEditorInput()); - setPageText(index, "Edit"); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - - public void createRunPage(Visualization visualization, Animation animation) { - StaticListenerRegistry.registerListener(this); - this.animation = animation; - - if (runPage != null) - runPage.dispose(); - - runPage = new BMotionStudioRunPage(visualization); - try { - int index = addPage(runPage, getEditorInput()); - setPageText(index, "Run"); - setActivePage(index); - fireRunPageCreatedListener(); - } catch (PartInitException e) { - } - } - - public void removeRunPage() { - fireRunPageRemovedListener(); - if (runPage != null) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - removePage(1); - } - }); - } - unregister(); - } - - private void fireRunPageCreatedListener() { - for (IRunPageListener listener : runPageListener) { - listener.runPageCreated(runPage); - } - } - - private void fireRunPageRemovedListener() { - for (IRunPageListener listener : runPageListener) { - listener.runPageRemoved(runPage); - } - } - - @Override - public void dispose() { - unregister(); - super.dispose(); - } - - public Visualization getVisualization() { - return visualization; - } - - public void setDirty(boolean dirty) { - editPage.setDirty(dirty); - } - - /** - * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) - **/ - @Override - public void init(IEditorSite iSite, IEditorInput iInput) - throws PartInitException { - - super.init(iSite, iInput); - - IFile file = ((IFileEditorInput) iInput).getFile(); - - try { - - // ------------------------------------------------------- - - DocumentBuilderFactory dbFactory = DocumentBuilderFactory - .newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(file.getContents()); - NodeList nList = doc.getElementsByTagName("version"); - if (nList.item(0) != null) { - Element versionElement = (Element) nList.item(0); - String version = versionElement.getTextContent(); - if (version.equals("5.1.2")) { - new BMSConverter512(file); - } - } else { - new BMSConverter512(file); - } - - // ------------------------------------------------------- - - InputStream inputStream = file.getContents(); - - XStream xstream = new XStream() { - @Override - protected MapperWrapper wrapMapper(final MapperWrapper next) { - return new MapperWrapper(next) { - @Override - public boolean shouldSerializeMember( - @SuppressWarnings("rawtypes") final Class definedIn, - final String fieldName) { - if (definedIn == Object.class) - return false; - return super.shouldSerializeMember(definedIn, - fieldName); - } - }; - } - }; - - BMotionEditorPlugin.setAliases(xstream); - - visualization = (Visualization) xstream.fromXML(inputStream); - visualization.setProjectFile(((IFileEditorInput) getEditorInput()) - .getFile()); - // initLanguage(visualization); - - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (CoreException e) { - e.printStackTrace(); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } - - } - - @Override - public String getPartName() { - return visualization.getProjectFile().getName().replace(".bmso", "") - + " (" + getVisualization().getMachineName() + " - " - + getVisualization().getLanguage() + ")"; - } - - @Override - public void doSave(final IProgressMonitor monitor) { - editPage.doSave(monitor); - } - - @Override - public void doSaveAs() { - // Nothing to do here, this is never allowed - throw new IllegalAccessError("No way to enter this method."); - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - @Override - protected void pageChange(int newPageIndex) { - String newPageString = getPageText(newPageIndex); - if (newPageString.equals("Run")) { - switchPerspective("de.bmotionstudio.perspective.run"); - } else { - switchPerspective("de.bmotionstudio.perspective.edit"); - } - } - - private void switchPerspective(String id) { - IWorkbench workbench = PlatformUI.getWorkbench(); - try { - workbench.showPerspective(id, workbench.getActiveWorkbenchWindow()); - } catch (WorkbenchException e) { - Logger.notifyUser( - "An error occured while trying to switch the perspective.", - e); - } - } - - public BMotionStudioEditorPage getEditPage() { - return this.editPage; - } - - public BMotionStudioRunPage getRunPage() { - return this.runPage; - } - - public void reset() { - removeRunPage(); - } - - private void unregister() { - getVisualization().setIsRunning(false); - StaticListenerRegistry.unregisterListener(this); - if (animation != null) { - animation.unregister(); - } - } - - public IEditorPart getCurrentPage() { - return getActiveEditor(); - } - - public void addRunPageListener(IRunPageListener listener) { - this.runPageListener.add(listener); - } - - public void removeRunPageListener(IRunPageListener listener) { - this.runPageListener.remove(listener); - } - - public double getZoomFactor() { - switch (getActivePage()) { - case 0: - return editPage.getRootEditPart().getZoomManager().getZoom(); - case 1: - return runPage.getRootEditPart().getZoomManager().getZoom(); - default: - return 1; - } - } - - @Override - protected void setActivePage(int pageIndex) { - super.setActivePage(pageIndex); - // TODO: This is a hack for fixing the selection bug in the editor! - getSite().setSelectionProvider( - editPage.getSite().getSelectionProvider()); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.part.MultiPageEditorPart; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.mapper.MapperWrapper; + +import de.bmotionstudio.gef.editor.internal.BMSConverter512; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.core.ILifecycleListener; +import de.prob.logging.Logger; + +public class BMotionStudioEditor extends MultiPageEditorPart implements + ILifecycleListener { + + private BMotionStudioEditorPage editPage; + + private BMotionStudioRunPage runPage; + + private Visualization visualization; + + private Animation animation; + + private ArrayList<IRunPageListener> runPageListener = new ArrayList<IRunPageListener>(); + + @Override + protected void createPages() { + createEditPage(); + } + + private void createEditPage() { + editPage = new BMotionStudioEditorPage(getVisualization(), this); + try { + int index = addPage(editPage, getEditorInput()); + setPageText(index, "Edit"); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + public void createRunPage(Visualization visualization, Animation animation) { + StaticListenerRegistry.registerListener(this); + this.animation = animation; + + if (runPage != null) + runPage.dispose(); + + runPage = new BMotionStudioRunPage(visualization); + try { + int index = addPage(runPage, getEditorInput()); + setPageText(index, "Run"); + setActivePage(index); + fireRunPageCreatedListener(); + } catch (PartInitException e) { + } + } + + public void removeRunPage() { + fireRunPageRemovedListener(); + if (runPage != null) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + removePage(1); + } + }); + } + unregister(); + } + + private void fireRunPageCreatedListener() { + for (IRunPageListener listener : runPageListener) { + listener.runPageCreated(runPage); + } + } + + private void fireRunPageRemovedListener() { + for (IRunPageListener listener : runPageListener) { + listener.runPageRemoved(runPage); + } + } + + @Override + public void dispose() { + unregister(); + super.dispose(); + } + + public Visualization getVisualization() { + return visualization; + } + + public void setDirty(boolean dirty) { + editPage.setDirty(dirty); + } + + /** + * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) + **/ + @Override + public void init(IEditorSite iSite, IEditorInput iInput) + throws PartInitException { + + super.init(iSite, iInput); + + IFile file = ((IFileEditorInput) iInput).getFile(); + + try { + + // ------------------------------------------------------- + + DocumentBuilderFactory dbFactory = DocumentBuilderFactory + .newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(file.getContents()); + NodeList nList = doc.getElementsByTagName("version"); + if (nList.item(0) != null) { + Element versionElement = (Element) nList.item(0); + String version = versionElement.getTextContent(); + if (version.equals("5.1.2")) { + new BMSConverter512(file); + } + } else { + new BMSConverter512(file); + } + + // ------------------------------------------------------- + + InputStream inputStream = file.getContents(); + + XStream xstream = new XStream() { + @Override + protected MapperWrapper wrapMapper(final MapperWrapper next) { + return new MapperWrapper(next) { + @Override + public boolean shouldSerializeMember( + @SuppressWarnings("rawtypes") final Class definedIn, + final String fieldName) { + if (definedIn == Object.class) + return false; + return super.shouldSerializeMember(definedIn, + fieldName); + } + }; + } + }; + + BMotionEditorPlugin.setAliases(xstream); + + visualization = (Visualization) xstream.fromXML(inputStream); + visualization.setProjectFile(((IFileEditorInput) getEditorInput()) + .getFile()); + // initLanguage(visualization); + + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + + } + + @Override + public String getPartName() { + return visualization.getProjectFile().getName().replace(".bmso", "") + + " (" + getVisualization().getMachineName() + " - " + + getVisualization().getLanguage() + ")"; + } + + @Override + public void doSave(final IProgressMonitor monitor) { + editPage.doSave(monitor); + } + + @Override + public void doSaveAs() { + // Nothing to do here, this is never allowed + throw new IllegalAccessError("No way to enter this method."); + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + protected void pageChange(int newPageIndex) { + String newPageString = getPageText(newPageIndex); + if (newPageString.equals("Run")) { + switchPerspective("de.bmotionstudio.perspective.run"); + } else { + switchPerspective("de.bmotionstudio.perspective.edit"); + } + } + + private void switchPerspective(String id) { + IWorkbench workbench = PlatformUI.getWorkbench(); + try { + workbench.showPerspective(id, workbench.getActiveWorkbenchWindow()); + } catch (WorkbenchException e) { + Logger.notifyUser( + "An error occured while trying to switch the perspective.", + e); + } + } + + public BMotionStudioEditorPage getEditPage() { + return this.editPage; + } + + public BMotionStudioRunPage getRunPage() { + return this.runPage; + } + + public void reset() { + removeRunPage(); + } + + private void unregister() { + getVisualization().setIsRunning(false); + StaticListenerRegistry.unregisterListener(this); + if (animation != null) { + animation.unregister(); + } + } + + public IEditorPart getCurrentPage() { + return getActiveEditor(); + } + + public void addRunPageListener(IRunPageListener listener) { + this.runPageListener.add(listener); + } + + public void removeRunPageListener(IRunPageListener listener) { + this.runPageListener.remove(listener); + } + + public double getZoomFactor() { + switch (getActivePage()) { + case 0: + return editPage.getRootEditPart().getZoomManager().getZoom(); + case 1: + return runPage.getRootEditPart().getZoomManager().getZoom(); + default: + return 1; + } + } + + @Override + protected void setActivePage(int pageIndex) { + super.setActivePage(pageIndex); + // TODO: This is a hack for fixing the selection bug in the editor! + getSite().setSelectionProvider( + editPage.getSite().getSelectionProvider()); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java index 38ddeb19632431e6baa08b70600459407bf4ac7c..b61e548929e65188194f138a481ed2fc8dcb8a9e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java @@ -1,842 +1,837 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.LightweightSystem; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.KeyHandler; -import org.eclipse.gef.KeyStroke; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.MouseWheelHandler; -import org.eclipse.gef.MouseWheelZoomHandler; -import org.eclipse.gef.SnapToGeometry; -import org.eclipse.gef.SnapToGrid; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackListener; -import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; -import org.eclipse.gef.editparts.GridLayer; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.rulers.RulerProvider; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.gef.ui.actions.ToggleGridAction; -import org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction; -import org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction; -import org.eclipse.gef.ui.actions.ZoomInAction; -import org.eclipse.gef.ui.actions.ZoomOutAction; -import org.eclipse.gef.ui.palette.FlyoutPaletteComposite; -import org.eclipse.gef.ui.palette.PaletteViewer; -import org.eclipse.gef.ui.palette.PaletteViewerProvider; -import org.eclipse.gef.ui.parts.ContentOutlinePage; -import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; -import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.gef.ui.parts.SelectionSynchronizer; -import org.eclipse.gef.ui.parts.TreeViewer; -import org.eclipse.gef.ui.rulers.RulerComposite; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; - -import com.thoughtworks.xstream.XStream; - -import de.bmotionstudio.gef.editor.action.CopyAction; -import de.bmotionstudio.gef.editor.action.OpenObserverAction; -import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; -import de.bmotionstudio.gef.editor.action.PasteAction; -import de.bmotionstudio.gef.editor.internal.BControlTransferDropTargetListener; -import de.bmotionstudio.gef.editor.library.AttributeTransferDropTargetListener; -import de.bmotionstudio.gef.editor.model.BMotionRuler; -import de.bmotionstudio.gef.editor.model.BMotionRulerProvider; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; -import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; -import de.bmotionstudio.gef.editor.part.BMSTreeEditPartFactory; - -public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { - - public final static String ID = "de.bmotionstudio.gef.editor"; - - private boolean isDirty; - - private KeyHandler sharedKeyHandler; - - private Visualization visualization; - - private RulerComposite rulerComp; - - // private BControl editArea; - - private BMotionStudioEditor bmotionStudioEditor; - - private BMotionSelectionSynchronizer bmotionSelectionSynchronizer; - - private Color gridColor = new Color(null, 240, 240, 240); - - /** Palette component, holding the tools and b-controls. */ - private PaletteRoot palette; - - private PropertyChangeListener viewerListener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent event) { - String propertyName = event.getPropertyName(); - if (propertyName.equals(SnapToGrid.PROPERTY_GRID_VISIBLE) - || propertyName.equals(SnapToGrid.PROPERTY_GRID_ENABLED)) { - setDirty(true); - } - } - - }; - - public BMotionStudioEditorPage(Visualization visualization, - BMotionStudioEditor bmotionStudioEditor) { - this.visualization = visualization; - this.bmotionStudioEditor = bmotionStudioEditor; - setEditDomain(new DefaultEditDomain(this)); - } - - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - - // If not the active editor, ignore selection changed. - if (!getBMotionStudioEditor().equals( - getSite().getPage().getActiveEditor())) - return; - - Object selectedElement = ((IStructuredSelection) selection) - .getFirstElement(); - if (selectedElement instanceof BMSAbstractEditPart - || selectedElement instanceof BMSAbstractTreeEditPart) - updateActions(getSelectionActions()); - - } - - /** - * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) - **/ - public void init(IEditorSite iSite, IEditorInput iInput) - throws PartInitException { - super.init(iSite, iInput); - setSite(iSite); - // add CommandStackListener - getCommandStack().addCommandStackListener(getCommandStackListener()); - } - - /** - * @see org.eclipse.gef.ui.parts.GraphicalEditor#initializeGraphicalViewer() - **/ - protected void initializeGraphicalViewer() { - - super.initializeGraphicalViewer(); - - getGraphicalViewer().setContents(getVisualization()); - - getGraphicalViewer().addDropTargetListener( - new BControlTransferDropTargetListener(getGraphicalViewer(), - visualization)); - getGraphicalViewer().addDropTargetListener( - new AttributeTransferDropTargetListener(getGraphicalViewer(), - getSite().getPart())); - - getPalettePreferences().setPaletteState( - FlyoutPaletteComposite.STATE_PINNED_OPEN); - - } - - @Override - protected PaletteViewerProvider createPaletteViewerProvider() { - return new PaletteViewerProvider(getEditDomain()) { - protected void configurePaletteViewer(PaletteViewer viewer) { - super.configurePaletteViewer(viewer); - viewer.addDragSourceListener(new TemplateTransferDragSourceListener( - viewer)); - } - - protected void hookPaletteViewer(PaletteViewer viewer) { - super.hookPaletteViewer(viewer); - } - }; - } - - /** - * @see org.eclipse.ui.IEditorPart#isSaveAsAllowed() - **/ - public boolean isSaveAsAllowed() { - return true; - } - - /** - * Creates an appropriate output stream and writes the activity diagram out - * to this stream. - * - * @param os - * the base output stream - * @throws IOException - */ - protected void createOutputStream(OutputStream os) throws IOException { - OutputStreamWriter writer = new OutputStreamWriter(os, "UTF8"); - XStream xstream = new XStream(); - BMotionEditorPlugin.setAliases(xstream); - xstream.toXML(visualization, writer); - } - - /** - * @see org.eclipse.ui.IEditorPart#doSave(IProgressMonitor) - **/ - public void doSave(IProgressMonitor iMonitor) { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - try { - saveProperties(); - createOutputStream(out); - IFile file = ((IFileEditorInput) getEditorInput()).getFile(); - file.setContents(new ByteArrayInputStream(out.toByteArray()), true, - false, iMonitor); - getCommandStack().markSaveLocation(); - } catch (CoreException ce) { - ce.printStackTrace(); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - // remove CommandStackListener - getCommandStack().removeCommandStackListener(getCommandStackListener()); - - // remove PropertyChangeListener from graphical viewer - getGraphicalViewer().removePropertyChangeListener(viewerListener); - - // important: always call super implementation of dispose - super.dispose(); - } - - /** - * @see org.eclipse.ui.IEditorPart#doSaveAs() - **/ - public void doSaveAs() { - // Nothing to do here, this is never allowed - throw new IllegalAccessError("No way to enter this method."); - } - - @Override - public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { - if (type == ZoomManager.class) - return ((ScalableRootEditPart) getGraphicalViewer() - .getRootEditPart()).getZoomManager(); - if (type == IContentOutlinePage.class) - return new BMotionOutlinePage(); - if (type == IPropertySheetPage.class) { - BMotionStudioPropertySheet page = new BMotionStudioPropertySheet(); - page.setRootEntry(new CustomSortPropertySheetEntry( - getCommandStack())); - return page; - } - return super.getAdapter(type); - } - - /** - * @see org.eclipse.ui.IEditorPart#gotoMarker(IMarker) - **/ - public void gotoMarker(IMarker iMarker) { - } - - /** - * Returns the KeyHandler with common bindings for both the Outline and - * Graphical Views. For example, delete is a common action. - */ - protected KeyHandler getCommonKeyHandler() { - if (sharedKeyHandler == null) { - sharedKeyHandler = new KeyHandler(); - sharedKeyHandler.put( - KeyStroke.getPressed(SWT.F2, 0), - getActionRegistry().getAction( - GEFActionConstants.DIRECT_EDIT)); - sharedKeyHandler - .put(KeyStroke.getPressed(SWT.DEL, 127, 0), - getActionRegistry().getAction( - ActionFactory.DELETE.getId())); - - sharedKeyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), - getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); - - sharedKeyHandler.put( - KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), - getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); - - sharedKeyHandler.put( - KeyStroke.getPressed(SWT.F2, 0), - getActionRegistry().getAction( - GEFActionConstants.DIRECT_EDIT)); - } - return sharedKeyHandler; - } - - public void setDirty(boolean dirty) { - if (isDirty() != dirty) { - isDirty = dirty; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - } - - /* - * @see EditorPart#isDirty - */ - @Override - public boolean isDirty() { - return isDirty; - } - - @SuppressWarnings("unchecked") - public void createActions() { - - super.createActions(); - - ActionRegistry registry = getActionRegistry(); - - installCustomActions(); - - IAction action = new CopyAction(this); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new PasteAction(this); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - installObserverActions(); - installSchedulerActions(); - - } - - @SuppressWarnings("unchecked") - private void installObserverActions() { - - IAction action; - ActionRegistry registry = getActionRegistry(); - - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = reg - .getExtensionPoint("de.bmotionstudio.gef.editor.observer"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("observer".equals(configurationElement.getName())) { - - String observerClassName = configurationElement - .getAttribute("class"); - - action = new OpenObserverAction(this); - action.setId("de.bmotionstudio.gef.editor.observerAction." - + observerClassName); - ((OpenObserverAction) action).setClassName(observerClassName); - registry.registerAction(action); - getSelectionActions().add( - "de.bmotionstudio.gef.editor.observerAction." - + observerClassName); - - } - - } - - } - - } - - @SuppressWarnings("unchecked") - private void installSchedulerActions() { - - IAction action; - ActionRegistry registry = getActionRegistry(); - - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = reg - .getExtensionPoint("de.bmotionstudio.gef.editor.schedulerEvent"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("schedulerEvent".equals(configurationElement.getName())) { - - String sClassName = configurationElement - .getAttribute("class"); - - action = new OpenSchedulerEventAction(this); - action.setId("de.bmotionstudio.gef.editor.SchedulerEventAction." - + sClassName); - ((OpenSchedulerEventAction) action).setClassName(sClassName); - registry.registerAction(action); - getSelectionActions().add( - "de.bmotionstudio.gef.editor.SchedulerEventAction." - + sClassName); - - } - - } - - } - - } - - @SuppressWarnings("unchecked") - private void installCustomActions() { - - ActionRegistry registry = getActionRegistry(); - - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = reg - .getExtensionPoint("de.bmotionstudio.gef.editor.installActions"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("action".equals(configurationElement.getName())) { - - try { - - IInstallActions installActionsClass = (IInstallActions) configurationElement - .createExecutableExtension("class"); - - installActionsClass.installActions(this); - HashMap<String, Action> actionMap = installActionsClass - .getActionMap(); - - for (Map.Entry<String, Action> entry : actionMap - .entrySet()) { - - registry.registerAction(entry.getValue()); - if (entry.getValue() instanceof SelectionAction) - getSelectionActions().add(entry.getKey()); - - } - - } catch (final CoreException e) { - e.printStackTrace(); - } - - } - - } - - } - - } - - protected Control getGraphicalControl() { - return rulerComp; - } - - protected void createGraphicalViewer(Composite parent) { - rulerComp = new RulerComposite(parent, SWT.NONE); - super.createGraphicalViewer(rulerComp); - rulerComp - .setGraphicalViewer((ScrollingGraphicalViewer) getGraphicalViewer()); - } - - /** - * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() - **/ - protected void configureGraphicalViewer() { - - double[] zoomLevels; - - super.configureGraphicalViewer(); - ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); - - viewer.setEditPartFactory(new BMSEditPartFactory()); - - ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); - GridLayer gridLayer = (GridLayer) rootEditPart - .getLayer(ScalableRootEditPart.GRID_LAYER); - gridLayer.setForegroundColor(gridColor); - viewer.setRootEditPart(rootEditPart); - - ZoomManager manager = rootEditPart.getZoomManager(); - getActionRegistry().registerAction(new ZoomInAction(manager)); - getActionRegistry().registerAction(new ZoomOutAction(manager)); - - zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, - 4.0, 5.0, 10.0, 20.0 }; - manager.setZoomLevels(zoomLevels); - ArrayList<String> zoomContributions = new ArrayList<String>(); - zoomContributions.add(ZoomManager.FIT_ALL); - zoomContributions.add(ZoomManager.FIT_HEIGHT); - zoomContributions.add(ZoomManager.FIT_WIDTH); - manager.setZoomLevelContributions(zoomContributions); - - viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), - MouseWheelZoomHandler.SINGLETON); - - // viewer.setKeyHandler(keyHandler); - - viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer) - .setParent(getCommonKeyHandler())); - - loadProperties(); - - getActionRegistry().registerAction( - new ToggleRulerVisibilityAction(getGraphicalViewer())); - getActionRegistry().registerAction( - new ToggleSnapToGeometryAction(getGraphicalViewer())); - getActionRegistry().registerAction( - new ToggleGridAction(getGraphicalViewer())); - - ContextMenuProvider provider = new BMSContextMenuProvider(viewer, - getActionRegistry()); - viewer.setContextMenu(provider); - - viewer.addPropertyChangeListener(viewerListener); - - } - - protected void loadProperties() { - - // Ruler properties - BMotionRuler ruler = getVisualization() - .getRuler(PositionConstants.WEST); - RulerProvider provider = null; - if (ruler != null) { - provider = new BMotionRulerProvider(ruler); - } - getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, - provider); - ruler = getVisualization().getRuler(PositionConstants.NORTH); - provider = null; - if (ruler != null) { - provider = new BMotionRulerProvider(ruler); - } - getGraphicalViewer().setProperty( - RulerProvider.PROPERTY_HORIZONTAL_RULER, provider); - getGraphicalViewer().setProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY, - getVisualization().getRulerVisibility()); - getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, - getVisualization().isSnapToGeometryEnabled()); - getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, - getVisualization().isGridEnabled()); - getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, - getVisualization().isGridEnabled()); - - getPalettePreferences().setPaletteState( - FlyoutPaletteComposite.STATE_PINNED_OPEN); - - } - - protected void saveProperties() { - getVisualization().setRulerVisibility( - ((Boolean) getGraphicalViewer().getProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY)) - .booleanValue()); - getVisualization().setGridEnabled( - ((Boolean) getGraphicalViewer().getProperty( - SnapToGrid.PROPERTY_GRID_ENABLED)).booleanValue()); - getVisualization().setSnapToGeometry( - ((Boolean) getGraphicalViewer().getProperty( - SnapToGeometry.PROPERTY_SNAP_ENABLED)).booleanValue()); - } - - /** - * The <code>CommandStackListener</code> that listens for - * <code>CommandStack </code>changes. - */ - private CommandStackListener commandStackListener = new CommandStackListener() { - public void commandStackChanged(EventObject event) { - setDirty(getCommandStack().isDirty()); - } - }; - - /** - * Returns the <code>CommandStack</code> of this editor's - * <code>EditDomain</code>. - * - * @return the <code>CommandStack</code> - */ - @Override - public CommandStack getCommandStack() { - return getEditDomain().getCommandStack(); - } - - /** - * Returns the <code>CommandStackListener</code>. - * - * @return the <code>CommandStackListener</code> - */ - protected CommandStackListener getCommandStackListener() { - return commandStackListener; - } - - /** - * Returns the palette root. - */ - protected PaletteRoot getPaletteRoot() { - if (palette == null) { - palette = new EditorPaletteFactory().createPalette(visualization); - } - return palette; - } - - protected FigureCanvas getEditor() { - return (FigureCanvas) getGraphicalViewer().getControl(); - } - - @Override - public SelectionSynchronizer getSelectionSynchronizer() { - if (bmotionSelectionSynchronizer == null) - bmotionSelectionSynchronizer = new BMotionSelectionSynchronizer(); - return bmotionSelectionSynchronizer; - } - - protected class BMotionOutlinePage extends ContentOutlinePage { - - private SashForm sash; - - private ScrollableThumbnail thumbnail; - private DisposeListener disposeListener; - - public BMotionOutlinePage() { - super(new TreeViewer()); - } - - public void init(IPageSite pageSite) { - super.init(pageSite); - IActionBars bars = pageSite.getActionBars(); - ActionRegistry ar = getActionRegistry(); - bars.setGlobalActionHandler(ActionFactory.UNDO.getId(), - ar.getAction(ActionFactory.UNDO.getId())); - bars.setGlobalActionHandler(ActionFactory.REDO.getId(), - ar.getAction(ActionFactory.REDO.getId())); - bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), - ar.getAction(ActionFactory.DELETE.getId())); - bars.setGlobalActionHandler(ActionFactory.COPY.getId(), - ar.getAction(ActionFactory.COPY.getId())); - bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), - ar.getAction(ActionFactory.PASTE.getId())); - buildCustomActions(bars, ar); - bars.updateActionBars(); - } - - protected void configureOutlineViewer() { - getViewer().setEditDomain(getEditDomain()); - getViewer().setEditPartFactory(new BMSTreeEditPartFactory()); - ContextMenuProvider provider = new BMSContextMenuProvider( - getViewer(), getActionRegistry()); - getViewer().setContextMenu(provider); - getViewer().setKeyHandler(getCommonKeyHandler()); - } - - protected void initializeOutlineViewer() { - setContents(getVisualization()); - } - - public void setContents(Object contents) { - getViewer().setContents(contents); - } - - protected void hookOutlineViewer() { - getSelectionSynchronizer().addViewer(getViewer()); - } - - protected void unhookOutlineViewer() { - getSelectionSynchronizer().removeViewer(getViewer()); - if (getGraphicalViewer().getControl() != null - && !getGraphicalViewer().getControl().isDisposed()) - getGraphicalViewer().getControl().removeDisposeListener( - disposeListener); - } - - @Override - public void createControl(Composite parent) { - initializeOverview(parent); - getGraphicalViewer().getControl().addDisposeListener( - disposeListener); - configureOutlineViewer(); - hookOutlineViewer(); - initializeOutlineViewer(); - createMenu(); - } - - /** - * - */ - private void createMenu() { - - Action expandAllAction = new Action("Expand All") { - - @Override - public void run() { - for (TreeItem item : ((Tree) getViewer().getControl()) - .getItems()) { - item.setExpanded(true); - } - } - - }; - - Action collapseAllAction = new Action("Collapse All") { - - @Override - public void run() { - for (TreeItem item : ((Tree) getViewer().getControl()) - .getItems()) { - item.setExpanded(false); - } - } - - }; - - getSite().getActionBars().getMenuManager().add(expandAllAction); - getSite().getActionBars().getMenuManager().add(collapseAllAction); - - } - - protected void initializeOverview(Composite parent) { - sash = new SashForm(parent, SWT.VERTICAL); - - getViewer().createControl(sash); - - Canvas canvas = new Canvas(sash, SWT.BORDER); - canvas.setBackground(Display.getDefault().getSystemColor( - SWT.COLOR_WHITE)); - LightweightSystem lws = new LightweightSystem(canvas); - - thumbnail = new ScrollableThumbnail( - (Viewport) ((ScalableRootEditPart) getGraphicalViewer() - .getRootEditPart()).getFigure()); - thumbnail.setSource(((ScalableRootEditPart) getGraphicalViewer() - .getRootEditPart()) - .getLayer(LayerConstants.PRINTABLE_LAYERS)); - - lws.setContents(thumbnail); - - disposeListener = new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (thumbnail != null) { - thumbnail.deactivate(); - thumbnail = null; - } - } - }; - } - - public Control getControl() { - return sash; - } - - public void dispose() { - unhookOutlineViewer(); - gridColor.dispose(); - super.dispose(); - } - - } - - private void buildCustomActions(IActionBars bars, ActionRegistry ar) { - - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = reg - .getExtensionPoint("de.bmotionstudio.gef.editor.installMenu"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("menu".equals(configurationElement.getName())) { - - try { - - IInstallMenu installMenuClass = (IInstallMenu) configurationElement - .createExecutableExtension("class"); - - installMenuClass.installBar(bars, getActionRegistry()); - - } catch (final CoreException e) { - e.printStackTrace(); - } - - } - - } - - } - - } - - public Visualization getVisualization() { - return visualization; - } - - public void setBMotionStudioEditor(BMotionStudioEditor bmotionStudioEditor) { - this.bmotionStudioEditor = bmotionStudioEditor; - } - - public BMotionStudioEditor getBMotionStudioEditor() { - return bmotionStudioEditor; - } - - public ScalableRootEditPart getRootEditPart() { - return (ScalableRootEditPart) getGraphicalViewer().getRootEditPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.draw2d.FigureCanvas; +import org.eclipse.draw2d.LightweightSystem; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.Viewport; +import org.eclipse.draw2d.parts.ScrollableThumbnail; +import org.eclipse.gef.ContextMenuProvider; +import org.eclipse.gef.DefaultEditDomain; +import org.eclipse.gef.KeyHandler; +import org.eclipse.gef.KeyStroke; +import org.eclipse.gef.LayerConstants; +import org.eclipse.gef.MouseWheelHandler; +import org.eclipse.gef.MouseWheelZoomHandler; +import org.eclipse.gef.SnapToGeometry; +import org.eclipse.gef.SnapToGrid; +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gef.commands.CommandStackListener; +import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; +import org.eclipse.gef.editparts.GridLayer; +import org.eclipse.gef.editparts.ScalableRootEditPart; +import org.eclipse.gef.editparts.ZoomManager; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.gef.ui.actions.ToggleGridAction; +import org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction; +import org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction; +import org.eclipse.gef.ui.actions.ZoomInAction; +import org.eclipse.gef.ui.actions.ZoomOutAction; +import org.eclipse.gef.ui.palette.FlyoutPaletteComposite; +import org.eclipse.gef.ui.palette.PaletteViewer; +import org.eclipse.gef.ui.palette.PaletteViewerProvider; +import org.eclipse.gef.ui.parts.ContentOutlinePage; +import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; +import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; +import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; +import org.eclipse.gef.ui.parts.SelectionSynchronizer; +import org.eclipse.gef.ui.parts.TreeViewer; +import org.eclipse.gef.ui.rulers.RulerComposite; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.part.IPageSite; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.ui.views.properties.IPropertySheetPage; + +import com.thoughtworks.xstream.XStream; + +import de.bmotionstudio.gef.editor.action.CopyAction; +import de.bmotionstudio.gef.editor.action.OpenObserverAction; +import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; +import de.bmotionstudio.gef.editor.action.PasteAction; +import de.bmotionstudio.gef.editor.internal.BControlTransferDropTargetListener; +import de.bmotionstudio.gef.editor.library.AttributeTransferDropTargetListener; +import de.bmotionstudio.gef.editor.model.BMotionRuler; +import de.bmotionstudio.gef.editor.model.BMotionRulerProvider; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; +import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; +import de.bmotionstudio.gef.editor.part.BMSTreeEditPartFactory; + +public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { + + public final static String ID = "de.bmotionstudio.gef.editor"; + + private boolean isDirty; + + private KeyHandler sharedKeyHandler; + + private Visualization visualization; + + private RulerComposite rulerComp; + + // private BControl editArea; + + private BMotionStudioEditor bmotionStudioEditor; + + private BMotionSelectionSynchronizer bmotionSelectionSynchronizer; + + private Color gridColor = new Color(null, 240, 240, 240); + + /** Palette component, holding the tools and b-controls. */ + private PaletteRoot palette; + + private PropertyChangeListener viewerListener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + String propertyName = event.getPropertyName(); + if (propertyName.equals(SnapToGrid.PROPERTY_GRID_VISIBLE) + || propertyName.equals(SnapToGrid.PROPERTY_GRID_ENABLED)) { + setDirty(true); + } + } + + }; + + public BMotionStudioEditorPage(Visualization visualization, + BMotionStudioEditor bmotionStudioEditor) { + this.visualization = visualization; + this.bmotionStudioEditor = bmotionStudioEditor; + setEditDomain(new DefaultEditDomain(this)); + } + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + + // If not the active editor, ignore selection changed. + if (!getBMotionStudioEditor().equals( + getSite().getPage().getActiveEditor())) + return; + + Object selectedElement = ((IStructuredSelection) selection) + .getFirstElement(); + if (selectedElement instanceof BMSAbstractEditPart + || selectedElement instanceof BMSAbstractTreeEditPart) + updateActions(getSelectionActions()); + + } + + /** + * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) + **/ + public void init(IEditorSite iSite, IEditorInput iInput) + throws PartInitException { + super.init(iSite, iInput); + setSite(iSite); + // add CommandStackListener + getCommandStack().addCommandStackListener(getCommandStackListener()); + } + + /** + * @see org.eclipse.gef.ui.parts.GraphicalEditor#initializeGraphicalViewer() + **/ + protected void initializeGraphicalViewer() { + + super.initializeGraphicalViewer(); + + getGraphicalViewer().setContents(getVisualization()); + + getGraphicalViewer().addDropTargetListener( + new BControlTransferDropTargetListener(getGraphicalViewer(), + visualization)); + getGraphicalViewer().addDropTargetListener( + new AttributeTransferDropTargetListener(getGraphicalViewer(), + getSite().getPart())); + + getPalettePreferences().setPaletteState( + FlyoutPaletteComposite.STATE_PINNED_OPEN); + + } + + @Override + protected PaletteViewerProvider createPaletteViewerProvider() { + return new PaletteViewerProvider(getEditDomain()) { + protected void configurePaletteViewer(PaletteViewer viewer) { + super.configurePaletteViewer(viewer); + viewer.addDragSourceListener(new TemplateTransferDragSourceListener( + viewer)); + } + + protected void hookPaletteViewer(PaletteViewer viewer) { + super.hookPaletteViewer(viewer); + } + }; + } + + /** + * @see org.eclipse.ui.IEditorPart#isSaveAsAllowed() + **/ + public boolean isSaveAsAllowed() { + return true; + } + + /** + * Creates an appropriate output stream and writes the activity diagram out + * to this stream. + * + * @param os + * the base output stream + * @throws IOException + */ + protected void createOutputStream(OutputStream os) throws IOException { + OutputStreamWriter writer = new OutputStreamWriter(os, "UTF8"); + XStream xstream = new XStream(); + BMotionEditorPlugin.setAliases(xstream); + xstream.toXML(visualization, writer); + } + + /** + * @see org.eclipse.ui.IEditorPart#doSave(IProgressMonitor) + **/ + public void doSave(IProgressMonitor iMonitor) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + saveProperties(); + createOutputStream(out); + IFile file = ((IFileEditorInput) getEditorInput()).getFile(); + file.setContents(new ByteArrayInputStream(out.toByteArray()), true, + false, iMonitor); + getCommandStack().markSaveLocation(); + } catch (CoreException ce) { + ce.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + + public void dispose() { + // remove CommandStackListener + getCommandStack().removeCommandStackListener(getCommandStackListener()); + + // remove PropertyChangeListener from graphical viewer + getGraphicalViewer().removePropertyChangeListener(viewerListener); + + // important: always call super implementation of dispose + super.dispose(); + } + + /** + * @see org.eclipse.ui.IEditorPart#doSaveAs() + **/ + public void doSaveAs() { + // Nothing to do here, this is never allowed + throw new IllegalAccessError("No way to enter this method."); + } + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { + if (type == ZoomManager.class) + return ((ScalableRootEditPart) getGraphicalViewer() + .getRootEditPart()).getZoomManager(); + if (type == IContentOutlinePage.class) + return new BMotionOutlinePage(); + if (type == IPropertySheetPage.class) { + BMotionStudioPropertySheet page = new BMotionStudioPropertySheet(); + page.setRootEntry(new CustomSortPropertySheetEntry( + getCommandStack())); + return page; + } + return super.getAdapter(type); + } + + /** + * @see org.eclipse.ui.IEditorPart#gotoMarker(IMarker) + **/ + public void gotoMarker(IMarker iMarker) { + } + + /** + * Returns the KeyHandler with common bindings for both the Outline and + * Graphical Views. For example, delete is a common action. + */ + protected KeyHandler getCommonKeyHandler() { + if (sharedKeyHandler == null) { + sharedKeyHandler = new KeyHandler(); + sharedKeyHandler.put( + KeyStroke.getPressed(SWT.F2, 0), + getActionRegistry().getAction( + GEFActionConstants.DIRECT_EDIT)); + sharedKeyHandler + .put(KeyStroke.getPressed(SWT.DEL, 127, 0), + getActionRegistry().getAction( + ActionFactory.DELETE.getId())); + + sharedKeyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), + getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); + + sharedKeyHandler.put( + KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), + getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); + + sharedKeyHandler.put( + KeyStroke.getPressed(SWT.F2, 0), + getActionRegistry().getAction( + GEFActionConstants.DIRECT_EDIT)); + } + return sharedKeyHandler; + } + + public void setDirty(boolean dirty) { + if (isDirty() != dirty) { + isDirty = dirty; + firePropertyChange(IEditorPart.PROP_DIRTY); + } + } + + /* + * @see EditorPart#isDirty + */ + @Override + public boolean isDirty() { + return isDirty; + } + + @SuppressWarnings("unchecked") + public void createActions() { + + super.createActions(); + + ActionRegistry registry = getActionRegistry(); + + installCustomActions(); + + IAction action = new CopyAction(this); + registry.registerAction(action); + getSelectionActions().add(action.getId()); + + action = new PasteAction(this); + registry.registerAction(action); + getSelectionActions().add(action.getId()); + + installObserverActions(); + installSchedulerActions(); + + } + + @SuppressWarnings("unchecked") + private void installObserverActions() { + + IAction action; + ActionRegistry registry = getActionRegistry(); + + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = reg + .getExtensionPoint("de.bmotionstudio.gef.editor.observer"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("observer".equals(configurationElement.getName())) { + + String observerClassName = configurationElement + .getAttribute("class"); + + action = new OpenObserverAction(this); + action.setId("de.bmotionstudio.gef.editor.observerAction." + + observerClassName); + ((OpenObserverAction) action).setClassName(observerClassName); + registry.registerAction(action); + getSelectionActions().add( + "de.bmotionstudio.gef.editor.observerAction." + + observerClassName); + + } + + } + + } + + } + + @SuppressWarnings("unchecked") + private void installSchedulerActions() { + + IAction action; + ActionRegistry registry = getActionRegistry(); + + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = reg + .getExtensionPoint("de.bmotionstudio.gef.editor.schedulerEvent"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("schedulerEvent".equals(configurationElement.getName())) { + + String sClassName = configurationElement + .getAttribute("class"); + + action = new OpenSchedulerEventAction(this); + action.setId("de.bmotionstudio.gef.editor.SchedulerEventAction." + + sClassName); + ((OpenSchedulerEventAction) action).setClassName(sClassName); + registry.registerAction(action); + getSelectionActions().add( + "de.bmotionstudio.gef.editor.SchedulerEventAction." + + sClassName); + + } + + } + + } + + } + + @SuppressWarnings("unchecked") + private void installCustomActions() { + + ActionRegistry registry = getActionRegistry(); + + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = reg + .getExtensionPoint("de.bmotionstudio.gef.editor.installActions"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("action".equals(configurationElement.getName())) { + + try { + + IInstallActions installActionsClass = (IInstallActions) configurationElement + .createExecutableExtension("class"); + + installActionsClass.installActions(this); + HashMap<String, Action> actionMap = installActionsClass + .getActionMap(); + + for (Map.Entry<String, Action> entry : actionMap + .entrySet()) { + + registry.registerAction(entry.getValue()); + if (entry.getValue() instanceof SelectionAction) + getSelectionActions().add(entry.getKey()); + + } + + } catch (final CoreException e) { + e.printStackTrace(); + } + + } + + } + + } + + } + + protected Control getGraphicalControl() { + return rulerComp; + } + + protected void createGraphicalViewer(Composite parent) { + rulerComp = new RulerComposite(parent, SWT.NONE); + super.createGraphicalViewer(rulerComp); + rulerComp + .setGraphicalViewer((ScrollingGraphicalViewer) getGraphicalViewer()); + } + + /** + * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() + **/ + protected void configureGraphicalViewer() { + + double[] zoomLevels; + + super.configureGraphicalViewer(); + ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); + + viewer.setEditPartFactory(new BMSEditPartFactory()); + + ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); + GridLayer gridLayer = (GridLayer) rootEditPart + .getLayer(ScalableRootEditPart.GRID_LAYER); + gridLayer.setForegroundColor(gridColor); + viewer.setRootEditPart(rootEditPart); + + ZoomManager manager = rootEditPart.getZoomManager(); + getActionRegistry().registerAction(new ZoomInAction(manager)); + getActionRegistry().registerAction(new ZoomOutAction(manager)); + + zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, + 4.0, 5.0, 10.0, 20.0 }; + manager.setZoomLevels(zoomLevels); + ArrayList<String> zoomContributions = new ArrayList<String>(); + zoomContributions.add(ZoomManager.FIT_ALL); + zoomContributions.add(ZoomManager.FIT_HEIGHT); + zoomContributions.add(ZoomManager.FIT_WIDTH); + manager.setZoomLevelContributions(zoomContributions); + + viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), + MouseWheelZoomHandler.SINGLETON); + + // viewer.setKeyHandler(keyHandler); + + viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer) + .setParent(getCommonKeyHandler())); + + loadProperties(); + + getActionRegistry().registerAction( + new ToggleRulerVisibilityAction(getGraphicalViewer())); + getActionRegistry().registerAction( + new ToggleSnapToGeometryAction(getGraphicalViewer())); + getActionRegistry().registerAction( + new ToggleGridAction(getGraphicalViewer())); + + ContextMenuProvider provider = new BMSContextMenuProvider(viewer, + getActionRegistry()); + viewer.setContextMenu(provider); + + viewer.addPropertyChangeListener(viewerListener); + + } + + protected void loadProperties() { + + // Ruler properties + BMotionRuler ruler = getVisualization() + .getRuler(PositionConstants.WEST); + RulerProvider provider = null; + if (ruler != null) { + provider = new BMotionRulerProvider(ruler); + } + getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, + provider); + ruler = getVisualization().getRuler(PositionConstants.NORTH); + provider = null; + if (ruler != null) { + provider = new BMotionRulerProvider(ruler); + } + getGraphicalViewer().setProperty( + RulerProvider.PROPERTY_HORIZONTAL_RULER, provider); + getGraphicalViewer().setProperty( + RulerProvider.PROPERTY_RULER_VISIBILITY, + getVisualization().getRulerVisibility()); + getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, + getVisualization().isSnapToGeometryEnabled()); + getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, + getVisualization().isGridEnabled()); + getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, + getVisualization().isGridEnabled()); + + getPalettePreferences().setPaletteState( + FlyoutPaletteComposite.STATE_PINNED_OPEN); + + } + + protected void saveProperties() { + getVisualization().setRulerVisibility( + ((Boolean) getGraphicalViewer().getProperty( + RulerProvider.PROPERTY_RULER_VISIBILITY)) + .booleanValue()); + getVisualization().setGridEnabled( + ((Boolean) getGraphicalViewer().getProperty( + SnapToGrid.PROPERTY_GRID_ENABLED)).booleanValue()); + getVisualization().setSnapToGeometry( + ((Boolean) getGraphicalViewer().getProperty( + SnapToGeometry.PROPERTY_SNAP_ENABLED)).booleanValue()); + } + + /** + * The <code>CommandStackListener</code> that listens for + * <code>CommandStack </code>changes. + */ + private CommandStackListener commandStackListener = new CommandStackListener() { + public void commandStackChanged(EventObject event) { + setDirty(getCommandStack().isDirty()); + } + }; + + /** + * Returns the <code>CommandStack</code> of this editor's + * <code>EditDomain</code>. + * + * @return the <code>CommandStack</code> + */ + @Override + public CommandStack getCommandStack() { + return getEditDomain().getCommandStack(); + } + + /** + * Returns the <code>CommandStackListener</code>. + * + * @return the <code>CommandStackListener</code> + */ + protected CommandStackListener getCommandStackListener() { + return commandStackListener; + } + + /** + * Returns the palette root. + */ + protected PaletteRoot getPaletteRoot() { + if (palette == null) { + palette = new EditorPaletteFactory().createPalette(visualization); + } + return palette; + } + + protected FigureCanvas getEditor() { + return (FigureCanvas) getGraphicalViewer().getControl(); + } + + @Override + public SelectionSynchronizer getSelectionSynchronizer() { + if (bmotionSelectionSynchronizer == null) + bmotionSelectionSynchronizer = new BMotionSelectionSynchronizer(); + return bmotionSelectionSynchronizer; + } + + protected class BMotionOutlinePage extends ContentOutlinePage { + + private SashForm sash; + + private ScrollableThumbnail thumbnail; + private DisposeListener disposeListener; + + public BMotionOutlinePage() { + super(new TreeViewer()); + } + + public void init(IPageSite pageSite) { + super.init(pageSite); + IActionBars bars = pageSite.getActionBars(); + ActionRegistry ar = getActionRegistry(); + bars.setGlobalActionHandler(ActionFactory.UNDO.getId(), + ar.getAction(ActionFactory.UNDO.getId())); + bars.setGlobalActionHandler(ActionFactory.REDO.getId(), + ar.getAction(ActionFactory.REDO.getId())); + bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), + ar.getAction(ActionFactory.DELETE.getId())); + bars.setGlobalActionHandler(ActionFactory.COPY.getId(), + ar.getAction(ActionFactory.COPY.getId())); + bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), + ar.getAction(ActionFactory.PASTE.getId())); + buildCustomActions(bars, ar); + bars.updateActionBars(); + } + + protected void configureOutlineViewer() { + getViewer().setEditDomain(getEditDomain()); + getViewer().setEditPartFactory(new BMSTreeEditPartFactory()); + ContextMenuProvider provider = new BMSContextMenuProvider( + getViewer(), getActionRegistry()); + getViewer().setContextMenu(provider); + getViewer().setKeyHandler(getCommonKeyHandler()); + } + + protected void initializeOutlineViewer() { + setContents(getVisualization()); + } + + public void setContents(Object contents) { + getViewer().setContents(contents); + } + + protected void hookOutlineViewer() { + getSelectionSynchronizer().addViewer(getViewer()); + } + + protected void unhookOutlineViewer() { + getSelectionSynchronizer().removeViewer(getViewer()); + if (getGraphicalViewer().getControl() != null + && !getGraphicalViewer().getControl().isDisposed()) + getGraphicalViewer().getControl().removeDisposeListener( + disposeListener); + } + + @Override + public void createControl(Composite parent) { + initializeOverview(parent); + getGraphicalViewer().getControl().addDisposeListener( + disposeListener); + configureOutlineViewer(); + hookOutlineViewer(); + initializeOutlineViewer(); + createMenu(); + } + + /** + * + */ + private void createMenu() { + + Action expandAllAction = new Action("Expand All") { + + @Override + public void run() { + for (TreeItem item : ((Tree) getViewer().getControl()) + .getItems()) { + item.setExpanded(true); + } + } + + }; + + Action collapseAllAction = new Action("Collapse All") { + + @Override + public void run() { + for (TreeItem item : ((Tree) getViewer().getControl()) + .getItems()) { + item.setExpanded(false); + } + } + + }; + + getSite().getActionBars().getMenuManager().add(expandAllAction); + getSite().getActionBars().getMenuManager().add(collapseAllAction); + + } + + protected void initializeOverview(Composite parent) { + sash = new SashForm(parent, SWT.VERTICAL); + + getViewer().createControl(sash); + + Canvas canvas = new Canvas(sash, SWT.BORDER); + canvas.setBackground(Display.getDefault().getSystemColor( + SWT.COLOR_WHITE)); + LightweightSystem lws = new LightweightSystem(canvas); + + thumbnail = new ScrollableThumbnail( + (Viewport) ((ScalableRootEditPart) getGraphicalViewer() + .getRootEditPart()).getFigure()); + thumbnail.setSource(((ScalableRootEditPart) getGraphicalViewer() + .getRootEditPart()) + .getLayer(LayerConstants.PRINTABLE_LAYERS)); + + lws.setContents(thumbnail); + + disposeListener = new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + if (thumbnail != null) { + thumbnail.deactivate(); + thumbnail = null; + } + } + }; + } + + public Control getControl() { + return sash; + } + + public void dispose() { + unhookOutlineViewer(); + gridColor.dispose(); + super.dispose(); + } + + } + + private void buildCustomActions(IActionBars bars, ActionRegistry ar) { + + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = reg + .getExtensionPoint("de.bmotionstudio.gef.editor.installMenu"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("menu".equals(configurationElement.getName())) { + + try { + + IInstallMenu installMenuClass = (IInstallMenu) configurationElement + .createExecutableExtension("class"); + + installMenuClass.installBar(bars, getActionRegistry()); + + } catch (final CoreException e) { + e.printStackTrace(); + } + + } + + } + + } + + } + + public Visualization getVisualization() { + return visualization; + } + + public void setBMotionStudioEditor(BMotionStudioEditor bmotionStudioEditor) { + this.bmotionStudioEditor = bmotionStudioEditor; + } + + public BMotionStudioEditor getBMotionStudioEditor() { + return bmotionStudioEditor; + } + + public ScalableRootEditPart getRootEditPart() { + return (ScalableRootEditPart) getGraphicalViewer().getRootEditPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioImage.java index eabeb2389370646f2fdaf49da35fec14613e4c00..b3eaa999e181a45a3691bf94e1324dbf3d46834f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioImage.java @@ -1,136 +1,136 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -public class BMotionStudioImage { - - private static ImageRegistry imageReg = new ImageRegistry(); - private static boolean isInit = false; - - public static final String IMG_LOGO_B = "logo_b"; - public static final String IMG_LOGO_BMOTION = "logo_bmotion"; - public static final String IMG_LOGO_BMOTION64 = "logo_bmotion64"; - - public static final String IMG_ICON_MOTION = "icon_motion"; - public static final String IMG_ICON_MOTION_WIZ = "icon_motion_wiz"; - - public static ImageDescriptor getImageDescriptor(final String path) { - return getImageDescriptor(BMotionEditorPlugin.PLUGIN_ID, path); - } - - public static ImageDescriptor getImageDescriptor(final String pluginID, - final String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin(pluginID, path); - } - - public static void registerImage(final String key, final String path) { - ImageDescriptor desc = getImageDescriptor(path); - imageReg.put(key, desc); - } - - public static void registerImage(final String key, final String pluginID, - final String path) { - ImageDescriptor desc = getImageDescriptor(pluginID, path); - imageReg.put(key, desc); - } - - public static Image getImage(final String key) { - if (!isInit) - initializeImageRegistry(); - return imageReg.get(key); - } - - public static Image getBControlImage(final String bcontrolID) { - if (!isInit) - initializeImageRegistry(); - return getImage("icon_control_" + bcontrolID); - } - - private static void initializeImageRegistry() { - - registerImage(IMG_LOGO_B, "icons/logo_b.gif"); - registerImage(IMG_LOGO_BMOTION, "icons/logo_bmotion.png"); - registerImage(IMG_LOGO_BMOTION64, "icons/logo_bmotion_64.png"); - registerImage(IMG_ICON_MOTION, "icons/icon_motion.gif"); - registerImage(IMG_ICON_MOTION_WIZ, "icons/icon_motion_wiz.gif"); - - registerBControlImages(); - - final IExtensionRegistry reg = Platform.getExtensionRegistry(); - final IExtensionPoint extensionPoint = reg - .getExtensionPoint("de.bmotionstudio.gef.editor.registerImages"); - - for (final IExtension extension : extensionPoint.getExtensions()) { - for (final IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("registerImages".equals(configurationElement.getName())) { - - try { - - IBMotionStudioImageRegistry imageReg = (IBMotionStudioImageRegistry) configurationElement - .createExecutableExtension("class"); - - imageReg.registerImages(); - - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - } - - } - - isInit = true; - - } - - private static void registerBControlImages() { - - final IExtensionRegistry registry = Platform.getExtensionRegistry(); - final IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.control"); - - for (final IExtension extension : extensionPoint.getExtensions()) { - - for (final IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("control".equals(configurationElement.getName())) { - - final String icon = configurationElement - .getAttribute("icon"); - final String ID = configurationElement.getAttribute("id"); - final String sourcePluginID = configurationElement - .getContributor().getName(); - - final String key = "icon_control_" + ID; - - registerImage(key, sourcePluginID, icon); - - } - - } - - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class BMotionStudioImage { + + private static ImageRegistry imageReg = new ImageRegistry(); + private static boolean isInit = false; + + public static final String IMG_LOGO_B = "logo_b"; + public static final String IMG_LOGO_BMOTION = "logo_bmotion"; + public static final String IMG_LOGO_BMOTION64 = "logo_bmotion64"; + + public static final String IMG_ICON_MOTION = "icon_motion"; + public static final String IMG_ICON_MOTION_WIZ = "icon_motion_wiz"; + + public static ImageDescriptor getImageDescriptor(final String path) { + return getImageDescriptor(BMotionEditorPlugin.PLUGIN_ID, path); + } + + public static ImageDescriptor getImageDescriptor(final String pluginID, + final String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin(pluginID, path); + } + + public static void registerImage(final String key, final String path) { + ImageDescriptor desc = getImageDescriptor(path); + imageReg.put(key, desc); + } + + public static void registerImage(final String key, final String pluginID, + final String path) { + ImageDescriptor desc = getImageDescriptor(pluginID, path); + imageReg.put(key, desc); + } + + public static Image getImage(final String key) { + if (!isInit) + initializeImageRegistry(); + return imageReg.get(key); + } + + public static Image getBControlImage(final String bcontrolID) { + if (!isInit) + initializeImageRegistry(); + return getImage("icon_control_" + bcontrolID); + } + + private static void initializeImageRegistry() { + + registerImage(IMG_LOGO_B, "icons/logo_b.gif"); + registerImage(IMG_LOGO_BMOTION, "icons/logo_bmotion.png"); + registerImage(IMG_LOGO_BMOTION64, "icons/logo_bmotion_64.png"); + registerImage(IMG_ICON_MOTION, "icons/icon_motion.gif"); + registerImage(IMG_ICON_MOTION_WIZ, "icons/icon_motion_wiz.gif"); + + registerBControlImages(); + + final IExtensionRegistry reg = Platform.getExtensionRegistry(); + final IExtensionPoint extensionPoint = reg + .getExtensionPoint("de.bmotionstudio.gef.editor.registerImages"); + + for (final IExtension extension : extensionPoint.getExtensions()) { + for (final IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("registerImages".equals(configurationElement.getName())) { + + try { + + IBMotionStudioImageRegistry imageReg = (IBMotionStudioImageRegistry) configurationElement + .createExecutableExtension("class"); + + imageReg.registerImages(); + + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + } + + } + + isInit = true; + + } + + private static void registerBControlImages() { + + final IExtensionRegistry registry = Platform.getExtensionRegistry(); + final IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.control"); + + for (final IExtension extension : extensionPoint.getExtensions()) { + + for (final IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("control".equals(configurationElement.getName())) { + + final String icon = configurationElement + .getAttribute("icon"); + final String ID = configurationElement.getAttribute("id"); + final String sourcePluginID = configurationElement + .getContributor().getName(); + + final String key = "icon_control_" + ID; + + registerImage(key, sourcePluginID, icon); + + } + + } + + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java index 64eb3321564db5a6915c5bd80557728b72a3e203..832bb3364c21ff307e1c521d10db1ac8411e1237 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.ui.views.properties.IPropertySheetEntry; -import org.eclipse.ui.views.properties.PropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheetSorter; - -/** - * @author Lukas Ladenberger - * - */ -public class BMotionStudioPropertySheet extends PropertySheetPage { - - public BMotionStudioPropertySheet() { - super(); - setSorter(new PropertySheetSorter() { - @Override - public int compare(IPropertySheetEntry entryA, - IPropertySheetEntry entryB) { - return getCollator() - .compare( - ((CustomSortPropertySheetEntry) entryA) - .getFullDisplayName(), - ((CustomSortPropertySheetEntry) entryB) - .getFullDisplayName()); - } - }); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.ui.views.properties.IPropertySheetEntry; +import org.eclipse.ui.views.properties.PropertySheetPage; +import org.eclipse.ui.views.properties.PropertySheetSorter; + +/** + * @author Lukas Ladenberger + * + */ +public class BMotionStudioPropertySheet extends PropertySheetPage { + + public BMotionStudioPropertySheet() { + super(); + setSorter(new PropertySheetSorter() { + @Override + public int compare(IPropertySheetEntry entryA, + IPropertySheetEntry entryB) { + return getCollator() + .compare( + ((CustomSortPropertySheetEntry) entryA) + .getFullDisplayName(), + ((CustomSortPropertySheetEntry) entryB) + .getFullDisplayName()); + } + }); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioRunPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioRunPage.java index ee49bff3c4f1f2116d8c0c3f5016c236c46a2fee..9f5260c9f6ab77238f35c7b08c3977b3c484703d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioRunPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioRunPage.java @@ -1,194 +1,194 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.KeyHandler; -import org.eclipse.gef.KeyStroke; -import org.eclipse.gef.MouseWheelHandler; -import org.eclipse.gef.MouseWheelZoomHandler; -import org.eclipse.gef.SnapToGeometry; -import org.eclipse.gef.SnapToGrid; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.rulers.RulerProvider; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.ZoomInAction; -import org.eclipse.gef.ui.actions.ZoomOutAction; -import org.eclipse.gef.ui.parts.GraphicalEditor; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.actions.ActionFactory; - -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; - -public class BMotionStudioRunPage extends GraphicalEditor { - - private Visualization visualization; - - private KeyHandler keyHandler; - - // private final Cursor cursor = new Cursor(Display.getCurrent(), - // SWT.CURSOR_HAND); - - public BMotionStudioRunPage(Visualization visualization) { - setEditDomain(new DefaultEditDomain(this)); - this.visualization = visualization; - } - - @Override - public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { - if (type == ZoomManager.class) - return ((ScalableRootEditPart) getGraphicalViewer() - .getRootEditPart()).getZoomManager(); - return super.getAdapter(type); - } - - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - // ignore selection changed. - } - - @Override - protected void initializeGraphicalViewer() { - - final GraphicalViewer viewer = getGraphicalViewer(); - - viewer.setContents(getVisualization()); - - // viewer.getControl().addMouseMoveListener(new MouseMoveListener() { - // - // public void mouseMove(MouseEvent e) { - // - // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); - // if (part instanceof AppAbstractEditPart) { - // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer - // .findObjectAt(new Point(e.x, e.y)); - // - // BControl bcontrol = (BControl) bpart.getModel(); - // if (bcontrol.hasEvent(AttributeConstants.EVENT_MOUSECLICK)) - // bpart.getFigure().setCursor(cursor); - // } - // - // } - // - // }); - // viewer.getControl().addMouseListener(new MouseListener() { - // - // public void mouseDoubleClick(final MouseEvent e) { - // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); - // if (part instanceof AppAbstractEditPart) { - // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer - // .findObjectAt(new Point(e.x, e.y)); - // bpart.executeEvent(AttributeConstants.EVENT_MOUSEDBLCLICK, - // e); - // } - // } - // - // public void mouseDown(final MouseEvent e) { - // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); - // if (part instanceof AppAbstractEditPart) { - // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer - // .findObjectAt(new Point(e.x, e.y)); - // bpart.executeEvent(AttributeConstants.EVENT_MOUSECLICK, e); - // } - // } - // - // public void mouseUp(final MouseEvent e) { - // } - // - // }); - - } - - public Visualization getVisualization() { - return this.visualization; - } - - /** - * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() - **/ - protected void configureGraphicalViewer() { - - double[] zoomLevels; - - super.configureGraphicalViewer(); - ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); - - viewer.setEditPartFactory(new BMSEditPartFactory()); - - ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); - viewer.setRootEditPart(rootEditPart); - - ZoomManager manager = rootEditPart.getZoomManager(); - getActionRegistry().registerAction(new ZoomInAction(manager)); - getActionRegistry().registerAction(new ZoomOutAction(manager)); - - zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, - 4.0, 5.0, 10.0, 20.0 }; - manager.setZoomLevels(zoomLevels); - ArrayList<String> zoomContributions = new ArrayList<String>(); - zoomContributions.add(ZoomManager.FIT_ALL); - zoomContributions.add(ZoomManager.FIT_HEIGHT); - zoomContributions.add(ZoomManager.FIT_WIDTH); - manager.setZoomLevelContributions(zoomContributions); - - keyHandler = new KeyHandler(); - - keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), - getActionRegistry().getAction(ActionFactory.DELETE.getId())); - - keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), - getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); - - keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), - getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); - - viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), - MouseWheelZoomHandler.SINGLETON); - - viewer.setKeyHandler(keyHandler); - - loadProperties(); - - } - - @Override - public void doSave(IProgressMonitor monitor) { - // Nothing to do here, this is never allowed - throw new IllegalAccessError("No way to enter this method."); - } - - protected void loadProperties() { - getGraphicalViewer().setProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY, false); - getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, - false); - getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, - false); - getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, - false); - } - - public ScalableRootEditPart getRootEditPart() { - return (ScalableRootEditPart) getGraphicalViewer().getRootEditPart(); - } - - /** - * The run page editor should be never dirty! - */ - public boolean isDirty() { - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.ArrayList; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gef.DefaultEditDomain; +import org.eclipse.gef.GraphicalViewer; +import org.eclipse.gef.KeyHandler; +import org.eclipse.gef.KeyStroke; +import org.eclipse.gef.MouseWheelHandler; +import org.eclipse.gef.MouseWheelZoomHandler; +import org.eclipse.gef.SnapToGeometry; +import org.eclipse.gef.SnapToGrid; +import org.eclipse.gef.editparts.ScalableRootEditPart; +import org.eclipse.gef.editparts.ZoomManager; +import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.gef.ui.actions.ZoomInAction; +import org.eclipse.gef.ui.actions.ZoomOutAction; +import org.eclipse.gef.ui.parts.GraphicalEditor; +import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionFactory; + +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; + +public class BMotionStudioRunPage extends GraphicalEditor { + + private Visualization visualization; + + private KeyHandler keyHandler; + + // private final Cursor cursor = new Cursor(Display.getCurrent(), + // SWT.CURSOR_HAND); + + public BMotionStudioRunPage(Visualization visualization) { + setEditDomain(new DefaultEditDomain(this)); + this.visualization = visualization; + } + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { + if (type == ZoomManager.class) + return ((ScalableRootEditPart) getGraphicalViewer() + .getRootEditPart()).getZoomManager(); + return super.getAdapter(type); + } + + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + // ignore selection changed. + } + + @Override + protected void initializeGraphicalViewer() { + + final GraphicalViewer viewer = getGraphicalViewer(); + + viewer.setContents(getVisualization()); + + // viewer.getControl().addMouseMoveListener(new MouseMoveListener() { + // + // public void mouseMove(MouseEvent e) { + // + // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); + // if (part instanceof AppAbstractEditPart) { + // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer + // .findObjectAt(new Point(e.x, e.y)); + // + // BControl bcontrol = (BControl) bpart.getModel(); + // if (bcontrol.hasEvent(AttributeConstants.EVENT_MOUSECLICK)) + // bpart.getFigure().setCursor(cursor); + // } + // + // } + // + // }); + // viewer.getControl().addMouseListener(new MouseListener() { + // + // public void mouseDoubleClick(final MouseEvent e) { + // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); + // if (part instanceof AppAbstractEditPart) { + // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer + // .findObjectAt(new Point(e.x, e.y)); + // bpart.executeEvent(AttributeConstants.EVENT_MOUSEDBLCLICK, + // e); + // } + // } + // + // public void mouseDown(final MouseEvent e) { + // EditPart part = viewer.findObjectAt(new Point(e.x, e.y)); + // if (part instanceof AppAbstractEditPart) { + // AppAbstractEditPart bpart = (AppAbstractEditPart) viewer + // .findObjectAt(new Point(e.x, e.y)); + // bpart.executeEvent(AttributeConstants.EVENT_MOUSECLICK, e); + // } + // } + // + // public void mouseUp(final MouseEvent e) { + // } + // + // }); + + } + + public Visualization getVisualization() { + return this.visualization; + } + + /** + * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() + **/ + protected void configureGraphicalViewer() { + + double[] zoomLevels; + + super.configureGraphicalViewer(); + ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); + + viewer.setEditPartFactory(new BMSEditPartFactory()); + + ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); + viewer.setRootEditPart(rootEditPart); + + ZoomManager manager = rootEditPart.getZoomManager(); + getActionRegistry().registerAction(new ZoomInAction(manager)); + getActionRegistry().registerAction(new ZoomOutAction(manager)); + + zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, + 4.0, 5.0, 10.0, 20.0 }; + manager.setZoomLevels(zoomLevels); + ArrayList<String> zoomContributions = new ArrayList<String>(); + zoomContributions.add(ZoomManager.FIT_ALL); + zoomContributions.add(ZoomManager.FIT_HEIGHT); + zoomContributions.add(ZoomManager.FIT_WIDTH); + manager.setZoomLevelContributions(zoomContributions); + + keyHandler = new KeyHandler(); + + keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), + getActionRegistry().getAction(ActionFactory.DELETE.getId())); + + keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), + getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); + + keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), + getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); + + viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), + MouseWheelZoomHandler.SINGLETON); + + viewer.setKeyHandler(keyHandler); + + loadProperties(); + + } + + @Override + public void doSave(IProgressMonitor monitor) { + // Nothing to do here, this is never allowed + throw new IllegalAccessError("No way to enter this method."); + } + + protected void loadProperties() { + getGraphicalViewer().setProperty( + RulerProvider.PROPERTY_RULER_VISIBILITY, false); + getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, + false); + getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, + false); + getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, + false); + } + + public ScalableRootEditPart getRootEditPart() { + return (ScalableRootEditPart) getGraphicalViewer().getRootEditPart(); + } + + /** + * The run page editor should be never dirty! + */ + public boolean isDirty() { + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioSWTConstants.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioSWTConstants.java index df47b4a385b8ac3d3f3e4019ceb49e2106b20f0b..6bb7663ab4759c6132f0ebd84579631d9e740c22 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioSWTConstants.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioSWTConstants.java @@ -1,31 +1,31 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Display; - -/** - * @author Lukas Ladenberger - * - */ -public class BMotionStudioSWTConstants { - - public static final String RODIN_FONT_KEY = "org.rodinp.keyboard.textFont"; - - public final static Color containerHighlighting1 = new Color(null, 200, - 200, 240); - - public final static Color containerHighlighting2 = new Color(null, 200, - 240, 200); - - public final static Font fontArial10 = new Font(Display.getDefault(), - new FontData("Arial", 10, SWT.NONE)); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.widgets.Display; + +/** + * @author Lukas Ladenberger + * + */ +public class BMotionStudioSWTConstants { + + public static final String RODIN_FONT_KEY = "org.rodinp.keyboard.textFont"; + + public final static Color containerHighlighting1 = new Color(null, 200, + 200, 240); + + public final static Color containerHighlighting2 = new Color(null, 200, + 240, 200); + + public final static Font fontArial10 = new Font(Display.getDefault(), + new FontData("Arial", 10, SWT.NONE)); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BindingObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BindingObject.java index 657ea9a4224ff6e4e347bed1d73acf3e8cca06f6..e4338e73da0878fe9fdf154b6386acdae9b90f15 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BindingObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BindingObject.java @@ -1,64 +1,64 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * - * @author Lukas Ladenberger - * - */ -public abstract class BindingObject implements Cloneable { - - private transient PropertyChangeSupport propertyChangeSupport; - - public void addPropertyChangeListener(PropertyChangeListener listener) { - getPropertyChangeSupport().addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener) { - getPropertyChangeSupport().addPropertyChangeListener(propertyName, - listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - getPropertyChangeSupport().removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener) { - getPropertyChangeSupport().removePropertyChangeListener(propertyName, - listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, - Object newValue) { - getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, - newValue); - } - - public void setPropertyChangeSupport( - PropertyChangeSupport propertyChangeSupport) { - this.propertyChangeSupport = propertyChangeSupport; - } - - public PropertyChangeSupport getPropertyChangeSupport() { - if (propertyChangeSupport == null) - propertyChangeSupport = new PropertyChangeSupport(this); - return propertyChangeSupport; - } - - public BindingObject clone() throws CloneNotSupportedException { - BindingObject clone = (BindingObject) super.clone(); - clone.setPropertyChangeSupport(null); - return clone; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +/** + * + * @author Lukas Ladenberger + * + */ +public abstract class BindingObject implements Cloneable { + + private transient PropertyChangeSupport propertyChangeSupport; + + public void addPropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(propertyName, + listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(propertyName, + listener); + } + + protected void firePropertyChange(String propertyName, Object oldValue, + Object newValue) { + getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, + newValue); + } + + public void setPropertyChangeSupport( + PropertyChangeSupport propertyChangeSupport) { + this.propertyChangeSupport = propertyChangeSupport; + } + + public PropertyChangeSupport getPropertyChangeSupport() { + if (propertyChangeSupport == null) + propertyChangeSupport = new PropertyChangeSupport(this); + return propertyChangeSupport; + } + + public BindingObject clone() throws CloneNotSupportedException { + BindingObject clone = (BindingObject) super.clone(); + clone.setPropertyChangeSupport(null); + return clone; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ButtonGroupHelper.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ButtonGroupHelper.java index 5e1169353ff98078f69a2bf9a244356d996317cb..a626256328733231d636e06012cb604adcfef44b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ButtonGroupHelper.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ButtonGroupHelper.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class ButtonGroupHelper { - - private static HashMap<String, Collection<BControl>> map = new HashMap<String, Collection<BControl>>(); - - public ButtonGroupHelper() { - } - - public static Collection<BControl> getButtonGroup(String buttonGroupID) { - return map.get(buttonGroupID); - } - - public static void addToButtonGroup(String buttonGroupID, BControl control) { - Collection<BControl> group; - if (!map.containsKey(buttonGroupID)) { - group = new ArrayList<BControl>(); - map.put(buttonGroupID, group); - } else { - group = map.get(buttonGroupID); - } - group.add(control); - } - - public static void removeButtonGroup(String buttonGroupID) { - map.remove(buttonGroupID); - } - - public static void reset() { - map.clear(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class ButtonGroupHelper { + + private static HashMap<String, Collection<BControl>> map = new HashMap<String, Collection<BControl>>(); + + public ButtonGroupHelper() { + } + + public static Collection<BControl> getButtonGroup(String buttonGroupID) { + return map.get(buttonGroupID); + } + + public static void addToButtonGroup(String buttonGroupID, BControl control) { + Collection<BControl> group; + if (!map.containsKey(buttonGroupID)) { + group = new ArrayList<BControl>(); + map.put(buttonGroupID, group); + } else { + group = map.get(buttonGroupID); + } + group.add(control); + } + + public static void removeButtonGroup(String buttonGroupID) { + map.remove(buttonGroupID); + } + + public static void reset() { + map.clear(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java index 41ffbc617ba79ea37ce2b14eaf28c0badc6bf3b4..1e1f702879937e338076a9568a7cb65b3b6421f0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; -import org.eclipse.ui.views.properties.PropertySheetEntry; - -/** - * Overridden to allow specific ordering of properties. Order can be forced by - * prepending text followed by a ':' for example: - * - * a1:id a2:x a3:y a4:width a5:height - * - * forces the above order. - * - * When the name is displayed, the getDisplayName method removes the prefix. - * - * Any number of colons maybe used, for example: - * - * bean:property:x bean:eventset:action bean:property:y - * - * (not a real, applicable example, but it gets the idea across) - * - */ -public class CustomSortPropertySheetEntry extends UndoablePropertySheetEntry { - - public CustomSortPropertySheetEntry(CommandStack stack) { - super(stack); - } - - protected PropertySheetEntry createChildEntry() { - return new CustomSortPropertySheetEntry(getCommandStack()); - } - - @Override - public String getDisplayName() { - String displayName = super.getDisplayName(); - int colon = displayName.lastIndexOf(':'); - if (colon != -1) - displayName = displayName.substring(colon + 1); - return displayName; - } - - public String getFullDisplayName() { - return getDescriptor().getDisplayName(); - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; +import org.eclipse.ui.views.properties.PropertySheetEntry; + +/** + * Overridden to allow specific ordering of properties. Order can be forced by + * prepending text followed by a ':' for example: + * + * a1:id a2:x a3:y a4:width a5:height + * + * forces the above order. + * + * When the name is displayed, the getDisplayName method removes the prefix. + * + * Any number of colons maybe used, for example: + * + * bean:property:x bean:eventset:action bean:property:y + * + * (not a real, applicable example, but it gets the idea across) + * + */ +public class CustomSortPropertySheetEntry extends UndoablePropertySheetEntry { + + public CustomSortPropertySheetEntry(CommandStack stack) { + super(stack); + } + + protected PropertySheetEntry createChildEntry() { + return new CustomSortPropertySheetEntry(getCommandStack()); + } + + @Override + public String getDisplayName() { + String displayName = super.getDisplayName(); + int colon = displayName.lastIndexOf(':'); + if (colon != -1) + displayName = displayName.substring(colon + 1); + return displayName; + } + + public String getFullDisplayName() { + return getDescriptor().getDisplayName(); + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java index 56b16757ec2c66df568c7fcd22408130837cacc3..967cf40bb7e56f43ce4db5b772e70b87c8c9d355 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java @@ -1,95 +1,95 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -public class EditorImageRegistry implements IBMotionStudioImageRegistry { - - public static final String IMG_ICON_ADD = "icon_add"; - public static final String IMG_ICON_CHOP = "icon_chop"; - public static final String IMG_ICON_DELETE = "icon_delete"; - public static final String IMG_ICON_DELETE21 = "icon_delete21"; - public static final String IMG_ICON_EDIT = "icon_edit"; - public static final String IMG_ICON_CHECKED = "icon_checked"; - public static final String IMG_ICON_UNCHECKED = "icon_unchecked"; - public static final String IMG_ICON_OBSERVER = "icon_observer"; - public static final String IMG_ICON_LOADING = "icon_loading"; - public static final String IMG_ICON_LIBRARY = "icon_library"; - public static final String IMG_ICON_ASCRIPT = "icon_ascript"; - public static final String IMG_ICON_UP = "icon_up"; - public static final String IMG_ICON_DOWN = "icon_down"; - public static final String IMG_ICON_CONNECTION16 = "icon_connection16"; - public static final String IMG_ICON_CONNECTION24 = "icon_connection24"; - public static final String IMG_ICON_NEW_WIZ = "icon_new_wiz"; - public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit"; - public static final String IMG_ICON_TR_UP = "icon_tr_up"; - public static final String IMG_ICON_TR_LEFT = "icon_tr_left"; - public static final String IMG_ICON_CONTROL_HIDDEN = "icon_control_hidden"; - - public static final String IMG_ICON_JPG = "icon_jpg"; - public static final String IMG_ICON_GIF = "icon_gif"; - - public static final String IMG_SPLASH = "splash"; - - public void registerImages() { - - BMotionStudioImage.registerImage(IMG_ICON_ADD, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_add.gif"); - BMotionStudioImage.registerImage(IMG_ICON_CHOP, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_chop.gif"); - BMotionStudioImage.registerImage(IMG_ICON_DELETE, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_delete.gif"); - BMotionStudioImage.registerImage(IMG_ICON_DELETE21, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_delete21.png"); - BMotionStudioImage.registerImage(IMG_ICON_CHECKED, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_checked.gif"); - BMotionStudioImage.registerImage(IMG_ICON_UNCHECKED, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_unchecked.gif"); - BMotionStudioImage.registerImage(IMG_ICON_EDIT, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_edit.gif"); - BMotionStudioImage.registerImage(IMG_ICON_LOADING, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_loading.gif"); - BMotionStudioImage.registerImage(IMG_ICON_LIBRARY, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_library.gif"); - BMotionStudioImage.registerImage(IMG_ICON_ASCRIPT, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_ascript.png"); - BMotionStudioImage.registerImage(IMG_ICON_UP, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_up.gif"); - BMotionStudioImage.registerImage(IMG_ICON_DOWN, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_down.gif"); - BMotionStudioImage.registerImage(IMG_ICON_CONNECTION16, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_connection16.gif"); - BMotionStudioImage.registerImage(IMG_ICON_CONNECTION24, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_connection24.gif"); - BMotionStudioImage.registerImage(IMG_ICON_CONTROL_HIDDEN, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_invisible.gif"); - BMotionStudioImage.registerImage(IMG_ICON_NEW_WIZ, "org.eclipse.ui", - "$nl$/icons/full/etool16/new_wiz.gif"); - BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, - "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); - BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, - "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); - BMotionStudioImage - .registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/updated_co.gif"); - BMotionStudioImage.registerImage(IMG_ICON_TR_LEFT, - BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/updated_col.gif"); - - BMotionStudioImage.registerImage(IMG_ICON_JPG, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif"); - BMotionStudioImage.registerImage(IMG_ICON_GIF, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_gif.gif"); - - BMotionStudioImage.registerImage(IMG_ICON_OBSERVER, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_observer.gif"); - - BMotionStudioImage.registerImage(IMG_SPLASH, - BMotionEditorPlugin.PLUGIN_ID, "icons/splash.jpg"); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +public class EditorImageRegistry implements IBMotionStudioImageRegistry { + + public static final String IMG_ICON_ADD = "icon_add"; + public static final String IMG_ICON_CHOP = "icon_chop"; + public static final String IMG_ICON_DELETE = "icon_delete"; + public static final String IMG_ICON_DELETE21 = "icon_delete21"; + public static final String IMG_ICON_EDIT = "icon_edit"; + public static final String IMG_ICON_CHECKED = "icon_checked"; + public static final String IMG_ICON_UNCHECKED = "icon_unchecked"; + public static final String IMG_ICON_OBSERVER = "icon_observer"; + public static final String IMG_ICON_LOADING = "icon_loading"; + public static final String IMG_ICON_LIBRARY = "icon_library"; + public static final String IMG_ICON_ASCRIPT = "icon_ascript"; + public static final String IMG_ICON_UP = "icon_up"; + public static final String IMG_ICON_DOWN = "icon_down"; + public static final String IMG_ICON_CONNECTION16 = "icon_connection16"; + public static final String IMG_ICON_CONNECTION24 = "icon_connection24"; + public static final String IMG_ICON_NEW_WIZ = "icon_new_wiz"; + public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit"; + public static final String IMG_ICON_TR_UP = "icon_tr_up"; + public static final String IMG_ICON_TR_LEFT = "icon_tr_left"; + public static final String IMG_ICON_CONTROL_HIDDEN = "icon_control_hidden"; + + public static final String IMG_ICON_JPG = "icon_jpg"; + public static final String IMG_ICON_GIF = "icon_gif"; + + public static final String IMG_SPLASH = "splash"; + + public void registerImages() { + + BMotionStudioImage.registerImage(IMG_ICON_ADD, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_add.gif"); + BMotionStudioImage.registerImage(IMG_ICON_CHOP, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_chop.gif"); + BMotionStudioImage.registerImage(IMG_ICON_DELETE, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_delete.gif"); + BMotionStudioImage.registerImage(IMG_ICON_DELETE21, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_delete21.png"); + BMotionStudioImage.registerImage(IMG_ICON_CHECKED, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_checked.gif"); + BMotionStudioImage.registerImage(IMG_ICON_UNCHECKED, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_unchecked.gif"); + BMotionStudioImage.registerImage(IMG_ICON_EDIT, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_edit.gif"); + BMotionStudioImage.registerImage(IMG_ICON_LOADING, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_loading.gif"); + BMotionStudioImage.registerImage(IMG_ICON_LIBRARY, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_library.gif"); + BMotionStudioImage.registerImage(IMG_ICON_ASCRIPT, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_ascript.png"); + BMotionStudioImage.registerImage(IMG_ICON_UP, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_up.gif"); + BMotionStudioImage.registerImage(IMG_ICON_DOWN, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_down.gif"); + BMotionStudioImage.registerImage(IMG_ICON_CONNECTION16, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_connection16.gif"); + BMotionStudioImage.registerImage(IMG_ICON_CONNECTION24, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_connection24.gif"); + BMotionStudioImage.registerImage(IMG_ICON_CONTROL_HIDDEN, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_invisible.gif"); + BMotionStudioImage.registerImage(IMG_ICON_NEW_WIZ, "org.eclipse.ui", + "$nl$/icons/full/etool16/new_wiz.gif"); + BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, + "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); + BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, + "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); + BMotionStudioImage + .registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/updated_co.gif"); + BMotionStudioImage.registerImage(IMG_ICON_TR_LEFT, + BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/updated_col.gif"); + + BMotionStudioImage.registerImage(IMG_ICON_JPG, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif"); + BMotionStudioImage.registerImage(IMG_ICON_GIF, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_gif.gif"); + + BMotionStudioImage.registerImage(IMG_ICON_OBSERVER, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_observer.gif"); + + BMotionStudioImage.registerImage(IMG_SPLASH, + BMotionEditorPlugin.PLUGIN_ID, "icons/splash.jpg"); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorPaletteFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorPaletteFactory.java index 82f237b384f0dba47687681aab2ce2496da7d255..64af86839a8e7ca1c79fb9e7e5392b91bfbec180 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorPaletteFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorPaletteFactory.java @@ -1,179 +1,179 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.gef.palette.ConnectionCreationToolEntry; -import org.eclipse.gef.palette.MarqueeToolEntry; -import org.eclipse.gef.palette.PaletteContainer; -import org.eclipse.gef.palette.PaletteDrawer; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.palette.PaletteToolbar; -import org.eclipse.gef.palette.PanningSelectionToolEntry; -import org.eclipse.gef.palette.ToolEntry; - -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class EditorPaletteFactory { - - private HashMap<String, PaletteDrawer> groupMap = new HashMap<String, PaletteDrawer>(); - - /** - * Creates the PaletteRoot and adds all palette elements. Use this factory - * method to create a new palette for your graphical editor. - * - * @param visualization - * - * @param editor - * - * @return a new PaletteRoot - */ - public PaletteRoot createPalette(Visualization visualization) { - PaletteRoot palette = new PaletteRoot(); - palette.add(createToolsGroup(palette, visualization)); - createControls(palette, visualization); - createFromExtension(palette, visualization); - return palette; - } - - private void createFromExtension(PaletteRoot palette, - Visualization visualization) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.paletteEntry"); - // Iterate over controls - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - if ("entry".equals(configurationElement.getName())) { - try { - IInstallPaletteEntry entry = (IInstallPaletteEntry) configurationElement - .createExecutableExtension("class"); - entry.installPaletteEntry(palette, groupMap); - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - } - } - - private void createControls(PaletteRoot palette, Visualization visualization) { - - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.control"); - - // Iterate over groups - for (IExtension extension : extensionPoint.getExtensions()) { - - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("group".equals(configurationElement.getName())) { - - String groupID = configurationElement.getAttribute("id"); - String groupName = configurationElement - .getAttribute("name"); - - PaletteDrawer componentsDrawer = new PaletteDrawer( - groupName); - if (!groupMap.containsKey(groupID)) - groupMap.put(groupID, componentsDrawer); - - } - - } - - } - - // Iterate over controls - for (IExtension extension : extensionPoint.getExtensions()) { - - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("control".equals(configurationElement.getName())) { - - String groupID = configurationElement - .getAttribute("groupid"); - PaletteDrawer groupDrawer = groupMap.get(groupID); - - if (groupDrawer != null) { - - // boolean createDefaultToolEntry = true; - - try { - IBControlService service = (IBControlService) configurationElement - .createExecutableExtension("service"); - if (service.showInPalette()) { - ToolEntry toolEntry = service.createToolEntry( - visualization, configurationElement); - if (toolEntry != null) { - groupDrawer.add(toolEntry); - } - } - } catch (CoreException e) { - // I think we can ignore the exception since - // we create a default tool entry which is - // independent from the configuration - // element - } - - // if (createDefaultToolEntry) - // groupDrawer.add(createDefaultToolEntry(type, - // visualization, configurationElement)); - - } - - } - - } - - } - - for (Map.Entry<String, PaletteDrawer> entry : groupMap.entrySet()) { - if (entry.getValue().getChildren().size() > 0) - palette.add(entry.getValue()); - } - - } - - /** - * Create the "Tools" group. - * - * @param visualization - */ - private PaletteContainer createToolsGroup(PaletteRoot palette, - Visualization visualization) { - PaletteToolbar toolbar = new PaletteToolbar("Tools"); - // Add a selection tool to the group - ToolEntry tool = new PanningSelectionToolEntry(); - toolbar.add(tool); - palette.setDefaultEntry(tool); - // Add a marquee tool to the group - toolbar.add(new MarqueeToolEntry()); - // Add connector tool to the group - toolbar.add(new ConnectionCreationToolEntry("Connection", - "Universal Connector", new BControlCreationFactory( - BConnection.TYPE, visualization), BMotionStudioImage - .getImageDescriptor("icons/icon_connection16.gif"), - BMotionStudioImage - .getImageDescriptor("icons/icon_connection24.gif"))); - return toolbar; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.gef.palette.ConnectionCreationToolEntry; +import org.eclipse.gef.palette.MarqueeToolEntry; +import org.eclipse.gef.palette.PaletteContainer; +import org.eclipse.gef.palette.PaletteDrawer; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.palette.PaletteToolbar; +import org.eclipse.gef.palette.PanningSelectionToolEntry; +import org.eclipse.gef.palette.ToolEntry; + +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class EditorPaletteFactory { + + private HashMap<String, PaletteDrawer> groupMap = new HashMap<String, PaletteDrawer>(); + + /** + * Creates the PaletteRoot and adds all palette elements. Use this factory + * method to create a new palette for your graphical editor. + * + * @param visualization + * + * @param editor + * + * @return a new PaletteRoot + */ + public PaletteRoot createPalette(Visualization visualization) { + PaletteRoot palette = new PaletteRoot(); + palette.add(createToolsGroup(palette, visualization)); + createControls(palette, visualization); + createFromExtension(palette, visualization); + return palette; + } + + private void createFromExtension(PaletteRoot palette, + Visualization visualization) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.paletteEntry"); + // Iterate over controls + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + if ("entry".equals(configurationElement.getName())) { + try { + IInstallPaletteEntry entry = (IInstallPaletteEntry) configurationElement + .createExecutableExtension("class"); + entry.installPaletteEntry(palette, groupMap); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + } + } + + private void createControls(PaletteRoot palette, Visualization visualization) { + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.control"); + + // Iterate over groups + for (IExtension extension : extensionPoint.getExtensions()) { + + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("group".equals(configurationElement.getName())) { + + String groupID = configurationElement.getAttribute("id"); + String groupName = configurationElement + .getAttribute("name"); + + PaletteDrawer componentsDrawer = new PaletteDrawer( + groupName); + if (!groupMap.containsKey(groupID)) + groupMap.put(groupID, componentsDrawer); + + } + + } + + } + + // Iterate over controls + for (IExtension extension : extensionPoint.getExtensions()) { + + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("control".equals(configurationElement.getName())) { + + String groupID = configurationElement + .getAttribute("groupid"); + PaletteDrawer groupDrawer = groupMap.get(groupID); + + if (groupDrawer != null) { + + // boolean createDefaultToolEntry = true; + + try { + IBControlService service = (IBControlService) configurationElement + .createExecutableExtension("service"); + if (service.showInPalette()) { + ToolEntry toolEntry = service.createToolEntry( + visualization, configurationElement); + if (toolEntry != null) { + groupDrawer.add(toolEntry); + } + } + } catch (CoreException e) { + // I think we can ignore the exception since + // we create a default tool entry which is + // independent from the configuration + // element + } + + // if (createDefaultToolEntry) + // groupDrawer.add(createDefaultToolEntry(type, + // visualization, configurationElement)); + + } + + } + + } + + } + + for (Map.Entry<String, PaletteDrawer> entry : groupMap.entrySet()) { + if (entry.getValue().getChildren().size() > 0) + palette.add(entry.getValue()); + } + + } + + /** + * Create the "Tools" group. + * + * @param visualization + */ + private PaletteContainer createToolsGroup(PaletteRoot palette, + Visualization visualization) { + PaletteToolbar toolbar = new PaletteToolbar("Tools"); + // Add a selection tool to the group + ToolEntry tool = new PanningSelectionToolEntry(); + toolbar.add(tool); + palette.setDefaultEntry(tool); + // Add a marquee tool to the group + toolbar.add(new MarqueeToolEntry()); + // Add connector tool to the group + toolbar.add(new ConnectionCreationToolEntry("Connection", + "Universal Connector", new BControlCreationFactory( + BConnection.TYPE, visualization), BMotionStudioImage + .getImageDescriptor("icons/icon_connection16.gif"), + BMotionStudioImage + .getImageDescriptor("icons/icon_connection24.gif"))); + return toolbar; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IAddErrorListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IAddErrorListener.java index 56541669bf2d5b35ef446a59aba23d5b9a641516..5341fb2282755ee857505dc5cf24940b271fd5a6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IAddErrorListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IAddErrorListener.java @@ -1,13 +1,13 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -public interface IAddErrorListener { - - public Object errorsAdded(); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +public interface IAddErrorListener { + + public Object errorsAdded(); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBControlService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBControlService.java index a55c324a812e760764e8e0c8a0aa1d19de10bdfe..6dda2ca32e38dbb7a87d0aebe4126fa881bfb275 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBControlService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBControlService.java @@ -1,34 +1,34 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.palette.ToolEntry; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; - -/** - * @author Lukas Ladenberger - * - */ -public interface IBControlService { - - public BControl createControl(Visualization visualization); - - public BMSAbstractEditPart createEditPart(); - - public BMSAbstractTreeEditPart createTreeEditPart(); - - public ToolEntry createToolEntry(Visualization visualization, - IConfigurationElement configurationElement); - - public boolean showInPalette(); - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.palette.ToolEntry; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart; + +/** + * @author Lukas Ladenberger + * + */ +public interface IBControlService { + + public BControl createControl(Visualization visualization); + + public BMSAbstractEditPart createEditPart(); + + public BMSAbstractTreeEditPart createTreeEditPart(); + + public ToolEntry createToolEntry(Visualization visualization, + IConfigurationElement configurationElement); + + public boolean showInPalette(); + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBMotionStudioImageRegistry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBMotionStudioImageRegistry.java index af1e8d11b27e568982a619a4e3cecc0652421e4c..32945d1aa04935800c3ac1f8e9c08d488851fb29 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBMotionStudioImageRegistry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IBMotionStudioImageRegistry.java @@ -4,11 +4,11 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor; - - -public interface IBMotionStudioImageRegistry { - - public void registerImages(); - -} +package de.bmotionstudio.gef.editor; + + +public interface IBMotionStudioImageRegistry { + + public void registerImages(); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallActions.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallActions.java index e05735f5b237801e2c2f90dbdf3208a810736673..f113c5004122f3b7703a1d5f1b8b93e8e2c591c9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallActions.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallActions.java @@ -4,17 +4,17 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor; - -import java.util.HashMap; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.part.WorkbenchPart; - -public interface IInstallActions { - - public void installActions(WorkbenchPart part); - - public HashMap<String, Action> getActionMap(); - -} +package de.bmotionstudio.gef.editor; + +import java.util.HashMap; + +import org.eclipse.jface.action.Action; +import org.eclipse.ui.part.WorkbenchPart; + +public interface IInstallActions { + + public void installActions(WorkbenchPart part); + + public HashMap<String, Action> getActionMap(); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallMenu.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallMenu.java index 657394603e154102c4d6bccabdf569bba1641289..510a81339f872cb8ac25ee081566f741c7928026 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallMenu.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallMenu.java @@ -4,16 +4,16 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor; - -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.ui.IActionBars; - -public interface IInstallMenu { - - public void installMenu(IMenuManager menu, ActionRegistry regitry); - - public void installBar(IActionBars bars, ActionRegistry regitry); - -} +package de.bmotionstudio.gef.editor; + +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.ui.IActionBars; + +public interface IInstallMenu { + + public void installMenu(IMenuManager menu, ActionRegistry regitry); + + public void installBar(IActionBars bars, ActionRegistry regitry); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallPaletteEntry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallPaletteEntry.java index a0853bb532dfe2d587cac80846b35e0a389b564e..657874ebc03c65db612aa90487045b2177444da0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallPaletteEntry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IInstallPaletteEntry.java @@ -1,22 +1,22 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor; - -import java.util.HashMap; - -import org.eclipse.gef.palette.PaletteDrawer; -import org.eclipse.gef.palette.PaletteRoot; - -/** - * @author Lukas Ladenberger - * - */ -public interface IInstallPaletteEntry { - - public void installPaletteEntry(PaletteRoot palette, - HashMap<String, PaletteDrawer> groups); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor; + +import java.util.HashMap; + +import org.eclipse.gef.palette.PaletteDrawer; +import org.eclipse.gef.palette.PaletteRoot; + +/** + * @author Lukas Ladenberger + * + */ +public interface IInstallPaletteEntry { + + public void installPaletteEntry(PaletteRoot palette, + HashMap<String, PaletteDrawer> groups); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ILanguageService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ILanguageService.java index 324da6b21c2977c1955a44005473e140c5211106..66eb7c2655e056d08412105882cd0232f8edbc8f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ILanguageService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ILanguageService.java @@ -1,24 +1,24 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.core.resources.IFile; - -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.exceptions.ProBException; - -/** - * @author Lukas Ladenberger - * - */ -public interface ILanguageService { - - public void startProBAnimator(Visualization v) throws ProBException; - - public boolean isLanguageFile(IFile f); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.core.resources.IFile; + +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.exceptions.ProBException; + +/** + * @author Lukas Ladenberger + * + */ +public interface ILanguageService { + + public void startProBAnimator(Visualization v) throws ProBException; + + public boolean isLanguageFile(IFile f); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IRunPageListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IRunPageListener.java index dddb30c73081c565438f4ff71d2239cc98a7fc14..a1b381a49d845f917a70cf46d9ba05e0c8f81175 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IRunPageListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/IRunPageListener.java @@ -1,15 +1,15 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -public interface IRunPageListener { - - public void runPageCreated(BMotionStudioRunPage runPage); - - public void runPageRemoved(BMotionStudioRunPage runPage); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +public interface IRunPageListener { + + public void runPageCreated(BMotionStudioRunPage runPage); + + public void runPageRemoved(BMotionStudioRunPage runPage); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ImageRegistry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ImageRegistry.java index cbde859b3df750fb34ebd9268e5f09735322504b..69cd14cc2f2c4628dc29ba8b2485b0da8f36a936 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ImageRegistry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/ImageRegistry.java @@ -1,25 +1,25 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - - -public class ImageRegistry implements IBMotionStudioImageRegistry { - - public static final String IMG_RADIOBUTTON_CHECKED = "img_radiobutton_checked"; - public static final String IMG_RADIOBUTTON_UNCHECKED = "img_radiobutton_unchecked"; - - public void registerImages() { - - BMotionStudioImage.registerImage(IMG_RADIOBUTTON_CHECKED, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_radiobutton_c.gif"); - - BMotionStudioImage.registerImage(IMG_RADIOBUTTON_UNCHECKED, - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_radiobutton_uc.gif"); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + + +public class ImageRegistry implements IBMotionStudioImageRegistry { + + public static final String IMG_RADIOBUTTON_CHECKED = "img_radiobutton_checked"; + public static final String IMG_RADIOBUTTON_UNCHECKED = "img_radiobutton_unchecked"; + + public void registerImages() { + + BMotionStudioImage.registerImage(IMG_RADIOBUTTON_CHECKED, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_radiobutton_c.gif"); + + BMotionStudioImage.registerImage(IMG_RADIOBUTTON_UNCHECKED, + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_radiobutton_uc.gif"); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallActions.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallActions.java index d2c7ada34e81b60a5df819d79fe2c4769c468179..feb252464e08a8aa477585bf5566ac775067d677 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallActions.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallActions.java @@ -1,31 +1,31 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.ui.part.WorkbenchPart; - -import de.bmotionstudio.gef.editor.action.BringToBottomAction; -import de.bmotionstudio.gef.editor.action.BringToBottomStepAction; -import de.bmotionstudio.gef.editor.action.BringToTopAction; -import de.bmotionstudio.gef.editor.action.BringToTopStepAction; -import de.bmotionstudio.gef.editor.action.FitImageAction; -import de.bmotionstudio.gef.editor.action.RenameAction; - -public class InstallActions extends AbstractInstallActions implements - IInstallActions { - - public void installActions(final WorkbenchPart part) { - installAction(RenameAction.ID, new RenameAction(part)); - installAction(FitImageAction.ID, new FitImageAction(part)); - installAction(BringToTopAction.ID, new BringToTopAction(part)); - installAction(BringToBottomAction.ID, new BringToBottomAction(part)); - installAction(BringToTopStepAction.ID, new BringToTopStepAction(part)); - installAction(BringToBottomStepAction.ID, new BringToBottomStepAction( - part)); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.ui.part.WorkbenchPart; + +import de.bmotionstudio.gef.editor.action.BringToBottomAction; +import de.bmotionstudio.gef.editor.action.BringToBottomStepAction; +import de.bmotionstudio.gef.editor.action.BringToTopAction; +import de.bmotionstudio.gef.editor.action.BringToTopStepAction; +import de.bmotionstudio.gef.editor.action.FitImageAction; +import de.bmotionstudio.gef.editor.action.RenameAction; + +public class InstallActions extends AbstractInstallActions implements + IInstallActions { + + public void installActions(final WorkbenchPart part) { + installAction(RenameAction.ID, new RenameAction(part)); + installAction(FitImageAction.ID, new FitImageAction(part)); + installAction(BringToTopAction.ID, new BringToTopAction(part)); + installAction(BringToBottomAction.ID, new BringToBottomAction(part)); + installAction(BringToTopStepAction.ID, new BringToTopStepAction(part)); + installAction(BringToBottomStepAction.ID, new BringToBottomStepAction( + part)); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallMenu.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallMenu.java index 80e218fd68a77a67657c1fcbabd321d917b04de1..b2c38c70835292ddb6582fb6a91301eac596504a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallMenu.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/InstallMenu.java @@ -1,56 +1,56 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.ui.IActionBars; - -import de.bmotionstudio.gef.editor.action.BringToBottomAction; -import de.bmotionstudio.gef.editor.action.BringToBottomStepAction; -import de.bmotionstudio.gef.editor.action.BringToTopAction; -import de.bmotionstudio.gef.editor.action.BringToTopStepAction; -import de.bmotionstudio.gef.editor.action.FitImageAction; -import de.bmotionstudio.gef.editor.action.RenameAction; - -public class InstallMenu implements IInstallMenu { - - public void installMenu(IMenuManager menu, ActionRegistry regitry) { - - IAction action; - - action = regitry.getAction(FitImageAction.ID); - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); - action = regitry.getAction(RenameAction.ID); - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); - - // menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new Separator( - // "de.bmotionstudio.gef.BringToGroup")); - - MenuManager adjustmentMenu = new MenuManager("Adjustment"); - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, adjustmentMenu); - - action = regitry.getAction(BringToTopAction.ID); - adjustmentMenu.add(action); - action = regitry.getAction(BringToBottomAction.ID); - adjustmentMenu.add(action); - action = regitry.getAction(BringToTopStepAction.ID); - adjustmentMenu.add(action); - action = regitry.getAction(BringToBottomStepAction.ID); - adjustmentMenu.add(action); - - } - - public void installBar(IActionBars bars, ActionRegistry regitry) { - // bars.setGlobalActionHandler(ActionFactory.RENAME.getId(), regitry - // .getAction(ActionFactory.RENAME.getId())); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.ui.IActionBars; + +import de.bmotionstudio.gef.editor.action.BringToBottomAction; +import de.bmotionstudio.gef.editor.action.BringToBottomStepAction; +import de.bmotionstudio.gef.editor.action.BringToTopAction; +import de.bmotionstudio.gef.editor.action.BringToTopStepAction; +import de.bmotionstudio.gef.editor.action.FitImageAction; +import de.bmotionstudio.gef.editor.action.RenameAction; + +public class InstallMenu implements IInstallMenu { + + public void installMenu(IMenuManager menu, ActionRegistry regitry) { + + IAction action; + + action = regitry.getAction(FitImageAction.ID); + menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); + action = regitry.getAction(RenameAction.ID); + menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); + + // menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new Separator( + // "de.bmotionstudio.gef.BringToGroup")); + + MenuManager adjustmentMenu = new MenuManager("Adjustment"); + menu.appendToGroup(GEFActionConstants.GROUP_EDIT, adjustmentMenu); + + action = regitry.getAction(BringToTopAction.ID); + adjustmentMenu.add(action); + action = regitry.getAction(BringToBottomAction.ID); + adjustmentMenu.add(action); + action = regitry.getAction(BringToTopStepAction.ID); + adjustmentMenu.add(action); + action = regitry.getAction(BringToBottomStepAction.ID); + adjustmentMenu.add(action); + + } + + public void installBar(IActionBars bars, ActionRegistry regitry) { + // bars.setGlobalActionHandler(ActionFactory.RENAME.getId(), regitry + // .getAction(ActionFactory.RENAME.getId())); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/StaticListenerRegistry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/StaticListenerRegistry.java index 9adfbab8813ae75f0cadeed5d362dd5852160261..ed344e1d03eaf8593e794e556c3ab74bc81c5fb1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/StaticListenerRegistry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/StaticListenerRegistry.java @@ -1,67 +1,67 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor; - -import java.util.HashSet; -import java.util.Set; - -import de.prob.core.IAnimationListener; -import de.prob.core.IComputationListener; -import de.prob.core.ILifecycleListener; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.State; - -public class StaticListenerRegistry implements ILifecycleListener, - IComputationListener, IAnimationListener { - - private static final Set<ILifecycleListener> lifeCycleListeners = new HashSet<ILifecycleListener>(); - private static final Set<IComputationListener> computationListeners = new HashSet<IComputationListener>(); - private static final Set<IAnimationListener> animationListeners = new HashSet<IAnimationListener>(); - - public static void registerListener(final ILifecycleListener listener) { - lifeCycleListeners.add(listener); - } - - public static void unregisterListener(final ILifecycleListener listener) { - lifeCycleListeners.remove(listener); - } - - public static void registerListener(final IComputationListener listener) { - computationListeners.add(listener); - } - - public static void unregisterListener(final IComputationListener listener) { - computationListeners.remove(listener); - } - - public static void registerListener(final IAnimationListener listener) { - animationListeners.add(listener); - } - - public static void unregisterListener(final IAnimationListener listener) { - animationListeners.remove(listener); - } - - public void reset() { - for (final ILifecycleListener listener : lifeCycleListeners) { - listener.reset(); - } - } - - public void computedState(final State state) { - for (final IComputationListener listener : computationListeners) { - listener.computedState(state); - } - } - - public void currentStateChanged(final State currentState, - final Operation operation) { - for (final IAnimationListener listener : animationListeners) { - listener.currentStateChanged(currentState, operation); - } - } +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor; + +import java.util.HashSet; +import java.util.Set; + +import de.prob.core.IAnimationListener; +import de.prob.core.IComputationListener; +import de.prob.core.ILifecycleListener; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.State; + +public class StaticListenerRegistry implements ILifecycleListener, + IComputationListener, IAnimationListener { + + private static final Set<ILifecycleListener> lifeCycleListeners = new HashSet<ILifecycleListener>(); + private static final Set<IComputationListener> computationListeners = new HashSet<IComputationListener>(); + private static final Set<IAnimationListener> animationListeners = new HashSet<IAnimationListener>(); + + public static void registerListener(final ILifecycleListener listener) { + lifeCycleListeners.add(listener); + } + + public static void unregisterListener(final ILifecycleListener listener) { + lifeCycleListeners.remove(listener); + } + + public static void registerListener(final IComputationListener listener) { + computationListeners.add(listener); + } + + public static void unregisterListener(final IComputationListener listener) { + computationListeners.remove(listener); + } + + public static void registerListener(final IAnimationListener listener) { + animationListeners.add(listener); + } + + public static void unregisterListener(final IAnimationListener listener) { + animationListeners.remove(listener); + } + + public void reset() { + for (final ILifecycleListener listener : lifeCycleListeners) { + listener.reset(); + } + } + + public void computedState(final State state) { + for (final IComputationListener listener : computationListeners) { + listener.computedState(state); + } + } + + public void currentStateChanged(final State currentState, + final Operation operation) { + for (final IAnimationListener listener : animationListeners) { + listener.currentStateChanged(currentState, operation); + } + } } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionAbstractWizardDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionAbstractWizardDialog.java index d9a3d5c380584994b742f7faf36ad8d7b89d886a..754134f8e32d80d9a8c17716c826d847f4d4f20b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionAbstractWizardDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionAbstractWizardDialog.java @@ -1,107 +1,107 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; - -public abstract class BMotionAbstractWizardDialog extends WizardDialog { - - public static final int DELETE = 3; - - private IWorkbenchPart workbenchPart; - - private String deleteToolTip; - - public BMotionAbstractWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) { - super(workbenchPart.getSite().getShell(), newWizard); - this.workbenchPart = workbenchPart; - } - - @Override - protected Control createButtonBar(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.horizontalSpacing = 0; - composite.setLayout(layout); - composite - .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - composite.setFont(parent.getFont()); - - // create help control if needed - if (isHelpAvailable()) { - Control helpControl = createHelpControl(composite); - ((GridData) helpControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - } - - Control deleteControl = createDeleteControl(composite); - ((GridData) deleteControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - setHelpAvailable(false); - Control buttonSection = super.createButtonBar(composite); - ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true; - return composite; - } - - private Control createDeleteControl(Composite parent) { - return createDeleteImageButton(parent, - BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE21)); - } - - private ToolBar createDeleteImageButton(Composite parent, Image image) { - ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); - ((GridLayout) parent.getLayout()).numColumns++; - toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); - final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); - toolBar.setCursor(cursor); - toolBar.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - cursor.dispose(); - } - }); - ToolItem deleteToolItem = new ToolItem(toolBar, SWT.NONE); - deleteToolItem.setImage(image); - deleteToolItem.setToolTipText(deleteToolTip); - deleteToolItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - deletePressed(); - } - }); - return toolBar; - } - - protected abstract void deletePressed(); - - public IWorkbenchPart getWorkbenchPart() { - return workbenchPart; - } - - protected void setDeleteToolTip(String msg) { - this.deleteToolTip = msg; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; + +public abstract class BMotionAbstractWizardDialog extends WizardDialog { + + public static final int DELETE = 3; + + private IWorkbenchPart workbenchPart; + + private String deleteToolTip; + + public BMotionAbstractWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) { + super(workbenchPart.getSite().getShell(), newWizard); + this.workbenchPart = workbenchPart; + } + + @Override + protected Control createButtonBar(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.horizontalSpacing = 0; + composite.setLayout(layout); + composite + .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); + composite.setFont(parent.getFont()); + + // create help control if needed + if (isHelpAvailable()) { + Control helpControl = createHelpControl(composite); + ((GridData) helpControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + } + + Control deleteControl = createDeleteControl(composite); + ((GridData) deleteControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + setHelpAvailable(false); + Control buttonSection = super.createButtonBar(composite); + ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true; + return composite; + } + + private Control createDeleteControl(Composite parent) { + return createDeleteImageButton(parent, + BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE21)); + } + + private ToolBar createDeleteImageButton(Composite parent, Image image) { + ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); + ((GridLayout) parent.getLayout()).numColumns++; + toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); + final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); + toolBar.setCursor(cursor); + toolBar.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + cursor.dispose(); + } + }); + ToolItem deleteToolItem = new ToolItem(toolBar, SWT.NONE); + deleteToolItem.setImage(image); + deleteToolItem.setToolTipText(deleteToolTip); + deleteToolItem.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + deletePressed(); + } + }); + return toolBar; + } + + protected abstract void deletePressed(); + + public IWorkbenchPart getWorkbenchPart() { + return workbenchPart; + } + + protected void setDeleteToolTip(String msg) { + this.deleteToolTip = msg; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionObserverWizardDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionObserverWizardDialog.java index b5ccee629af599d22f068f274a63be7b2e341788..811a2afb9d737d2d99d7a425b19b054bccfdcbb1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionObserverWizardDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionObserverWizardDialog.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchPart; - -public class BMotionObserverWizardDialog extends BMotionAbstractWizardDialog { - - public BMotionObserverWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) { - super(workbenchPart, newWizard); - setShellStyle(SWT.CLOSE | SWT.RESIZE); - setDeleteToolTip("Delete Observer"); - } - - @Override - protected void deletePressed() { - - if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), - "Do you really want to delete this Observer?", - "Do you really want to delete this Observer?")) { - setReturnCode(DELETE); - close(); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPart; + +public class BMotionObserverWizardDialog extends BMotionAbstractWizardDialog { + + public BMotionObserverWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) { + super(workbenchPart, newWizard); + setShellStyle(SWT.CLOSE | SWT.RESIZE); + setDeleteToolTip("Delete Observer"); + } + + @Override + protected void deletePressed() { + + if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), + "Do you really want to delete this Observer?", + "Do you really want to delete this Observer?")) { + setReturnCode(DELETE); + close(); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionSchedulerEventWizardDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionSchedulerEventWizardDialog.java index f14aa16a5b28e12a8e7b0601ef55e65850ec328c..fbcc22408167b82bed405190416d5863d4761353 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionSchedulerEventWizardDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionSchedulerEventWizardDialog.java @@ -1,43 +1,43 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; - -public class BMotionSchedulerEventWizardDialog extends BMotionAbstractWizardDialog { - - public BMotionSchedulerEventWizardDialog(IWorkbenchPart workbenchPart, - IWizard newWizard) { - super(workbenchPart, newWizard); - setShellStyle(SWT.CLOSE); - setDeleteToolTip("Delete Event"); - } - - @Override - protected void deletePressed() { - - if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), - "Do you really want to delete this Event?", - "Do you really want to delete this Event?")) { - RemoveSchedulerEventAction action = new RemoveSchedulerEventAction( - getWorkbenchPart()); - action.setControl(((SchedulerWizard) getWizard()).getBControl()); - action.setSchedulerEvent(((SchedulerWizard) getWizard()) - .getScheduler()); - action.run(); - setReturnCode(DELETE); - close(); - } - - } -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; + +public class BMotionSchedulerEventWizardDialog extends BMotionAbstractWizardDialog { + + public BMotionSchedulerEventWizardDialog(IWorkbenchPart workbenchPart, + IWizard newWizard) { + super(workbenchPart, newWizard); + setShellStyle(SWT.CLOSE); + setDeleteToolTip("Delete Event"); + } + + @Override + protected void deletePressed() { + + if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), + "Do you really want to delete this Event?", + "Do you really want to delete this Event?")) { + RemoveSchedulerEventAction action = new RemoveSchedulerEventAction( + getWorkbenchPart()); + action.setControl(((SchedulerWizard) getWizard()).getBControl()); + action.setSchedulerEvent(((SchedulerWizard) getWizard()) + .getScheduler()); + action.run(); + setReturnCode(DELETE); + close(); + } + + } +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardAddItemAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardAddItemAction.java index 2f8b5d46dc22e42c7b94e193528b2ebfaabf22c4..80340e2c284344d30f693d18ca35276a62877a36 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardAddItemAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardAddItemAction.java @@ -1,50 +1,50 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; - -public class BMotionWizardAddItemAction extends Action { - - private TableViewer viewer; - private Class<?> itemClass; - - public BMotionWizardAddItemAction(TableViewer viewer, Class<?> itemClass) { - this.viewer = viewer; - this.itemClass = itemClass; - setText("Add new item"); - setImageDescriptor(BMotionStudioImage.getImageDescriptor( - "org.eclipse.ui", "$nl$/icons/full/etool16/new_wiz.gif")); - } - - @Override - public void run() { - - try { - IStructuredSelection sel = (IStructuredSelection) viewer - .getSelection(); - Object firstElement = sel.getFirstElement(); - WritableList list = (WritableList) viewer.getInput(); - int indexOf = list.size(); - if (firstElement != null) - indexOf = list.indexOf(firstElement) + 1; - Object newInstance = itemClass.newInstance(); - list.add(indexOf, newInstance); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; + +public class BMotionWizardAddItemAction extends Action { + + private TableViewer viewer; + private Class<?> itemClass; + + public BMotionWizardAddItemAction(TableViewer viewer, Class<?> itemClass) { + this.viewer = viewer; + this.itemClass = itemClass; + setText("Add new item"); + setImageDescriptor(BMotionStudioImage.getImageDescriptor( + "org.eclipse.ui", "$nl$/icons/full/etool16/new_wiz.gif")); + } + + @Override + public void run() { + + try { + IStructuredSelection sel = (IStructuredSelection) viewer + .getSelection(); + Object firstElement = sel.getFirstElement(); + WritableList list = (WritableList) viewer.getInput(); + int indexOf = list.size(); + if (firstElement != null) + indexOf = list.indexOf(firstElement) + 1; + Object newInstance = itemClass.newInstance(); + list.add(indexOf, newInstance); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardDeleteItemsAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardDeleteItemsAction.java index 1ad64e4046aec6232ca6f4a2c27fe400bc103345..444992ad04f798bfae2d96f2a51fa78e6d8a40dc 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardDeleteItemsAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BMotionWizardDeleteItemsAction.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.Arrays; - -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; - -public class BMotionWizardDeleteItemsAction extends Action { - - private TableViewer viewer; - - public BMotionWizardDeleteItemsAction(TableViewer viewer) { - this.viewer = viewer; - setText("Delete selected items"); - setImageDescriptor(BMotionStudioImage.getImageDescriptor( - "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif")); - } - - @Override - public void run() { - - IStructuredSelection sel = (IStructuredSelection) viewer.getSelection(); - Object[] lobjects = sel.toArray(); - - if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), - "Please confirm", "Do you realy want to delete these objects?")) { - WritableList list = (WritableList) viewer.getInput(); - list.removeAll(Arrays.asList(lobjects)); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.Arrays; + +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; + +public class BMotionWizardDeleteItemsAction extends Action { + + private TableViewer viewer; + + public BMotionWizardDeleteItemsAction(TableViewer viewer) { + this.viewer = viewer; + setText("Delete selected items"); + setImageDescriptor(BMotionStudioImage.getImageDescriptor( + "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif")); + } + + @Override + public void run() { + + IStructuredSelection sel = (IStructuredSelection) viewer.getSelection(); + Object[] lobjects = sel.toArray(); + + if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), + "Please confirm", "Do you realy want to delete these objects?")) { + WritableList list = (WritableList) viewer.getInput(); + list.removeAll(Arrays.asList(lobjects)); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomAction.java index ab2dcc35ee639bf6ba7384b39de759dbc84bee86..390b293e8cfe4ad2faac892170574aa578228e81 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomAction.java @@ -1,80 +1,80 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.command.BringToBottomCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.VisualizationPart; - -public class BringToBottomAction extends SelectionAction { - - public final static String ID = "de.bmotionstudio.gef.editor.action.bringToBottom"; - - public BringToBottomAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Bring to bottom"); - setToolTipText("Bring to bottom"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( - BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/caught_ovr_d.gif"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - List<?> selectedObjects = getSelectedObjects(); - if (selectedObjects.size() == 1) { - if (selectedObjects.get(0) instanceof VisualizationPart) { - return false; - } - } - return true; - } - - public BringToBottomCommand createBringToBottomCommand( - List<BControl> modelList) { - BringToBottomCommand command = new BringToBottomCommand(); - command.setControlList(modelList); - return command; - } - - public void run() { - - List<BControl> modelList = new ArrayList<BControl>(); - - List<?> selectedObjects = getSelectedObjects(); - - for (Object obj : selectedObjects) { - if (obj instanceof BMSAbstractEditPart) { - modelList - .add((BControl) ((BMSAbstractEditPart) obj).getModel()); - } - } - - execute(createBringToBottomCommand(modelList)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.command.BringToBottomCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.VisualizationPart; + +public class BringToBottomAction extends SelectionAction { + + public final static String ID = "de.bmotionstudio.gef.editor.action.bringToBottom"; + + public BringToBottomAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Bring to bottom"); + setToolTipText("Bring to bottom"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( + BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/caught_ovr_d.gif"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + List<?> selectedObjects = getSelectedObjects(); + if (selectedObjects.size() == 1) { + if (selectedObjects.get(0) instanceof VisualizationPart) { + return false; + } + } + return true; + } + + public BringToBottomCommand createBringToBottomCommand( + List<BControl> modelList) { + BringToBottomCommand command = new BringToBottomCommand(); + command.setControlList(modelList); + return command; + } + + public void run() { + + List<BControl> modelList = new ArrayList<BControl>(); + + List<?> selectedObjects = getSelectedObjects(); + + for (Object obj : selectedObjects) { + if (obj instanceof BMSAbstractEditPart) { + modelList + .add((BControl) ((BMSAbstractEditPart) obj).getModel()); + } + } + + execute(createBringToBottomCommand(modelList)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomStepAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomStepAction.java index 9073dfdde11e7f235c0182a01a271c90023bd156..1ab64246202177d6c58434572a1eb49497bca9ac 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomStepAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToBottomStepAction.java @@ -1,80 +1,80 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.command.BringToBottomStepCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.VisualizationPart; - -public class BringToBottomStepAction extends SelectionAction { - - public final static String ID = "de.bmotionstudio.gef.editor.action.bringToBottomStep"; - - public BringToBottomStepAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Bring to bottom (Step)"); - setToolTipText("Bring to bottom (Step)"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( - BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/uncaught_ovr_d.gif"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - List<?> selectedObjects = getSelectedObjects(); - if (selectedObjects.size() == 1) { - if (selectedObjects.get(0) instanceof VisualizationPart) { - return false; - } - } - return true; - } - - public BringToBottomStepCommand createBringToBottomStepCommand( - List<BControl> modelList) { - BringToBottomStepCommand command = new BringToBottomStepCommand(); - command.setControlList(modelList); - return command; - } - - public void run() { - - List<BControl> modelList = new ArrayList<BControl>(); - - List<?> selectedObjects = getSelectedObjects(); - - for (Object obj : selectedObjects) { - if (obj instanceof BMSAbstractEditPart) { - modelList - .add((BControl) ((BMSAbstractEditPart) obj).getModel()); - } - } - - execute(createBringToBottomStepCommand(modelList)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.command.BringToBottomStepCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.VisualizationPart; + +public class BringToBottomStepAction extends SelectionAction { + + public final static String ID = "de.bmotionstudio.gef.editor.action.bringToBottomStep"; + + public BringToBottomStepAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Bring to bottom (Step)"); + setToolTipText("Bring to bottom (Step)"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( + BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/uncaught_ovr_d.gif"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + List<?> selectedObjects = getSelectedObjects(); + if (selectedObjects.size() == 1) { + if (selectedObjects.get(0) instanceof VisualizationPart) { + return false; + } + } + return true; + } + + public BringToBottomStepCommand createBringToBottomStepCommand( + List<BControl> modelList) { + BringToBottomStepCommand command = new BringToBottomStepCommand(); + command.setControlList(modelList); + return command; + } + + public void run() { + + List<BControl> modelList = new ArrayList<BControl>(); + + List<?> selectedObjects = getSelectedObjects(); + + for (Object obj : selectedObjects) { + if (obj instanceof BMSAbstractEditPart) { + modelList + .add((BControl) ((BMSAbstractEditPart) obj).getModel()); + } + } + + execute(createBringToBottomStepCommand(modelList)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopAction.java index 9229eb4f691a049825ec7dc9050b06099308d75c..23509f94dd9d1c3d2242690c92f46b64712b8f9e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopAction.java @@ -1,74 +1,74 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.command.BringToTopCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.VisualizationPart; - -public class BringToTopAction extends SelectionAction { - - public final static String ID = "de.bmotionstudio.gef.editor.action.bringToTop"; - - public BringToTopAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Bring to top"); - setToolTipText("Bring to top"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin - .imageDescriptorFromPlugin(BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/caught_ovr.gif"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - List<?> selectedObjects = getSelectedObjects(); - if (selectedObjects.size() == 1) { - if (selectedObjects.get(0) instanceof VisualizationPart) { - return false; - } - } - return true; - } - - public BringToTopCommand createBringToTopCommand(List<BControl> controlList) { - BringToTopCommand command = new BringToTopCommand(); - command.setControlList(controlList); - return command; - } - - public void run() { - List<BControl> controlList = new ArrayList<BControl>(); - List<?> selectedObjects = getSelectedObjects(); - for (Object obj : selectedObjects) { - if (obj instanceof BMSAbstractEditPart) { - controlList.add((BControl) ((BMSAbstractEditPart) obj) - .getModel()); - } - } - execute(createBringToTopCommand(controlList)); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.command.BringToTopCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.VisualizationPart; + +public class BringToTopAction extends SelectionAction { + + public final static String ID = "de.bmotionstudio.gef.editor.action.bringToTop"; + + public BringToTopAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Bring to top"); + setToolTipText("Bring to top"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin + .imageDescriptorFromPlugin(BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/caught_ovr.gif"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + List<?> selectedObjects = getSelectedObjects(); + if (selectedObjects.size() == 1) { + if (selectedObjects.get(0) instanceof VisualizationPart) { + return false; + } + } + return true; + } + + public BringToTopCommand createBringToTopCommand(List<BControl> controlList) { + BringToTopCommand command = new BringToTopCommand(); + command.setControlList(controlList); + return command; + } + + public void run() { + List<BControl> controlList = new ArrayList<BControl>(); + List<?> selectedObjects = getSelectedObjects(); + for (Object obj : selectedObjects) { + if (obj instanceof BMSAbstractEditPart) { + controlList.add((BControl) ((BMSAbstractEditPart) obj) + .getModel()); + } + } + execute(createBringToTopCommand(controlList)); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopStepAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopStepAction.java index 588eb5e6a479eab8034c2cac5ddcba6036cb64a4..19da6546300684289f477bf8c82e3a2b08c48910 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopStepAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/BringToTopStepAction.java @@ -1,80 +1,80 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.command.BringToTopStepCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.VisualizationPart; - -public class BringToTopStepAction extends SelectionAction { - - public final static String ID = "de.bmotionstudio.gef.editor.action.bringToTopStep"; - - public BringToTopStepAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Bring to top (Step)"); - setToolTipText("Bring to top (Step)"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( - BMotionEditorPlugin.PLUGIN_ID, - "icons/eclipse16/uncaught_ovr.gif"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - List<?> selectedObjects = getSelectedObjects(); - if (selectedObjects.size() == 1) { - if (selectedObjects.get(0) instanceof VisualizationPart) { - return false; - } - } - return true; - } - - public BringToTopStepCommand createBringToTopStepCommand( - List<BControl> modelList) { - BringToTopStepCommand command = new BringToTopStepCommand(); - command.setControlList(modelList); - return command; - } - - public void run() { - - List<BControl> modelList = new ArrayList<BControl>(); - - List<?> selectedObjects = getSelectedObjects(); - - for (Object obj : selectedObjects) { - if (obj instanceof BMSAbstractEditPart) { - modelList - .add((BControl) ((BMSAbstractEditPart) obj).getModel()); - } - } - - execute(createBringToTopStepCommand(modelList)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.command.BringToTopStepCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.VisualizationPart; + +public class BringToTopStepAction extends SelectionAction { + + public final static String ID = "de.bmotionstudio.gef.editor.action.bringToTopStep"; + + public BringToTopStepAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Bring to top (Step)"); + setToolTipText("Bring to top (Step)"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( + BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/uncaught_ovr.gif"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + List<?> selectedObjects = getSelectedObjects(); + if (selectedObjects.size() == 1) { + if (selectedObjects.get(0) instanceof VisualizationPart) { + return false; + } + } + return true; + } + + public BringToTopStepCommand createBringToTopStepCommand( + List<BControl> modelList) { + BringToTopStepCommand command = new BringToTopStepCommand(); + command.setControlList(modelList); + return command; + } + + public void run() { + + List<BControl> modelList = new ArrayList<BControl>(); + + List<?> selectedObjects = getSelectedObjects(); + + for (Object obj : selectedObjects) { + if (obj instanceof BMSAbstractEditPart) { + modelList + .add((BControl) ((BMSAbstractEditPart) obj).getModel()); + } + } + + execute(createBringToTopStepCommand(modelList)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/CopyAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/CopyAction.java index d2e6dfdcccfaf7818c317c221d5f93b6fff237b3..8a9939d9fe39904a1fe3942bc8ad036f79e19aea 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/CopyAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/CopyAction.java @@ -1,85 +1,85 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; - -import de.bmotionstudio.gef.editor.command.CopyCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class CopyAction extends SelectionAction { - - public CopyAction(IWorkbenchPart part) { - super(part); - // force calculateEnabled() to be called in every context - setLazyEnablementCalculation(true); - } - - @Override - protected void init() { - super.init(); - ISharedImages sharedImages = PlatformUI.getWorkbench() - .getSharedImages(); - setText("Copy"); - setId(ActionFactory.COPY.getId()); - setHoverImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); - setImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); - setDisabledImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); - setEnabled(false); - } - - private Command createCopyCommand(List<Object> selectedObjects) { - if (selectedObjects == null || selectedObjects.isEmpty()) - return null; - CopyCommand cmd = new CopyCommand(); - Iterator<Object> it = selectedObjects.iterator(); - while (it.hasNext()) { - Object nextElement = it.next(); - if (nextElement instanceof EditPart) { - EditPart ep = (EditPart) nextElement; - if (ep.getModel() instanceof BControl) { - BControl node = (BControl) ep.getModel(); - if (cmd.isCopyableControl(node)) - cmd.addElement(node); - } - } - - } - return cmd; - } - - @SuppressWarnings("unchecked") - @Override - protected boolean calculateEnabled() { - Command cmd = createCopyCommand(getSelectedObjects()); - if (cmd == null) - return false; - return cmd.canExecute(); - } - - @SuppressWarnings("unchecked") - @Override - public void run() { - Command cmd = createCopyCommand(getSelectedObjects()); - if (cmd != null && cmd.canExecute()) { - cmd.execute(); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; + +import de.bmotionstudio.gef.editor.command.CopyCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class CopyAction extends SelectionAction { + + public CopyAction(IWorkbenchPart part) { + super(part); + // force calculateEnabled() to be called in every context + setLazyEnablementCalculation(true); + } + + @Override + protected void init() { + super.init(); + ISharedImages sharedImages = PlatformUI.getWorkbench() + .getSharedImages(); + setText("Copy"); + setId(ActionFactory.COPY.getId()); + setHoverImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); + setImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); + setDisabledImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); + setEnabled(false); + } + + private Command createCopyCommand(List<Object> selectedObjects) { + if (selectedObjects == null || selectedObjects.isEmpty()) + return null; + CopyCommand cmd = new CopyCommand(); + Iterator<Object> it = selectedObjects.iterator(); + while (it.hasNext()) { + Object nextElement = it.next(); + if (nextElement instanceof EditPart) { + EditPart ep = (EditPart) nextElement; + if (ep.getModel() instanceof BControl) { + BControl node = (BControl) ep.getModel(); + if (cmd.isCopyableControl(node)) + cmd.addElement(node); + } + } + + } + return cmd; + } + + @SuppressWarnings("unchecked") + @Override + protected boolean calculateEnabled() { + Command cmd = createCopyCommand(getSelectedObjects()); + if (cmd == null) + return false; + return cmd.canExecute(); + } + + @SuppressWarnings("unchecked") + @Override + public void run() { + Command cmd = createCopyCommand(getSelectedObjects()); + if (cmd != null && cmd.canExecute()) { + cmd.execute(); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/FitImageAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/FitImageAction.java index c0b1dd01618bf5766ae3e2c6e9f9aae8e8c35c47..04170a9a5359524e4d12acccce1dee41172965be 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/FitImageAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/FitImageAction.java @@ -1,146 +1,146 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.command.FitImageCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class FitImageAction extends SelectionAction { - - public final static String ID = "de.bmotionstudio.gef.editor.action.fitImage"; - - public FitImageAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Fit size to image"); - setToolTipText("Fit size to image"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_fitimage.png"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - List<?> selectedObjects = getSelectedObjects(); - for (Object obj : selectedObjects) { - if (obj instanceof EditPart) { - EditPart part = (EditPart) obj; - if (part.getModel() instanceof BControl) { - BControl bcontrol = (BControl) part.getModel(); - if (bcontrol - .getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE) != null) { - return true; - } - } - } - } - return false; - } - - public FitImageCommand createFitImageCommand(List<BControl> modelList, - Map<BControl, org.eclipse.draw2d.geometry.Rectangle> newSizeMap) { - FitImageCommand command = new FitImageCommand(); - command.setModelList(modelList); - command.setNewSizeMap(newSizeMap); - return command; - } - - public void run() { - - List<BControl> modelList = new ArrayList<BControl>(); - Map<BControl, org.eclipse.draw2d.geometry.Rectangle> newSizeMap = new HashMap<BControl, org.eclipse.draw2d.geometry.Rectangle>(); - - List<?> selectedObjects = getSelectedObjects(); - - for (Object obj : selectedObjects) { - - if (obj instanceof EditPart) { - - EditPart part = (EditPart) obj; - BControl control = (BControl) part.getModel(); - - Object imgAttribute = control - .getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE); - - if (imgAttribute != null) { - - String imagePath = control.getAttributeValue( - AttributeConstants.ATTRIBUTE_IMAGE).toString(); - - Rectangle imageBounds = null; - Image img = null; - - IFile pFile = control.getVisualization().getProjectFile(); - - if (pFile != null) { - final String myPath = (pFile.getProject().getLocation() - + "/images/" + imagePath).replace("file:", ""); - if (new File(myPath).exists() && imagePath.length() > 0) { - img = new Image(Display.getCurrent(), myPath); - imageBounds = img.getBounds(); - } - } - - if (imageBounds != null) { - - modelList.add(control); - newSizeMap - .put(control, - new org.eclipse.draw2d.geometry.Rectangle( - Integer.valueOf(control - .getAttributeValue( - AttributeConstants.ATTRIBUTE_X) - .toString()), - Integer.valueOf(control - .getAttributeValue( - AttributeConstants.ATTRIBUTE_Y) - .toString()), - imageBounds.width, - imageBounds.height)); - - } - - if (img != null) { - img.dispose(); - } - - } - - } - - } - - execute(createFitImageCommand(modelList, newSizeMap)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.command.FitImageCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class FitImageAction extends SelectionAction { + + public final static String ID = "de.bmotionstudio.gef.editor.action.fitImage"; + + public FitImageAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Fit size to image"); + setToolTipText("Fit size to image"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_fitimage.png"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + List<?> selectedObjects = getSelectedObjects(); + for (Object obj : selectedObjects) { + if (obj instanceof EditPart) { + EditPart part = (EditPart) obj; + if (part.getModel() instanceof BControl) { + BControl bcontrol = (BControl) part.getModel(); + if (bcontrol + .getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE) != null) { + return true; + } + } + } + } + return false; + } + + public FitImageCommand createFitImageCommand(List<BControl> modelList, + Map<BControl, org.eclipse.draw2d.geometry.Rectangle> newSizeMap) { + FitImageCommand command = new FitImageCommand(); + command.setModelList(modelList); + command.setNewSizeMap(newSizeMap); + return command; + } + + public void run() { + + List<BControl> modelList = new ArrayList<BControl>(); + Map<BControl, org.eclipse.draw2d.geometry.Rectangle> newSizeMap = new HashMap<BControl, org.eclipse.draw2d.geometry.Rectangle>(); + + List<?> selectedObjects = getSelectedObjects(); + + for (Object obj : selectedObjects) { + + if (obj instanceof EditPart) { + + EditPart part = (EditPart) obj; + BControl control = (BControl) part.getModel(); + + Object imgAttribute = control + .getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE); + + if (imgAttribute != null) { + + String imagePath = control.getAttributeValue( + AttributeConstants.ATTRIBUTE_IMAGE).toString(); + + Rectangle imageBounds = null; + Image img = null; + + IFile pFile = control.getVisualization().getProjectFile(); + + if (pFile != null) { + final String myPath = (pFile.getProject().getLocation() + + "/images/" + imagePath).replace("file:", ""); + if (new File(myPath).exists() && imagePath.length() > 0) { + img = new Image(Display.getCurrent(), myPath); + imageBounds = img.getBounds(); + } + } + + if (imageBounds != null) { + + modelList.add(control); + newSizeMap + .put(control, + new org.eclipse.draw2d.geometry.Rectangle( + Integer.valueOf(control + .getAttributeValue( + AttributeConstants.ATTRIBUTE_X) + .toString()), + Integer.valueOf(control + .getAttributeValue( + AttributeConstants.ATTRIBUTE_Y) + .toString()), + imageBounds.width, + imageBounds.height)); + + } + + if (img != null) { + img.dispose(); + } + + } + + } + + } + + execute(createFitImageCommand(modelList, newSizeMap)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java index 352e07a9d562a4e5c756458b55b1c9685741b7a4..20e1197ab3fa999549dd19a371bbc1ec28e6bac4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java @@ -1,183 +1,183 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.command.RemoveObserverCommand; -import de.bmotionstudio.gef.editor.command.SetObserverCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.prob.logging.Logger; - -public class OpenObserverAction extends SelectionAction { - - private String className; - - public OpenObserverAction(IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(true); - } - - @Override - protected void init() { - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - return true; - } - - @Override - public void run() { - - BControl actionControl = getControl(); - - if (actionControl != null) { - - Observer oldObserver = null; - Observer observer = getControl().getObserver(getClassName()); - - // If an observer does not exist, add one - if (observer == null) { - - try { - observer = (Observer) BMotionEditorPlugin - .getObserverExtension(getClassName()) - .createExecutableExtension("class"); - } catch (CoreException e) { - } - - } else { // else edit the current observer - - // therefore, clone the current observer, if the user aborts - // editing the current observer - try { - oldObserver = observer.clone(); - } catch (CloneNotSupportedException e) { - } - - } - - ObserverWizard wizard = observer.getWizard(actionControl); - - if (wizard != null) { - - BMotionObserverWizardDialog dialog = new BMotionObserverWizardDialog( - getWorkbenchPart(), wizard); - dialog.create(); - dialog.getShell().setSize(wizard.getSize()); - String title = "Observer: " + observer.getName() - + " Control: " + getControl().getID(); - wizard.setWindowTitle("BMotion Studio Observer Wizard"); - dialog.setTitle(title); - dialog.setMessage(observer.getDescription()); - dialog.setTitleImage(BMotionStudioImage - .getImage(BMotionStudioImage.IMG_LOGO_BMOTION64)); - int status = dialog.open(); - - // The user clicked on the "OK" button in order to confirm his - // changes on the observer - if (status == WizardDialog.OK) { - - // If the observer delete flag is set to true, delete the - // observer anyway - if (wizard.isObserverDelete()) { - RemoveObserverCommand cmd = createRemoveObserverCommand( - observer, actionControl); - execute(cmd); - } else { - SetObserverCommand cmd = createObserverSetCommand( - actionControl, observer, oldObserver); - execute(cmd); - } - - // else the user canceled his changes on the observer - } else if (status == WizardDialog.CANCEL) { - - // Reset observer without using a command! - if (oldObserver != null) - actionControl.getObservers().put(oldObserver.getID(), - oldObserver); - - // else the user clicked on the delete button in order to - // delete the observer - } else if (status == BMotionObserverWizardDialog.DELETE) { - RemoveObserverCommand cmd = createRemoveObserverCommand( - observer, actionControl); - execute(cmd); - } - - } else { - Logger.notifyUserWithoutBugreport("The Observer \"" - + observer.getName() - + "\" does not support a wizard."); - } - } - - } - - private RemoveObserverCommand createRemoveObserverCommand( - Observer observer, BControl control) { - RemoveObserverCommand cmd = new RemoveObserverCommand(); - cmd.setControl(control); - cmd.setObserver(observer); - return cmd; - } - - public SetObserverCommand createObserverSetCommand(BControl control, - Observer newObserver, Observer oldObserver) { - SetObserverCommand cmd = new SetObserverCommand(); - cmd.setNewObserver(newObserver); - cmd.setOldObserver(oldObserver); - cmd.setControl(control); - return cmd; - } - - public SetObserverCommand createObserverSetCommand(BControl control, - Observer newObserver) { - return createObserverSetCommand(control, newObserver, null); - } - - public void setClassName(String className) { - this.className = className; - } - - public String getClassName() { - return className; - } - - protected BControl getControl() { - - List<?> objects = getSelectedObjects(); - - if (objects.isEmpty()) - return null; - - if ((objects.get(0) instanceof EditPart)) { - EditPart part = (EditPart) objects.get(0); - BControl control = null; - if (part.getModel() instanceof BControl) - control = (BControl) part.getModel(); - return control; - } - - return null; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.command.RemoveObserverCommand; +import de.bmotionstudio.gef.editor.command.SetObserverCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.prob.logging.Logger; + +public class OpenObserverAction extends SelectionAction { + + private String className; + + public OpenObserverAction(IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(true); + } + + @Override + protected void init() { + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + return true; + } + + @Override + public void run() { + + BControl actionControl = getControl(); + + if (actionControl != null) { + + Observer oldObserver = null; + Observer observer = getControl().getObserver(getClassName()); + + // If an observer does not exist, add one + if (observer == null) { + + try { + observer = (Observer) BMotionEditorPlugin + .getObserverExtension(getClassName()) + .createExecutableExtension("class"); + } catch (CoreException e) { + } + + } else { // else edit the current observer + + // therefore, clone the current observer, if the user aborts + // editing the current observer + try { + oldObserver = observer.clone(); + } catch (CloneNotSupportedException e) { + } + + } + + ObserverWizard wizard = observer.getWizard(actionControl); + + if (wizard != null) { + + BMotionObserverWizardDialog dialog = new BMotionObserverWizardDialog( + getWorkbenchPart(), wizard); + dialog.create(); + dialog.getShell().setSize(wizard.getSize()); + String title = "Observer: " + observer.getName() + + " Control: " + getControl().getID(); + wizard.setWindowTitle("BMotion Studio Observer Wizard"); + dialog.setTitle(title); + dialog.setMessage(observer.getDescription()); + dialog.setTitleImage(BMotionStudioImage + .getImage(BMotionStudioImage.IMG_LOGO_BMOTION64)); + int status = dialog.open(); + + // The user clicked on the "OK" button in order to confirm his + // changes on the observer + if (status == WizardDialog.OK) { + + // If the observer delete flag is set to true, delete the + // observer anyway + if (wizard.isObserverDelete()) { + RemoveObserverCommand cmd = createRemoveObserverCommand( + observer, actionControl); + execute(cmd); + } else { + SetObserverCommand cmd = createObserverSetCommand( + actionControl, observer, oldObserver); + execute(cmd); + } + + // else the user canceled his changes on the observer + } else if (status == WizardDialog.CANCEL) { + + // Reset observer without using a command! + if (oldObserver != null) + actionControl.getObservers().put(oldObserver.getID(), + oldObserver); + + // else the user clicked on the delete button in order to + // delete the observer + } else if (status == BMotionObserverWizardDialog.DELETE) { + RemoveObserverCommand cmd = createRemoveObserverCommand( + observer, actionControl); + execute(cmd); + } + + } else { + Logger.notifyUserWithoutBugreport("The Observer \"" + + observer.getName() + + "\" does not support a wizard."); + } + } + + } + + private RemoveObserverCommand createRemoveObserverCommand( + Observer observer, BControl control) { + RemoveObserverCommand cmd = new RemoveObserverCommand(); + cmd.setControl(control); + cmd.setObserver(observer); + return cmd; + } + + public SetObserverCommand createObserverSetCommand(BControl control, + Observer newObserver, Observer oldObserver) { + SetObserverCommand cmd = new SetObserverCommand(); + cmd.setNewObserver(newObserver); + cmd.setOldObserver(oldObserver); + cmd.setControl(control); + return cmd; + } + + public SetObserverCommand createObserverSetCommand(BControl control, + Observer newObserver) { + return createObserverSetCommand(control, newObserver, null); + } + + public void setClassName(String className) { + this.className = className; + } + + public String getClassName() { + return className; + } + + protected BControl getControl() { + + List<?> objects = getSelectedObjects(); + + if (objects.isEmpty()) + return null; + + if ((objects.get(0) instanceof EditPart)) { + EditPart part = (EditPart) objects.get(0); + BControl control = null; + if (part.getModel() instanceof BControl) + control = (BControl) part.getModel(); + return control; + } + + return null; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java index dff15928f5b8e190611a5eaba4c8f43eff2ef959..cf5b463c09ec1749919bad45bf2d1ea3a5bbd6aa 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java @@ -1,174 +1,174 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.command.SchedulerEventCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; -import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; -import de.prob.logging.Logger; - -public class OpenSchedulerEventAction extends SelectionAction { - - private String className; - private String eventID; - private SchedulerEvent clonedSchedulerEvent; - - public OpenSchedulerEventAction(IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(true); - } - - protected void init() { - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - return true; - } - - public void run() { - - BControl bcontrol = getControl(); - clonedSchedulerEvent = null; - - if (bcontrol != null) { - - SchedulerEvent newSchedulerEvent = bcontrol.getEvent(getEventID()); - - // Add Scheduler Event - if (newSchedulerEvent == null) { - - try { - newSchedulerEvent = (SchedulerEvent) BMotionEditorPlugin - .getSchedulerExtension(getClassName()) - .createExecutableExtension("class"); - } catch (CoreException e) { - } - - } else { // Edit Scheduler Event - - // Clone Scheduler Event - try { - clonedSchedulerEvent = newSchedulerEvent.clone(); - } catch (CloneNotSupportedException e) { - } - - } - - if (newSchedulerEvent != null) { - - newSchedulerEvent.setEventID(getEventID()); - SchedulerWizard wizard = newSchedulerEvent.getWizard(bcontrol); - - if (wizard != null) { - - BMotionSchedulerEventWizardDialog dialog = new BMotionSchedulerEventWizardDialog( - getWorkbenchPart(), wizard); - dialog.create(); - dialog.getShell().setSize(wizard.getSize()); - String title = "Scheduler Event: " - + newSchedulerEvent.getName() - + " Control: " - + bcontrol - .getAttributeValue(AttributeConstants.ATTRIBUTE_ID); - wizard.setWindowTitle("BMotion Studio Scheduler Event Wizard"); - dialog.setTitle(title); - dialog.setMessage(newSchedulerEvent.getDescription()); - dialog.setTitleImage(BMotionStudioImage - .getImage(BMotionStudioImage.IMG_LOGO_BMOTION64)); - int status = dialog.open(); - - if (status == WizardDialog.OK) { - - SchedulerEventCommand schedulerEventCommand = createSchedulerEventCommand(); - schedulerEventCommand - .setNewSchedulerEvent(newSchedulerEvent); - - if (wizard.isEventDelete()) { - - RemoveSchedulerEventAction action = new RemoveSchedulerEventAction( - getWorkbenchPart()); - action.setControl(getControl()); - action.setSchedulerEvent(clonedSchedulerEvent); - action.run(); - - } else { - if (clonedSchedulerEvent != null) { - schedulerEventCommand - .setClonedSchedulerEvent(clonedSchedulerEvent); - } - execute(schedulerEventCommand); - } - - } else if (status == WizardDialog.CANCEL) { - if (clonedSchedulerEvent != null) - bcontrol.addEvent(getEventID(), - clonedSchedulerEvent); - } - - } else { - Logger.notifyUserWithoutBugreport("The Scheduler Event \"" - + newSchedulerEvent.getName() - + "\" does not support a wizard."); - } - - } else { - // TODO: Error message?! - } - - } - - } - - public SchedulerEventCommand createSchedulerEventCommand() { - SchedulerEventCommand command = new SchedulerEventCommand(); - command.setClassName(getClassName()); - command.setEventID(getEventID()); - command.setControl(getControl()); - return command; - } - - public void setClassName(String className) { - this.className = className; - } - - public String getClassName() { - return this.className; - } - - public void setEventID(String eventID) { - this.eventID = eventID; - } - - public String getEventID() { - return eventID; - } - - protected BControl getControl() { - List<?> objects = getSelectedObjects(); - if (objects.isEmpty()) - return null; - if (!(objects.get(0) instanceof EditPart)) - return null; - EditPart part = (EditPart) objects.get(0); - return (BControl) part.getModel(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.command.SchedulerEventCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; +import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; +import de.prob.logging.Logger; + +public class OpenSchedulerEventAction extends SelectionAction { + + private String className; + private String eventID; + private SchedulerEvent clonedSchedulerEvent; + + public OpenSchedulerEventAction(IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(true); + } + + protected void init() { + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + return true; + } + + public void run() { + + BControl bcontrol = getControl(); + clonedSchedulerEvent = null; + + if (bcontrol != null) { + + SchedulerEvent newSchedulerEvent = bcontrol.getEvent(getEventID()); + + // Add Scheduler Event + if (newSchedulerEvent == null) { + + try { + newSchedulerEvent = (SchedulerEvent) BMotionEditorPlugin + .getSchedulerExtension(getClassName()) + .createExecutableExtension("class"); + } catch (CoreException e) { + } + + } else { // Edit Scheduler Event + + // Clone Scheduler Event + try { + clonedSchedulerEvent = newSchedulerEvent.clone(); + } catch (CloneNotSupportedException e) { + } + + } + + if (newSchedulerEvent != null) { + + newSchedulerEvent.setEventID(getEventID()); + SchedulerWizard wizard = newSchedulerEvent.getWizard(bcontrol); + + if (wizard != null) { + + BMotionSchedulerEventWizardDialog dialog = new BMotionSchedulerEventWizardDialog( + getWorkbenchPart(), wizard); + dialog.create(); + dialog.getShell().setSize(wizard.getSize()); + String title = "Scheduler Event: " + + newSchedulerEvent.getName() + + " Control: " + + bcontrol + .getAttributeValue(AttributeConstants.ATTRIBUTE_ID); + wizard.setWindowTitle("BMotion Studio Scheduler Event Wizard"); + dialog.setTitle(title); + dialog.setMessage(newSchedulerEvent.getDescription()); + dialog.setTitleImage(BMotionStudioImage + .getImage(BMotionStudioImage.IMG_LOGO_BMOTION64)); + int status = dialog.open(); + + if (status == WizardDialog.OK) { + + SchedulerEventCommand schedulerEventCommand = createSchedulerEventCommand(); + schedulerEventCommand + .setNewSchedulerEvent(newSchedulerEvent); + + if (wizard.isEventDelete()) { + + RemoveSchedulerEventAction action = new RemoveSchedulerEventAction( + getWorkbenchPart()); + action.setControl(getControl()); + action.setSchedulerEvent(clonedSchedulerEvent); + action.run(); + + } else { + if (clonedSchedulerEvent != null) { + schedulerEventCommand + .setClonedSchedulerEvent(clonedSchedulerEvent); + } + execute(schedulerEventCommand); + } + + } else if (status == WizardDialog.CANCEL) { + if (clonedSchedulerEvent != null) + bcontrol.addEvent(getEventID(), + clonedSchedulerEvent); + } + + } else { + Logger.notifyUserWithoutBugreport("The Scheduler Event \"" + + newSchedulerEvent.getName() + + "\" does not support a wizard."); + } + + } else { + // TODO: Error message?! + } + + } + + } + + public SchedulerEventCommand createSchedulerEventCommand() { + SchedulerEventCommand command = new SchedulerEventCommand(); + command.setClassName(getClassName()); + command.setEventID(getEventID()); + command.setControl(getControl()); + return command; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getClassName() { + return this.className; + } + + public void setEventID(String eventID) { + this.eventID = eventID; + } + + public String getEventID() { + return eventID; + } + + protected BControl getControl() { + List<?> objects = getSelectedObjects(); + if (objects.isEmpty()) + return null; + if (!(objects.get(0) instanceof EditPart)) + return null; + EditPart part = (EditPart) objects.get(0); + return (BControl) part.getModel(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/PasteAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/PasteAction.java index 35515085d31c1b240a6a825ad2569579997f7f91..1619bfb35a1e518105c6d071407d1377c44e9c43 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/PasteAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/PasteAction.java @@ -1,82 +1,82 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; - -import de.bmotionstudio.gef.editor.command.PasteCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class PasteAction extends SelectionAction { - - public PasteAction(IWorkbenchPart part) { - super(part); - // force calculateEnabled() to be called in every context - setLazyEnablementCalculation(true); - } - - protected void init() { - super.init(); - ISharedImages sharedImages = PlatformUI.getWorkbench() - .getSharedImages(); - setText("Paste"); - setId(ActionFactory.PASTE.getId()); - setHoverImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); - setImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); - setDisabledImageDescriptor(sharedImages - .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); - setEnabled(false); - } - - private PasteCommand createPasteCommand(List<Object> selectedObjects) { - - PasteCommand cmd = new PasteCommand(); - - Iterator<Object> it = selectedObjects.iterator(); - while (it.hasNext()) { - Object nextElement = it.next(); - if (nextElement instanceof EditPart) { - EditPart ep = (EditPart) nextElement; - if (ep.getModel() instanceof BControl) { - BControl node = (BControl) ep.getModel(); - if (cmd.isContainer(node)) - cmd.addElement(node); - } - } - } - - return cmd; - - } - - @SuppressWarnings("unchecked") - @Override - protected boolean calculateEnabled() { - Command command = createPasteCommand(getSelectedObjects()); - return command != null && command.canExecute(); - } - - @SuppressWarnings("unchecked") - @Override - public void run() { - PasteCommand command = createPasteCommand(getSelectedObjects()); - if (command != null && command.canExecute()) - execute(command); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; + +import de.bmotionstudio.gef.editor.command.PasteCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class PasteAction extends SelectionAction { + + public PasteAction(IWorkbenchPart part) { + super(part); + // force calculateEnabled() to be called in every context + setLazyEnablementCalculation(true); + } + + protected void init() { + super.init(); + ISharedImages sharedImages = PlatformUI.getWorkbench() + .getSharedImages(); + setText("Paste"); + setId(ActionFactory.PASTE.getId()); + setHoverImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); + setImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); + setDisabledImageDescriptor(sharedImages + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); + setEnabled(false); + } + + private PasteCommand createPasteCommand(List<Object> selectedObjects) { + + PasteCommand cmd = new PasteCommand(); + + Iterator<Object> it = selectedObjects.iterator(); + while (it.hasNext()) { + Object nextElement = it.next(); + if (nextElement instanceof EditPart) { + EditPart ep = (EditPart) nextElement; + if (ep.getModel() instanceof BControl) { + BControl node = (BControl) ep.getModel(); + if (cmd.isContainer(node)) + cmd.addElement(node); + } + } + } + + return cmd; + + } + + @SuppressWarnings("unchecked") + @Override + protected boolean calculateEnabled() { + Command command = createPasteCommand(getSelectedObjects()); + return command != null && command.canExecute(); + } + + @SuppressWarnings("unchecked") + @Override + public void run() { + PasteCommand command = createPasteCommand(getSelectedObjects()); + if (command != null && command.canExecute()) + execute(command); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveObserverAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveObserverAction.java index 8474eccb6a34aef526df013fabb298dbeae5cbf2..c4eeeb3db7c0eb53c038e0a6b9f003c8b526183a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveObserverAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveObserverAction.java @@ -1,50 +1,50 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.gef.ui.actions.WorkbenchPartAction; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.command.RemoveObserverCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; - -public class RemoveObserverAction extends WorkbenchPartAction { - - private Observer observer; - private BControl control; - - public RemoveObserverAction(IWorkbenchPart workbenchPart) { - super(workbenchPart); - } - - @Override - protected boolean calculateEnabled() { - return true; - } - - public void run() { - execute(createRemoveObserverCommand()); - } - - public RemoveObserverCommand createRemoveObserverCommand() { - RemoveObserverCommand command = new RemoveObserverCommand(); - command.setControl(this.control); - command.setObserver(this.observer); - return command; - } - - public void setControl(BControl control) { - this.control = control; - - } - - public void setObserver(Observer observer) { - this.observer = observer; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.gef.ui.actions.WorkbenchPartAction; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.command.RemoveObserverCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; + +public class RemoveObserverAction extends WorkbenchPartAction { + + private Observer observer; + private BControl control; + + public RemoveObserverAction(IWorkbenchPart workbenchPart) { + super(workbenchPart); + } + + @Override + protected boolean calculateEnabled() { + return true; + } + + public void run() { + execute(createRemoveObserverCommand()); + } + + public RemoveObserverCommand createRemoveObserverCommand() { + RemoveObserverCommand command = new RemoveObserverCommand(); + command.setControl(this.control); + command.setObserver(this.observer); + return command; + } + + public void setControl(BControl control) { + this.control = control; + + } + + public void setObserver(Observer observer) { + this.observer = observer; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveSchedulerEventAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveSchedulerEventAction.java index 04d00c4216cb2721d1b044cd3f9826a1b4709d3c..20a2d6f569a9cb57a3d03a938d2ae0dc04422e55 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveSchedulerEventAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RemoveSchedulerEventAction.java @@ -1,50 +1,50 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.gef.ui.actions.WorkbenchPartAction; -import org.eclipse.ui.IWorkbenchPart; - -import de.bmotionstudio.gef.editor.command.RemoveSchedulerEventCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public class RemoveSchedulerEventAction extends WorkbenchPartAction { - - private SchedulerEvent schedulerEvent; - private BControl control; - - public RemoveSchedulerEventAction(IWorkbenchPart workbenchPart) { - super(workbenchPart); - } - - @Override - protected boolean calculateEnabled() { - return true; - } - - public void run() { - execute(createRemoveSchedulerEventCommand()); - } - - public RemoveSchedulerEventCommand createRemoveSchedulerEventCommand() { - RemoveSchedulerEventCommand command = new RemoveSchedulerEventCommand(); - command.setControl(this.control); - command.setSchedulerEvent(this.schedulerEvent); - return command; - } - - public void setControl(BControl control) { - this.control = control; - - } - - public void setSchedulerEvent(SchedulerEvent schedulerEvent) { - this.schedulerEvent = schedulerEvent; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.gef.ui.actions.WorkbenchPartAction; +import org.eclipse.ui.IWorkbenchPart; + +import de.bmotionstudio.gef.editor.command.RemoveSchedulerEventCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public class RemoveSchedulerEventAction extends WorkbenchPartAction { + + private SchedulerEvent schedulerEvent; + private BControl control; + + public RemoveSchedulerEventAction(IWorkbenchPart workbenchPart) { + super(workbenchPart); + } + + @Override + protected boolean calculateEnabled() { + return true; + } + + public void run() { + execute(createRemoveSchedulerEventCommand()); + } + + public RemoveSchedulerEventCommand createRemoveSchedulerEventCommand() { + RemoveSchedulerEventCommand command = new RemoveSchedulerEventCommand(); + command.setControl(this.control); + command.setSchedulerEvent(this.schedulerEvent); + return command; + } + + public void setControl(BControl control) { + this.control = control; + + } + + public void setSchedulerEvent(SchedulerEvent schedulerEvent) { + this.schedulerEvent = schedulerEvent; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameAction.java index 080cadb502769b19452c9593a5c1acab8c2a7cff..3f3fa1860d09d120c998fc24767c87b642783d19 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameAction.java @@ -1,102 +1,102 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import java.util.HashMap; -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.model.BControl; - -public class RenameAction extends SelectionAction { - - public final static String ID = ActionFactory.RENAME.getId(); - - public RenameAction(final IWorkbenchPart part) { - super(part); - setLazyEnablementCalculation(false); - } - - protected void init() { - setText("Rename..."); - setToolTipText("Rename"); - setId(ID); - ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( - BMotionEditorPlugin.PLUGIN_ID, "icons/icon_rename.png"); - if (icon != null) { - setImageDescriptor(icon); - } - setEnabled(false); - } - - @Override - protected boolean calculateEnabled() { - Command cmd = createRenameCommand(""); - if (cmd == null) { - return false; - } - return true; - } - - public Command createRenameCommand(final String name) { - Request renameReq = new Request("rename"); - - HashMap<String, String> reqData = new HashMap<String, String>(); - reqData.put("newName", name); - renameReq.setExtendedData(reqData); - - if (getSelectedObjects().size() > 0) { - if (getSelectedObjects().get(0) instanceof EditPart) { - EditPart object = (EditPart) getSelectedObjects().get(0); - Command cmd = object.getCommand(renameReq); - return cmd; - } - } - - return null; - } - - public void run() { - BControl bcontrol = getSelectedBControl(); - RenameWizard wizard = new RenameWizard(bcontrol.getAttributeValue( - AttributeConstants.ATTRIBUTE_TEXT).toString()); - WizardDialog dialog = new WizardDialog(getWorkbenchPart().getSite() - .getShell(), wizard); - dialog.create(); - dialog.getShell().setSize(400, 315); - dialog.getShell().setText("BMotion Studio Rename Wizard"); - - if (dialog.open() == WizardDialog.OK) { - String name = wizard.getRenameValue(); - execute(createRenameCommand(name)); - } - } - - private BControl getSelectedBControl() { - List<?> objects = getSelectedObjects(); - if (objects.isEmpty()) { - return null; - } - if (!(objects.get(0) instanceof EditPart)) { - return null; - } - EditPart part = (EditPart) objects.get(0); - return (BControl) part.getModel(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import java.util.HashMap; +import java.util.List; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.ui.actions.SelectionAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.model.BControl; + +public class RenameAction extends SelectionAction { + + public final static String ID = ActionFactory.RENAME.getId(); + + public RenameAction(final IWorkbenchPart part) { + super(part); + setLazyEnablementCalculation(false); + } + + protected void init() { + setText("Rename..."); + setToolTipText("Rename"); + setId(ID); + ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( + BMotionEditorPlugin.PLUGIN_ID, "icons/icon_rename.png"); + if (icon != null) { + setImageDescriptor(icon); + } + setEnabled(false); + } + + @Override + protected boolean calculateEnabled() { + Command cmd = createRenameCommand(""); + if (cmd == null) { + return false; + } + return true; + } + + public Command createRenameCommand(final String name) { + Request renameReq = new Request("rename"); + + HashMap<String, String> reqData = new HashMap<String, String>(); + reqData.put("newName", name); + renameReq.setExtendedData(reqData); + + if (getSelectedObjects().size() > 0) { + if (getSelectedObjects().get(0) instanceof EditPart) { + EditPart object = (EditPart) getSelectedObjects().get(0); + Command cmd = object.getCommand(renameReq); + return cmd; + } + } + + return null; + } + + public void run() { + BControl bcontrol = getSelectedBControl(); + RenameWizard wizard = new RenameWizard(bcontrol.getAttributeValue( + AttributeConstants.ATTRIBUTE_TEXT).toString()); + WizardDialog dialog = new WizardDialog(getWorkbenchPart().getSite() + .getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(400, 315); + dialog.getShell().setText("BMotion Studio Rename Wizard"); + + if (dialog.open() == WizardDialog.OK) { + String name = wizard.getRenameValue(); + execute(createRenameCommand(name)); + } + } + + private BControl getSelectedBControl() { + List<?> objects = getSelectedObjects(); + if (objects.isEmpty()) { + return null; + } + if (!(objects.get(0) instanceof EditPart)) { + return null; + } + EditPart part = (EditPart) objects.get(0); + return (BControl) part.getModel(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameWizard.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameWizard.java index 34c95998316f8cf40ae8974e4b34245682a88989..aba4d4c603eef90875c121934b29f6095c579a13 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameWizard.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/RenameWizard.java @@ -1,72 +1,72 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.action; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class RenameWizard extends Wizard { - - private class RenamePage extends WizardPage { - - public Text nameText; - - public RenamePage(final String pageName) { - super(pageName); - setTitle("BMotion Studio Rename Wizard"); - setDescription("Rename a control"); - } - - public void createControl(final Composite parent) { - - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - - Label lab = new Label(composite, SWT.NONE); - lab.setText("Rename to: "); - lab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.heightHint = 90; - - nameText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); - nameText.setText(oldName); - nameText.setLayoutData(gd); - - setControl(composite); - - } - - } - - private final String oldName; - private String newName; - - public RenameWizard(final String oldName) { - this.oldName = oldName; - this.newName = null; - addPage(new RenamePage("MyRenamePage")); - } - - @Override - public boolean performFinish() { - RenamePage page = (RenamePage) getPage("MyRenamePage"); - newName = page.nameText.getText(); - return true; - } - - public String getRenameValue() { - return newName; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.action; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class RenameWizard extends Wizard { + + private class RenamePage extends WizardPage { + + public Text nameText; + + public RenamePage(final String pageName) { + super(pageName); + setTitle("BMotion Studio Rename Wizard"); + setDescription("Rename a control"); + } + + public void createControl(final Composite parent) { + + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(2, false)); + + Label lab = new Label(composite, SWT.NONE); + lab.setText("Rename to: "); + lab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.heightHint = 90; + + nameText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); + nameText.setText(oldName); + nameText.setLayoutData(gd); + + setControl(composite); + + } + + } + + private final String oldName; + private String newName; + + public RenameWizard(final String oldName) { + this.oldName = oldName; + this.newName = null; + addPage(new RenamePage("MyRenamePage")); + } + + @Override + public boolean performFinish() { + RenamePage page = (RenamePage) getPage("MyRenamePage"); + newName = page.nameText.getText(); + return true; + } + + public String getRenameValue() { + return newName; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java index b267dcac6b7cfb1b3521e9a7d086dc8e9e8a685f..e12ab5f33bf69d5fdb9ff4c4107a7bc68232bcf8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java @@ -1,212 +1,212 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * - * Represents an attribute of a {@link BControl}. - * - * @author Lukas Ladenberger - * - */ -public abstract class AbstractAttribute implements IPropertySource, Cloneable { - - public static final String ROOT = "de.bmotionstudio.gef.editor.attribute.BAttributeRoot"; - - private transient HashMap<String, AbstractAttribute> children; - private transient BControl control; - private transient PropertyDescriptor propertyDescriptor; - private transient Object initValue; - private transient Object defaultValue; - private transient boolean editable; - private transient boolean show; - private transient String group; - - // The current value of the attribute - private Object value; - - public AbstractAttribute(Object value) { - this.value = value; - this.defaultValue = value; - this.group = AttributeConstants.ATTRIBUTE_MISC; - this.editable = true; - this.show = true; - } - - private Object readResolve() { - this.initValue = this.value; - return this; - } - - public void addChild(AbstractAttribute atr) { - getChildren().put(atr.getID(), atr); - } - - public Boolean hasChildren() { - return !getChildren().isEmpty(); - } - - public PropertyDescriptor getPropertyDescriptor() { - propertyDescriptor = new PropertyDescriptor(getID(), getName()); - if (isEditable()) { - propertyDescriptor = preparePropertyDescriptor(); - if (propertyDescriptor != null) { - propertyDescriptor.setValidator(new ICellEditorValidator() { - public String isValid(Object value) { - return validateValue(value, control); - } - }); - } - } - return propertyDescriptor; - } - - protected abstract PropertyDescriptor preparePropertyDescriptor(); - - public Object unmarshal(String s) { - return s; - } - - public String getID() { - return getClass().getName(); - } - - public abstract String getName(); - - public void setGroup(AbstractAttribute group) { - setGroup(group.getClass().getName()); - } - - public void setGroup(String group) { - this.group = group; - } - - public String getGroup() { - return group; - } - - public Object getEditableValue() { - return this; - } - - public IPropertyDescriptor[] getPropertyDescriptors() { - ArrayList<IPropertyDescriptor> descriptor = new ArrayList<IPropertyDescriptor>(); - for (AbstractAttribute atr : getChildren().values()) { - descriptor.add(atr.getPropertyDescriptor()); - } - return descriptor.toArray(new IPropertyDescriptor[0]); - } - - public Object getPropertyValue(Object attrID) { - AbstractAttribute atr = getChildren().get(attrID); - if (atr.hasChildren()) { - return atr; - } else { - return atr.getValue(); - } - } - - public boolean isPropertySet(Object id) { - return false; - } - - public void resetPropertyValue(Object id) { - } - - public void setPropertyValue(Object id, Object value) { - AbstractAttribute atr = children.get(id); - atr.setValue(value); - } - - public void setValue(Object value) { - setValue(value, true, true); - } - - public void setValue(Object value, Boolean firePropertyChange, - Boolean setInitVal) { - Object oldVal = this.value; - this.value = value; - if (setInitVal) - this.initValue = value; - if (firePropertyChange && control != null) - control.getListeners().firePropertyChange(getID(), oldVal, value); - } - - public void restoreValue() { - Object oldVal = this.value; - this.value = this.initValue; - if (control != null) - control.getListeners().firePropertyChange(getID(), oldVal, value); - } - - public Object getValue() { - return this.value; - } - - public Object getInitValue() { - return initValue; - } - - public HashMap<String, AbstractAttribute> getChildren() { - if (children == null) - children = new HashMap<String, AbstractAttribute>(); - return children; - } - - @Override - public AbstractAttribute clone() throws CloneNotSupportedException { - return (AbstractAttribute) super.clone(); - } - - public void setEditable(boolean editable) { - this.editable = editable; - } - - public boolean isEditable() { - return editable; - } - - public String validateValue(Object value, BControl control) { - return null; - } - - public void setShow(boolean show) { - this.show = show; - } - - public boolean show() { - return show; - } - - public BControl getControl() { - return control; - } - - public void setControl(BControl control) { - this.control = control; - } - - public Object getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * + * Represents an attribute of a {@link BControl}. + * + * @author Lukas Ladenberger + * + */ +public abstract class AbstractAttribute implements IPropertySource, Cloneable { + + public static final String ROOT = "de.bmotionstudio.gef.editor.attribute.BAttributeRoot"; + + private transient HashMap<String, AbstractAttribute> children; + private transient BControl control; + private transient PropertyDescriptor propertyDescriptor; + private transient Object initValue; + private transient Object defaultValue; + private transient boolean editable; + private transient boolean show; + private transient String group; + + // The current value of the attribute + private Object value; + + public AbstractAttribute(Object value) { + this.value = value; + this.defaultValue = value; + this.group = AttributeConstants.ATTRIBUTE_MISC; + this.editable = true; + this.show = true; + } + + private Object readResolve() { + this.initValue = this.value; + return this; + } + + public void addChild(AbstractAttribute atr) { + getChildren().put(atr.getID(), atr); + } + + public Boolean hasChildren() { + return !getChildren().isEmpty(); + } + + public PropertyDescriptor getPropertyDescriptor() { + propertyDescriptor = new PropertyDescriptor(getID(), getName()); + if (isEditable()) { + propertyDescriptor = preparePropertyDescriptor(); + if (propertyDescriptor != null) { + propertyDescriptor.setValidator(new ICellEditorValidator() { + public String isValid(Object value) { + return validateValue(value, control); + } + }); + } + } + return propertyDescriptor; + } + + protected abstract PropertyDescriptor preparePropertyDescriptor(); + + public Object unmarshal(String s) { + return s; + } + + public String getID() { + return getClass().getName(); + } + + public abstract String getName(); + + public void setGroup(AbstractAttribute group) { + setGroup(group.getClass().getName()); + } + + public void setGroup(String group) { + this.group = group; + } + + public String getGroup() { + return group; + } + + public Object getEditableValue() { + return this; + } + + public IPropertyDescriptor[] getPropertyDescriptors() { + ArrayList<IPropertyDescriptor> descriptor = new ArrayList<IPropertyDescriptor>(); + for (AbstractAttribute atr : getChildren().values()) { + descriptor.add(atr.getPropertyDescriptor()); + } + return descriptor.toArray(new IPropertyDescriptor[0]); + } + + public Object getPropertyValue(Object attrID) { + AbstractAttribute atr = getChildren().get(attrID); + if (atr.hasChildren()) { + return atr; + } else { + return atr.getValue(); + } + } + + public boolean isPropertySet(Object id) { + return false; + } + + public void resetPropertyValue(Object id) { + } + + public void setPropertyValue(Object id, Object value) { + AbstractAttribute atr = children.get(id); + atr.setValue(value); + } + + public void setValue(Object value) { + setValue(value, true, true); + } + + public void setValue(Object value, Boolean firePropertyChange, + Boolean setInitVal) { + Object oldVal = this.value; + this.value = value; + if (setInitVal) + this.initValue = value; + if (firePropertyChange && control != null) + control.getListeners().firePropertyChange(getID(), oldVal, value); + } + + public void restoreValue() { + Object oldVal = this.value; + this.value = this.initValue; + if (control != null) + control.getListeners().firePropertyChange(getID(), oldVal, value); + } + + public Object getValue() { + return this.value; + } + + public Object getInitValue() { + return initValue; + } + + public HashMap<String, AbstractAttribute> getChildren() { + if (children == null) + children = new HashMap<String, AbstractAttribute>(); + return children; + } + + @Override + public AbstractAttribute clone() throws CloneNotSupportedException { + return (AbstractAttribute) super.clone(); + } + + public void setEditable(boolean editable) { + this.editable = editable; + } + + public boolean isEditable() { + return editable; + } + + public String validateValue(Object value, BControl control) { + return null; + } + + public void setShow(boolean show) { + this.show = show; + } + + public boolean show() { + return show; + } + + public BControl getControl() { + return control; + } + + public void setControl(BControl control) { + this.control = control; + } + + public Object getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeBlocks.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeBlocks.java index c8bc0a271d4bbad53892d0fb4de6ef0d36efc7bd..fc909432782f26a2781ace883fe198f7402dc0db 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeBlocks.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeBlocks.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class AttributeBlocks extends AbstractAttribute { - - public AttributeBlocks(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Blocks"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class AttributeBlocks extends AbstractAttribute { + + public AttributeBlocks(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Blocks"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillColor.java index bf60950d26341e9d1d227aa21506c31f0d1041ca..3830b106f3cee29637a18df40f18378f8c5d443d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillColor.java @@ -1,48 +1,48 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.views.properties.ColorPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - - -public class AttributeFillColor extends AbstractAttribute { - - public AttributeFillColor(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new ColorPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Fill-Color"; - } - - @Override - public Object unmarshal(String s) { - - String colorStr = s.toLowerCase().replace(" ", ""); - colorStr = colorStr.replace("rgb", ""); - colorStr = colorStr.replace("}", ""); - colorStr = colorStr.replace("{", ""); - String[] str = String.valueOf(colorStr).split("\\,"); - if (str.length == 3) { - int red = Integer.valueOf(str[0]); - int green = Integer.valueOf(str[1]); - int blue = Integer.valueOf(str[2]); - return new RGB(red, green, blue); - } else { - return new RGB(192, 192, 192); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.views.properties.ColorPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + + +public class AttributeFillColor extends AbstractAttribute { + + public AttributeFillColor(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new ColorPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Fill-Color"; + } + + @Override + public Object unmarshal(String s) { + + String colorStr = s.toLowerCase().replace(" ", ""); + colorStr = colorStr.replace("rgb", ""); + colorStr = colorStr.replace("}", ""); + colorStr = colorStr.replace("{", ""); + String[] str = String.valueOf(colorStr).split("\\,"); + if (str.length == 3) { + int red = Integer.valueOf(str[0]); + int green = Integer.valueOf(str[1]); + int blue = Integer.valueOf(str[2]); + return new RGB(red, green, blue); + } else { + return new RGB(192, 192, 192); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillHeight.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillHeight.java index 87fd14a739285a50037ea7b4924991b977ddd071..265280e333e9eba3cc96119708b426a410961f6a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillHeight.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeFillHeight.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class AttributeFillHeight extends AbstractAttribute { - - public AttributeFillHeight(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Fill-Height"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class AttributeFillHeight extends AbstractAttribute { + + public AttributeFillHeight(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Fill-Height"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeLights.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeLights.java index 0c1d0822a4fa6e2172c53408bad655d4a7157454..113f844365124185f5d3c0808501265ec7af38a8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeLights.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeLights.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class AttributeLights extends AbstractAttribute { - - public AttributeLights(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Lights"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class AttributeLights extends AbstractAttribute { + + public AttributeLights(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Lights"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureInterval.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureInterval.java index 7c78a501ca1e55a99370a2b3e03ad4ce2ab5049e..52f0ec332b8ca09bb2482a2b740d60bf13cceff2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureInterval.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureInterval.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class AttributeMeasureInterval extends AbstractAttribute { - - public AttributeMeasureInterval(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Measure-Interval"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class AttributeMeasureInterval extends AbstractAttribute { + + public AttributeMeasureInterval(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Measure-Interval"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureMaxPos.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureMaxPos.java index 328348c8365d63e4def3e93ed930f2f321303bcd..f25d34e2b8847e3462d94a70f3ee6463ca40c9ee 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureMaxPos.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeMeasureMaxPos.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class AttributeMeasureMaxPos extends AbstractAttribute { - - public AttributeMeasureMaxPos(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Measure-Max-Pos"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class AttributeMeasureMaxPos extends AbstractAttribute { + + public AttributeMeasureMaxPos(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Measure-Max-Pos"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeShowMeasure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeShowMeasure.java index 2d53e7796a8e9a4e489695aceaf74773de1178f0..244c0ed5be427bc64a40d05591b5dea824077a02 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeShowMeasure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeShowMeasure.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; - -public class AttributeShowMeasure extends AbstractAttribute { - - public AttributeShowMeasure(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new CheckboxPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - if ((String.valueOf(value)).trim().equalsIgnoreCase("true") - || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { - return null; - } else { - return "Value must be a Boolean value (\"true\" or \"false\")"; - } - } - - @Override - public String getName() { - return "Show-Measure"; - } - - @Override - public Object unmarshal(String s) { - return Boolean.valueOf(s); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; + +public class AttributeShowMeasure extends AbstractAttribute { + + public AttributeShowMeasure(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new CheckboxPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + if ((String.valueOf(value)).trim().equalsIgnoreCase("true") + || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { + return null; + } else { + return "Value must be a Boolean value (\"true\" or \"false\")"; + } + } + + @Override + public String getName() { + return "Show-Measure"; + } + + @Override + public Object unmarshal(String s) { + return Boolean.valueOf(s); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSignalColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSignalColor.java index 19bc13837938bb4447b7bcddc0dd0806f31212ca..0a653cf1d509f4418fe7dbd4e64b563dd27dc523 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSignalColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSignalColor.java @@ -1,38 +1,38 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - - -public class AttributeSignalColor extends AbstractAttribute { - - public static final int RED = 0; - public static final int GREEN = 1; - public static final int NO_COLOR = 2; - - public AttributeSignalColor(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "Red", "Green", "No Color" }); - } - - @Override - public Object unmarshal(final String s) { - return Integer.valueOf(s); - } - - @Override - public String getName() { - return "Signal Color"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + + +public class AttributeSignalColor extends AbstractAttribute { + + public static final int RED = 0; + public static final int GREEN = 1; + public static final int NO_COLOR = 2; + + public AttributeSignalColor(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "Red", "Green", "No Color" }); + } + + @Override + public Object unmarshal(final String s) { + return Integer.valueOf(s); + } + + @Override + public String getName() { + return "Signal Color"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchDirection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchDirection.java index 783b182283947934b9fc5e4d1ffb45e0ee2246d2..bb09a257870a5b21db17b56a9984c454c8af3d15 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchDirection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchDirection.java @@ -1,39 +1,39 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - - -public class AttributeSwitchDirection extends AbstractAttribute { - - public static final int RIGHT_SOUTH = 0; - public static final int LEFT_SOUTH = 1; - public static final int RIGHT_NORTH = 2; - public static final int LEFT_NORTH = 3; - - public AttributeSwitchDirection(Object value) { - super(value); - } - - @Override - public Object unmarshal(final String s) { - return Integer.valueOf(s); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "Right South", "Left South", "Right North", "Left North" }); - } - - @Override - public String getName() { - return "Switch Direction"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + + +public class AttributeSwitchDirection extends AbstractAttribute { + + public static final int RIGHT_SOUTH = 0; + public static final int LEFT_SOUTH = 1; + public static final int RIGHT_NORTH = 2; + public static final int LEFT_NORTH = 3; + + public AttributeSwitchDirection(Object value) { + super(value); + } + + @Override + public Object unmarshal(final String s) { + return Integer.valueOf(s); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "Right South", "Left South", "Right North", "Left North" }); + } + + @Override + public String getName() { + return "Switch Direction"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchPosition.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchPosition.java index a214d084617f0bdee8ba018ca05f497e6401ab00..5985ed60f66200e60ec797b9e5add539ca58895d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchPosition.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeSwitchPosition.java @@ -1,37 +1,37 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class AttributeSwitchPosition extends AbstractAttribute { - - public static final int LEFT = 0; - public static final int RIGHT = 1; - public static final int UNKNOWN = 2; - - public AttributeSwitchPosition(Object value) { - super(value); - } - - @Override - public Object unmarshal(final String s) { - return Integer.valueOf(s); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "LEFT", "RIGHT", "UNKNOWN" }); - } - - @Override - public String getName() { - return "Switch Position"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class AttributeSwitchPosition extends AbstractAttribute { + + public static final int LEFT = 0; + public static final int RIGHT = 1; + public static final int UNKNOWN = 2; + + public AttributeSwitchPosition(Object value) { + super(value); + } + + @Override + public Object unmarshal(final String s) { + return Integer.valueOf(s); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "LEFT", "RIGHT", "UNKNOWN" }); + } + + @Override + public String getName() { + return "Switch Position"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeTrackDirection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeTrackDirection.java index b6a6dff2f2e2be9d93188ff9ea80dffbd4ddd002..0898112df66fd3f9153bc975d0023f968979c839 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeTrackDirection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AttributeTrackDirection.java @@ -1,36 +1,36 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class AttributeTrackDirection extends AbstractAttribute { - - public static final int RIGHT = 0; - public static final int LEFT = 1; - - public AttributeTrackDirection(Object value) { - super(value); - } - - @Override - public Object unmarshal(final String s) { - return Integer.valueOf(s); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "R", "L" }); - } - - @Override - public String getName() { - return "Track Direction"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class AttributeTrackDirection extends AbstractAttribute { + + public static final int RIGHT = 0; + public static final int LEFT = 1; + + public AttributeTrackDirection(Object value) { + super(value); + } + + @Override + public Object unmarshal(final String s) { + return Integer.valueOf(s); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "R", "L" }); + } + + @Override + public String getName() { + return "Track Direction"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java index fe192157564608b16cc527627ed8ff49cd13ec62..ced44636ecd9f445c0418cb1e6064b28bcff8ac2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java @@ -1,49 +1,49 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; - -public class BAttributeAlpha extends AbstractAttribute { - - public BAttributeAlpha(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - - if (Integer.valueOf(value.toString()) > 255 - || Integer.valueOf(value.toString()) < 0) { - return "Only a range from 0 to 255 is allowed"; - } - - return null; - } - - @Override - public String getName() { - return "Alpha"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; + +public class BAttributeAlpha extends AbstractAttribute { + + public BAttributeAlpha(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + + if (Integer.valueOf(value.toString()) > 255 + || Integer.valueOf(value.toString()) < 0) { + return "Only a range from 0 to 255 is allowed"; + } + + return null; + } + + @Override + public String getName() { + return "Alpha"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java index 0023246f77f3519457e9c64abf7ba27698fff49f..72d0ad68e8060f0add59abcfb971d8d1fe4461c3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.views.properties.ColorPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BAttributeBackgroundColor extends AbstractAttribute { - - public BAttributeBackgroundColor(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new ColorPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - // TODO: Implement me! - return null; - } - - @Override - public String getName() { - return "Background-Color"; - } - - @Override - public Object unmarshal(String s) { - - String colorStr = s.toLowerCase().replace(" ", ""); - colorStr = colorStr.replace("rgb", ""); - colorStr = colorStr.replace("}", ""); - colorStr = colorStr.replace("{", ""); - String[] str = String.valueOf(colorStr).split("\\,"); - if (str.length == 3) { - int red = Integer.valueOf(str[0]); - int green = Integer.valueOf(str[1]); - int blue = Integer.valueOf(str[2]); - return new RGB(red, green, blue); - } else { - return new RGB(192, 192, 192); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.views.properties.ColorPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BAttributeBackgroundColor extends AbstractAttribute { + + public BAttributeBackgroundColor(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new ColorPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + // TODO: Implement me! + return null; + } + + @Override + public String getName() { + return "Background-Color"; + } + + @Override + public Object unmarshal(String s) { + + String colorStr = s.toLowerCase().replace(" ", ""); + colorStr = colorStr.replace("rgb", ""); + colorStr = colorStr.replace("}", ""); + colorStr = colorStr.replace("{", ""); + String[] str = String.valueOf(colorStr).split("\\,"); + if (str.length == 3) { + int red = Integer.valueOf(str[0]); + int green = Integer.valueOf(str[1]); + int blue = Integer.valueOf(str[2]); + return new RGB(red, green, blue); + } else { + return new RGB(192, 192, 192); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java index 05c468b63454bd7836f67c8c319cb7660f76de34..2fe7e5f98645f83461e615a4987962f3ab205895 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; - -public class BAttributeBackgroundVisible extends AbstractAttribute { - - public BAttributeBackgroundVisible(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new CheckboxPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - if ((String.valueOf(value)).trim().equalsIgnoreCase("true") - || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { - return null; - } else { - return "Value must be a Boolean value (\"true\" or \"false\")"; - } - } - - @Override - public String getName() { - return "Visible"; - } - - @Override - public Object unmarshal(String s) { - return Boolean.valueOf(s); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; + +public class BAttributeBackgroundVisible extends AbstractAttribute { + + public BAttributeBackgroundVisible(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new CheckboxPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + if ((String.valueOf(value)).trim().equalsIgnoreCase("true") + || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { + return null; + } else { + return "Value must be a Boolean value (\"true\" or \"false\")"; + } + } + + @Override + public String getName() { + return "Visible"; + } + + @Override + public Object unmarshal(String s) { + return Boolean.valueOf(s); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java index e15182719126fc38f4fd36bd599f1938e6f6c0f0..fc659623d253b5c3baa72077b1b27f0958b5b76a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeButtonGroup extends AbstractAttribute { - - public BAttributeButtonGroup(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Group Name"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeButtonGroup extends AbstractAttribute { + + public BAttributeButtonGroup(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Group Name"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java index d3013220cac3d2a736d85297118267822590618b..37cffe4c2c15b714b29a2bb6b528a60b80787909 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; - -public class BAttributeChecked extends AbstractAttribute { - - public BAttributeChecked(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new CheckboxPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - if ((String.valueOf(value)).trim().equalsIgnoreCase("true") - || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { - return null; - } else { - return "Value must be a Boolean value (\"true\" or \"false\")"; - } - } - - @Override - public String getName() { - return "Checked"; - } - - @Override - public Object unmarshal(String s) { - return Boolean.valueOf(s); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; + +public class BAttributeChecked extends AbstractAttribute { + + public BAttributeChecked(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new CheckboxPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + if ((String.valueOf(value)).trim().equalsIgnoreCase("true") + || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { + return null; + } else { + return "Value must be a Boolean value (\"true\" or \"false\")"; + } + } + + @Override + public String getName() { + return "Checked"; + } + + @Override + public Object unmarshal(String s) { + return Boolean.valueOf(s); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java index 12a636d196f8838fb2daf5c2561d8c3aa829aae2..cf1521782ae4116cc13c18a546cc485cd0e03db1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeColumns extends AbstractAttribute { - - public BAttributeColumns(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Columns"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeColumns extends AbstractAttribute { + + public BAttributeColumns(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Columns"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java index 19428d8be059cc602dd29770813165943a53820a..c6c418995997b6b13e2636a86e916ddebee7f3e2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeConnection extends AbstractAttribute { - - public BAttributeConnection(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - PropertyDescriptor descriptor = new PropertyDescriptor(getID(), - getName()); - descriptor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return ""; - } - }); - return descriptor; - } - - @Override - public String getName() { - return "Connection"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeConnection extends AbstractAttribute { + + public BAttributeConnection(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + PropertyDescriptor descriptor = new PropertyDescriptor(getID(), + getName()); + descriptor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + return ""; + } + }); + return descriptor; + } + + @Override + public String getName() { + return "Connection"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java index 0a63dffb6f8a8d0b709dde9ed4c1da1a212c1427..42797db6180cfbc5751605f6e8791ab6c2a48a6f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java @@ -1,32 +1,32 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeConnectionSourceDecoration extends AbstractAttribute { - - public BAttributeConnectionSourceDecoration(Object value) { - super(value); - } - - public static int DECORATION_NONE = 0; - public static int DECORATION_TRIANGLE = 1; - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "None", "Triangle" }); - } - - @Override - public String getName() { - return "Connection-Source-Decoration"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeConnectionSourceDecoration extends AbstractAttribute { + + public BAttributeConnectionSourceDecoration(Object value) { + super(value); + } + + public static int DECORATION_NONE = 0; + public static int DECORATION_TRIANGLE = 1; + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "None", "Triangle" }); + } + + @Override + public String getName() { + return "Connection-Source-Decoration"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java index 0666b2593ff07f542384d97154175c2057889d6c..db54fb07232f2bd442acc60db1f77e6766f3b49a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java @@ -1,32 +1,32 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeConnectionTargetDecoration extends AbstractAttribute { - - public BAttributeConnectionTargetDecoration(Object value) { - super(value); - } - - public static int DECORATION_NONE = 0; - public static int DECORATION_TRIANGLE = 1; - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "None", "Triangle" }); - } - - @Override - public String getName() { - return "Connection-Target-Decoration"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeConnectionTargetDecoration extends AbstractAttribute { + + public BAttributeConnectionTargetDecoration(Object value) { + super(value); + } + + public static int DECORATION_NONE = 0; + public static int DECORATION_TRIANGLE = 1; + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "None", "Triangle" }); + } + + @Override + public String getName() { + return "Connection-Target-Decoration"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java index 193d963f3be639fc568ca7d4339a0f80181a67d5..0bd357620f5acd09363cf518efff63ebacb4e81c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java @@ -1,65 +1,65 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.AttributeConstants; - -public class BAttributeCoordinates extends AbstractAttribute { - - public BAttributeCoordinates(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - PropertyDescriptor descriptor = new PropertyDescriptor(getID(), - getName()); - descriptor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - Point point = (Point) element; - StringBuffer buf = new StringBuffer(); - buf.append("["); - buf.append(point.x); - buf.append(", "); - buf.append(point.y); - buf.append("]"); - return buf.toString(); - } - }); - return descriptor; - } - - @Override - public Object getEditableValue() { - - AbstractAttribute atrX = getChildren().get( - AttributeConstants.ATTRIBUTE_X); - AbstractAttribute atrY = getChildren().get( - AttributeConstants.ATTRIBUTE_Y); - - int x = -1; - int y = -1; - - if (atrX != null) - x = Integer.valueOf(atrX.getValue().toString()); - if (atrY != null) - y = Integer.valueOf(atrY.getValue().toString()); - - return new Point(x, y); - - } - - @Override - public String getName() { - return "a4:Coordinates"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.AttributeConstants; + +public class BAttributeCoordinates extends AbstractAttribute { + + public BAttributeCoordinates(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + PropertyDescriptor descriptor = new PropertyDescriptor(getID(), + getName()); + descriptor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + Point point = (Point) element; + StringBuffer buf = new StringBuffer(); + buf.append("["); + buf.append(point.x); + buf.append(", "); + buf.append(point.y); + buf.append("]"); + return buf.toString(); + } + }); + return descriptor; + } + + @Override + public Object getEditableValue() { + + AbstractAttribute atrX = getChildren().get( + AttributeConstants.ATTRIBUTE_X); + AbstractAttribute atrY = getChildren().get( + AttributeConstants.ATTRIBUTE_Y); + + int x = -1; + int y = -1; + + if (atrX != null) + x = Integer.valueOf(atrX.getValue().toString()); + if (atrY != null) + y = Integer.valueOf(atrY.getValue().toString()); + + return new Point(x, y); + + } + + @Override + public String getName() { + return "a4:Coordinates"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java index 476f71d06243ab8705c9ba308a48360051d56e53..a12576f7d55387efcdef8e8edf27aa0d0ec05366 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeCustom extends AbstractAttribute { - - public BAttributeCustom(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "a2:this"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeCustom extends AbstractAttribute { + + public BAttributeCustom(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "a2:this"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java index ffd7f2c1fc564bfd48c24cf47bf8016e7357e3a0..f9a41df03fa259b803104af0688c4aeb9e4218c8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java @@ -1,34 +1,34 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeDirection extends AbstractAttribute { - - public BAttributeDirection(Object value) { - super(value); - } - - public static final int NORTH = 0; - public static final int SOUTH = 1; - public static final int WEST = 2; - public static final int EAST = 3; - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "NORTH", "SOUTH", "WEST", "EAST" }); - } - - @Override - public String getName() { - return "Direction"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeDirection extends AbstractAttribute { + + public BAttributeDirection(Object value) { + super(value); + } + + public static final int NORTH = 0; + public static final int SOUTH = 1; + public static final int WEST = 2; + public static final int EAST = 3; + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "NORTH", "SOUTH", "WEST", "EAST" }); + } + + @Override + public String getName() { + return "Direction"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java index 170e1dfde4ec606c0932fe2fcb03fd8eb0ec7b0e..90e17ef0f039ba5e219e2213aafc74a6b01b88df 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; - -public class BAttributeEnabled extends AbstractAttribute { - - public BAttributeEnabled(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new CheckboxPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(final Object value, BControl control) { - if ((String.valueOf(value)).trim().equalsIgnoreCase("true") - || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { - return null; - } else { - return "Value must be a Boolean value (\"true\" or \"false\")"; - } - } - - @Override - public String getName() { - return "Enabled"; - } - - @Override - public Object unmarshal(String s) { - return Boolean.valueOf(s); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; + +public class BAttributeEnabled extends AbstractAttribute { + + public BAttributeEnabled(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new CheckboxPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(final Object value, BControl control) { + if ((String.valueOf(value)).trim().equalsIgnoreCase("true") + || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { + return null; + } else { + return "Value must be a Boolean value (\"true\" or \"false\")"; + } + } + + @Override + public String getName() { + return "Enabled"; + } + + @Override + public Object unmarshal(String s) { + return Boolean.valueOf(s); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java index 342f0d7ab5761275cb97d0705ad3ed10ccbd4cea..87f52d06c58310aa81274cea79b1bfaebecf5cac 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeFalseValue extends AbstractAttribute { - - public BAttributeFalseValue(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "False-Value"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeFalseValue extends AbstractAttribute { + + public BAttributeFalseValue(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "False-Value"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java index 81abe496879115fa02f1c2bf99682cd727f57344..4bef194a0f7f628537918095ffffbbcf3e10eb33 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java @@ -1,34 +1,34 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeFillType extends AbstractAttribute { - - public static final int FILLED = 0; - public static final int EMPTY = 1; - public static final int SHADED = 2; - public static final int GRADIENT = 3; - - public BAttributeFillType(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "Filled", "Empty", "Shaded", "Gradient" }); - } - - @Override - public String getName() { - return "Fill-Type"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeFillType extends AbstractAttribute { + + public static final int FILLED = 0; + public static final int EMPTY = 1; + public static final int SHADED = 2; + public static final int GRADIENT = 3; + + public BAttributeFillType(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "Filled", "Empty", "Shaded", "Gradient" }); + } + + @Override + public String getName() { + return "Fill-Type"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java index 85986759f8aed85204a780a1d4f54082296b91f0..9f8c3d87d53b33eeacc2cc82402a5a971d55a400 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.property.FontPropertyDescriptor; - -public class BAttributeFont extends AbstractAttribute { - - public BAttributeFont(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new FontPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Font"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.property.FontPropertyDescriptor; + +public class BAttributeFont extends AbstractAttribute { + + public BAttributeFont(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new FontPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Font"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java index cf4abf23f94cd929925ae936b74ba1c6aeae5888..298d82bff4cd7facdae1c7c68f4f596fedbe1f16 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.views.properties.ColorPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BAttributeForegroundColor extends AbstractAttribute { - - public BAttributeForegroundColor(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new ColorPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - // TODO: Implement me! - return null; - } - - @Override - public String getName() { - return "Foreground-Color"; - } - - @Override - public Object unmarshal(String s) { - - String colorStr = s.toLowerCase().replace(" ", ""); - colorStr = colorStr.replace("rgb", ""); - colorStr = colorStr.replace("}", ""); - colorStr = colorStr.replace("{", ""); - String[] str = String.valueOf(colorStr).split("\\,"); - if (str.length == 3) { - int red = Integer.valueOf(str[0]); - int green = Integer.valueOf(str[1]); - int blue = Integer.valueOf(str[2]); - return new RGB(red, green, blue); - } else { - return new RGB(192, 192, 192); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.views.properties.ColorPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BAttributeForegroundColor extends AbstractAttribute { + + public BAttributeForegroundColor(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new ColorPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + // TODO: Implement me! + return null; + } + + @Override + public String getName() { + return "Foreground-Color"; + } + + @Override + public Object unmarshal(String s) { + + String colorStr = s.toLowerCase().replace(" ", ""); + colorStr = colorStr.replace("rgb", ""); + colorStr = colorStr.replace("}", ""); + colorStr = colorStr.replace("{", ""); + String[] str = String.valueOf(colorStr).split("\\,"); + if (str.length == 3) { + int red = Integer.valueOf(str[0]); + int green = Integer.valueOf(str[1]); + int blue = Integer.valueOf(str[2]); + return new RGB(red, green, blue); + } else { + return new RGB(192, 192, 192); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java index 5947e5cd808c696ae11196e1b7eddc77c2b98fb7..a4eec8e565146d2ea80384a8f9878286e95a3deb 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeHeight extends AbstractAttribute { - - public BAttributeHeight(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Height"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeHeight extends AbstractAttribute { + + public BAttributeHeight(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Height"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java index b181122cdbd830bab5682d75b05d494f0fb8e00d..21ce6046376c7d88e8275147f5984fe8ec02ac4b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BAttributeID extends AbstractAttribute { - - public BAttributeID(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - TextPropertyDescriptor descriptor = new TextPropertyDescriptor(getID(), - getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (((String) value).trim().length() == 0) { - return "Value must not be empty string"; - } - if (!(String.valueOf(value)).trim().matches("^[a-zA-Z_0-9]*")) { - return "Special characters are not allowed."; - } - if (control.getVisualization().checkIfIdExists((String) value)) { - return "ID already exists"; - } - return null; - } - - @Override - public String getName() { - return "a1:ID"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BAttributeID extends AbstractAttribute { + + public BAttributeID(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + TextPropertyDescriptor descriptor = new TextPropertyDescriptor(getID(), + getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (((String) value).trim().length() == 0) { + return "Value must not be empty string"; + } + if (!(String.valueOf(value)).trim().matches("^[a-zA-Z_0-9]*")) { + return "Special characters are not allowed."; + } + if (control.getVisualization().checkIfIdExists((String) value)) { + return "ID already exists"; + } + return null; + } + + @Override + public String getName() { + return "a1:ID"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java index 86f1d299bf2ef2cf3811c6eee0916e062ae9605f..d17d58ffc6b6362ec480380b5f2d126026a800d6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import java.io.File; - -import org.eclipse.core.resources.IFile; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.ImagePropertyDescriptor; - -public class BAttributeImage extends AbstractAttribute { - - public BAttributeImage(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new ImagePropertyDescriptor(getID(), getName()); - } - - public String validateValue(Object value, BControl control) { - if (value != null) { - String fImage = value.toString(); - IFile pFile = control.getVisualization().getProjectFile(); - String myPath = (pFile.getProject().getLocation() + "/images/" + fImage) - .replace("file:", ""); - if (!new File(myPath).exists()) { - return "No such image in your library: " + fImage; - } - } - return null; - } - - @Override - public String getName() { - return "Image"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import java.io.File; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.ImagePropertyDescriptor; + +public class BAttributeImage extends AbstractAttribute { + + public BAttributeImage(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new ImagePropertyDescriptor(getID(), getName()); + } + + public String validateValue(Object value, BControl control) { + if (value != null) { + String fImage = value.toString(); + IFile pFile = control.getVisualization().getProjectFile(); + String myPath = (pFile.getProject().getLocation() + "/images/" + fImage) + .replace("file:", ""); + if (!new File(myPath).exists()) { + return "No such image in your library: " + fImage; + } + } + return null; + } + + @Override + public String getName() { + return "Image"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java index a3f962a2702da02a2554dd4cb6f2b2476904edda..55c7e2dc3a3501555aacadbad76ece3f85b42e10 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeLabel extends AbstractAttribute { - - public BAttributeLabel(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Label"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeLabel extends AbstractAttribute { + + public BAttributeLabel(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Label"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java index 9e0132d7d607e9eb4d1f08f382ea7894a5489e9b..e3699f44b2712787a742fdaaf888d7b8f61d839d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeLineStyle extends AbstractAttribute { - - public static final int SOLID_CONNECTION = 0; - public static final int DASHED_CONNECTION = 1; - public static final int DOTTED_CONNECTION = 2; - public static final int DASHED_DOTTED_CONNECTION = 3; - public static final int DASHED_DOTTED_DOTTED_CONNECTION = 4; - - public BAttributeLineStyle(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "Solid", "Dash", "Dot", "Dash Dot", "Dash Dot Dot" }); - } - - @Override - public String getName() { - return "Line-Style"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeLineStyle extends AbstractAttribute { + + public static final int SOLID_CONNECTION = 0; + public static final int DASHED_CONNECTION = 1; + public static final int DOTTED_CONNECTION = 2; + public static final int DASHED_DOTTED_CONNECTION = 3; + public static final int DASHED_DOTTED_DOTTED_CONNECTION = 4; + + public BAttributeLineStyle(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "Solid", "Dash", "Dot", "Dash Dot", "Dash Dot Dot" }); + } + + @Override + public String getName() { + return "Line-Style"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java index 82f43fda9cb00aa3fd4cbc51cd9625191b90f79d..355cf9863edfae3a391ac04433461845d6fe87b2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java @@ -1,36 +1,36 @@ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeLineWidth extends AbstractAttribute { - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - public BAttributeLineWidth(Object value) { - super(value); - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Line-Width"; - } - -} +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeLineWidth extends AbstractAttribute { + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + public BAttributeLineWidth(Object value) { + super(value); + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Line-Width"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java index 2870f97b871646f1bc141b5c33f76b3dde21b219..428265636c95876c93c2ccf09c9a80fbfd907f25 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeMain extends AbstractAttribute { - - public BAttributeMain(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - PropertyDescriptor descriptor = new PropertyDescriptor(getID(), - getName()); - descriptor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return ""; - } - }); - return descriptor; - } - - @Override - public String getName() { - return "Main"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeMain extends AbstractAttribute { + + public BAttributeMain(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + PropertyDescriptor descriptor = new PropertyDescriptor(getID(), + getName()); + descriptor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + return ""; + } + }); + return descriptor; + } + + @Override + public String getName() { + return "Main"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java index 658f9e91b231ea21d6383cc32298f73424977693..cffc3cea6c6ccefeb93808ca2a2acb0a31ad8c5b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeMisc extends AbstractAttribute { - - public BAttributeMisc(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - PropertyDescriptor descriptor = new PropertyDescriptor(getID(), - getName()); - descriptor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return ""; - } - }); - return descriptor; - } - - @Override - public String getName() { - return "Misc"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeMisc extends AbstractAttribute { + + public BAttributeMisc(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + PropertyDescriptor descriptor = new PropertyDescriptor(getID(), + getName()); + descriptor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + return ""; + } + }); + return descriptor; + } + + @Override + public String getName() { + return "Misc"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java index f173bbfb605a0c922380c2e9db6bae83e9eba08f..89116bc2c1805566c22e7dc36b07a9c9610b602a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeOffsetH extends AbstractAttribute { - - public BAttributeOffsetH(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Offset-H"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeOffsetH extends AbstractAttribute { + + public BAttributeOffsetH(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Offset-H"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java index 9fafedfc1c7588060e666ac95d51344bc3c9dfc5..1dd63241d4797ec04756287f9da762b9c87231a6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeOffsetV extends AbstractAttribute { - - public BAttributeOffsetV(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Offset-V"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeOffsetV extends AbstractAttribute { + + public BAttributeOffsetV(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Offset-V"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java index db025c10df17ae79035008eac615bd1a36069290..86a63f255045d1efeb566d9403392a143f238437 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java @@ -1,26 +1,26 @@ -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeOrientation extends AbstractAttribute { - - public BAttributeOrientation(Object value) { - super(value); - } - - public static final int HORIZONTAL = 0; - public static final int VERTICAL = 1; - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "HORIZONTAL", "VERTICAL" }); - } - - @Override - public String getName() { - return "Orientation"; - } - -} +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeOrientation extends AbstractAttribute { + + public BAttributeOrientation(Object value) { + super(value); + } + + public static final int HORIZONTAL = 0; + public static final int VERTICAL = 1; + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "HORIZONTAL", "VERTICAL" }); + } + + @Override + public String getName() { + return "Orientation"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java index f583a8f03f37c48592c2358a6217a1f2b347b7b3..dd3ce6d151ad5b70e2e2f2af0578049f3136ab73 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java @@ -1,50 +1,50 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; - -public class BAttributeOutlineAlpha extends AbstractAttribute { - - public BAttributeOutlineAlpha(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - public String validateValue(Object value, BControl control) { - - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - - if (Integer.valueOf(value.toString()) > 255 - || Integer.valueOf(value.toString()) < 0) { - return "Only a range from 0 to 255 is allowed"; - } - - return null; - - } - - @Override - public String getName() { - return "Outline-Alpha"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; + +public class BAttributeOutlineAlpha extends AbstractAttribute { + + public BAttributeOutlineAlpha(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + public String validateValue(Object value, BControl control) { + + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + + if (Integer.valueOf(value.toString()) > 255 + || Integer.valueOf(value.toString()) < 0) { + return "Only a range from 0 to 255 is allowed"; + } + + return null; + + } + + @Override + public String getName() { + return "Outline-Alpha"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java index b3df0f422b0fab661a49ac893d785b2c3cda0a00..578a8253dcb95f89adeb9889b8651cc2a15d8570 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeRows extends AbstractAttribute { - - public BAttributeRows(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Rows"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeRows extends AbstractAttribute { + + public BAttributeRows(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Rows"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java index 506461deca4a39e20ff8bf3adecaeedb1555f601..5e3a9fced0dae740559db673421e08819dbed5f0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java @@ -1,34 +1,34 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class BAttributeShape extends AbstractAttribute { - - public BAttributeShape(Object value) { - super(value); - } - - public static final int SHAPE_RECTANGLE = 0; - public static final int SHAPE_OVAL = 1; - public static final int SHAPE_TRIANGLE = 2; - public static final int SHAPE_DIAMOND = 3; - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { - "Rectangle", "Oval", "Triangle", "Diamond" }); - } - - @Override - public String getName() { - return "Shape"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class BAttributeShape extends AbstractAttribute { + + public BAttributeShape(Object value) { + super(value); + } + + public static final int SHAPE_RECTANGLE = 0; + public static final int SHAPE_OVAL = 1; + public static final int SHAPE_TRIANGLE = 2; + public static final int SHAPE_DIAMOND = 3; + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { + "Rectangle", "Oval", "Triangle", "Diamond" }); + } + + @Override + public String getName() { + return "Shape"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java index 23094707bf3e913c307528b9d8d3bb5d1a5e0fda..3354a569b3d8d5adcfb31666548c7cb88e1440f5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java @@ -1,70 +1,70 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.AttributeConstants; - -public class BAttributeSize extends AbstractAttribute { - - public BAttributeSize(Object value) { - super(value); - } - - public static final String ID = "de.bmotionstudio.gef.editor.attribute.BAttributeSize"; - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - PropertyDescriptor descriptor = new PropertyDescriptor(getID(), - getName()); - descriptor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - Point point = (Point) element; - StringBuffer buf = new StringBuffer(); - buf.append("["); - if (point.x >= 0) - buf.append(point.x); - if (point.y >= 0) { - buf.append(", "); - buf.append(point.y); - } - buf.append("]"); - return buf.toString(); - } - }); - return descriptor; - } - - @Override - public Object getEditableValue() { - - AbstractAttribute atrWidth = getChildren().get( - AttributeConstants.ATTRIBUTE_WIDTH); - AbstractAttribute atrHeight = getChildren().get( - AttributeConstants.ATTRIBUTE_HEIGHT); - - int width = -1; - int height = -1; - - if (atrWidth != null) - width = Integer.valueOf(atrWidth.getValue().toString()); - if (atrHeight != null) - height = Integer.valueOf(atrHeight.getValue().toString()); - - return new Point(width, height); - - } - - @Override - public String getName() { - return "a5:Size"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.AttributeConstants; + +public class BAttributeSize extends AbstractAttribute { + + public BAttributeSize(Object value) { + super(value); + } + + public static final String ID = "de.bmotionstudio.gef.editor.attribute.BAttributeSize"; + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + PropertyDescriptor descriptor = new PropertyDescriptor(getID(), + getName()); + descriptor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + Point point = (Point) element; + StringBuffer buf = new StringBuffer(); + buf.append("["); + if (point.x >= 0) + buf.append(point.x); + if (point.y >= 0) { + buf.append(", "); + buf.append(point.y); + } + buf.append("]"); + return buf.toString(); + } + }); + return descriptor; + } + + @Override + public Object getEditableValue() { + + AbstractAttribute atrWidth = getChildren().get( + AttributeConstants.ATTRIBUTE_WIDTH); + AbstractAttribute atrHeight = getChildren().get( + AttributeConstants.ATTRIBUTE_HEIGHT); + + int width = -1; + int height = -1; + + if (atrWidth != null) + width = Integer.valueOf(atrWidth.getValue().toString()); + if (atrHeight != null) + height = Integer.valueOf(atrHeight.getValue().toString()); + + return new Point(width, height); + + } + + @Override + public String getName() { + return "a5:Size"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java index 97d071630c2c0df0fdc1159ecb2d74de2f47fd23..d9d0ab66bd3b789452376e3505bca4542a911033 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java @@ -1,27 +1,27 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeText extends AbstractAttribute { - - public BAttributeText(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Text"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeText extends AbstractAttribute { + + public BAttributeText(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Text"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java index dbba315d244d7655012a87b6072cc0db9ca37eda..4e2da94ca5f29e91e6425ae3d25b9f36acfcfa69 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.views.properties.ColorPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BAttributeTextColor extends AbstractAttribute { - - public BAttributeTextColor(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new ColorPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - // TODO: Implement me! - return null; - } - - @Override - public String getName() { - return "Text-Color"; - } - - @Override - public Object unmarshal(String s) { - - String colorStr = s.toLowerCase().replace(" ", ""); - colorStr = colorStr.replace("rgb", ""); - colorStr = colorStr.replace("}", ""); - colorStr = colorStr.replace("{", ""); - String[] str = String.valueOf(colorStr).split("\\,"); - if (str.length == 3) { - int red = Integer.valueOf(str[0]); - int green = Integer.valueOf(str[1]); - int blue = Integer.valueOf(str[2]); - return new RGB(red, green, blue); - } else { - return new RGB(192, 192, 192); - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.views.properties.ColorPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BAttributeTextColor extends AbstractAttribute { + + public BAttributeTextColor(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new ColorPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + // TODO: Implement me! + return null; + } + + @Override + public String getName() { + return "Text-Color"; + } + + @Override + public Object unmarshal(String s) { + + String colorStr = s.toLowerCase().replace(" ", ""); + colorStr = colorStr.replace("rgb", ""); + colorStr = colorStr.replace("}", ""); + colorStr = colorStr.replace("{", ""); + String[] str = String.valueOf(colorStr).split("\\,"); + if (str.length == 3) { + int red = Integer.valueOf(str[0]); + int green = Integer.valueOf(str[1]); + int blue = Integer.valueOf(str[2]); + return new RGB(red, green, blue); + } else { + return new RGB(192, 192, 192); + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java index 3d58d1fbd9b9645fb4df65b4b0ed72f3ee1adb24..cb4f3e65919854898325c3461eccf61b8de50b75 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeTrueValue extends AbstractAttribute { - - public BAttributeTrueValue(Object value) { - super(value); - } - - @Override - public PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "True-Value"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeTrueValue extends AbstractAttribute { + + public BAttributeTrueValue(Object value) { + super(value); + } + + @Override + public PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "True-Value"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java index 2b0aaf110088d54fde29b51a5fc1f5125ba80b54..b4b64418c03297869ee33a93ac0878dfb9a332a9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -public class BAttributeValue extends AbstractAttribute { - - public BAttributeValue(Object value) { - super(value); - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return new TextPropertyDescriptor(getID(), getName()); - } - - @Override - public String getName() { - return "Value"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +public class BAttributeValue extends AbstractAttribute { + + public BAttributeValue(Object value) { + super(value); + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return new TextPropertyDescriptor(getID(), getName()); + } + + @Override + public String getName() { + return "Value"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java index bbf89608770e925157c6fcf401e58fcd3338d59b..96961a53dab4e56bb39a99a59c2d84b93aea36fe 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; - -public class BAttributeVisible extends AbstractAttribute { - - public BAttributeVisible(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - return new CheckboxPropertyDescriptor(getID(), getName()); - } - - @Override - public String validateValue(Object value, BControl control) { - if ((String.valueOf(value)).trim().equalsIgnoreCase("true") - || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { - return null; - } else { - return "Value must be a Boolean value (\"true\" or \"false\")"; - } - } - - @Override - public String getName() { - return "a3:Visible"; - } - - @Override - public Object unmarshal(String s) { - return Boolean.valueOf(s); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; + +public class BAttributeVisible extends AbstractAttribute { + + public BAttributeVisible(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + return new CheckboxPropertyDescriptor(getID(), getName()); + } + + @Override + public String validateValue(Object value, BControl control) { + if ((String.valueOf(value)).trim().equalsIgnoreCase("true") + || (String.valueOf(value)).trim().equalsIgnoreCase("false")) { + return null; + } else { + return "Value must be a Boolean value (\"true\" or \"false\")"; + } + } + + @Override + public String getName() { + return "a3:Visible"; + } + + @Override + public Object unmarshal(String s) { + return Boolean.valueOf(s); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java index 34844653d9226fbca2ab5020f527fb7d43718cc0..bcb310e77a51b6c9f68576b6de16f70a6c2dd351 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeWidth extends AbstractAttribute { - - public BAttributeWidth(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Width"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeWidth extends AbstractAttribute { + + public BAttributeWidth(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Width"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java index e3f911398536a6f4a871fdd8b037608462a064a0..2ff72c75024892ef73ef0c1edcde72af764a319a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeX extends AbstractAttribute { - - public BAttributeX(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "X"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeX extends AbstractAttribute { + + public BAttributeX(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "X"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java index 45c5959a7837d01f33fe22d722db436167b3d7fa..a48a0e28ef74a9324e999255f6c93cf1f8a85385 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.attribute; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; - -public class BAttributeY extends AbstractAttribute { - - public BAttributeY(Object value) { - super(value); - } - - public PropertyDescriptor preparePropertyDescriptor() { - IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( - getID(), getName()); - return descriptor; - } - - @Override - public String validateValue(Object value, BControl control) { - if (!(String.valueOf(value)).trim().matches("\\d*")) { - return "Value must be a number"; - } - if ((String.valueOf(value)).trim().length() == 0) { - return "Value must not be empty string"; - } - return null; - } - - @Override - public String getName() { - return "Y"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.attribute; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; + +public class BAttributeY extends AbstractAttribute { + + public BAttributeY(Object value) { + super(value); + } + + public PropertyDescriptor preparePropertyDescriptor() { + IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( + getID(), getName()); + return descriptor; + } + + @Override + public String validateValue(Object value, BControl control) { + if (!(String.valueOf(value)).trim().matches("\\d*")) { + return "Value must be a number"; + } + if ((String.valueOf(value)).trim().length() == 0) { + return "Value must not be empty string"; + } + return null; + } + + @Override + public String getName() { + return "Y"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractBringToCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractBringToCommand.java index d5d52472ba652177fb241cd61ce2abada17d1ca9..35de475cd6e0680c754dce6b0222c188623366c7 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractBringToCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractBringToCommand.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; - -public abstract class AbstractBringToCommand extends Command { - - private List<BControl> controlList = new ArrayList<BControl>(); - private Map<BControl, Integer> oldIndexMap = new HashMap<BControl, Integer>(); - - public void setControlList(List<BControl> controlList) { - this.controlList = controlList; - } - - public List<BControl> getControlList() { - return controlList; - } - - @Override - public boolean canExecute() { - if (controlList.isEmpty()) - return false; - return true; - } - - @Override - public boolean canUndo() { - if (controlList.isEmpty() || oldIndexMap.isEmpty()) - return false; - return true; - } - - public Map<BControl, Integer> getOldIndexMap() { - return oldIndexMap; - } - - public void setOldIndexMap(HashMap<BControl, Integer> oldIndexMap) { - this.oldIndexMap = oldIndexMap; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; + +public abstract class AbstractBringToCommand extends Command { + + private List<BControl> controlList = new ArrayList<BControl>(); + private Map<BControl, Integer> oldIndexMap = new HashMap<BControl, Integer>(); + + public void setControlList(List<BControl> controlList) { + this.controlList = controlList; + } + + public List<BControl> getControlList() { + return controlList; + } + + @Override + public boolean canExecute() { + if (controlList.isEmpty()) + return false; + return true; + } + + @Override + public boolean canUndo() { + if (controlList.isEmpty() || oldIndexMap.isEmpty()) + return false; + return true; + } + + public Map<BControl, Integer> getOldIndexMap() { + return oldIndexMap; + } + + public void setOldIndexMap(HashMap<BControl, Integer> oldIndexMap) { + this.oldIndexMap = oldIndexMap; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractLayoutCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractLayoutCommand.java index 231e1866e27fa4ebb0e85cde44ebf48ab03ad703..ec9fa1df5a27dcc759436e54c11c4fb53a423734 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractLayoutCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AbstractLayoutCommand.java @@ -4,15 +4,15 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; - -public abstract class AbstractLayoutCommand extends Command { - - public abstract void setConstraint(Rectangle rect); - - public abstract void setModel(Object model); - -} +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; + +public abstract class AbstractLayoutCommand extends Command { + + public abstract void setConstraint(Rectangle rect); + + public abstract void setModel(Object model); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AddCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AddCommand.java index 8310dc4371d939c53c076d428159a487841401b4..6c1fd1e4ca8ef5f096bdb8030726a33508437374 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AddCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/AddCommand.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class AddCommand extends org.eclipse.gef.commands.Command { - - private BControl child; - private BControl parent; - private int index = -1; - - public AddCommand() { - super("Add Control"); - } - - public void execute() { - if (index < 0) - parent.addChild(child); - else - parent.addChild(child, index); - } - - public BControl getParent() { - return parent; - } - - public void redo() { - if (index < 0) - parent.addChild(child); - else - parent.addChild(child, index); - } - - public void setChild(BControl subpart) { - child = subpart; - } - - public void setIndex(int i) { - index = i; - } - - public void setParent(BControl newParent) { - parent = newParent; - } - - public void undo() { - parent.removeChild(child); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class AddCommand extends org.eclipse.gef.commands.Command { + + private BControl child; + private BControl parent; + private int index = -1; + + public AddCommand() { + super("Add Control"); + } + + public void execute() { + if (index < 0) + parent.addChild(child); + else + parent.addChild(child, index); + } + + public BControl getParent() { + return parent; + } + + public void redo() { + if (index < 0) + parent.addChild(child); + else + parent.addChild(child, index); + } + + public void setChild(BControl subpart) { + child = subpart; + } + + public void setIndex(int i) { + index = i; + } + + public void setParent(BControl newParent) { + parent = newParent; + } + + public void undo() { + parent.removeChild(child); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BControlChangeLayoutCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BControlChangeLayoutCommand.java index 96effb5f2ec96106463679be4b9335ac54b4856c..0362ff942c735c321c4302bd39ce36c6ecf03621 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BControlChangeLayoutCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BControlChangeLayoutCommand.java @@ -1,37 +1,37 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.draw2d.geometry.Rectangle; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class BControlChangeLayoutCommand extends AbstractLayoutCommand { - - private BControl control; - private Rectangle newLayout; - private Rectangle oldLayout; - - public void execute() { - control.setLayout(newLayout); - } - - public void setConstraint(Rectangle rect) { - newLayout = rect; - } - - public void setModel(Object model) { - control = (BControl) model; - oldLayout = control.getLayout(); - } - - @Override - public void undo() { - control.setLayout(oldLayout); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.draw2d.geometry.Rectangle; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class BControlChangeLayoutCommand extends AbstractLayoutCommand { + + private BControl control; + private Rectangle newLayout; + private Rectangle oldLayout; + + public void execute() { + control.setLayout(newLayout); + } + + public void setConstraint(Rectangle rect) { + newLayout = rect; + } + + public void setModel(Object model) { + control = (BControl) model; + oldLayout = control.getLayout(); + } + + @Override + public void undo() { + control.setLayout(oldLayout); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomCommand.java index 16a668b4a38479700afe1151baac872be8af1c56..b31565dc214f84c1ee7d814c62d3c350a596d65f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomCommand.java @@ -1,37 +1,37 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; - -public class BringToBottomCommand extends AbstractBringToCommand { - - public void execute() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - Integer oldIndex = parent.getChildrenArray().indexOf(control); - getOldIndexMap().put(control, oldIndex); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(0, control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - - public void undo() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(getOldIndexMap().get(control), - control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; + +public class BringToBottomCommand extends AbstractBringToCommand { + + public void execute() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + Integer oldIndex = parent.getChildrenArray().indexOf(control); + getOldIndexMap().put(control, oldIndex); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(0, control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + + public void undo() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(getOldIndexMap().get(control), + control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomStepCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomStepCommand.java index f5bbb964961743c6278780f6722418212334f86d..831cc48715de601d86d7a3a9e4e81029870889ba 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomStepCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToBottomStepCommand.java @@ -1,40 +1,40 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; - -public class BringToBottomStepCommand extends AbstractBringToCommand { - - public void execute() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - Integer oldIndex = parent.getChildrenArray().indexOf(control); - getOldIndexMap().put(control, oldIndex); - if (oldIndex > 0) { - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(oldIndex - 1, control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, - null); - } - } - } - - public void undo() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(getOldIndexMap().get(control), - control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; + +public class BringToBottomStepCommand extends AbstractBringToCommand { + + public void execute() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + Integer oldIndex = parent.getChildrenArray().indexOf(control); + getOldIndexMap().put(control, oldIndex); + if (oldIndex > 0) { + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(oldIndex - 1, control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, + null); + } + } + } + + public void undo() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(getOldIndexMap().get(control), + control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopCommand.java index c290043b3e2eb8df9d0c9354948cdc8681250e52..aaee09d368034de3c79aa6fcce89f93433eadaee 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopCommand.java @@ -1,38 +1,38 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; - -public class BringToTopCommand extends AbstractBringToCommand { - - public void execute() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - Integer oldIndex = parent.getChildrenArray().indexOf(control); - getOldIndexMap().put(control, oldIndex); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(parent.getChildrenArray().size(), - control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - - public void undo() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(getOldIndexMap().get(control), - control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; + +public class BringToTopCommand extends AbstractBringToCommand { + + public void execute() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + Integer oldIndex = parent.getChildrenArray().indexOf(control); + getOldIndexMap().put(control, oldIndex); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(parent.getChildrenArray().size(), + control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + + public void undo() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(getOldIndexMap().get(control), + control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopStepCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopStepCommand.java index 805599aaac6c0ee0ac237a4e713e6ea191114729..d5c2cb1f81e8ca1e24630c7742cf8973c3f42461 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopStepCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/BringToTopStepCommand.java @@ -1,40 +1,40 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; - -public class BringToTopStepCommand extends AbstractBringToCommand { - - public void execute() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - Integer oldIndex = parent.getChildrenArray().indexOf(control); - getOldIndexMap().put(control, oldIndex); - if (oldIndex < parent.getChildrenArray().size() - 1) { - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(oldIndex + 1, control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, - null); - } - } - } - - public void undo() { - for (BControl control : getControlList()) { - BControl parent = control.getParent(); - parent.getChildrenArray().remove(control); - parent.getChildrenArray().add(getOldIndexMap().get(control), - control); - parent.getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; + +public class BringToTopStepCommand extends AbstractBringToCommand { + + public void execute() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + Integer oldIndex = parent.getChildrenArray().indexOf(control); + getOldIndexMap().put(control, oldIndex); + if (oldIndex < parent.getChildrenArray().size() - 1) { + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(oldIndex + 1, control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, + null); + } + } + } + + public void undo() { + for (BControl control : getControlList()) { + BControl parent = control.getParent(); + parent.getChildrenArray().remove(control); + parent.getChildrenArray().add(getOldIndexMap().get(control), + control); + parent.getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, null, null); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ChangeGuideCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ChangeGuideCommand.java index fc87321d42881e9a6f9467d1396c7010a456960a..f131dd3af60939e60e6085b58d2a294f2099e15f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ChangeGuideCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ChangeGuideCommand.java @@ -1,66 +1,66 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BMotionGuide; - -public class ChangeGuideCommand extends Command { - - private BControl part; - private BMotionGuide oldGuide, newGuide; - private int oldAlign, newAlign; - private boolean horizontal; - - public ChangeGuideCommand(BControl part, boolean horizontalGuide) { - super(); - this.part = part; - horizontal = horizontalGuide; - } - - protected void changeGuide(BMotionGuide oldGuide, BMotionGuide newGuide, - int newAlignment) { - - if (oldGuide != null && oldGuide != newGuide) { - oldGuide.detachPart(part); - } - // You need to re-attach the part even if the oldGuide and the - // newGuide - // are the same - // because the alignment could have changed - if (newGuide != null) { - newGuide.attachPart(part, newAlignment); - } - - } - - public void execute() { - // Cache the old values - oldGuide = horizontal ? part.getHorizontalGuide() : part - .getVerticalGuide(); - if (oldGuide != null) - oldAlign = oldGuide.getAlignment(part); - - redo(); - } - - public void redo() { - changeGuide(oldGuide, newGuide, newAlign); - } - - public void setNewGuide(BMotionGuide guide, int alignment) { - newGuide = guide; - newAlign = alignment; - } - - public void undo() { - changeGuide(newGuide, oldGuide, oldAlign); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BMotionGuide; + +public class ChangeGuideCommand extends Command { + + private BControl part; + private BMotionGuide oldGuide, newGuide; + private int oldAlign, newAlign; + private boolean horizontal; + + public ChangeGuideCommand(BControl part, boolean horizontalGuide) { + super(); + this.part = part; + horizontal = horizontalGuide; + } + + protected void changeGuide(BMotionGuide oldGuide, BMotionGuide newGuide, + int newAlignment) { + + if (oldGuide != null && oldGuide != newGuide) { + oldGuide.detachPart(part); + } + // You need to re-attach the part even if the oldGuide and the + // newGuide + // are the same + // because the alignment could have changed + if (newGuide != null) { + newGuide.attachPart(part, newAlignment); + } + + } + + public void execute() { + // Cache the old values + oldGuide = horizontal ? part.getHorizontalGuide() : part + .getVerticalGuide(); + if (oldGuide != null) + oldAlign = oldGuide.getAlignment(part); + + redo(); + } + + public void redo() { + changeGuide(oldGuide, newGuide, newAlign); + } + + public void setNewGuide(BMotionGuide guide, int alignment) { + newGuide = guide; + newAlign = alignment; + } + + public void undo() { + changeGuide(newGuide, oldGuide, oldAlign); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionCreateCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionCreateCommand.java index f9893ed87ffd0cfe0466f7bb8b99d16b94279f89..a28d84a71d99561f20c8cec6abceb3e557dca735 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionCreateCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionCreateCommand.java @@ -1,152 +1,132 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Elias Volanakis and others. -�* All rights reserved. This program and the accompanying materials -�* are made available under the terms of the Eclipse Public License v1.0 -�* which accompanies this distribution, and is available at -�* http://www.eclipse.org/legal/epl-v10.html -�* -�* Contributors: -�*����Elias Volanakis - initial API and implementation -�*******************************************************************************/ -package de.bmotionstudio.gef.editor.command; - -import java.util.Iterator; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * A command to create a connection between two shapes. The command can be - * undone or redone. - * <p> - * This command is designed to be used together with a GraphicalNodeEditPolicy. - * To use this command properly, following steps are necessary: - * </p> - * <ol> - * <li>Create a subclass of GraphicalNodeEditPolicy.</li> - * <li>Override the <tt>getConnectionCreateCommand(...)</tt> method, to create a - * new instance of this class and put it into the CreateConnectionRequest.</li> - * <li>Override the <tt>getConnectionCompleteCommand(...)</tt> method, to obtain - * the Command from the ConnectionRequest, call setTarget(...) to set the target - * endpoint of the connection and return this command instance.</li> - * </ol> - * - * @see org.eclipse.gef.examples.shapes.parts.ShapeEditPart#createEditPolicies() - * for an example of the above procedure. - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy - * @author Elias Volanakis - */ -public class ConnectionCreateCommand extends Command { - /** The connection instance. */ - private BConnection connection; - - /** Start endpoint for the connection. */ - private final BControl source; - /** Target endpoint for the connection. */ - private BControl target; - - /** - * Instantiate a command that can create a connection between two shapes. - * - * @param source - * the source endpoint (a non-null Shape instance) - * @param lineStyle - * the desired line style. See Connection#setLineStyle(int) for - * details - * @throws IllegalArgumentException - * if source is null - * @see Connection#setLineStyle(int) - */ - public ConnectionCreateCommand(BControl source) { - if (source == null) { - throw new IllegalArgumentException(); - } - setLabel("connection creation"); - this.source = source; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#canExecute() - */ - public boolean canExecute() { - // disallow source -> source connections - if (source.equals(target)) { - return false; - } - // return false, if the source -> target connection exists already - for (Iterator<BConnection> iter = source.getSourceConnections() - .iterator(); iter.hasNext();) { - BConnection conn = (BConnection) iter.next(); - if (conn.getTarget().equals(target)) { - return false; - } - } - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() { - // create a new connection between source and target - connection.setSource(source); - connection.setTarget(target); - connection.reconnect(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#redo() - */ - public void redo() { - connection.reconnect(); - } - - /** - * Set the target endpoint for the connection. - * - * @param target - * that target endpoint (a non-null Shape instance) - * @throws IllegalArgumentException - * if target is null - */ - public void setTarget(BControl target) { - if (target == null) { - throw new IllegalArgumentException(); - } - this.target = target; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#undo() - */ - public void undo() { - connection.disconnect(); - } - - public void setConnection(BConnection con) { - this.connection = con; - } - - public BConnection getConnection() { - return this.connection; - } - - public BControl getSource() { - return this.source; - } - - public BControl getTarget() { - return this.target; - } - -} +/******************************************************************************* + * Copyright (c) 2004, 2005 Elias Volanakis and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Elias Volanakis - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.command; + +import java.util.Iterator; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * A command to create a connection between two shapes. The command can be + * undone or redone. + * <p> + * This command is designed to be used together with a GraphicalNodeEditPolicy. + * To use this command properly, following steps are necessary: + * </p> + * <ol> + * <li>Create a subclass of GraphicalNodeEditPolicy.</li> + * <li>Override the <tt>getConnectionCreateCommand(...)</tt> method, to create a + * new instance of this class and put it into the CreateConnectionRequest.</li> + * <li>Override the <tt>getConnectionCompleteCommand(...)</tt> method, to obtain + * the Command from the ConnectionRequest, call setTarget(...) to set the target + * endpoint of the connection and return this command instance.</li> + * </ol> + * + * @see org.eclipse.gef.examples.shapes.parts.ShapeEditPart#createEditPolicies() + * for an example of the above procedure. + * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy + * @author Elias Volanakis + */ +public class ConnectionCreateCommand extends Command { + /** The connection instance. */ + private BConnection connection; + + /** Start endpoint for the connection. */ + private final BControl source; + /** Target endpoint for the connection. */ + private BControl target; + + /** + * Instantiate a command that can create a connection between two shapes. + * + * @param source + * the source endpoint (a non-null Shape instance) + * @param lineStyle + * the desired line style. See Connection#setLineStyle(int) for + * details + * @throws IllegalArgumentException + * if source is null + * @see Connection#setLineStyle(int) + */ + public ConnectionCreateCommand(BControl source) { + if (source == null) { + throw new IllegalArgumentException(); + } + setLabel("connection creation"); + this.source = source; + } + + public boolean canExecute() { + // disallow source -> source connections + if (source.equals(target)) { + return false; + } + // return false, if the source -> target connection exists already + for (Iterator<BConnection> iter = source.getSourceConnections() + .iterator(); iter.hasNext();) { + BConnection conn = (BConnection) iter.next(); + if (conn.getTarget().equals(target)) { + return false; + } + } + return true; + } + + public void execute() { + // create a new connection between source and target + connection.setSource(source); + connection.setTarget(target); + connection.reconnect(); + } + + public void redo() { + connection.reconnect(); + } + + /** + * Set the target endpoint for the connection. + * + * @param target + * that target endpoint (a non-null Shape instance) + * @throws IllegalArgumentException + * if target is null + */ + public void setTarget(BControl target) { + if (target == null) { + throw new IllegalArgumentException(); + } + this.target = target; + } + + public void undo() { + connection.disconnect(); + } + + public void setConnection(BConnection con) { + this.connection = con; + } + + public BConnection getConnection() { + return this.connection; + } + + public BControl getSource() { + return this.source; + } + + public BControl getTarget() { + return this.target; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionDeleteCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionDeleteCommand.java index 09edf327f0d0a3371deeac2e0a94dc541a7e3661..7f6eb5653dac8d590d2c228bda4070cb5a53071f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionDeleteCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionDeleteCommand.java @@ -1,61 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Elias Volanakis and others. -�* All rights reserved. This program and the accompanying materials -�* are made available under the terms of the Eclipse Public License v1.0 -�* which accompanies this distribution, and is available at -�* http://www.eclipse.org/legal/epl-v10.html -�* -�* Contributors: -�*����Elias Volanakis - initial API and implementation -�*******************************************************************************/ -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BConnection; - -/** - * A command to disconnect (remove) a connection from its endpoints. The command - * can be undone or redone. - * - * @author Elias Volanakis - */ -public class ConnectionDeleteCommand extends Command { - - /** Connection instance to disconnect. */ - private final BConnection connection; - - /** - * Create a command that will disconnect a connection from its endpoints. - * - * @param conn - * the connection instance to disconnect (non-null) - * @throws IllegalArgumentException - * if conn is null - */ - public ConnectionDeleteCommand(BConnection conn) { - if (conn == null) { - throw new IllegalArgumentException(); - } - setLabel("connection deletion"); - this.connection = conn; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() { - connection.disconnect(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#undo() - */ - public void undo() { - connection.reconnect(); - } -} +/******************************************************************************* + * Copyright (c) 2004, 2005 Elias Volanakis and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Elias Volanakis - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BConnection; + +/** + * A command to disconnect (remove) a connection from its endpoints. The command + * can be undone or redone. + * + * @author Elias Volanakis + */ +public class ConnectionDeleteCommand extends Command { + + /** Connection instance to disconnect. */ + private final BConnection connection; + + /** + * Create a command that will disconnect a connection from its endpoints. + * + * @param conn + * the connection instance to disconnect (non-null) + * @throws IllegalArgumentException + * if conn is null + */ + public ConnectionDeleteCommand(BConnection conn) { + if (conn == null) { + throw new IllegalArgumentException(); + } + setLabel("connection deletion"); + this.connection = conn; + } + + public void execute() { + connection.disconnect(); + } + + public void undo() { + connection.reconnect(); + } +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionReconnectCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionReconnectCommand.java index 93de1bffc1bf3c7ebb9871a3f5ab8c5bb069e7d5..28c9d0e446f1acb015ef7be778dc03f59cbc0f3b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionReconnectCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ConnectionReconnectCommand.java @@ -1,208 +1,203 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Elias Volanakis and others. -�* All rights reserved. This program and the accompanying materials -�* are made available under the terms of the Eclipse Public License v1.0 -�* which accompanies this distribution, and is available at -�* http://www.eclipse.org/legal/epl-v10.html -�* -�* Contributors: -�*����Elias Volanakis - initial API and implementation -�*******************************************************************************/ -package de.bmotionstudio.gef.editor.command; - -import java.util.Iterator; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * A command to reconnect a connection to a different start point or end point. - * The command can be undone or redone. - * <p> - * This command is designed to be used together with a GraphicalNodeEditPolicy. - * To use this command propertly, following steps are necessary: - * </p> - * <ol> - * <li>Create a subclass of GraphicalNodeEditPolicy.</li> - * <li>Override the <tt>getReconnectSourceCommand(...)</tt> method. Here you - * need to obtain the Connection model element from the ReconnectRequest, create - * a new ConnectionReconnectCommand, set the new connection <i>source</i> by - * calling the <tt>setNewSource(Shape)</tt> method and return the command - * instance. - * <li>Override the <tt>getReconnectTargetCommand(...)</tt> method.</li> - * Here again you need to obtain the Connection model element from the - * ReconnectRequest, create a new ConnectionReconnectCommand, set the new - * connection <i>target</i> by calling the <tt>setNewTarget(Shape)</tt> method - * and return the command instance.</li> - * </ol> - * - * @see org.eclipse.gef.examples.shapes.parts.ShapeEditPart#createEditPolicies() - * for an example of the above procedure. - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy - * @see #setNewSource(Shape) - * @see #setNewTarget(Shape) - * @author Elias Volanakis - */ -public class ConnectionReconnectCommand extends Command { - - /** The connection instance to reconnect. */ - private BConnection connection; - /** The new source endpoint. */ - private BControl newSource; - /** The new target endpoint. */ - private BControl newTarget; - /** The original source endpoint. */ - private BControl oldSource; - /** The original target endpoint. */ - private BControl oldTarget; - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#canExecute() - */ - public boolean canExecute() { - if (newSource != null) { - return checkSourceReconnection(); - } else if (newTarget != null) { - return checkTargetReconnection(); - } - return false; - } - - /** - * Return true, if reconnecting the connection-instance to newSource is - * allowed. - */ - private boolean checkSourceReconnection() { - // connection endpoints must be different Shapes - if (newSource.equals(oldTarget)) { - return false; - } - // return false, if the connection exists already - for (Iterator<BConnection> iter = newSource.getSourceConnections() - .iterator(); iter.hasNext();) { - BConnection conn = (BConnection) iter.next(); - // return false if a newSource -> oldTarget connection exists - // already - // and it is a different instance than the connection-field - if (conn.getTarget().equals(oldTarget) && !conn.equals(connection)) { - return false; - } - } - return true; - } - - /** - * Return true, if reconnecting the connection-instance to newTarget is - * allowed. - */ - private boolean checkTargetReconnection() { - // connection endpoints must be different Shapes - if (newTarget.equals(oldSource)) { - return false; - } - // return false, if the connection exists already - for (Iterator<BConnection> iter = newTarget.getTargetConnections() - .iterator(); iter.hasNext();) { - BConnection conn = (BConnection) iter.next(); - // return false if a oldSource -> newTarget connection exists - // already - // and it is a differenct instance that the connection-field - if (conn.getSource().equals(oldSource) && !conn.equals(connection)) { - return false; - } - } - return true; - } - - /** - * Reconnect the connection to newSource (if setNewSource(...) was invoked - * before) or newTarget (if setNewTarget(...) was invoked before). - */ - public void execute() { - if (newSource != null) { - connection.reconnect(newSource, oldTarget); - } else if (newTarget != null) { - connection.reconnect(oldSource, newTarget); - } else { - throw new IllegalStateException("Should not happen"); - } - } - - /** - * Set a new source endpoint for this connection. When execute() is invoked, - * the source endpoint of the connection will be attached to the supplied - * Shape instance. - * <p> - * Note: Calling this method, deactivates reconnection of the <i>target</i> - * endpoint. A single instance of this command can only reconnect either the - * source or the target endpoint. - * </p> - * - * @param connectionSource - * a non-null Shape instance, to be used as a new source endpoint - * @throws IllegalArgumentException - * if connectionSource is null - */ - public void setNewSource(BControl connectionSource) { - if (connectionSource == null) { - throw new IllegalArgumentException(); - } - setLabel("move connection startpoint"); - newSource = connectionSource; - newTarget = null; - } - - public BControl getNewSource() { - return this.newSource; - } - - /** - * Set a new target endpoint for this connection When execute() is invoked, - * the target endpoint of the connection will be attached to the supplied - * Shape instance. - * <p> - * Note: Calling this method, deactivates reconnection of the <i>source</i> - * endpoint. A single instance of this command can only reconnect either the - * source or the target endpoint. - * </p> - * - * @param connectionTarget - * a non-null Shape instance, to be used as a new target endpoint - * @throws IllegalArgumentException - * if connectionTarget is null - */ - public void setNewTarget(BControl connectionTarget) { - if (connectionTarget == null) { - throw new IllegalArgumentException(); - } - setLabel("move connection endpoint"); - newSource = null; - newTarget = connectionTarget; - } - - public BControl getNewTarget() { - return this.newTarget; - } - - /** - * Reconnect the connection to its original source and target endpoints. - */ - public void undo() { - connection.reconnect(oldSource, oldTarget); - } - - public void setConnection(BConnection conn) { - this.connection = conn; - this.oldSource = conn.getSource(); - this.oldTarget = conn.getTarget(); - } - - public BConnection getConnection() { - return this.connection; - } - -} +/******************************************************************************* + * Copyright (c) 2004, 2005 Elias Volanakis and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Elias Volanakis - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.command; + +import java.util.Iterator; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * A command to reconnect a connection to a different start point or end point. + * The command can be undone or redone. + * <p> + * This command is designed to be used together with a GraphicalNodeEditPolicy. + * To use this command propertly, following steps are necessary: + * </p> + * <ol> + * <li>Create a subclass of GraphicalNodeEditPolicy.</li> + * <li>Override the <tt>getReconnectSourceCommand(...)</tt> method. Here you + * need to obtain the Connection model element from the ReconnectRequest, create + * a new ConnectionReconnectCommand, set the new connection <i>source</i> by + * calling the <tt>setNewSource(Shape)</tt> method and return the command + * instance. + * <li>Override the <tt>getReconnectTargetCommand(...)</tt> method.</li> + * Here again you need to obtain the Connection model element from the + * ReconnectRequest, create a new ConnectionReconnectCommand, set the new + * connection <i>target</i> by calling the <tt>setNewTarget(Shape)</tt> method + * and return the command instance.</li> + * </ol> + * + * @see org.eclipse.gef.examples.shapes.parts.ShapeEditPart#createEditPolicies() + * for an example of the above procedure. + * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy + * @see #setNewSource(Shape) + * @see #setNewTarget(Shape) + * @author Elias Volanakis + */ +public class ConnectionReconnectCommand extends Command { + + /** The connection instance to reconnect. */ + private BConnection connection; + /** The new source endpoint. */ + private BControl newSource; + /** The new target endpoint. */ + private BControl newTarget; + /** The original source endpoint. */ + private BControl oldSource; + /** The original target endpoint. */ + private BControl oldTarget; + + public boolean canExecute() { + if (newSource != null) { + return checkSourceReconnection(); + } else if (newTarget != null) { + return checkTargetReconnection(); + } + return false; + } + + /** + * Return true, if reconnecting the connection-instance to newSource is + * allowed. + */ + private boolean checkSourceReconnection() { + // connection endpoints must be different Shapes + if (newSource.equals(oldTarget)) { + return false; + } + // return false, if the connection exists already + for (Iterator<BConnection> iter = newSource.getSourceConnections() + .iterator(); iter.hasNext();) { + BConnection conn = (BConnection) iter.next(); + // return false if a newSource -> oldTarget connection exists + // already + // and it is a different instance than the connection-field + if (conn.getTarget().equals(oldTarget) && !conn.equals(connection)) { + return false; + } + } + return true; + } + + /** + * Return true, if reconnecting the connection-instance to newTarget is + * allowed. + */ + private boolean checkTargetReconnection() { + // connection endpoints must be different Shapes + if (newTarget.equals(oldSource)) { + return false; + } + // return false, if the connection exists already + for (Iterator<BConnection> iter = newTarget.getTargetConnections() + .iterator(); iter.hasNext();) { + BConnection conn = (BConnection) iter.next(); + // return false if a oldSource -> newTarget connection exists + // already + // and it is a differenct instance that the connection-field + if (conn.getSource().equals(oldSource) && !conn.equals(connection)) { + return false; + } + } + return true; + } + + /** + * Reconnect the connection to newSource (if setNewSource(...) was invoked + * before) or newTarget (if setNewTarget(...) was invoked before). + */ + public void execute() { + if (newSource != null) { + connection.reconnect(newSource, oldTarget); + } else if (newTarget != null) { + connection.reconnect(oldSource, newTarget); + } else { + throw new IllegalStateException("Should not happen"); + } + } + + /** + * Set a new source endpoint for this connection. When execute() is invoked, + * the source endpoint of the connection will be attached to the supplied + * Shape instance. + * <p> + * Note: Calling this method, deactivates reconnection of the <i>target</i> + * endpoint. A single instance of this command can only reconnect either the + * source or the target endpoint. + * </p> + * + * @param connectionSource + * a non-null Shape instance, to be used as a new source endpoint + * @throws IllegalArgumentException + * if connectionSource is null + */ + public void setNewSource(BControl connectionSource) { + if (connectionSource == null) { + throw new IllegalArgumentException(); + } + setLabel("move connection startpoint"); + newSource = connectionSource; + newTarget = null; + } + + public BControl getNewSource() { + return this.newSource; + } + + /** + * Set a new target endpoint for this connection When execute() is invoked, + * the target endpoint of the connection will be attached to the supplied + * Shape instance. + * <p> + * Note: Calling this method, deactivates reconnection of the <i>source</i> + * endpoint. A single instance of this command can only reconnect either the + * source or the target endpoint. + * </p> + * + * @param connectionTarget + * a non-null Shape instance, to be used as a new target endpoint + * @throws IllegalArgumentException + * if connectionTarget is null + */ + public void setNewTarget(BControl connectionTarget) { + if (connectionTarget == null) { + throw new IllegalArgumentException(); + } + setLabel("move connection endpoint"); + newSource = null; + newTarget = connectionTarget; + } + + public BControl getNewTarget() { + return this.newTarget; + } + + /** + * Reconnect the connection to its original source and target endpoints. + */ + public void undo() { + connection.reconnect(oldSource, oldTarget); + } + + public void setConnection(BConnection conn) { + this.connection = conn; + this.oldSource = conn.getSource(); + this.oldTarget = conn.getTarget(); + } + + public BConnection getConnection() { + return this.connection; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyCommand.java index 86190dff463fa8e2e8db039fcd6609a891555eef..553de75793ebfb692705b88bf9eba6991d7f54ce 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyCommand.java @@ -1,61 +1,61 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.ui.actions.Clipboard; - -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class CopyCommand extends Command { - - private ArrayList<BControl> list = new ArrayList<BControl>(); - - public boolean addElement(BControl control) { - if (!list.contains(control)) { - return list.add(control); - } - return false; - } - - @Override - public boolean canExecute() { - if (list == null || list.isEmpty()) - return false; - Iterator<BControl> it = list.iterator(); - while (it.hasNext()) { - if (!isCopyableControl(it.next())) - return false; - } - return true; - } - - @Override - public void execute() { - if (canExecute()) { - Clipboard.getDefault().setContents(new CopyPasteHelper(list, 10)); - } - } - - @Override - public boolean canUndo() { - return false; - } - - public boolean isCopyableControl(BControl control) { - if (!(control instanceof Visualization) - && !(control instanceof BConnection)) - return true; - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.ui.actions.Clipboard; + +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class CopyCommand extends Command { + + private ArrayList<BControl> list = new ArrayList<BControl>(); + + public boolean addElement(BControl control) { + if (!list.contains(control)) { + return list.add(control); + } + return false; + } + + @Override + public boolean canExecute() { + if (list == null || list.isEmpty()) + return false; + Iterator<BControl> it = list.iterator(); + while (it.hasNext()) { + if (!isCopyableControl(it.next())) + return false; + } + return true; + } + + @Override + public void execute() { + if (canExecute()) { + Clipboard.getDefault().setContents(new CopyPasteHelper(list, 10)); + } + } + + @Override + public boolean canUndo() { + return false; + } + + public boolean isCopyableControl(BControl control) { + if (!(control instanceof Visualization) + && !(control instanceof BConnection)) + return true; + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyPasteHelper.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyPasteHelper.java index 119d6ffef4d5a0bd0bf1183ed31a34baec46f64f..43969b95619207670b276456d5628e217bc65608 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyPasteHelper.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CopyPasteHelper.java @@ -1,46 +1,46 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class CopyPasteHelper { - - private ArrayList<BControl> list = new ArrayList<BControl>(); - private Map<BControl, BControl> alreadyCloned = new HashMap<BControl, BControl>(); - private int distance = 10; - - public CopyPasteHelper(ArrayList<BControl> list, int distance) { - this.list = list; - this.setDistance(distance); - } - - public void setList(ArrayList<BControl> list) { - this.list = list; - } - - public ArrayList<BControl> getList() { - return list; - } - - public void setDistance(int distance) { - this.distance = distance; - } - - public int getDistance() { - return distance; - } - - public Map<BControl, BControl> getAlreadyClonedMap() { - return alreadyCloned; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class CopyPasteHelper { + + private ArrayList<BControl> list = new ArrayList<BControl>(); + private Map<BControl, BControl> alreadyCloned = new HashMap<BControl, BControl>(); + private int distance = 10; + + public CopyPasteHelper(ArrayList<BControl> list, int distance) { + this.list = list; + this.setDistance(distance); + } + + public void setList(ArrayList<BControl> list) { + this.list = list; + } + + public ArrayList<BControl> getList() { + return list; + } + + public void setDistance(int distance) { + this.distance = distance; + } + + public int getDistance() { + return distance; + } + + public Map<BControl, BControl> getAlreadyClonedMap() { + return alreadyCloned; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateCommand.java index f2461937099b0b4077a63a7f0f1b2ce3f7ce1a16..e895d1f98ce6b77b92c103372c27b08cfdd641e9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateCommand.java @@ -1,60 +1,60 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class CreateCommand extends Command { - - private BControl parent; - private BControl child; - private int index = -1; - - public CreateCommand(BControl child, BControl parent) { - super(); - this.parent = parent; - this.child = child; - } - - public void setLayout(Rectangle r) { - if (child == null) - return; - child.setLayout(r); - } - - @Override - public boolean canExecute() { - if (parent == null || child == null) - return false; - return true; - } - - @Override - public void execute() { - parent.addChild(child, index); - } - - @Override - public boolean canUndo() { - if (parent == null || child == null) - return false; - return parent.contains(child); - } - - @Override - public void undo() { - parent.removeChild(child); - } - - public void setIndex(int index) { - this.index = index; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class CreateCommand extends Command { + + private BControl parent; + private BControl child; + private int index = -1; + + public CreateCommand(BControl child, BControl parent) { + super(); + this.parent = parent; + this.child = child; + } + + public void setLayout(Rectangle r) { + if (child == null) + return; + child.setLayout(r); + } + + @Override + public boolean canExecute() { + if (parent == null || child == null) + return false; + return true; + } + + @Override + public void execute() { + parent.addChild(child, index); + } + + @Override + public boolean canUndo() { + if (parent == null || child == null) + return false; + return parent.contains(child); + } + + @Override + public void undo() { + parent.removeChild(child); + } + + public void setIndex(int index) { + this.index = index; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateGuideCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateGuideCommand.java index f3d2f445b9b42811a8533b2ad1041491101eb85a..a4f452e9a6470d05eb606afb8ce1dff0253d8a90 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateGuideCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/CreateGuideCommand.java @@ -1,41 +1,41 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BMotionGuide; -import de.bmotionstudio.gef.editor.model.BMotionRuler; - -public class CreateGuideCommand extends Command { - - private BMotionGuide guide; - private BMotionRuler parent; - private int position; - - public CreateGuideCommand(BMotionRuler parent, int position) { - super("Create Guide"); - this.parent = parent; - this.position = position; - } - - public boolean canUndo() { - return true; - } - - public void execute() { - if (guide == null) - guide = new BMotionGuide(!parent.isHorizontal()); - guide.setPosition(position); - parent.addGuide(guide); - } - - public void undo() { - parent.removeGuide(guide); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.model.BMotionRuler; + +public class CreateGuideCommand extends Command { + + private BMotionGuide guide; + private BMotionRuler parent; + private int position; + + public CreateGuideCommand(BMotionRuler parent, int position) { + super("Create Guide"); + this.parent = parent; + this.position = position; + } + + public boolean canUndo() { + return true; + } + + public void execute() { + if (guide == null) + guide = new BMotionGuide(!parent.isHorizontal()); + guide.setPosition(position); + parent.addGuide(guide); + } + + public void undo() { + parent.removeGuide(guide); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteCommand.java index c6abca10c2aa75b03af902e081231c0bb5586b12..a4db8f4ea11f5f0032076c8abb7f1aabd29bd547 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteCommand.java @@ -1,47 +1,47 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class DeleteCommand extends Command { - - private BControl control; - private BControl parent; - - public DeleteCommand(BControl control, BControl parent) { - this.control = control; - this.parent = parent; - } - - @Override - public boolean canExecute() { - if (parent == null || control == null || !parent.contains(control)) - return false; - return true; - } - - @Override - public boolean canUndo() { - if (parent == null || control == null) - return false; - return !parent.contains(control); - } - - @Override - public void execute() { - this.parent.removeChild(control); - } - - @Override - public void undo() { - this.parent.addChild(control); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class DeleteCommand extends Command { + + private BControl control; + private BControl parent; + + public DeleteCommand(BControl control, BControl parent) { + this.control = control; + this.parent = parent; + } + + @Override + public boolean canExecute() { + if (parent == null || control == null || !parent.contains(control)) + return false; + return true; + } + + @Override + public boolean canUndo() { + if (parent == null || control == null) + return false; + return !parent.contains(control); + } + + @Override + public void execute() { + this.parent.removeChild(control); + } + + @Override + public void undo() { + this.parent.addChild(control); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteGuideCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteGuideCommand.java index 9870617b91747248c17940b59d0be6a4b281c7e1..4bb0001686e9e2a7eaafc21e19d43fa10d77a24e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteGuideCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/DeleteGuideCommand.java @@ -1,52 +1,52 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BMotionGuide; -import de.bmotionstudio.gef.editor.model.BMotionRuler; - -public class DeleteGuideCommand extends Command { - - private BMotionRuler parent; - private BMotionGuide guide; - private HashMap<BControl, Integer> oldParts; - - public DeleteGuideCommand(BMotionGuide guide, BMotionRuler parent) { - super("Delete Guide"); - this.guide = guide; - this.parent = parent; - } - - public boolean canUndo() { - return true; - } - - public void execute() { - oldParts = new HashMap<BControl, Integer>(guide.getMap()); - Iterator<BControl> iter = oldParts.keySet().iterator(); - while (iter.hasNext()) { - guide.detachPart((BControl) iter.next()); - } - parent.removeGuide(guide); - } - - public void undo() { - parent.addGuide(guide); - Iterator<BControl> iter = oldParts.keySet().iterator(); - while (iter.hasNext()) { - BControl part = (BControl) iter.next(); - guide.attachPart(part, ((Integer) oldParts.get(part)).intValue()); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.model.BMotionRuler; + +public class DeleteGuideCommand extends Command { + + private BMotionRuler parent; + private BMotionGuide guide; + private HashMap<BControl, Integer> oldParts; + + public DeleteGuideCommand(BMotionGuide guide, BMotionRuler parent) { + super("Delete Guide"); + this.guide = guide; + this.parent = parent; + } + + public boolean canUndo() { + return true; + } + + public void execute() { + oldParts = new HashMap<BControl, Integer>(guide.getMap()); + Iterator<BControl> iter = oldParts.keySet().iterator(); + while (iter.hasNext()) { + guide.detachPart((BControl) iter.next()); + } + parent.removeGuide(guide); + } + + public void undo() { + parent.addGuide(guide); + Iterator<BControl> iter = oldParts.keySet().iterator(); + while (iter.hasNext()) { + BControl part = (BControl) iter.next(); + guide.attachPart(part, ((Integer) oldParts.get(part)).intValue()); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/FitImageCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/FitImageCommand.java index d82996c071f62f53831bb4115eee52b96861d574..7f2b875d316e7426f97e2c3dc7cbdda17e3adb62 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/FitImageCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/FitImageCommand.java @@ -1,71 +1,71 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; - -public class FitImageCommand extends Command { - - private List<BControl> modelList = new ArrayList<BControl>(); - private Map<BControl, Rectangle> oldSizeMap = new HashMap<BControl, Rectangle>(); - private Map<BControl, Rectangle> newSizeMap = new HashMap<BControl, Rectangle>(); - - @Override - public boolean canExecute() { - return check(); - } - - @Override - public void execute() { - for (BControl control : modelList) { - oldSizeMap.put(control, control.getLayout()); - control.setLayout(newSizeMap.get(control)); - } - } - - @Override - public boolean canUndo() { - if (oldSizeMap.isEmpty()) - return false; - return check(); - } - - @Override - public void undo() { - for (BControl control : this.modelList) { - control.setLayout(oldSizeMap.get(control)); - } - } - - public void setModelList(List<BControl> modelList) { - this.modelList = modelList; - } - - public void setNewSizeMap(Map<BControl, Rectangle> newSizeMap) { - this.newSizeMap = newSizeMap; - } - - private boolean check() { - if (modelList.isEmpty() || newSizeMap.isEmpty()) - return false; - for (BControl control : modelList) { - if (!control.hasAttribute(AttributeConstants.ATTRIBUTE_IMAGE)) - return false; - } - return true; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; + +public class FitImageCommand extends Command { + + private List<BControl> modelList = new ArrayList<BControl>(); + private Map<BControl, Rectangle> oldSizeMap = new HashMap<BControl, Rectangle>(); + private Map<BControl, Rectangle> newSizeMap = new HashMap<BControl, Rectangle>(); + + @Override + public boolean canExecute() { + return check(); + } + + @Override + public void execute() { + for (BControl control : modelList) { + oldSizeMap.put(control, control.getLayout()); + control.setLayout(newSizeMap.get(control)); + } + } + + @Override + public boolean canUndo() { + if (oldSizeMap.isEmpty()) + return false; + return check(); + } + + @Override + public void undo() { + for (BControl control : this.modelList) { + control.setLayout(oldSizeMap.get(control)); + } + } + + public void setModelList(List<BControl> modelList) { + this.modelList = modelList; + } + + public void setNewSizeMap(Map<BControl, Rectangle> newSizeMap) { + this.newSizeMap = newSizeMap; + } + + private boolean check() { + if (modelList.isEmpty() || newSizeMap.isEmpty()) + return false; + for (BControl control : modelList) { + if (!control.hasAttribute(AttributeConstants.ATTRIBUTE_IMAGE)) + return false; + } + return true; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/MoveGuideCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/MoveGuideCommand.java index bcc1e2fe70e1359dc24414ef3cb7f88e115f38fa..c92ac806e952a899dd516be15005817fea2f8d76 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/MoveGuideCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/MoveGuideCommand.java @@ -1,61 +1,61 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.Iterator; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BMotionGuide; - -public class MoveGuideCommand extends Command { - - private int pDelta; - private BMotionGuide guide; - - public MoveGuideCommand(BMotionGuide guide, int positionDelta) { - super("Move Guide"); - this.guide = guide; - pDelta = positionDelta; - } - - public void execute() { - - guide.setPosition(guide.getPosition() + pDelta); - - Iterator<BControl> iter = guide.getParts().iterator(); - while (iter.hasNext()) { - BControl part = (BControl) iter.next(); - Point location = part.getLocation().getCopy(); - if (guide.isHorizontal()) { - location.y += pDelta; - } else { - location.x += pDelta; - } - part.setLocation(location); - } - - } - - public void undo() { - guide.setPosition(guide.getPosition() - pDelta); - Iterator<BControl> iter = guide.getParts().iterator(); - while (iter.hasNext()) { - BControl part = (BControl) iter.next(); - Point location = part.getLocation().getCopy(); - if (guide.isHorizontal()) { - location.y -= pDelta; - } else { - location.x -= pDelta; - } - part.setLocation(location); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.Iterator; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BMotionGuide; + +public class MoveGuideCommand extends Command { + + private int pDelta; + private BMotionGuide guide; + + public MoveGuideCommand(BMotionGuide guide, int positionDelta) { + super("Move Guide"); + this.guide = guide; + pDelta = positionDelta; + } + + public void execute() { + + guide.setPosition(guide.getPosition() + pDelta); + + Iterator<BControl> iter = guide.getParts().iterator(); + while (iter.hasNext()) { + BControl part = (BControl) iter.next(); + Point location = part.getLocation().getCopy(); + if (guide.isHorizontal()) { + location.y += pDelta; + } else { + location.x += pDelta; + } + part.setLocation(location); + } + + } + + public void undo() { + guide.setPosition(guide.getPosition() - pDelta); + Iterator<BControl> iter = guide.getParts().iterator(); + while (iter.hasNext()) { + BControl part = (BControl) iter.next(); + Point location = part.getLocation().getCopy(); + if (guide.isHorizontal()) { + location.y -= pDelta; + } else { + location.x -= pDelta; + } + part.setLocation(location); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/PasteCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/PasteCommand.java index 65f80d35058642eeb81d42fbb3350d7b4e5bbd25..04099c87e859bcc9047a8e2acf0ece2e465d331e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/PasteCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/PasteCommand.java @@ -1,188 +1,188 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.ui.actions.Clipboard; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class PasteCommand extends Command { - - private CopyPasteHelper cHelper; - - // List with mapping original BControl ==> cloned BControl - private HashMap<BControl, BControl> mappingControl = new HashMap<BControl, BControl>(); - private HashMap<BConnection, BConnection> mappingConnection = new HashMap<BConnection, BConnection>(); - - private List<BControl> parentControls = new ArrayList<BControl>(); - - @Override - public boolean canExecute() { - cHelper = (CopyPasteHelper) Clipboard.getDefault().getContents(); - if (cHelper == null) - return false; - ArrayList<BControl> myList = cHelper.getList(); - if (myList.isEmpty()) - return false; - Iterator<?> it = myList.iterator(); - while (it.hasNext()) { - BControl node = (BControl) it.next(); - if (isPastableControl(node)) { - mappingControl.put(node, null); - } - } - return true; - } - - public boolean addElement(BControl control) { - if (!parentControls.contains(control)) { - return parentControls.add(control); - } - return false; - } - - public boolean isContainer(BControl control) { - return control.canHaveChildren(); - } - - @Override - public void execute() { - - if (!canExecute()) - return; - - try { - - for (BControl parent : parentControls) { - - // Copy/Paste controls - Iterator<BControl> it = mappingControl.keySet().iterator(); - while (it.hasNext()) { - BControl control = (BControl) it.next(); - control.setParent(parent); - BControl clone = (BControl) control.clone(); - clone.setParent(parent); - int x = Integer.valueOf(Integer.valueOf(clone - .getAttributeValue(AttributeConstants.ATTRIBUTE_X) - .toString())); - int y = Integer.valueOf(Integer.valueOf(clone - .getAttributeValue(AttributeConstants.ATTRIBUTE_Y) - .toString())); - clone.setAttributeValue(AttributeConstants.ATTRIBUTE_X, x - + cHelper.getDistance()); - clone.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, y - + cHelper.getDistance()); - mappingControl.put(control, clone); - cHelper.setDistance(cHelper.getDistance() + 10); - } - - // Copy/Paste connections - HashMap<BControl, BControl> helpMap = new HashMap<BControl, BControl>(); - helpMap.putAll(cHelper.getAlreadyClonedMap()); - helpMap.putAll(mappingControl); - Iterator<BControl> it2 = helpMap.keySet().iterator(); - while (it2.hasNext()) { - BControl control = it2.next(); - // Clone connections - for (BConnection c : control.getSourceConnections()) - copyPasteConnection(c, helpMap); - for (BConnection c : control.getTargetConnections()) - copyPasteConnection(c, helpMap); - } - - redo(); - - } - - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - - } - - private void copyPasteConnection(BConnection c, - HashMap<BControl, BControl> controlMap) - throws CloneNotSupportedException { - BConnection newConnection = mappingConnection.get(c); - if (newConnection == null) { - newConnection = (BConnection) c.clone(); - newConnection.disconnect(); - mappingConnection.put(c, newConnection); - } - BControl t = controlMap.get(newConnection.getTarget()); - if (t == null) - t = newConnection.getTarget(); - BControl s = controlMap.get(newConnection.getSource()); - if (s == null) - s = newConnection.getSource(); - newConnection.setTarget(t); - newConnection.setSource(s); - } - - @Override - public void redo() { - - Iterator<BControl> it = mappingControl.values().iterator(); - while (it.hasNext()) { - BControl control = it.next(); - if (isPastableControl(control)) { - control.getParent().addChild(control); - } - } - - Iterator<BConnection> it2 = mappingConnection.values().iterator(); - while (it2.hasNext()) { - BConnection connection = it2.next(); - connection.reconnect(); - } - - } - - @Override - public boolean canUndo() { - return !(mappingControl.isEmpty()); - } - - @Override - public void undo() { - - Iterator<BControl> it = mappingControl.values().iterator(); - while (it.hasNext()) { - BControl bcontrol = it.next(); - if (isPastableControl(bcontrol)) { - bcontrol.getParent().removeChild(bcontrol); - } - } - - Iterator<BConnection> it2 = mappingConnection.values().iterator(); - while (it2.hasNext()) { - BConnection connection = it2.next(); - connection.disconnect(); - } - - } - - public boolean isPastableControl(BControl control) { - if (control instanceof Visualization) - return false; - return true; - } - - public HashMap<BControl, BControl> getList() { - return this.mappingControl; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.ui.actions.Clipboard; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class PasteCommand extends Command { + + private CopyPasteHelper cHelper; + + // List with mapping original BControl ==> cloned BControl + private HashMap<BControl, BControl> mappingControl = new HashMap<BControl, BControl>(); + private HashMap<BConnection, BConnection> mappingConnection = new HashMap<BConnection, BConnection>(); + + private List<BControl> parentControls = new ArrayList<BControl>(); + + @Override + public boolean canExecute() { + cHelper = (CopyPasteHelper) Clipboard.getDefault().getContents(); + if (cHelper == null) + return false; + ArrayList<BControl> myList = cHelper.getList(); + if (myList.isEmpty()) + return false; + Iterator<?> it = myList.iterator(); + while (it.hasNext()) { + BControl node = (BControl) it.next(); + if (isPastableControl(node)) { + mappingControl.put(node, null); + } + } + return true; + } + + public boolean addElement(BControl control) { + if (!parentControls.contains(control)) { + return parentControls.add(control); + } + return false; + } + + public boolean isContainer(BControl control) { + return control.canHaveChildren(); + } + + @Override + public void execute() { + + if (!canExecute()) + return; + + try { + + for (BControl parent : parentControls) { + + // Copy/Paste controls + Iterator<BControl> it = mappingControl.keySet().iterator(); + while (it.hasNext()) { + BControl control = (BControl) it.next(); + control.setParent(parent); + BControl clone = (BControl) control.clone(); + clone.setParent(parent); + int x = Integer.valueOf(Integer.valueOf(clone + .getAttributeValue(AttributeConstants.ATTRIBUTE_X) + .toString())); + int y = Integer.valueOf(Integer.valueOf(clone + .getAttributeValue(AttributeConstants.ATTRIBUTE_Y) + .toString())); + clone.setAttributeValue(AttributeConstants.ATTRIBUTE_X, x + + cHelper.getDistance()); + clone.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, y + + cHelper.getDistance()); + mappingControl.put(control, clone); + cHelper.setDistance(cHelper.getDistance() + 10); + } + + // Copy/Paste connections + HashMap<BControl, BControl> helpMap = new HashMap<BControl, BControl>(); + helpMap.putAll(cHelper.getAlreadyClonedMap()); + helpMap.putAll(mappingControl); + Iterator<BControl> it2 = helpMap.keySet().iterator(); + while (it2.hasNext()) { + BControl control = it2.next(); + // Clone connections + for (BConnection c : control.getSourceConnections()) + copyPasteConnection(c, helpMap); + for (BConnection c : control.getTargetConnections()) + copyPasteConnection(c, helpMap); + } + + redo(); + + } + + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + + } + + private void copyPasteConnection(BConnection c, + HashMap<BControl, BControl> controlMap) + throws CloneNotSupportedException { + BConnection newConnection = mappingConnection.get(c); + if (newConnection == null) { + newConnection = (BConnection) c.clone(); + newConnection.disconnect(); + mappingConnection.put(c, newConnection); + } + BControl t = controlMap.get(newConnection.getTarget()); + if (t == null) + t = newConnection.getTarget(); + BControl s = controlMap.get(newConnection.getSource()); + if (s == null) + s = newConnection.getSource(); + newConnection.setTarget(t); + newConnection.setSource(s); + } + + @Override + public void redo() { + + Iterator<BControl> it = mappingControl.values().iterator(); + while (it.hasNext()) { + BControl control = it.next(); + if (isPastableControl(control)) { + control.getParent().addChild(control); + } + } + + Iterator<BConnection> it2 = mappingConnection.values().iterator(); + while (it2.hasNext()) { + BConnection connection = it2.next(); + connection.reconnect(); + } + + } + + @Override + public boolean canUndo() { + return !(mappingControl.isEmpty()); + } + + @Override + public void undo() { + + Iterator<BControl> it = mappingControl.values().iterator(); + while (it.hasNext()) { + BControl bcontrol = it.next(); + if (isPastableControl(bcontrol)) { + bcontrol.getParent().removeChild(bcontrol); + } + } + + Iterator<BConnection> it2 = mappingConnection.values().iterator(); + while (it2.hasNext()) { + BConnection connection = it2.next(); + connection.disconnect(); + } + + } + + public boolean isPastableControl(BControl control) { + if (control instanceof Visualization) + return false; + return true; + } + + public HashMap<BControl, BControl> getList() { + return this.mappingControl; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveObserverCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveObserverCommand.java index e1b703e321e681f65257c67d14a13338a85d583f..c8afdf5d659feb35e0165701bcd684d97e087060 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveObserverCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveObserverCommand.java @@ -1,47 +1,47 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; - -public class RemoveObserverCommand extends Command { - - private BControl control; - private Observer observer; - - public void execute() { - control.removeObserver(observer.getID()); - } - - public boolean canExecute() { - return true; - } - - public void undo() { - control.addObserver(observer); - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return control; - } - - public void setObserver(Observer observer) { - this.observer = observer; - } - - public Observer getObserver() { - return observer; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; + +public class RemoveObserverCommand extends Command { + + private BControl control; + private Observer observer; + + public void execute() { + control.removeObserver(observer.getID()); + } + + public boolean canExecute() { + return true; + } + + public void undo() { + control.addObserver(observer); + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return control; + } + + public void setObserver(Observer observer) { + this.observer = observer; + } + + public Observer getObserver() { + return observer; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveSchedulerEventCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveSchedulerEventCommand.java index 804d579c122c9bfbd95d0db2ab9585fa64c4f87b..6a13866e86c732cef8b4df7208e1565e2549b027 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveSchedulerEventCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RemoveSchedulerEventCommand.java @@ -1,47 +1,47 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public class RemoveSchedulerEventCommand extends Command { - - private BControl control; - private SchedulerEvent schedulerEvent; - - public void execute() { - control.removeEvent(schedulerEvent.getEventID()); - } - - public boolean canExecute() { - return true; - } - - public void undo() { - control.addEvent(schedulerEvent.getEventID(), schedulerEvent); - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return control; - } - - public void setSchedulerEvent(SchedulerEvent schedulerEvent) { - this.schedulerEvent = schedulerEvent; - } - - public SchedulerEvent getSchedulerEvent() { - return this.schedulerEvent; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public class RemoveSchedulerEventCommand extends Command { + + private BControl control; + private SchedulerEvent schedulerEvent; + + public void execute() { + control.removeEvent(schedulerEvent.getEventID()); + } + + public boolean canExecute() { + return true; + } + + public void undo() { + control.addEvent(schedulerEvent.getEventID(), schedulerEvent); + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return control; + } + + public void setSchedulerEvent(SchedulerEvent schedulerEvent) { + this.schedulerEvent = schedulerEvent; + } + + public SchedulerEvent getSchedulerEvent() { + return this.schedulerEvent; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RenameCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RenameCommand.java index 717444d85ff9e468907e51d45eee00dc3ef97838..0f0ffbc055eabc3596b19b2f64f38e9ba6af52f4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RenameCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/RenameCommand.java @@ -1,61 +1,61 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; - -public class RenameCommand extends Command { - - private BControl control; - private String oldString; - private String newString; - - public void setControl(BControl control) { - this.control = control; - } - - public void setNewString(String newString) { - this.newString = newString; - } - - @Override - public boolean canExecute() { - return checkControl(); - } - - @Override - public boolean canUndo() { - if (oldString == null) - return false; - return checkControl(); - } - - private boolean checkControl() { - if (control == null || newString == null - || !control.hasAttribute(AttributeConstants.ATTRIBUTE_TEXT)) - return false; - return true; - } - - @Override - public void execute() { - this.oldString = control.getAttributeValue( - AttributeConstants.ATTRIBUTE_TEXT).toString(); - this.control.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, - newString); - } - - @Override - public void undo() { - this.control.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, - oldString); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; + +public class RenameCommand extends Command { + + private BControl control; + private String oldString; + private String newString; + + public void setControl(BControl control) { + this.control = control; + } + + public void setNewString(String newString) { + this.newString = newString; + } + + @Override + public boolean canExecute() { + return checkControl(); + } + + @Override + public boolean canUndo() { + if (oldString == null) + return false; + return checkControl(); + } + + private boolean checkControl() { + if (control == null || newString == null + || !control.hasAttribute(AttributeConstants.ATTRIBUTE_TEXT)) + return false; + return true; + } + + @Override + public void execute() { + this.oldString = control.getAttributeValue( + AttributeConstants.ATTRIBUTE_TEXT).toString(); + this.control.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, + newString); + } + + @Override + public void undo() { + this.control.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, + oldString); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ReorderPartCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ReorderPartCommand.java index 4303b61d04b346d1cca0f5183310ab92c34f5eb8..d03fbf90f94094cfeb318414e5ba4906630c45e8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ReorderPartCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/ReorderPartCommand.java @@ -1,36 +1,36 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; - -public class ReorderPartCommand extends Command { - - private int oldIndex, newIndex; - private BControl child; - private BControl parent; - - public ReorderPartCommand(BControl child, BControl parent, int newIndex) { - super("Reorder Control"); - this.child = child; - this.parent = parent; - this.newIndex = newIndex; - } - - public void execute() { - oldIndex = parent.getChildrenArray().indexOf(child); - parent.removeChild(child); - parent.addChild(child, newIndex); - } - - public void undo() { - parent.removeChild(child); - parent.addChild(child, oldIndex); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; + +public class ReorderPartCommand extends Command { + + private int oldIndex, newIndex; + private BControl child; + private BControl parent; + + public ReorderPartCommand(BControl child, BControl parent, int newIndex) { + super("Reorder Control"); + this.child = child; + this.parent = parent; + this.newIndex = newIndex; + } + + public void execute() { + oldIndex = parent.getChildrenArray().indexOf(child); + parent.removeChild(child); + parent.addChild(child, newIndex); + } + + public void undo() { + parent.removeChild(child); + parent.addChild(child, oldIndex); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SchedulerEventCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SchedulerEventCommand.java index 8f4465cb39d2e8c7a9cf9358bb6a1873a3fe0b20..94f35894d9552d81d311490a9c6381ab1dc39608 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SchedulerEventCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SchedulerEventCommand.java @@ -1,95 +1,95 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public class SchedulerEventCommand extends Command { - - private String className; - private String eventID; - private SchedulerEvent clonedSchedulerEvent; - private SchedulerEvent newSchedulerEvent; - private SchedulerEvent clonedNewSchedulerEvent; - private BControl control; - - public void execute() { - - try { - clonedNewSchedulerEvent = newSchedulerEvent.clone(); - } catch (CloneNotSupportedException e) { - } - - if (clonedSchedulerEvent == null) { - control.addEvent(eventID, newSchedulerEvent); - } - - } - - public boolean canExecute() { - return true; - } - - public void undo() { - - // Remove completely new Observer - if (clonedSchedulerEvent == null) { - control.removeEvent(eventID); - } else { // Reset Observer - control.addEvent(eventID, clonedSchedulerEvent); - } - - } - - public void redo() { - control.addEvent(eventID, clonedNewSchedulerEvent); - } - - public void setClassName(String className) { - this.className = className; - } - - public String getClassName() { - return className; - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return this.control; - } - - public String getEventID() { - return eventID; - } - - public void setEventID(String eventID) { - this.eventID = eventID; - } - - public SchedulerEvent getClonedSchedulerEvent() { - return clonedSchedulerEvent; - } - - public void setClonedSchedulerEvent(SchedulerEvent clonedSchedulerEvent) { - this.clonedSchedulerEvent = clonedSchedulerEvent; - } - - public SchedulerEvent getNewSchedulerEvent() { - return newSchedulerEvent; - } - - public void setNewSchedulerEvent(SchedulerEvent newSchedulerEvent) { - this.newSchedulerEvent = newSchedulerEvent; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public class SchedulerEventCommand extends Command { + + private String className; + private String eventID; + private SchedulerEvent clonedSchedulerEvent; + private SchedulerEvent newSchedulerEvent; + private SchedulerEvent clonedNewSchedulerEvent; + private BControl control; + + public void execute() { + + try { + clonedNewSchedulerEvent = newSchedulerEvent.clone(); + } catch (CloneNotSupportedException e) { + } + + if (clonedSchedulerEvent == null) { + control.addEvent(eventID, newSchedulerEvent); + } + + } + + public boolean canExecute() { + return true; + } + + public void undo() { + + // Remove completely new Observer + if (clonedSchedulerEvent == null) { + control.removeEvent(eventID); + } else { // Reset Observer + control.addEvent(eventID, clonedSchedulerEvent); + } + + } + + public void redo() { + control.addEvent(eventID, clonedNewSchedulerEvent); + } + + public void setClassName(String className) { + this.className = className; + } + + public String getClassName() { + return className; + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return this.control; + } + + public String getEventID() { + return eventID; + } + + public void setEventID(String eventID) { + this.eventID = eventID; + } + + public SchedulerEvent getClonedSchedulerEvent() { + return clonedSchedulerEvent; + } + + public void setClonedSchedulerEvent(SchedulerEvent clonedSchedulerEvent) { + this.clonedSchedulerEvent = clonedSchedulerEvent; + } + + public SchedulerEvent getNewSchedulerEvent() { + return newSchedulerEvent; + } + + public void setNewSchedulerEvent(SchedulerEvent newSchedulerEvent) { + this.newSchedulerEvent = newSchedulerEvent; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SetObserverCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SetObserverCommand.java index 76d48c5491d39d8b67579dbb2c04b775c803a23f..784bba52a584dd0c0222de6311553b1521b3137c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SetObserverCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/SetObserverCommand.java @@ -1,78 +1,78 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.command; - -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; - -public class SetObserverCommand extends Command { - - private Observer oldObserver; - private Observer newObserver; - private Observer clonedNewObserver; - private BControl control; - - public void execute() { - // Clone the new observer - try { - clonedNewObserver = newObserver.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - // Set the new observer - control.addObserver(newObserver); - } - - public boolean canExecute() { - if (newObserver == null || control == null) - return false; - return true; - } - - public void undo() { - // If we had an old observer, set the old one - if (oldObserver != null) { - control.addObserver(oldObserver); - // else remove the observer - } else { - control.removeObserver(newObserver); - } - } - - public void redo() { - // Redo method adds the cloned observer, since the observer could be - // changed during set and redo action - control.addObserver(clonedNewObserver); - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return this.control; - } - - public Observer getOldObserver() { - return oldObserver; - } - - public void setOldObserver(Observer oldObserver) { - this.oldObserver = oldObserver; - } - - public Observer getNewObserver() { - return newObserver; - } - - public void setNewObserver(Observer newObserver) { - this.newObserver = newObserver; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.command; + +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; + +public class SetObserverCommand extends Command { + + private Observer oldObserver; + private Observer newObserver; + private Observer clonedNewObserver; + private BControl control; + + public void execute() { + // Clone the new observer + try { + clonedNewObserver = newObserver.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + // Set the new observer + control.addObserver(newObserver); + } + + public boolean canExecute() { + if (newObserver == null || control == null) + return false; + return true; + } + + public void undo() { + // If we had an old observer, set the old one + if (oldObserver != null) { + control.addObserver(oldObserver); + // else remove the observer + } else { + control.removeObserver(newObserver); + } + } + + public void redo() { + // Redo method adds the cloned observer, since the observer could be + // changed during set and redo action + control.addObserver(clonedNewObserver); + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return this.control; + } + + public Observer getOldObserver() { + return oldObserver; + } + + public void setOldObserver(Observer oldObserver) { + this.oldObserver = oldObserver; + } + + public Observer getNewObserver() { + return newObserver; + } + + public void setNewObserver(Observer newObserver) { + this.newObserver = newObserver; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/AttributeExpressionEdittingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/AttributeExpressionEdittingSupport.java index eac88df0edaa01f81b2a9fc5ac5ab1396e38e546..6a61a01087a1889376dcbc821ce540dbb84f773f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/AttributeExpressionEdittingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/AttributeExpressionEdittingSupport.java @@ -1,109 +1,109 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class AttributeExpressionEdittingSupport extends EditingSupport { - - private CellEditor cellEditor; - - private BControl control; - - private String stdAttribute; - - public AttributeExpressionEdittingSupport(ColumnViewer viewer, - BControl control) { - this(viewer, control, null); - } - - public AttributeExpressionEdittingSupport(ColumnViewer viewer, - BControl control, String stdAttribute) { - super(viewer); - this.control = control; - this.stdAttribute = stdAttribute; - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - - @Override - protected Object getValue(Object element) { - ObserverEvalObject evalObject = (ObserverEvalObject) element; - return evalObject.getValue(); - } - - @Override - protected void setValue(Object element, Object value) { - if (value == null) - return; - ((ObserverEvalObject) element).setValue(value); - } - - @Override - protected CellEditor getCellEditor(Object element) { - - ObserverEvalObject obj = ((ObserverEvalObject) element); - - if (obj.isExpressionMode()) { - if (cellEditor == null) { - cellEditor = new TextCellEditor((Composite) getViewer() - .getControl()); - } - return cellEditor; - } else { - - String atrID = stdAttribute; - - if (atrID == null) - atrID = obj.getAttribute(); - - if (atrID != null) { - if (atrID.length() > 0) { - AbstractAttribute atr = getControl().getAttributes().get( - atrID); - PropertyDescriptor desc = atr.getPropertyDescriptor(); - return desc.createPropertyEditor((Composite) getViewer() - .getControl()); - } - } - - } - - return null; - - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return control; - } - - public void setStdAttribute(String stdAttribute) { - this.stdAttribute = stdAttribute; - } - - public String getStdAttribute() { - return stdAttribute; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class AttributeExpressionEdittingSupport extends EditingSupport { + + private CellEditor cellEditor; + + private BControl control; + + private String stdAttribute; + + public AttributeExpressionEdittingSupport(ColumnViewer viewer, + BControl control) { + this(viewer, control, null); + } + + public AttributeExpressionEdittingSupport(ColumnViewer viewer, + BControl control, String stdAttribute) { + super(viewer); + this.control = control; + this.stdAttribute = stdAttribute; + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + + @Override + protected Object getValue(Object element) { + ObserverEvalObject evalObject = (ObserverEvalObject) element; + return evalObject.getValue(); + } + + @Override + protected void setValue(Object element, Object value) { + if (value == null) + return; + ((ObserverEvalObject) element).setValue(value); + } + + @Override + protected CellEditor getCellEditor(Object element) { + + ObserverEvalObject obj = ((ObserverEvalObject) element); + + if (obj.isExpressionMode()) { + if (cellEditor == null) { + cellEditor = new TextCellEditor((Composite) getViewer() + .getControl()); + } + return cellEditor; + } else { + + String atrID = stdAttribute; + + if (atrID == null) + atrID = obj.getAttribute(); + + if (atrID != null) { + if (atrID.length() > 0) { + AbstractAttribute atr = getControl().getAttributes().get( + atrID); + PropertyDescriptor desc = atr.getPropertyDescriptor(); + return desc.createPropertyEditor((Composite) getViewer() + .getControl()); + } + } + + } + + return null; + + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return control; + } + + public void setStdAttribute(String stdAttribute) { + this.stdAttribute = stdAttribute; + } + + public String getStdAttribute() { + return stdAttribute; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IPopupListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IPopupListener.java index b7464ec82ed4df967dd6aeb47ec4d0773012323b..b52aeba1b30c996e86ff3714963a81b661bbd015 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IPopupListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IPopupListener.java @@ -1,15 +1,15 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -public interface IPopupListener { - - public void popupOpened(); - - public void popupClosed(); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +public interface IPopupListener { + + public void popupOpened(); + + public void popupClosed(); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IntEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IntEditingSupport.java index 6444776b7a9ce6fc20ad45b5b367ea5bf04649e4..26a29edce7e266323476ee97fd7d482c7a9906b0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IntEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IntEditingSupport.java @@ -1,64 +1,64 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -public class IntEditingSupport extends ObservableValueEditingSupport { - - private CellEditor cellEditor; - private String atr; - - public IntEditingSupport(TableViewer tv, DataBindingContext dbc, String atr) { - super(tv, dbc); - this.atr = atr; - cellEditor = new TextCellEditor((Composite) tv.getControl()); - cellEditor.getControl().addListener(SWT.Verify, new Listener() { - public void handleEvent(Event e) { - String string = e.text; - char[] chars = new char[string.length()]; - string.getChars(0, chars.length, chars, 0); - for (int i = 0; i < chars.length; i++) { - if (!('0' <= chars[i] && chars[i] <= '9')) { - e.doit = false; - return; - } - } - } - }); - } - - @Override - protected IObservableValue doCreateCellEditorObservable( - CellEditor cellEditor) { - return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); - } - - @Override - protected IObservableValue doCreateElementObservable(Object element, - ViewerCell cell) { - return BeansObservables.observeValue(element, atr); - } - - @Override - protected CellEditor getCellEditor(Object element) { - return cellEditor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +public class IntEditingSupport extends ObservableValueEditingSupport { + + private CellEditor cellEditor; + private String atr; + + public IntEditingSupport(TableViewer tv, DataBindingContext dbc, String atr) { + super(tv, dbc); + this.atr = atr; + cellEditor = new TextCellEditor((Composite) tv.getControl()); + cellEditor.getControl().addListener(SWT.Verify, new Listener() { + public void handleEvent(Event e) { + String string = e.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + for (int i = 0; i < chars.length; i++) { + if (!('0' <= chars[i] && chars[i] <= '9')) { + e.doit = false; + return; + } + } + } + }); + } + + @Override + protected IObservableValue doCreateCellEditorObservable( + CellEditor cellEditor) { + return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); + } + + @Override + protected IObservableValue doCreateElementObservable(Object element, + ViewerCell cell) { + return BeansObservables.observeValue(element, atr); + } + + @Override + protected CellEditor getCellEditor(Object element) { + return cellEditor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IsExpressionModeEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IsExpressionModeEditingSupport.java index e24284f8a551278d12a408e59e4f5097e9561352..8da5687335cc6eb47ca025b7636184c321a5473f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IsExpressionModeEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/IsExpressionModeEditingSupport.java @@ -1,75 +1,75 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.swt.widgets.Composite; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; - -public class IsExpressionModeEditingSupport extends EditingSupport { - - private CellEditor cellEditor; - - private BControl control; - - public IsExpressionModeEditingSupport(ColumnViewer viewer, BControl control) { - super(viewer); - this.control = control; - } - - @Override - protected void setValue(Object element, Object value) { - Boolean bol = Boolean.valueOf(String.valueOf(value)); - ObserverEvalObject obj = (ObserverEvalObject) element; - obj.setIsExpressionMode(bol); - if (obj.getAttribute() != null) { - AbstractAttribute atr = getControl().getAttributes().get( - obj.getAttribute()); - if (atr != null) { - if (!bol) { - obj.setValue(atr.getValue()); - } else { - obj.setValue(atr.getValue().toString()); - } - } - } - } - - @Override - protected Object getValue(Object element) { - Boolean b = ((ObserverEvalObject) element).isExpressionMode(); - return b != null ? b : false; - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) - cellEditor = new CheckboxCellEditor((Composite) getViewer() - .getControl()); - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - public void setControl(BControl control) { - this.control = control; - } - - public BControl getControl() { - return control; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.swt.widgets.Composite; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; + +public class IsExpressionModeEditingSupport extends EditingSupport { + + private CellEditor cellEditor; + + private BControl control; + + public IsExpressionModeEditingSupport(ColumnViewer viewer, BControl control) { + super(viewer); + this.control = control; + } + + @Override + protected void setValue(Object element, Object value) { + Boolean bol = Boolean.valueOf(String.valueOf(value)); + ObserverEvalObject obj = (ObserverEvalObject) element; + obj.setIsExpressionMode(bol); + if (obj.getAttribute() != null) { + AbstractAttribute atr = getControl().getAttributes().get( + obj.getAttribute()); + if (atr != null) { + if (!bol) { + obj.setValue(atr.getValue()); + } else { + obj.setValue(atr.getValue().toString()); + } + } + } + } + + @Override + protected Object getValue(Object element) { + Boolean b = ((ObserverEvalObject) element).isExpressionMode(); + return b != null ? b : false; + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) + cellEditor = new CheckboxCellEditor((Composite) getViewer() + .getControl()); + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return true; + } + + public void setControl(BControl control) { + this.control = control; + } + + public BControl getControl() { + return control; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/OperationValueEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/OperationValueEditingSupport.java index a33391f9387d655ea9271aea61af1a210891c694..6eccabfec64493bae578f3e98147b30332475a43 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/OperationValueEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/OperationValueEditingSupport.java @@ -1,76 +1,76 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.observable.list.ComputedList; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import de.bmotionstudio.gef.editor.eventb.EventBHelper; -import de.bmotionstudio.gef.editor.eventb.MachineContentObject; -import de.bmotionstudio.gef.editor.eventb.MachineOperation; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class OperationValueEditingSupport extends EditingSupport { - - private ComboBoxViewerCellEditor cellEditor = null; - - private BControl control; - - public OperationValueEditingSupport(TableViewer cv, BControl control) { - super(cv); - this.control = control; - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - - @Override - protected Object getValue(Object element) { - return ((PredicateOperation) element).getOperationName(); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) - ((PredicateOperation) element).setOperationName(value.toString()); - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer() - .getControl(), SWT.READ_ONLY); - cellEditor.setContentProvider(new ObservableListContentProvider()); - cellEditor.setInput(new ComputedList() { - @Override - protected List<String> calculate() { - ArrayList<String> tmpList = new ArrayList<String>(); - for (MachineContentObject op : EventBHelper - .getOperations(control.getVisualization())) { - tmpList.add(((MachineOperation) op).getLabel()); - } - return tmpList; - } - }); - } - return cellEditor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.observable.list.ComputedList; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +import de.bmotionstudio.gef.editor.eventb.EventBHelper; +import de.bmotionstudio.gef.editor.eventb.MachineContentObject; +import de.bmotionstudio.gef.editor.eventb.MachineOperation; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class OperationValueEditingSupport extends EditingSupport { + + private ComboBoxViewerCellEditor cellEditor = null; + + private BControl control; + + public OperationValueEditingSupport(TableViewer cv, BControl control) { + super(cv); + this.control = control; + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + + @Override + protected Object getValue(Object element) { + return ((PredicateOperation) element).getOperationName(); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) + ((PredicateOperation) element).setOperationName(value.toString()); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer() + .getControl(), SWT.READ_ONLY); + cellEditor.setContentProvider(new ObservableListContentProvider()); + cellEditor.setInput(new ComputedList() { + @Override + protected List<String> calculate() { + ArrayList<String> tmpList = new ArrayList<String>(); + for (MachineContentObject op : EventBHelper + .getOperations(control.getVisualization())) { + tmpList.add(((MachineOperation) op).getLabel()); + } + return tmpList; + } + }); + } + return cellEditor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupCellEditor.java index ce154fa7e7444987cdbadaa417965323746e67c4..4755623ac54ecf575e1e27dc3e2860aaf3bfbb70 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupCellEditor.java @@ -1,78 +1,78 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * @author Lukas Ladenberger - * - */ -public class PopupCellEditor extends TextCellEditor { - - private Shell parentShell; - private TextEditorWindow dialog; - // private int test = 0; - private boolean isOpen = false; - private int counter = 0; - - public PopupCellEditor(Composite parent, Shell parentShell) { - super(parent); - this.parentShell = parentShell; - text.addFocusListener(new FocusListener() { - @Override - public void focusLost(FocusEvent evt) { - } - - @Override - public void focusGained(FocusEvent evt) { - if (!isOpen && counter == 0) { - counter = counter + 1; - openDialogBox(); - } else if (counter == 1) { - counter = 0; - } - } - }); - } - - protected void openDialogBox() { - dialog = new TextEditorWindow(this.parentShell, text); - dialog.addPopupListener(new IPopupListener() { - @Override - public void popupOpened() { - isOpen = true; - } - - @Override - public void popupClosed() { - isOpen = false; - } - }); - PopupResult result = dialog.openPopup(); - if (result.getReturncode() == Window.OK) { - setValue(result.getValue()); - } else if (result.getReturncode() == Window.CANCEL) { - } - } - - @Override - protected void focusLost() { - if (!isOpen) - super.focusLost(); - } - - @Override - protected boolean dependsOnExternalFocusListener() { - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Lukas Ladenberger + * + */ +public class PopupCellEditor extends TextCellEditor { + + private Shell parentShell; + private TextEditorWindow dialog; + // private int test = 0; + private boolean isOpen = false; + private int counter = 0; + + public PopupCellEditor(Composite parent, Shell parentShell) { + super(parent); + this.parentShell = parentShell; + text.addFocusListener(new FocusListener() { + @Override + public void focusLost(FocusEvent evt) { + } + + @Override + public void focusGained(FocusEvent evt) { + if (!isOpen && counter == 0) { + counter = counter + 1; + openDialogBox(); + } else if (counter == 1) { + counter = 0; + } + } + }); + } + + protected void openDialogBox() { + dialog = new TextEditorWindow(this.parentShell, text); + dialog.addPopupListener(new IPopupListener() { + @Override + public void popupOpened() { + isOpen = true; + } + + @Override + public void popupClosed() { + isOpen = false; + } + }); + PopupResult result = dialog.openPopup(); + if (result.getReturncode() == Window.OK) { + setValue(result.getValue()); + } else if (result.getReturncode() == Window.CANCEL) { + } + } + + @Override + protected void focusLost() { + if (!isOpen) + super.focusLost(); + } + + @Override + protected boolean dependsOnExternalFocusListener() { + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupResult.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupResult.java index 14d87a770d015f00473261e0222a5f5266e7a92e..6ea2daacce66f947ed5f13e743d52df601a0ade9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupResult.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PopupResult.java @@ -1,33 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.edit; - -/** - * @author Lukas Ladenberger - * - */ -public class PopupResult { - - private String value; - private int returncode; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public void setReturncode(int returncode) { - this.returncode = returncode; - } - - public int getReturncode() { - return returncode; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.edit; + +/** + * @author Lukas Ladenberger + * + */ +public class PopupResult { + + private String value; + private int returncode; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public void setReturncode(int returncode) { + this.returncode = returncode; + } + + public int getReturncode() { + return returncode; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PredicateEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PredicateEditingSupport.java index 44958fce0ab5c94416c419b216363591e59dbcfc..3ad7a19c1f4759664cc307585af02d3c5c3197cd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PredicateEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/PredicateEditingSupport.java @@ -1,63 +1,63 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -/** - * @author Lukas Ladenberger - * - */ -public class PredicateEditingSupport extends ObservableValueEditingSupport { - - private TextCellEditor cellEditor; - private String property; - - public PredicateEditingSupport(TableViewer viewer, DataBindingContext dbc, - String property, Visualization visualization, Shell shell) { - super(viewer, dbc); - this.property = property; - this.cellEditor = new PopupCellEditor((Composite) getViewer() - .getControl(), shell); - } - - @Override - protected IObservableValue doCreateCellEditorObservable( - CellEditor cellEditor) { - return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); - } - - @Override - protected IObservableValue doCreateElementObservable(Object element, - ViewerCell cell) { - return BeansObservables.observeValue(element, property); - } - - @Override - protected CellEditor getCellEditor(Object element) { - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +/** + * @author Lukas Ladenberger + * + */ +public class PredicateEditingSupport extends ObservableValueEditingSupport { + + private TextCellEditor cellEditor; + private String property; + + public PredicateEditingSupport(TableViewer viewer, DataBindingContext dbc, + String property, Visualization visualization, Shell shell) { + super(viewer, dbc); + this.property = property; + this.cellEditor = new PopupCellEditor((Composite) getViewer() + .getControl(), shell); + } + + @Override + protected IObservableValue doCreateCellEditorObservable( + CellEditor cellEditor) { + return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); + } + + @Override + protected IObservableValue doCreateElementObservable(Object element, + ViewerCell cell) { + return BeansObservables.observeValue(element, property); + } + + @Override + protected CellEditor getCellEditor(Object element) { + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorLocator.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorLocator.java index db6448097bb0a2baf40351c365fef23f462b889d..ff822972b3615762b319ee29b5eb33d936c10de9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorLocator.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorLocator.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Text; - -public class TextCellEditorLocator implements CellEditorLocator { - - private IFigure textField; - - public TextCellEditorLocator(IFigure textField) { - setTextField(textField); - } - - public void relocate(CellEditor celleditor) { - Text text = (Text) celleditor.getControl(); - Rectangle rect = textField.getClientArea(); - textField.translateToAbsolute(rect); - org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0); - rect.translate(trim.x, trim.y); - rect.width += trim.width; - rect.height += trim.height; - text.setBounds(rect.x, rect.y, rect.width, rect.height); - } - - protected IFigure getTextField() { - return textField; - } - - protected void setTextField(IFigure textField) { - this.textField = textField; - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.widgets.Text; + +public class TextCellEditorLocator implements CellEditorLocator { + + private IFigure textField; + + public TextCellEditorLocator(IFigure textField) { + setTextField(textField); + } + + public void relocate(CellEditor celleditor) { + Text text = (Text) celleditor.getControl(); + Rectangle rect = textField.getClientArea(); + textField.translateToAbsolute(rect); + org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0); + rect.translate(trim.x, trim.y); + rect.width += trim.width; + rect.height += trim.height; + text.setBounds(rect.x, rect.y, rect.width, rect.height); + } + + protected IFigure getTextField() { + return textField; + } + + protected void setTextField(IFigure textField) { + this.textField = textField; + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorWithContentProposal.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorWithContentProposal.java index 285034bd2235f71373d4128e903eceda1e2e4780..9aed0adb512006db078ec2440b6fdeaa7063d1aa 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorWithContentProposal.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextCellEditorWithContentProposal.java @@ -1,86 +1,86 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.fieldassist.ContentProposalAdapter; -import org.eclipse.jface.fieldassist.IContentProposalListener2; -import org.eclipse.jface.fieldassist.IContentProposalProvider; -import org.eclipse.jface.fieldassist.TextContentAdapter; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.widgets.Composite; - -/** - * @author Lukas Ladenberger - * - */ -public class TextCellEditorWithContentProposal extends TextCellEditor { - - private ContentProposalAdapter contentProposalAdapter; - private boolean popupOpen = false; // true, iff popup is currently open - - public TextCellEditorWithContentProposal(Composite parent, - IContentProposalProvider contentProposalProvider, - KeyStroke keyStroke, char[] autoActivationCharacters) { - super(parent); - - enableContentProposal(contentProposalProvider, keyStroke, - autoActivationCharacters); - } - - private void enableContentProposal( - IContentProposalProvider contentProposalProvider, - KeyStroke keyStroke, char[] autoActivationCharacters) { - contentProposalAdapter = new ContentProposalAdapter(text, - new TextContentAdapter(), contentProposalProvider, keyStroke, - autoActivationCharacters); - - // Listen for popup open/close events to be able to handle focus events - // correctly - contentProposalAdapter - .addContentProposalListener(new IContentProposalListener2() { - - public void proposalPopupClosed( - ContentProposalAdapter adapter) { - popupOpen = false; - } - - public void proposalPopupOpened( - ContentProposalAdapter adapter) { - popupOpen = true; - } - }); - } - - /** - * Return the {@link ContentProposalAdapter} of this cell editor. - * - * @return the {@link ContentProposalAdapter} - */ - public ContentProposalAdapter getContentProposalAdapter() { - return contentProposalAdapter; - } - - protected void focusLost() { - if (!popupOpen) { - // Focus lost deactivates the cell editor. - // This must not happen if focus lost was caused by activating - // the completion proposal popup. - super.focusLost(); - } - } - - protected boolean dependsOnExternalFocusListener() { - // Always return false; - // Otherwise, the ColumnViewerEditor will install an additional focus - // listener - // that cancels cell editing on focus lost, even if focus gets lost due - // to - // activation of the completion proposal popup. See also bug 58777. - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.IContentProposalListener2; +import org.eclipse.jface.fieldassist.IContentProposalProvider; +import org.eclipse.jface.fieldassist.TextContentAdapter; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Lukas Ladenberger + * + */ +public class TextCellEditorWithContentProposal extends TextCellEditor { + + private ContentProposalAdapter contentProposalAdapter; + private boolean popupOpen = false; // true, iff popup is currently open + + public TextCellEditorWithContentProposal(Composite parent, + IContentProposalProvider contentProposalProvider, + KeyStroke keyStroke, char[] autoActivationCharacters) { + super(parent); + + enableContentProposal(contentProposalProvider, keyStroke, + autoActivationCharacters); + } + + private void enableContentProposal( + IContentProposalProvider contentProposalProvider, + KeyStroke keyStroke, char[] autoActivationCharacters) { + contentProposalAdapter = new ContentProposalAdapter(text, + new TextContentAdapter(), contentProposalProvider, keyStroke, + autoActivationCharacters); + + // Listen for popup open/close events to be able to handle focus events + // correctly + contentProposalAdapter + .addContentProposalListener(new IContentProposalListener2() { + + public void proposalPopupClosed( + ContentProposalAdapter adapter) { + popupOpen = false; + } + + public void proposalPopupOpened( + ContentProposalAdapter adapter) { + popupOpen = true; + } + }); + } + + /** + * Return the {@link ContentProposalAdapter} of this cell editor. + * + * @return the {@link ContentProposalAdapter} + */ + public ContentProposalAdapter getContentProposalAdapter() { + return contentProposalAdapter; + } + + protected void focusLost() { + if (!popupOpen) { + // Focus lost deactivates the cell editor. + // This must not happen if focus lost was caused by activating + // the completion proposal popup. + super.focusLost(); + } + } + + protected boolean dependsOnExternalFocusListener() { + // Always return false; + // Otherwise, the ColumnViewerEditor will install an additional focus + // listener + // that cancels cell editing on focus lost, even if focus gets lost due + // to + // activation of the completion proposal popup. See also bug 58777. + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditManager.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditManager.java index c2ad978d12b81b1248409b800616cceddc1487f7..d26b48a3900774863faa339976b931d01d8c6efe 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditManager.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditManager.java @@ -1,156 +1,156 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.editparts.ZoomListener; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.CellEditorActionHandler; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; - -public class TextEditManager extends DirectEditManager { - - private IActionBars actionBars; - private CellEditorActionHandler actionHandler; - private IAction copy, cut, paste, undo, redo, find, selectAll, delete; - private double cachedZoom = -1.0; - private Font scaledFont; - private ZoomListener zoomListener = new ZoomListener() { - public void zoomChanged(double newZoom) { - updateScaledFont(newZoom); - } - }; - - public TextEditManager(BMSAbstractEditPart source, CellEditorLocator locator) { - super(source, null, locator); - } - - /** - * @see org.eclipse.gef.tools.DirectEditManager#bringDown() - */ - protected void bringDown() { - ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer() - .getProperty(ZoomManager.class.toString()); - if (zoomMgr != null) - zoomMgr.removeZoomListener(zoomListener); - - if (actionHandler != null) { - actionHandler.dispose(); - actionHandler = null; - } - if (actionBars != null) { - restoreSavedActions(actionBars); - actionBars.updateActionBars(); - actionBars = null; - } - - super.bringDown(); - // dispose any scaled fonts that might have been created - disposeScaledFont(); - } - - protected CellEditor createCellEditorOn(Composite composite) { - return new TextCellEditor(composite, SWT.NONE); - } - - private void disposeScaledFont() { - if (scaledFont != null) { - scaledFont.dispose(); - scaledFont = null; - } - } - - protected void initCellEditor() { - // update text - IFigure figure = (IFigure) getEditPart().getFigure(); - getCellEditor().setValue( - ((BControl) getEditPart().getModel()) - .getAttributeValue(AttributeConstants.ATTRIBUTE_TEXT)); - // update font - ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer() - .getProperty(ZoomManager.class.toString()); - if (zoomMgr != null) { - // this will force the font to be set - cachedZoom = -1.0; - updateScaledFont(zoomMgr.getZoom()); - zoomMgr.addZoomListener(zoomListener); - } else { - getCellEditor().getControl().setFont(figure.getFont()); - } - - // Hook the cell editor's copy/paste actions to the actionBars so that - // they can - // be invoked via keyboard shortcuts. - actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().getActiveEditor().getEditorSite() - .getActionBars(); - saveCurrentActions(actionBars); - actionHandler = new CellEditorActionHandler(actionBars); - actionHandler.addCellEditor(getCellEditor()); - actionBars.updateActionBars(); - } - - private void restoreSavedActions(IActionBars actionBars) { - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste); - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), delete); - actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), - selectAll); - actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut); - actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), find); - actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo); - actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo); - } - - private void saveCurrentActions(IActionBars actionBars) { - copy = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); - paste = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()); - delete = actionBars - .getGlobalActionHandler(ActionFactory.DELETE.getId()); - selectAll = actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL - .getId()); - cut = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()); - find = actionBars.getGlobalActionHandler(ActionFactory.FIND.getId()); - undo = actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId()); - redo = actionBars.getGlobalActionHandler(ActionFactory.REDO.getId()); - } - - private void updateScaledFont(double zoom) { - if (cachedZoom == zoom) - return; - - Text text = (Text) getCellEditor().getControl(); - Font font = getEditPart().getFigure().getFont(); - - disposeScaledFont(); - cachedZoom = zoom; - if (zoom == 1.0) - text.setFont(font); - else { - FontData fd = font.getFontData()[0]; - fd.setHeight((int) (fd.getHeight() * zoom)); - text.setFont(scaledFont = new Font(null, fd)); - } - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.editparts.ZoomListener; +import org.eclipse.gef.editparts.ZoomManager; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.part.CellEditorActionHandler; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; + +public class TextEditManager extends DirectEditManager { + + private IActionBars actionBars; + private CellEditorActionHandler actionHandler; + private IAction copy, cut, paste, undo, redo, find, selectAll, delete; + private double cachedZoom = -1.0; + private Font scaledFont; + private ZoomListener zoomListener = new ZoomListener() { + public void zoomChanged(double newZoom) { + updateScaledFont(newZoom); + } + }; + + public TextEditManager(BMSAbstractEditPart source, CellEditorLocator locator) { + super(source, null, locator); + } + + /** + * @see org.eclipse.gef.tools.DirectEditManager#bringDown() + */ + protected void bringDown() { + ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer() + .getProperty(ZoomManager.class.toString()); + if (zoomMgr != null) + zoomMgr.removeZoomListener(zoomListener); + + if (actionHandler != null) { + actionHandler.dispose(); + actionHandler = null; + } + if (actionBars != null) { + restoreSavedActions(actionBars); + actionBars.updateActionBars(); + actionBars = null; + } + + super.bringDown(); + // dispose any scaled fonts that might have been created + disposeScaledFont(); + } + + protected CellEditor createCellEditorOn(Composite composite) { + return new TextCellEditor(composite, SWT.NONE); + } + + private void disposeScaledFont() { + if (scaledFont != null) { + scaledFont.dispose(); + scaledFont = null; + } + } + + protected void initCellEditor() { + // update text + IFigure figure = (IFigure) getEditPart().getFigure(); + getCellEditor().setValue( + ((BControl) getEditPart().getModel()) + .getAttributeValue(AttributeConstants.ATTRIBUTE_TEXT)); + // update font + ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer() + .getProperty(ZoomManager.class.toString()); + if (zoomMgr != null) { + // this will force the font to be set + cachedZoom = -1.0; + updateScaledFont(zoomMgr.getZoom()); + zoomMgr.addZoomListener(zoomListener); + } else { + getCellEditor().getControl().setFont(figure.getFont()); + } + + // Hook the cell editor's copy/paste actions to the actionBars so that + // they can + // be invoked via keyboard shortcuts. + actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().getActiveEditor().getEditorSite() + .getActionBars(); + saveCurrentActions(actionBars); + actionHandler = new CellEditorActionHandler(actionBars); + actionHandler.addCellEditor(getCellEditor()); + actionBars.updateActionBars(); + } + + private void restoreSavedActions(IActionBars actionBars) { + actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy); + actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste); + actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), delete); + actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), + selectAll); + actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut); + actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), find); + actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo); + actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo); + } + + private void saveCurrentActions(IActionBars actionBars) { + copy = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); + paste = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()); + delete = actionBars + .getGlobalActionHandler(ActionFactory.DELETE.getId()); + selectAll = actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL + .getId()); + cut = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()); + find = actionBars.getGlobalActionHandler(ActionFactory.FIND.getId()); + undo = actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId()); + redo = actionBars.getGlobalActionHandler(ActionFactory.REDO.getId()); + } + + private void updateScaledFont(double zoom) { + if (cachedZoom == zoom) + return; + + Text text = (Text) getCellEditor().getControl(); + Font font = getEditPart().getFigure().getFont(); + + disposeScaledFont(); + cachedZoom = zoom; + if (zoom == 1.0) + text.setFont(font); + else { + FontData fd = font.getFontData()[0]; + fd.setHeight((int) (fd.getHeight() * zoom)); + text.setFont(scaledFont = new Font(null, fd)); + } + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditingSupport.java index bc01452ea8c5b2d1006d62fa7398b0ad02b67445..4181dbeb93d946b93e481a5b2efe58c6416aa356 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditingSupport.java @@ -1,60 +1,60 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class TextEditingSupport extends ObservableValueEditingSupport { - - private TextCellEditor cellEditor; - private String property; - - public TextEditingSupport(ColumnViewer viewer, DataBindingContext dbc, - String property) { - super(viewer, dbc); - this.property = property; - } - - @Override - protected IObservableValue doCreateCellEditorObservable( - CellEditor cellEditor) { - return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); - } - - @Override - protected IObservableValue doCreateElementObservable(Object element, - ViewerCell cell) { - return BeansObservables.observeValue(element, property); - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - cellEditor = new TextCellEditor((Composite) getViewer() - .getControl()); - } - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class TextEditingSupport extends ObservableValueEditingSupport { + + private TextCellEditor cellEditor; + private String property; + + public TextEditingSupport(ColumnViewer viewer, DataBindingContext dbc, + String property) { + super(viewer, dbc); + this.property = property; + } + + @Override + protected IObservableValue doCreateCellEditorObservable( + CellEditor cellEditor) { + return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); + } + + @Override + protected IObservableValue doCreateElementObservable(Object element, + ViewerCell cell) { + return BeansObservables.observeValue(element, property); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + cellEditor = new TextCellEditor((Composite) getViewer() + .getControl()); + } + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditorWindow.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditorWindow.java index f32d117991de9e35d54393b021320b6e72efb1f8..c004179bf417dd5ceee9db722960f89a40633b43 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditorWindow.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TextEditorWindow.java @@ -1,127 +1,117 @@ -package de.bmotionstudio.gef.editor.edit; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.window.IShellProvider; -import org.eclipse.jface.window.SameShellProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; - -public class TextEditorWindow extends Window { - - private String value; - private Point position; - private Text text; - private PopupResult result = new PopupResult(); - private List<IPopupListener> popupListener = new ArrayList<IPopupListener>(); - - protected TextEditorWindow(Shell parentShell, Text text) { - this(new SameShellProvider(parentShell), text); - } - - protected TextEditorWindow(IShellProvider parentShell, Text text) { - super(parentShell); - this.value = text.getText(); - this.position = text.toDisplay(0, 0); - this.result.setReturncode(getReturnCode()); - setShellStyle(SWT.ON_TOP); - setBlockOnOpen(true); - } - - @Override - protected Control createContents(Composite parent) { - Composite composite = new Composite(parent, 0); - FillLayout layout = new FillLayout(); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - text = new Text(composite, SWT.MULTI | SWT.WRAP); - text.setText(value); - text.selectAll(); - text.setFont(BMotionStudioSWTConstants.fontArial10); - return composite; - } - - @Override - protected Point getInitialSize() { - return new Point(500, 200); - } - - @Override - protected Point getInitialLocation(Point initialSize) { - return position; - } - - @Override - protected void configureShell(Shell newShell) { - newShell.addShellListener(new ShellAdapter() { - @Override - public void shellDeactivated(ShellEvent e) { - setReturnCode(OK); - close(); - } - }); - super.configureShell(newShell); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#setReturnCode(int) - */ - @Override - protected void setReturnCode(int code) { - result.setReturncode(code); - super.setReturnCode(code); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#close() - */ - @Override - public boolean close() { - result.setValue(text.getText()); - notifyPopupClosed(); - boolean b = super.close(); - return b; - } - - public PopupResult openPopup() { - notifyPopupOpened(); - int i = super.open(); - result.setReturncode(i); - return result; - } - - public void notifyPopupOpened() { - for (IPopupListener l : popupListener) - l.popupOpened(); - } - - public void notifyPopupClosed() { - for (IPopupListener l : popupListener) - l.popupClosed(); - } - - public void addPopupListener(IPopupListener l) { - this.popupListener.add(l); - } - - public void removePopupListener(IPopupListener l) { - this.popupListener.remove(l); - } - -} +package de.bmotionstudio.gef.editor.edit; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.window.IShellProvider; +import org.eclipse.jface.window.SameShellProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; + +public class TextEditorWindow extends Window { + + private String value; + private Point position; + private Text text; + private PopupResult result = new PopupResult(); + private List<IPopupListener> popupListener = new ArrayList<IPopupListener>(); + + protected TextEditorWindow(Shell parentShell, Text text) { + this(new SameShellProvider(parentShell), text); + } + + protected TextEditorWindow(IShellProvider parentShell, Text text) { + super(parentShell); + this.value = text.getText(); + this.position = text.toDisplay(0, 0); + this.result.setReturncode(getReturnCode()); + setShellStyle(SWT.ON_TOP); + setBlockOnOpen(true); + } + + @Override + protected Control createContents(Composite parent) { + Composite composite = new Composite(parent, 0); + FillLayout layout = new FillLayout(); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + text = new Text(composite, SWT.MULTI | SWT.WRAP); + text.setText(value); + text.selectAll(); + text.setFont(BMotionStudioSWTConstants.fontArial10); + return composite; + } + + @Override + protected Point getInitialSize() { + return new Point(500, 200); + } + + @Override + protected Point getInitialLocation(Point initialSize) { + return position; + } + + @Override + protected void configureShell(Shell newShell) { + newShell.addShellListener(new ShellAdapter() { + @Override + public void shellDeactivated(ShellEvent e) { + setReturnCode(OK); + close(); + } + }); + super.configureShell(newShell); + } + + @Override + protected void setReturnCode(int code) { + result.setReturncode(code); + super.setReturnCode(code); + } + + @Override + public boolean close() { + result.setValue(text.getText()); + notifyPopupClosed(); + boolean b = super.close(); + return b; + } + + public PopupResult openPopup() { + notifyPopupOpened(); + int i = super.open(); + result.setReturncode(i); + return result; + } + + public void notifyPopupOpened() { + for (IPopupListener l : popupListener) + l.popupOpened(); + } + + public void notifyPopupClosed() { + for (IPopupListener l : popupListener) + l.popupClosed(); + } + + public void addPopupListener(IPopupListener l) { + this.popupListener.add(l); + } + + public void removePopupListener(IPopupListener l) { + this.popupListener.remove(l); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TypeEditingSupport.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TypeEditingSupport.java index 80867c619fabdbd39c019522e2163f99b9696312..8c009c4ba7fa50fe44db9d3d47366f3e770bea16 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TypeEditingSupport.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/edit/TypeEditingSupport.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.edit; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.widgets.Composite; - -import de.be4.classicalb.core.parser.BParser; - -public class TypeEditingSupport extends ObservableValueEditingSupport { - - private CellEditor cellEditor; - private String propertyName; - - public TypeEditingSupport(ColumnViewer viewer, DataBindingContext dbc, - String propertyName) { - super(viewer, dbc); - this.propertyName = propertyName; - } - - @Override - protected IObservableValue doCreateCellEditorObservable( - CellEditor cellEditor) { - return SWTObservables.observeSelection(cellEditor.getControl()); - } - - @Override - protected IObservableValue doCreateElementObservable(Object element, - ViewerCell cell) { - return BeansObservables.observeValue(element, propertyName); - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - cellEditor = new ComboBoxCellEditor((Composite) getViewer() - .getControl(), new String[] { BParser.PREDICATE_PREFIX, - BParser.EXPRESSION_PREFIX }); - } - return cellEditor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.edit; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.widgets.Composite; + +import de.be4.classicalb.core.parser.BParser; + +public class TypeEditingSupport extends ObservableValueEditingSupport { + + private CellEditor cellEditor; + private String propertyName; + + public TypeEditingSupport(ColumnViewer viewer, DataBindingContext dbc, + String propertyName) { + super(viewer, dbc); + this.propertyName = propertyName; + } + + @Override + protected IObservableValue doCreateCellEditorObservable( + CellEditor cellEditor) { + return SWTObservables.observeSelection(cellEditor.getControl()); + } + + @Override + protected IObservableValue doCreateElementObservable(Object element, + ViewerCell cell) { + return BeansObservables.observeValue(element, propertyName); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + cellEditor = new ComboBoxCellEditor((Composite) getViewer() + .getControl(), new String[] { BParser.PREDICATE_PREFIX, + BParser.EXPRESSION_PREFIX }); + } + return cellEditor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSConnectionEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSConnectionEditPolicy.java index 86d7c74f263eef5a06034e143ae22034002f88ba..54d63dc1d1200d08f6a8f4176dd19d8beb6eea61 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSConnectionEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSConnectionEditPolicy.java @@ -1,98 +1,71 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy; -import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gef.requests.ReconnectRequest; - -import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; -import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BMSConnectionEditPolicy extends GraphicalNodeEditPolicy { - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy# - * getConnectionCompleteCommand - * (org.eclipse.gef.requests.CreateConnectionRequest) - */ - protected Command getConnectionCompleteCommand( - CreateConnectionRequest request) { - ConnectionCreateCommand cmd = null; - Object newObject = request.getNewObject(); - if (newObject instanceof BConnection) { - cmd = (ConnectionCreateCommand) request.getStartCommand(); - cmd.setTarget((BControl) getHost().getModel()); - } - return cmd; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy# - * getConnectionCreateCommand - * (org.eclipse.gef.requests.CreateConnectionRequest) - */ - protected Command getConnectionCreateCommand(CreateConnectionRequest request) { - ConnectionCreateCommand cmd = null; - Object newObject = request.getNewObject(); - if (newObject instanceof BConnection) { - BControl source = (BControl) getHost().getModel(); - cmd = new ConnectionCreateCommand(source); - BConnection con = (BConnection) newObject; - con.setVisualization(source.getVisualization()); - cmd.setConnection(con); - request.setStartCommand(cmd); - } - return cmd; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy# - * getReconnectSourceCommand (org.eclipse.gef.requests.ReconnectRequest) - */ - protected Command getReconnectSourceCommand(ReconnectRequest request) { - ConnectionReconnectCommand cmd = null; - Object newObject = request.getConnectionEditPart().getModel(); - if (newObject instanceof BConnection) { - BConnection conn = (BConnection) newObject; - BControl newSource = (BControl) getHost().getModel(); - cmd = new ConnectionReconnectCommand(); - cmd.setNewSource(newSource); - cmd.setConnection(conn); - } - return cmd; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy# - * getReconnectTargetCommand (org.eclipse.gef.requests.ReconnectRequest) - */ - protected Command getReconnectTargetCommand(ReconnectRequest request) { - ConnectionReconnectCommand cmd = null; - Object newObject = request.getConnectionEditPart().getModel(); - if (newObject instanceof BConnection) { - BConnection conn = (BConnection) newObject; - BControl newTarget = (BControl) getHost().getModel(); - cmd = new ConnectionReconnectCommand(); - cmd.setNewTarget(newTarget); - cmd.setConnection(conn); - } - return cmd; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; + +import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; +import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BMSConnectionEditPolicy extends GraphicalNodeEditPolicy { + protected Command getConnectionCompleteCommand( + CreateConnectionRequest request) { + ConnectionCreateCommand cmd = null; + Object newObject = request.getNewObject(); + if (newObject instanceof BConnection) { + cmd = (ConnectionCreateCommand) request.getStartCommand(); + cmd.setTarget((BControl) getHost().getModel()); + } + return cmd; + } + + protected Command getConnectionCreateCommand(CreateConnectionRequest request) { + ConnectionCreateCommand cmd = null; + Object newObject = request.getNewObject(); + if (newObject instanceof BConnection) { + BControl source = (BControl) getHost().getModel(); + cmd = new ConnectionCreateCommand(source); + BConnection con = (BConnection) newObject; + con.setVisualization(source.getVisualization()); + cmd.setConnection(con); + request.setStartCommand(cmd); + } + return cmd; + } + + protected Command getReconnectSourceCommand(ReconnectRequest request) { + ConnectionReconnectCommand cmd = null; + Object newObject = request.getConnectionEditPart().getModel(); + if (newObject instanceof BConnection) { + BConnection conn = (BConnection) newObject; + BControl newSource = (BControl) getHost().getModel(); + cmd = new ConnectionReconnectCommand(); + cmd.setNewSource(newSource); + cmd.setConnection(conn); + } + return cmd; + } + + protected Command getReconnectTargetCommand(ReconnectRequest request) { + ConnectionReconnectCommand cmd = null; + Object newObject = request.getConnectionEditPart().getModel(); + if (newObject instanceof BConnection) { + BConnection conn = (BConnection) newObject; + BControl newTarget = (BControl) getHost().getModel(); + cmd = new ConnectionReconnectCommand(); + cmd.setNewTarget(newTarget); + cmd.setConnection(conn); + } + return cmd; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSDeletePolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSDeletePolicy.java index 21f255bd50f434c9648132b238f1f83c9af2c124..c29e2b451e8f0f8cc241bba95accdf5d2647913a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSDeletePolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSDeletePolicy.java @@ -1,24 +1,24 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ComponentEditPolicy; -import org.eclipse.gef.requests.GroupRequest; - -import de.bmotionstudio.gef.editor.command.DeleteCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BMSDeletePolicy extends ComponentEditPolicy { - - protected Command createDeleteCommand(GroupRequest deleteRequest) { - DeleteCommand command = new DeleteCommand((BControl) getHost() - .getModel(), (BControl) getHost().getParent().getModel()); - return command; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.ComponentEditPolicy; +import org.eclipse.gef.requests.GroupRequest; + +import de.bmotionstudio.gef.editor.command.DeleteCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BMSDeletePolicy extends ComponentEditPolicy { + + protected Command createDeleteCommand(GroupRequest deleteRequest) { + DeleteCommand command = new DeleteCommand((BControl) getHost() + .getModel(), (BControl) getHost().getParent().getModel()); + return command; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSEditLayoutPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSEditLayoutPolicy.java index 8eae508da5b13fa6318f457154eca3cecb12eb69..0bf13ce7ebb7c57c337fb6144913151ff9577277 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSEditLayoutPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSEditLayoutPolicy.java @@ -1,236 +1,236 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.SnapToGuides; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ResizableEditPolicy; -import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gef.rulers.RulerProvider; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; -import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; -import de.bmotionstudio.gef.editor.command.ChangeGuideCommand; -import de.bmotionstudio.gef.editor.command.CreateCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BMotionGuide; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; - -public class BMSEditLayoutPolicy extends XYLayoutEditPolicy { - - @Override - protected Command createChangeConstraintCommand(EditPart child, - Object constraint) { - return null; - } - - @Override - protected Command createChangeConstraintCommand( - ChangeBoundsRequest request, EditPart child, Object constraint) { - - BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); - BControl part = (BControl) child.getModel(); - cmd.setModel(child.getModel()); - cmd.setConstraint((Rectangle) constraint); - Command result = cmd; - - if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) { - Integer guidePos = (Integer) request.getExtendedData().get( - SnapToGuides.KEY_HORIZONTAL_GUIDE); - if (guidePos != null) { - result = chainGuideAttachmentCommand(request, part, result, - true); - } else if (part.getHorizontalGuide() != null) { - // SnapToGuides didn't provide a horizontal guide, but this part - // is attached - // to a horizontal guide. Now we check to see if the part is - // attached to - // the guide along the edge being resized. If that is the case, - // we need to - // detach the part from the guide; otherwise, we leave it alone. - int alignment = part.getHorizontalGuide().getAlignment(part); - int edgeBeingResized = 0; - if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) - edgeBeingResized = -1; - else - edgeBeingResized = 1; - if (alignment == edgeBeingResized) - result = result.chain(new ChangeGuideCommand(part, true)); - } - } - - if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) { - Integer guidePos = (Integer) request.getExtendedData().get( - SnapToGuides.KEY_VERTICAL_GUIDE); - if (guidePos != null) { - result = chainGuideAttachmentCommand(request, part, result, - false); - } else if (part.getVerticalGuide() != null) { - int alignment = part.getVerticalGuide().getAlignment(part); - int edgeBeingResized = 0; - if ((request.getResizeDirection() & PositionConstants.WEST) != 0) - edgeBeingResized = -1; - else - edgeBeingResized = 1; - if (alignment == edgeBeingResized) - result = result.chain(new ChangeGuideCommand(part, false)); - } - } - - if (request.getType().equals(REQ_MOVE_CHILDREN) - || request.getType().equals(REQ_ALIGN_CHILDREN)) { - result = chainGuideAttachmentCommand(request, part, result, true); - result = chainGuideAttachmentCommand(request, part, result, false); - result = chainGuideDetachmentCommand(request, part, result, true); - result = chainGuideDetachmentCommand(request, part, result, false); - } - - return result; - } - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - - BControl control = (BControl) child.getModel(); - - ResizableEditPolicy policy = new ResizableEditPolicy(); - - BAttributeWidth atrWidth = (BAttributeWidth) control.getAttributes() - .get(AttributeConstants.ATTRIBUTE_WIDTH); - BAttributeHeight atrHeight = (BAttributeHeight) control.getAttributes() - .get(AttributeConstants.ATTRIBUTE_HEIGHT); - - if (atrWidth.isEditable() && atrHeight.isEditable()) - return policy; - - if (atrWidth.isEditable()) { - policy.setResizeDirections(PositionConstants.EAST_WEST); - return policy; - } - - if (atrHeight.isEditable()) { - policy.setResizeDirections(PositionConstants.NORTH_SOUTH); - return policy; - } - - policy.setResizeDirections(0); - - return policy; - - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - - if (request.getType() == REQ_CREATE - && getHost() instanceof BMSAbstractEditPart) { - - if (((BControl) ((BMSAbstractEditPart) getHost()).getModel()) - .canHaveChildren()) { - - BControl newObj = (BControl) request.getNewObject(); - - CreateCommand createCmd = new CreateCommand(newObj, - (BControl) getHost().getModel()); - - Rectangle constraint = (Rectangle) getConstraintFor(request); - - constraint.x = (constraint.x < 0) ? 0 : constraint.x; - constraint.y = (constraint.y < 0) ? 0 : constraint.y; - - BAttributeWidth atrWidth = (BAttributeWidth) newObj - .getAttributes() - .get(AttributeConstants.ATTRIBUTE_WIDTH); - BAttributeHeight atrHeight = (BAttributeHeight) newObj - .getAttributes().get( - AttributeConstants.ATTRIBUTE_HEIGHT); - - Integer cWidth = Integer.valueOf(atrWidth.getDefaultValue() - .toString()); - if (!atrWidth.isEditable()) { - constraint.width = cWidth; - } else { - constraint.width = (constraint.width <= 0) ? cWidth - : constraint.width; - } - - Integer cHeight = Integer.valueOf(atrHeight.getDefaultValue() - .toString()); - if (!atrHeight.isEditable()) { - constraint.height = cHeight; - } else { - constraint.height = (constraint.height <= 0) ? cHeight - : constraint.height; - } - - createCmd.setLayout(constraint); - - Command cmd = chainGuideAttachmentCommand(request, newObj, - createCmd, true); - return chainGuideAttachmentCommand(request, newObj, cmd, false); - - } - - } - - return null; - - } - - protected Command chainGuideAttachmentCommand(Request request, - BControl part, Command cmd, boolean horizontal) { - Command result = cmd; - - // Attach to guide, if one is given - Integer guidePos = (Integer) request.getExtendedData().get( - horizontal ? SnapToGuides.KEY_HORIZONTAL_GUIDE - : SnapToGuides.KEY_VERTICAL_GUIDE); - if (guidePos != null) { - int alignment = ((Integer) request.getExtendedData().get( - horizontal ? SnapToGuides.KEY_HORIZONTAL_ANCHOR - : SnapToGuides.KEY_VERTICAL_ANCHOR)).intValue(); - ChangeGuideCommand cgm = new ChangeGuideCommand(part, horizontal); - cgm.setNewGuide(findGuideAt(guidePos.intValue(), horizontal), - alignment); - result = result.chain(cgm); - } - - return result; - } - - protected Command chainGuideDetachmentCommand(Request request, - BControl part, Command cmd, boolean horizontal) { - Command result = cmd; - - // Detach from guide, if none is given - Integer guidePos = (Integer) request.getExtendedData().get( - horizontal ? SnapToGuides.KEY_HORIZONTAL_GUIDE - : SnapToGuides.KEY_VERTICAL_GUIDE); - if (guidePos == null) - result = result.chain(new ChangeGuideCommand(part, horizontal)); - - return result; - } - - protected BMotionGuide findGuideAt(int pos, boolean horizontal) { - RulerProvider provider = ((RulerProvider) getHost().getViewer() - .getProperty( - horizontal ? RulerProvider.PROPERTY_VERTICAL_RULER - : RulerProvider.PROPERTY_HORIZONTAL_RULER)); - return (BMotionGuide) provider.getGuideAt(pos); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.SnapToGuides; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.ResizableEditPolicy; +import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gef.rulers.RulerProvider; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; +import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; +import de.bmotionstudio.gef.editor.command.ChangeGuideCommand; +import de.bmotionstudio.gef.editor.command.CreateCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; + +public class BMSEditLayoutPolicy extends XYLayoutEditPolicy { + + @Override + protected Command createChangeConstraintCommand(EditPart child, + Object constraint) { + return null; + } + + @Override + protected Command createChangeConstraintCommand( + ChangeBoundsRequest request, EditPart child, Object constraint) { + + BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); + BControl part = (BControl) child.getModel(); + cmd.setModel(child.getModel()); + cmd.setConstraint((Rectangle) constraint); + Command result = cmd; + + if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) { + Integer guidePos = (Integer) request.getExtendedData().get( + SnapToGuides.KEY_HORIZONTAL_GUIDE); + if (guidePos != null) { + result = chainGuideAttachmentCommand(request, part, result, + true); + } else if (part.getHorizontalGuide() != null) { + // SnapToGuides didn't provide a horizontal guide, but this part + // is attached + // to a horizontal guide. Now we check to see if the part is + // attached to + // the guide along the edge being resized. If that is the case, + // we need to + // detach the part from the guide; otherwise, we leave it alone. + int alignment = part.getHorizontalGuide().getAlignment(part); + int edgeBeingResized = 0; + if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) + edgeBeingResized = -1; + else + edgeBeingResized = 1; + if (alignment == edgeBeingResized) + result = result.chain(new ChangeGuideCommand(part, true)); + } + } + + if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) { + Integer guidePos = (Integer) request.getExtendedData().get( + SnapToGuides.KEY_VERTICAL_GUIDE); + if (guidePos != null) { + result = chainGuideAttachmentCommand(request, part, result, + false); + } else if (part.getVerticalGuide() != null) { + int alignment = part.getVerticalGuide().getAlignment(part); + int edgeBeingResized = 0; + if ((request.getResizeDirection() & PositionConstants.WEST) != 0) + edgeBeingResized = -1; + else + edgeBeingResized = 1; + if (alignment == edgeBeingResized) + result = result.chain(new ChangeGuideCommand(part, false)); + } + } + + if (request.getType().equals(REQ_MOVE_CHILDREN) + || request.getType().equals(REQ_ALIGN_CHILDREN)) { + result = chainGuideAttachmentCommand(request, part, result, true); + result = chainGuideAttachmentCommand(request, part, result, false); + result = chainGuideDetachmentCommand(request, part, result, true); + result = chainGuideDetachmentCommand(request, part, result, false); + } + + return result; + } + + @Override + protected EditPolicy createChildEditPolicy(EditPart child) { + + BControl control = (BControl) child.getModel(); + + ResizableEditPolicy policy = new ResizableEditPolicy(); + + BAttributeWidth atrWidth = (BAttributeWidth) control.getAttributes() + .get(AttributeConstants.ATTRIBUTE_WIDTH); + BAttributeHeight atrHeight = (BAttributeHeight) control.getAttributes() + .get(AttributeConstants.ATTRIBUTE_HEIGHT); + + if (atrWidth.isEditable() && atrHeight.isEditable()) + return policy; + + if (atrWidth.isEditable()) { + policy.setResizeDirections(PositionConstants.EAST_WEST); + return policy; + } + + if (atrHeight.isEditable()) { + policy.setResizeDirections(PositionConstants.NORTH_SOUTH); + return policy; + } + + policy.setResizeDirections(0); + + return policy; + + } + + @Override + protected Command getCreateCommand(CreateRequest request) { + + if (request.getType() == REQ_CREATE + && getHost() instanceof BMSAbstractEditPart) { + + if (((BControl) ((BMSAbstractEditPart) getHost()).getModel()) + .canHaveChildren()) { + + BControl newObj = (BControl) request.getNewObject(); + + CreateCommand createCmd = new CreateCommand(newObj, + (BControl) getHost().getModel()); + + Rectangle constraint = (Rectangle) getConstraintFor(request); + + constraint.x = (constraint.x < 0) ? 0 : constraint.x; + constraint.y = (constraint.y < 0) ? 0 : constraint.y; + + BAttributeWidth atrWidth = (BAttributeWidth) newObj + .getAttributes() + .get(AttributeConstants.ATTRIBUTE_WIDTH); + BAttributeHeight atrHeight = (BAttributeHeight) newObj + .getAttributes().get( + AttributeConstants.ATTRIBUTE_HEIGHT); + + Integer cWidth = Integer.valueOf(atrWidth.getDefaultValue() + .toString()); + if (!atrWidth.isEditable()) { + constraint.width = cWidth; + } else { + constraint.width = (constraint.width <= 0) ? cWidth + : constraint.width; + } + + Integer cHeight = Integer.valueOf(atrHeight.getDefaultValue() + .toString()); + if (!atrHeight.isEditable()) { + constraint.height = cHeight; + } else { + constraint.height = (constraint.height <= 0) ? cHeight + : constraint.height; + } + + createCmd.setLayout(constraint); + + Command cmd = chainGuideAttachmentCommand(request, newObj, + createCmd, true); + return chainGuideAttachmentCommand(request, newObj, cmd, false); + + } + + } + + return null; + + } + + protected Command chainGuideAttachmentCommand(Request request, + BControl part, Command cmd, boolean horizontal) { + Command result = cmd; + + // Attach to guide, if one is given + Integer guidePos = (Integer) request.getExtendedData().get( + horizontal ? SnapToGuides.KEY_HORIZONTAL_GUIDE + : SnapToGuides.KEY_VERTICAL_GUIDE); + if (guidePos != null) { + int alignment = ((Integer) request.getExtendedData().get( + horizontal ? SnapToGuides.KEY_HORIZONTAL_ANCHOR + : SnapToGuides.KEY_VERTICAL_ANCHOR)).intValue(); + ChangeGuideCommand cgm = new ChangeGuideCommand(part, horizontal); + cgm.setNewGuide(findGuideAt(guidePos.intValue(), horizontal), + alignment); + result = result.chain(cgm); + } + + return result; + } + + protected Command chainGuideDetachmentCommand(Request request, + BControl part, Command cmd, boolean horizontal) { + Command result = cmd; + + // Detach from guide, if none is given + Integer guidePos = (Integer) request.getExtendedData().get( + horizontal ? SnapToGuides.KEY_HORIZONTAL_GUIDE + : SnapToGuides.KEY_VERTICAL_GUIDE); + if (guidePos == null) + result = result.chain(new ChangeGuideCommand(part, horizontal)); + + return result; + } + + protected BMotionGuide findGuideAt(int pos, boolean horizontal) { + RulerProvider provider = ((RulerProvider) getHost().getViewer() + .getProperty( + horizontal ? RulerProvider.PROPERTY_VERTICAL_RULER + : RulerProvider.PROPERTY_HORIZONTAL_RULER)); + return (BMotionGuide) provider.getGuideAt(pos); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSResizableEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSResizableEditPolicy.java index 0c51a081ccef22f7cff3e5ee76d8273819b8f891..daff32a91b345ef1225fd48c86048b9f8acadf29 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSResizableEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/BMSResizableEditPolicy.java @@ -1,83 +1,83 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.editpolicy; - -import java.util.Iterator; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editpolicies.ResizableEditPolicy; - -public class BMSResizableEditPolicy extends ResizableEditPolicy { - - /** - * Creates the figure used for feedback. - * - * @return the new feedback figure - */ - protected IFigure createDragSourceFeedbackFigure() { - IFigure figure = createFigure((GraphicalEditPart) getHost(), null); - figure.setBounds(getInitialFeedbackBounds()); - addFeedback(figure); - return figure; - } - - protected IFigure createFigure(GraphicalEditPart part, IFigure parent) { - IFigure child = getCustomFeedbackFigure(part.getModel()); - - if (parent != null) - parent.add(child); - - Rectangle childBounds = part.getFigure().getBounds().getCopy(); - - IFigure walker = part.getFigure().getParent(); - - while (walker != ((GraphicalEditPart) part.getParent()).getFigure()) { - walker.translateToParent(childBounds); - walker = walker.getParent(); - } - - child.setBounds(childBounds); - - Iterator<?> i = part.getChildren().iterator(); - - while (i.hasNext()) - createFigure((GraphicalEditPart) i.next(), child); - - return child; - } - - protected IFigure getCustomFeedbackFigure(Object modelPart) { - IFigure figure; - figure = new RectangleFigure(); - ((RectangleFigure) figure).setXOR(true); - ((RectangleFigure) figure).setFill(true); - figure.setBackgroundColor(ColorConstants.blue); - figure.setForegroundColor(ColorConstants.white); - return figure; - } - - /** - * Returns the layer used for displaying feedback. - * - * @return the feedback layer - */ - protected IFigure getFeedbackLayer() { - return getLayer(LayerConstants.SCALED_FEEDBACK_LAYER); - } - - /** - * @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#getInitialFeedbackBounds() - */ - protected Rectangle getInitialFeedbackBounds() { - return getHostFigure().getBounds(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.editpolicy; + +import java.util.Iterator; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.LayerConstants; +import org.eclipse.gef.editpolicies.ResizableEditPolicy; + +public class BMSResizableEditPolicy extends ResizableEditPolicy { + + /** + * Creates the figure used for feedback. + * + * @return the new feedback figure + */ + protected IFigure createDragSourceFeedbackFigure() { + IFigure figure = createFigure((GraphicalEditPart) getHost(), null); + figure.setBounds(getInitialFeedbackBounds()); + addFeedback(figure); + return figure; + } + + protected IFigure createFigure(GraphicalEditPart part, IFigure parent) { + IFigure child = getCustomFeedbackFigure(part.getModel()); + + if (parent != null) + parent.add(child); + + Rectangle childBounds = part.getFigure().getBounds().getCopy(); + + IFigure walker = part.getFigure().getParent(); + + while (walker != ((GraphicalEditPart) part.getParent()).getFigure()) { + walker.translateToParent(childBounds); + walker = walker.getParent(); + } + + child.setBounds(childBounds); + + Iterator<?> i = part.getChildren().iterator(); + + while (i.hasNext()) + createFigure((GraphicalEditPart) i.next(), child); + + return child; + } + + protected IFigure getCustomFeedbackFigure(Object modelPart) { + IFigure figure; + figure = new RectangleFigure(); + ((RectangleFigure) figure).setXOR(true); + ((RectangleFigure) figure).setFill(true); + figure.setBackgroundColor(ColorConstants.blue); + figure.setForegroundColor(ColorConstants.white); + return figure; + } + + /** + * Returns the layer used for displaying feedback. + * + * @return the feedback layer + */ + protected IFigure getFeedbackLayer() { + return getLayer(LayerConstants.SCALED_FEEDBACK_LAYER); + } + + /** + * @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#getInitialFeedbackBounds() + */ + protected Rectangle getInitialFeedbackBounds() { + return getHostFigure().getBounds(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/ChangeAttributePolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/ChangeAttributePolicy.java index 781627fa430f9ac8bfae681adc2f5c01ab88f7dd..73808cfdb9231a0b2e3e30067e014e52e648016c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/ChangeAttributePolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/ChangeAttributePolicy.java @@ -1,49 +1,49 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.AbstractEditPolicy; - -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; - -public class ChangeAttributePolicy extends AbstractEditPolicy { - - public static final String CHANGE_ATTRIBUTE_POLICY = "ChangeAttributePolicy"; - - @Override - public Command getCommand(Request request) { - if ("change attribute" == request.getType() - && request instanceof AttributeRequest) { - AttributeRequest changeAttributeReq = (AttributeRequest) request; - if (changeAttributeReq.getAttributeTransferObject() != null) { - AbstractLibraryCommand command = ((BMSAbstractEditPart) getHost()) - .getLibraryCommand(changeAttributeReq); - if (command != null) { - command.setEditPart(getHost()); - command.setAttributeTransferObject(changeAttributeReq - .getAttributeTransferObject()); - command.setDropLocation(changeAttributeReq - .getDropLocation()); - } - return command; - } - } - return null; - } - - public EditPart getTargetEditPart(Request request) { - if ("change attribute" == request.getType()) - return getHost(); - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.AbstractEditPolicy; + +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; + +public class ChangeAttributePolicy extends AbstractEditPolicy { + + public static final String CHANGE_ATTRIBUTE_POLICY = "ChangeAttributePolicy"; + + @Override + public Command getCommand(Request request) { + if ("change attribute" == request.getType() + && request instanceof AttributeRequest) { + AttributeRequest changeAttributeReq = (AttributeRequest) request; + if (changeAttributeReq.getAttributeTransferObject() != null) { + AbstractLibraryCommand command = ((BMSAbstractEditPart) getHost()) + .getLibraryCommand(changeAttributeReq); + if (command != null) { + command.setEditPart(getHost()); + command.setAttributeTransferObject(changeAttributeReq + .getAttributeTransferObject()); + command.setDropLocation(changeAttributeReq + .getDropLocation()); + } + return command; + } + } + return null; + } + + public EditPart getTargetEditPart(Request request) { + if ("change attribute" == request.getType()) + return getHost(); + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/CustomDirectEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/CustomDirectEditPolicy.java index a25a39d8859a2d736cde7e70e2e77dd9ab4730c0..0c496a2f00996be6e7eb0a9510bd737aba72c888 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/CustomDirectEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/CustomDirectEditPolicy.java @@ -1,39 +1,39 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.DirectEditPolicy; -import org.eclipse.gef.requests.DirectEditRequest; - -import de.bmotionstudio.gef.editor.command.RenameCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; - -public class CustomDirectEditPolicy extends DirectEditPolicy { - - /** - * @see CustomDirectEditPolicy#getDirectEditCommand(DirectEditRequest) - */ - protected Command getDirectEditCommand(DirectEditRequest edit) { - String labelText = (String) edit.getCellEditor().getValue(); - BMSAbstractEditPart label = (BMSAbstractEditPart) getHost(); - RenameCommand command = new RenameCommand(); - command.setControl((BControl) label.getModel()); - command.setNewString(labelText); - return command; - } - - /** - * @see CustomDirectEditPolicy#showCurrentEditValue(DirectEditRequest) - */ - protected void showCurrentEditValue(DirectEditRequest request) { - // String value = (String) request.getCellEditor().getValue(); - getHostFigure().getUpdateManager().performUpdate(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.DirectEditPolicy; +import org.eclipse.gef.requests.DirectEditRequest; + +import de.bmotionstudio.gef.editor.command.RenameCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; + +public class CustomDirectEditPolicy extends DirectEditPolicy { + + /** + * @see CustomDirectEditPolicy#getDirectEditCommand(DirectEditRequest) + */ + protected Command getDirectEditCommand(DirectEditRequest edit) { + String labelText = (String) edit.getCellEditor().getValue(); + BMSAbstractEditPart label = (BMSAbstractEditPart) getHost(); + RenameCommand command = new RenameCommand(); + command.setControl((BControl) label.getModel()); + command.setNewString(labelText); + return command; + } + + /** + * @see CustomDirectEditPolicy#showCurrentEditValue(DirectEditRequest) + */ + protected void showCurrentEditValue(DirectEditRequest request) { + // String value = (String) request.getCellEditor().getValue(); + getHostFigure().getUpdateManager().performUpdate(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/RenamePolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/RenamePolicy.java index 831e24d56d4a10548c69bdcfd4d44202a68c0753..3d555a6708d99ab15db3c1ab83d02026af54cd34 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/RenamePolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/RenamePolicy.java @@ -1,33 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.AbstractEditPolicy; - -import de.bmotionstudio.gef.editor.command.RenameCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class RenamePolicy extends AbstractEditPolicy { - - @Override - public Command getCommand(Request request) { - if (request.getType().equals("rename")) - return createRenameCommand(request); - return null; - } - - protected Command createRenameCommand(Request renameRequest) { - RenameCommand command = new RenameCommand(); - command.setControl(((BControl) getHost().getModel())); - command.setNewString(((String) renameRequest.getExtendedData().get( - "newName"))); - return command; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.AbstractEditPolicy; + +import de.bmotionstudio.gef.editor.command.RenameCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class RenamePolicy extends AbstractEditPolicy { + + @Override + public Command getCommand(Request request) { + if (request.getType().equals("rename")) + return createRenameCommand(request); + return null; + } + + protected Command createRenameCommand(Request renameRequest) { + RenameCommand command = new RenameCommand(); + command.setControl(((BControl) getHost().getModel())); + command.setNewString(((String) renameRequest.getExtendedData().get( + "newName"))); + return command; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/SignalLayoutEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/SignalLayoutEditPolicy.java index 7d5ca8febe819d62b19bef3552077041fb6f2fc7..ff7814857844eae21986957bea7d324cfc011e07 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/SignalLayoutEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/SignalLayoutEditPolicy.java @@ -1,270 +1,270 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.editpolicy; - -import java.util.List; - -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PrecisionRectangle; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.geometry.Translatable; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.editpolicies.FlowLayoutEditPolicy; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.CreateRequest; - -import de.bmotionstudio.gef.editor.command.AddCommand; -import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; -import de.bmotionstudio.gef.editor.command.ReorderPartCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Light; -import de.bmotionstudio.gef.editor.model.Signal; - -public class SignalLayoutEditPolicy extends FlowLayoutEditPolicy { - - private static final Dimension PREFERRED_SIZE = new Dimension(-1, -1); - - /** - * Constant being used to indicate that upon creation (or during move) a - * size was not specified. - * - * @since 3.7 - */ - protected static final Dimension UNSPECIFIED_SIZE = new Dimension(); - - @Override - protected Command createAddCommand(EditPart child, EditPart after) { - - BControl childModel = (BControl) child.getModel(); - BControl parentModel = (BControl) getHost().getModel(); - if ((childModel instanceof Light && parentModel instanceof Signal)) { - AddCommand command = new AddCommand(); - command.setChild(childModel); - command.setParent(parentModel); - int index = getHost().getChildren().indexOf(after); - command.setIndex(index); - return command; - } - return null; - - } - - @Override - public Command getCommand(Request request) { - if (REQ_RESIZE_CHILDREN.equals(request.getType())) - return getResizeChildrenCommand((ChangeBoundsRequest) request); - return super.getCommand(request); - } - - protected Command getResizeChildrenCommand(ChangeBoundsRequest request) { - CompoundCommand resize = new CompoundCommand(); - Command c; - GraphicalEditPart child; - List<?> children = request.getEditParts(); - for (int i = 0; i < children.size(); i++) { - child = (GraphicalEditPart) children.get(i); - c = createChangeConstraintCommand( - request, - child, - translateToModelConstraint(getConstraintFor(request, child))); - resize.add(c); - } - return resize.unwrap(); - } - - protected Command createChangeConstraintCommand( - ChangeBoundsRequest request, EditPart child, Object constraint) { - BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); - cmd.setModel(child.getModel()); - cmd.setConstraint((Rectangle) constraint); - return cmd; - } - - /** - * Generates a draw2d constraint object for the given - * <code>ChangeBoundsRequest</code> and child EditPart by delegating to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * The rectangle being passed over to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)} is - * calculated based on the child figure's current bounds and the - * ChangeBoundsRequest's move and resize deltas. It is made layout-relative - * by using {@link #translateFromAbsoluteToLayoutRelative(Translatable)} - * before calling - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * @param request - * the ChangeBoundsRequest - * @param child - * the child EditPart for which the constraint should be - * generated - * @return the draw2d constraint - */ - protected Object getConstraintFor(ChangeBoundsRequest request, - GraphicalEditPart child) { - Rectangle locationAndSize = new PrecisionRectangle(child.getFigure() - .getBounds()); - child.getFigure().translateToAbsolute(locationAndSize); - locationAndSize = request.getTransformedRectangle(locationAndSize); - translateFromAbsoluteToLayoutRelative(locationAndSize); - return getConstraintFor(request, child, locationAndSize); - } - - /** - * Responsible of generating a draw2d constraint for the given Rectangle, - * which represents the already transformed (layout-relative) position and - * size of the given Request. - * - * By default, this method delegates to {@link #getConstraintFor(Point)} or - * {@link #getConstraintFor(Rectangle)}, dependent on whether the size of - * the rectangle is an {@link #UNSPECIFIED_SIZE} or not. - * - * Subclasses may overwrite this method in case they need the request or the - * edit part (which will of course not be set during creation) to calculate - * a layout constraint for the request. - * - * @param rectangle - * the Rectangle relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - * @since 3.7 - */ - protected Object getConstraintFor(Request request, GraphicalEditPart child, - Rectangle rectangle) { - if (UNSPECIFIED_SIZE.equals(rectangle.getSize())) { - return getConstraintFor(rectangle.getLocation()); - } - return getConstraintFor(rectangle); - } - - /** - * Generates a draw2d constraint for the given <code>CreateRequest</code> by - * delegating to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * If the CreateRequest has a size, is used during size-on-drop creation, a - * Rectangle of the request's location and size is passed with the - * delegation. Otherwise, a rectangle with the request's location and an - * empty size (0,0) is passed over. - * <P> - * The CreateRequest's location is relative to the Viewer. The location is - * made layout-relative by using - * {@link #translateFromAbsoluteToLayoutRelative(Translatable)} before - * calling {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * @param request - * the CreateRequest - * @return a draw2d constraint - */ - protected Object getConstraintFor(CreateRequest request) { - Rectangle locationAndSize = null; - if (request.getSize() == null || request.getSize().isEmpty()) { - locationAndSize = new PrecisionRectangle(request.getLocation(), - UNSPECIFIED_SIZE); - } else { - locationAndSize = new PrecisionRectangle(request.getLocation(), - request.getSize()); - } - translateFromAbsoluteToLayoutRelative(locationAndSize); - return getConstraintFor(request, null, locationAndSize); - } - - /** - * Generates a draw2d constraint given a <code>Point</code>. This method is - * called during creation, when only a mouse location is available, as well - * as during move, in case no resizing is involved. - * - * @param point - * the Point relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - */ - protected Object getConstraintFor(Point p) { - return new Rectangle(p, PREFERRED_SIZE); - } - - /** - * Generates a draw2d constraint given a <code>Rectangle</code>. This method - * is called during most operations. - * - * @param rect - * the Rectangle relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - */ - protected Object getConstraintFor(Rectangle r) { - return new Rectangle(r); - } - - /** - * Converts a constraint from the format used by LayoutManagers, to the form - * stored in the model. - * - * @param figureConstraint - * the draw2d constraint - * @return the model constraint - */ - protected Object translateToModelConstraint(Object figureConstraint) { - return figureConstraint; - } - - /** - * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#createChildEditPolicy(org.eclipse.gef.EditPart) - */ - protected EditPolicy createChildEditPolicy(EditPart child) { - BMSResizableEditPolicy policy = new BMSResizableEditPolicy(); - policy.setResizeDirections(PositionConstants.EAST - | PositionConstants.WEST); - return policy; - } - - @Override - protected Command createMoveChildCommand(EditPart child, EditPart after) { - - BControl childModel = (BControl) child.getModel(); - BControl parentModel = (BControl) getHost().getModel(); - - if ((childModel instanceof Light && parentModel instanceof Signal)) { - int oldIndex = getHost().getChildren().indexOf(child); - int newIndex = getHost().getChildren().indexOf(after); - if (newIndex > oldIndex) - newIndex--; - ReorderPartCommand command = new ReorderPartCommand(childModel, - parentModel, newIndex); - return command; - } - - return null; - - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - - @Override - protected boolean isHorizontal() { - IFigure figure = getLayoutContainer(); - if (figure.getLayoutManager() instanceof ToolbarLayout) { - return ((ToolbarLayout) figure.getLayoutManager()).isHorizontal(); - } else if (figure.getLayoutManager() instanceof FlowLayout) { - return ((FlowLayout) figure.getLayoutManager()).isHorizontal(); - } - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.editpolicy; + +import java.util.List; + +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.ToolbarLayout; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionRectangle; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.draw2d.geometry.Translatable; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.editpolicies.FlowLayoutEditPolicy; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gef.requests.CreateRequest; + +import de.bmotionstudio.gef.editor.command.AddCommand; +import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; +import de.bmotionstudio.gef.editor.command.ReorderPartCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Light; +import de.bmotionstudio.gef.editor.model.Signal; + +public class SignalLayoutEditPolicy extends FlowLayoutEditPolicy { + + private static final Dimension PREFERRED_SIZE = new Dimension(-1, -1); + + /** + * Constant being used to indicate that upon creation (or during move) a + * size was not specified. + * + * @since 3.7 + */ + protected static final Dimension UNSPECIFIED_SIZE = new Dimension(); + + @Override + protected Command createAddCommand(EditPart child, EditPart after) { + + BControl childModel = (BControl) child.getModel(); + BControl parentModel = (BControl) getHost().getModel(); + if ((childModel instanceof Light && parentModel instanceof Signal)) { + AddCommand command = new AddCommand(); + command.setChild(childModel); + command.setParent(parentModel); + int index = getHost().getChildren().indexOf(after); + command.setIndex(index); + return command; + } + return null; + + } + + @Override + public Command getCommand(Request request) { + if (REQ_RESIZE_CHILDREN.equals(request.getType())) + return getResizeChildrenCommand((ChangeBoundsRequest) request); + return super.getCommand(request); + } + + protected Command getResizeChildrenCommand(ChangeBoundsRequest request) { + CompoundCommand resize = new CompoundCommand(); + Command c; + GraphicalEditPart child; + List<?> children = request.getEditParts(); + for (int i = 0; i < children.size(); i++) { + child = (GraphicalEditPart) children.get(i); + c = createChangeConstraintCommand( + request, + child, + translateToModelConstraint(getConstraintFor(request, child))); + resize.add(c); + } + return resize.unwrap(); + } + + protected Command createChangeConstraintCommand( + ChangeBoundsRequest request, EditPart child, Object constraint) { + BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); + cmd.setModel(child.getModel()); + cmd.setConstraint((Rectangle) constraint); + return cmd; + } + + /** + * Generates a draw2d constraint object for the given + * <code>ChangeBoundsRequest</code> and child EditPart by delegating to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * The rectangle being passed over to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)} is + * calculated based on the child figure's current bounds and the + * ChangeBoundsRequest's move and resize deltas. It is made layout-relative + * by using {@link #translateFromAbsoluteToLayoutRelative(Translatable)} + * before calling + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * @param request + * the ChangeBoundsRequest + * @param child + * the child EditPart for which the constraint should be + * generated + * @return the draw2d constraint + */ + protected Object getConstraintFor(ChangeBoundsRequest request, + GraphicalEditPart child) { + Rectangle locationAndSize = new PrecisionRectangle(child.getFigure() + .getBounds()); + child.getFigure().translateToAbsolute(locationAndSize); + locationAndSize = request.getTransformedRectangle(locationAndSize); + translateFromAbsoluteToLayoutRelative(locationAndSize); + return getConstraintFor(request, child, locationAndSize); + } + + /** + * Responsible of generating a draw2d constraint for the given Rectangle, + * which represents the already transformed (layout-relative) position and + * size of the given Request. + * + * By default, this method delegates to {@link #getConstraintFor(Point)} or + * {@link #getConstraintFor(Rectangle)}, dependent on whether the size of + * the rectangle is an {@link #UNSPECIFIED_SIZE} or not. + * + * Subclasses may overwrite this method in case they need the request or the + * edit part (which will of course not be set during creation) to calculate + * a layout constraint for the request. + * + * @param rectangle + * the Rectangle relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + * @since 3.7 + */ + protected Object getConstraintFor(Request request, GraphicalEditPart child, + Rectangle rectangle) { + if (UNSPECIFIED_SIZE.equals(rectangle.getSize())) { + return getConstraintFor(rectangle.getLocation()); + } + return getConstraintFor(rectangle); + } + + /** + * Generates a draw2d constraint for the given <code>CreateRequest</code> by + * delegating to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * If the CreateRequest has a size, is used during size-on-drop creation, a + * Rectangle of the request's location and size is passed with the + * delegation. Otherwise, a rectangle with the request's location and an + * empty size (0,0) is passed over. + * <P> + * The CreateRequest's location is relative to the Viewer. The location is + * made layout-relative by using + * {@link #translateFromAbsoluteToLayoutRelative(Translatable)} before + * calling {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * @param request + * the CreateRequest + * @return a draw2d constraint + */ + protected Object getConstraintFor(CreateRequest request) { + Rectangle locationAndSize = null; + if (request.getSize() == null || request.getSize().isEmpty()) { + locationAndSize = new PrecisionRectangle(request.getLocation(), + UNSPECIFIED_SIZE); + } else { + locationAndSize = new PrecisionRectangle(request.getLocation(), + request.getSize()); + } + translateFromAbsoluteToLayoutRelative(locationAndSize); + return getConstraintFor(request, null, locationAndSize); + } + + /** + * Generates a draw2d constraint given a <code>Point</code>. This method is + * called during creation, when only a mouse location is available, as well + * as during move, in case no resizing is involved. + * + * @param point + * the Point relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + */ + protected Object getConstraintFor(Point p) { + return new Rectangle(p, PREFERRED_SIZE); + } + + /** + * Generates a draw2d constraint given a <code>Rectangle</code>. This method + * is called during most operations. + * + * @param rect + * the Rectangle relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + */ + protected Object getConstraintFor(Rectangle r) { + return new Rectangle(r); + } + + /** + * Converts a constraint from the format used by LayoutManagers, to the form + * stored in the model. + * + * @param figureConstraint + * the draw2d constraint + * @return the model constraint + */ + protected Object translateToModelConstraint(Object figureConstraint) { + return figureConstraint; + } + + /** + * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#createChildEditPolicy(org.eclipse.gef.EditPart) + */ + protected EditPolicy createChildEditPolicy(EditPart child) { + BMSResizableEditPolicy policy = new BMSResizableEditPolicy(); + policy.setResizeDirections(PositionConstants.EAST + | PositionConstants.WEST); + return policy; + } + + @Override + protected Command createMoveChildCommand(EditPart child, EditPart after) { + + BControl childModel = (BControl) child.getModel(); + BControl parentModel = (BControl) getHost().getModel(); + + if ((childModel instanceof Light && parentModel instanceof Signal)) { + int oldIndex = getHost().getChildren().indexOf(child); + int newIndex = getHost().getChildren().indexOf(after); + if (newIndex > oldIndex) + newIndex--; + ReorderPartCommand command = new ReorderPartCommand(childModel, + parentModel, newIndex); + return command; + } + + return null; + + } + + @Override + protected Command getCreateCommand(CreateRequest request) { + return null; + } + + @Override + protected boolean isHorizontal() { + IFigure figure = getLayoutContainer(); + if (figure.getLayoutManager() instanceof ToolbarLayout) { + return ((ToolbarLayout) figure.getLayoutManager()).isHorizontal(); + } else if (figure.getLayoutManager() instanceof FlowLayout) { + return ((FlowLayout) figure.getLayoutManager()).isHorizontal(); + } + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TableLayoutEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TableLayoutEditPolicy.java index d15decd9868483af831862757a055012ea5a8a02..4e2d64056062c9aea01de89eabf8b5ecba38ff06 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TableLayoutEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TableLayoutEditPolicy.java @@ -1,292 +1,292 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.editpolicy; - -import java.util.List; - -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PrecisionRectangle; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.geometry.Translatable; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.editpolicies.FlowLayoutEditPolicy; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.CreateRequest; - -import de.bmotionstudio.gef.editor.command.AddCommand; -import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; -import de.bmotionstudio.gef.editor.command.ReorderPartCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BTable; -import de.bmotionstudio.gef.editor.model.BTableCell; -import de.bmotionstudio.gef.editor.model.BTableColumn; - -public class TableLayoutEditPolicy extends FlowLayoutEditPolicy { - - private static final Dimension PREFERRED_SIZE = new Dimension(-1, -1); - - /** - * Constant being used to indicate that upon creation (or during move) a - * size was not specified. - * - * @since 3.7 - */ - protected static final Dimension UNSPECIFIED_SIZE = new Dimension(); - - @Override - protected Command createAddCommand(EditPart child, EditPart after) { - - BControl childModel = (BControl) child.getModel(); - BControl parentModel = (BControl) getHost().getModel(); - if ((childModel instanceof BTableColumn && parentModel instanceof BTable) - || (childModel instanceof BTableCell - && parentModel instanceof BTableColumn && childModel - .getParent().equals(parentModel))) { - AddCommand command = new AddCommand(); - command.setChild(childModel); - command.setParent(parentModel); - int index = getHost().getChildren().indexOf(after); - command.setIndex(index); - return command; - } - return null; - } - - @Override - public Command getCommand(Request request) { - if (REQ_RESIZE_CHILDREN.equals(request.getType())) - return getResizeChildrenCommand((ChangeBoundsRequest) request); - return super.getCommand(request); - } - - protected Command getResizeChildrenCommand(ChangeBoundsRequest request) { - CompoundCommand resize = new CompoundCommand(); - Command c; - GraphicalEditPart child; - List<?> children = request.getEditParts(); - for (int i = 0; i < children.size(); i++) { - child = (GraphicalEditPart) children.get(i); - c = createChangeConstraintCommand( - request, - child, - translateToModelConstraint(getConstraintFor(request, child))); - resize.add(c); - } - return resize.unwrap(); - } - - protected Command createChangeConstraintCommand( - ChangeBoundsRequest request, EditPart child, Object constraint) { - BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); - cmd.setModel(child.getModel()); - cmd.setConstraint((Rectangle) constraint); - return cmd; - } - - /** - * Generates a draw2d constraint object for the given - * <code>ChangeBoundsRequest</code> and child EditPart by delegating to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * The rectangle being passed over to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)} is - * calculated based on the child figure's current bounds and the - * ChangeBoundsRequest's move and resize deltas. It is made layout-relative - * by using {@link #translateFromAbsoluteToLayoutRelative(Translatable)} - * before calling - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * @param request - * the ChangeBoundsRequest - * @param child - * the child EditPart for which the constraint should be - * generated - * @return the draw2d constraint - */ - protected Object getConstraintFor(ChangeBoundsRequest request, - GraphicalEditPart child) { - Rectangle locationAndSize = new PrecisionRectangle(child.getFigure() - .getBounds()); - child.getFigure().translateToAbsolute(locationAndSize); - locationAndSize = request.getTransformedRectangle(locationAndSize); - translateFromAbsoluteToLayoutRelative(locationAndSize); - return getConstraintFor(request, child, locationAndSize); - } - - /** - * Responsible of generating a draw2d constraint for the given Rectangle, - * which represents the already transformed (layout-relative) position and - * size of the given Request. - * - * By default, this method delegates to {@link #getConstraintFor(Point)} or - * {@link #getConstraintFor(Rectangle)}, dependent on whether the size of - * the rectangle is an {@link #UNSPECIFIED_SIZE} or not. - * - * Subclasses may overwrite this method in case they need the request or the - * edit part (which will of course not be set during creation) to calculate - * a layout constraint for the request. - * - * @param rectangle - * the Rectangle relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - * @since 3.7 - */ - protected Object getConstraintFor(Request request, GraphicalEditPart child, - Rectangle rectangle) { - if (UNSPECIFIED_SIZE.equals(rectangle.getSize())) { - return getConstraintFor(rectangle.getLocation()); - } - return getConstraintFor(rectangle); - } - - /** - * Generates a draw2d constraint for the given <code>CreateRequest</code> by - * delegating to - * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * If the CreateRequest has a size, is used during size-on-drop creation, a - * Rectangle of the request's location and size is passed with the - * delegation. Otherwise, a rectangle with the request's location and an - * empty size (0,0) is passed over. - * <P> - * The CreateRequest's location is relative to the Viewer. The location is - * made layout-relative by using - * {@link #translateFromAbsoluteToLayoutRelative(Translatable)} before - * calling {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. - * - * @param request - * the CreateRequest - * @return a draw2d constraint - */ - protected Object getConstraintFor(CreateRequest request) { - Rectangle locationAndSize = null; - if (request.getSize() == null || request.getSize().isEmpty()) { - locationAndSize = new PrecisionRectangle(request.getLocation(), - UNSPECIFIED_SIZE); - } else { - locationAndSize = new PrecisionRectangle(request.getLocation(), - request.getSize()); - } - translateFromAbsoluteToLayoutRelative(locationAndSize); - return getConstraintFor(request, null, locationAndSize); - } - - /** - * Generates a draw2d constraint given a <code>Point</code>. This method is - * called during creation, when only a mouse location is available, as well - * as during move, in case no resizing is involved. - * - * @param point - * the Point relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - */ - protected Object getConstraintFor(Point p) { - return new Rectangle(p, PREFERRED_SIZE); - } - - /** - * Generates a draw2d constraint given a <code>Rectangle</code>. This method - * is called during most operations. - * - * @param rect - * the Rectangle relative to the {@link #getLayoutOrigin() layout - * origin} - * @return the constraint - */ - protected Object getConstraintFor(Rectangle r) { - return new Rectangle(r); - } - - /** - * Converts a constraint from the format used by LayoutManagers, to the form - * stored in the model. - * - * @param figureConstraint - * the draw2d constraint - * @return the model constraint - */ - protected Object translateToModelConstraint(Object figureConstraint) { - return figureConstraint; - } - - /** - * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#createChildEditPolicy(org.eclipse.gef.EditPart) - */ - protected EditPolicy createChildEditPolicy(EditPart child) { - BMSResizableEditPolicy policy = new BMSResizableEditPolicy(); - policy.setResizeDirections(PositionConstants.EAST - | PositionConstants.WEST); - return policy; - } - - @Override - protected Command createMoveChildCommand(EditPart child, EditPart after) { - - BControl childModel = (BControl) child.getModel(); - BControl parentModel = (BControl) getHost().getModel(); - - if ((childModel instanceof BTableColumn && parentModel instanceof BTable) - || (childModel instanceof BTableCell && parentModel instanceof BTableColumn)) { - int oldIndex = getHost().getChildren().indexOf(child); - int newIndex = getHost().getChildren().indexOf(after); - if (newIndex > oldIndex) - newIndex--; - ReorderPartCommand command = new ReorderPartCommand(childModel, - parentModel, newIndex); - return command; - } - - return null; - - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - // CreateCommand command = new CreateCommand( - // (BControl) request.getNewObject(), (BControl) getHost() - // .getModel()); - // EditPart after = getInsertionReference(request); - // command.setLayout(new Rectangle(0, 0, 100, 25)); - // int index = getHost().getChildren().indexOf(after); - // command.setIndex(index); - // return command; - return null; - } - - @Override - protected boolean isHorizontal() { - IFigure figure = getLayoutContainer(); - if (figure.getLayoutManager() instanceof ToolbarLayout) { - return ((ToolbarLayout) figure.getLayoutManager()).isHorizontal(); - } else if (figure.getLayoutManager() instanceof FlowLayout) { - return ((FlowLayout) figure.getLayoutManager()).isHorizontal(); - } - return false; - } - - @Override - public void showLayoutTargetFeedback(Request request) { - if (request instanceof CreateRequest) { - Object newObject = ((CreateRequest) request).getNewObject(); - if (!(newObject instanceof BTableColumn || newObject instanceof BTableCell)) - return; - } - super.showLayoutTargetFeedback(request); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.editpolicy; + +import java.util.List; + +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.ToolbarLayout; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionRectangle; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.draw2d.geometry.Translatable; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.editpolicies.FlowLayoutEditPolicy; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gef.requests.CreateRequest; + +import de.bmotionstudio.gef.editor.command.AddCommand; +import de.bmotionstudio.gef.editor.command.BControlChangeLayoutCommand; +import de.bmotionstudio.gef.editor.command.ReorderPartCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BTable; +import de.bmotionstudio.gef.editor.model.BTableCell; +import de.bmotionstudio.gef.editor.model.BTableColumn; + +public class TableLayoutEditPolicy extends FlowLayoutEditPolicy { + + private static final Dimension PREFERRED_SIZE = new Dimension(-1, -1); + + /** + * Constant being used to indicate that upon creation (or during move) a + * size was not specified. + * + * @since 3.7 + */ + protected static final Dimension UNSPECIFIED_SIZE = new Dimension(); + + @Override + protected Command createAddCommand(EditPart child, EditPart after) { + + BControl childModel = (BControl) child.getModel(); + BControl parentModel = (BControl) getHost().getModel(); + if ((childModel instanceof BTableColumn && parentModel instanceof BTable) + || (childModel instanceof BTableCell + && parentModel instanceof BTableColumn && childModel + .getParent().equals(parentModel))) { + AddCommand command = new AddCommand(); + command.setChild(childModel); + command.setParent(parentModel); + int index = getHost().getChildren().indexOf(after); + command.setIndex(index); + return command; + } + return null; + } + + @Override + public Command getCommand(Request request) { + if (REQ_RESIZE_CHILDREN.equals(request.getType())) + return getResizeChildrenCommand((ChangeBoundsRequest) request); + return super.getCommand(request); + } + + protected Command getResizeChildrenCommand(ChangeBoundsRequest request) { + CompoundCommand resize = new CompoundCommand(); + Command c; + GraphicalEditPart child; + List<?> children = request.getEditParts(); + for (int i = 0; i < children.size(); i++) { + child = (GraphicalEditPart) children.get(i); + c = createChangeConstraintCommand( + request, + child, + translateToModelConstraint(getConstraintFor(request, child))); + resize.add(c); + } + return resize.unwrap(); + } + + protected Command createChangeConstraintCommand( + ChangeBoundsRequest request, EditPart child, Object constraint) { + BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand(); + cmd.setModel(child.getModel()); + cmd.setConstraint((Rectangle) constraint); + return cmd; + } + + /** + * Generates a draw2d constraint object for the given + * <code>ChangeBoundsRequest</code> and child EditPart by delegating to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * The rectangle being passed over to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)} is + * calculated based on the child figure's current bounds and the + * ChangeBoundsRequest's move and resize deltas. It is made layout-relative + * by using {@link #translateFromAbsoluteToLayoutRelative(Translatable)} + * before calling + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * @param request + * the ChangeBoundsRequest + * @param child + * the child EditPart for which the constraint should be + * generated + * @return the draw2d constraint + */ + protected Object getConstraintFor(ChangeBoundsRequest request, + GraphicalEditPart child) { + Rectangle locationAndSize = new PrecisionRectangle(child.getFigure() + .getBounds()); + child.getFigure().translateToAbsolute(locationAndSize); + locationAndSize = request.getTransformedRectangle(locationAndSize); + translateFromAbsoluteToLayoutRelative(locationAndSize); + return getConstraintFor(request, child, locationAndSize); + } + + /** + * Responsible of generating a draw2d constraint for the given Rectangle, + * which represents the already transformed (layout-relative) position and + * size of the given Request. + * + * By default, this method delegates to {@link #getConstraintFor(Point)} or + * {@link #getConstraintFor(Rectangle)}, dependent on whether the size of + * the rectangle is an {@link #UNSPECIFIED_SIZE} or not. + * + * Subclasses may overwrite this method in case they need the request or the + * edit part (which will of course not be set during creation) to calculate + * a layout constraint for the request. + * + * @param rectangle + * the Rectangle relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + * @since 3.7 + */ + protected Object getConstraintFor(Request request, GraphicalEditPart child, + Rectangle rectangle) { + if (UNSPECIFIED_SIZE.equals(rectangle.getSize())) { + return getConstraintFor(rectangle.getLocation()); + } + return getConstraintFor(rectangle); + } + + /** + * Generates a draw2d constraint for the given <code>CreateRequest</code> by + * delegating to + * {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * If the CreateRequest has a size, is used during size-on-drop creation, a + * Rectangle of the request's location and size is passed with the + * delegation. Otherwise, a rectangle with the request's location and an + * empty size (0,0) is passed over. + * <P> + * The CreateRequest's location is relative to the Viewer. The location is + * made layout-relative by using + * {@link #translateFromAbsoluteToLayoutRelative(Translatable)} before + * calling {@link #getConstraintFor(Request, GraphicalEditPart, Rectangle)}. + * + * @param request + * the CreateRequest + * @return a draw2d constraint + */ + protected Object getConstraintFor(CreateRequest request) { + Rectangle locationAndSize = null; + if (request.getSize() == null || request.getSize().isEmpty()) { + locationAndSize = new PrecisionRectangle(request.getLocation(), + UNSPECIFIED_SIZE); + } else { + locationAndSize = new PrecisionRectangle(request.getLocation(), + request.getSize()); + } + translateFromAbsoluteToLayoutRelative(locationAndSize); + return getConstraintFor(request, null, locationAndSize); + } + + /** + * Generates a draw2d constraint given a <code>Point</code>. This method is + * called during creation, when only a mouse location is available, as well + * as during move, in case no resizing is involved. + * + * @param point + * the Point relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + */ + protected Object getConstraintFor(Point p) { + return new Rectangle(p, PREFERRED_SIZE); + } + + /** + * Generates a draw2d constraint given a <code>Rectangle</code>. This method + * is called during most operations. + * + * @param rect + * the Rectangle relative to the {@link #getLayoutOrigin() layout + * origin} + * @return the constraint + */ + protected Object getConstraintFor(Rectangle r) { + return new Rectangle(r); + } + + /** + * Converts a constraint from the format used by LayoutManagers, to the form + * stored in the model. + * + * @param figureConstraint + * the draw2d constraint + * @return the model constraint + */ + protected Object translateToModelConstraint(Object figureConstraint) { + return figureConstraint; + } + + /** + * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#createChildEditPolicy(org.eclipse.gef.EditPart) + */ + protected EditPolicy createChildEditPolicy(EditPart child) { + BMSResizableEditPolicy policy = new BMSResizableEditPolicy(); + policy.setResizeDirections(PositionConstants.EAST + | PositionConstants.WEST); + return policy; + } + + @Override + protected Command createMoveChildCommand(EditPart child, EditPart after) { + + BControl childModel = (BControl) child.getModel(); + BControl parentModel = (BControl) getHost().getModel(); + + if ((childModel instanceof BTableColumn && parentModel instanceof BTable) + || (childModel instanceof BTableCell && parentModel instanceof BTableColumn)) { + int oldIndex = getHost().getChildren().indexOf(child); + int newIndex = getHost().getChildren().indexOf(after); + if (newIndex > oldIndex) + newIndex--; + ReorderPartCommand command = new ReorderPartCommand(childModel, + parentModel, newIndex); + return command; + } + + return null; + + } + + @Override + protected Command getCreateCommand(CreateRequest request) { + // CreateCommand command = new CreateCommand( + // (BControl) request.getNewObject(), (BControl) getHost() + // .getModel()); + // EditPart after = getInsertionReference(request); + // command.setLayout(new Rectangle(0, 0, 100, 25)); + // int index = getHost().getChildren().indexOf(after); + // command.setIndex(index); + // return command; + return null; + } + + @Override + protected boolean isHorizontal() { + IFigure figure = getLayoutContainer(); + if (figure.getLayoutManager() instanceof ToolbarLayout) { + return ((ToolbarLayout) figure.getLayoutManager()).isHorizontal(); + } else if (figure.getLayoutManager() instanceof FlowLayout) { + return ((FlowLayout) figure.getLayoutManager()).isHorizontal(); + } + return false; + } + + @Override + public void showLayoutTargetFeedback(Request request) { + if (request instanceof CreateRequest) { + Object newObject = ((CreateRequest) request).getNewObject(); + if (!(newObject instanceof BTableColumn || newObject instanceof BTableCell)) + return; + } + super.showLayoutTargetFeedback(request); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java index 9756e26f670cb2c3b8d19ee1b01f592220d83a18..7ae1416b8fb32c19c83d8d2f37c805c2b527d847 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java @@ -1,133 +1,133 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.editpolicy; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gef.requests.DropRequest; -import org.eclipse.gef.requests.ReconnectRequest; - -import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; -import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.Track; -import de.bmotionstudio.gef.editor.model.TrackNode; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; - -public class TrackEditPolicy extends BMSConnectionEditPolicy { - - @Override - protected Command getConnectionCreateCommand(CreateConnectionRequest request) { - - Command cmd = null; - - Object newObject = request.getNewObject(); - if (newObject instanceof Track) { - - Object model = getHost().getModel(); - if (model instanceof TrackNode) { - - Track track = (Track) newObject; - TrackNode trackNode = (TrackNode) model; - cmd = new ConnectionCreateCommand(trackNode); - track.setVisualization(trackNode.getVisualization()); - ((ConnectionCreateCommand) cmd).setConnection(track); - request.setStartCommand(cmd); - - } - - } else if (newObject instanceof BConnection) { - cmd = super.getConnectionCreateCommand(request); - } - - return cmd; - - } - - @Override - protected Command getConnectionCompleteCommand( - CreateConnectionRequest request) { - - Command cmd = null; - - Object newObject = request.getNewObject(); - if (newObject instanceof Track) { - - cmd = request.getStartCommand(); - ((ConnectionCreateCommand) cmd).setTarget((TrackNode) getHost() - .getModel()); - - } else if (newObject instanceof BConnection) { - cmd = super.getConnectionCompleteCommand(request); - } - - return cmd; - - } - - @Override - protected Command getReconnectSourceCommand(ReconnectRequest request) { - - Command cmd = null; - - Object newObject = request.getConnectionEditPart().getModel(); - if (newObject instanceof Track) { - - Track track = (Track) newObject; - TrackNode newSource = (TrackNode) getHost().getModel(); - cmd = new ConnectionReconnectCommand(); - ((ConnectionReconnectCommand) cmd).setNewSource(newSource); - ((ConnectionReconnectCommand) cmd).setConnection(track); - - } else if (newObject instanceof BConnection) { - cmd = super.getReconnectSourceCommand(request); - } - - return cmd; - - } - - @Override - protected Command getReconnectTargetCommand(ReconnectRequest request) { - - Command cmd = null; - - Object newObject = request.getConnectionEditPart().getModel(); - if (newObject instanceof Track) { - - Track track = (Track) newObject; - TrackNode newTarget = (TrackNode) getHost().getModel(); - cmd = new ConnectionReconnectCommand(); - ((ConnectionReconnectCommand) cmd).setNewTarget(newTarget); - ((ConnectionReconnectCommand) cmd).setConnection(track); - - } else if (newObject instanceof BConnection) { - cmd = super.getReconnectTargetCommand(request); - } - - return cmd; - - } - - @Override - protected void showTargetConnectionFeedback(DropRequest request) { - if (getHost() instanceof BMSAbstractEditPart) { - BMSAbstractEditPart host = (BMSAbstractEditPart) getHost(); - host.getFigure().setBackgroundColor(ColorConstants.lightGray); - } - } - - @Override - protected void eraseTargetConnectionFeedback(DropRequest request) { - if (getHost() instanceof BMSAbstractEditPart) { - BMSAbstractEditPart host = (BMSAbstractEditPart) getHost(); - host.getFigure().setBackgroundColor(ColorConstants.white); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.editpolicy; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.DropRequest; +import org.eclipse.gef.requests.ReconnectRequest; + +import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; +import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.Track; +import de.bmotionstudio.gef.editor.model.TrackNode; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; + +public class TrackEditPolicy extends BMSConnectionEditPolicy { + + @Override + protected Command getConnectionCreateCommand(CreateConnectionRequest request) { + + Command cmd = null; + + Object newObject = request.getNewObject(); + if (newObject instanceof Track) { + + Object model = getHost().getModel(); + if (model instanceof TrackNode) { + + Track track = (Track) newObject; + TrackNode trackNode = (TrackNode) model; + cmd = new ConnectionCreateCommand(trackNode); + track.setVisualization(trackNode.getVisualization()); + ((ConnectionCreateCommand) cmd).setConnection(track); + request.setStartCommand(cmd); + + } + + } else if (newObject instanceof BConnection) { + cmd = super.getConnectionCreateCommand(request); + } + + return cmd; + + } + + @Override + protected Command getConnectionCompleteCommand( + CreateConnectionRequest request) { + + Command cmd = null; + + Object newObject = request.getNewObject(); + if (newObject instanceof Track) { + + cmd = request.getStartCommand(); + ((ConnectionCreateCommand) cmd).setTarget((TrackNode) getHost() + .getModel()); + + } else if (newObject instanceof BConnection) { + cmd = super.getConnectionCompleteCommand(request); + } + + return cmd; + + } + + @Override + protected Command getReconnectSourceCommand(ReconnectRequest request) { + + Command cmd = null; + + Object newObject = request.getConnectionEditPart().getModel(); + if (newObject instanceof Track) { + + Track track = (Track) newObject; + TrackNode newSource = (TrackNode) getHost().getModel(); + cmd = new ConnectionReconnectCommand(); + ((ConnectionReconnectCommand) cmd).setNewSource(newSource); + ((ConnectionReconnectCommand) cmd).setConnection(track); + + } else if (newObject instanceof BConnection) { + cmd = super.getReconnectSourceCommand(request); + } + + return cmd; + + } + + @Override + protected Command getReconnectTargetCommand(ReconnectRequest request) { + + Command cmd = null; + + Object newObject = request.getConnectionEditPart().getModel(); + if (newObject instanceof Track) { + + Track track = (Track) newObject; + TrackNode newTarget = (TrackNode) getHost().getModel(); + cmd = new ConnectionReconnectCommand(); + ((ConnectionReconnectCommand) cmd).setNewTarget(newTarget); + ((ConnectionReconnectCommand) cmd).setConnection(track); + + } else if (newObject instanceof BConnection) { + cmd = super.getReconnectTargetCommand(request); + } + + return cmd; + + } + + @Override + protected void showTargetConnectionFeedback(DropRequest request) { + if (getHost() instanceof BMSAbstractEditPart) { + BMSAbstractEditPart host = (BMSAbstractEditPart) getHost(); + host.getFigure().setBackgroundColor(ColorConstants.lightGray); + } + } + + @Override + protected void eraseTargetConnectionFeedback(DropRequest request) { + if (getHost() instanceof BMSAbstractEditPart) { + BMSAbstractEditPart host = (BMSAbstractEditPart) getHost(); + host.getFigure().setBackgroundColor(ColorConstants.white); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBHelper.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBHelper.java index 2b02cd813bf0fd2ded27ffc60c619f4caaef8b30..a683ecc91165361f3cae6ed35c0b253c07c04656 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBHelper.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBHelper.java @@ -1,297 +1,297 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.eventb; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eventb.core.ISCAction; -import org.eventb.core.ISCConstant; -import org.eventb.core.ISCContextRoot; -import org.eventb.core.ISCEvent; -import org.eventb.core.ISCGuard; -import org.eventb.core.ISCInternalContext; -import org.eventb.core.ISCInvariant; -import org.eventb.core.ISCMachineRoot; -import org.eventb.core.ISCParameter; -import org.eventb.core.ISCVariable; -import org.eventb.core.ast.FormulaFactory; -import org.eventb.core.basis.ContextRoot; -import org.eventb.core.basis.EventBRoot; -import org.eventb.core.basis.MachineRoot; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; - -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.logging.Logger; - -public final class EventBHelper { - - private static FormulaFactory formularFactory = FormulaFactory.getDefault(); - - public static EventBRoot getCorrespondingFile(IFile file, - String machineFileName) { - IRodinProject rProject = RodinCore.valueOf(file.getProject()); - EventBRoot root = null; - if (rProject != null) { - IRodinFile rFile = rProject.getRodinFile(machineFileName); - if (rFile != null && rFile.getRoot() instanceof EventBRoot) - root = (EventBRoot) rFile.getRoot(); - } - return root; - } - - public static List<MachineOperation> getOperations( - Visualization visualization) { - - ArrayList<MachineOperation> tmpSet = new ArrayList<MachineOperation>(); - - if (visualization.getLanguage().equals("EventB")) { - - EventBRoot correspondingFile = getCorrespondingFile( - visualization.getProjectFile(), - visualization.getMachineName()); - - if (correspondingFile instanceof MachineRoot - && correspondingFile.exists()) { - - ISCMachineRoot machineRoot = correspondingFile - .getSCMachineRoot(); - - try { - - ISCEvent[] events = machineRoot.getSCEvents(); - - for (ISCEvent event : events) { - - List<String> parSet = new ArrayList<String>(); - List<String> guardSet = new ArrayList<String>(); - - for (ISCParameter par : event.getSCParameters()) - parSet.add(par.getIdentifierString()); - - for (ISCGuard guard : event.getSCGuards()) - guardSet.add(guard.getPredicateString()); - - MachineOperation op = new MachineOperation( - event.getLabel(), parSet, guardSet, - renderEvent(event)); - tmpSet.add(op); - - } - - } catch (CoreException e) { - String message = "Rodin DB Exception while getting operations: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineOperation>()); - } - - } else if (visualization.getLanguage().equals("ClassicalB")) { - // TODO: Implement me!!! - } - - } - - return tmpSet; - - } - - public static List<MachineContentObject> getVariables( - Visualization visualization) { - - EventBRoot correspondingFile = getCorrespondingFile( - visualization.getProjectFile(), visualization.getMachineName()); - - ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); - - if (correspondingFile instanceof MachineRoot - && correspondingFile.exists()) { - - ISCMachineRoot machineRoot = correspondingFile.getSCMachineRoot(); - - try { - ISCVariable[] vars = machineRoot.getSCVariables(); - for (ISCVariable var : vars) { - MachineContentObject machinevar = new MachineContentObject( - var.getIdentifierString()); - machinevar.setType(var.getType(formularFactory)); - tmpSet.add(machinevar); - } - } catch (CoreException e) { - String message = "Rodin DB Exception while getting variables: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineContentObject>()); - } - - } - - return tmpSet; - - } - - public static List<MachineContentObject> getInvariants( - Visualization visualization) { - - EventBRoot correspondingFile = getCorrespondingFile( - visualization.getProjectFile(), visualization.getMachineName()); - - ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); - - if (correspondingFile instanceof MachineRoot - && correspondingFile.exists()) { - - ISCMachineRoot machineRoot = correspondingFile.getSCMachineRoot(); - - try { - ISCInvariant[] invariants = machineRoot.getSCInvariants(); - for (ISCInvariant inv : invariants) { - MachineContentObject machineinv = new MachineContentObject( - inv.getPredicateString()); - tmpSet.add(machineinv); - } - } catch (RodinDBException e) { - String message = "Rodin DB Exception while getting invariants: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineContentObject>()); - } - - } - - return tmpSet; - - } - - public static List<MachineContentObject> getConstants( - Visualization visualization) { - - EventBRoot correspondingFile = getCorrespondingFile( - visualization.getProjectFile(), visualization.getMachineName()); - - ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); - - if (correspondingFile.exists()) { - - try { - if (correspondingFile instanceof MachineRoot) { - - ISCMachineRoot machineRoot = correspondingFile - .getSCMachineRoot(); - - ISCInternalContext[] seenContexts = machineRoot - .getSCSeenContexts(); - for (ISCInternalContext context : seenContexts) { - - for (ISCConstant constant : context.getSCConstants()) { - try { - MachineContentObject machineinv = new MachineContentObject( - constant.getIdentifierString()); - machineinv.setType(constant - .getType(formularFactory)); - tmpSet.add(machineinv); - } catch (CoreException e) { - String message = "Rodin DB Exception while getting variables: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineContentObject>()); - } - - } - - } - - } else if (correspondingFile instanceof ContextRoot) { - - ISCContextRoot contextRoot = correspondingFile - .getSCContextRoot(); - for (ISCConstant constant : contextRoot.getSCConstants()) { - MachineContentObject machineinv = new MachineContentObject( - constant.getIdentifierString()); - try { - machineinv.setType(constant - .getType(formularFactory)); - } catch (CoreException e) { - String message = "Rodin DB Exception while getting variables: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineContentObject>()); - } - tmpSet.add(machineinv); - } - - } - - } catch (RodinDBException e) { - String message = "Rodin DB Exception while getting constants: " - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - return Collections - .unmodifiableList(new ArrayList<MachineContentObject>()); - } - - } - - return tmpSet; - - } - - // Changed RodinDBException to CoreException for Rodin 3 - // Might not be an intentional change in Rodin? - public static String renderEvent(ISCEvent event) throws CoreException { - StringBuffer sb = new StringBuffer(); - sb.append("event "); - sb.append(event.getLabel()); - sb.append("\n"); - - if (event.getSCParameters().length > 0) { - sb.append(" any "); - for (ISCParameter parameter : event.getSCParameters()) { - sb.append(parameter.getIdentifierString()); - sb.append(" "); - } - sb.append("\n"); - - } - - if (event.getSCGuards().length > 0) { - sb.append(" where\n"); - for (ISCGuard guard : event.getSCGuards()) { - sb.append(" @"); - sb.append(guard.getLabel()); - sb.append(" "); - sb.append(guard.getPredicateString()); - sb.append("\n"); - } - } - - if (event.getSCActions().length > 0) { - sb.append(" then\n"); - for (ISCAction action : event.getSCActions()) { - sb.append(" @"); - sb.append(action.getLabel()); - sb.append(" "); - sb.append(action.getAssignmentString()); - sb.append("\n"); - } - } - sb.append("end"); - return sb.toString(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.eventb; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eventb.core.ISCAction; +import org.eventb.core.ISCConstant; +import org.eventb.core.ISCContextRoot; +import org.eventb.core.ISCEvent; +import org.eventb.core.ISCGuard; +import org.eventb.core.ISCInternalContext; +import org.eventb.core.ISCInvariant; +import org.eventb.core.ISCMachineRoot; +import org.eventb.core.ISCParameter; +import org.eventb.core.ISCVariable; +import org.eventb.core.ast.FormulaFactory; +import org.eventb.core.basis.ContextRoot; +import org.eventb.core.basis.EventBRoot; +import org.eventb.core.basis.MachineRoot; +import org.rodinp.core.IRodinFile; +import org.rodinp.core.IRodinProject; +import org.rodinp.core.RodinCore; +import org.rodinp.core.RodinDBException; + +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.logging.Logger; + +public final class EventBHelper { + + private static FormulaFactory formularFactory = FormulaFactory.getDefault(); + + public static EventBRoot getCorrespondingFile(IFile file, + String machineFileName) { + IRodinProject rProject = RodinCore.valueOf(file.getProject()); + EventBRoot root = null; + if (rProject != null) { + IRodinFile rFile = rProject.getRodinFile(machineFileName); + if (rFile != null && rFile.getRoot() instanceof EventBRoot) + root = (EventBRoot) rFile.getRoot(); + } + return root; + } + + public static List<MachineOperation> getOperations( + Visualization visualization) { + + ArrayList<MachineOperation> tmpSet = new ArrayList<MachineOperation>(); + + if (visualization.getLanguage().equals("EventB")) { + + EventBRoot correspondingFile = getCorrespondingFile( + visualization.getProjectFile(), + visualization.getMachineName()); + + if (correspondingFile instanceof MachineRoot + && correspondingFile.exists()) { + + ISCMachineRoot machineRoot = correspondingFile + .getSCMachineRoot(); + + try { + + ISCEvent[] events = machineRoot.getSCEvents(); + + for (ISCEvent event : events) { + + List<String> parSet = new ArrayList<String>(); + List<String> guardSet = new ArrayList<String>(); + + for (ISCParameter par : event.getSCParameters()) + parSet.add(par.getIdentifierString()); + + for (ISCGuard guard : event.getSCGuards()) + guardSet.add(guard.getPredicateString()); + + MachineOperation op = new MachineOperation( + event.getLabel(), parSet, guardSet, + renderEvent(event)); + tmpSet.add(op); + + } + + } catch (CoreException e) { + String message = "Rodin DB Exception while getting operations: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineOperation>()); + } + + } else if (visualization.getLanguage().equals("ClassicalB")) { + // TODO: Implement me!!! + } + + } + + return tmpSet; + + } + + public static List<MachineContentObject> getVariables( + Visualization visualization) { + + EventBRoot correspondingFile = getCorrespondingFile( + visualization.getProjectFile(), visualization.getMachineName()); + + ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); + + if (correspondingFile instanceof MachineRoot + && correspondingFile.exists()) { + + ISCMachineRoot machineRoot = correspondingFile.getSCMachineRoot(); + + try { + ISCVariable[] vars = machineRoot.getSCVariables(); + for (ISCVariable var : vars) { + MachineContentObject machinevar = new MachineContentObject( + var.getIdentifierString()); + machinevar.setType(var.getType(formularFactory)); + tmpSet.add(machinevar); + } + } catch (CoreException e) { + String message = "Rodin DB Exception while getting variables: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineContentObject>()); + } + + } + + return tmpSet; + + } + + public static List<MachineContentObject> getInvariants( + Visualization visualization) { + + EventBRoot correspondingFile = getCorrespondingFile( + visualization.getProjectFile(), visualization.getMachineName()); + + ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); + + if (correspondingFile instanceof MachineRoot + && correspondingFile.exists()) { + + ISCMachineRoot machineRoot = correspondingFile.getSCMachineRoot(); + + try { + ISCInvariant[] invariants = machineRoot.getSCInvariants(); + for (ISCInvariant inv : invariants) { + MachineContentObject machineinv = new MachineContentObject( + inv.getPredicateString()); + tmpSet.add(machineinv); + } + } catch (RodinDBException e) { + String message = "Rodin DB Exception while getting invariants: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineContentObject>()); + } + + } + + return tmpSet; + + } + + public static List<MachineContentObject> getConstants( + Visualization visualization) { + + EventBRoot correspondingFile = getCorrespondingFile( + visualization.getProjectFile(), visualization.getMachineName()); + + ArrayList<MachineContentObject> tmpSet = new ArrayList<MachineContentObject>(); + + if (correspondingFile.exists()) { + + try { + if (correspondingFile instanceof MachineRoot) { + + ISCMachineRoot machineRoot = correspondingFile + .getSCMachineRoot(); + + ISCInternalContext[] seenContexts = machineRoot + .getSCSeenContexts(); + for (ISCInternalContext context : seenContexts) { + + for (ISCConstant constant : context.getSCConstants()) { + try { + MachineContentObject machineinv = new MachineContentObject( + constant.getIdentifierString()); + machineinv.setType(constant + .getType(formularFactory)); + tmpSet.add(machineinv); + } catch (CoreException e) { + String message = "Rodin DB Exception while getting variables: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineContentObject>()); + } + + } + + } + + } else if (correspondingFile instanceof ContextRoot) { + + ISCContextRoot contextRoot = correspondingFile + .getSCContextRoot(); + for (ISCConstant constant : contextRoot.getSCConstants()) { + MachineContentObject machineinv = new MachineContentObject( + constant.getIdentifierString()); + try { + machineinv.setType(constant + .getType(formularFactory)); + } catch (CoreException e) { + String message = "Rodin DB Exception while getting variables: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineContentObject>()); + } + tmpSet.add(machineinv); + } + + } + + } catch (RodinDBException e) { + String message = "Rodin DB Exception while getting constants: " + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + return Collections + .unmodifiableList(new ArrayList<MachineContentObject>()); + } + + } + + return tmpSet; + + } + + // Changed RodinDBException to CoreException for Rodin 3 + // Might not be an intentional change in Rodin? + public static String renderEvent(ISCEvent event) throws CoreException { + StringBuffer sb = new StringBuffer(); + sb.append("event "); + sb.append(event.getLabel()); + sb.append("\n"); + + if (event.getSCParameters().length > 0) { + sb.append(" any "); + for (ISCParameter parameter : event.getSCParameters()) { + sb.append(parameter.getIdentifierString()); + sb.append(" "); + } + sb.append("\n"); + + } + + if (event.getSCGuards().length > 0) { + sb.append(" where\n"); + for (ISCGuard guard : event.getSCGuards()) { + sb.append(" @"); + sb.append(guard.getLabel()); + sb.append(" "); + sb.append(guard.getPredicateString()); + sb.append("\n"); + } + } + + if (event.getSCActions().length > 0) { + sb.append(" then\n"); + for (ISCAction action : event.getSCActions()) { + sb.append(" @"); + sb.append(action.getLabel()); + sb.append(" "); + sb.append(action.getAssignmentString()); + sb.append("\n"); + } + } + sb.append("end"); + return sb.toString(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBLanguageService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBLanguageService.java index 35dd823a1a34c023287d9cfa9fa6647e827a62d5..30b1cdd5fb4b4c620ecfc033c9bf31a92dd0cba5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBLanguageService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/EventBLanguageService.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.eventb; - -import org.eclipse.core.resources.IFile; -import org.eventb.core.IContextRoot; -import org.eventb.core.IEventBRoot; -import org.eventb.core.IMachineRoot; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; -import org.rodinp.core.RodinCore; - -import de.bmotionstudio.gef.editor.ILanguageService; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.core.command.LoadEventBModelCommand; -import de.prob.exceptions.ProBException; - -/** - * @author Lukas Ladenberger - * - */ -public class EventBLanguageService implements ILanguageService { - - private IEventBRoot getCorrespondingFile(IFile file, String machineFileName) { - IRodinProject rProject = RodinCore.valueOf(file.getProject()); - IRodinFile rFile = rProject.getRodinFile(machineFileName); - IEventBRoot eventbRoot = (IEventBRoot) rFile.getRoot(); - return eventbRoot; - } - - @Override - public void startProBAnimator(Visualization v) throws ProBException { - IEventBRoot modelRoot = getCorrespondingFile(v.getProjectFile(), - v.getMachineName()); - LoadEventBModelCommand.load(v.getAnimation().getAnimator(), modelRoot); - } - - @Override - public boolean isLanguageFile(IFile f) { - IRodinProject rProject = RodinCore.valueOf(f.getProject()); - IRodinFile rFile = rProject.getRodinFile(f.getName()); - if (rFile != null - && ((rFile.getRoot() instanceof IMachineRoot) || (rFile - .getRoot() instanceof IContextRoot))) - return true; - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.eventb; + +import org.eclipse.core.resources.IFile; +import org.eventb.core.IContextRoot; +import org.eventb.core.IEventBRoot; +import org.eventb.core.IMachineRoot; +import org.rodinp.core.IRodinFile; +import org.rodinp.core.IRodinProject; +import org.rodinp.core.RodinCore; + +import de.bmotionstudio.gef.editor.ILanguageService; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.core.command.LoadEventBModelCommand; +import de.prob.exceptions.ProBException; + +/** + * @author Lukas Ladenberger + * + */ +public class EventBLanguageService implements ILanguageService { + + private IEventBRoot getCorrespondingFile(IFile file, String machineFileName) { + IRodinProject rProject = RodinCore.valueOf(file.getProject()); + IRodinFile rFile = rProject.getRodinFile(machineFileName); + IEventBRoot eventbRoot = (IEventBRoot) rFile.getRoot(); + return eventbRoot; + } + + @Override + public void startProBAnimator(Visualization v) throws ProBException { + IEventBRoot modelRoot = getCorrespondingFile(v.getProjectFile(), + v.getMachineName()); + LoadEventBModelCommand.load(v.getAnimation().getAnimator(), modelRoot); + } + + @Override + public boolean isLanguageFile(IFile f) { + IRodinProject rProject = RodinCore.valueOf(f.getProject()); + IRodinFile rFile = rProject.getRodinFile(f.getName()); + if (rFile != null + && ((rFile.getRoot() instanceof IMachineRoot) || (rFile + .getRoot() instanceof IContextRoot))) + return true; + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineContentObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineContentObject.java index e96ac7b06d2282ca95ac0713d56474ccc7a31b38..b30211bca12e23ed05e97e16635c2e40ac0686f2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineContentObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineContentObject.java @@ -4,32 +4,32 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.eventb; +package de.bmotionstudio.gef.editor.eventb; import org.eventb.core.ast.Type; import de.bmotionstudio.gef.editor.BindingObject; - - -public class MachineContentObject extends BindingObject { - + + +public class MachineContentObject extends BindingObject { + private String label; - private Type type; - - public MachineContentObject(String label) { - this.setLabel(label); - } - - public void setLabel(String label) { - this.label = label; - } - - public String getLabel() { - return label; - } - - public String toString() { - return this.label; + private Type type; + + public MachineContentObject(String label) { + this.setLabel(label); + } + + public void setLabel(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + + public String toString() { + return this.label; } public Type getType() { @@ -39,5 +39,5 @@ public class MachineContentObject extends BindingObject { public void setType(Type type) { this.type = type; } - -} + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineOperation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineOperation.java index 92e892667da3043a9f943db1971ed37f5ae2e8e0..503e8e6012a7ac59b081ba3eba911c3f6e563a23 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineOperation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/eventb/MachineOperation.java @@ -1,54 +1,54 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.eventb; - -import java.util.ArrayList; -import java.util.List; - -public class MachineOperation extends MachineContentObject { - - private List<String> parameters; - private List<String> guards; - private String renderedOperation; - - public MachineOperation(String label, List<String> parameters, - List<String> guards, String renderedOperation) { - super(label); - this.parameters = parameters; - this.guards = guards; - this.renderedOperation = renderedOperation; - } - - public MachineOperation(String label) { - super(label); - } - - public List<String> getParameters() { - return this.parameters; - } - - public List<String> getGuards() { - return guards; - } - - public void setParameters(ArrayList<String> parameters) { - this.parameters = parameters; - } - - public void setGuards(ArrayList<String> guards) { - this.guards = guards; - } - - public String getRenderedOperation() { - return renderedOperation; - } - - public void setRenderedOperation(String renderedOperation) { - this.renderedOperation = renderedOperation; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.eventb; + +import java.util.ArrayList; +import java.util.List; + +public class MachineOperation extends MachineContentObject { + + private List<String> parameters; + private List<String> guards; + private String renderedOperation; + + public MachineOperation(String label, List<String> parameters, + List<String> guards, String renderedOperation) { + super(label); + this.parameters = parameters; + this.guards = guards; + this.renderedOperation = renderedOperation; + } + + public MachineOperation(String label) { + super(label); + } + + public List<String> getParameters() { + return this.parameters; + } + + public List<String> getGuards() { + return guards; + } + + public void setParameters(ArrayList<String> parameters) { + this.parameters = parameters; + } + + public void setGuards(ArrayList<String> guards) { + this.guards = guards; + } + + public String getRenderedOperation() { + return renderedOperation; + } + + public void setRenderedOperation(String renderedOperation) { + this.renderedOperation = renderedOperation; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/AbstractBMotionFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/AbstractBMotionFigure.java index 479b6923fb817ab333ffdc67c08d29c8408c61bf..f8df828dc80f408e824fc1ca60401ae0db9403ff 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/AbstractBMotionFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/AbstractBMotionFigure.java @@ -1,67 +1,67 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.Clickable; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.geometry.Rectangle; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; - -/** - * @author Lukas Ladenberger - * - */ -public class AbstractBMotionFigure extends Clickable { - - protected boolean visible; - protected boolean isRunning; - public static final int HIDDEN_ALPHA_VALUE = 35; - - public AbstractBMotionFigure() { - this.visible = true; - this.isRunning = false; - } - - public void deactivateFigure() { - } - - public void activateFigure() { - } - - @Override - public void setVisible(boolean visible) { - if (!isRunning()) { - this.visible = visible; - repaint(); - } else { - super.setVisible(visible); - } - } - - @Override - public void paint(Graphics g) { - Rectangle clientArea = getClientArea(); - if (!this.visible && !isRunning()) { - g.drawImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_CONTROL_HIDDEN), - clientArea.x, clientArea.y); - g.setAlpha(HIDDEN_ALPHA_VALUE); - } - super.paint(g); - } - - public boolean isRunning() { - return isRunning; - } - - public void setRunning(boolean isRunning) { - this.isRunning = isRunning; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.Clickable; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Rectangle; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; + +/** + * @author Lukas Ladenberger + * + */ +public class AbstractBMotionFigure extends Clickable { + + protected boolean visible; + protected boolean isRunning; + public static final int HIDDEN_ALPHA_VALUE = 35; + + public AbstractBMotionFigure() { + this.visible = true; + this.isRunning = false; + } + + public void deactivateFigure() { + } + + public void activateFigure() { + } + + @Override + public void setVisible(boolean visible) { + if (!isRunning()) { + this.visible = visible; + repaint(); + } else { + super.setVisible(visible); + } + } + + @Override + public void paint(Graphics g) { + Rectangle clientArea = getClientArea(); + if (!this.visible && !isRunning()) { + g.drawImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_CONTROL_HIDDEN), + clientArea.x, clientArea.y); + g.setAlpha(HIDDEN_ALPHA_VALUE); + } + super.paint(g); + } + + public boolean isRunning() { + return isRunning; + } + + public void setRunning(boolean isRunning) { + this.isRunning = isRunning; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/BMSImageFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/BMSImageFigure.java index 091a5bacec7edea739cc5e3cc7b8881ad4f39465..02e828689def7954f2fd52f11e46f6728834219a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/BMSImageFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/BMSImageFigure.java @@ -1,156 +1,151 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.ImageFigure; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.ImageLoader; -import org.eclipse.swt.widgets.Display; - -public class BMSImageFigure extends AbstractBMotionFigure { - - private ImageFigure imageFigure; - - private int alpha; - - final ImageLoader loader = new ImageLoader(); - - private Map<String, List<Image>> images = new HashMap<String, List<Image>>(); - private GIFThread currentGIFThread; - - public BMSImageFigure() { - setLayoutManager(new StackLayout()); - imageFigure = new ImageFigure(); - add(imageFigure); - } - - public void setLayout(Rectangle rect) { - getParent().setConstraint(imageFigure, rect); - } - - @Override - public void paint(Graphics g) { - g.setAlpha(alpha); - super.paint(g); - } - - public void setImage(String myPath) { - - if (currentGIFThread != null) - currentGIFThread.interrupt(); - - if (new File(myPath).exists()) { - - loader.load(myPath); - - List<Image> imgList = images.get(myPath); - if (imgList == null) { - imgList = new ArrayList<Image>(); - for (ImageData imageData : loader.data) - imgList.add(new Image(Display.getDefault(), imageData)); - images.put(myPath, imgList); - } - - if (loader.data.length > 1) { // GIF file - currentGIFThread = new GIFThread(this.imageFigure, myPath, - imgList); - currentGIFThread.start(); - } else { // Non GIF file - imageFigure.setImage(imgList.get(0)); - } - - } - - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (currentGIFThread != null) - currentGIFThread.interrupt(); - if (imageFigure.getImage() != null) - imageFigure.getImage().dispose(); - for (List<Image> l : images.values()) - for (Image img : l) - img.dispose(); - } - - class GIFThread extends Thread { - - ImageFigure imgFigure; - int imageNumber; - final ImageLoader loader = new ImageLoader(); - boolean stopped = false; - List<Image> imgList; - - public GIFThread(ImageFigure imgFigure, String imgPath, - List<Image> imgList) { - this.imgFigure = imgFigure; - this.imgList = imgList; - loader.load(imgPath); - } - - @Override - public void run() { - - stopped = false; - - while (!stopped) { - - int delayTime = loader.data[imageNumber].delayTime; - - try { - Thread.sleep(delayTime * 10); - } catch (InterruptedException e) { - // e.printStackTrace(); - } - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - // Increase the variable holding the frame - // number - imageNumber = imageNumber == loader.data.length - 1 ? 0 - : imageNumber + 1; - Image image = imgList.get(imageNumber); - if (image != null && !image.isDisposed() && !stopped) { - imgFigure.setImage(image); - } - } - }); - - } - - } - - @Override - public void interrupt() { - stopped = true; - super.interrupt(); - } - - } - - public void setAlpha(int alpha) { - this.alpha = alpha; - repaint(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.ImageFigure; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.ImageLoader; +import org.eclipse.swt.widgets.Display; + +public class BMSImageFigure extends AbstractBMotionFigure { + + private ImageFigure imageFigure; + + private int alpha; + + final ImageLoader loader = new ImageLoader(); + + private Map<String, List<Image>> images = new HashMap<String, List<Image>>(); + private GIFThread currentGIFThread; + + public BMSImageFigure() { + setLayoutManager(new StackLayout()); + imageFigure = new ImageFigure(); + add(imageFigure); + } + + public void setLayout(Rectangle rect) { + getParent().setConstraint(imageFigure, rect); + } + + @Override + public void paint(Graphics g) { + g.setAlpha(alpha); + super.paint(g); + } + + public void setImage(String myPath) { + + if (currentGIFThread != null) + currentGIFThread.interrupt(); + + if (new File(myPath).exists()) { + + loader.load(myPath); + + List<Image> imgList = images.get(myPath); + if (imgList == null) { + imgList = new ArrayList<Image>(); + for (ImageData imageData : loader.data) + imgList.add(new Image(Display.getDefault(), imageData)); + images.put(myPath, imgList); + } + + if (loader.data.length > 1) { // GIF file + currentGIFThread = new GIFThread(this.imageFigure, myPath, + imgList); + currentGIFThread.start(); + } else { // Non GIF file + imageFigure.setImage(imgList.get(0)); + } + + } + + } + + @Override + public void deactivateFigure() { + if (currentGIFThread != null) + currentGIFThread.interrupt(); + if (imageFigure.getImage() != null) + imageFigure.getImage().dispose(); + for (List<Image> l : images.values()) + for (Image img : l) + img.dispose(); + } + + class GIFThread extends Thread { + + ImageFigure imgFigure; + int imageNumber; + final ImageLoader loader = new ImageLoader(); + boolean stopped = false; + List<Image> imgList; + + public GIFThread(ImageFigure imgFigure, String imgPath, + List<Image> imgList) { + this.imgFigure = imgFigure; + this.imgList = imgList; + loader.load(imgPath); + } + + @Override + public void run() { + + stopped = false; + + while (!stopped) { + + int delayTime = loader.data[imageNumber].delayTime; + + try { + Thread.sleep(delayTime * 10); + } catch (InterruptedException e) { + // e.printStackTrace(); + } + + Display.getDefault().asyncExec(new Runnable() { + public void run() { + // Increase the variable holding the frame + // number + imageNumber = imageNumber == loader.data.length - 1 ? 0 + : imageNumber + 1; + Image image = imgList.get(imageNumber); + if (image != null && !image.isDisposed() && !stopped) { + imgFigure.setImage(image); + } + } + }); + + } + + } + + @Override + public void interrupt() { + stopped = true; + super.interrupt(); + } + + } + + public void setAlpha(int alpha) { + this.alpha = alpha; + repaint(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ButtonFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ButtonFigure.java index bc93d479ed950ae32c85284325fbcf6a33af51bf..642f077bbc7f048a4e85f21661de2d196d888114 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ButtonFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ButtonFigure.java @@ -1,89 +1,84 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.ButtonBorder; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -public class ButtonFigure extends AbstractBMotionFigure { - - private Label txtLabel; - private Color backgroundColor; - private Color foregroundColor; - - public ButtonFigure() { - setLayoutManager(new StackLayout()); - txtLabel = new Label("Click"); - add(txtLabel); - setOpaque(true); - setBorder(new ButtonBorder()); - } - - public void setText(String text) { - txtLabel.setText(text); - } - - public void setBackgroundColor(RGB rgb) { - if (backgroundColor != null) - backgroundColor.dispose(); - backgroundColor = new Color(Display.getDefault(), rgb); - setBackgroundColor(backgroundColor); - } - - public void setTextColor(RGB rgb) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), rgb); - setForegroundColor(foregroundColor); - } - - public void setBtEnabled(Boolean bool) { - txtLabel.setEnabled(bool); - repaint(); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (backgroundColor != null) - backgroundColor.dispose(); - if (foregroundColor != null) - foregroundColor.dispose(); - } - - @Override - protected void paintBorder(Graphics graphics) { - super.paintBorder(graphics); - if (hasFocus()) { - graphics.setForegroundColor(ColorConstants.black); - graphics.setBackgroundColor(ColorConstants.white); - Rectangle area = getClientArea(); - graphics.drawFocus(area.x, area.y, area.width, area.height); - } - } - - @Override - protected void paintClientArea(Graphics graphics) { - graphics.translate(1, 1); - graphics.pushState(); - super.paintClientArea(graphics); - graphics.popState(); - graphics.translate(-1, -1); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.ButtonBorder; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +public class ButtonFigure extends AbstractBMotionFigure { + + private Label txtLabel; + private Color backgroundColor; + private Color foregroundColor; + + public ButtonFigure() { + setLayoutManager(new StackLayout()); + txtLabel = new Label("Click"); + add(txtLabel); + setOpaque(true); + setBorder(new ButtonBorder()); + } + + public void setText(String text) { + txtLabel.setText(text); + } + + public void setBackgroundColor(RGB rgb) { + if (backgroundColor != null) + backgroundColor.dispose(); + backgroundColor = new Color(Display.getDefault(), rgb); + setBackgroundColor(backgroundColor); + } + + public void setTextColor(RGB rgb) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), rgb); + setForegroundColor(foregroundColor); + } + + public void setBtEnabled(Boolean bool) { + txtLabel.setEnabled(bool); + repaint(); + } + + @Override + public void deactivateFigure() { + if (backgroundColor != null) + backgroundColor.dispose(); + if (foregroundColor != null) + foregroundColor.dispose(); + } + + @Override + protected void paintBorder(Graphics graphics) { + super.paintBorder(graphics); + if (hasFocus()) { + graphics.setForegroundColor(ColorConstants.black); + graphics.setBackgroundColor(ColorConstants.white); + Rectangle area = getClientArea(); + graphics.drawFocus(area.x, area.y, area.width, area.height); + } + } + + @Override + protected void paintClientArea(Graphics graphics) { + graphics.translate(1, 1); + graphics.pushState(); + super.paintClientArea(graphics); + graphics.popState(); + graphics.translate(-1, -1); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CheckboxFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CheckboxFigure.java index 6ab54c357e703e8a972c04db22475bf6fe6b5f93..7ca971561683e4509697ea1ac1518ab8ee07d33f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CheckboxFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CheckboxFigure.java @@ -1,50 +1,50 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.ImageFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; - -import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; - -public class CheckboxFigure extends AbstractBMotionFigure { - - private Label textLb; - - private ImageFigure checkBox; - - public CheckboxFigure() { - setLayoutManager(new FlowLayout(true)); - checkBox = new ImageFigure(); - add(checkBox); - textLb = new Label(); - textLb.setFont(BMotionStudioSWTConstants.fontArial10); - add(textLb); - } - - public void setImage(Image img) { - checkBox.setImage(img); - } - - public int setText(String text) { - textLb.setText(text); - return textLb.getPreferredSize().width; - } - - public void setTextColor(Color color) { - textLb.setForegroundColor(color); - } - - public void setBtEnabled(Boolean bool) { - textLb.setEnabled(bool); - repaint(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.ImageFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; + +import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; + +public class CheckboxFigure extends AbstractBMotionFigure { + + private Label textLb; + + private ImageFigure checkBox; + + public CheckboxFigure() { + setLayoutManager(new FlowLayout(true)); + checkBox = new ImageFigure(); + add(checkBox); + textLb = new Label(); + textLb.setFont(BMotionStudioSWTConstants.fontArial10); + add(textLb); + } + + public void setImage(Image img) { + checkBox.setImage(img); + } + + public int setText(String text) { + textLb.setText(text); + return textLb.getPreferredSize().width; + } + + public void setTextColor(Color color) { + textLb.setForegroundColor(color); + } + + public void setBtEnabled(Boolean bool) { + textLb.setEnabled(bool); + repaint(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CompositeFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CompositeFigure.java index 3dd9ed8e42ad1ce137364e0b2564336c5c9f2434..d9bc6d7173c3b5a481443b1be1ac69bd49ac703b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CompositeFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/CompositeFigure.java @@ -1,145 +1,140 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -public class CompositeFigure extends AbstractBMotionFigure { - - protected Image layerImage; - private ImageData imageData; - private Dimension size = new Dimension(); - private boolean hasImage; - - public CompositeFigure() { - XYLayout layout = new XYLayout(); - setLayoutManager(layout); - PaletteData palette = new PaletteData( - new RGB[] { ColorConstants.white.getRGB() }); - imageData = new ImageData(1, 1, 8, palette); - imageData.alpha = 255; - imageData.setPixel(0, 0, 0); - layerImage = new Image(Display.getDefault(), imageData); - hasImage = false; - setOpaque(true); - } - - // public void setAlpha(int alpha) { - // imageData.alpha = alpha; - // if (!hasImage) { - // if (layerImage != null && !layerImage.isDisposed()) { - // layerImage.dispose(); - // } - // layerImage = new Image(Display.getDefault(), imageData); - // repaint(); - // } - // } - - public void setBackgroundColor(RGB rgb) { - imageData.palette.colors[0] = rgb; - if (!hasImage) { - if (layerImage != null && !layerImage.isDisposed()) { - layerImage.dispose(); - } - layerImage = new Image(Display.getDefault(), imageData); - repaint(); - } - } - - public void paintFigure(Graphics g) { - if (getImage() == null) - return; - Rectangle rectangle = getClientArea(); - if (hasImage) { - int aWidth = rectangle.width; - int aHeight = rectangle.height; - int countX = aWidth / getImage().getBounds().width; - int countY = aHeight / getImage().getBounds().height; - for (int i = 0; i <= countX; i++) { - for (int z = 0; z <= countY; z++) { - g.drawImage(getImage(), getBounds().x + i - * getImage().getBounds().width, getBounds().y + z - * getImage().getBounds().height); - } - } - } else { - g.drawImage(getImage(), 0, 0, 1, 1, rectangle.x, rectangle.y, - rectangle.width, rectangle.height); - } - } - - /** - * Sets the Image that this ImageFigure displays. - * <p> - * IMPORTANT: Note that it is the client's responsibility to dispose the - * given image. - * - * @param image - * The Image to be displayed. It can be <code>null</code>. - */ - public void setImage(Image image) { - if (layerImage != null) - layerImage.dispose(); - layerImage = image; - if (layerImage != null) { - size = new Rectangle(image.getBounds()).getSize(); - hasImage = true; - } else { - layerImage = new Image(null, imageData); - size = new Dimension(); - hasImage = false; - } - revalidate(); - repaint(); - } - - /** - * @return The Image that this Figure displays - */ - public Image getImage() { - return layerImage; - } - - /** - * Calculates the necessary size to display the Image within the figure's - * client area. - * - * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int) - */ - public Dimension getPreferredSize(int wHint, int hHint) { - if (getInsets() == NO_INSETS) - return size; - Insets i = getInsets(); - return size.getExpanded(i.getWidth(), i.getHeight()); - } - - public void setLayout(Rectangle rect) { - getParent().setConstraint(this, rect); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (layerImage != null) - layerImage.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +public class CompositeFigure extends AbstractBMotionFigure { + + protected Image layerImage; + private ImageData imageData; + private Dimension size = new Dimension(); + private boolean hasImage; + + public CompositeFigure() { + XYLayout layout = new XYLayout(); + setLayoutManager(layout); + PaletteData palette = new PaletteData( + new RGB[] { ColorConstants.white.getRGB() }); + imageData = new ImageData(1, 1, 8, palette); + imageData.alpha = 255; + imageData.setPixel(0, 0, 0); + layerImage = new Image(Display.getDefault(), imageData); + hasImage = false; + setOpaque(true); + } + + // public void setAlpha(int alpha) { + // imageData.alpha = alpha; + // if (!hasImage) { + // if (layerImage != null && !layerImage.isDisposed()) { + // layerImage.dispose(); + // } + // layerImage = new Image(Display.getDefault(), imageData); + // repaint(); + // } + // } + + public void setBackgroundColor(RGB rgb) { + imageData.palette.colors[0] = rgb; + if (!hasImage) { + if (layerImage != null && !layerImage.isDisposed()) { + layerImage.dispose(); + } + layerImage = new Image(Display.getDefault(), imageData); + repaint(); + } + } + + public void paintFigure(Graphics g) { + if (getImage() == null) + return; + Rectangle rectangle = getClientArea(); + if (hasImage) { + int aWidth = rectangle.width; + int aHeight = rectangle.height; + int countX = aWidth / getImage().getBounds().width; + int countY = aHeight / getImage().getBounds().height; + for (int i = 0; i <= countX; i++) { + for (int z = 0; z <= countY; z++) { + g.drawImage(getImage(), getBounds().x + i + * getImage().getBounds().width, getBounds().y + z + * getImage().getBounds().height); + } + } + } else { + g.drawImage(getImage(), 0, 0, 1, 1, rectangle.x, rectangle.y, + rectangle.width, rectangle.height); + } + } + + /** + * Sets the Image that this ImageFigure displays. + * <p> + * IMPORTANT: Note that it is the client's responsibility to dispose the + * given image. + * + * @param image + * The Image to be displayed. It can be <code>null</code>. + */ + public void setImage(Image image) { + if (layerImage != null) + layerImage.dispose(); + layerImage = image; + if (layerImage != null) { + size = new Rectangle(image.getBounds()).getSize(); + hasImage = true; + } else { + layerImage = new Image(null, imageData); + size = new Dimension(); + hasImage = false; + } + revalidate(); + repaint(); + } + + /** + * @return The Image that this Figure displays + */ + public Image getImage() { + return layerImage; + } + + /** + * Calculates the necessary size to display the Image within the figure's + * client area. + * + * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int) + */ + public Dimension getPreferredSize(int wHint, int hHint) { + if (getInsets() == NO_INSETS) + return size; + Insets i = getInsets(); + return size.getExpanded(i.getWidth(), i.getHeight()); + } + + public void setLayout(Rectangle rect) { + getParent().setConstraint(this, rect); + } + + @Override + public void deactivateFigure() { + if (layerImage != null) + layerImage.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/FixedConnectionAnchor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/FixedConnectionAnchor.java index 7c465787ccada9036fc1e91365c7fd1625e0accd..689350bde470ea1f59ef1d0662a2a9afeb96db4a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/FixedConnectionAnchor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/FixedConnectionAnchor.java @@ -1,113 +1,103 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.AbstractConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.ScalableFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PrecisionPoint; -import org.eclipse.draw2d.geometry.Rectangle; - -public class FixedConnectionAnchor extends AbstractConnectionAnchor { - - public boolean leftToRight = true; - public int offsetH; - public int offsetV; - public boolean topDown = false; - - public FixedConnectionAnchor(IFigure owner) { - super(owner); - } - - /** - * @see org.eclipse.draw2d.AbstractConnectionAnchor#ancestorMoved(IFigure) - */ - public void ancestorMoved(IFigure figure) { - if (figure instanceof ScalableFigure) - return; - super.ancestorMoved(figure); - } - - public Point getLocation(Point reference) { - - Rectangle r = getOwner().getBounds(); - int x, y; - if (topDown) - y = r.y + offsetV; - else - y = r.bottom() - offsetV; - - if (leftToRight) - x = r.x + offsetH; - else - x = r.right() - offsetH; - - Point p = new PrecisionPoint(x, y); - getOwner().translateToAbsolute(p); - return p; - - } - - public Point getReferencePoint() { - return getLocation(null); - } - - /** - * @param offsetH - * The offsetH to set. - */ - public void setOffsetH(int offsetH) { - this.offsetH = offsetH; - fireAnchorMoved(); - } - - /** - * @param offsetV - * The offsetV to set. - */ - public void setOffsetV(int offsetV) { - this.offsetV = offsetV; - fireAnchorMoved(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (o instanceof FixedConnectionAnchor) { - FixedConnectionAnchor fa = (FixedConnectionAnchor) o; - - if (fa.leftToRight == this.leftToRight - && fa.topDown == this.topDown && fa.offsetH == this.offsetH - && fa.offsetV == this.offsetV - && fa.getOwner() == this.getOwner()) { - return true; - } - } - - return false; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return ((this.leftToRight ? 31 : 0) + (this.topDown ? 37 : 0) - + this.offsetH * 43 + this.offsetV * 47) - ^ this.getOwner().hashCode(); - } - -} +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.ScalableFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionPoint; +import org.eclipse.draw2d.geometry.Rectangle; + +public class FixedConnectionAnchor extends AbstractConnectionAnchor { + + public boolean leftToRight = true; + public int offsetH; + public int offsetV; + public boolean topDown = false; + + public FixedConnectionAnchor(IFigure owner) { + super(owner); + } + + /** + * @see org.eclipse.draw2d.AbstractConnectionAnchor#ancestorMoved(IFigure) + */ + public void ancestorMoved(IFigure figure) { + if (figure instanceof ScalableFigure) + return; + super.ancestorMoved(figure); + } + + public Point getLocation(Point reference) { + + Rectangle r = getOwner().getBounds(); + int x, y; + if (topDown) + y = r.y + offsetV; + else + y = r.bottom() - offsetV; + + if (leftToRight) + x = r.x + offsetH; + else + x = r.right() - offsetH; + + Point p = new PrecisionPoint(x, y); + getOwner().translateToAbsolute(p); + return p; + + } + + public Point getReferencePoint() { + return getLocation(null); + } + + /** + * @param offsetH + * The offsetH to set. + */ + public void setOffsetH(int offsetH) { + this.offsetH = offsetH; + fireAnchorMoved(); + } + + /** + * @param offsetV + * The offsetV to set. + */ + public void setOffsetV(int offsetV) { + this.offsetV = offsetV; + fireAnchorMoved(); + } + + public boolean equals(Object o) { + if (o instanceof FixedConnectionAnchor) { + FixedConnectionAnchor fa = (FixedConnectionAnchor) o; + + if (fa.leftToRight == this.leftToRight + && fa.topDown == this.topDown && fa.offsetH == this.offsetH + && fa.offsetV == this.offsetV + && fa.getOwner() == this.getOwner()) { + return true; + } + } + + return false; + } + + public int hashCode() { + return ((this.leftToRight ? 31 : 0) + (this.topDown ? 37 : 0) + + this.offsetH * 43 + this.offsetV * 47) + ^ this.getOwner().hashCode(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/MouseClickAdapter.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/MouseClickAdapter.java index 4a6cef59d6ea4ca65d77e78ebae5ab767210d048..00b0b84817df3ab5ebf9e5baf78abcc65a42ae5f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/MouseClickAdapter.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/MouseClickAdapter.java @@ -1,45 +1,45 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; - -public class MouseClickAdapter extends MouseAdapter { - - private BControl control; - - public MouseClickAdapter(BControl control) { - this.control = control; - } - - public void mousePressed(MouseEvent e) { - control.executeEvent(AttributeConstants.EVENT_MOUSECLICK); - } - - // TODO: change mouse cursor! - public void mouseEntered(MouseEvent e) { - if (control.getEvent(AttributeConstants.EVENT_MOUSECLICK) != null) { - if (control.getAttributeValue(AttributeConstants.ATTRIBUTE_ENABLED) != null) { - if (!Boolean.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_ENABLED).toString())) { - return; - } - } - } - } - - // TODO: change mouse cursor! - public void mouseExited(MouseEvent e) { - if (control.getEvent(AttributeConstants.EVENT_MOUSECLICK) != null) { - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; + +public class MouseClickAdapter extends MouseAdapter { + + private BControl control; + + public MouseClickAdapter(BControl control) { + this.control = control; + } + + public void mousePressed(MouseEvent e) { + control.executeEvent(AttributeConstants.EVENT_MOUSECLICK); + } + + // TODO: change mouse cursor! + public void mouseEntered(MouseEvent e) { + if (control.getEvent(AttributeConstants.EVENT_MOUSECLICK) != null) { + if (control.getAttributeValue(AttributeConstants.ATTRIBUTE_ENABLED) != null) { + if (!Boolean.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_ENABLED).toString())) { + return; + } + } + } + } + + // TODO: change mouse cursor! + public void mouseExited(MouseEvent e) { + if (control.getEvent(AttributeConstants.EVENT_MOUSECLICK) != null) { + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/RadioButtonFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/RadioButtonFigure.java index 100671a13438d7a02b882bc717f4c65824284bea..dedfe3502ed2d7a01153cf6b2b0f060d29c50f3f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/RadioButtonFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/RadioButtonFigure.java @@ -1,66 +1,61 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.ImageFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; - -public class RadioButtonFigure extends AbstractBMotionFigure { - - private Label textLb; - private ImageFigure radioBt; - private Color foregroundColor; - - public RadioButtonFigure() { - setLayoutManager(new FlowLayout(true)); - radioBt = new ImageFigure(); - add(radioBt); - textLb = new Label(); - textLb.setFont(BMotionStudioSWTConstants.fontArial10); - add(textLb); - } - - public void setImage(Image img) { - radioBt.setImage(img); - } - - public int setText(String text) { - textLb.setText(text); - return textLb.getPreferredSize().width; - } - - public void setTextColor(RGB rgb) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), rgb); - textLb.setForegroundColor(foregroundColor); - } - - public void setBtEnabled(Boolean bool) { - textLb.setEnabled(bool); - repaint(); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (foregroundColor != null) - foregroundColor.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.ImageFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; + +public class RadioButtonFigure extends AbstractBMotionFigure { + + private Label textLb; + private ImageFigure radioBt; + private Color foregroundColor; + + public RadioButtonFigure() { + setLayoutManager(new FlowLayout(true)); + radioBt = new ImageFigure(); + add(radioBt); + textLb = new Label(); + textLb.setFont(BMotionStudioSWTConstants.fontArial10); + add(textLb); + } + + public void setImage(Image img) { + radioBt.setImage(img); + } + + public int setText(String text) { + textLb.setText(text); + return textLb.getPreferredSize().width; + } + + public void setTextColor(RGB rgb) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), rgb); + textLb.setForegroundColor(foregroundColor); + } + + public void setBtEnabled(Boolean bool) { + textLb.setEnabled(bool); + repaint(); + } + + @Override + public void deactivateFigure() { + if (foregroundColor != null) + foregroundColor.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java index 9ddf860ff85bf9c074c77be4a97e385f98f6834b..1aa8198629b8e57b1253c06a3e4490a8cd0b3855 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java @@ -1,440 +1,435 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Orientable; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.Shape; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.graphics.Pattern; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; - -public class ShapeFigure extends AbstractBMotionFigure { - - private int alpha; - private int outlineAlpha; - private int shape; - private Integer fillType; - private Image img; - private Color foregroundColor; - private Color backgroundColor; - - private Image patternImage; - private Image shadedImage; - private Pattern pattern; - private Pattern shadedPattern; - private Pattern gradientPattern; - - private final Color white = Display.getDefault().getSystemColor( - SWT.COLOR_WHITE); - - private static final int FILL_TYPE_FILLED = 0; - private static final int FILL_TYPE_EMPTY = 1; - private static final int FILL_TYPE_SHADED = 2; - private static final int FILL_TYPE_GRADIENT = 3; - - private static final int SHAPE_TYPE_RECTANGLE = 0; - private static final int SHAPE_TYPE_OVAL = 1; - private static final int SHAPE_TYPE_TRIANGLE = 2; - private static final int SHAPE_TYPE_DIAMOND = 3; - - /** - * The direction this triangle will face. Possible values are - * {@link PositionConstants#NORTH}, {@link PositionConstants#SOUTH}, - * {@link PositionConstants#EAST} and {@link PositionConstants#WEST}. - */ - protected int direction = PositionConstants.NORTH; - /** - * The orientation of this triangle. Possible values are - * {@link Orientable#VERTICAL} and {@link Orientable#HORIZONTAL}. - */ - protected int orientation = PositionConstants.VERTICAL; - - /** The points of the triangle. */ - protected PointList triangle = new PointList(3); - - /** The points of the diamond. */ - protected PointList diamond = new PointList(4); - - private Shape shapeFigure; - - public ShapeFigure() { - setLayoutManager(new StackLayout()); - shapeFigure = new Shape() { - - @Override - protected void fillShape(Graphics g) { - - if (!visible && !isRunning) - g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); - else - g.setAlpha(alpha); - g.setAntialias(SWT.ON); - - if (fillType == FILL_TYPE_GRADIENT) { // Gradient fill type - - if (gradientPattern != null) - gradientPattern.dispose(); - gradientPattern = new Pattern(Display.getDefault(), - this.getBounds().x, this.getBounds().y, - this.getBounds().x + this.getBounds().width, - this.getBounds().y + this.getBounds().height, - this.getBackgroundColor(), - this.getForegroundColor()); - g.setBackgroundPattern(gradientPattern); - - } else if (fillType == FILL_TYPE_SHADED) { // Shaded fill type - - Color black = this.getForegroundColor(); - PaletteData palette = new PaletteData(new RGB[] { - white.getRGB(), black.getRGB() }); - ImageData sourceData = new ImageData(11, 11, 1, palette); - for (int i = 0; i < 11; i++) { - sourceData.setPixel(6, i, 1); - } - if (shadedImage != null) - shadedImage.dispose(); - shadedImage = new Image(Display.getDefault(), sourceData); - - if (shadedPattern != null) - shadedPattern.dispose(); - shadedPattern = new Pattern(Display.getDefault(), - shadedImage); - g.setBackgroundPattern(shadedPattern); - - } else if (fillType == FILL_TYPE_FILLED && img != null) { - - double zoom = 1; - if (BMotionEditorPlugin.getActiveEditor() != null) - zoom = BMotionEditorPlugin.getActiveEditor() - .getZoomFactor(); - - ImageData d = img.getImageData().scaledTo( - (int) (img.getBounds().width * zoom), - (int) (img.getBounds().height * zoom)); - - if (patternImage != null) - patternImage.dispose(); - - patternImage = new Image(Display.getDefault(), d); - - if (pattern != null) - pattern.dispose(); - - pattern = new Pattern(Display.getDefault(), patternImage); - - g.setBackgroundPattern(pattern); - - } else if (fillType == FILL_TYPE_FILLED) { - g.setBackgroundColor(this.getBackgroundColor()); - } - - switch (shape) { - case SHAPE_TYPE_RECTANGLE: - g.fillRectangle(this.getBounds()); - break; - case SHAPE_TYPE_OVAL: - g.fillOval(this.getBounds().x, this.getBounds().y, - this.getBounds().width - 3, - this.getBounds().height - 3); - break; - case SHAPE_TYPE_TRIANGLE: - g.fillPolygon(triangle); - break; - case SHAPE_TYPE_DIAMOND: - g.fillPolygon(diamond); - break; - default: - break; - } - - } - - @Override - protected void outlineShape(Graphics g) { - - if (!visible && !isRunning) - g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); - else - g.setAlpha(outlineAlpha); - g.setAntialias(SWT.ON); - g.setForegroundColor(this.getForegroundColor()); - - float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; - - int inset1 = (int) Math.floor(lineInset); - int inset2 = (int) Math.ceil(lineInset); - - Rectangle r = Rectangle.SINGLETON.setBounds(this.getBounds()); - r.x += inset1; - r.y += inset1; - r.width -= inset1 + inset2; - r.height -= inset1 + inset2; - - switch (shape) { - case SHAPE_TYPE_RECTANGLE: - g.drawRectangle(r); - break; - case SHAPE_TYPE_OVAL: - r.width -= 2; - r.height -= 2; - g.drawOval(r); - break; - case SHAPE_TYPE_TRIANGLE: - g.drawPolygon(triangle); - break; - case SHAPE_TYPE_DIAMOND: - g.drawPolygon(diamond); - break; - default: - break; - } - - } - - }; - // shapeFigure.setForegroundColor(ColorConstants.blue); - // setOpaque(true); - add(shapeFigure); - } - - /** - * @see Orientable#setDirection(int) - */ - public void setDirection(int value) { - if ((value & (PositionConstants.NORTH | PositionConstants.SOUTH)) != 0) - orientation = PositionConstants.VERTICAL; - else - orientation = PositionConstants.HORIZONTAL; - direction = value; - revalidate(); - repaint(); - } - - /** - * @see Orientable#setOrientation(int) - */ - public void setOrientation(int value) { - if (orientation == PositionConstants.VERTICAL - && value == PositionConstants.HORIZONTAL) { - if (direction == PositionConstants.NORTH) - setDirection(PositionConstants.WEST); - else - setDirection(PositionConstants.EAST); - } - if (orientation == PositionConstants.HORIZONTAL - && value == PositionConstants.VERTICAL) { - if (direction == PositionConstants.WEST) - setDirection(PositionConstants.NORTH); - else - setDirection(PositionConstants.SOUTH); - } - } - - /** - * @see IFigure#validate() - */ - public void validate() { - - super.validate(); - - Rectangle r = new Rectangle(); - r.setBounds(getBounds()); - r.crop(getInsets()); - r.resize(-1, -1); - - switch (shape) { - - case SHAPE_TYPE_TRIANGLE: - - int size; - switch (direction - & (PositionConstants.NORTH | PositionConstants.SOUTH)) { - case 0: // East or west. - size = Math.min(r.height / 2, r.width); - r.x += (r.width - size) / 2; - break; - default: // North or south - size = Math.min(r.height, r.width / 2); - r.y += (r.height - size) / 2; - break; - } - - size = Math.max(size, 1); // Size cannot be negative - - Point head, - p2, - p3; - - switch (direction) { - case PositionConstants.NORTH: - head = new Point(r.x + r.width / 2, r.y); - p2 = new Point(head.x - size, head.y + size); - p3 = new Point(head.x + size, head.y + size); - break; - case PositionConstants.SOUTH: - head = new Point(r.x + r.width / 2, r.y + size); - p2 = new Point(head.x - size, head.y - size); - p3 = new Point(head.x + size, head.y - size); - break; - case PositionConstants.WEST: - head = new Point(r.x, r.y + r.height / 2); - p2 = new Point(head.x + size, head.y - size); - p3 = new Point(head.x + size, head.y + size); - break; - default: - head = new Point(r.x + size, r.y + r.height / 2); - p2 = new Point(head.x - size, head.y - size); - p3 = new Point(head.x - size, head.y + size); - - } - triangle.removeAllPoints(); - triangle.addPoint(head); - triangle.addPoint(p2); - triangle.addPoint(p3); - - break; - - case SHAPE_TYPE_DIAMOND: - - Point pt1 = new Point(r.x + r.width / 2, r.y); - Point pt2 = new Point(r.x + r.width, r.y + r.height / 2); - Point pt3 = new Point(r.x + r.width / 2, r.y + r.height); - Point pt4 = new Point(r.x, r.y + r.height / 2); - - diamond.removeAllPoints(); - diamond.addPoint(pt1); - diamond.addPoint(pt2); - diamond.addPoint(pt3); - diamond.addPoint(pt4); - - break; - - default: - break; - } - - } - - /** - * @see Figure#primTranslate(int, int) - */ - public void primTranslate(int dx, int dy) { - super.primTranslate(dx, dy); - switch (shape) { - case SHAPE_TYPE_TRIANGLE: - triangle.translate(dx, dy); - break; - case SHAPE_TYPE_DIAMOND: - diamond.translate(dx, dy); - break; - default: - break; - } - } - - public void setBackgroundColor(RGB rgb) { - if (backgroundColor != null) - backgroundColor.dispose(); - backgroundColor = new Color(Display.getDefault(), rgb); - shapeFigure.setBackgroundColor(backgroundColor); - } - - public void setForegroundColor(RGB rgb) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), rgb); - shapeFigure.setForegroundColor(foregroundColor); - shapeFigure.repaint(); - } - - public void setLayout(Rectangle rect) { - getParent().setConstraint(this, rect); - } - - public void setShape(int shape) { - this.shape = shape; - revalidate(); - shapeFigure.repaint(); - } - - public int getShape() { - return shape; - } - - public Integer getAlpha() { - return alpha; - } - - public void setAlpha(Integer alpha) { - this.alpha = alpha; - repaint(); - } - - public Integer getOutlineAlpha() { - return outlineAlpha; - } - - public void setOutlineAlpha(Integer outlineAlpha) { - this.outlineAlpha = outlineAlpha; - repaint(); - } - - public void setFillType(Integer fillType) { - if (fillType == FILL_TYPE_EMPTY) - shapeFigure.setFill(false); - else - shapeFigure.setFill(true); - this.fillType = fillType; - repaint(); - } - - public void setImage(Image img) { - this.img = img; - repaint(); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (img != null) - img.dispose(); - if (foregroundColor != null) - foregroundColor.dispose(); - if (backgroundColor != null) - backgroundColor.dispose(); - if (patternImage != null) - patternImage.dispose(); - if (shadedImage != null) - shadedImage.dispose(); - if (pattern != null) - pattern.dispose(); - if (shadedPattern != null) - shadedPattern.dispose(); - if (gradientPattern != null) - gradientPattern.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Orientable; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.Shape; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.Pattern; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; + +public class ShapeFigure extends AbstractBMotionFigure { + + private int alpha; + private int outlineAlpha; + private int shape; + private Integer fillType; + private Image img; + private Color foregroundColor; + private Color backgroundColor; + + private Image patternImage; + private Image shadedImage; + private Pattern pattern; + private Pattern shadedPattern; + private Pattern gradientPattern; + + private final Color white = Display.getDefault().getSystemColor( + SWT.COLOR_WHITE); + + private static final int FILL_TYPE_FILLED = 0; + private static final int FILL_TYPE_EMPTY = 1; + private static final int FILL_TYPE_SHADED = 2; + private static final int FILL_TYPE_GRADIENT = 3; + + private static final int SHAPE_TYPE_RECTANGLE = 0; + private static final int SHAPE_TYPE_OVAL = 1; + private static final int SHAPE_TYPE_TRIANGLE = 2; + private static final int SHAPE_TYPE_DIAMOND = 3; + + /** + * The direction this triangle will face. Possible values are + * {@link PositionConstants#NORTH}, {@link PositionConstants#SOUTH}, + * {@link PositionConstants#EAST} and {@link PositionConstants#WEST}. + */ + protected int direction = PositionConstants.NORTH; + /** + * The orientation of this triangle. Possible values are + * {@link Orientable#VERTICAL} and {@link Orientable#HORIZONTAL}. + */ + protected int orientation = PositionConstants.VERTICAL; + + /** The points of the triangle. */ + protected PointList triangle = new PointList(3); + + /** The points of the diamond. */ + protected PointList diamond = new PointList(4); + + private Shape shapeFigure; + + public ShapeFigure() { + setLayoutManager(new StackLayout()); + shapeFigure = new Shape() { + + @Override + protected void fillShape(Graphics g) { + + if (!visible && !isRunning) + g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); + else + g.setAlpha(alpha); + g.setAntialias(SWT.ON); + + if (fillType == FILL_TYPE_GRADIENT) { // Gradient fill type + + if (gradientPattern != null) + gradientPattern.dispose(); + gradientPattern = new Pattern(Display.getDefault(), + this.getBounds().x, this.getBounds().y, + this.getBounds().x + this.getBounds().width, + this.getBounds().y + this.getBounds().height, + this.getBackgroundColor(), + this.getForegroundColor()); + g.setBackgroundPattern(gradientPattern); + + } else if (fillType == FILL_TYPE_SHADED) { // Shaded fill type + + Color black = this.getForegroundColor(); + PaletteData palette = new PaletteData(new RGB[] { + white.getRGB(), black.getRGB() }); + ImageData sourceData = new ImageData(11, 11, 1, palette); + for (int i = 0; i < 11; i++) { + sourceData.setPixel(6, i, 1); + } + if (shadedImage != null) + shadedImage.dispose(); + shadedImage = new Image(Display.getDefault(), sourceData); + + if (shadedPattern != null) + shadedPattern.dispose(); + shadedPattern = new Pattern(Display.getDefault(), + shadedImage); + g.setBackgroundPattern(shadedPattern); + + } else if (fillType == FILL_TYPE_FILLED && img != null) { + + double zoom = 1; + if (BMotionEditorPlugin.getActiveEditor() != null) + zoom = BMotionEditorPlugin.getActiveEditor() + .getZoomFactor(); + + ImageData d = img.getImageData().scaledTo( + (int) (img.getBounds().width * zoom), + (int) (img.getBounds().height * zoom)); + + if (patternImage != null) + patternImage.dispose(); + + patternImage = new Image(Display.getDefault(), d); + + if (pattern != null) + pattern.dispose(); + + pattern = new Pattern(Display.getDefault(), patternImage); + + g.setBackgroundPattern(pattern); + + } else if (fillType == FILL_TYPE_FILLED) { + g.setBackgroundColor(this.getBackgroundColor()); + } + + switch (shape) { + case SHAPE_TYPE_RECTANGLE: + g.fillRectangle(this.getBounds()); + break; + case SHAPE_TYPE_OVAL: + g.fillOval(this.getBounds().x, this.getBounds().y, + this.getBounds().width - 3, + this.getBounds().height - 3); + break; + case SHAPE_TYPE_TRIANGLE: + g.fillPolygon(triangle); + break; + case SHAPE_TYPE_DIAMOND: + g.fillPolygon(diamond); + break; + default: + break; + } + + } + + @Override + protected void outlineShape(Graphics g) { + + if (!visible && !isRunning) + g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); + else + g.setAlpha(outlineAlpha); + g.setAntialias(SWT.ON); + g.setForegroundColor(this.getForegroundColor()); + + float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; + + int inset1 = (int) Math.floor(lineInset); + int inset2 = (int) Math.ceil(lineInset); + + Rectangle r = Rectangle.SINGLETON.setBounds(this.getBounds()); + r.x += inset1; + r.y += inset1; + r.width -= inset1 + inset2; + r.height -= inset1 + inset2; + + switch (shape) { + case SHAPE_TYPE_RECTANGLE: + g.drawRectangle(r); + break; + case SHAPE_TYPE_OVAL: + r.width -= 2; + r.height -= 2; + g.drawOval(r); + break; + case SHAPE_TYPE_TRIANGLE: + g.drawPolygon(triangle); + break; + case SHAPE_TYPE_DIAMOND: + g.drawPolygon(diamond); + break; + default: + break; + } + + } + + }; + // shapeFigure.setForegroundColor(ColorConstants.blue); + // setOpaque(true); + add(shapeFigure); + } + + /** + * @see Orientable#setDirection(int) + */ + public void setDirection(int value) { + if ((value & (PositionConstants.NORTH | PositionConstants.SOUTH)) != 0) + orientation = PositionConstants.VERTICAL; + else + orientation = PositionConstants.HORIZONTAL; + direction = value; + revalidate(); + repaint(); + } + + /** + * @see Orientable#setOrientation(int) + */ + public void setOrientation(int value) { + if (orientation == PositionConstants.VERTICAL + && value == PositionConstants.HORIZONTAL) { + if (direction == PositionConstants.NORTH) + setDirection(PositionConstants.WEST); + else + setDirection(PositionConstants.EAST); + } + if (orientation == PositionConstants.HORIZONTAL + && value == PositionConstants.VERTICAL) { + if (direction == PositionConstants.WEST) + setDirection(PositionConstants.NORTH); + else + setDirection(PositionConstants.SOUTH); + } + } + + /** + * @see IFigure#validate() + */ + public void validate() { + + super.validate(); + + Rectangle r = new Rectangle(); + r.setBounds(getBounds()); + r.crop(getInsets()); + r.resize(-1, -1); + + switch (shape) { + + case SHAPE_TYPE_TRIANGLE: + + int size; + switch (direction + & (PositionConstants.NORTH | PositionConstants.SOUTH)) { + case 0: // East or west. + size = Math.min(r.height / 2, r.width); + r.x += (r.width - size) / 2; + break; + default: // North or south + size = Math.min(r.height, r.width / 2); + r.y += (r.height - size) / 2; + break; + } + + size = Math.max(size, 1); // Size cannot be negative + + Point head, + p2, + p3; + + switch (direction) { + case PositionConstants.NORTH: + head = new Point(r.x + r.width / 2, r.y); + p2 = new Point(head.x - size, head.y + size); + p3 = new Point(head.x + size, head.y + size); + break; + case PositionConstants.SOUTH: + head = new Point(r.x + r.width / 2, r.y + size); + p2 = new Point(head.x - size, head.y - size); + p3 = new Point(head.x + size, head.y - size); + break; + case PositionConstants.WEST: + head = new Point(r.x, r.y + r.height / 2); + p2 = new Point(head.x + size, head.y - size); + p3 = new Point(head.x + size, head.y + size); + break; + default: + head = new Point(r.x + size, r.y + r.height / 2); + p2 = new Point(head.x - size, head.y - size); + p3 = new Point(head.x - size, head.y + size); + + } + triangle.removeAllPoints(); + triangle.addPoint(head); + triangle.addPoint(p2); + triangle.addPoint(p3); + + break; + + case SHAPE_TYPE_DIAMOND: + + Point pt1 = new Point(r.x + r.width / 2, r.y); + Point pt2 = new Point(r.x + r.width, r.y + r.height / 2); + Point pt3 = new Point(r.x + r.width / 2, r.y + r.height); + Point pt4 = new Point(r.x, r.y + r.height / 2); + + diamond.removeAllPoints(); + diamond.addPoint(pt1); + diamond.addPoint(pt2); + diamond.addPoint(pt3); + diamond.addPoint(pt4); + + break; + + default: + break; + } + + } + + /** + * @see Figure#primTranslate(int, int) + */ + public void primTranslate(int dx, int dy) { + super.primTranslate(dx, dy); + switch (shape) { + case SHAPE_TYPE_TRIANGLE: + triangle.translate(dx, dy); + break; + case SHAPE_TYPE_DIAMOND: + diamond.translate(dx, dy); + break; + default: + break; + } + } + + public void setBackgroundColor(RGB rgb) { + if (backgroundColor != null) + backgroundColor.dispose(); + backgroundColor = new Color(Display.getDefault(), rgb); + shapeFigure.setBackgroundColor(backgroundColor); + } + + public void setForegroundColor(RGB rgb) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), rgb); + shapeFigure.setForegroundColor(foregroundColor); + shapeFigure.repaint(); + } + + public void setLayout(Rectangle rect) { + getParent().setConstraint(this, rect); + } + + public void setShape(int shape) { + this.shape = shape; + revalidate(); + shapeFigure.repaint(); + } + + public int getShape() { + return shape; + } + + public Integer getAlpha() { + return alpha; + } + + public void setAlpha(Integer alpha) { + this.alpha = alpha; + repaint(); + } + + public Integer getOutlineAlpha() { + return outlineAlpha; + } + + public void setOutlineAlpha(Integer outlineAlpha) { + this.outlineAlpha = outlineAlpha; + repaint(); + } + + public void setFillType(Integer fillType) { + if (fillType == FILL_TYPE_EMPTY) + shapeFigure.setFill(false); + else + shapeFigure.setFill(true); + this.fillType = fillType; + repaint(); + } + + public void setImage(Image img) { + this.img = img; + repaint(); + } + + @Override + public void deactivateFigure() { + if (img != null) + img.dispose(); + if (foregroundColor != null) + foregroundColor.dispose(); + if (backgroundColor != null) + backgroundColor.dispose(); + if (patternImage != null) + patternImage.dispose(); + if (shadedImage != null) + shadedImage.dispose(); + if (pattern != null) + pattern.dispose(); + if (shadedPattern != null) + shadedPattern.dispose(); + if (gradientPattern != null) + gradientPattern.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SignalFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SignalFigure.java index 052554a54b80675119080156d503d09a3fbb9d86..6017a2547529af7e5251d6e3370a2e3ea1514bdd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SignalFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SignalFigure.java @@ -1,130 +1,120 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; - - -/** - * @author Lukas Ladenberger - * - */ -public class SignalFigure extends AbstractBMotionFigure { - - private Label lb; - private PointList arrow = new PointList(); - private boolean isEast; - private Figure panel; - - public SignalFigure() { - - ToolbarLayout layout = new ToolbarLayout(); - layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER); - setLayoutManager(layout); - - setOpaque(true); - - lb = new Label(); - - panel = new Figure() { - @Override - protected void paintFigure(Graphics g) { - - super.paintFigure(g); - Rectangle r = getClientArea(); - arrow.removeAllPoints(); - - g.setAlpha(0); - g.setBackgroundColor(ColorConstants.white); - g.setForegroundColor(ColorConstants.lightGray); - g.fillRectangle(r); // Fill background with color - - // Draw track lines - g.setAlpha(255); - g.setLineWidth(1); - - // Draw horizontal line - Point pt1 = r.getTopLeft(); - Point pt2 = r.getTopRight(); - pt1.y = pt1.y + 4; - pt2.y = pt2.y + 4; - g.drawLine(pt1, pt2); - - g.setAlpha(255); - g.setBackgroundColor(ColorConstants.lightGray); - - // Draw arrow - Point p1; - Point p2; - Point p3; - - if (isEast) { - p1 = r.getTopRight(); - p2 = r.getTopRight(); - p3 = r.getTopRight(); - p2.x = p2.x - 8; - p3.x = p3.x - 8; - } else { - p1 = r.getTopLeft(); - p2 = r.getTopLeft(); - p3 = r.getTopLeft(); - p2.x = p2.x + 8; - p3.x = p3.x + 8; - } - - p1.y = p1.y + 4; - p2.y = p2.y + 8; - - arrow.addPoint(p1); - arrow.addPoint(p2); - arrow.addPoint(p3); - g.fillPolygon(arrow); - - } - - }; - panel.setPreferredSize(60, 10); - - // add(node); - add(lb); - add(panel); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#activateFigure() - */ - @Override - public void activateFigure() { - } - - public void setTrackDirection(boolean isEast) { - this.isEast = isEast; - this.panel.repaint(); - } - - public void setLabel(String lb) { - this.lb.setText(lb); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.ToolbarLayout; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; + + +/** + * @author Lukas Ladenberger + * + */ +public class SignalFigure extends AbstractBMotionFigure { + + private Label lb; + private PointList arrow = new PointList(); + private boolean isEast; + private Figure panel; + + public SignalFigure() { + + ToolbarLayout layout = new ToolbarLayout(); + layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER); + setLayoutManager(layout); + + setOpaque(true); + + lb = new Label(); + + panel = new Figure() { + @Override + protected void paintFigure(Graphics g) { + + super.paintFigure(g); + Rectangle r = getClientArea(); + arrow.removeAllPoints(); + + g.setAlpha(0); + g.setBackgroundColor(ColorConstants.white); + g.setForegroundColor(ColorConstants.lightGray); + g.fillRectangle(r); // Fill background with color + + // Draw track lines + g.setAlpha(255); + g.setLineWidth(1); + + // Draw horizontal line + Point pt1 = r.getTopLeft(); + Point pt2 = r.getTopRight(); + pt1.y = pt1.y + 4; + pt2.y = pt2.y + 4; + g.drawLine(pt1, pt2); + + g.setAlpha(255); + g.setBackgroundColor(ColorConstants.lightGray); + + // Draw arrow + Point p1; + Point p2; + Point p3; + + if (isEast) { + p1 = r.getTopRight(); + p2 = r.getTopRight(); + p3 = r.getTopRight(); + p2.x = p2.x - 8; + p3.x = p3.x - 8; + } else { + p1 = r.getTopLeft(); + p2 = r.getTopLeft(); + p3 = r.getTopLeft(); + p2.x = p2.x + 8; + p3.x = p3.x + 8; + } + + p1.y = p1.y + 4; + p2.y = p2.y + 8; + + arrow.addPoint(p1); + arrow.addPoint(p2); + arrow.addPoint(p3); + g.fillPolygon(arrow); + + } + + }; + panel.setPreferredSize(60, 10); + + // add(node); + add(lb); + add(panel); + } + + @Override + public void deactivateFigure() { + } + + @Override + public void activateFigure() { + } + + public void setTrackDirection(boolean isEast) { + this.isEast = isEast; + this.panel.repaint(); + } + + public void setLabel(String lb) { + this.lb.setText(lb); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SwitchFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SwitchFigure.java index 3e2436ac384a2b478d3fe8945bb33182aa223eda..fe008f4a38d8651fa16ce9d5e29f94c14cc63c61 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SwitchFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/SwitchFigure.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -public class SwitchFigure extends AbstractBMotionFigure { - - Color borderColor = new Color(Display.getDefault(), new RGB(235, 235, 235)); - - public SwitchFigure() { - setLayoutManager(new XYLayout()); - setOpaque(false); - } - - @Override - protected void paintBorder(Graphics g) { - Rectangle r = getClientArea(); - if (!this.visible && !isRunning()) - g.setAlpha(255); - g.setForegroundColor(borderColor); - g.setLineStyle(SWT.LINE_DASH); - r.height += -1; - r.width += -1; - g.drawRectangle(r); - super.paintBorder(g); - } - - @Override - public void deactivateFigure() { - borderColor.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +public class SwitchFigure extends AbstractBMotionFigure { + + Color borderColor = new Color(Display.getDefault(), new RGB(235, 235, 235)); + + public SwitchFigure() { + setLayoutManager(new XYLayout()); + setOpaque(false); + } + + @Override + protected void paintBorder(Graphics g) { + Rectangle r = getClientArea(); + if (!this.visible && !isRunning()) + g.setAlpha(255); + g.setForegroundColor(borderColor); + g.setLineStyle(SWT.LINE_DASH); + r.height += -1; + r.width += -1; + g.drawRectangle(r); + super.paintBorder(g); + } + + @Override + public void deactivateFigure() { + borderColor.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java index 4f266aef27d7c9cdf5304cd6ca843060118c73de..4e349ba728670e0c80cbfd83a4f4731e59e10ab5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java @@ -1,164 +1,164 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - - -public class TankFigure extends AbstractBMotionFigure { - - private Image layerImage; - private ImageData imageData; - - private int fill_height; - private double positions; - private int show_pos; - - private Color fillColor; - - private Boolean showMeasure; - - public TankFigure() { - PaletteData palette = new PaletteData( - new RGB[] { ColorConstants.white.getRGB() }); - imageData = new ImageData(1, 1, 8, palette); - imageData.alpha = 255; - imageData.setPixel(0, 0, 0); - layerImage = new Image(null, imageData); - } - - public void setAlpha(int alpha) { - imageData.alpha = alpha; - if (layerImage != null && !layerImage.isDisposed()) { - layerImage.dispose(); - } - layerImage = new Image(null, imageData); - repaint(); - } - - @Override - protected void paintFigure(Graphics g) { - - Rectangle rect = getClientArea(); - g.drawImage(layerImage, new Rectangle(layerImage.getBounds()), rect); - - // Set the right size and position of the y-axis - - int fillPos = 0; - - double one_pos = Double.valueOf(rect.height) / positions; - - if (showMeasure) { - - g.setForegroundColor(ColorConstants.black); - g.drawLine(rect.x + 5, rect.y, rect.x + 5, rect.y + rect.height); - - for (int i = 0; i <= positions; i = i + show_pos) { - - if (i == 0) { - // First position - // Draw label - g.drawText(String.valueOf((int) (positions - i)), - rect.x + 18, rect.y + (int) (i * one_pos) - 3); - - // Draw line - g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos), - rect.x, rect.y + (int) (i * one_pos)); - } else if (i == positions) { - // Last position - - // Draw label - g.drawText(String.valueOf((int) (positions - i)), - rect.x + 18, rect.y + (int) (i * one_pos) - 12); - - // Draw line - g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos) - 1, - rect.x, rect.y + (int) (i * one_pos) - 1); - } else { - // All other positions - - // Draw label - g.drawText(String.valueOf((int) (positions - i)), - rect.x + 18, rect.y + (int) (i * one_pos) - 5); - - // // Draw line - g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos), - rect.x, rect.y + (int) (i * one_pos)); - } - - } - - fillPos = 60; - - } - - // Set right size of the fill figure - g.setBackgroundColor(fillColor); - - double tmp = one_pos * (positions - Double.valueOf(fill_height)); - int f_fill_height = (int) tmp; - - g.fillRectangle(rect.x + fillPos, rect.y + f_fill_height, rect.width - - fillPos, rect.height); - - super.paintFigure(g); - - } - - public void setFillColor(RGB rgb) { - if (fillColor != null) - fillColor.dispose(); - fillColor = new Color(Display.getDefault(), rgb); - repaint(); - } - - public void setFillHeight(Integer height) { - this.fill_height = height; - repaint(); - } - - public void setMaxPos(Integer maxPos) { - this.positions = maxPos; - repaint(); - } - - public void setInterval(Integer interval) { - this.show_pos = interval; - repaint(); - } - - public void setMeasure(Boolean bol) { - this.showMeasure = bol; - repaint(); - } - - public void setBackgroundColor(RGB rgb) { - imageData.palette.colors[0] = rgb; - if (layerImage != null && !layerImage.isDisposed()) { - layerImage.dispose(); - } - layerImage = new Image(null, imageData); - repaint(); - } - - @Override - public void deactivateFigure() { - if (fillColor != null) - fillColor.dispose(); - if (layerImage != null) - layerImage.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + + +public class TankFigure extends AbstractBMotionFigure { + + private Image layerImage; + private ImageData imageData; + + private int fill_height; + private double positions; + private int show_pos; + + private Color fillColor; + + private Boolean showMeasure; + + public TankFigure() { + PaletteData palette = new PaletteData( + new RGB[] { ColorConstants.white.getRGB() }); + imageData = new ImageData(1, 1, 8, palette); + imageData.alpha = 255; + imageData.setPixel(0, 0, 0); + layerImage = new Image(null, imageData); + } + + public void setAlpha(int alpha) { + imageData.alpha = alpha; + if (layerImage != null && !layerImage.isDisposed()) { + layerImage.dispose(); + } + layerImage = new Image(null, imageData); + repaint(); + } + + @Override + protected void paintFigure(Graphics g) { + + Rectangle rect = getClientArea(); + g.drawImage(layerImage, new Rectangle(layerImage.getBounds()), rect); + + // Set the right size and position of the y-axis + + int fillPos = 0; + + double one_pos = Double.valueOf(rect.height) / positions; + + if (showMeasure) { + + g.setForegroundColor(ColorConstants.black); + g.drawLine(rect.x + 5, rect.y, rect.x + 5, rect.y + rect.height); + + for (int i = 0; i <= positions; i = i + show_pos) { + + if (i == 0) { + // First position + // Draw label + g.drawText(String.valueOf((int) (positions - i)), + rect.x + 18, rect.y + (int) (i * one_pos) - 3); + + // Draw line + g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos), + rect.x, rect.y + (int) (i * one_pos)); + } else if (i == positions) { + // Last position + + // Draw label + g.drawText(String.valueOf((int) (positions - i)), + rect.x + 18, rect.y + (int) (i * one_pos) - 12); + + // Draw line + g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos) - 1, + rect.x, rect.y + (int) (i * one_pos) - 1); + } else { + // All other positions + + // Draw label + g.drawText(String.valueOf((int) (positions - i)), + rect.x + 18, rect.y + (int) (i * one_pos) - 5); + + // // Draw line + g.drawLine(rect.x + 10, rect.y + (int) (i * one_pos), + rect.x, rect.y + (int) (i * one_pos)); + } + + } + + fillPos = 60; + + } + + // Set right size of the fill figure + g.setBackgroundColor(fillColor); + + double tmp = one_pos * (positions - Double.valueOf(fill_height)); + int f_fill_height = (int) tmp; + + g.fillRectangle(rect.x + fillPos, rect.y + f_fill_height, rect.width + - fillPos, rect.height); + + super.paintFigure(g); + + } + + public void setFillColor(RGB rgb) { + if (fillColor != null) + fillColor.dispose(); + fillColor = new Color(Display.getDefault(), rgb); + repaint(); + } + + public void setFillHeight(Integer height) { + this.fill_height = height; + repaint(); + } + + public void setMaxPos(Integer maxPos) { + this.positions = maxPos; + repaint(); + } + + public void setInterval(Integer interval) { + this.show_pos = interval; + repaint(); + } + + public void setMeasure(Boolean bol) { + this.showMeasure = bol; + repaint(); + } + + public void setBackgroundColor(RGB rgb) { + imageData.palette.colors[0] = rgb; + if (layerImage != null && !layerImage.isDisposed()) { + layerImage.dispose(); + } + layerImage = new Image(null, imageData); + repaint(); + } + + @Override + public void deactivateFigure() { + if (fillColor != null) + fillColor.dispose(); + if (layerImage != null) + layerImage.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextFigure.java index 4cbbc7d8a22a7e4e5aa80a94a95f99f82d3cef34..ce3567bda28b76d2d811cf9f5f4f69c247b54a2d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextFigure.java @@ -1,101 +1,96 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.text.FlowPage; -import org.eclipse.draw2d.text.ParagraphTextLayout; -import org.eclipse.draw2d.text.TextFlow; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -public class TextFigure extends AbstractBMotionFigure { - - private TextFlow textFlow; - protected Image layerImage; - private Color foregroundColor; - private Font font; - - public TextFigure() { - setBorder(new MarginBorder(1)); - FlowPage flowPage = new FlowPage(); - textFlow = new TextFlow(); - textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, - ParagraphTextLayout.WORD_WRAP_SOFT)); - flowPage.add(textFlow); - setLayoutManager(new StackLayout()); - add(flowPage); - } - - /** - * Returns the text inside the TextFlow. - * - * @return the text flow inside the text. - */ - public String getText() { - return textFlow.getText(); - } - - /** - * Sets the text of the TextFlow to the given value. - * - * @param newText - * the new text value. - */ - public void setText(String newText) { - textFlow.setText(newText); - } - - public void setTextColor(RGB rgb) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), rgb); - textFlow.setForegroundColor(foregroundColor); - } - - public void setBackgroundVisible(Boolean bol) { - setOpaque(bol); - } - - public void setFont(String fontData) { - if (font != null) - font.dispose(); - font = new Font(Display.getDefault(), new FontData(fontData)); - textFlow.setFont(font); - } - - // TODO: CHECK STACK OVERFLOW ERROR!!!! - public Font getFont() { - return textFlow.getFont(); - } - - public void setLayout(Rectangle rect) { - getParent().setConstraint(this, rect); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (foregroundColor != null) - foregroundColor.dispose(); - if (font != null) - font.dispose(); - if (layerImage != null) - layerImage.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.MarginBorder; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.draw2d.text.FlowPage; +import org.eclipse.draw2d.text.ParagraphTextLayout; +import org.eclipse.draw2d.text.TextFlow; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +public class TextFigure extends AbstractBMotionFigure { + + private TextFlow textFlow; + protected Image layerImage; + private Color foregroundColor; + private Font font; + + public TextFigure() { + setBorder(new MarginBorder(1)); + FlowPage flowPage = new FlowPage(); + textFlow = new TextFlow(); + textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, + ParagraphTextLayout.WORD_WRAP_SOFT)); + flowPage.add(textFlow); + setLayoutManager(new StackLayout()); + add(flowPage); + } + + /** + * Returns the text inside the TextFlow. + * + * @return the text flow inside the text. + */ + public String getText() { + return textFlow.getText(); + } + + /** + * Sets the text of the TextFlow to the given value. + * + * @param newText + * the new text value. + */ + public void setText(String newText) { + textFlow.setText(newText); + } + + public void setTextColor(RGB rgb) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), rgb); + textFlow.setForegroundColor(foregroundColor); + } + + public void setBackgroundVisible(Boolean bol) { + setOpaque(bol); + } + + public void setFont(String fontData) { + if (font != null) + font.dispose(); + font = new Font(Display.getDefault(), new FontData(fontData)); + textFlow.setFont(font); + } + + // TODO: CHECK STACK OVERFLOW ERROR!!!! + public Font getFont() { + return textFlow.getFont(); + } + + public void setLayout(Rectangle rect) { + getParent().setConstraint(this, rect); + } + + @Override + public void deactivateFigure() { + if (foregroundColor != null) + foregroundColor.dispose(); + if (font != null) + font.dispose(); + if (layerImage != null) + layerImage.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextfieldFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextfieldFigure.java index b2d80ff7ff4bad18fff6fd1e42677d269a79cf7e..0b99d5ccb1a04e679ea68e435e11c58d6661259f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextfieldFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TextfieldFigure.java @@ -1,63 +1,58 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.GridLayout; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; - -public class TextfieldFigure extends AbstractBMotionFigure { - - private Label lb; - private Color foregroundColor; - - public TextfieldFigure() { - GridLayout fl = new GridLayout(); - fl.marginHeight = 2; - fl.marginWidth = 3; - setLayoutManager(fl); - foregroundColor = new Color(Display.getDefault(), 171, 173, 179); - setBorder(new LineBorder( - new Color(Display.getDefault(), 226, 227, 234), 1)); - this.lb = new Label(); - add(lb); - setOpaque(true); - } - - @Override - public void paint(Graphics g) { - super.paint(g); - Rectangle r = Rectangle.SINGLETON; - r.setBounds(getBounds()); - g.setForegroundColor(foregroundColor); - g.drawLine(r.getTopLeft(), r.getTopRight()); - } - - public void setText(String text) { - lb.setText(text); - } - - public String getText() { - return lb.getText(); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() - */ - @Override - public void deactivateFigure() { - if (foregroundColor != null) - foregroundColor.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.GridLayout; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.LineBorder; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; + +public class TextfieldFigure extends AbstractBMotionFigure { + + private Label lb; + private Color foregroundColor; + + public TextfieldFigure() { + GridLayout fl = new GridLayout(); + fl.marginHeight = 2; + fl.marginWidth = 3; + setLayoutManager(fl); + foregroundColor = new Color(Display.getDefault(), 171, 173, 179); + setBorder(new LineBorder( + new Color(Display.getDefault(), 226, 227, 234), 1)); + this.lb = new Label(); + add(lb); + setOpaque(true); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Rectangle r = Rectangle.SINGLETON; + r.setBounds(getBounds()); + g.setForegroundColor(foregroundColor); + g.drawLine(r.getTopLeft(), r.getTopRight()); + } + + public void setText(String text) { + lb.setText(text); + } + + public String getText() { + return lb.getText(); + } + + @Override + public void deactivateFigure() { + if (foregroundColor != null) + foregroundColor.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TrackNodeFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TrackNodeFigure.java index 9af55953bab0885dccc7ad316fdb021db135f255..38ddc348385c66b41fbf463ec848a3a9fe40dc19 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TrackNodeFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TrackNodeFigure.java @@ -1,61 +1,61 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Color; - - -public class TrackNodeFigure extends AbstractBMotionFigure { - - private Color foregroundColor; - private int lineWidth; - private int lineStyle; - - public TrackNodeFigure() { - setOpaque(false); - } - - @Override - protected void paintFigure(Graphics g) { - - Rectangle r = getClientArea(); - g.setBackgroundColor(getBackgroundColor()); - g.fillRectangle(r); - g.setForegroundColor(foregroundColor); - g.setLineStyle(lineStyle); - g.setLineWidth(lineWidth); - g.drawLine(r.getTop().x, r.getTop().y + 5, r.getBottom().x, - r.getBottom().y - 5); - super.paintFigure(g); - - } - - @Override - public void setForegroundColor(Color fg) { - this.foregroundColor = fg; - repaint(); - } - - public void setLineWidth(int lineWidth) { - this.lineWidth = lineWidth; - repaint(); - } - - public void setLineStyle(int lineStyle) { - this.lineStyle = lineStyle; - repaint(); - } - - @Override - public void deactivateFigure() { - if (foregroundColor != null) - foregroundColor.dispose(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Color; + + +public class TrackNodeFigure extends AbstractBMotionFigure { + + private Color foregroundColor; + private int lineWidth; + private int lineStyle; + + public TrackNodeFigure() { + setOpaque(false); + } + + @Override + protected void paintFigure(Graphics g) { + + Rectangle r = getClientArea(); + g.setBackgroundColor(getBackgroundColor()); + g.fillRectangle(r); + g.setForegroundColor(foregroundColor); + g.setLineStyle(lineStyle); + g.setLineWidth(lineWidth); + g.drawLine(r.getTop().x, r.getTop().y + 5, r.getBottom().x, + r.getBottom().y - 5); + super.paintFigure(g); + + } + + @Override + public void setForegroundColor(Color fg) { + this.foregroundColor = fg; + repaint(); + } + + public void setLineWidth(int lineWidth) { + this.lineWidth = lineWidth; + repaint(); + } + + public void setLineStyle(int lineStyle) { + this.lineStyle = lineStyle; + repaint(); + } + + @Override + public void deactivateFigure() { + if (foregroundColor != null) + foregroundColor.dispose(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/UnknownBControl.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/UnknownBControl.java index 2e7fc294f18c0a839c962c67f437aff2660e9d8d..120245cdb9b4ea6238a642da5cc35abdc2235c70 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/UnknownBControl.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/UnknownBControl.java @@ -1,47 +1,47 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.text.FlowPage; -import org.eclipse.draw2d.text.ParagraphTextLayout; -import org.eclipse.draw2d.text.TextFlow; - -public class UnknownBControl extends AbstractBMotionFigure { - - public static String ID = "de.bmotionstudio.gef.editor.unknown"; - - private final TextFlow textFlow; - - public UnknownBControl() { - setBorder(new MarginBorder(1)); - FlowPage flowPage = new FlowPage(); - textFlow = new TextFlow(); - textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, - ParagraphTextLayout.WORD_WRAP_SOFT)); - flowPage.add(textFlow); - setLayoutManager(new StackLayout()); - add(flowPage); - setBackgroundColor(ColorConstants.red); - setOpaque(true); - } - - public void prepareForEditing() { - } - - public void setMessage(final String type) { - textFlow.setText("Unknown part: " + type); - } - - public void setLayout(final Rectangle rect) { - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.MarginBorder; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.draw2d.text.FlowPage; +import org.eclipse.draw2d.text.ParagraphTextLayout; +import org.eclipse.draw2d.text.TextFlow; + +public class UnknownBControl extends AbstractBMotionFigure { + + public static String ID = "de.bmotionstudio.gef.editor.unknown"; + + private final TextFlow textFlow; + + public UnknownBControl() { + setBorder(new MarginBorder(1)); + FlowPage flowPage = new FlowPage(); + textFlow = new TextFlow(); + textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, + ParagraphTextLayout.WORD_WRAP_SOFT)); + flowPage.add(textFlow); + setLayoutManager(new StackLayout()); + add(flowPage); + setBackgroundColor(ColorConstants.red); + setOpaque(true); + } + + public void prepareForEditing() { + } + + public void setMessage(final String type) { + textFlow.setText("Unknown part: " + type); + } + + public void setLayout(final Rectangle rect) { + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/VisualizationFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/VisualizationFigure.java index b2b647d2a08de4b9008f5922c86e17c3401cc102..801a8fd4060138240a35fb59d903e9eb90c2e1d0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/VisualizationFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/VisualizationFigure.java @@ -1,31 +1,31 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.figure; - -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.LayoutAnimator; -import org.eclipse.draw2d.LayoutListener; -import org.eclipse.draw2d.geometry.Rectangle; - -public class VisualizationFigure extends FreeformLayer { - - private LayoutListener layoutListener = LayoutAnimator.getDefault(); - - public VisualizationFigure() { - setLayoutManager(new FreeformLayout()); - addLayoutListener(layoutListener); - } - - public void prepareForEditing() { - removeLayoutListener(layoutListener); - } - - public void setLayout(Rectangle rect) { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.figure; + +import org.eclipse.draw2d.FreeformLayer; +import org.eclipse.draw2d.FreeformLayout; +import org.eclipse.draw2d.LayoutAnimator; +import org.eclipse.draw2d.LayoutListener; +import org.eclipse.draw2d.geometry.Rectangle; + +public class VisualizationFigure extends FreeformLayer { + + private LayoutListener layoutListener = LayoutAnimator.getDefault(); + + public VisualizationFigure() { + setLayoutManager(new FreeformLayout()); + addLayoutListener(layoutListener); + } + + public void prepareForEditing() { + removeLayoutListener(layoutListener); + } + + public void setLayout(Rectangle rect) { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/OpenWebsiteHandler.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/OpenWebsiteHandler.java index 9122b15e222de30d845fada8f4a41b35e265b4c1..5a956e4483e387bb3cac5ba2cc6a3c379a50e6b0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/OpenWebsiteHandler.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/OpenWebsiteHandler.java @@ -1,39 +1,39 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.handler; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import de.prob.logging.Logger; - -public class OpenWebsiteHandler extends AbstractHandler { - - private static final String URL = "http://www.stups.uni-duesseldorf.de/BMotionStudio/"; - - public Object execute(ExecutionEvent event) throws ExecutionException { - try { - PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() - .openURL(new URL(URL)); - } catch (PartInitException e) { - final String message = "Part init exception occurred\n" - + e.getLocalizedMessage(); - Logger.notifyUser(message, e); - } catch (MalformedURLException e) { - final String message = "This really should never happen unless the http protocol changes"; - Logger.notifyUser(message, e); - } - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.handler; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import de.prob.logging.Logger; + +public class OpenWebsiteHandler extends AbstractHandler { + + private static final String URL = "https://prob.hhu.de/w/index.php/BMotion_Studio"; + + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() + .openURL(new URL(URL)); + } catch (PartInitException e) { + final String message = "Part init exception occurred\n" + + e.getLocalizedMessage(); + Logger.notifyUser(message, e); + } catch (MalformedURLException e) { + final String message = "This really should never happen unless the http protocol changes"; + Logger.notifyUser(message, e); + } + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationEditorHandler.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationEditorHandler.java index ebd89b02a01f24f608dc4c9c07d78650519e767e..a2063106ee957476f5b568a8553dfaddeb89f87a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationEditorHandler.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationEditorHandler.java @@ -1,74 +1,74 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.WorkbenchException; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.internal.VisualizationProgressBar; -import de.prob.core.Animator; -import de.prob.logging.Logger; - -public class StartVisualizationEditorHandler extends AbstractHandler implements - IHandler { - - private VisualizationProgressBar dpb; - - public Object execute(final ExecutionEvent event) throws ExecutionException { - - if (BMotionEditorPlugin.getActiveEditor().isDirty()) { - if (MessageDialog - .openConfirm( - Display.getDefault().getActiveShell(), - "Please confirm", - "You made changes in your editor. Do you want to safe before starting visualization?")) { - BMotionEditorPlugin.getActiveEditor().doSave( - new NullProgressMonitor()); - } - } - - IFile projectFile = BMotionEditorPlugin.getActiveEditor() - .getVisualization().getProjectFile(); - - // Get ProB Animator - Animator animator = Animator.getAnimator(); - - // Open Run Perspective - IWorkbench workbench = PlatformUI.getWorkbench(); - try { - workbench.showPerspective("de.bmotionstudio.perspective.run", - workbench.getActiveWorkbenchWindow()); - } catch (WorkbenchException e) { - Logger.notifyUser("Error opening BMotion Studio Run perspective.", - e); - } - - // First, kill old visualization (only if exists) - if (dpb != null) - dpb.kill(); - // Create a new visualization - dpb = new VisualizationProgressBar(Display.getDefault() - .getActiveShell(), animator, - BMotionEditorPlugin.getActiveEditor(), projectFile); - dpb.initGuage(); - dpb.open(); - - return null; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.WorkbenchException; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.internal.VisualizationProgressBar; +import de.prob.core.Animator; +import de.prob.logging.Logger; + +public class StartVisualizationEditorHandler extends AbstractHandler implements + IHandler { + + private VisualizationProgressBar dpb; + + public Object execute(final ExecutionEvent event) throws ExecutionException { + + if (BMotionEditorPlugin.getActiveEditor().isDirty()) { + if (MessageDialog + .openConfirm( + Display.getDefault().getActiveShell(), + "Please confirm", + "You made changes in your editor. Do you want to safe before starting visualization?")) { + BMotionEditorPlugin.getActiveEditor().doSave( + new NullProgressMonitor()); + } + } + + IFile projectFile = BMotionEditorPlugin.getActiveEditor() + .getVisualization().getProjectFile(); + + // Get ProB Animator + Animator animator = Animator.getAnimator(); + + // Open Run Perspective + IWorkbench workbench = PlatformUI.getWorkbench(); + try { + workbench.showPerspective("de.bmotionstudio.perspective.run", + workbench.getActiveWorkbenchWindow()); + } catch (WorkbenchException e) { + Logger.notifyUser("Error opening BMotion Studio Run perspective.", + e); + } + + // First, kill old visualization (only if exists) + if (dpb != null) + dpb.kill(); + // Create a new visualization + dpb = new VisualizationProgressBar(Display.getDefault() + .getActiveShell(), animator, + BMotionEditorPlugin.getActiveEditor(), projectFile); + dpb.initGuage(); + dpb.open(); + + return null; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationFileHandler.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationFileHandler.java index 945993e514a2dfa94a453379a0aa7c8fb502b4e9..1accf0bf2bb9b375dbd900778362e1ad4c7a2ba7 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationFileHandler.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/handler/StartVisualizationFileHandler.java @@ -1,136 +1,136 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.part.FileEditorInput; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioEditor; -import de.bmotionstudio.gef.editor.internal.VisualizationProgressBar; -import de.prob.core.Animator; -import de.prob.logging.Logger; - -public class StartVisualizationFileHandler extends AbstractHandler implements - IHandler { - - private ISelection fSelection; - private VisualizationProgressBar dpb; - private BMotionStudioEditor activeEditor; - - public Object execute(final ExecutionEvent event) throws ExecutionException { - - fSelection = HandlerUtil.getCurrentSelection(event); - - BMotionStudioEditor editor = BMotionEditorPlugin.getActiveEditor(); - if (editor != null) { - if (BMotionEditorPlugin.getActiveEditor().isDirty()) { - if (MessageDialog - .openConfirm( - Display.getDefault().getActiveShell(), - "Please confirm", - "You made changes in your editor. Do you want to safe before starting visualization?")) { - - BMotionEditorPlugin.getActiveEditor().doSave( - new NullProgressMonitor()); - } - } - } - - IFile f = null; - - // Get the Selection - if (fSelection instanceof IStructuredSelection) { - - IStructuredSelection ssel = (IStructuredSelection) fSelection; - - if (ssel.size() == 1) { - - f = getBmsFileFromSelection(ssel); - - IWorkbenchWindow window = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - - IEditorDescriptor desc = PlatformUI.getWorkbench() - .getEditorRegistry().getDefaultEditor(f.getName()); - - try { - IEditorPart part = page.openEditor(new FileEditorInput(f), - desc.getId()); - if (part instanceof BMotionStudioEditor) { - activeEditor = (BMotionStudioEditor) part; - } else { - // TODO: Return some useful error?! - return null; - } - } catch (PartInitException e) { - e.printStackTrace(); - } - - // Get ProB Animator - Animator animator = Animator.getAnimator(); - - // Open Run Perspective - IWorkbench workbench = PlatformUI.getWorkbench(); - try { - workbench.showPerspective( - "de.bmotionstudio.perspective.run", - workbench.getActiveWorkbenchWindow()); - } catch (WorkbenchException e) { - Logger.notifyUser( - "Error opening BMotion Studio Run perspective.", e); - } - - // First, kill old visualization (only if exists) - if (dpb != null) - dpb.kill(); - // Create a new visualization - dpb = new VisualizationProgressBar(Display.getDefault() - .getActiveShell(), animator, activeEditor, f); - dpb.initGuage(); - dpb.open(); - - } - - } - - return null; - - } - - public void selectionChanged(final IAction action, - final ISelection selection) { - fSelection = selection; - } - - protected IFile getBmsFileFromSelection(IStructuredSelection ssel) { - if (ssel.getFirstElement() instanceof IFile) - return (IFile) ssel.getFirstElement(); - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.part.FileEditorInput; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioEditor; +import de.bmotionstudio.gef.editor.internal.VisualizationProgressBar; +import de.prob.core.Animator; +import de.prob.logging.Logger; + +public class StartVisualizationFileHandler extends AbstractHandler implements + IHandler { + + private ISelection fSelection; + private VisualizationProgressBar dpb; + private BMotionStudioEditor activeEditor; + + public Object execute(final ExecutionEvent event) throws ExecutionException { + + fSelection = HandlerUtil.getCurrentSelection(event); + + BMotionStudioEditor editor = BMotionEditorPlugin.getActiveEditor(); + if (editor != null) { + if (BMotionEditorPlugin.getActiveEditor().isDirty()) { + if (MessageDialog + .openConfirm( + Display.getDefault().getActiveShell(), + "Please confirm", + "You made changes in your editor. Do you want to safe before starting visualization?")) { + + BMotionEditorPlugin.getActiveEditor().doSave( + new NullProgressMonitor()); + } + } + } + + IFile f = null; + + // Get the Selection + if (fSelection instanceof IStructuredSelection) { + + IStructuredSelection ssel = (IStructuredSelection) fSelection; + + if (ssel.size() == 1) { + + f = getBmsFileFromSelection(ssel); + + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + IWorkbenchPage page = window.getActivePage(); + + IEditorDescriptor desc = PlatformUI.getWorkbench() + .getEditorRegistry().getDefaultEditor(f.getName()); + + try { + IEditorPart part = page.openEditor(new FileEditorInput(f), + desc.getId()); + if (part instanceof BMotionStudioEditor) { + activeEditor = (BMotionStudioEditor) part; + } else { + // TODO: Return some useful error?! + return null; + } + } catch (PartInitException e) { + e.printStackTrace(); + } + + // Get ProB Animator + Animator animator = Animator.getAnimator(); + + // Open Run Perspective + IWorkbench workbench = PlatformUI.getWorkbench(); + try { + workbench.showPerspective( + "de.bmotionstudio.perspective.run", + workbench.getActiveWorkbenchWindow()); + } catch (WorkbenchException e) { + Logger.notifyUser( + "Error opening BMotion Studio Run perspective.", e); + } + + // First, kill old visualization (only if exists) + if (dpb != null) + dpb.kill(); + // Create a new visualization + dpb = new VisualizationProgressBar(Display.getDefault() + .getActiveShell(), animator, activeEditor, f); + dpb.initGuage(); + dpb.open(); + + } + + } + + return null; + + } + + public void selectionChanged(final IAction action, + final ISelection selection) { + fSelection = selection; + } + + protected IFile getBmsFileFromSelection(IStructuredSelection ssel) { + if (ssel.getFirstElement() instanceof IFile) + return (IFile) ssel.getFirstElement(); + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlListConverter.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlListConverter.java index 44f40543b95a639d01d1e4114524f865dd16773b..16a795e9654aed6fc0e8dc9b28b3a0960ea87d89 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlListConverter.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlListConverter.java @@ -1,56 +1,56 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlList; - -public class BControlListConverter implements Converter { - - @Override - public boolean canConvert(Class clazz) { - if (clazz == BControlList.class) - return true; - return false; - } - - @Override - public void marshal(Object obj, HierarchicalStreamWriter writer, - MarshallingContext context) { - BControlList list = (BControlList) obj; - for (BControl control : list) { - writer.startNode(control.getClass().getName()); - context.convertAnother(control); - writer.endNode(); - } - } - - @Override - public Object unmarshal(HierarchicalStreamReader reader, - UnmarshallingContext context) { - BControlList list = new BControlList(); - while (reader.hasMoreChildren()) { - reader.moveDown(); - try { - BControl c = (BControl) context.convertAnother(list, - Class.forName(reader.getNodeName())); - list.add(c); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - reader.moveUp(); - } - return list; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlList; + +public class BControlListConverter implements Converter { + + @Override + public boolean canConvert(Class clazz) { + if (clazz == BControlList.class) + return true; + return false; + } + + @Override + public void marshal(Object obj, HierarchicalStreamWriter writer, + MarshallingContext context) { + BControlList list = (BControlList) obj; + for (BControl control : list) { + writer.startNode(control.getClass().getName()); + context.convertAnother(control); + writer.endNode(); + } + } + + @Override + public Object unmarshal(HierarchicalStreamReader reader, + UnmarshallingContext context) { + BControlList list = new BControlList(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + try { + BControl c = (BControl) context.convertAnother(list, + Class.forName(reader.getNodeName())); + list.add(c); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + reader.moveUp(); + } + return list; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java index 2a836bbb01b329295719dcb98442848f2bbecd5e..97f6638b300307f6b0d2e646946af07de2fb6184 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java @@ -1,75 +1,75 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeMisc; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BControlPropertySource extends AbstractAttribute { - - private BControl control; - - private BAttributeMisc miscAttribute; - - public BControlPropertySource(BControl control) { - super(null); - this.control = control; - this.miscAttribute = new BAttributeMisc(""); - addChild(this.miscAttribute); - init(); - } - - private void init() { - - for (AbstractAttribute atr : control.getAttributes().values()) { - - if (atr.show()) { - - atr.setControl(control); - - String group = atr.getGroup(); - - if (group != null) { - - // If group is root node --> add to root - if (group.equals(ROOT)) { - addChild(atr); - } else { - AbstractAttribute groupAtr = control - .getAttribute(group); - if (groupAtr != null) { - groupAtr.addChild(atr); - } else { - miscAttribute.addChild(atr); - } - } - - } else { - // No group, add to misc attribute node - miscAttribute.addChild(atr); - } - - } - - } - - } - - @Override - protected PropertyDescriptor preparePropertyDescriptor() { - return null; - } - - @Override - public String getName() { - return "RootProperties"; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.ui.views.properties.PropertyDescriptor; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.BAttributeMisc; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BControlPropertySource extends AbstractAttribute { + + private BControl control; + + private BAttributeMisc miscAttribute; + + public BControlPropertySource(BControl control) { + super(null); + this.control = control; + this.miscAttribute = new BAttributeMisc(""); + addChild(this.miscAttribute); + init(); + } + + private void init() { + + for (AbstractAttribute atr : control.getAttributes().values()) { + + if (atr.show()) { + + atr.setControl(control); + + String group = atr.getGroup(); + + if (group != null) { + + // If group is root node --> add to root + if (group.equals(ROOT)) { + addChild(atr); + } else { + AbstractAttribute groupAtr = control + .getAttribute(group); + if (groupAtr != null) { + groupAtr.addChild(atr); + } else { + miscAttribute.addChild(atr); + } + } + + } else { + // No group, add to misc attribute node + miscAttribute.addChild(atr); + } + + } + + } + + } + + @Override + protected PropertyDescriptor preparePropertyDescriptor() { + return null; + } + + @Override + public String getName() { + return "RootProperties"; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTemplate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTemplate.java index 5e882b32101d0967748a6862a18f26371e46b002..2e2c9df0ceb0e56cc4a92130795f4930c854828f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTemplate.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTemplate.java @@ -1,21 +1,21 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -public class BControlTemplate { - - private String type; - - public BControlTemplate(String type) { - this.type = type; - } - - public String getType() { - return type; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +public class BControlTemplate { + + private String type; + + public BControlTemplate(String type) { + this.type = type; + } + + public String getType() { + return type; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTransferDropTargetListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTransferDropTargetListener.java index ef02d27d109ba3895bf37b5c91e2ca737fe50b27..dd51e114545efa35b295a2d1a6f2e4b1d8d6e093 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTransferDropTargetListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlTransferDropTargetListener.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; -import org.eclipse.gef.requests.CreationFactory; - -import de.bmotionstudio.gef.editor.BControlCreationFactory; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class BControlTransferDropTargetListener extends - TemplateTransferDropTargetListener { - - private CreationFactory factory = null; - private BControlTemplate currentTempl; - private Visualization visualization; - - public BControlTransferDropTargetListener(EditPartViewer viewer, - Visualization visualization) { - super(viewer); - this.visualization = visualization; - } - - @Override - protected CreationFactory getFactory(Object template) { - - if (template != null) { - - if (template instanceof BControlTemplate) { - - BControlTemplate templ = (BControlTemplate) template; - - if (factory == null - || !templ.getType().equals(currentTempl.getType())) { - factory = new BControlCreationFactory(templ.getType(), - visualization); - currentTempl = templ; - } - - } - - } - - return factory; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; +import org.eclipse.gef.requests.CreationFactory; + +import de.bmotionstudio.gef.editor.BControlCreationFactory; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class BControlTransferDropTargetListener extends + TemplateTransferDropTargetListener { + + private CreationFactory factory = null; + private BControlTemplate currentTempl; + private Visualization visualization; + + public BControlTransferDropTargetListener(EditPartViewer viewer, + Visualization visualization) { + super(viewer); + this.visualization = visualization; + } + + @Override + protected CreationFactory getFactory(Object template) { + + if (template != null) { + + if (template instanceof BControlTemplate) { + + BControlTemplate templ = (BControlTemplate) template; + + if (factory == null + || !templ.getType().equals(currentTempl.getType())) { + factory = new BControlCreationFactory(templ.getType(), + visualization); + currentTempl = templ; + } + + } + + } + + return factory; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMSConverter512.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMSConverter512.java index 518b6961c6208988ce9d9258b16eb0ae20301b9c..84163cbe90135da74e57ae238dfc0ab88a1ce08a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMSConverter512.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMSConverter512.java @@ -1,322 +1,323 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.mapper.MapperWrapper; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlList; -import de.bmotionstudio.gef.editor.model.BMotionGuide; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -public class BMSConverter512 { - - private IFile file; - - public BMSConverter512(IFile file) { - this.file = file; - try { - convert(); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); - } catch (CoreException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } catch (SAXException e) { - e.printStackTrace(); - } catch (TransformerException e) { - e.printStackTrace(); - } catch (TransformerFactoryConfigurationError e) { - e.printStackTrace(); - } - } - - private void convert() throws CoreException, IOException, - ParserConfigurationException, SAXException, - TransformerConfigurationException, TransformerException, - TransformerFactoryConfigurationError { - - InputStream inputStream = file.getContents(); - - ByteArrayInputStream byteArrayInputStream = null; - - String str = inputStreamToString(inputStream); - - str = str.replace("de.bmotionstudio.gef.basic", - "de.bmotionstudio.gef.editor"); - str = str.replace("de.bmotionstudio.gef.core", - "de.bmotionstudio.gef.editor"); - - str = str.replace("de.bmotionstudio.gef.editor.model.BControl", - "control"); - str = str.replace("de.bmotionstudio.gef.editor.model.BMotionGuide", - "guide"); - str = str.replace("de.bmotionstudio.gef.editor.Visualization", - "visualization"); - str = str.replace("de.bmotionstudio.gef.editor.model.Visualization", - "visualization"); - str = str.replace("de.bmotionstudio.gef.editor.model.BConnection", - "connection"); - - str = str.replace("de.bmotionstudio.gef.editor.rectangle", - "de.bmotionstudio.gef.editor.shape"); - - str = str.replace( - "de.bmotionstudio.gef.editor.observer.ToggleCoordinates", - "de.bmotionstudio.gef.editor.observer.SwitchCoordinates"); - str = str.replace("de.bmotionstudio.gef.editor.observer.ToggleImage", - "de.bmotionstudio.gef.editor.observer.SwitchImage"); - str = str.replace("de.bmotionstudio.gef.editor.observer.ToggleImage", - "de.bmotionstudio.gef.editor.observer.SwitchImage"); - str = str.replace( - "de.bmotionstudio.gef.editor.observer.ToggleChildCoordinates", - "de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates"); - - byteArrayInputStream = new ByteArrayInputStream(str.getBytes()); - - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(byteArrayInputStream); - - NodeList nList = doc.getElementsByTagName("type"); - for (int temp = 0; temp < nList.getLength(); temp++) { - - Node nNode = nList.item(temp); - - if (nNode.getParentNode().getNodeName().equals("control")) { - Element parent = (Element) nNode.getParentNode(); - parent.setAttribute("type", nNode.getTextContent()); - } - - } - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - Source xmlSource = new DOMSource(doc); - Result outputTarget = new StreamResult(outputStream); - TransformerFactory.newInstance().newTransformer() - .transform(xmlSource, outputTarget); - byteArrayInputStream = new ByteArrayInputStream( - outputStream.toByteArray()); - - XStream xstream = new XStream() { - @Override - protected MapperWrapper wrapMapper(final MapperWrapper next) { - return new MapperWrapper(next) { - @Override - public boolean shouldSerializeMember( - @SuppressWarnings("rawtypes") final Class definedIn, - final String fieldName) { - if (definedIn == Object.class) - return false; - return super - .shouldSerializeMember(definedIn, fieldName); - } - }; - } - }; - - xstream.registerConverter(new Converter() { - - @Override - public boolean canConvert(Class clazz) { - if (clazz == BControlList.class) - return true; - return false; - } - - @Override - public void marshal(Object obj, HierarchicalStreamWriter writer, - MarshallingContext context) { - BControlList list = (BControlList) obj; - for (BControl control : list) { - writer.startNode(control.getClass().getName()); - context.convertAnother(control); - writer.endNode(); - } - } - - @Override - public Object unmarshal(HierarchicalStreamReader reader, - UnmarshallingContext context) { - BControlList list = new BControlList(); - while (reader.hasMoreChildren()) { - reader.moveDown(); - list.add((BControl) context.convertAnother(list, - BControl.class)); - reader.moveUp(); - } - return list; - } - }); - xstream.registerConverter(new Converter() { - - @Override - public boolean canConvert(Class clazz) { - if (clazz == BControl.class) - return true; - return false; - } - - @Override - public void marshal(Object obj, HierarchicalStreamWriter writer, - MarshallingContext context) { - BControl c = (BControl) obj; - writer.startNode(c.getClass().getName()); - context.convertAnother(c); - writer.endNode(); - } - - @Override - public Object unmarshal(HierarchicalStreamReader reader, - UnmarshallingContext context) { - - String type = reader.getAttribute("type"); - - BControl c = null; - - IConfigurationElement controlExtension = BMotionEditorPlugin - .getControlExtension(type); - if (controlExtension != null) { - try { - IBControlService service = (IBControlService) controlExtension - .createExecutableExtension("service"); - c = service.createControl(null); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - if (c != null) { - - while (reader.hasMoreChildren()) { - - reader.moveDown(); - - if ("children".equals(reader.getNodeName())) { - c.setChildrenArray((BControlList) context - .convertAnother(c, BControlList.class)); - } else if ("observers".equals(reader.getNodeName())) { - c.setObserverMap((Map<String, Observer>) context - .convertAnother(c, Map.class)); - } else if ("events".equals(reader.getNodeName())) { - c.setEventMap((Map<String, SchedulerEvent>) (context - .convertAnother(c, Map.class))); - } else if ("attributes".equals(reader.getNodeName())) { - Map<String, AbstractAttribute> attributes = (Map<String, AbstractAttribute>) context - .convertAnother(c, Map.class); - for (AbstractAttribute atr : attributes.values()) { - atr.setEditable(true); - atr.setShow(true); - } - c.setAttributes(attributes); - } else if ("verticalGuide".equals(reader.getNodeName())) { - c.setVerticalGuide((BMotionGuide) context - .convertAnother(c, BMotionGuide.class)); - } else if ("horizontalGuide".equals(reader - .getNodeName())) { - c.setVerticalGuide((BMotionGuide) context - .convertAnother(c, BMotionGuide.class)); - } else if ("sourceConnections".equals(reader - .getNodeName())) { - c.setHorizontalGuide((BMotionGuide) context - .convertAnother(c, BMotionGuide.class)); - } else if ("targetConnections".equals(reader - .getNodeName())) { - c.setTargetConnections((List<BConnection>) context - .convertAnother(c, List.class)); - } - - reader.moveUp(); - - } - - } - - return c; - - } - - }); - xstream.useAttributeFor(BControl.class, "type"); - xstream.alias("control", BControl.class); - xstream.alias("visualization", Visualization.class); - xstream.alias("guide", BMotionGuide.class); - xstream.alias("connection", BConnection.class); - xstream.alias("children", BControlList.class); - - Visualization visualization = (Visualization) xstream - .fromXML(byteArrayInputStream); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - OutputStreamWriter writer = new OutputStreamWriter(out, "UTF8"); - visualization.setVersion("5.2.0"); - xstream.toXML(visualization, writer); - file.setContents(new ByteArrayInputStream(out.toByteArray()), false, - false, null); - - } - - private static String inputStreamToString(InputStream in) - throws IOException { - BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(in)); - StringBuilder stringBuilder = new StringBuilder(); - String line = null; - while ((line = bufferedReader.readLine()) != null) { - stringBuilder.append(line + "\n"); - } - bufferedReader.close(); - return stringBuilder.toString(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.mapper.MapperWrapper; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlList; +import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +public class BMSConverter512 { + + private IFile file; + + public BMSConverter512(IFile file) { + this.file = file; + try { + convert(); + } catch (TransformerConfigurationException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); + } catch (TransformerException e) { + e.printStackTrace(); + } catch (TransformerFactoryConfigurationError e) { + e.printStackTrace(); + } + } + + private void convert() throws CoreException, IOException, + ParserConfigurationException, SAXException, + TransformerConfigurationException, TransformerException, + TransformerFactoryConfigurationError { + + InputStream inputStream = file.getContents(); + + ByteArrayInputStream byteArrayInputStream = null; + + String str = inputStreamToString(inputStream); + + str = str.replace("de.bmotionstudio.gef.basic", + "de.bmotionstudio.gef.editor"); + str = str.replace("de.bmotionstudio.gef.core", + "de.bmotionstudio.gef.editor"); + + str = str.replace("de.bmotionstudio.gef.editor.model.BControl", + "control"); + str = str.replace("de.bmotionstudio.gef.editor.model.BMotionGuide", + "guide"); + str = str.replace("de.bmotionstudio.gef.editor.Visualization", + "visualization"); + str = str.replace("de.bmotionstudio.gef.editor.model.Visualization", + "visualization"); + str = str.replace("de.bmotionstudio.gef.editor.model.BConnection", + "connection"); + + str = str.replace("de.bmotionstudio.gef.editor.rectangle", + "de.bmotionstudio.gef.editor.shape"); + + str = str.replace( + "de.bmotionstudio.gef.editor.observer.ToggleCoordinates", + "de.bmotionstudio.gef.editor.observer.SwitchCoordinates"); + str = str.replace("de.bmotionstudio.gef.editor.observer.ToggleImage", + "de.bmotionstudio.gef.editor.observer.SwitchImage"); + str = str.replace("de.bmotionstudio.gef.editor.observer.ToggleImage", + "de.bmotionstudio.gef.editor.observer.SwitchImage"); + str = str.replace( + "de.bmotionstudio.gef.editor.observer.ToggleChildCoordinates", + "de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates"); + + byteArrayInputStream = new ByteArrayInputStream(str.getBytes()); + + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(byteArrayInputStream); + + NodeList nList = doc.getElementsByTagName("type"); + for (int temp = 0; temp < nList.getLength(); temp++) { + + Node nNode = nList.item(temp); + + if (nNode.getParentNode().getNodeName().equals("control")) { + Element parent = (Element) nNode.getParentNode(); + parent.setAttribute("type", nNode.getTextContent()); + } + + } + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + Source xmlSource = new DOMSource(doc); + Result outputTarget = new StreamResult(outputStream); + TransformerFactory.newInstance().newTransformer() + .transform(xmlSource, outputTarget); + byteArrayInputStream = new ByteArrayInputStream( + outputStream.toByteArray()); + + XStream xstream = new XStream() { + @Override + protected MapperWrapper wrapMapper(final MapperWrapper next) { + return new MapperWrapper(next) { + @Override + public boolean shouldSerializeMember( + @SuppressWarnings("rawtypes") final Class definedIn, + final String fieldName) { + if (definedIn == Object.class) + return false; + return super + .shouldSerializeMember(definedIn, fieldName); + } + }; + } + }; + + xstream.registerConverter(new Converter() { + + @Override + public boolean canConvert(Class clazz) { + if (clazz == BControlList.class) + return true; + return false; + } + + @Override + public void marshal(Object obj, HierarchicalStreamWriter writer, + MarshallingContext context) { + BControlList list = (BControlList) obj; + for (BControl control : list) { + writer.startNode(control.getClass().getName()); + context.convertAnother(control); + writer.endNode(); + } + } + + @Override + public Object unmarshal(HierarchicalStreamReader reader, + UnmarshallingContext context) { + BControlList list = new BControlList(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + list.add((BControl) context.convertAnother(list, + BControl.class)); + reader.moveUp(); + } + return list; + } + }); + xstream.registerConverter(new Converter() { + + @Override + public boolean canConvert(Class clazz) { + if (clazz == BControl.class) + return true; + return false; + } + + @Override + public void marshal(Object obj, HierarchicalStreamWriter writer, + MarshallingContext context) { + BControl c = (BControl) obj; + writer.startNode(c.getClass().getName()); + context.convertAnother(c); + writer.endNode(); + } + + @Override + public Object unmarshal(HierarchicalStreamReader reader, + UnmarshallingContext context) { + + String type = reader.getAttribute("type"); + + BControl c = null; + + IConfigurationElement controlExtension = BMotionEditorPlugin + .getControlExtension(type); + if (controlExtension != null) { + try { + IBControlService service = (IBControlService) controlExtension + .createExecutableExtension("service"); + c = service.createControl(null); + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + if (c != null) { + + while (reader.hasMoreChildren()) { + + reader.moveDown(); + + if ("children".equals(reader.getNodeName())) { + c.setChildrenArray((BControlList) context + .convertAnother(c, BControlList.class)); + } else if ("observers".equals(reader.getNodeName())) { + c.setObserverMap((Map<String, Observer>) context + .convertAnother(c, Map.class)); + } else if ("events".equals(reader.getNodeName())) { + c.setEventMap((Map<String, SchedulerEvent>) (context + .convertAnother(c, Map.class))); + } else if ("attributes".equals(reader.getNodeName())) { + Map<String, AbstractAttribute> attributes = (Map<String, AbstractAttribute>) context + .convertAnother(c, Map.class); + for (AbstractAttribute atr : attributes.values()) { + atr.setEditable(true); + atr.setShow(true); + } + c.setAttributes(attributes); + } else if ("verticalGuide".equals(reader.getNodeName())) { + c.setVerticalGuide((BMotionGuide) context + .convertAnother(c, BMotionGuide.class)); + } else if ("horizontalGuide".equals(reader + .getNodeName())) { + c.setVerticalGuide((BMotionGuide) context + .convertAnother(c, BMotionGuide.class)); + } else if ("sourceConnections".equals(reader + .getNodeName())) { + c.setHorizontalGuide((BMotionGuide) context + .convertAnother(c, BMotionGuide.class)); + } else if ("targetConnections".equals(reader + .getNodeName())) { + c.setTargetConnections((List<BConnection>) context + .convertAnother(c, List.class)); + } + + reader.moveUp(); + + } + + } + + return c; + + } + + }); + xstream.useAttributeFor(BControl.class, "type"); + xstream.alias("control", BControl.class); + xstream.alias("visualization", Visualization.class); + xstream.alias("guide", BMotionGuide.class); + xstream.alias("connection", BConnection.class); + xstream.alias("children", BControlList.class); + BMotionEditorPlugin.allowTypes(xstream); + + Visualization visualization = (Visualization) xstream + .fromXML(byteArrayInputStream); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(out, "UTF8"); + visualization.setVersion("5.2.0"); + xstream.toXML(visualization, writer); + file.setContents(new ByteArrayInputStream(out.toByteArray()), false, + false, null); + + } + + private static String inputStreamToString(InputStream in) + throws IOException { + BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(in)); + StringBuilder stringBuilder = new StringBuilder(); + String line = null; + while ((line = bufferedReader.readLine()) != null) { + stringBuilder.append(line + "\n"); + } + bufferedReader.close(); + return stringBuilder.toString(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMotionFileInputValidator.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMotionFileInputValidator.java index 96b89c750ada14851095e6b2f4eeac89276e1a5b..2f01cc79460af34ee6914aedce3d74e0a7c86ed9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMotionFileInputValidator.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BMotionFileInputValidator.java @@ -1,31 +1,31 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.jface.dialogs.IInputValidator; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; - -public class BMotionFileInputValidator implements IInputValidator { - - private IRodinProject prj; - - public BMotionFileInputValidator(IRodinProject prj) { - this.prj = prj; - } - - public String isValid(String newText) { - IRodinFile rodinFile = prj.getRodinFile(newText + "." - + BMotionEditorPlugin.FILEEXT_STUDIO); - if (rodinFile != null && rodinFile.exists()) - return "The BMotion-Project filename must be unique in a project."; - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.jface.dialogs.IInputValidator; +import org.rodinp.core.IRodinFile; +import org.rodinp.core.IRodinProject; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; + +public class BMotionFileInputValidator implements IInputValidator { + + private IRodinProject prj; + + public BMotionFileInputValidator(IRodinProject prj) { + this.prj = prj; + } + + public String isValid(String newText) { + IRodinFile rodinFile = prj.getRodinFile(newText + "." + + BMotionEditorPlugin.FILEEXT_STUDIO); + if (rodinFile != null && rodinFile.exists()) + return "The BMotion-Project filename must be unique in a project."; + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectAction.java index 414d011ed9919fb863a0f44ffb4c47003d703777..8144c6734f46d6372a9d5bbd4903a65706899450 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectAction.java @@ -1,78 +1,78 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.rodinp.core.IRodinProject; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; - -@Deprecated -public class NewBMotionProjectAction implements IObjectActionDelegate { - - // private IWorkbenchPart targetPart; - private IStructuredSelection currentSelection; - private IRodinProject rodinProject; - - public NewBMotionProjectAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(final IAction action, - final IWorkbenchPart targetPart) { - // this.targetPart = targetPart; - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - - if (rodinProject == null) { - return; - } - - NewBMotionProjectWizard wizard = new NewBMotionProjectWizard(); - wizard.init(BMotionEditorPlugin.getDefault().getWorkbench(), - currentSelection); - WizardDialog dialog = new WizardDialog(BMotionEditorPlugin - .getActiveEditor().getSite().getShell(), wizard); - dialog.create(); - dialog.open(); - - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - - if (selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; - currentSelection = ssel; - if (ssel.size() == 1) { - Object firstElement = ssel.getFirstElement(); - if (firstElement instanceof IRodinProject) { - rodinProject = (IRodinProject) firstElement; - return; - } - } - } - rodinProject = null; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.rodinp.core.IRodinProject; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; + +@Deprecated +public class NewBMotionProjectAction implements IObjectActionDelegate { + + // private IWorkbenchPart targetPart; + private IStructuredSelection currentSelection; + private IRodinProject rodinProject; + + public NewBMotionProjectAction() { + super(); + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(final IAction action, + final IWorkbenchPart targetPart) { + // this.targetPart = targetPart; + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + + if (rodinProject == null) { + return; + } + + NewBMotionProjectWizard wizard = new NewBMotionProjectWizard(); + wizard.init(BMotionEditorPlugin.getDefault().getWorkbench(), + currentSelection); + WizardDialog dialog = new WizardDialog(BMotionEditorPlugin + .getActiveEditor().getSite().getShell(), wizard); + dialog.create(); + dialog.open(); + + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + + if (selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) selection; + currentSelection = ssel; + if (ssel.size() == 1) { + Object firstElement = ssel.getFirstElement(); + if (firstElement instanceof IRodinProject) { + rodinProject = (IRodinProject) firstElement; + return; + } + } + } + rodinProject = null; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizard.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizard.java index ae7689f1420914eb61a023b05dd64ce66467e40a..c43736ade824237727c41f35825e477f76d8c0b6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizard.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizard.java @@ -1,140 +1,140 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -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.rodinp.core.RodinCore; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; - -public class NewBMotionProjectWizard extends Wizard implements INewWizard { - - // The wizard page. - private NewBMotionProjectWizardPage page; - - // The selection when the wizard is launched. - private IStructuredSelection selection; - - public NewBMotionProjectWizard() { - super(); - setNeedsProgressMonitor(true); - } - - @Override - public void addPages() { - page = new NewBMotionProjectWizardPage(selection); - addPage(page); - } - - public void init(final IWorkbench workbench, final IStructuredSelection sel) { - this.selection = sel; - } - - @Override - public boolean performFinish() { - - // New project/file name - final String projectName = page.getFileName(); - - // Selected rodin project root - final String projectRoot = page.getProjectRoot(); - - final IRunnableWithProgress op = new IRunnableWithProgress() { - public void run(final IProgressMonitor monitor) - throws InvocationTargetException { - try { - doFinish( - projectRoot, - projectName, - page.getProject(), - page.getInitialContents(BMotionEditorPlugin.FILEEXT_STUDIO), - monitor); - } catch (final CoreException e) { - Logger.getAnonymousLogger().log(Level.SEVERE, - "CoreException", e); - } catch (UnsupportedEncodingException e) { - Logger.getAnonymousLogger().log(Level.SEVERE, - "CoreException", e); - } finally { - monitor.done(); - } - } - - }; - try { - getContainer().run(true, false, op); - } catch (final InterruptedException e) { - return false; - } catch (final InvocationTargetException e) { - final Throwable realException = e.getTargetException(); - MessageDialog.openError(getShell(), "Error", - realException.getMessage()); - return false; - } - - return true; - } - - private void doFinish(String projectRoot, final String projectName, - final IProject project, final InputStream defaultContentStudio, - final IProgressMonitor monitor) throws CoreException { - - monitor.beginTask("Creating " + projectName - + " BMotion Studio Visualization", 2); - - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IResource resource = root.findMember(new Path(projectRoot)); - if (!resource.exists() || !(resource instanceof IContainer)) { - throw new CoreException(new Status(IStatus.ERROR, - "org.eventb.internal.ui", IStatus.OK, "Project \"" - + projectRoot + "\" does not exist.", null)); - } - - RodinCore.run(new IWorkspaceRunnable() { - - public void run(final IProgressMonitor pMonitor) - throws CoreException { - - // Create .bmso file - IFile file = project.getFile(projectName + "." - + BMotionEditorPlugin.FILEEXT_STUDIO); - - file.create(defaultContentStudio, false, monitor); - file.refreshLocal(IResource.DEPTH_ZERO, null); - - } - - }, monitor); - - monitor.worked(1); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +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.rodinp.core.RodinCore; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; + +public class NewBMotionProjectWizard extends Wizard implements INewWizard { + + // The wizard page. + private NewBMotionProjectWizardPage page; + + // The selection when the wizard is launched. + private IStructuredSelection selection; + + public NewBMotionProjectWizard() { + super(); + setNeedsProgressMonitor(true); + } + + @Override + public void addPages() { + page = new NewBMotionProjectWizardPage(selection); + addPage(page); + } + + public void init(final IWorkbench workbench, final IStructuredSelection sel) { + this.selection = sel; + } + + @Override + public boolean performFinish() { + + // New project/file name + final String projectName = page.getFileName(); + + // Selected rodin project root + final String projectRoot = page.getProjectRoot(); + + final IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(final IProgressMonitor monitor) + throws InvocationTargetException { + try { + doFinish( + projectRoot, + projectName, + page.getProject(), + page.getInitialContents(BMotionEditorPlugin.FILEEXT_STUDIO), + monitor); + } catch (final CoreException e) { + Logger.getAnonymousLogger().log(Level.SEVERE, + "CoreException", e); + } catch (UnsupportedEncodingException e) { + Logger.getAnonymousLogger().log(Level.SEVERE, + "CoreException", e); + } finally { + monitor.done(); + } + } + + }; + try { + getContainer().run(true, false, op); + } catch (final InterruptedException e) { + return false; + } catch (final InvocationTargetException e) { + final Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", + realException.getMessage()); + return false; + } + + return true; + } + + private void doFinish(String projectRoot, final String projectName, + final IProject project, final InputStream defaultContentStudio, + final IProgressMonitor monitor) throws CoreException { + + monitor.beginTask("Creating " + projectName + + " BMotion Studio Visualization", 2); + + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = root.findMember(new Path(projectRoot)); + if (!resource.exists() || !(resource instanceof IContainer)) { + throw new CoreException(new Status(IStatus.ERROR, + "org.eventb.internal.ui", IStatus.OK, "Project \"" + + projectRoot + "\" does not exist.", null)); + } + + RodinCore.run(new IWorkspaceRunnable() { + + public void run(final IProgressMonitor pMonitor) + throws CoreException { + + // Create .bmso file + IFile file = project.getFile(projectName + "." + + BMotionEditorPlugin.FILEEXT_STUDIO); + + file.create(defaultContentStudio, false, monitor); + file.refreshLocal(IResource.DEPTH_ZERO, null); + + } + + }, monitor); + + monitor.worked(1); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizardPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizardPage.java index a4c4580a0f7f2d9ab8b6d51c952866f3241b0b70..c56395b712928dd2c43c9835ef17a4a3f9ae4ae0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizardPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/NewBMotionProjectWizardPage.java @@ -1,417 +1,417 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -import com.thoughtworks.xstream.XStream; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.ILanguageService; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class NewBMotionProjectWizardPage extends WizardPage { - - private static final String DEFAULT_PROJECT_NAME = "NewBMotionVisualization"; - - private IProject selectedProject; - private final MachineList machineList = new MachineList(); - - private MachineEntry selectedEntry = null; - private Text projectRootText; - private Text projectText; - private TableViewer tableViewer; - - private Map<String, ILanguageService> languages = new HashMap<String, ILanguageService>(); - - protected NewBMotionProjectWizardPage(IStructuredSelection selection) { - super("wizardPage"); - this.selectedProject = getSelectedFromSelection(selection); - setTitle("New BMotion Studio Visualization"); - setDescription("Please select a B-Machine and enter a name for the new BMotion Studio Visualization."); - setImageDescriptor(BMotionStudioImage - .getImageDescriptor("icons/logo_bmotion_64.png")); - initLanguageExtensions(); - } - - private void initLanguageExtensions() { - // Get language loader - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.language"); - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - try { - ILanguageService lang = (ILanguageService) configurationElement - .createExecutableExtension("service"); - languages - .put(configurationElement.getAttribute("id"), lang); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - } - } - - private IProject getSelectedFromSelection(IStructuredSelection selection) { - if (selection.size() == 1) { - Object firstElement = selection.getFirstElement(); - if (firstElement instanceof IProject) { - return (IProject) firstElement; - } - } - return null; - } - - public IProject getProject() { - return selectedProject; - } - - public InputStream getInitialContents(String fileExtension) - throws UnsupportedEncodingException { - Visualization visualization = new Visualization(getSelectedEntry() - .getMachineFile().getName(), getSelectedEntry() - .getMachineLanguage(), Platform - .getBundle(BMotionEditorPlugin.PLUGIN_ID).getHeaders() - .get("Bundle-Version")); - XStream xstream = new XStream(); - BMotionEditorPlugin.setAliases(xstream); - String content = xstream.toXML(visualization); - return new ByteArrayInputStream(content.getBytes("UTF-8")); - } - - public String getFileName() { - if (projectText.getText().length() > 0) { - return projectText.getText(); - } - return DEFAULT_PROJECT_NAME; - } - - public MachineEntry getSelectedEntry() { - return this.selectedEntry; - } - - public String getProjectRoot() { - return this.projectRootText.getText(); - } - - public String getBMotionProjectName() { - return this.projectText.getText(); - } - - private void initContent() { - - machineList.clearList(); - - if (selectedProject != null) { - - String basePath = (selectedProject.getLocation().toString()) - .replace("file:", ""); - File dir = new File(basePath); - - for (File f : dir.listFiles()) { - - for (Entry<String, ILanguageService> e : languages.entrySet()) { - - String langID = e.getKey(); - ILanguageService langService = e.getValue(); - - IPath path = new Path(f.getAbsolutePath()); - IFile ifile = ResourcesPlugin.getWorkspace().getRoot() - .getFile(path); - if (langService.isLanguageFile(ifile)) { - machineList.addEntry(new MachineEntry(ifile, langID)); - } - - } - - } - - } - - tableViewer.setInput(machineList.getChildren()); - - } - - private boolean resourceExistsInProject(String resourceName) { - IFile f = selectedProject.getFile(resourceName + "." - + BMotionEditorPlugin.FILEEXT_STUDIO); - return f.exists(); - } - - public void validateInput() { - StringBuffer errorMessages = new StringBuffer(150); - - if (getProjectRoot().length() == 0) { - errorMessages.append("The Project name must not be empty.\n"); - } - - if (getBMotionProjectName().length() == 0) { - errorMessages - .append("The BMotion Studio Visualization filename must not be empty.\n"); - } - - // if (errorMessages.length() == 0) { - // rodinProject = RodinCore.getRodinDB().getRodinProject( - // getProjectRoot().replaceAll("/", "")); - // - // if (!rodinProject.exists()) { - // errorMessages.append("The Project '" + getProjectRoot() - // + "' does not exist.\n"); - // } - // } - - if (getSelectedEntry() == null) { - errorMessages.append("You have to select a Machine.\n"); - } - - if (errorMessages.length() == 0 - && resourceExistsInProject(getBMotionProjectName())) { - errorMessages - .append("The BMotion Studio Visualization filename must be unique in a project.\n"); - } - - if (errorMessages.length() > 0) { - setErrorMessage(errorMessages.toString()); - setPageComplete(false); - } else { - setErrorMessage(null); - setPageComplete(true); - } - } - - public void createControl(final Composite parent) { - final Composite container = new Composite(parent, SWT.NULL); - - final GridLayout layout = new GridLayout(); - container.setLayout(layout); - - layout.numColumns = 3; - layout.verticalSpacing = 20; - - setControl(container); - - final ModifyListener listener = new ModifyListener() { - public void modifyText(final ModifyEvent e) { - validateInput(); - } - }; - - GridData gd = new GridData(); - gd.horizontalAlignment = SWT.FILL; - gd.grabExcessHorizontalSpace = true; - - Label label = new Label(container, SWT.NULL); - label.setText("&Project folder:"); - - projectRootText = new Text(container, SWT.BORDER | SWT.SINGLE); - projectRootText.setLayoutData(gd); - if (selectedProject != null) { - projectRootText.setText(selectedProject.getFullPath().toOSString()); - } - projectRootText.setEditable(false); - projectRootText.addModifyListener(listener); - - final Button button = new Button(container, SWT.NULL); - button.setText("Browse..."); - button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerSelectionDialog dialog = new ContainerSelectionDialog( - getShell(), ResourcesPlugin.getWorkspace().getRoot(), - false, "Select Project"); - if (dialog.open() == Window.OK) { - final Object[] result = dialog.getResult(); - if (result.length == 1) { - Path newPath = (Path) result[0]; - IProject newProject = ResourcesPlugin.getWorkspace() - .getRoot().getProject(newPath.toString()); - selectedProject = newProject; - initContent(); - projectRootText.setText(((Path) result[0]).toOSString()); - validateInput(); - } - } - } - }); - - label = new Label(container, SWT.NULL); - label.setText("&Project name:"); - - projectText = new Text(container, SWT.BORDER | SWT.SINGLE); - projectText.setText(DEFAULT_PROJECT_NAME); - projectText.setLayoutData(gd); - projectText.addModifyListener(listener); - - gd = new GridData(); - gd.verticalAlignment = SWT.BEGINNING; - gd.horizontalSpan = 3; - - label = new Label(container, SWT.NULL); - label.setText("&Formal model:"); - label.setLayoutData(gd); - - gd = new GridData(GridData.FILL_VERTICAL); - gd.horizontalAlignment = SWT.FILL; - gd.grabExcessHorizontalSpace = true; - gd.horizontalSpan = 3; - - tableViewer = new TableViewer(container, SWT.SINGLE - | SWT.FULL_SELECTION); - final Table table = tableViewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - table.setLayoutData(gd); - - final String[] columnsNames = new String[] { "Model", "Language" }; - final int[] columnWidths = new int[] { 250, 100 }; - final int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT }; - - for (int i = 0; i < columnsNames.length; i++) { - final TableColumn tableColumn = new TableColumn(table, - columnAlignments[i]); - tableColumn.setText(columnsNames[i]); - tableColumn.setWidth(columnWidths[i]); - } - - tableViewer.setLabelProvider(new MachineLabelProvider()); - tableViewer.setContentProvider(new ArrayContentProvider()); - initContent(); - - tableViewer - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection) event - .getSelection(); - selectedEntry = (MachineEntry) selection - .getFirstElement(); - validateInput(); - } - }); - - validateInput(); - - } - - private static class MachineLabelProvider extends LabelProvider implements - ITableLabelProvider { - - public Image getColumnImage(final Object element, final int columnIndex) { - return null; - } - - public String getColumnText(final Object element, final int columnIndex) { - if (element instanceof MachineEntry) { - - final MachineEntry currentEntry = (MachineEntry) element; - - switch (columnIndex) { - case 0: - return currentEntry.getMachineName(); - case 1: - return currentEntry.getMachineLanguage(); - } - - } - - return null; - } - - } - - private static class MachineList { - private final ArrayList<MachineEntry> entries = new ArrayList<MachineEntry>(); - - public MachineEntry[] getChildren() { - return entries.toArray(new MachineEntry[entries.size()]); - } - - public void addEntry(final MachineEntry entry) { - if (!entries.contains(entry)) { - entries.add(entry); - } - } - - public void clearList() { - this.entries.clear(); - } - - } - - private static class MachineEntry { - - private final String machineName; - private final String machineLanguage; - private final IFile file; - - public MachineEntry(IFile file, String machineLanguage) { - this.file = file; - this.machineName = file.getName(); - this.machineLanguage = machineLanguage; - } - - public String getMachineName() { - return this.machineName; - } - - public String getMachineLanguage() { - return this.machineLanguage; - } - - public IFile getMachineFile() { - return this.file; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +import com.thoughtworks.xstream.XStream; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.ILanguageService; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class NewBMotionProjectWizardPage extends WizardPage { + + private static final String DEFAULT_PROJECT_NAME = "NewBMotionVisualization"; + + private IProject selectedProject; + private final MachineList machineList = new MachineList(); + + private MachineEntry selectedEntry = null; + private Text projectRootText; + private Text projectText; + private TableViewer tableViewer; + + private Map<String, ILanguageService> languages = new HashMap<String, ILanguageService>(); + + protected NewBMotionProjectWizardPage(IStructuredSelection selection) { + super("wizardPage"); + this.selectedProject = getSelectedFromSelection(selection); + setTitle("New BMotion Studio Visualization"); + setDescription("Please select a B-Machine and enter a name for the new BMotion Studio Visualization."); + setImageDescriptor(BMotionStudioImage + .getImageDescriptor("icons/logo_bmotion_64.png")); + initLanguageExtensions(); + } + + private void initLanguageExtensions() { + // Get language loader + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.language"); + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + try { + ILanguageService lang = (ILanguageService) configurationElement + .createExecutableExtension("service"); + languages + .put(configurationElement.getAttribute("id"), lang); + } catch (CoreException e) { + e.printStackTrace(); + } + + } + } + } + + private IProject getSelectedFromSelection(IStructuredSelection selection) { + if (selection.size() == 1) { + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof IProject) { + return (IProject) firstElement; + } + } + return null; + } + + public IProject getProject() { + return selectedProject; + } + + public InputStream getInitialContents(String fileExtension) + throws UnsupportedEncodingException { + Visualization visualization = new Visualization(getSelectedEntry() + .getMachineFile().getName(), getSelectedEntry() + .getMachineLanguage(), Platform + .getBundle(BMotionEditorPlugin.PLUGIN_ID).getHeaders() + .get("Bundle-Version")); + XStream xstream = new XStream(); + BMotionEditorPlugin.setAliases(xstream); + String content = xstream.toXML(visualization); + return new ByteArrayInputStream(content.getBytes("UTF-8")); + } + + public String getFileName() { + if (projectText.getText().length() > 0) { + return projectText.getText(); + } + return DEFAULT_PROJECT_NAME; + } + + public MachineEntry getSelectedEntry() { + return this.selectedEntry; + } + + public String getProjectRoot() { + return this.projectRootText.getText(); + } + + public String getBMotionProjectName() { + return this.projectText.getText(); + } + + private void initContent() { + + machineList.clearList(); + + if (selectedProject != null) { + + String basePath = (selectedProject.getLocation().toString()) + .replace("file:", ""); + File dir = new File(basePath); + + for (File f : dir.listFiles()) { + + for (Entry<String, ILanguageService> e : languages.entrySet()) { + + String langID = e.getKey(); + ILanguageService langService = e.getValue(); + + IPath path = new Path(f.getAbsolutePath()); + IFile ifile = ResourcesPlugin.getWorkspace().getRoot() + .getFile(path); + if (langService.isLanguageFile(ifile)) { + machineList.addEntry(new MachineEntry(ifile, langID)); + } + + } + + } + + } + + tableViewer.setInput(machineList.getChildren()); + + } + + private boolean resourceExistsInProject(String resourceName) { + IFile f = selectedProject.getFile(resourceName + "." + + BMotionEditorPlugin.FILEEXT_STUDIO); + return f.exists(); + } + + public void validateInput() { + StringBuffer errorMessages = new StringBuffer(150); + + if (getProjectRoot().length() == 0) { + errorMessages.append("The Project name must not be empty.\n"); + } + + if (getBMotionProjectName().length() == 0) { + errorMessages + .append("The BMotion Studio Visualization filename must not be empty.\n"); + } + + // if (errorMessages.length() == 0) { + // rodinProject = RodinCore.getRodinDB().getRodinProject( + // getProjectRoot().replaceAll("/", "")); + // + // if (!rodinProject.exists()) { + // errorMessages.append("The Project '" + getProjectRoot() + // + "' does not exist.\n"); + // } + // } + + if (getSelectedEntry() == null) { + errorMessages.append("You have to select a Machine.\n"); + } + + if (errorMessages.length() == 0 + && resourceExistsInProject(getBMotionProjectName())) { + errorMessages + .append("The BMotion Studio Visualization filename must be unique in a project.\n"); + } + + if (errorMessages.length() > 0) { + setErrorMessage(errorMessages.toString()); + setPageComplete(false); + } else { + setErrorMessage(null); + setPageComplete(true); + } + } + + public void createControl(final Composite parent) { + final Composite container = new Composite(parent, SWT.NULL); + + final GridLayout layout = new GridLayout(); + container.setLayout(layout); + + layout.numColumns = 3; + layout.verticalSpacing = 20; + + setControl(container); + + final ModifyListener listener = new ModifyListener() { + public void modifyText(final ModifyEvent e) { + validateInput(); + } + }; + + GridData gd = new GridData(); + gd.horizontalAlignment = SWT.FILL; + gd.grabExcessHorizontalSpace = true; + + Label label = new Label(container, SWT.NULL); + label.setText("&Project folder:"); + + projectRootText = new Text(container, SWT.BORDER | SWT.SINGLE); + projectRootText.setLayoutData(gd); + if (selectedProject != null) { + projectRootText.setText(selectedProject.getFullPath().toOSString()); + } + projectRootText.setEditable(false); + projectRootText.addModifyListener(listener); + + final Button button = new Button(container, SWT.NULL); + button.setText("Browse..."); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + final ContainerSelectionDialog dialog = new ContainerSelectionDialog( + getShell(), ResourcesPlugin.getWorkspace().getRoot(), + false, "Select Project"); + if (dialog.open() == Window.OK) { + final Object[] result = dialog.getResult(); + if (result.length == 1) { + Path newPath = (Path) result[0]; + IProject newProject = ResourcesPlugin.getWorkspace() + .getRoot().getProject(newPath.toString()); + selectedProject = newProject; + initContent(); + projectRootText.setText(((Path) result[0]).toOSString()); + validateInput(); + } + } + } + }); + + label = new Label(container, SWT.NULL); + label.setText("&Project name:"); + + projectText = new Text(container, SWT.BORDER | SWT.SINGLE); + projectText.setText(DEFAULT_PROJECT_NAME); + projectText.setLayoutData(gd); + projectText.addModifyListener(listener); + + gd = new GridData(); + gd.verticalAlignment = SWT.BEGINNING; + gd.horizontalSpan = 3; + + label = new Label(container, SWT.NULL); + label.setText("&Formal model:"); + label.setLayoutData(gd); + + gd = new GridData(GridData.FILL_VERTICAL); + gd.horizontalAlignment = SWT.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalSpan = 3; + + tableViewer = new TableViewer(container, SWT.SINGLE + | SWT.FULL_SELECTION); + final Table table = tableViewer.getTable(); + table.setHeaderVisible(true); + table.setLinesVisible(true); + table.setLayoutData(gd); + + final String[] columnsNames = new String[] { "Model", "Language" }; + final int[] columnWidths = new int[] { 250, 100 }; + final int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT }; + + for (int i = 0; i < columnsNames.length; i++) { + final TableColumn tableColumn = new TableColumn(table, + columnAlignments[i]); + tableColumn.setText(columnsNames[i]); + tableColumn.setWidth(columnWidths[i]); + } + + tableViewer.setLabelProvider(new MachineLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + initContent(); + + tableViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) event + .getSelection(); + selectedEntry = (MachineEntry) selection + .getFirstElement(); + validateInput(); + } + }); + + validateInput(); + + } + + private static class MachineLabelProvider extends LabelProvider implements + ITableLabelProvider { + + public Image getColumnImage(final Object element, final int columnIndex) { + return null; + } + + public String getColumnText(final Object element, final int columnIndex) { + if (element instanceof MachineEntry) { + + final MachineEntry currentEntry = (MachineEntry) element; + + switch (columnIndex) { + case 0: + return currentEntry.getMachineName(); + case 1: + return currentEntry.getMachineLanguage(); + } + + } + + return null; + } + + } + + private static class MachineList { + private final ArrayList<MachineEntry> entries = new ArrayList<MachineEntry>(); + + public MachineEntry[] getChildren() { + return entries.toArray(new MachineEntry[entries.size()]); + } + + public void addEntry(final MachineEntry entry) { + if (!entries.contains(entry)) { + entries.add(entry); + } + } + + public void clearList() { + this.entries.clear(); + } + + } + + private static class MachineEntry { + + private final String machineName; + private final String machineLanguage; + private final IFile file; + + public MachineEntry(IFile file, String machineLanguage) { + this.file = file; + this.machineName = file.getName(); + this.machineLanguage = machineLanguage; + } + + public String getMachineName() { + return this.machineName; + } + + public String getMachineLanguage() { + return this.machineLanguage; + } + + public IFile getMachineFile() { + return this.file; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveEditFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveEditFactory.java index cbef8d7e70d7766dbe2afcffd33e753470dba99b..2603fee362ae80c07df25e5b1caf8e9e4f367193 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveEditFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveEditFactory.java @@ -1,43 +1,43 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -import de.bmotionstudio.gef.editor.library.LibraryView; - -public class PerspectiveEditFactory implements IPerspectiveFactory { - - public void createInitialLayout(final IPageLayout layout) { - - final String editorArea = layout.getEditorArea(); - - // Place the project explorer to left of editor area. - final IFolderLayout left = layout.createFolder("left", - IPageLayout.LEFT, 0.15f, editorArea); - left.addView("fr.systerel.explorer.navigator.view"); - - // Place the outline to right of editor area. - final IFolderLayout righttop = layout.createFolder("right", - IPageLayout.RIGHT, 0.8f, editorArea); - righttop.addView(IPageLayout.ID_OUTLINE); - - // Library view - final IFolderLayout rightbot = layout.createFolder("rightb", - IPageLayout.BOTTOM, 0.6f, "right"); - rightbot.addView(LibraryView.ID); - - final IFolderLayout bottom = layout.createFolder("bottom", - IPageLayout.BOTTOM, 0.75f, editorArea); - // Properties view - bottom.addView(IPageLayout.ID_PROP_SHEET); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +import de.bmotionstudio.gef.editor.library.LibraryView; + +public class PerspectiveEditFactory implements IPerspectiveFactory { + + public void createInitialLayout(final IPageLayout layout) { + + final String editorArea = layout.getEditorArea(); + + // Place the project explorer to left of editor area. + final IFolderLayout left = layout.createFolder("left", + IPageLayout.LEFT, 0.15f, editorArea); + left.addView("fr.systerel.explorer.navigator.view"); + + // Place the outline to right of editor area. + final IFolderLayout righttop = layout.createFolder("right", + IPageLayout.RIGHT, 0.8f, editorArea); + righttop.addView(IPageLayout.ID_OUTLINE); + + // Library view + final IFolderLayout rightbot = layout.createFolder("rightb", + IPageLayout.BOTTOM, 0.6f, "right"); + rightbot.addView(LibraryView.ID); + + final IFolderLayout bottom = layout.createFolder("bottom", + IPageLayout.BOTTOM, 0.75f, editorArea); + // Properties view + bottom.addView(IPageLayout.ID_PROP_SHEET); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveRunFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveRunFactory.java index cc52fd79fcf9ef27a191d0651191f5c2492f8aaf..7586a12d5e625a3928e1ff3346fe7a7e5640c0d6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveRunFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/PerspectiveRunFactory.java @@ -1,43 +1,43 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -public class PerspectiveRunFactory implements IPerspectiveFactory { - - public void createInitialLayout(IPageLayout layout) { - - String editorArea = layout.getEditorArea(); - - // ProB Event View (Top-Left) - IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, - 0.15f, editorArea); - left.addView("de.prob.ui.OperationView"); - - // Navigator + Rodin Problem View (Bottom-Left) - IFolderLayout leftb = layout.createFolder("leftb", IPageLayout.BOTTOM, - 0.6f, "left"); - leftb.addView("fr.systerel.explorer.navigator.view"); - // leftb.addView("org.eventb.ui.views.RodinProblemView"); - - // ProB State View (Right) - IFolderLayout right1 = layout.createFolder("right1", IPageLayout.RIGHT, - 0.7f, editorArea); - right1.addView("de.prob.ui.StateView"); - - // ProB History + ProB Event Error View (Right) - IFolderLayout right2 = layout.createFolder("right2", IPageLayout.RIGHT, - 0.6f, "right1"); - right2.addView("de.prob.ui.HistoryView"); - right2.addView("de.prob.ui.EventErrorView"); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class PerspectiveRunFactory implements IPerspectiveFactory { + + public void createInitialLayout(IPageLayout layout) { + + String editorArea = layout.getEditorArea(); + + // ProB Event View (Top-Left) + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, + 0.15f, editorArea); + left.addView("de.prob.ui.OperationView"); + + // Navigator + Rodin Problem View (Bottom-Left) + IFolderLayout leftb = layout.createFolder("leftb", IPageLayout.BOTTOM, + 0.6f, "left"); + leftb.addView("fr.systerel.explorer.navigator.view"); + // leftb.addView("org.eventb.ui.views.RodinProblemView"); + + // ProB State View (Right) + IFolderLayout right1 = layout.createFolder("right1", IPageLayout.RIGHT, + 0.7f, editorArea); + right1.addView("de.prob.ui.StateView"); + + // ProB History + ProB Event Error View (Right) + IFolderLayout right2 = layout.createFolder("right2", IPageLayout.RIGHT, + 0.6f, "right1"); + right2.addView("de.prob.ui.HistoryView"); + right2.addView("de.prob.ui.EventErrorView"); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/ProgressBarDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/ProgressBarDialog.java index 693325bff2e39393221139a49131b5f524a2a811..6c9139acd4a2c6ce83c321bfa5a8957abffc8f1d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/ProgressBarDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/ProgressBarDialog.java @@ -21,14 +21,14 @@ import de.bmotionstudio.gef.editor.EditorImageRegistry; public abstract class ProgressBarDialog extends Dialog { - private Label processMessageLabel; // info of process finish - private Button cancelButton; // cancel button + private Label processMessageLabel; // info of process finish + private Button cancelButton; // cancel button private Composite cancelComposite; - private Composite progressBarComposite;// - private CLabel message;// - private ProgressBar progressBar = null; // + private Composite progressBarComposite;// + private CLabel message;// + private ProgressBar progressBar = null; // - private Shell shell; // + private Shell shell; // public Shell getShell() { return shell; @@ -36,15 +36,15 @@ public abstract class ProgressBarDialog extends Dialog { private Display display = null; - protected volatile boolean isClosed = false;// closed state + protected volatile boolean isClosed = false;// closed state - protected int executeTime = 50;// process times - protected String processMessage = "process......";// procress info - protected String shellTitle = "Progress..."; // + protected int executeTime = 50;// process times + protected String processMessage = "process......";// procress info + protected String shellTitle = "Progress..."; // protected Image processImage = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_LOADING);// image - protected boolean mayCancel = true; // cancel - protected int processBarStyle = SWT.SMOOTH; // process bar style + .getImage(EditorImageRegistry.IMG_ICON_LOADING);// image + protected boolean mayCancel = true; // cancel + protected int processBarStyle = SWT.SMOOTH; // process bar style protected ProcessThread currentThread; @@ -75,11 +75,11 @@ public abstract class ProgressBarDialog extends Dialog { public abstract void initGuage(); public void open() { - createContents(); // create window + createContents(); // create window shell.open(); shell.layout(); - // start work + // start work currentThread = new ProcessThread(executeTime); currentThread.start(); @@ -118,7 +118,7 @@ public abstract class ProgressBarDialog extends Dialog { fd.right = new FormAttachment(100, -5); fd.bottom = new FormAttachment(100, -10); - // Cancel button + // Cancel button cancelComposite = new Composite(shell, SWT.NONE); final GridLayout gridLayout_1 = new GridLayout(); gridLayout_1.numColumns = 2; @@ -163,7 +163,7 @@ public abstract class ProgressBarDialog extends Dialog { fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(progressBarComposite, -5); - // Message label + // Message label message = new CLabel(shell, SWT.NONE); message.setLayoutData(fd); message.setImage(processImage); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/SelectOperationDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/SelectOperationDialog.java index 3f65f2ac5918321df5b2915b28c36e599aee679d..60b4903ffa1b173a49acc21c4ec79957ba3fd58e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/SelectOperationDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/SelectOperationDialog.java @@ -1,105 +1,105 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import de.prob.core.domainobjects.Operation; - -public class SelectOperationDialog extends Dialog { - - private List<Operation> ops; - private Operation selectedOperation; - // private ComboViewer cb; - private ListViewer listViewer; - - protected SelectOperationDialog(Shell parentShell, List<Operation> ops) { - super(parentShell); - this.ops = ops; - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite container = (Composite) super.createDialogArea(parent); - - GridLayout gl = new GridLayout(2, false); - gl.marginLeft = 15; - gl.marginTop = 20; - - container.setLayout(gl); - - Label lb = new Label(container, SWT.NONE); - lb.setText("Select an operation:"); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - listViewer = new ListViewer(container); - listViewer.setContentProvider(new ArrayContentProvider()); - listViewer.setInput(ops); - listViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); - - // cb = new ComboViewer(container, SWT.NONE); - // cb.setContentProvider(new ArrayContentProvider()); - // cb.setInput(ops); - // cb.getCombo().setLayoutData(new GridData(200, 20)); - // cb.getCombo() - // .setFont( - // JFaceResources.getFontRegistry().get( - // BasicUtils.RODIN_FONT_KEY)); - - return container; - - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("Please select an operation ..."); - } - - @Override - protected Point getInitialSize() { - return new Point(600, 250); - } - - @Override - protected void okPressed() { - - IStructuredSelection selection = (IStructuredSelection) listViewer - .getSelection(); - selectedOperation = (Operation) selection.getFirstElement(); - - if (selectedOperation == null) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An error occurred", "Please select an operation ..."); - return; - } else { - setReturnCode(OK); - close(); - } - - } - - public Operation getSelectedOperation() { - return this.selectedOperation; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +import de.prob.core.domainobjects.Operation; + +public class SelectOperationDialog extends Dialog { + + private List<Operation> ops; + private Operation selectedOperation; + // private ComboViewer cb; + private ListViewer listViewer; + + protected SelectOperationDialog(Shell parentShell, List<Operation> ops) { + super(parentShell); + this.ops = ops; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + + GridLayout gl = new GridLayout(2, false); + gl.marginLeft = 15; + gl.marginTop = 20; + + container.setLayout(gl); + + Label lb = new Label(container, SWT.NONE); + lb.setText("Select an event:"); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + listViewer = new ListViewer(container); + listViewer.setContentProvider(new ArrayContentProvider()); + listViewer.setInput(ops); + listViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); + + // cb = new ComboViewer(container, SWT.NONE); + // cb.setContentProvider(new ArrayContentProvider()); + // cb.setInput(ops); + // cb.getCombo().setLayoutData(new GridData(200, 20)); + // cb.getCombo() + // .setFont( + // JFaceResources.getFontRegistry().get( + // BasicUtils.RODIN_FONT_KEY)); + + return container; + + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Please select an event ..."); + } + + @Override + protected Point getInitialSize() { + return new Point(600, 250); + } + + @Override + protected void okPressed() { + + IStructuredSelection selection = (IStructuredSelection) listViewer + .getSelection(); + selectedOperation = (Operation) selection.getFirstElement(); + + if (selectedOperation == null) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An error occurred", "Please select an event ..."); + return; + } else { + setReturnCode(OK); + close(); + } + + } + + public Operation getSelectedOperation() { + return this.selectedOperation; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/VisualizationProgressBar.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/VisualizationProgressBar.java index 70ee9ce5129299210a7d579009c6f02ab2dba118..86c289130241ed7983ae5a33ca6c7f7f68e48361 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/VisualizationProgressBar.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/VisualizationProgressBar.java @@ -1,286 +1,286 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.internal; - -import java.io.IOException; -import java.util.List; -import java.util.Locale; - -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.xml.sax.SAXException; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.mapper.MapperWrapper; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioEditor; -import de.bmotionstudio.gef.editor.ILanguageService; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.prob.core.Animator; -import de.prob.core.command.ExecuteOperationCommand; -import de.prob.core.domainobjects.Operation; -import de.prob.exceptions.ProBException; - -public class VisualizationProgressBar extends ProgressBarDialog { - - private Animator animator; - private IFile f; - private Visualization visualization; - private Animation animation; - private int confirm = -1; - private SelectOperationDialog dialog; - private BMotionStudioEditor activeEditor; - - public VisualizationProgressBar(Shell parent, Animator animator, - BMotionStudioEditor activeEditor, IFile f) { - super(parent); - this.animator = animator; - this.activeEditor = activeEditor; - this.f = f; - } - - @Override - public void initGuage() { - this.setExecuteTime(6); - this.setMayCancel(true); - this.setProcessMessage("Starting Visualization ..."); - this.setShellTitle("Starting Visualization"); - } - - @Override - protected String process(int i) { - - switch (i) { - case 1: - try { - createVisualizationRoot(); - } catch (CoreException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } catch (IOException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } catch (ParserConfigurationException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } catch (SAXException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - return "Starting ProB Animator"; - case 2: - startProbAnimator(); - return "Setup Constants"; - case 3: - try { - setupOperation("SETUP_CONTEXT"); - } catch (InterruptedException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - return "Create Visualization"; - case 4: - Display.getDefault().asyncExec(new Runnable() { - public void run() { - createShell(); - } - }); - return "Initialize machine"; - case 5: - try { - setupOperation("INITIALISATION"); - } catch (InterruptedException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - return "Starting Visualization"; - } - - return "Starting BMotion Studio Visualization"; - - } - - // private void startOperationScheduler() { - // visualization.startOperationScheduler(); - // } - - private void createVisualizationRoot() throws CoreException, IOException, - ParserConfigurationException, SAXException { - XStream xstream = new XStream(new DomDriver()) { - @Override - protected MapperWrapper wrapMapper(MapperWrapper next) { - return new MapperWrapper(next) { - @Override - public boolean shouldSerializeMember( - @SuppressWarnings("rawtypes") Class definedIn, - String fieldName) { - if (definedIn == Object.class) { - return false; - } - return super - .shouldSerializeMember(definedIn, fieldName); - } - }; - } - }; - BMotionEditorPlugin.setAliases(xstream); - visualization = (Visualization) xstream.fromXML(f.getContents()); - visualization.setProjectFile(f); - } - - @Override - protected void cleanUp() { - if (animation != null) - animation.unregister(); - } - - private void startProbAnimator() { - animation = new Animation(animator, visualization); - ILanguageService langService = getGenericLoadMachine(visualization - .getLanguage()); - if (langService != null) { - try { - langService.startProBAnimator(visualization); - } catch (ProBException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - } else { - openErrorDialog("Unknown formal language: " - + visualization.getLanguage()); - setClose(true); - } - } - - private void setupOperation(String opName) throws InterruptedException { - - final List<Operation> ops = animation.getState().getEnabledOperations(); - - if (ops.size() > 1) { - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - dialog = new SelectOperationDialog(getShell(), ops); - confirm = dialog.open(); - } - }); - - while (true) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - - if (confirm == Window.OK) { - Operation op = dialog.getSelectedOperation(); - if (op != null) - try { - ExecuteOperationCommand.executeOperation(animator, - op); - } catch (ProBException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - confirm = -1; - break; - } else if (confirm == Window.CANCEL) { - setClose(true); - confirm = -1; - break; - } - - } - - } else { - Operation op = animation.getCurrentStateOperation(opName); - if (op != null) - try { - ExecuteOperationCommand.executeOperation(animator, op); - } catch (ProBException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - } - - visualization.setIsRunning(true); - - } - - private void createShell() { - activeEditor.createRunPage(visualization, animation); - } - - private ILanguageService getGenericLoadMachine(String language) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry - .getExtensionPoint("de.bmotionstudio.gef.editor.language"); - ILanguageService langService = null; - - // Get GenericLoadMachine command for language - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("language".equals(configurationElement.getName())) { - - String languageEx = configurationElement.getAttribute("id"); - if (language.toLowerCase(Locale.ENGLISH).equals( - languageEx.toLowerCase(Locale.ENGLISH))) { - - try { - langService = (ILanguageService) configurationElement - .createExecutableExtension("service"); - } catch (final CoreException e) { - openErrorDialog(e.getMessage()); - setClose(true); - } - - } - - } - - } - } - return langService; - } - - public void kill() { - // if (shell != null) - // if (shell.getShell() != null) - // shell.getShell().dispose(); - } - - public void openErrorDialog(final String msg) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - ErrorDialog.openError(getParent(), "Error", - "Error creating visualization", new Status( - IStatus.ERROR, BMotionEditorPlugin.PLUGIN_ID, - msg)); - } - }); - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.internal; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; + +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.xml.sax.SAXException; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.DomDriver; +import com.thoughtworks.xstream.mapper.MapperWrapper; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioEditor; +import de.bmotionstudio.gef.editor.ILanguageService; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.prob.core.Animator; +import de.prob.core.command.ExecuteOperationCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.exceptions.ProBException; + +public class VisualizationProgressBar extends ProgressBarDialog { + + private Animator animator; + private IFile f; + private Visualization visualization; + private Animation animation; + private int confirm = -1; + private SelectOperationDialog dialog; + private BMotionStudioEditor activeEditor; + + public VisualizationProgressBar(Shell parent, Animator animator, + BMotionStudioEditor activeEditor, IFile f) { + super(parent); + this.animator = animator; + this.activeEditor = activeEditor; + this.f = f; + } + + @Override + public void initGuage() { + this.setExecuteTime(6); + this.setMayCancel(true); + this.setProcessMessage("Starting Visualization ..."); + this.setShellTitle("Starting Visualization"); + } + + @Override + protected String process(int i) { + + switch (i) { + case 1: + try { + createVisualizationRoot(); + } catch (CoreException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } catch (IOException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } catch (ParserConfigurationException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } catch (SAXException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + return "Starting ProB Animator"; + case 2: + startProbAnimator(); + return "Setup Constants"; + case 3: + try { + setupOperation("SETUP_CONTEXT"); + } catch (InterruptedException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + return "Create Visualization"; + case 4: + Display.getDefault().asyncExec(new Runnable() { + public void run() { + createShell(); + } + }); + return "Initialize machine"; + case 5: + try { + setupOperation("INITIALISATION"); + } catch (InterruptedException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + return "Starting Visualization"; + } + + return "Starting BMotion Studio Visualization"; + + } + + // private void startOperationScheduler() { + // visualization.startOperationScheduler(); + // } + + private void createVisualizationRoot() throws CoreException, IOException, + ParserConfigurationException, SAXException { + XStream xstream = new XStream(new DomDriver()) { + @Override + protected MapperWrapper wrapMapper(MapperWrapper next) { + return new MapperWrapper(next) { + @Override + public boolean shouldSerializeMember( + @SuppressWarnings("rawtypes") Class definedIn, + String fieldName) { + if (definedIn == Object.class) { + return false; + } + return super + .shouldSerializeMember(definedIn, fieldName); + } + }; + } + }; + BMotionEditorPlugin.setAliases(xstream); + visualization = (Visualization) xstream.fromXML(f.getContents()); + visualization.setProjectFile(f); + } + + @Override + protected void cleanUp() { + if (animation != null) + animation.unregister(); + } + + private void startProbAnimator() { + animation = new Animation(animator, visualization); + ILanguageService langService = getGenericLoadMachine(visualization + .getLanguage()); + if (langService != null) { + try { + langService.startProBAnimator(visualization); + } catch (ProBException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + } else { + openErrorDialog("Unknown formal language: " + + visualization.getLanguage()); + setClose(true); + } + } + + private void setupOperation(String opName) throws InterruptedException { + + final List<Operation> ops = animation.getState().getEnabledOperations(); + + if (ops.size() > 1) { + + Display.getDefault().asyncExec(new Runnable() { + public void run() { + dialog = new SelectOperationDialog(getShell(), ops); + confirm = dialog.open(); + } + }); + + while (true) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + + if (confirm == Window.OK) { + Operation op = dialog.getSelectedOperation(); + if (op != null) + try { + ExecuteOperationCommand.executeOperation(animator, + op); + } catch (ProBException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + confirm = -1; + break; + } else if (confirm == Window.CANCEL) { + setClose(true); + confirm = -1; + break; + } + + } + + } else { + Operation op = animation.getCurrentStateOperation(opName); + if (op != null) + try { + ExecuteOperationCommand.executeOperation(animator, op); + } catch (ProBException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + } + + visualization.setIsRunning(true); + + } + + private void createShell() { + activeEditor.createRunPage(visualization, animation); + } + + private ILanguageService getGenericLoadMachine(String language) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry + .getExtensionPoint("de.bmotionstudio.gef.editor.language"); + ILanguageService langService = null; + + // Get GenericLoadMachine command for language + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("language".equals(configurationElement.getName())) { + + String languageEx = configurationElement.getAttribute("id"); + if (language.toLowerCase(Locale.ENGLISH).equals( + languageEx.toLowerCase(Locale.ENGLISH))) { + + try { + langService = (ILanguageService) configurationElement + .createExecutableExtension("service"); + } catch (final CoreException e) { + openErrorDialog(e.getMessage()); + setClose(true); + } + + } + + } + + } + } + return langService; + } + + public void kill() { + // if (shell != null) + // if (shell.getShell() != null) + // shell.getShell().dispose(); + } + + public void openErrorDialog(final String msg) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + ErrorDialog.openError(getParent(), "Error", + "Error creating visualization", new Status( + IStatus.ERROR, BMotionEditorPlugin.PLUGIN_ID, + msg)); + } + }); + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryAction.java index 9ba118c5c77502911854349ce0aa1c17b743516e..83ea31668a6ff148f122a9c74104fa67b3170248 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryAction.java @@ -1,28 +1,28 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.jface.action.Action; - - -public class AbstractLibraryAction extends Action { - - private LibraryPage page; - - public AbstractLibraryAction(LibraryPage page) { - this.page = page; - } - - public void setPage(LibraryPage page) { - this.page = page; - } - - public LibraryPage getPage() { - return page; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.jface.action.Action; + + +public class AbstractLibraryAction extends Action { + + private LibraryPage page; + + public AbstractLibraryAction(LibraryPage page) { + this.page = page; + } + + public void setPage(LibraryPage page) { + this.page = page; + } + + public LibraryPage getPage() { + return page; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryCommand.java index 3e6f5cb1a0c6871708f170aed81eb402e15a56e8..e27bf03657bad262315426beb98fcab6f910ca8b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AbstractLibraryCommand.java @@ -1,66 +1,66 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; - -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * @author Lukas Ladenberger - * - */ -public abstract class AbstractLibraryCommand extends Command { - - protected EditPart editPart; - protected AttributeTransferObject transferObject; - protected String attributeName; - protected Object attributeValue; - protected Object oldAttributeValue; - protected Point dropLocation; - - public boolean canExecute() { - return true; - } - - public void setEditPart(EditPart editPart) { - this.editPart = editPart; - } - - public EditPart getEditPart() { - return this.editPart; - } - - public void undo() { - if (attributeName != null) - getCastedModel() - .setAttributeValue(attributeName, oldAttributeValue); - } - - public void setAttributeTransferObject( - AttributeTransferObject transferObject) { - this.transferObject = transferObject; - } - - public AttributeTransferObject getAttributeTransferObject() { - return this.transferObject; - } - - public Point getDropLocation() { - return dropLocation; - } - - public void setDropLocation(Point dropLocation) { - this.dropLocation = dropLocation; - } - - protected BControl getCastedModel() { - return (BControl) editPart.getModel(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; + +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * @author Lukas Ladenberger + * + */ +public abstract class AbstractLibraryCommand extends Command { + + protected EditPart editPart; + protected AttributeTransferObject transferObject; + protected String attributeName; + protected Object attributeValue; + protected Object oldAttributeValue; + protected Point dropLocation; + + public boolean canExecute() { + return true; + } + + public void setEditPart(EditPart editPart) { + this.editPart = editPart; + } + + public EditPart getEditPart() { + return this.editPart; + } + + public void undo() { + if (attributeName != null) + getCastedModel() + .setAttributeValue(attributeName, oldAttributeValue); + } + + public void setAttributeTransferObject( + AttributeTransferObject transferObject) { + this.transferObject = transferObject; + } + + public AttributeTransferObject getAttributeTransferObject() { + return this.transferObject; + } + + public Point getDropLocation() { + return dropLocation; + } + + public void setDropLocation(Point dropLocation) { + this.dropLocation = dropLocation; + } + + protected BControl getCastedModel() { + return (BControl) editPart.getModel(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeRequest.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeRequest.java index 11837177d96a10a13bad7225f975c1e05ae9564b..5f4d150bc8dc46e964954123c52166b6189ba265 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeRequest.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeRequest.java @@ -1,39 +1,39 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.Request; - - -public class AttributeRequest extends Request { - - private AttributeTransferObject attributeTransferObject; - private Point dropLocation; - - public Point getDropLocation() { - return this.dropLocation; - } - - public void setDropLocation(Point dropLocation) { - this.dropLocation = dropLocation; - } - - public AttributeRequest() { - super("change attribute"); - } - - public void setAttributeTransferObject( - AttributeTransferObject attributeTransferObject) { - this.attributeTransferObject = attributeTransferObject; - } - - public AttributeTransferObject getAttributeTransferObject() { - return attributeTransferObject; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.Request; + + +public class AttributeRequest extends Request { + + private AttributeTransferObject attributeTransferObject; + private Point dropLocation; + + public Point getDropLocation() { + return this.dropLocation; + } + + public void setDropLocation(Point dropLocation) { + this.dropLocation = dropLocation; + } + + public AttributeRequest() { + super("change attribute"); + } + + public void setAttributeTransferObject( + AttributeTransferObject attributeTransferObject) { + this.attributeTransferObject = attributeTransferObject; + } + + public AttributeTransferObject getAttributeTransferObject() { + return attributeTransferObject; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransfer.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransfer.java index 9c309696ea0e03f74c2c040f60a3441216ef1c83..fb310824371acf27e39310151d31e29727c68481 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransfer.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransfer.java @@ -1,41 +1,41 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.gef.dnd.SimpleObjectTransfer; - -public class AttributeTransfer extends SimpleObjectTransfer { - - private static final AttributeTransfer INSTANCE = new AttributeTransfer(); - private static final String TYPE_NAME = "Attribute transfer"//$NON-NLS-1$ - + System.currentTimeMillis() + ":" + INSTANCE.hashCode();//$NON-NLS-1$ - private static final int TYPEID = registerType(TYPE_NAME); - - /** - * @see org.eclipse.swt.dnd.Transfer#getTypeIds() - */ - protected int[] getTypeIds() { - return new int[] { TYPEID }; - } - - /** - * @see org.eclipse.swt.dnd.Transfer#getTypeNames() - */ - protected String[] getTypeNames() { - return new String[] { TYPE_NAME }; - } - - /** - * Returns the singleton instance - * - * @return the singleton - */ - public static AttributeTransfer getInstance() { - return INSTANCE; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.gef.dnd.SimpleObjectTransfer; + +public class AttributeTransfer extends SimpleObjectTransfer { + + private static final AttributeTransfer INSTANCE = new AttributeTransfer(); + private static final String TYPE_NAME = "Attribute transfer"//$NON-NLS-1$ + + System.currentTimeMillis() + ":" + INSTANCE.hashCode();//$NON-NLS-1$ + private static final int TYPEID = registerType(TYPE_NAME); + + /** + * @see org.eclipse.swt.dnd.Transfer#getTypeIds() + */ + protected int[] getTypeIds() { + return new int[] { TYPEID }; + } + + /** + * @see org.eclipse.swt.dnd.Transfer#getTypeNames() + */ + protected String[] getTypeNames() { + return new String[] { TYPE_NAME }; + } + + /** + * Returns the singleton instance + * + * @return the singleton + */ + public static AttributeTransfer getInstance() { + return INSTANCE; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferDropTargetListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferDropTargetListener.java index d65d146ed234a8de6a64a997341b8b19953b3030..31a2481d117b0be40ea5712b1b63cc620f7a0d89 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferDropTargetListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferDropTargetListener.java @@ -1,60 +1,60 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.dnd.AbstractTransferDropTargetListener; -import org.eclipse.swt.dnd.DND; -import org.eclipse.ui.IWorkbenchPart; - - -public class AttributeTransferDropTargetListener extends - AbstractTransferDropTargetListener { - - private IWorkbenchPart workbenchPart; - - public AttributeTransferDropTargetListener(EditPartViewer viewer, - IWorkbenchPart workbenchPart) { - super(viewer, AttributeTransfer.getInstance()); - this.workbenchPart = workbenchPart; - } - - @Override - protected void updateTargetRequest() { - } - - @Override - protected Request createTargetRequest() { - AttributeRequest req = new AttributeRequest(); - req.setDropLocation(getDropLocation()); - Object transferObject = AttributeTransfer.getInstance().getObject(); - if (transferObject instanceof AttributeTransferObject) - req - .setAttributeTransferObject((AttributeTransferObject) transferObject); - return req; - } - - @Override - protected void handleDragOperationChanged() { - getCurrentEvent().detail = DND.DROP_COPY; - super.handleDragOperationChanged(); - } - - @Override - protected void handleDragOver() { - getCurrentEvent().detail = DND.DROP_COPY; - super.handleDragOver(); - } - - @Override - protected void handleDrop() { - super.handleDrop(); - workbenchPart.setFocus(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.Request; +import org.eclipse.gef.dnd.AbstractTransferDropTargetListener; +import org.eclipse.swt.dnd.DND; +import org.eclipse.ui.IWorkbenchPart; + + +public class AttributeTransferDropTargetListener extends + AbstractTransferDropTargetListener { + + private IWorkbenchPart workbenchPart; + + public AttributeTransferDropTargetListener(EditPartViewer viewer, + IWorkbenchPart workbenchPart) { + super(viewer, AttributeTransfer.getInstance()); + this.workbenchPart = workbenchPart; + } + + @Override + protected void updateTargetRequest() { + } + + @Override + protected Request createTargetRequest() { + AttributeRequest req = new AttributeRequest(); + req.setDropLocation(getDropLocation()); + Object transferObject = AttributeTransfer.getInstance().getObject(); + if (transferObject instanceof AttributeTransferObject) + req + .setAttributeTransferObject((AttributeTransferObject) transferObject); + return req; + } + + @Override + protected void handleDragOperationChanged() { + getCurrentEvent().detail = DND.DROP_COPY; + super.handleDragOperationChanged(); + } + + @Override + protected void handleDragOver() { + getCurrentEvent().detail = DND.DROP_COPY; + super.handleDragOver(); + } + + @Override + protected void handleDrop() { + super.handleDrop(); + workbenchPart.setFocus(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferObject.java index cb714f3435fa96006796e16fd8fa962985512927..c5fc3c1777cc84718485246eb24b85115decca82 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/AttributeTransferObject.java @@ -1,26 +1,26 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - - -public class AttributeTransferObject { - - private LibraryObject libraryObject; - - public AttributeTransferObject(LibraryObject attributeValue) { - this.libraryObject = attributeValue; - } - - public void setLibraryObject(LibraryObject libraryObject) { - this.libraryObject = libraryObject; - } - - public LibraryObject getLibraryObject() { - return libraryObject; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + + +public class AttributeTransferObject { + + private LibraryObject libraryObject; + + public AttributeTransferObject(LibraryObject attributeValue) { + this.libraryObject = attributeValue; + } + + public void setLibraryObject(LibraryObject libraryObject) { + this.libraryObject = libraryObject; + } + + public LibraryObject getLibraryObject() { + return libraryObject; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/DeleteItemsAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/DeleteItemsAction.java index 5ccb2146d2e911dacd7399f13678de30e6601df7..8d31c9a57709cbabc51a7dfa18be9c905db56b41 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/DeleteItemsAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/DeleteItemsAction.java @@ -1,55 +1,55 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; - -public class DeleteItemsAction extends AbstractLibraryAction { - - public DeleteItemsAction(LibraryPage page) { - super(page); - setText("Delete selected items"); - setImageDescriptor(BMotionStudioImage.getImageDescriptor( - "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif")); - } - - @Override - public void run() { - - IStructuredSelection sel = (IStructuredSelection) getPage() - .getTableViewer().getSelection(); - Object[] lobjects = sel.toArray(); - - if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), - "Please confirm", "Do you realy want to delete these objects?")) { - - for (Object lobj : lobjects) { - ((LibraryObject) lobj).delete(getPage()); - } - - getPage().refresh(); - - try { - getPage().getEditor().getVisualization().getProjectFile() - .getProject().getProject().refreshLocal( - IResource.DEPTH_ONE, new NullProgressMonitor()); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; + +public class DeleteItemsAction extends AbstractLibraryAction { + + public DeleteItemsAction(LibraryPage page) { + super(page); + setText("Delete selected items"); + setImageDescriptor(BMotionStudioImage.getImageDescriptor( + "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif")); + } + + @Override + public void run() { + + IStructuredSelection sel = (IStructuredSelection) getPage() + .getTableViewer().getSelection(); + Object[] lobjects = sel.toArray(); + + if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), + "Please confirm", "Do you realy want to delete these objects?")) { + + for (Object lobj : lobjects) { + ((LibraryObject) lobj).delete(getPage()); + } + + getPage().refresh(); + + try { + getPage().getEditor().getVisualization().getProjectFile() + .getProject().getProject().refreshLocal( + IResource.DEPTH_ONE, new NullProgressMonitor()); + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/ImportImagesAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/ImportImagesAction.java index 24be5c8565e068727a7fa00746079c6c437cd9fe..b99001771afae3997a74d8ba9f6bd801fccbb4fd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/ImportImagesAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/ImportImagesAction.java @@ -1,101 +1,101 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.MessageBox; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; - -public class ImportImagesAction extends AbstractLibraryAction { - - public ImportImagesAction(LibraryPage page) { - super(page); - setText("Import images..."); - setImageDescriptor(BMotionStudioImage.getImageDescriptor( - "org.eclipse.ui", "$nl$/icons/full/etool16/import_wiz.gif")); - } - - @Override - public void run() { - - // The file dialog - FileDialog fd = new FileDialog(Display.getDefault().getActiveShell(), - SWT.OPEN | SWT.MULTI); - fd.setText("Open"); - fd.setFilterPath("C:/"); - String[] filterExt = { "*.jpg", "*.gif", "*.png", "*.*" }; - fd.setFilterExtensions(filterExt); - - fd.open(); - - // File path - String folderPath = fd.getFilterPath(); - - // Selected items - String[] selectedFiles = fd.getFileNames(); - - // The project file - IFile pFile = getPage().getEditor().getVisualization().getProjectFile(); - - try { - - IProject project = pFile.getProject(); - IFolder folder = project.getFolder("images"); - NullProgressMonitor monitor = new NullProgressMonitor(); - - if (!folder.exists()) - folder.create(true, true, monitor); - - // Iterate the selected files - for (String fileName : selectedFiles) { - - File inputFile = new File(folderPath + File.separator - + fileName); - IFile newFile = folder.getFile(fileName); - FileInputStream fileInputStream = new FileInputStream(inputFile); - - if (!newFile.exists()) { - newFile.create(fileInputStream, true, - monitor); - } else { - // The file already exists; asks for confirmation - MessageBox mb = new MessageBox(fd.getParent(), - SWT.ICON_WARNING | SWT.YES | SWT.NO); - mb.setMessage(fileName - + " already exists. Do you want to replace it?"); - // If they click Yes, we're done and we drop out. If - // they click No, we redisplay the File Dialog - if (mb.open() == SWT.YES) - newFile.setContents(fileInputStream, true, false, - monitor); - } - - } - - } catch (CoreException e1) { - e1.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - getPage().refresh(); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.MessageBox; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; + +public class ImportImagesAction extends AbstractLibraryAction { + + public ImportImagesAction(LibraryPage page) { + super(page); + setText("Import images..."); + setImageDescriptor(BMotionStudioImage.getImageDescriptor( + "org.eclipse.ui", "$nl$/icons/full/etool16/import_wiz.gif")); + } + + @Override + public void run() { + + // The file dialog + FileDialog fd = new FileDialog(Display.getDefault().getActiveShell(), + SWT.OPEN | SWT.MULTI); + fd.setText("Open"); + fd.setFilterPath("C:/"); + String[] filterExt = { "*.jpg", "*.gif", "*.png", "*.*" }; + fd.setFilterExtensions(filterExt); + + fd.open(); + + // File path + String folderPath = fd.getFilterPath(); + + // Selected items + String[] selectedFiles = fd.getFileNames(); + + // The project file + IFile pFile = getPage().getEditor().getVisualization().getProjectFile(); + + try { + + IProject project = pFile.getProject(); + IFolder folder = project.getFolder("images"); + NullProgressMonitor monitor = new NullProgressMonitor(); + + if (!folder.exists()) + folder.create(true, true, monitor); + + // Iterate the selected files + for (String fileName : selectedFiles) { + + File inputFile = new File(folderPath + File.separator + + fileName); + IFile newFile = folder.getFile(fileName); + FileInputStream fileInputStream = new FileInputStream(inputFile); + + if (!newFile.exists()) { + newFile.create(fileInputStream, true, + monitor); + } else { + // The file already exists; asks for confirmation + MessageBox mb = new MessageBox(fd.getParent(), + SWT.ICON_WARNING | SWT.YES | SWT.NO); + mb.setMessage(fileName + + " already exists. Do you want to replace it?"); + // If they click Yes, we're done and we drop out. If + // they click No, we redisplay the File Dialog + if (mb.open() == SWT.YES) + newFile.setContents(fileInputStream, true, false, + monitor); + } + + } + + } catch (CoreException e1) { + e1.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + getPage().refresh(); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageCommand.java index 2ff5c604982f9d11040a07c6aa138b5e98fe46b8..d162f773743da8b732770ecb893a9b553178a6a8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageCommand.java @@ -1,83 +1,83 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import java.io.File; - -import org.eclipse.core.resources.IFile; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.command.CreateCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BImage; - -public class LibraryImageCommand extends AbstractLibraryCommand { - - private BControl newImageControl; - - public void execute() { - - attributeName = AttributeConstants.ATTRIBUTE_IMAGE; - attributeValue = transferObject.getLibraryObject().getName(); - oldAttributeValue = getCastedModel().getAttributeValue(attributeName); - - if (getCastedModel().canHaveChildren()) { - - newImageControl = new BImage(getCastedModel().getVisualization()); - newImageControl.setAttributeValue(attributeName, attributeValue); - - CreateCommand createCommand = new CreateCommand( - newImageControl, getCastedModel()); - - String imagePath = attributeValue.toString(); - - org.eclipse.swt.graphics.Rectangle imageBounds = null; - Image img = null; - - IFile pFile = getCastedModel().getVisualization().getProjectFile(); - - Rectangle fRect = new Rectangle(getDropLocation().x - - getCastedModel().getLocation().x, getDropLocation().y - - getCastedModel().getLocation().y, 100, 100); - - if (pFile != null) { - final String myPath = (pFile.getProject().getLocation() - + "/images/" + imagePath).replace("file:", ""); - if (new File(myPath).exists() && imagePath.length() > 0) { - img = new Image(Display.getCurrent(), myPath); - imageBounds = img.getBounds(); - } - } - - if (imageBounds != null) { - fRect.width = imageBounds.width; - fRect.height = imageBounds.height; - } - - createCommand.setLayout(fRect); - createCommand.execute(); - - } else { - - if (getCastedModel().hasAttribute( - AttributeConstants.ATTRIBUTE_IMAGE)) - getCastedModel().setAttributeValue(attributeName, - attributeValue); - - } - - } - - public void undo() { - super.undo(); - getCastedModel().removeChild(newImageControl); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import java.io.File; + +import org.eclipse.core.resources.IFile; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.command.CreateCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BImage; + +public class LibraryImageCommand extends AbstractLibraryCommand { + + private BControl newImageControl; + + public void execute() { + + attributeName = AttributeConstants.ATTRIBUTE_IMAGE; + attributeValue = transferObject.getLibraryObject().getName(); + oldAttributeValue = getCastedModel().getAttributeValue(attributeName); + + if (getCastedModel().canHaveChildren()) { + + newImageControl = new BImage(getCastedModel().getVisualization()); + newImageControl.setAttributeValue(attributeName, attributeValue); + + CreateCommand createCommand = new CreateCommand( + newImageControl, getCastedModel()); + + String imagePath = attributeValue.toString(); + + org.eclipse.swt.graphics.Rectangle imageBounds = null; + Image img = null; + + IFile pFile = getCastedModel().getVisualization().getProjectFile(); + + Rectangle fRect = new Rectangle(getDropLocation().x + - getCastedModel().getLocation().x, getDropLocation().y + - getCastedModel().getLocation().y, 100, 100); + + if (pFile != null) { + final String myPath = (pFile.getProject().getLocation() + + "/images/" + imagePath).replace("file:", ""); + if (new File(myPath).exists() && imagePath.length() > 0) { + img = new Image(Display.getCurrent(), myPath); + imageBounds = img.getBounds(); + } + } + + if (imageBounds != null) { + fRect.width = imageBounds.width; + fRect.height = imageBounds.height; + } + + createCommand.setLayout(fRect); + createCommand.execute(); + + } else { + + if (getCastedModel().hasAttribute( + AttributeConstants.ATTRIBUTE_IMAGE)) + getCastedModel().setAttributeValue(attributeName, + attributeValue); + + } + + } + + public void undo() { + super.undo(); + getCastedModel().removeChild(newImageControl); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageObject.java index 3931e467070b0f1b4d637a63591fdddbc2741e5a..2da82325530bc925e39a588ab9d31e3f7e28a073 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryImageObject.java @@ -1,51 +1,51 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - -public class LibraryImageObject extends LibraryObject { - - public LibraryImageObject(String name, String type, Image typeImage) { - super(name, type, typeImage); - } - - @Override - public void delete(LibraryPage page) { - - try { - IFolder imageFolder = page.getEditor().getVisualization() - .getProjectFile().getProject().getFolder("images"); - if (imageFolder.exists()) { - IFile file = imageFolder.getFile(getName()); - if (file.exists()) - file.delete(true, new NullProgressMonitor()); - } - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - @Override - public Image getPreview(LibraryPage page) { - IFile pFile = page.getEditor().getVisualization().getProjectFile(); - if (pFile != null) { - String myPath = (pFile.getProject().getLocation() + "/images/" + getName()) - .replace("file:", ""); - return new Image(Display.getDefault(), myPath); - } else { - return null; - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +public class LibraryImageObject extends LibraryObject { + + public LibraryImageObject(String name, String type, Image typeImage) { + super(name, type, typeImage); + } + + @Override + public void delete(LibraryPage page) { + + try { + IFolder imageFolder = page.getEditor().getVisualization() + .getProjectFile().getProject().getFolder("images"); + if (imageFolder.exists()) { + IFile file = imageFolder.getFile(getName()); + if (file.exists()) + file.delete(true, new NullProgressMonitor()); + } + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + @Override + public Image getPreview(LibraryPage page) { + IFile pFile = page.getEditor().getVisualization().getProjectFile(); + if (pFile != null) { + String myPath = (pFile.getProject().getLocation() + "/images/" + getName()) + .replace("file:", ""); + return new Image(Display.getDefault(), myPath); + } else { + return null; + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryObject.java index d84a1cf87b4cbf5ede40061f826d4574808fc3b5..25ae33b0adc6efd18ccd05eb6e2c260401c7b590 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryObject.java @@ -1,54 +1,54 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.swt.graphics.Image; - -public class LibraryObject { - - private String name; - private String type; - private Image typeImage; - - public LibraryObject(String name, String type, Image typeImage) { - this.name = name; - this.type = type; - this.typeImage = typeImage; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public void setImage(Image image) { - this.typeImage = image; - } - - public Image getImage() { - return typeImage; - } - - public void delete(LibraryPage page) { - } - - public Image getPreview(LibraryPage page) { - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.swt.graphics.Image; + +public class LibraryObject { + + private String name; + private String type; + private Image typeImage; + + public LibraryObject(String name, String type, Image typeImage) { + this.name = name; + this.type = type; + this.typeImage = typeImage; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public void setImage(Image image) { + this.typeImage = image; + } + + public Image getImage() { + return typeImage; + } + + public void delete(LibraryPage page) { + } + + public Image getPreview(LibraryPage page) { + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java index 77752772e9e93264e19ccaac2069ff44b12d2890..5582fbbf7af11dcdb1884e62d081ac311f40cf29 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java @@ -1,310 +1,311 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DragSourceAdapter; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.part.Page; - -import de.bmotionstudio.gef.editor.BMotionStudioEditor; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; - -public class LibraryPage extends Page { - - private Image previewImage; - - private TableViewer tvLibrary; - - private Canvas previewCanvas; - - private Composite libMainContainer; - - private Action importImagesAction, deleteItemAction; - - private BMotionStudioEditor editor; - - public LibraryPage(final BMotionStudioEditor editor) { - this.editor = editor; - } - - @Override - public void createControl(final Composite parent) { - - libMainContainer = new Composite(parent, SWT.NONE); - - GridLayout gl = new GridLayout(1, true); - gl.horizontalSpacing = 0; - - libMainContainer.setLayout(gl); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalIndent = 0; - - previewCanvas = new Canvas(libMainContainer, SWT.BORDER); - previewCanvas.addPaintListener(new PaintListener() { - public void paintControl(final PaintEvent e) { - if (previewImage == null) { - e.gc.drawString("No preview...", 0, 0); - } else { - e.gc.drawImage(previewImage, 0, 0); - } - } - }); - previewCanvas.setLayoutData(gd); - - Composite libContainer = new Composite(libMainContainer, SWT.NONE); - libContainer.setLayoutData(gd); - libContainer.setLayout(new FillLayout()); - - tvLibrary = new TableViewer(libContainer, SWT.FULL_SELECTION - | SWT.V_SCROLL | SWT.MULTI); - tvLibrary.getTable().setLayoutData(gd); - tvLibrary.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(final SelectionChangedEvent event) { - - IStructuredSelection selection = (IStructuredSelection) event - .getSelection(); - - LibraryObject obj = (LibraryObject) selection.getFirstElement(); - - if (previewImage != null) { - previewImage.dispose(); - } - - if (obj != null) { - previewImage = obj.getPreview(LibraryPage.this); - } else { - previewImage = null; - } - - previewCanvas.redraw(); - - updateActionEnablement(); - - } - - }); - - tvLibrary.getControl().addKeyListener(new KeyAdapter() { - public void keyPressed(final KeyEvent event) { - if (event.character == SWT.DEL && event.stateMask == 0 - && deleteItemAction.isEnabled()) { - deleteItemAction.run(); - } - } - }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tvLibrary.setContentProvider(contentProvider); - - tvLibrary.getTable().setLinesVisible(true); - tvLibrary.getTable().setHeaderVisible(true); - - TableViewerColumn column1 = new TableViewerColumn(tvLibrary, SWT.NONE); - column1.getColumn().setText("Name"); - column1.getColumn().setWidth(190); - column1.setLabelProvider(new CellLabelProvider() { - @Override - public void update(final ViewerCell cell) { - cell.setText(((LibraryObject) cell.getElement()).getName()); - cell.setImage(((LibraryObject) cell.getElement()).getImage()); - } - }); - - TableViewerColumn column2 = new TableViewerColumn(tvLibrary, SWT.NONE); - column2.getColumn().setText("Type"); - column2.getColumn().setWidth(60); - column2.setLabelProvider(new CellLabelProvider() { - @Override - public void update(final ViewerCell cell) { - cell.setText(((LibraryObject) cell.getElement()).getType()); - } - }); - - createDragAndDropSupport(); - createActions(); - createContextMenu(); - createMenu(getSite()); - refresh(); - - } - - private void createDragAndDropSupport() { - - tvLibrary.addDragSupport(DND.DROP_COPY, - new Transfer[] { AttributeTransfer.getInstance() }, - new DragSourceAdapter() { - - public void dragSetData(final DragSourceEvent event) { - LibraryObject object = (LibraryObject) ((StructuredSelection) tvLibrary - .getSelection()).getFirstElement(); - - // TODO: Abstract this method!!! - // String attributeID = - // AttributeConstants.ATTRIBUTE_IMAGE; - // if (object.getType().equals("variable")) { - // attributeID = AttributeConstants.ATTRIBUTE_TEXT; - // } - event.data = new AttributeTransferObject(object); - } - - public void dragStart(final DragSourceEvent event) { - } - - }); - - } - - @Override - public Control getControl() { - return libMainContainer; - } - - @Override - public void setFocus() { - libMainContainer.setFocus(); - } - - private void createContextMenu() { - MenuManager manager = new MenuManager(); - tvLibrary.getControl().setMenu( - manager.createContextMenu(tvLibrary.getControl())); - manager.add(deleteItemAction); - } - - public void refresh() { - tvLibrary.setInput(new WritableList(getLibraryObjects(), - LibraryObject.class)); - updateActionEnablement(); - } - - private List<LibraryObject> getLibraryObjects() { - - List<LibraryObject> tmpList = new ArrayList<LibraryObject>(); - - if (editor != null) { - - String basePath = (editor.getVisualization().getProjectFile() - .getProject().getLocation().toString()) - .replace("file:", ""); - File dir = new File(basePath + "/images"); - File[] fileList = dir.listFiles(new FilenameFilter() { - public boolean accept(final File dir, final String name) { - if (name.toLowerCase().endsWith(".jpg") - || name.toLowerCase().endsWith(".gif") - || name.toLowerCase().endsWith(".png")) { - return true; - } - return false; - } - }); - if (fileList != null) { - for (File f : fileList) { - Image img = null; - if (f.getName().toLowerCase().endsWith(".jpg")) { - img = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_JPG); - } else { - img = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_GIF); - } - tmpList.add(new LibraryImageObject(f.getName(), "image", - img)); - } - } - - // TODO: Reimplement me!!! - // Visualization vis = this.editor.getVisualization(); - // if (vis != null) { - // for (MachineContentObject obj : vis.getVariableList() - // .getCollection()) { - // tmpList.add(new LibraryVariableObject(obj.getLabel(), - // "variable", BMotionStudioImage - // .getImage(BMotionStudioImage.IMG_LOGO_B))); - // } - // } - - } - - return tmpList; - - } - - private void createMenu(final IPageSite pageSite) { - pageSite.getActionBars().getToolBarManager().add(importImagesAction); - pageSite.getActionBars().getToolBarManager().add(deleteItemAction); - } - - private void createActions() { - importImagesAction = new ImportImagesAction(this); - deleteItemAction = new DeleteItemsAction(this); - } - - private void updateActionEnablement() { - IStructuredSelection sel = (IStructuredSelection) tvLibrary - .getSelection(); - deleteItemAction.setEnabled(sel.size() > 0); - } - - @Override - public void dispose() { - if (previewImage != null) - previewImage.dispose(); - super.dispose(); - } - - public BMotionStudioEditor getEditor() { - return editor; - } - - public void setEditor(final BMotionStudioEditor editor) { - this.editor = editor; - } - - public TableViewer getTableViewer() { - return tvLibrary; - } - - public void setTableViewer(final TableViewer viewer) { - this.tvLibrary = viewer; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DragSourceAdapter; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.part.IPageSite; +import org.eclipse.ui.part.Page; + +import de.bmotionstudio.gef.editor.BMotionStudioEditor; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; + +public class LibraryPage extends Page { + + private Image previewImage; + + private TableViewer tvLibrary; + + private Canvas previewCanvas; + + private Composite libMainContainer; + + private Action importImagesAction, deleteItemAction; + + private BMotionStudioEditor editor; + + public LibraryPage(final BMotionStudioEditor editor) { + this.editor = editor; + } + + @Override + public void createControl(final Composite parent) { + + libMainContainer = new Composite(parent, SWT.NONE); + + GridLayout gl = new GridLayout(1, true); + gl.horizontalSpacing = 0; + + libMainContainer.setLayout(gl); + + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalIndent = 0; + + previewCanvas = new Canvas(libMainContainer, SWT.BORDER); + previewCanvas.setLayout(gl); + previewCanvas.addPaintListener(new PaintListener() { + public void paintControl(final PaintEvent e) { + if (previewImage == null) { + e.gc.drawString("No preview...", 0, 0); + } else { + e.gc.drawImage(previewImage, 0, 0); + } + } + }); + previewCanvas.setLayoutData(gd); + + Composite libContainer = new Composite(libMainContainer, SWT.NONE); + libContainer.setLayout(gl); + libContainer.setLayoutData(gd); + + tvLibrary = new TableViewer(libContainer, SWT.FULL_SELECTION + | SWT.V_SCROLL | SWT.MULTI); + tvLibrary.getTable().setLayoutData(gd); + tvLibrary.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(final SelectionChangedEvent event) { + + IStructuredSelection selection = (IStructuredSelection) event + .getSelection(); + + LibraryObject obj = (LibraryObject) selection.getFirstElement(); + + if (previewImage != null) { + previewImage.dispose(); + } + + if (obj != null) { + previewImage = obj.getPreview(LibraryPage.this); + } else { + previewImage = null; + } + + previewCanvas.redraw(); + + updateActionEnablement(); + + } + + }); + + tvLibrary.getControl().addKeyListener(new KeyAdapter() { + public void keyPressed(final KeyEvent event) { + if (event.character == SWT.DEL && event.stateMask == 0 + && deleteItemAction.isEnabled()) { + deleteItemAction.run(); + } + } + }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tvLibrary.setContentProvider(contentProvider); + + tvLibrary.getTable().setLinesVisible(true); + tvLibrary.getTable().setHeaderVisible(true); + + TableViewerColumn column1 = new TableViewerColumn(tvLibrary, SWT.NONE); + column1.getColumn().setText("Name"); + column1.getColumn().setWidth(190); + column1.setLabelProvider(new CellLabelProvider() { + @Override + public void update(final ViewerCell cell) { + cell.setText(((LibraryObject) cell.getElement()).getName()); + cell.setImage(((LibraryObject) cell.getElement()).getImage()); + } + }); + + TableViewerColumn column2 = new TableViewerColumn(tvLibrary, SWT.NONE); + column2.getColumn().setText("Type"); + column2.getColumn().setWidth(60); + column2.setLabelProvider(new CellLabelProvider() { + @Override + public void update(final ViewerCell cell) { + cell.setText(((LibraryObject) cell.getElement()).getType()); + } + }); + + createDragAndDropSupport(); + createActions(); + createContextMenu(); + createMenu(getSite()); + refresh(); + + } + + private void createDragAndDropSupport() { + + tvLibrary.addDragSupport(DND.DROP_COPY, + new Transfer[] { AttributeTransfer.getInstance() }, + new DragSourceAdapter() { + + public void dragSetData(final DragSourceEvent event) { + LibraryObject object = (LibraryObject) ((StructuredSelection) tvLibrary + .getSelection()).getFirstElement(); + + // TODO: Abstract this method!!! + // String attributeID = + // AttributeConstants.ATTRIBUTE_IMAGE; + // if (object.getType().equals("variable")) { + // attributeID = AttributeConstants.ATTRIBUTE_TEXT; + // } + event.data = new AttributeTransferObject(object); + } + + public void dragStart(final DragSourceEvent event) { + } + + }); + + } + + @Override + public Control getControl() { + return libMainContainer; + } + + @Override + public void setFocus() { + libMainContainer.setFocus(); + } + + private void createContextMenu() { + MenuManager manager = new MenuManager(); + tvLibrary.getControl().setMenu( + manager.createContextMenu(tvLibrary.getControl())); + manager.add(deleteItemAction); + } + + public void refresh() { + tvLibrary.setInput(new WritableList(getLibraryObjects(), + LibraryObject.class)); + updateActionEnablement(); + } + + private List<LibraryObject> getLibraryObjects() { + + List<LibraryObject> tmpList = new ArrayList<LibraryObject>(); + + if (editor != null) { + + String basePath = (editor.getVisualization().getProjectFile() + .getProject().getLocation().toString()) + .replace("file:", ""); + File dir = new File(basePath + "/images"); + File[] fileList = dir.listFiles(new FilenameFilter() { + public boolean accept(final File dir, final String name) { + if (name.toLowerCase().endsWith(".jpg") + || name.toLowerCase().endsWith(".gif") + || name.toLowerCase().endsWith(".png")) { + return true; + } + return false; + } + }); + if (fileList != null) { + for (File f : fileList) { + Image img = null; + if (f.getName().toLowerCase().endsWith(".jpg")) { + img = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_JPG); + } else { + img = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_GIF); + } + tmpList.add(new LibraryImageObject(f.getName(), "image", + img)); + } + } + + // TODO: Reimplement me!!! + // Visualization vis = this.editor.getVisualization(); + // if (vis != null) { + // for (MachineContentObject obj : vis.getVariableList() + // .getCollection()) { + // tmpList.add(new LibraryVariableObject(obj.getLabel(), + // "variable", BMotionStudioImage + // .getImage(BMotionStudioImage.IMG_LOGO_B))); + // } + // } + + } + + return tmpList; + + } + + private void createMenu(final IPageSite pageSite) { + pageSite.getActionBars().getToolBarManager().add(importImagesAction); + pageSite.getActionBars().getToolBarManager().add(deleteItemAction); + } + + private void createActions() { + importImagesAction = new ImportImagesAction(this); + deleteItemAction = new DeleteItemsAction(this); + } + + private void updateActionEnablement() { + IStructuredSelection sel = (IStructuredSelection) tvLibrary + .getSelection(); + deleteItemAction.setEnabled(sel.size() > 0); + } + + @Override + public void dispose() { + if (previewImage != null) + previewImage.dispose(); + super.dispose(); + } + + public BMotionStudioEditor getEditor() { + return editor; + } + + public void setEditor(final BMotionStudioEditor editor) { + this.editor = editor; + } + + public TableViewer getTableViewer() { + return tvLibrary; + } + + public void setTableViewer(final TableViewer viewer) { + this.tvLibrary = viewer; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableCommand.java index 39c76dcaf6bffe25e999f136c7b165445483bc11..77653658e9180937bdf6e9350ec7059ca947dd1b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableCommand.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableCommand.java @@ -1,64 +1,64 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.draw2d.geometry.Rectangle; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.command.CreateCommand; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BText; -import de.bmotionstudio.gef.editor.observer.SimpleValueDisplay; - -public class LibraryVariableCommand extends AbstractLibraryCommand { - - private BControl newControl; - - public void execute() { - - attributeName = AttributeConstants.ATTRIBUTE_TEXT; - attributeValue = transferObject.getLibraryObject().getName(); - oldAttributeValue = getCastedModel().getAttributeValue(attributeName); - - SimpleValueDisplay observer = new SimpleValueDisplay(); - observer.setEval(attributeValue.toString()); - observer.setReplacementString("%%VALUE%%"); - - if (getCastedModel().canHaveChildren()) { - - newControl = new BText(getCastedModel().getVisualization()); - newControl.setAttributeValue(attributeName, attributeValue - + " = %%VALUE%%"); - newControl.addObserver(observer); - - CreateCommand createCommand = new CreateCommand( - newControl, getCastedModel()); - - Rectangle fRect = new Rectangle(getDropLocation().x - - getCastedModel().getLocation().x, getDropLocation().y - - getCastedModel().getLocation().y, 100, 100); - - createCommand.setLayout(fRect); - createCommand.execute(); - - } else { - if (getCastedModel() - .hasAttribute(AttributeConstants.ATTRIBUTE_TEXT)) { - getCastedModel().setAttributeValue(attributeName, - attributeValue + " = %%VALUE%%"); - getCastedModel().addObserver(observer); - } - } - - } - - public void undo() { - super.undo(); - getCastedModel().removeChild(newControl); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.draw2d.geometry.Rectangle; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.command.CreateCommand; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BText; +import de.bmotionstudio.gef.editor.observer.SimpleValueDisplay; + +public class LibraryVariableCommand extends AbstractLibraryCommand { + + private BControl newControl; + + public void execute() { + + attributeName = AttributeConstants.ATTRIBUTE_TEXT; + attributeValue = transferObject.getLibraryObject().getName(); + oldAttributeValue = getCastedModel().getAttributeValue(attributeName); + + SimpleValueDisplay observer = new SimpleValueDisplay(); + observer.setEval(attributeValue.toString()); + observer.setReplacementString("%%VALUE%%"); + + if (getCastedModel().canHaveChildren()) { + + newControl = new BText(getCastedModel().getVisualization()); + newControl.setAttributeValue(attributeName, attributeValue + + " = %%VALUE%%"); + newControl.addObserver(observer); + + CreateCommand createCommand = new CreateCommand( + newControl, getCastedModel()); + + Rectangle fRect = new Rectangle(getDropLocation().x + - getCastedModel().getLocation().x, getDropLocation().y + - getCastedModel().getLocation().y, 100, 100); + + createCommand.setLayout(fRect); + createCommand.execute(); + + } else { + if (getCastedModel() + .hasAttribute(AttributeConstants.ATTRIBUTE_TEXT)) { + getCastedModel().setAttributeValue(attributeName, + attributeValue + " = %%VALUE%%"); + getCastedModel().addObserver(observer); + } + } + + } + + public void undo() { + super.undo(); + getCastedModel().removeChild(newControl); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableObject.java index 26ac39aedd2586b8518d8d42eef1b9885b64b2c1..672cf58b75b9fce55a23ccafa089eaf85416b2fb 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryVariableObject.java @@ -1,20 +1,20 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.swt.graphics.Image; - -/** - * @author Lukas Ladenberger - * - */ -public class LibraryVariableObject extends LibraryObject { - - public LibraryVariableObject(String name, String type, Image typeImage) { - super(name, type, typeImage); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.swt.graphics.Image; + +/** + * @author Lukas Ladenberger + * + */ +public class LibraryVariableObject extends LibraryObject { + + public LibraryVariableObject(String name, String type, Image typeImage) { + super(name, type, typeImage); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java index 962029267cbb388066a6e8dad0d927d75f098eb8..08240a63b7a45fd3e70872f75bd61fbefeb93742 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java @@ -1,76 +1,76 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.library; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.IPage; -import org.eclipse.ui.part.MessagePage; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.part.PageBookView; - -import de.bmotionstudio.gef.editor.BMotionStudioEditor; - -public class LibraryView extends PageBookView { - - public static String ID = "de.bmotionstudio.gef.editor.LibraryView"; - - private String defaultText = "A library is not available."; - - private LibraryPage page; - - public LibraryView() { - super(); - } - - @Override - protected IPage createDefaultPage(PageBook book) { - MessagePage page = new MessagePage(); - initPage(page); - page.createControl(book); - page.setMessage(defaultText); - return page; - } - - @Override - protected PageRec doCreatePage(IWorkbenchPart part) { - if (part instanceof BMotionStudioEditor) { - page = new LibraryPage((BMotionStudioEditor) part); - initPage(page); - page.createControl(getPageBook()); - return new PageRec(part, page); - } - return null; - } - - @Override - protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { - LibraryPage page = (LibraryPage) rec.page; - page.dispose(); - rec.dispose(); - } - - @Override - protected IWorkbenchPart getBootstrapPart() { - IWorkbenchPage page = getSite().getPage(); - if (page != null) { - return page.getActiveEditor(); - } - return null; - } - - public void partBroughtToTop(IWorkbenchPart part) { - partActivated(part); - } - - @Override - protected boolean isImportant(IWorkbenchPart part) { - return (part instanceof IEditorPart); - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.library; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.IPage; +import org.eclipse.ui.part.MessagePage; +import org.eclipse.ui.part.PageBook; +import org.eclipse.ui.part.PageBookView; + +import de.bmotionstudio.gef.editor.BMotionStudioEditor; + +public class LibraryView extends PageBookView { + + public static String ID = "de.bmotionstudio.gef.editor.LibraryView"; + + private String defaultText = "A library is not available."; + + private LibraryPage page; + + public LibraryView() { + super(); + } + + @Override + protected IPage createDefaultPage(PageBook book) { + MessagePage page = new MessagePage(); + initPage(page); + page.createControl(book); + page.setMessage(defaultText); + return page; + } + + @Override + protected PageRec doCreatePage(IWorkbenchPart part) { + if (part instanceof BMotionStudioEditor) { + page = new LibraryPage((BMotionStudioEditor) part); + initPage(page); + page.createControl(getPageBook()); + return new PageRec(part, page); + } + return null; + } + + @Override + protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { + LibraryPage page = (LibraryPage) rec.page; + page.dispose(); + rec.dispose(); + } + + @Override + protected IWorkbenchPart getBootstrapPart() { + IWorkbenchPage page = getSite().getPage(); + if (page != null) { + return page.getActiveEditor(); + } + return null; + } + + public void partBroughtToTop(IWorkbenchPart part) { + partActivated(part); + } + + @Override + protected boolean isImportant(IWorkbenchPart part) { + return (part instanceof IEditorPart); + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java index 64dd3ec4e5451d88a678378f2c8f1cab84dc2c77..d46f760fe8c295bd05577dda60458f0d29e68788 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java @@ -1,56 +1,56 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; - -/** - * @author Lukas Ladenberger - * - */ -public class BButton extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.button"; - - public static transient String DEFAULT_TEXT = "Click!"; - - public BButton(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeEnabled(true)); - - BAttributeHeight aHeight = new BAttributeHeight(25); - aHeight.setGroup(BAttributeSize.ID); - initAttribute(aHeight); - - BAttributeWidth aWidth = new BAttributeWidth(100); - aWidth.setGroup(BAttributeSize.ID); - initAttribute(aWidth); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeText; +import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; + +/** + * @author Lukas Ladenberger + * + */ +public class BButton extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.button"; + + public static transient String DEFAULT_TEXT = "Click!"; + + public BButton(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeText(DEFAULT_TEXT)); + initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); + initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); + initAttribute(new BAttributeEnabled(true)); + + BAttributeHeight aHeight = new BAttributeHeight(25); + aHeight.setGroup(BAttributeSize.ID); + initAttribute(aHeight); + + BAttributeWidth aWidth = new BAttributeWidth(100); + aWidth.setGroup(BAttributeSize.ID); + initAttribute(aWidth); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java index 96950332d7be34480035dff478e53e6fcada563c..1df7bfc42625e2c5c24d3f882c1bdff7422f5e04 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java @@ -1,70 +1,70 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeFalseValue; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeTrueValue; - -/** - * @author Lukas Ladenberger - * - */ -public class BCheckbox extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.checkbox"; - - public static transient String DEFAULT_TEXT = "Text..."; - - public BCheckbox(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeEnabled(true)); - initAttribute(new BAttributeChecked(true)); - initAttribute(new BAttributeTrueValue("")); - initAttribute(new BAttributeFalseValue("")); - - BAttributeHeight aHeight = new BAttributeHeight(21); - aHeight.setGroup(BAttributeSize.ID); - aHeight.setShow(false); - aHeight.setEditable(false); - initAttribute(aHeight); - - } - - @Override - public String getValueOfData() { - if (Boolean.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED).toString())) { - return getAttributeValue(AttributeConstants.ATTRIBUTE_TRUEVALUE) - .toString(); - } else { - return getAttributeValue(AttributeConstants.ATTRIBUTE_FALSEVALUE) - .toString(); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; +import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; +import de.bmotionstudio.gef.editor.attribute.BAttributeFalseValue; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeText; +import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeTrueValue; + +/** + * @author Lukas Ladenberger + * + */ +public class BCheckbox extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.checkbox"; + + public static transient String DEFAULT_TEXT = "Text..."; + + public BCheckbox(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeText(DEFAULT_TEXT)); + initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); + initAttribute(new BAttributeEnabled(true)); + initAttribute(new BAttributeChecked(true)); + initAttribute(new BAttributeTrueValue("")); + initAttribute(new BAttributeFalseValue("")); + + BAttributeHeight aHeight = new BAttributeHeight(21); + aHeight.setGroup(BAttributeSize.ID); + aHeight.setShow(false); + aHeight.setEditable(false); + initAttribute(aHeight); + + } + + @Override + public String getValueOfData() { + if (Boolean.valueOf(getAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED).toString())) { + return getAttributeValue(AttributeConstants.ATTRIBUTE_TRUEVALUE) + .toString(); + } else { + return getAttributeValue(AttributeConstants.ATTRIBUTE_FALSEVALUE) + .toString(); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java index 52d060b4781b977535ead1436f069d5df9b0b666..90ac3bf2e9da863a5d30e1ffe5c309ee6f937641 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java @@ -1,44 +1,44 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; - -/** - * @author Lukas Ladenberger - * - */ -public class BComposite extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.composite"; - - public BComposite(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); - initAttribute(new BAttributeImage(null)); - - } - - @Override - public boolean canHaveChildren() { - return true; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeImage; + +/** + * @author Lukas Ladenberger + * + */ +public class BComposite extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.composite"; + + public BComposite(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); + initAttribute(new BAttributeImage(null)); + + } + + @Override + public boolean canHaveChildren() { + return true; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java index 6b36f515876e6917ee508f1bd5edf5a1b5cb5681..cddb2b255b901efbce1a12d7ea39fbe31dc158fe 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java @@ -1,159 +1,159 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; - -public class BConnection extends BControl { - - public static String TYPE = "de.bmotionstudio.gef.editor.connection"; - - /** True, if the connection is attached to its endpoints. */ - protected boolean isConnected; - /** Connection's source endpoint. */ - protected BControl source; - /** Connection's target endpoint. */ - protected BControl target; - - /** - * Create a (solid) connection between two distinct shapes. - * - * @param source - * a source endpoint for this connection (non null) - * @param target - * a target endpoint for this connection (non null) - * @throws IllegalArgumentException - * if any of the parameters are null or source == target - * @see #setLineStyle(int) - */ - public BConnection(Visualization visualization) { - super(visualization); - } - - /** - * Disconnect this connection from the shapes it is attached to. - */ - public void disconnect() { - if (isConnected) { - source.removeConnection(this); - target.removeConnection(this); - isConnected = false; - } - } - - /** - * Returns the source endpoint of this connection. - * - * @return a non-null Shape instance - */ - public BControl getSource() { - return source; - } - - /** - * Returns the target endpoint of this connection. - * - * @return a non-null Shape instance - */ - public BControl getTarget() { - return target; - } - - public void setTarget(BControl c) { - this.target = c; - } - - public void setSource(BControl c) { - this.source = c; - } - - /** - * Reconnect this connection. The connection will reconnect with the shapes - * it was previously attached to. - */ - public void reconnect() { - if (!isConnected) { - source.addConnection(this); - target.addConnection(this); - isConnected = true; - } - } - - /** - * Reconnect to a different source and/or target shape. The connection will - * disconnect from its current attachments and reconnect to the new source - * and target. - * - * @param newSource - * a new source endpoint for this connection (non null) - * @param newTarget - * a new target endpoint for this connection (non null) - * @throws IllegalArgumentException - * if any of the paramers are null or newSource == newTarget - */ - public void reconnect(BControl newSource, BControl newTarget) { - if (newSource == null || newTarget == null || newSource == newTarget) { - throw new IllegalArgumentException(); - } - disconnect(); - this.source = newSource; - this.target = newTarget; - reconnect(); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - BAttributeConnection aConnection = new BAttributeConnection(null); - aConnection.setGroup(AbstractAttribute.ROOT); - initAttribute(aConnection); - - BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1); - aLineWidth.setGroup(aConnection); - initAttribute(aLineWidth); - - BAttributeLineStyle aLineStyle = new BAttributeLineStyle( - BAttributeLineStyle.SOLID_CONNECTION); - aLineStyle.setGroup(aConnection); - initAttribute(aLineStyle); - - BAttributeForegroundColor aForegroundColor = new BAttributeForegroundColor( - new RGB(0, 0, 0)); - aForegroundColor.setGroup(aConnection); - initAttribute(aForegroundColor); - - BAttributeConnectionSourceDecoration aSourceDeco = new BAttributeConnectionSourceDecoration( - BAttributeConnectionSourceDecoration.DECORATION_NONE); - aSourceDeco.setGroup(aConnection); - initAttribute(aSourceDeco); - - BAttributeConnectionTargetDecoration aTargetDeco = new BAttributeConnectionTargetDecoration( - BAttributeConnectionSourceDecoration.DECORATION_NONE); - aTargetDeco.setGroup(aConnection); - initAttribute(aTargetDeco); - - BAttributeLabel aLabel = new BAttributeLabel("Label ..."); - aLabel.setGroup(aConnection); - initAttribute(aLabel); - - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; +import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; + +public class BConnection extends BControl { + + public static String TYPE = "de.bmotionstudio.gef.editor.connection"; + + /** True, if the connection is attached to its endpoints. */ + protected boolean isConnected; + /** Connection's source endpoint. */ + protected BControl source; + /** Connection's target endpoint. */ + protected BControl target; + + /** + * Create a (solid) connection between two distinct shapes. + * + * @param source + * a source endpoint for this connection (non null) + * @param target + * a target endpoint for this connection (non null) + * @throws IllegalArgumentException + * if any of the parameters are null or source == target + * @see #setLineStyle(int) + */ + public BConnection(Visualization visualization) { + super(visualization); + } + + /** + * Disconnect this connection from the shapes it is attached to. + */ + public void disconnect() { + if (isConnected) { + source.removeConnection(this); + target.removeConnection(this); + isConnected = false; + } + } + + /** + * Returns the source endpoint of this connection. + * + * @return a non-null Shape instance + */ + public BControl getSource() { + return source; + } + + /** + * Returns the target endpoint of this connection. + * + * @return a non-null Shape instance + */ + public BControl getTarget() { + return target; + } + + public void setTarget(BControl c) { + this.target = c; + } + + public void setSource(BControl c) { + this.source = c; + } + + /** + * Reconnect this connection. The connection will reconnect with the shapes + * it was previously attached to. + */ + public void reconnect() { + if (!isConnected) { + source.addConnection(this); + target.addConnection(this); + isConnected = true; + } + } + + /** + * Reconnect to a different source and/or target shape. The connection will + * disconnect from its current attachments and reconnect to the new source + * and target. + * + * @param newSource + * a new source endpoint for this connection (non null) + * @param newTarget + * a new target endpoint for this connection (non null) + * @throws IllegalArgumentException + * if any of the paramers are null or newSource == newTarget + */ + public void reconnect(BControl newSource, BControl newTarget) { + if (newSource == null || newTarget == null || newSource == newTarget) { + throw new IllegalArgumentException(); + } + disconnect(); + this.source = newSource; + this.target = newTarget; + reconnect(); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + BAttributeConnection aConnection = new BAttributeConnection(null); + aConnection.setGroup(AbstractAttribute.ROOT); + initAttribute(aConnection); + + BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1); + aLineWidth.setGroup(aConnection); + initAttribute(aLineWidth); + + BAttributeLineStyle aLineStyle = new BAttributeLineStyle( + BAttributeLineStyle.SOLID_CONNECTION); + aLineStyle.setGroup(aConnection); + initAttribute(aLineStyle); + + BAttributeForegroundColor aForegroundColor = new BAttributeForegroundColor( + new RGB(0, 0, 0)); + aForegroundColor.setGroup(aConnection); + initAttribute(aForegroundColor); + + BAttributeConnectionSourceDecoration aSourceDeco = new BAttributeConnectionSourceDecoration( + BAttributeConnectionSourceDecoration.DECORATION_NONE); + aSourceDeco.setGroup(aConnection); + initAttribute(aSourceDeco); + + BAttributeConnectionTargetDecoration aTargetDeco = new BAttributeConnectionTargetDecoration( + BAttributeConnectionSourceDecoration.DECORATION_NONE); + aTargetDeco.setGroup(aConnection); + initAttribute(aTargetDeco); + + BAttributeLabel aLabel = new BAttributeLabel("Label ..."); + aLabel.setGroup(aConnection); + initAttribute(aLabel); + + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java index 1d93f734a06479b0c4b5d1ab7281be37797aea78..d83b2770558b39fa9ab0f31d8966d9be5d161a72 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java @@ -1,841 +1,841 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.ui.actions.Clipboard; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.views.properties.IPropertySource; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates; -import de.bmotionstudio.gef.editor.attribute.BAttributeCustom; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeID; -import de.bmotionstudio.gef.editor.attribute.BAttributeMisc; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeVisible; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; -import de.bmotionstudio.gef.editor.attribute.BAttributeX; -import de.bmotionstudio.gef.editor.attribute.BAttributeY; -import de.bmotionstudio.gef.editor.command.CopyPasteHelper; -import de.bmotionstudio.gef.editor.internal.BControlPropertySource; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; - -/** - * - * A Control is a graphical representation of some aspects of the model. - * Typically we use labels, images or buttons to represent informations. For - * instance, if we model a system that has a temperature and a threshold - * temperature that triggers a cool down, we might simply use two labels - * displaying both values, or maybe we can incorporate both information into a - * gauge display. It is also possible to define new controls for domain specific - * visualizations. - * - * @author Lukas Ladenberger - * - */ -public abstract class BControl implements IAdaptable, Cloneable { - - protected String type; - - private BControlList children; - - private Map<String, Observer> observers; - - private Map<String, SchedulerEvent> events; - - private Map<String, AbstractAttribute> attributes; - - private BMotionGuide verticalGuide, horizontalGuide; - - // List of outgoing Connections - private List<BConnection> sourceConnections; - // List of incoming Connections - private List<BConnection> targetConnections; - - private transient Rectangle layout = null; - - private transient Point location = null; - - private transient BControl parent; - - private transient Visualization visualization; - - private transient PropertyChangeSupport listeners; - - private transient boolean newControl; - - public BControl(Visualization visualization) { - this.visualization = visualization; - this.children = new BControlList(); - this.observers = new HashMap<String, Observer>(); - this.events = new HashMap<String, SchedulerEvent>(); - this.attributes = new HashMap<String, AbstractAttribute>(); - this.listeners = new PropertyChangeSupport(this); - this.sourceConnections = new ArrayList<BConnection>(); - this.targetConnections = new ArrayList<BConnection>(); - this.newControl = true; - init(); - } - - protected Object readResolve() { - // Populate parent - for (BControl child : getChildrenArray()) - child.setParent(this); - this.newControl = false; - return this; - } - - /** - * Remove an incoming or outgoing connection from this shape. - * - * @param conn - * a non-null connection instance - * @throws IllegalArgumentException - * if the parameter is null - */ - public void removeConnection(BConnection conn) { - if (conn == null) { - throw new IllegalArgumentException(); - } - if (conn.getSource() == this) { - getSourceConnections().remove(conn); - getListeners().firePropertyChange( - BControlPropertyConstants.SOURCE_CONNECTIONS, null, conn); - } else if (conn.getTarget() == this) { - getTargetConnections().remove(conn); - getListeners().firePropertyChange( - BControlPropertyConstants.TARGET_CONNECTIONS, null, conn); - } - } - - /** - * Add an incoming or outgoing connection to this shape. - * - * @param conn - * a non-null connection instance - * @throws IllegalArgumentException - * if the connection is null or has not distinct endpoints - */ - public void addConnection(BConnection conn) { - if (conn == null || conn.getSource() == conn.getTarget()) { - throw new IllegalArgumentException(); - } - if (conn.getSource() == this) { - getSourceConnections().add(conn); - getListeners().firePropertyChange( - BControlPropertyConstants.SOURCE_CONNECTIONS, null, conn); - } else if (conn.getTarget() == this) { - getTargetConnections().add(conn); - getListeners().firePropertyChange( - BControlPropertyConstants.TARGET_CONNECTIONS, null, conn); - } - } - - protected void init() { - // Init standard control attributes - initStandardAttributes(); - // Init custom control attributes - initAttributes(); - - } - - private List<String> getSupportedObserverList() { - - List<String> supportedObserver = new ArrayList<String>(); - - IExtensionPoint extensionPoint = Platform.getExtensionRegistry() - .getExtensionPoint( - "de.bmotionstudio.gef.editor.includeObserver"); - - for (IExtension extension : extensionPoint.getExtensions()) { - for (IConfigurationElement configurationElement : extension - .getConfigurationElements()) { - - if ("include".equals(configurationElement.getName())) { - - String langID = configurationElement - .getAttribute("language"); - - if (langID != null - && langID.equals(getVisualization() - .getLanguage())) { - - for (IConfigurationElement configC : configurationElement - .getChildren("control")) { - - String cID = configC.getAttribute("id"); - - if (getType().equals(cID)) { - - for (IConfigurationElement configO : configC - .getChildren("observer")) { - - supportedObserver.add(configO - .getAttribute("id")); - - } - - } - - } - - } - - } - - } - } - - return supportedObserver; - - } - - private void initStandardAttributes() { - - // Init unique ID - String ID; - if (this instanceof Visualization) - ID = "visualization"; - else if (visualization == null) - ID = UUID.randomUUID().toString(); - else - ID = (visualization.getMaxIDString(type)); - - BAttributeID aID = new BAttributeID(ID); - aID.setGroup(AbstractAttribute.ROOT); - initAttribute(aID); - - BAttributeMisc aMisc = new BAttributeMisc(""); - aMisc.setGroup(AbstractAttribute.ROOT); - initAttribute(aMisc); - - // Init location and size attributes - BAttributeCoordinates aCoordinates = new BAttributeCoordinates(null); - aCoordinates.setGroup(AbstractAttribute.ROOT); - initAttribute(aCoordinates); - - BAttributeX aX = new BAttributeX(100); - aX.setGroup(aCoordinates); - initAttribute(aX); - - BAttributeY aY = new BAttributeY(100); - aY.setGroup(aCoordinates); - initAttribute(aY); - - BAttributeSize aSize = new BAttributeSize(null); - aSize.setGroup(AbstractAttribute.ROOT); - initAttribute(aSize); - - BAttributeWidth aWidth = new BAttributeWidth(100); - aWidth.setGroup(aSize); - initAttribute(aWidth); - - BAttributeHeight aHeight = new BAttributeHeight(100); - aHeight.setGroup(aSize); - initAttribute(aHeight); - - // Init visible and this attribute - BAttributeVisible aVisible = new BAttributeVisible(true); - aVisible.setGroup(AbstractAttribute.ROOT); - initAttribute(aVisible); - - BAttributeCustom aCustom = new BAttributeCustom(""); - aCustom.setGroup(AbstractAttribute.ROOT); - initAttribute(aCustom); - - } - - protected abstract void initAttributes(); - - public String getID() { - return getAttributeValue(AttributeConstants.ATTRIBUTE_ID).toString(); - } - - public AbstractAttribute getAttribute(String attributeID) { - return getAttributes().get(attributeID); - } - - public Object getAttributeValue(String attributeID) { - - AbstractAttribute atr = attributes.get(attributeID); - - if (atr != null) { - return atr.getValue(); - } else { - // TODO: handle error/exception (no such attribute) - return null; - } - - } - - public boolean setAttributeValue(String attributeID, Object value) { - return setAttributeValue(attributeID, value, true, true); - } - - public boolean setAttributeValue(String attributeID, Object value, - Boolean firePropertyChange) { - return setAttributeValue(attributeID, value, firePropertyChange, true); - } - - public boolean setAttributeValue(String attributeID, Object value, - Boolean firePropertyChange, Boolean setInitVal) { - - AbstractAttribute atr = attributes.get(attributeID); - - if (atr == null) { - return false; - // TODO: Throw some error!?! - } - - atr.setControl(this); - - if ((atr.getValue() != null && atr.getValue().equals(value)) - || !atr.isEditable()) - return true; - - atr.setValue(value, firePropertyChange, setInitVal); - - return true; - - } - - public void restoreDefaultValue(String attributeID) { - AbstractAttribute atr = attributes.get(attributeID); - if (atr != null) { - atr.restoreValue(); - Object oldVal = atr.getValue(); - Object initValue = atr.getInitValue(); - getListeners().firePropertyChange(attributeID, oldVal, initValue); - } - } - - public boolean hasAttribute(String attributeID) { - return attributes.containsKey(attributeID); - } - - public void setLayout(Rectangle newLayout) { - Rectangle oldLayout = getLayout(); - layout = newLayout; - setAttributeValue(AttributeConstants.ATTRIBUTE_X, newLayout.x, false); - setAttributeValue(AttributeConstants.ATTRIBUTE_Y, newLayout.y, false); - setAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH, newLayout.width, - false); - setAttributeValue(AttributeConstants.ATTRIBUTE_HEIGHT, - newLayout.height, false); - getListeners() - .firePropertyChange(BControlPropertyConstants.PROPERTY_LAYOUT, - oldLayout, newLayout); - } - - public Rectangle getLayout() { - - String widthStr = getAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH) - .toString(); - String heightStr = getAttributeValue( - AttributeConstants.ATTRIBUTE_HEIGHT).toString(); - String xStr = getAttributeValue(AttributeConstants.ATTRIBUTE_X) - .toString(); - String yStr = getAttributeValue(AttributeConstants.ATTRIBUTE_Y) - .toString(); - - // TODO: check if strings are a correct integers - - try { - - int width = Integer.valueOf(widthStr); - int height = Integer.valueOf(heightStr); - int x = Integer.valueOf(xStr); - int y = Integer.valueOf(yStr); - - if (layout == null) { - layout = new Rectangle(x, y, width, height); - } else { - layout.x = x; - layout.y = y; - layout.width = width; - layout.height = height; - } - - } catch (NumberFormatException e) { - // We ignore number format exceptions, however we should return an - // error message here - // TODO: return error message - } - - return layout; - - } - - public void setLocation(Point newLocation) { - Point oldLocation = getLocation(); - location = newLocation; - setAttributeValue(AttributeConstants.ATTRIBUTE_X, newLocation.x, false); - setAttributeValue(AttributeConstants.ATTRIBUTE_Y, newLocation.y, false); - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_LOCATION, oldLocation, - newLocation); - } - - public Point getLocation() { - int x = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_X).toString()); - int y = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_Y).toString()); - if (location == null) { - location = new Point(x, y); - } else { - location.x = x; - location.y = y; - } - return location; - } - - public Dimension getDimension() { - int width = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_WIDTH).toString()); - int height = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_HEIGHT).toString()); - return new Dimension(width, height); - } - - public void addChild(BControl child) { - addChild(child, -1); - } - - public void addChild(BControl child, int index) { - child.setParent(this); - if (index >= 0) { - children.add(index, child); - } else { - children.add(child); - } - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_CHILD, index, child); - } - - public void removeAllChildren() { - getChildrenArray().clear(); - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_REMOVE_CHILD, null, null); - } - - public boolean removeChild(int index) { - BControl control = children.get(index); - return removeChild(control); - } - - public boolean removeChild(BControl child) { - boolean b = children.remove(child); - if (b) - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_REMOVE_CHILD, child, - null); - return b; - } - - public List<BControl> getChildrenArray() { - if (children == null) - children = new BControlList(); - return children; - } - - public void setChildrenArray(BControlList children) { - this.children = children; - } - - public boolean hasChildren() { - return children.size() > 0; - } - - public BControl getChild(String ID) { - for (BControl bcontrol : children) { - String bcontrolID = bcontrol.getAttributeValue( - AttributeConstants.ATTRIBUTE_ID).toString(); - if (bcontrolID != null) { - if (bcontrolID.equals(ID)) - return bcontrol; - } - } - return null; - } - - public Map<String, Observer> getObservers() { - if (observers == null) - observers = new HashMap<String, Observer>(); - return observers; - } - - public Observer getObserver(String observerID) { - return this.observers.get(observerID); - } - - public Boolean hasObserver(String ID) { - if (getObservers().containsKey(ID)) - return true; - return false; - } - - public void addObserver(Observer observer) { - observers.put(observer.getID(), (Observer) observer); - getListeners() - .firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_OBSERVER, - observer, null); - } - - public void removeObserver(Observer observer) { - removeObserver(observer.getID()); - } - - public void removeObserver(String observerID) { - Observer o = observers.remove(observerID); - if (o != null) { - o.beforeDelete(this); - getListeners() - .firePropertyChange( - BControlPropertyConstants.PROPERTY_REMOVE_OBSERVER, - o, null); - } - } - - public Map<String, SchedulerEvent> getEvents() { - if (events == null) - events = new HashMap<String, SchedulerEvent>(); - return events; - } - - public SchedulerEvent getEvent(String ID) { - return events.get(ID); - } - - public Boolean hasEvent(String ID) { - if (getEvents().containsKey(ID)) - return true; - return false; - } - - public void addEvent(String eventID, SchedulerEvent schedulerEvent) { - events.put(eventID, schedulerEvent); - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_ADD_EVENT, schedulerEvent, - null); - } - - public void removeEvent(String eventID) { - SchedulerEvent e = events.remove(eventID); - if (e != null) { - e.beforeDelete(this); - getListeners().firePropertyChange( - BControlPropertyConstants.PROPERTY_REMOVE_EVENT, e, null); - } - } - - public Map<String, AbstractAttribute> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, AbstractAttribute> attributes) { - this.attributes = attributes; - } - - public void setParent(BControl parent) { - this.parent = parent; - } - - public BControl getParent() { - return this.parent; - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - getListeners().addPropertyChangeListener(listener); - } - - public PropertyChangeSupport getListeners() { - if (listeners == null) - listeners = new PropertyChangeSupport(this); - return listeners; - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - getListeners().removePropertyChangeListener(listener); - } - - public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - if (adapter == IPropertySource.class) { - return new BControlPropertySource(this); - } - return null; - } - - public boolean contains(BControl child) { - return children.contains(child); - } - - public String getDefaultValue(String attributeID) { - - IConfigurationElement configurationElement = BMotionEditorPlugin - .getControlExtension(getType()); - - if (configurationElement != null) { - - for (final IConfigurationElement configBAttributes : configurationElement - .getChildren("attributes")) { - - for (final IConfigurationElement configBAttribute : configBAttributes - .getChildren("attribute-string")) { - - String aID = configBAttribute.getAttribute("id"); - - if (aID.equals(attributeID)) { - String attributeDefaultValue = configBAttribute - .getAttribute("default-value"); - - return attributeDefaultValue; - } - - } - - } - - } - - return null; - - } - - public Boolean isAttributeEditable(String attributeID) { - - IConfigurationElement configurationElement = BMotionEditorPlugin - .getControlExtension(getType()); - - if (configurationElement != null) { - - for (final IConfigurationElement configBAttributes : configurationElement - .getChildren("attributes")) { - - for (final IConfigurationElement configBAttribute : configBAttributes - .getChildren("attribute-string")) { - - String aID = configBAttribute.getAttribute("id"); - - if (aID.equals(attributeID)) { - String val = configBAttribute.getAttribute("editable"); - return Boolean.valueOf(val); - } - - } - - } - - } - - return false; - - } - - public Visualization getVisualization() { - return visualization; - } - - public void setVisualization(Visualization visualization) { - this.visualization = visualization; - } - - @Override - public BControl clone() throws CloneNotSupportedException { - - BControl clonedControl = (BControl) super.clone(); - - clonedControl.listeners = new PropertyChangeSupport(clonedControl); - clonedControl.sourceConnections = new ArrayList<BConnection>(); - clonedControl.targetConnections = new ArrayList<BConnection>(); - - clonedControl.setParent(getParent()); - - // Clone attributes - Map<String, AbstractAttribute> newProperties = new HashMap<String, AbstractAttribute>(); - for (Entry<String, AbstractAttribute> e : getAttributes().entrySet()) { - AbstractAttribute idAtr = e.getValue().clone(); - newProperties.put(e.getKey(), idAtr); - } - clonedControl.setAttributes(newProperties); - clonedControl.setAttributeValue(AttributeConstants.ATTRIBUTE_ID, - getVisualization().getMaxIDString(type)); - - // Clone children - clonedControl.setChildrenArray(new BControlList()); - Iterator<BControl> it = getChildrenArray().iterator(); - while (it.hasNext()) { - BControl next = (BControl) it.next(); - BControl childClone = next.clone(); - CopyPasteHelper cHelper = (CopyPasteHelper) Clipboard.getDefault() - .getContents(); - if (cHelper != null) - cHelper.getAlreadyClonedMap().put(next, childClone); - clonedControl.addChild(childClone); - } - - // Clone observer - clonedControl.setObserverMap(new HashMap<String, Observer>()); - for (Observer observer : observers.values()) { - clonedControl.addObserver(observer.clone()); - } - - // Clone events - clonedControl.setEventMap(new HashMap<String, SchedulerEvent>()); - for (Map.Entry<String, SchedulerEvent> e : events.entrySet()) { - clonedControl.addEvent(e.getKey(), e.getValue().clone()); - } - - return clonedControl; - - } - - public void checkObserver(final Animation animation) { - - // Check all Observers - for (Observer observer : getObservers().values()) { - observer.check(animation, BControl.this); - } - - // TODO: Currently connection observer are checked twice (source + - // target) => change this, so that observer are checked only on time per - // state!!! - for (BConnection con : getSourceConnections()) { - con.checkObserver(animation); - } - for (BConnection con : getTargetConnections()) { - con.checkObserver(animation); - } - - } - - public void executeEvent(String eventID) { - if (hasAttribute(AttributeConstants.ATTRIBUTE_ENABLED)) { - if (!(Boolean) getAttributeValue(AttributeConstants.ATTRIBUTE_ENABLED)) - return; - } - SchedulerEvent e = getEvents().get(eventID); - if (e != null) - e.execute(getVisualization().getAnimation(), this); - } - - public void setVerticalGuide(BMotionGuide verticalGuide) { - this.verticalGuide = verticalGuide; - } - - public BMotionGuide getVerticalGuide() { - return verticalGuide; - } - - public void setHorizontalGuide(BMotionGuide horizontalGuide) { - this.horizontalGuide = horizontalGuide; - } - - public BMotionGuide getHorizontalGuide() { - return horizontalGuide; - } - - /** - * Return a List of outgoing Connections. - */ - public List<BConnection> getSourceConnections() { - if (this.sourceConnections == null) - this.sourceConnections = new ArrayList<BConnection>(); - return this.sourceConnections; - } - - public void setSourceConnections(List<BConnection> connections) { - this.sourceConnections = connections; - } - - public void setTargetConnections(List<BConnection> connections) { - this.targetConnections = connections; - } - - /** - * Return a List of incoming Connections. - */ - public List<BConnection> getTargetConnections() { - if (this.targetConnections == null) - this.targetConnections = new ArrayList<BConnection>(); - return this.targetConnections; - } - - public boolean hasConnections() { - return !getTargetConnections().isEmpty() - || !getSourceConnections().isEmpty(); - } - - public boolean showInOutlineView() { - return true; - } - - public void setObserverMap(Map<String, Observer> observerMap) { - observers = observerMap; - } - - public void setEventMap(Map<String, SchedulerEvent> eventMap) { - events = eventMap; - } - - public abstract String getType(); - - protected void initAttribute(AbstractAttribute atr) { - - AbstractAttribute oldAtr = getAttribute(atr.getID()); - - // If a new control is created via the editor (not from the saved file) - // set the saved value of the file - if (oldAtr != null && !newControl) { - atr.setValue(oldAtr.getValue()); - atr.setDefaultValue(oldAtr.getDefaultValue()); - } - - getAttributes().put(atr.getID(), atr); - - } - - public boolean canHaveChildren() { - return false; - } - - public String getValueOfData() { - return getAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM) - .toString(); - } - - public Image getIcon() { - return BMotionStudioImage.getBControlImage(getType()); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.ui.actions.Clipboard; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.views.properties.IPropertySource; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates; +import de.bmotionstudio.gef.editor.attribute.BAttributeCustom; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeID; +import de.bmotionstudio.gef.editor.attribute.BAttributeMisc; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeVisible; +import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; +import de.bmotionstudio.gef.editor.attribute.BAttributeX; +import de.bmotionstudio.gef.editor.attribute.BAttributeY; +import de.bmotionstudio.gef.editor.command.CopyPasteHelper; +import de.bmotionstudio.gef.editor.internal.BControlPropertySource; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; + +/** + * + * A Control is a graphical representation of some aspects of the model. + * Typically we use labels, images or buttons to represent informations. For + * instance, if we model a system that has a temperature and a threshold + * temperature that triggers a cool down, we might simply use two labels + * displaying both values, or maybe we can incorporate both information into a + * gauge display. It is also possible to define new controls for domain specific + * visualizations. + * + * @author Lukas Ladenberger + * + */ +public abstract class BControl implements IAdaptable, Cloneable { + + protected String type; + + private BControlList children; + + private Map<String, Observer> observers; + + private Map<String, SchedulerEvent> events; + + private Map<String, AbstractAttribute> attributes; + + private BMotionGuide verticalGuide, horizontalGuide; + + // List of outgoing Connections + private List<BConnection> sourceConnections; + // List of incoming Connections + private List<BConnection> targetConnections; + + private transient Rectangle layout = null; + + private transient Point location = null; + + private transient BControl parent; + + private transient Visualization visualization; + + private transient PropertyChangeSupport listeners; + + private transient boolean newControl; + + public BControl(Visualization visualization) { + this.visualization = visualization; + this.children = new BControlList(); + this.observers = new HashMap<String, Observer>(); + this.events = new HashMap<String, SchedulerEvent>(); + this.attributes = new HashMap<String, AbstractAttribute>(); + this.listeners = new PropertyChangeSupport(this); + this.sourceConnections = new ArrayList<BConnection>(); + this.targetConnections = new ArrayList<BConnection>(); + this.newControl = true; + init(); + } + + protected Object readResolve() { + // Populate parent + for (BControl child : getChildrenArray()) + child.setParent(this); + this.newControl = false; + return this; + } + + /** + * Remove an incoming or outgoing connection from this shape. + * + * @param conn + * a non-null connection instance + * @throws IllegalArgumentException + * if the parameter is null + */ + public void removeConnection(BConnection conn) { + if (conn == null) { + throw new IllegalArgumentException(); + } + if (conn.getSource() == this) { + getSourceConnections().remove(conn); + getListeners().firePropertyChange( + BControlPropertyConstants.SOURCE_CONNECTIONS, null, conn); + } else if (conn.getTarget() == this) { + getTargetConnections().remove(conn); + getListeners().firePropertyChange( + BControlPropertyConstants.TARGET_CONNECTIONS, null, conn); + } + } + + /** + * Add an incoming or outgoing connection to this shape. + * + * @param conn + * a non-null connection instance + * @throws IllegalArgumentException + * if the connection is null or has not distinct endpoints + */ + public void addConnection(BConnection conn) { + if (conn == null || conn.getSource() == conn.getTarget()) { + throw new IllegalArgumentException(); + } + if (conn.getSource() == this) { + getSourceConnections().add(conn); + getListeners().firePropertyChange( + BControlPropertyConstants.SOURCE_CONNECTIONS, null, conn); + } else if (conn.getTarget() == this) { + getTargetConnections().add(conn); + getListeners().firePropertyChange( + BControlPropertyConstants.TARGET_CONNECTIONS, null, conn); + } + } + + protected void init() { + // Init standard control attributes + initStandardAttributes(); + // Init custom control attributes + initAttributes(); + + } + + private List<String> getSupportedObserverList() { + + List<String> supportedObserver = new ArrayList<String>(); + + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint( + "de.bmotionstudio.gef.editor.includeObserver"); + + for (IExtension extension : extensionPoint.getExtensions()) { + for (IConfigurationElement configurationElement : extension + .getConfigurationElements()) { + + if ("include".equals(configurationElement.getName())) { + + String langID = configurationElement + .getAttribute("language"); + + if (langID != null + && langID.equals(getVisualization() + .getLanguage())) { + + for (IConfigurationElement configC : configurationElement + .getChildren("control")) { + + String cID = configC.getAttribute("id"); + + if (getType().equals(cID)) { + + for (IConfigurationElement configO : configC + .getChildren("observer")) { + + supportedObserver.add(configO + .getAttribute("id")); + + } + + } + + } + + } + + } + + } + } + + return supportedObserver; + + } + + private void initStandardAttributes() { + + // Init unique ID + String ID; + if (this instanceof Visualization) + ID = "visualization"; + else if (visualization == null) + ID = UUID.randomUUID().toString(); + else + ID = (visualization.getMaxIDString(type)); + + BAttributeID aID = new BAttributeID(ID); + aID.setGroup(AbstractAttribute.ROOT); + initAttribute(aID); + + BAttributeMisc aMisc = new BAttributeMisc(""); + aMisc.setGroup(AbstractAttribute.ROOT); + initAttribute(aMisc); + + // Init location and size attributes + BAttributeCoordinates aCoordinates = new BAttributeCoordinates(null); + aCoordinates.setGroup(AbstractAttribute.ROOT); + initAttribute(aCoordinates); + + BAttributeX aX = new BAttributeX(100); + aX.setGroup(aCoordinates); + initAttribute(aX); + + BAttributeY aY = new BAttributeY(100); + aY.setGroup(aCoordinates); + initAttribute(aY); + + BAttributeSize aSize = new BAttributeSize(null); + aSize.setGroup(AbstractAttribute.ROOT); + initAttribute(aSize); + + BAttributeWidth aWidth = new BAttributeWidth(100); + aWidth.setGroup(aSize); + initAttribute(aWidth); + + BAttributeHeight aHeight = new BAttributeHeight(100); + aHeight.setGroup(aSize); + initAttribute(aHeight); + + // Init visible and this attribute + BAttributeVisible aVisible = new BAttributeVisible(true); + aVisible.setGroup(AbstractAttribute.ROOT); + initAttribute(aVisible); + + BAttributeCustom aCustom = new BAttributeCustom(""); + aCustom.setGroup(AbstractAttribute.ROOT); + initAttribute(aCustom); + + } + + protected abstract void initAttributes(); + + public String getID() { + return getAttributeValue(AttributeConstants.ATTRIBUTE_ID).toString(); + } + + public AbstractAttribute getAttribute(String attributeID) { + return getAttributes().get(attributeID); + } + + public Object getAttributeValue(String attributeID) { + + AbstractAttribute atr = attributes.get(attributeID); + + if (atr != null) { + return atr.getValue(); + } else { + // TODO: handle error/exception (no such attribute) + return null; + } + + } + + public boolean setAttributeValue(String attributeID, Object value) { + return setAttributeValue(attributeID, value, true, true); + } + + public boolean setAttributeValue(String attributeID, Object value, + Boolean firePropertyChange) { + return setAttributeValue(attributeID, value, firePropertyChange, true); + } + + public boolean setAttributeValue(String attributeID, Object value, + Boolean firePropertyChange, Boolean setInitVal) { + + AbstractAttribute atr = attributes.get(attributeID); + + if (atr == null) { + return false; + // TODO: Throw some error!?! + } + + atr.setControl(this); + + if ((atr.getValue() != null && atr.getValue().equals(value)) + || !atr.isEditable()) + return true; + + atr.setValue(value, firePropertyChange, setInitVal); + + return true; + + } + + public void restoreDefaultValue(String attributeID) { + AbstractAttribute atr = attributes.get(attributeID); + if (atr != null) { + atr.restoreValue(); + Object oldVal = atr.getValue(); + Object initValue = atr.getInitValue(); + getListeners().firePropertyChange(attributeID, oldVal, initValue); + } + } + + public boolean hasAttribute(String attributeID) { + return attributes.containsKey(attributeID); + } + + public void setLayout(Rectangle newLayout) { + Rectangle oldLayout = getLayout(); + layout = newLayout; + setAttributeValue(AttributeConstants.ATTRIBUTE_X, newLayout.x, false); + setAttributeValue(AttributeConstants.ATTRIBUTE_Y, newLayout.y, false); + setAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH, newLayout.width, + false); + setAttributeValue(AttributeConstants.ATTRIBUTE_HEIGHT, + newLayout.height, false); + getListeners() + .firePropertyChange(BControlPropertyConstants.PROPERTY_LAYOUT, + oldLayout, newLayout); + } + + public Rectangle getLayout() { + + String widthStr = getAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH) + .toString(); + String heightStr = getAttributeValue( + AttributeConstants.ATTRIBUTE_HEIGHT).toString(); + String xStr = getAttributeValue(AttributeConstants.ATTRIBUTE_X) + .toString(); + String yStr = getAttributeValue(AttributeConstants.ATTRIBUTE_Y) + .toString(); + + // TODO: check if strings are a correct integers + + try { + + int width = Integer.valueOf(widthStr); + int height = Integer.valueOf(heightStr); + int x = Integer.valueOf(xStr); + int y = Integer.valueOf(yStr); + + if (layout == null) { + layout = new Rectangle(x, y, width, height); + } else { + layout.x = x; + layout.y = y; + layout.width = width; + layout.height = height; + } + + } catch (NumberFormatException e) { + // We ignore number format exceptions, however we should return an + // error message here + // TODO: return error message + } + + return layout; + + } + + public void setLocation(Point newLocation) { + Point oldLocation = getLocation(); + location = newLocation; + setAttributeValue(AttributeConstants.ATTRIBUTE_X, newLocation.x, false); + setAttributeValue(AttributeConstants.ATTRIBUTE_Y, newLocation.y, false); + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_LOCATION, oldLocation, + newLocation); + } + + public Point getLocation() { + int x = Integer.valueOf(getAttributeValue( + AttributeConstants.ATTRIBUTE_X).toString()); + int y = Integer.valueOf(getAttributeValue( + AttributeConstants.ATTRIBUTE_Y).toString()); + if (location == null) { + location = new Point(x, y); + } else { + location.x = x; + location.y = y; + } + return location; + } + + public Dimension getDimension() { + int width = Integer.valueOf(getAttributeValue( + AttributeConstants.ATTRIBUTE_WIDTH).toString()); + int height = Integer.valueOf(getAttributeValue( + AttributeConstants.ATTRIBUTE_HEIGHT).toString()); + return new Dimension(width, height); + } + + public void addChild(BControl child) { + addChild(child, -1); + } + + public void addChild(BControl child, int index) { + child.setParent(this); + if (index >= 0) { + children.add(index, child); + } else { + children.add(child); + } + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_CHILD, index, child); + } + + public void removeAllChildren() { + getChildrenArray().clear(); + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_REMOVE_CHILD, null, null); + } + + public boolean removeChild(int index) { + BControl control = children.get(index); + return removeChild(control); + } + + public boolean removeChild(BControl child) { + boolean b = children.remove(child); + if (b) + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_REMOVE_CHILD, child, + null); + return b; + } + + public List<BControl> getChildrenArray() { + if (children == null) + children = new BControlList(); + return children; + } + + public void setChildrenArray(BControlList children) { + this.children = children; + } + + public boolean hasChildren() { + return children.size() > 0; + } + + public BControl getChild(String ID) { + for (BControl bcontrol : children) { + String bcontrolID = bcontrol.getAttributeValue( + AttributeConstants.ATTRIBUTE_ID).toString(); + if (bcontrolID != null) { + if (bcontrolID.equals(ID)) + return bcontrol; + } + } + return null; + } + + public Map<String, Observer> getObservers() { + if (observers == null) + observers = new HashMap<String, Observer>(); + return observers; + } + + public Observer getObserver(String observerID) { + return this.observers.get(observerID); + } + + public Boolean hasObserver(String ID) { + if (getObservers().containsKey(ID)) + return true; + return false; + } + + public void addObserver(Observer observer) { + observers.put(observer.getID(), (Observer) observer); + getListeners() + .firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_OBSERVER, + observer, null); + } + + public void removeObserver(Observer observer) { + removeObserver(observer.getID()); + } + + public void removeObserver(String observerID) { + Observer o = observers.remove(observerID); + if (o != null) { + o.beforeDelete(this); + getListeners() + .firePropertyChange( + BControlPropertyConstants.PROPERTY_REMOVE_OBSERVER, + o, null); + } + } + + public Map<String, SchedulerEvent> getEvents() { + if (events == null) + events = new HashMap<String, SchedulerEvent>(); + return events; + } + + public SchedulerEvent getEvent(String ID) { + return events.get(ID); + } + + public Boolean hasEvent(String ID) { + if (getEvents().containsKey(ID)) + return true; + return false; + } + + public void addEvent(String eventID, SchedulerEvent schedulerEvent) { + events.put(eventID, schedulerEvent); + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_ADD_EVENT, schedulerEvent, + null); + } + + public void removeEvent(String eventID) { + SchedulerEvent e = events.remove(eventID); + if (e != null) { + e.beforeDelete(this); + getListeners().firePropertyChange( + BControlPropertyConstants.PROPERTY_REMOVE_EVENT, e, null); + } + } + + public Map<String, AbstractAttribute> getAttributes() { + return attributes; + } + + public void setAttributes(Map<String, AbstractAttribute> attributes) { + this.attributes = attributes; + } + + public void setParent(BControl parent) { + this.parent = parent; + } + + public BControl getParent() { + return this.parent; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + getListeners().addPropertyChangeListener(listener); + } + + public PropertyChangeSupport getListeners() { + if (listeners == null) + listeners = new PropertyChangeSupport(this); + return listeners; + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getListeners().removePropertyChangeListener(listener); + } + + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { + if (adapter == IPropertySource.class) { + return new BControlPropertySource(this); + } + return null; + } + + public boolean contains(BControl child) { + return children.contains(child); + } + + public String getDefaultValue(String attributeID) { + + IConfigurationElement configurationElement = BMotionEditorPlugin + .getControlExtension(getType()); + + if (configurationElement != null) { + + for (final IConfigurationElement configBAttributes : configurationElement + .getChildren("attributes")) { + + for (final IConfigurationElement configBAttribute : configBAttributes + .getChildren("attribute-string")) { + + String aID = configBAttribute.getAttribute("id"); + + if (aID.equals(attributeID)) { + String attributeDefaultValue = configBAttribute + .getAttribute("default-value"); + + return attributeDefaultValue; + } + + } + + } + + } + + return null; + + } + + public Boolean isAttributeEditable(String attributeID) { + + IConfigurationElement configurationElement = BMotionEditorPlugin + .getControlExtension(getType()); + + if (configurationElement != null) { + + for (final IConfigurationElement configBAttributes : configurationElement + .getChildren("attributes")) { + + for (final IConfigurationElement configBAttribute : configBAttributes + .getChildren("attribute-string")) { + + String aID = configBAttribute.getAttribute("id"); + + if (aID.equals(attributeID)) { + String val = configBAttribute.getAttribute("editable"); + return Boolean.valueOf(val); + } + + } + + } + + } + + return false; + + } + + public Visualization getVisualization() { + return visualization; + } + + public void setVisualization(Visualization visualization) { + this.visualization = visualization; + } + + @Override + public BControl clone() throws CloneNotSupportedException { + + BControl clonedControl = (BControl) super.clone(); + + clonedControl.listeners = new PropertyChangeSupport(clonedControl); + clonedControl.sourceConnections = new ArrayList<BConnection>(); + clonedControl.targetConnections = new ArrayList<BConnection>(); + + clonedControl.setParent(getParent()); + + // Clone attributes + Map<String, AbstractAttribute> newProperties = new HashMap<String, AbstractAttribute>(); + for (Entry<String, AbstractAttribute> e : getAttributes().entrySet()) { + AbstractAttribute idAtr = e.getValue().clone(); + newProperties.put(e.getKey(), idAtr); + } + clonedControl.setAttributes(newProperties); + clonedControl.setAttributeValue(AttributeConstants.ATTRIBUTE_ID, + getVisualization().getMaxIDString(type)); + + // Clone children + clonedControl.setChildrenArray(new BControlList()); + Iterator<BControl> it = getChildrenArray().iterator(); + while (it.hasNext()) { + BControl next = (BControl) it.next(); + BControl childClone = next.clone(); + CopyPasteHelper cHelper = (CopyPasteHelper) Clipboard.getDefault() + .getContents(); + if (cHelper != null) + cHelper.getAlreadyClonedMap().put(next, childClone); + clonedControl.addChild(childClone); + } + + // Clone observer + clonedControl.setObserverMap(new HashMap<String, Observer>()); + for (Observer observer : observers.values()) { + clonedControl.addObserver(observer.clone()); + } + + // Clone events + clonedControl.setEventMap(new HashMap<String, SchedulerEvent>()); + for (Map.Entry<String, SchedulerEvent> e : events.entrySet()) { + clonedControl.addEvent(e.getKey(), e.getValue().clone()); + } + + return clonedControl; + + } + + public void checkObserver(final Animation animation) { + + // Check all Observers + for (Observer observer : getObservers().values()) { + observer.check(animation, BControl.this); + } + + // TODO: Currently connection observer are checked twice (source + + // target) => change this, so that observer are checked only on time per + // state!!! + for (BConnection con : getSourceConnections()) { + con.checkObserver(animation); + } + for (BConnection con : getTargetConnections()) { + con.checkObserver(animation); + } + + } + + public void executeEvent(String eventID) { + if (hasAttribute(AttributeConstants.ATTRIBUTE_ENABLED)) { + if (!(Boolean) getAttributeValue(AttributeConstants.ATTRIBUTE_ENABLED)) + return; + } + SchedulerEvent e = getEvents().get(eventID); + if (e != null) + e.execute(getVisualization().getAnimation(), this); + } + + public void setVerticalGuide(BMotionGuide verticalGuide) { + this.verticalGuide = verticalGuide; + } + + public BMotionGuide getVerticalGuide() { + return verticalGuide; + } + + public void setHorizontalGuide(BMotionGuide horizontalGuide) { + this.horizontalGuide = horizontalGuide; + } + + public BMotionGuide getHorizontalGuide() { + return horizontalGuide; + } + + /** + * Return a List of outgoing Connections. + */ + public List<BConnection> getSourceConnections() { + if (this.sourceConnections == null) + this.sourceConnections = new ArrayList<BConnection>(); + return this.sourceConnections; + } + + public void setSourceConnections(List<BConnection> connections) { + this.sourceConnections = connections; + } + + public void setTargetConnections(List<BConnection> connections) { + this.targetConnections = connections; + } + + /** + * Return a List of incoming Connections. + */ + public List<BConnection> getTargetConnections() { + if (this.targetConnections == null) + this.targetConnections = new ArrayList<BConnection>(); + return this.targetConnections; + } + + public boolean hasConnections() { + return !getTargetConnections().isEmpty() + || !getSourceConnections().isEmpty(); + } + + public boolean showInOutlineView() { + return true; + } + + public void setObserverMap(Map<String, Observer> observerMap) { + observers = observerMap; + } + + public void setEventMap(Map<String, SchedulerEvent> eventMap) { + events = eventMap; + } + + public abstract String getType(); + + protected void initAttribute(AbstractAttribute atr) { + + AbstractAttribute oldAtr = getAttribute(atr.getID()); + + // If a new control is created via the editor (not from the saved file) + // set the saved value of the file + if (oldAtr != null && !newControl) { + atr.setValue(oldAtr.getValue()); + atr.setDefaultValue(oldAtr.getDefaultValue()); + } + + getAttributes().put(atr.getID(), atr); + + } + + public boolean canHaveChildren() { + return false; + } + + public String getValueOfData() { + return getAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM) + .toString(); + } + + public Image getIcon() { + return BMotionStudioImage.getBControlImage(getType()); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControlList.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControlList.java index 8b156629c91fed2acbc5da0e93d048713c413a25..856d56e14cb6a32f1ee57947d0cd7afa1f9880d3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControlList.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControlList.java @@ -1,19 +1,19 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.util.ArrayList; - -/** - * @author Lukas Ladenberger - * - */ -public class BControlList extends ArrayList<BControl> { - - private static final long serialVersionUID = 1L; - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.util.ArrayList; + +/** + * @author Lukas Ladenberger + * + */ +public class BControlList extends ArrayList<BControl> { + + private static final long serialVersionUID = 1L; + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java index e85ed92ffdd7485541c99f7d367e74e779b5a974..b7fb7b1327756280cb0883f5ba7351455dd445a0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; - -/** - * @author Lukas Ladenberger - * - */ -public class BImage extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.image"; - - public BImage(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - initAttribute(new BAttributeImage(null)); - initAttribute(new BAttributeAlpha(255)); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; +import de.bmotionstudio.gef.editor.attribute.BAttributeImage; + +/** + * @author Lukas Ladenberger + * + */ +public class BImage extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.image"; + + public BImage(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + initAttribute(new BAttributeImage(null)); + initAttribute(new BAttributeAlpha(255)); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionGuide.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionGuide.java index 37bd419e09e0ecc8ff3bc9ec7940e58d8528c00b..74577521d1528d3e55d482851ce1b69b28777614 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionGuide.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionGuide.java @@ -1,218 +1,218 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Set; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.requests.ChangeBoundsRequest; - -/** - * Model object representing a guide. - * <p> - * In addition to maintaining information about which parts are attached to the - * guide, LogicGuide also maintains information about the edge along which those - * parts are attached. This information is useful during resize operations to - * determine the attachment status of a part. - * </p> - */ -public class BMotionGuide implements Serializable { - - /** - * Property used to notify listeners when the parts attached to a guide are - * changed - */ - public transient static final String PROPERTY_CHILDREN = "subparts changed"; //$NON-NLS-1$ - /** - * Property used to notify listeners when the guide is re-positioned - */ - public transient static final String PROPERTY_POSITION = "position changed"; //$NON-NLS-1$ - - static transient final long serialVersionUID = 1; - - protected transient PropertyChangeSupport listeners = new PropertyChangeSupport( - this); - private HashMap<BControl, Integer> map; - private int position; - private boolean horizontal; - - /** - * Empty default constructor - */ - public BMotionGuide() { - // empty constructor - } - - /** - * Constructor - * - * @param isHorizontal - * <code>true</code> if the guide is horizontal (i.e., placed on - * a vertical ruler) - */ - public BMotionGuide(boolean isHorizontal) { - setHorizontal(isHorizontal); - } - - protected Object readResolve() { - this.listeners = new PropertyChangeSupport(this); - return this; - } - - /** - * @see PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener) - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - listeners.addPropertyChangeListener(listener); - } - - /* - * @TODO:Pratik use PositionConstants here - */ - /** - * Attaches the given part along the given edge to this guide. The - * LogicSubpart is also updated to reflect this attachment. - * - * @param part - * The part that is to be attached to this guide; if the part is - * already attached, its alignment is updated - * @param alignment - * -1 is left or top; 0, center; 1, right or bottom - */ - public void attachPart(BControl control, int alignment) { - - if (getMap().containsKey(control) && getAlignment(control) == alignment) - return; - - getMap().put(control, Integer.valueOf(alignment)); - - BMotionGuide parent = isHorizontal() ? control.getHorizontalGuide() - : control.getVerticalGuide(); - if (parent != null && parent != this) { - parent.detachPart(control); - } - if (isHorizontal()) { - control.setHorizontalGuide(this); - } else { - control.setVerticalGuide(this); - } - listeners.firePropertyChange(PROPERTY_CHILDREN, null, control); - - } - - /** - * Detaches the given part from this guide. The LogicSubpart is also updated - * to reflect this change. - * - * @param part - * the part that is to be detached from this guide - */ - public void detachPart(BControl control) { - if (getMap().containsKey(control)) { - getMap().remove(control); - if (isHorizontal()) { - control.setHorizontalGuide(null); - } else { - control.setVerticalGuide(null); - } - listeners.firePropertyChange(PROPERTY_CHILDREN, null, control); - } - } - - /** - * This methods returns the edge along which the given part is attached to - * this guide. This information is used by - * {@link org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEditPolicy - * LogicXYLayoutEditPolicy} to determine whether to attach or detach a part - * from a guide during resize operations. - * - * @param part - * The part whose alignment has to be found - * @return an int representing the edge along which the given part is - * attached to this guide; 1 is bottom or right; 0, center; -1, top - * or left; -2 if the part is not attached to this guide - * @see org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEditPolicy#createChangeConstraintCommand(ChangeBoundsRequest, - * EditPart, Object) - */ - public int getAlignment(BControl part) { - if (getMap().get(part) != null) - return ((Integer) getMap().get(part)).intValue(); - return -2; - } - - /** - * @return The Map containing all the parts attached to this guide, and - * their alignments; the keys are LogicSubparts and values are - * Integers - */ - public HashMap<BControl, Integer> getMap() { - if (map == null) { - map = new HashMap<BControl, Integer>(); - } - return map; - } - - /** - * @return the set of all the parts attached to this guide; a set is used - * because a part can only be attached to a guide along one edge. - */ - public Set<BControl> getParts() { - return getMap().keySet(); - } - - /** - * @return the position/location of the guide (in pixels) - */ - public int getPosition() { - return position; - } - - /** - * @return <code>true</code> if the guide is horizontal (i.e., placed on a - * vertical ruler) - */ - public boolean isHorizontal() { - return horizontal; - } - - /** - * @see PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener) - */ - public void removePropertyChangeListener(PropertyChangeListener listener) { - listeners.removePropertyChangeListener(listener); - } - - /** - * Sets the orientation of the guide - * - * @param isHorizontal - * <code>true</code> if this guide is to be placed on a vertical - * ruler - */ - public void setHorizontal(boolean isHorizontal) { - horizontal = isHorizontal; - } - - /** - * Sets the location of the guide - * - * @param offset - * The location of the guide (in pixels) - */ - public void setPosition(int offset) { - if (position != offset) { - int oldValue = position; - position = offset; - listeners.firePropertyChange(PROPERTY_POSITION, - Integer.valueOf(oldValue), Integer.valueOf(position)); - } - } -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Set; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.requests.ChangeBoundsRequest; + +/** + * Model object representing a guide. + * <p> + * In addition to maintaining information about which parts are attached to the + * guide, LogicGuide also maintains information about the edge along which those + * parts are attached. This information is useful during resize operations to + * determine the attachment status of a part. + * </p> + */ +public class BMotionGuide implements Serializable { + + /** + * Property used to notify listeners when the parts attached to a guide are + * changed + */ + public transient static final String PROPERTY_CHILDREN = "subparts changed"; //$NON-NLS-1$ + /** + * Property used to notify listeners when the guide is re-positioned + */ + public transient static final String PROPERTY_POSITION = "position changed"; //$NON-NLS-1$ + + static transient final long serialVersionUID = 1; + + protected transient PropertyChangeSupport listeners = new PropertyChangeSupport( + this); + private HashMap<BControl, Integer> map; + private int position; + private boolean horizontal; + + /** + * Empty default constructor + */ + public BMotionGuide() { + // empty constructor + } + + /** + * Constructor + * + * @param isHorizontal + * <code>true</code> if the guide is horizontal (i.e., placed on + * a vertical ruler) + */ + public BMotionGuide(boolean isHorizontal) { + setHorizontal(isHorizontal); + } + + protected Object readResolve() { + this.listeners = new PropertyChangeSupport(this); + return this; + } + + /** + * @see PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener) + */ + public void addPropertyChangeListener(PropertyChangeListener listener) { + listeners.addPropertyChangeListener(listener); + } + + /* + * @TODO:Pratik use PositionConstants here + */ + /** + * Attaches the given part along the given edge to this guide. The + * LogicSubpart is also updated to reflect this attachment. + * + * @param part + * The part that is to be attached to this guide; if the part is + * already attached, its alignment is updated + * @param alignment + * -1 is left or top; 0, center; 1, right or bottom + */ + public void attachPart(BControl control, int alignment) { + + if (getMap().containsKey(control) && getAlignment(control) == alignment) + return; + + getMap().put(control, Integer.valueOf(alignment)); + + BMotionGuide parent = isHorizontal() ? control.getHorizontalGuide() + : control.getVerticalGuide(); + if (parent != null && parent != this) { + parent.detachPart(control); + } + if (isHorizontal()) { + control.setHorizontalGuide(this); + } else { + control.setVerticalGuide(this); + } + listeners.firePropertyChange(PROPERTY_CHILDREN, null, control); + + } + + /** + * Detaches the given part from this guide. The LogicSubpart is also updated + * to reflect this change. + * + * @param part + * the part that is to be detached from this guide + */ + public void detachPart(BControl control) { + if (getMap().containsKey(control)) { + getMap().remove(control); + if (isHorizontal()) { + control.setHorizontalGuide(null); + } else { + control.setVerticalGuide(null); + } + listeners.firePropertyChange(PROPERTY_CHILDREN, null, control); + } + } + + /** + * This methods returns the edge along which the given part is attached to + * this guide. This information is used by + * {@link org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEditPolicy + * LogicXYLayoutEditPolicy} to determine whether to attach or detach a part + * from a guide during resize operations. + * + * @param part + * The part whose alignment has to be found + * @return an int representing the edge along which the given part is + * attached to this guide; 1 is bottom or right; 0, center; -1, top + * or left; -2 if the part is not attached to this guide + * @see org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEditPolicy#createChangeConstraintCommand(ChangeBoundsRequest, + * EditPart, Object) + */ + public int getAlignment(BControl part) { + if (getMap().get(part) != null) + return ((Integer) getMap().get(part)).intValue(); + return -2; + } + + /** + * @return The Map containing all the parts attached to this guide, and + * their alignments; the keys are LogicSubparts and values are + * Integers + */ + public HashMap<BControl, Integer> getMap() { + if (map == null) { + map = new HashMap<BControl, Integer>(); + } + return map; + } + + /** + * @return the set of all the parts attached to this guide; a set is used + * because a part can only be attached to a guide along one edge. + */ + public Set<BControl> getParts() { + return getMap().keySet(); + } + + /** + * @return the position/location of the guide (in pixels) + */ + public int getPosition() { + return position; + } + + /** + * @return <code>true</code> if the guide is horizontal (i.e., placed on a + * vertical ruler) + */ + public boolean isHorizontal() { + return horizontal; + } + + /** + * @see PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener) + */ + public void removePropertyChangeListener(PropertyChangeListener listener) { + listeners.removePropertyChangeListener(listener); + } + + /** + * Sets the orientation of the guide + * + * @param isHorizontal + * <code>true</code> if this guide is to be placed on a vertical + * ruler + */ + public void setHorizontal(boolean isHorizontal) { + horizontal = isHorizontal; + } + + /** + * Sets the location of the guide + * + * @param offset + * The location of the guide (in pixels) + */ + public void setPosition(int offset) { + if (position != offset) { + int oldValue = position; + position = offset; + listeners.firePropertyChange(PROPERTY_POSITION, + Integer.valueOf(oldValue), Integer.valueOf(position)); + } + } +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRuler.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRuler.java index cb3d4333d1d2fd09199c19f7773ecb42baae071b..f6d3d22e084e059d3ca106f1f8ceb2fc812288b5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRuler.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRuler.java @@ -1,95 +1,95 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.rulers.RulerProvider; - - -public class BMotionRuler implements Serializable { - - public transient static final String PROPERTY_CHILDREN = "children changed"; //$NON-NLS-1$ - public transient static final String PROPERTY_UNIT = "units changed"; //$NON-NLS-1$ - - static transient final long serialVersionUID = 1; - - protected transient PropertyChangeSupport listeners = new PropertyChangeSupport( - this); - private int unit; - private boolean horizontal; - private List<BMotionGuide> guides = new ArrayList<BMotionGuide>(); - - public BMotionRuler(boolean isHorizontal) { - this(isHorizontal, RulerProvider.UNIT_PIXELS); - } - - public BMotionRuler(boolean isHorizontal, int unit) { - horizontal = isHorizontal; - setUnit(unit); - } - - protected Object readResolve() { - this.listeners = new PropertyChangeSupport(this); - return this; - } - - public void addGuide(BMotionGuide guide) { - if (!guides.contains(guide)) { - guide.setHorizontal(!isHorizontal()); - guides.add(guide); - listeners.firePropertyChange(PROPERTY_CHILDREN, null, guide); - } - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - listeners.addPropertyChangeListener(listener); - } - - // the returned list should not be modified - public List<BMotionGuide> getGuides() { - return guides; - } - - public int getUnit() { - return unit; - } - - public boolean isHidden() { - return false; - } - - public boolean isHorizontal() { - return horizontal; - } - - public void removeGuide(BMotionGuide guide) { - if (guides.remove(guide)) { - listeners.firePropertyChange(PROPERTY_CHILDREN, null, guide); - } - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - listeners.removePropertyChangeListener(listener); - } - - public void setHidden(boolean isHidden) { - } - - public void setUnit(int newUnit) { - if (unit != newUnit) { - int oldUnit = unit; - unit = newUnit; - listeners.firePropertyChange(PROPERTY_UNIT, oldUnit, newUnit); - } - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.rulers.RulerProvider; + + +public class BMotionRuler implements Serializable { + + public transient static final String PROPERTY_CHILDREN = "children changed"; //$NON-NLS-1$ + public transient static final String PROPERTY_UNIT = "units changed"; //$NON-NLS-1$ + + static transient final long serialVersionUID = 1; + + protected transient PropertyChangeSupport listeners = new PropertyChangeSupport( + this); + private int unit; + private boolean horizontal; + private List<BMotionGuide> guides = new ArrayList<BMotionGuide>(); + + public BMotionRuler(boolean isHorizontal) { + this(isHorizontal, RulerProvider.UNIT_PIXELS); + } + + public BMotionRuler(boolean isHorizontal, int unit) { + horizontal = isHorizontal; + setUnit(unit); + } + + protected Object readResolve() { + this.listeners = new PropertyChangeSupport(this); + return this; + } + + public void addGuide(BMotionGuide guide) { + if (!guides.contains(guide)) { + guide.setHorizontal(!isHorizontal()); + guides.add(guide); + listeners.firePropertyChange(PROPERTY_CHILDREN, null, guide); + } + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + listeners.addPropertyChangeListener(listener); + } + + // the returned list should not be modified + public List<BMotionGuide> getGuides() { + return guides; + } + + public int getUnit() { + return unit; + } + + public boolean isHidden() { + return false; + } + + public boolean isHorizontal() { + return horizontal; + } + + public void removeGuide(BMotionGuide guide) { + if (guides.remove(guide)) { + listeners.firePropertyChange(PROPERTY_CHILDREN, null, guide); + } + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + listeners.removePropertyChangeListener(listener); + } + + public void setHidden(boolean isHidden) { + } + + public void setUnit(int newUnit) { + if (unit != newUnit) { + int oldUnit = unit; + unit = newUnit; + listeners.firePropertyChange(PROPERTY_UNIT, oldUnit, newUnit); + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRulerProvider.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRulerProvider.java index a124bbededfbed0e8917e02ad3d45b4c8d910f9c..97d10cddbecf893dfb18bb68da9aeb6f0d04e55c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRulerProvider.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BMotionRulerProvider.java @@ -1,118 +1,118 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.rulers.RulerChangeListener; -import org.eclipse.gef.rulers.RulerProvider; - -import de.bmotionstudio.gef.editor.command.CreateGuideCommand; -import de.bmotionstudio.gef.editor.command.DeleteGuideCommand; -import de.bmotionstudio.gef.editor.command.MoveGuideCommand; - -public class BMotionRulerProvider extends RulerProvider { - - private BMotionRuler ruler; - private PropertyChangeListener rulerListener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals(BMotionRuler.PROPERTY_CHILDREN)) { - BMotionGuide guide = (BMotionGuide) evt.getNewValue(); - if (getGuides().contains(guide)) { - guide.addPropertyChangeListener(guideListener); - } else { - guide.removePropertyChangeListener(guideListener); - } - for (int i = 0; i < listeners.size(); i++) { - ((RulerChangeListener) listeners.get(i)) - .notifyGuideReparented(guide); - } - } else { - for (int i = 0; i < listeners.size(); i++) { - ((RulerChangeListener) listeners.get(i)) - .notifyUnitsChanged(ruler.getUnit()); - } - } - } - }; - private PropertyChangeListener guideListener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals(BMotionGuide.PROPERTY_CHILDREN)) { - for (int i = 0; i < listeners.size(); i++) { - ((RulerChangeListener) listeners.get(i)) - .notifyPartAttachmentChanged(evt.getNewValue(), evt - .getSource()); - } - } else { - for (int i = 0; i < listeners.size(); i++) { - ((RulerChangeListener) listeners.get(i)) - .notifyGuideMoved(evt.getSource()); - } - } - } - }; - - public BMotionRulerProvider(BMotionRuler ruler) { - this.ruler = ruler; - this.ruler.addPropertyChangeListener(rulerListener); - List<BMotionGuide> guides = getGuides(); - for (int i = 0; i < guides.size(); i++) { - ((BMotionGuide) guides.get(i)) - .addPropertyChangeListener(guideListener); - } - } - - public List<BControl> getAttachedModelObjects(Object guide) { - return new ArrayList<BControl>(((BMotionGuide) guide).getParts()); - } - - public Command getCreateGuideCommand(int position) { - return new CreateGuideCommand(ruler, position); - } - - public Command getDeleteGuideCommand(Object guide) { - return new DeleteGuideCommand((BMotionGuide) guide, ruler); - } - - public Command getMoveGuideCommand(Object guide, int pDelta) { - return new MoveGuideCommand((BMotionGuide) guide, pDelta); - } - - public int[] getGuidePositions() { - List<BMotionGuide> guides = getGuides(); - int[] result = new int[guides.size()]; - for (int i = 0; i < guides.size(); i++) { - result[i] = ((BMotionGuide) guides.get(i)).getPosition(); - } - return result; - } - - public Object getRuler() { - return ruler; - } - - public int getUnit() { - return ruler.getUnit(); - } - - public void setUnit(int newUnit) { - ruler.setUnit(newUnit); - } - - public int getGuidePosition(Object guide) { - return ((BMotionGuide) guide).getPosition(); - } - - public List<BMotionGuide> getGuides() { - return ruler.getGuides(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.rulers.RulerChangeListener; +import org.eclipse.gef.rulers.RulerProvider; + +import de.bmotionstudio.gef.editor.command.CreateGuideCommand; +import de.bmotionstudio.gef.editor.command.DeleteGuideCommand; +import de.bmotionstudio.gef.editor.command.MoveGuideCommand; + +public class BMotionRulerProvider extends RulerProvider { + + private BMotionRuler ruler; + private PropertyChangeListener rulerListener = new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals(BMotionRuler.PROPERTY_CHILDREN)) { + BMotionGuide guide = (BMotionGuide) evt.getNewValue(); + if (getGuides().contains(guide)) { + guide.addPropertyChangeListener(guideListener); + } else { + guide.removePropertyChangeListener(guideListener); + } + for (int i = 0; i < listeners.size(); i++) { + ((RulerChangeListener) listeners.get(i)) + .notifyGuideReparented(guide); + } + } else { + for (int i = 0; i < listeners.size(); i++) { + ((RulerChangeListener) listeners.get(i)) + .notifyUnitsChanged(ruler.getUnit()); + } + } + } + }; + private PropertyChangeListener guideListener = new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals(BMotionGuide.PROPERTY_CHILDREN)) { + for (int i = 0; i < listeners.size(); i++) { + ((RulerChangeListener) listeners.get(i)) + .notifyPartAttachmentChanged(evt.getNewValue(), evt + .getSource()); + } + } else { + for (int i = 0; i < listeners.size(); i++) { + ((RulerChangeListener) listeners.get(i)) + .notifyGuideMoved(evt.getSource()); + } + } + } + }; + + public BMotionRulerProvider(BMotionRuler ruler) { + this.ruler = ruler; + this.ruler.addPropertyChangeListener(rulerListener); + List<BMotionGuide> guides = getGuides(); + for (int i = 0; i < guides.size(); i++) { + ((BMotionGuide) guides.get(i)) + .addPropertyChangeListener(guideListener); + } + } + + public List<BControl> getAttachedModelObjects(Object guide) { + return new ArrayList<BControl>(((BMotionGuide) guide).getParts()); + } + + public Command getCreateGuideCommand(int position) { + return new CreateGuideCommand(ruler, position); + } + + public Command getDeleteGuideCommand(Object guide) { + return new DeleteGuideCommand((BMotionGuide) guide, ruler); + } + + public Command getMoveGuideCommand(Object guide, int pDelta) { + return new MoveGuideCommand((BMotionGuide) guide, pDelta); + } + + public int[] getGuidePositions() { + List<BMotionGuide> guides = getGuides(); + int[] result = new int[guides.size()]; + for (int i = 0; i < guides.size(); i++) { + result[i] = ((BMotionGuide) guides.get(i)).getPosition(); + } + return result; + } + + public Object getRuler() { + return ruler; + } + + public int getUnit() { + return ruler.getUnit(); + } + + public void setUnit(int newUnit) { + ruler.setUnit(newUnit); + } + + public int getGuidePosition(Object guide) { + return ((BMotionGuide) guide).getPosition(); + } + + public List<BMotionGuide> getGuides() { + return ruler.getGuides(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java index ea370fbfd120477d521b6dba181cd4bbab4b9537..0c5e80c466348c1fc56ee448d60842b23dac9180 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java @@ -1,91 +1,86 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.util.Collection; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.ButtonGroupHelper; -import de.bmotionstudio.gef.editor.attribute.BAttributeButtonGroup; -import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeValue; - -/** - * @author Lukas Ladenberger - * - */ -public class BRadioButton extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.radiobutton"; - - public static transient String DEFAULT_TEXT = "Text..."; - - public BRadioButton(Visualization visualization) { - super(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.model.BControl#getType() - */ - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeEnabled(true)); - initAttribute(new BAttributeChecked(true)); - initAttribute(new BAttributeValue("")); - initAttribute(new BAttributeButtonGroup("")); - - BAttributeHeight aHeight = new BAttributeHeight(21); - aHeight.setGroup(BAttributeSize.ID); - aHeight.setShow(false); - aHeight.setEditable(false); - initAttribute(aHeight); - - } - - @Override - public String getValueOfData() { - String btgroupid = getAttributeValue( - AttributeConstants.ATTRIBUTE_BUTTONGROUP).toString(); - if (!btgroupid.trim().equals("")) { - Collection<BControl> btGroup = ButtonGroupHelper - .getButtonGroup(btgroupid); - return getValueFromButtonGroup(btGroup); - } else { - return getAttributeValue(AttributeConstants.ATTRIBUTE_VALUE) - .toString(); - } - } - - private String getValueFromButtonGroup(Collection<BControl> group) { - for (BControl control : group) { - if (Boolean.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED).toString())) { - return control.getAttributeValue( - AttributeConstants.ATTRIBUTE_VALUE).toString(); - } - } - return ""; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.util.Collection; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.ButtonGroupHelper; +import de.bmotionstudio.gef.editor.attribute.BAttributeButtonGroup; +import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; +import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeText; +import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeValue; + +/** + * @author Lukas Ladenberger + * + */ +public class BRadioButton extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.radiobutton"; + + public static transient String DEFAULT_TEXT = "Text..."; + + public BRadioButton(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeText(DEFAULT_TEXT)); + initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); + initAttribute(new BAttributeEnabled(true)); + initAttribute(new BAttributeChecked(true)); + initAttribute(new BAttributeValue("")); + initAttribute(new BAttributeButtonGroup("")); + + BAttributeHeight aHeight = new BAttributeHeight(21); + aHeight.setGroup(BAttributeSize.ID); + aHeight.setShow(false); + aHeight.setEditable(false); + initAttribute(aHeight); + + } + + @Override + public String getValueOfData() { + String btgroupid = getAttributeValue( + AttributeConstants.ATTRIBUTE_BUTTONGROUP).toString(); + if (!btgroupid.trim().equals("")) { + Collection<BControl> btGroup = ButtonGroupHelper + .getButtonGroup(btgroupid); + return getValueFromButtonGroup(btGroup); + } else { + return getAttributeValue(AttributeConstants.ATTRIBUTE_VALUE) + .toString(); + } + } + + private String getValueFromButtonGroup(Collection<BControl> group) { + for (BControl control : group) { + if (Boolean.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED).toString())) { + return control.getAttributeValue( + AttributeConstants.ATTRIBUTE_VALUE).toString(); + } + } + return ""; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java index 3e2bdb233831215341b2be3ff2777f63be9860e4..67b417fe350ffd3f545aacc3f61605842a3c4aea 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java @@ -1,71 +1,71 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeDirection; -import de.bmotionstudio.gef.editor.attribute.BAttributeFillType; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; -import de.bmotionstudio.gef.editor.attribute.BAttributeOrientation; -import de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha; -import de.bmotionstudio.gef.editor.attribute.BAttributeShape; - -/** - * @author Lukas Ladenberger - * - */ -public class BShape extends BControl { - - public static transient String TYPE_RECTANGLE = "de.bmotionstudio.gef.editor.rectangle"; - public static transient String TYPE_OVAL = "de.bmotionstudio.gef.editor.ellipse"; - - public BShape(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( - BAttributeShape.SHAPE_OVAL)) - return TYPE_OVAL; - else - return TYPE_RECTANGLE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeBackgroundColor(new RGB(255, 0, 0))); - initAttribute(new BAttributeForegroundColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeImage(null)); - initAttribute(new BAttributeAlpha(255)); - initAttribute(new BAttributeOutlineAlpha(0)); - initAttribute(new BAttributeShape(BAttributeShape.SHAPE_RECTANGLE)); - initAttribute(new BAttributeOrientation( - BAttributeOrientation.HORIZONTAL)); - initAttribute(new BAttributeDirection(BAttributeDirection.NORTH)); - initAttribute(new BAttributeFillType(BAttributeFillType.FILLED)); - - } - - @Override - public Image getIcon() { - if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( - BAttributeShape.SHAPE_OVAL)) - return BMotionStudioImage.getBControlImage(TYPE_OVAL); - else - return super.getIcon(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeDirection; +import de.bmotionstudio.gef.editor.attribute.BAttributeFillType; +import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeImage; +import de.bmotionstudio.gef.editor.attribute.BAttributeOrientation; +import de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha; +import de.bmotionstudio.gef.editor.attribute.BAttributeShape; + +/** + * @author Lukas Ladenberger + * + */ +public class BShape extends BControl { + + public static transient String TYPE_RECTANGLE = "de.bmotionstudio.gef.editor.rectangle"; + public static transient String TYPE_OVAL = "de.bmotionstudio.gef.editor.ellipse"; + + public BShape(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( + BAttributeShape.SHAPE_OVAL)) + return TYPE_OVAL; + else + return TYPE_RECTANGLE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeBackgroundColor(new RGB(255, 0, 0))); + initAttribute(new BAttributeForegroundColor(new RGB(0, 0, 0))); + initAttribute(new BAttributeImage(null)); + initAttribute(new BAttributeAlpha(255)); + initAttribute(new BAttributeOutlineAlpha(0)); + initAttribute(new BAttributeShape(BAttributeShape.SHAPE_RECTANGLE)); + initAttribute(new BAttributeOrientation( + BAttributeOrientation.HORIZONTAL)); + initAttribute(new BAttributeDirection(BAttributeDirection.NORTH)); + initAttribute(new BAttributeFillType(BAttributeFillType.FILLED)); + + } + + @Override + public Image getIcon() { + if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( + BAttributeShape.SHAPE_OVAL)) + return BMotionStudioImage.getBControlImage(TYPE_OVAL); + else + return super.getIcon(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java index 6a2ad36c36265fab3fb457a4d6419c58b3c66514..3f69c7a818abc5023bc0b70f8e22243dddb18cbc 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java @@ -1,49 +1,49 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.draw2d.ColorConstants; - -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundVisible; -import de.bmotionstudio.gef.editor.attribute.BAttributeFont; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; - -/** - * @author Lukas Ladenberger - * - */ -public class BText extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.text"; - - public static transient String DEFAULT_TEXT = "Text..."; - - public BText(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeTextColor(ColorConstants.black.getRGB())); - initAttribute(new BAttributeBackgroundColor( - ColorConstants.white.getRGB())); - initAttribute(new BAttributeBackgroundVisible(true)); - initAttribute(new BAttributeFont( - "1||9.75|0|WINDOWS|1|-13|0|0|0|400|0|0|0|0|0|0|0|0|")); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.draw2d.ColorConstants; + +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundVisible; +import de.bmotionstudio.gef.editor.attribute.BAttributeFont; +import de.bmotionstudio.gef.editor.attribute.BAttributeText; +import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; + +/** + * @author Lukas Ladenberger + * + */ +public class BText extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.text"; + + public static transient String DEFAULT_TEXT = "Text..."; + + public BText(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeText(DEFAULT_TEXT)); + initAttribute(new BAttributeTextColor(ColorConstants.black.getRGB())); + initAttribute(new BAttributeBackgroundColor( + ColorConstants.white.getRGB())); + initAttribute(new BAttributeBackgroundVisible(true)); + initAttribute(new BAttributeFont( + "1||9.75|0|WINDOWS|1|-13|0|0|0|400|0|0|0|0|0|0|0|0|")); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java index aafd035e5c872cc4929ebe3b8535110b1bde9f23..d764510c673002f3b72db9d8a753009c712cada1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java @@ -1,51 +1,51 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; - -/** - * @author Lukas Ladenberger - * - */ -public class BTextfield extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.textfield"; - - public static transient String DEFAULT_TEXT = "Text..."; - - public BTextfield(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeText(DEFAULT_TEXT)); - - BAttributeHeight aHeight = new BAttributeHeight(21); - aHeight.setGroup(BAttributeSize.ID); - aHeight.setShow(false); - aHeight.setEditable(false); - initAttribute(aHeight); - - } - - @Override - public String getValueOfData() { - return getAttributeValue(AttributeConstants.ATTRIBUTE_TEXT).toString(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeText; + +/** + * @author Lukas Ladenberger + * + */ +public class BTextfield extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.textfield"; + + public static transient String DEFAULT_TEXT = "Text..."; + + public BTextfield(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeText(DEFAULT_TEXT)); + + BAttributeHeight aHeight = new BAttributeHeight(21); + aHeight.setGroup(BAttributeSize.ID); + aHeight.setShow(false); + aHeight.setEditable(false); + initAttribute(aHeight); + + } + + @Override + public String getValueOfData() { + return getAttributeValue(AttributeConstants.ATTRIBUTE_TEXT).toString(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Signal.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Signal.java index 3d45a52eacd06f0667f37debc2041937a18e4e37..6a3023daace32226707d8f22334156587afb0634 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Signal.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Signal.java @@ -1,68 +1,68 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.draw2d.geometry.Rectangle; - -import de.bmotionstudio.gef.editor.attribute.AttributeLights; -import de.bmotionstudio.gef.editor.attribute.AttributeTrackDirection; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.command.CreateCommand; - -/** - * @author Lukas Ladenberger - * - */ -public class Signal extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.signal"; - - public Signal(Visualization visualization) { - - super(visualization); - - int numberOfLights = 2; - - CreateCommand cmd; - for (int i = 0; i < numberOfLights; i++) { - Light light = new Light(visualization); - cmd = new CreateCommand(light, this); - cmd.setLayout(new Rectangle(0, 0, 12, 12)); - cmd.execute(); - } - - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - BAttributeHeight aHeight = new BAttributeHeight(48); - aHeight.setGroup(BAttributeSize.ID); - aHeight.setShow(false); - aHeight.setEditable(false); - initAttribute(aHeight); - - initAttribute(new AttributeTrackDirection(AttributeTrackDirection.RIGHT)); - initAttribute(new AttributeLights(2)); - - BAttributeLabel aLabel = new BAttributeLabel("Signal"); - initAttribute(aLabel); - - } - - @Override - public boolean canHaveChildren() { - return true; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.draw2d.geometry.Rectangle; + +import de.bmotionstudio.gef.editor.attribute.AttributeLights; +import de.bmotionstudio.gef.editor.attribute.AttributeTrackDirection; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.command.CreateCommand; + +/** + * @author Lukas Ladenberger + * + */ +public class Signal extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.signal"; + + public Signal(Visualization visualization) { + + super(visualization); + + int numberOfLights = 2; + + CreateCommand cmd; + for (int i = 0; i < numberOfLights; i++) { + Light light = new Light(visualization); + cmd = new CreateCommand(light, this); + cmd.setLayout(new Rectangle(0, 0, 12, 12)); + cmd.execute(); + } + + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + BAttributeHeight aHeight = new BAttributeHeight(48); + aHeight.setGroup(BAttributeSize.ID); + aHeight.setShow(false); + aHeight.setEditable(false); + initAttribute(aHeight); + + initAttribute(new AttributeTrackDirection(AttributeTrackDirection.RIGHT)); + initAttribute(new AttributeLights(2)); + + BAttributeLabel aLabel = new BAttributeLabel("Signal"); + initAttribute(aLabel); + + } + + @Override + public boolean canHaveChildren() { + return true; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java index 1fa35bd1b7bbd5ba1112618bef532c4bd8e207d8..983beb6f8778c899c86eea77ca3bd9c1d7fa8d9e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java @@ -1,178 +1,178 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.geometry.Rectangle; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection; -import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; -import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; -import de.bmotionstudio.gef.editor.command.CreateCommand; - -public class Switch extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.switch"; - - private transient Track track1; - - private transient Track track2; - - public Switch(Visualization visualization) { - - super(visualization); - - // Build up switch - TrackNode tracknode1 = new TrackNode(getVisualization()); - CreateCommand cmd = new CreateCommand(tracknode1, this); - cmd.setLayout(new Rectangle(5, 0, 50, 20)); - cmd.execute(); - - TrackNode tracknode2 = new TrackNode(getVisualization()); - cmd = new CreateCommand(tracknode2, this); - cmd.setLayout(new Rectangle(70, 0, 50, 20)); - cmd.execute(); - - TrackNode tracknode3 = new TrackNode(getVisualization()); - cmd = new CreateCommand(tracknode3, this); - cmd.setLayout(new Rectangle(70, 70, 50, 20)); - cmd.execute(); - - ConnectionCreateCommand trackCreateCmd = new ConnectionCreateCommand( - tracknode1); - trackCreateCmd.setTarget(tracknode2); - track1 = new Track(getVisualization()); - trackCreateCmd.setConnection(track1); - trackCreateCmd.execute(); - - trackCreateCmd = new ConnectionCreateCommand(tracknode1); - trackCreateCmd.setTarget(tracknode3); - track2 = new Track(getVisualization()); - trackCreateCmd.setConnection(track2); - trackCreateCmd.execute(); - - track1.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); - track2.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); - - track1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "LEFT"); - AbstractAttribute a1 = track1 - .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); - a1.setEditable(false); - a1.setShow(false); - - track2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "RIGHT"); - AbstractAttribute a2 = track2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); - a2.setEditable(false); - a2.setShow(false); - - tracknode1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "1"); - tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) - .setEditable(false); - tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( - false); - tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) - .setShow(false); - - tracknode2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "2"); - tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) - .setEditable(false); - tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( - false); - tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) - .setShow(false); - - tracknode3.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "3"); - tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) - .setEditable(false); - tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( - false); - tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) - .setShow(false); - - } - - @Override - protected void initAttributes() { - - BAttributeHeight aHeight = new BAttributeHeight(50); - aHeight.setGroup(BAttributeSize.ID); - initAttribute(aHeight); - - BAttributeWidth aWidth = new BAttributeWidth(100); - aWidth.setGroup(BAttributeSize.ID); - initAttribute(aWidth); - - initAttribute(new AttributeSwitchDirection( - AttributeSwitchDirection.RIGHT_SOUTH)); - initAttribute(new AttributeSwitchPosition( - AttributeSwitchPosition.UNKNOWN)); - - } - - // We have to set the two tracks of the switch, since their are set to - // transient - protected Object readResolve() { - - super.readResolve(); - - for (BControl control : getChildrenArray()) { - - List<Track> tracks = new ArrayList<Track>(); - for (BConnection c : ((TrackNode) control).getSourceConnections()) { - if (c instanceof Track) - tracks.add((Track) c); - } - for (BConnection c : ((TrackNode) control).getTargetConnections()) { - if (c instanceof Track) - tracks.add((Track) c); - } - for (Track n : tracks) { - AbstractAttribute a2 = n - .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); - if (a2.getValue().equals("LEFT")) { - a2.setEditable(false); - a2.setShow(false); - track1 = n; - } else if (a2.getValue().equals("RIGHT")) { - track2 = n; - a2.setEditable(false); - a2.setShow(false); - } - } - - } - - return this; - - } - - @Override - public String getType() { - return TYPE; - } - - @Override - public boolean canHaveChildren() { - return true; - } - - public Track getTrack1() { - return track1; - } - - public Track getTrack2() { - return track2; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.geometry.Rectangle; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection; +import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; +import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand; +import de.bmotionstudio.gef.editor.command.CreateCommand; + +public class Switch extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.switch"; + + private transient Track track1; + + private transient Track track2; + + public Switch(Visualization visualization) { + + super(visualization); + + // Build up switch + TrackNode tracknode1 = new TrackNode(getVisualization()); + CreateCommand cmd = new CreateCommand(tracknode1, this); + cmd.setLayout(new Rectangle(5, 0, 50, 20)); + cmd.execute(); + + TrackNode tracknode2 = new TrackNode(getVisualization()); + cmd = new CreateCommand(tracknode2, this); + cmd.setLayout(new Rectangle(70, 0, 50, 20)); + cmd.execute(); + + TrackNode tracknode3 = new TrackNode(getVisualization()); + cmd = new CreateCommand(tracknode3, this); + cmd.setLayout(new Rectangle(70, 70, 50, 20)); + cmd.execute(); + + ConnectionCreateCommand trackCreateCmd = new ConnectionCreateCommand( + tracknode1); + trackCreateCmd.setTarget(tracknode2); + track1 = new Track(getVisualization()); + trackCreateCmd.setConnection(track1); + trackCreateCmd.execute(); + + trackCreateCmd = new ConnectionCreateCommand(tracknode1); + trackCreateCmd.setTarget(tracknode3); + track2 = new Track(getVisualization()); + trackCreateCmd.setConnection(track2); + trackCreateCmd.execute(); + + track1.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); + track2.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); + + track1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "LEFT"); + AbstractAttribute a1 = track1 + .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); + a1.setEditable(false); + a1.setShow(false); + + track2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "RIGHT"); + AbstractAttribute a2 = track2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); + a2.setEditable(false); + a2.setShow(false); + + tracknode1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "1"); + tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( + false); + tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); + + tracknode2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "2"); + tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( + false); + tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); + + tracknode3.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "3"); + tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow( + false); + tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); + + } + + @Override + protected void initAttributes() { + + BAttributeHeight aHeight = new BAttributeHeight(50); + aHeight.setGroup(BAttributeSize.ID); + initAttribute(aHeight); + + BAttributeWidth aWidth = new BAttributeWidth(100); + aWidth.setGroup(BAttributeSize.ID); + initAttribute(aWidth); + + initAttribute(new AttributeSwitchDirection( + AttributeSwitchDirection.RIGHT_SOUTH)); + initAttribute(new AttributeSwitchPosition( + AttributeSwitchPosition.UNKNOWN)); + + } + + // We have to set the two tracks of the switch, since their are set to + // transient + protected Object readResolve() { + + super.readResolve(); + + for (BControl control : getChildrenArray()) { + + List<Track> tracks = new ArrayList<Track>(); + for (BConnection c : ((TrackNode) control).getSourceConnections()) { + if (c instanceof Track) + tracks.add((Track) c); + } + for (BConnection c : ((TrackNode) control).getTargetConnections()) { + if (c instanceof Track) + tracks.add((Track) c); + } + for (Track n : tracks) { + AbstractAttribute a2 = n + .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); + if (a2.getValue().equals("LEFT")) { + a2.setEditable(false); + a2.setShow(false); + track1 = n; + } else if (a2.getValue().equals("RIGHT")) { + track2 = n; + a2.setEditable(false); + a2.setShow(false); + } + } + + } + + return this; + + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public boolean canHaveChildren() { + return true; + } + + public Track getTrack1() { + return track1; + } + + public Track getTrack2() { + return track2; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Tank.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Tank.java index 3b6215e913f60487831895b846c286c449e81945..4b05d926ecbebdc730030b0144170b1fe7378082 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Tank.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Tank.java @@ -1,46 +1,46 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.draw2d.ColorConstants; - -import de.bmotionstudio.gef.editor.attribute.AttributeFillColor; -import de.bmotionstudio.gef.editor.attribute.AttributeFillHeight; -import de.bmotionstudio.gef.editor.attribute.AttributeMeasureInterval; -import de.bmotionstudio.gef.editor.attribute.AttributeMeasureMaxPos; -import de.bmotionstudio.gef.editor.attribute.AttributeShowMeasure; -import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; - -public class Tank extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.tank"; - - public Tank(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - initAttribute(new BAttributeBackgroundColor( - ColorConstants.black.getRGB())); - initAttribute(new AttributeShowMeasure(true)); - initAttribute(new AttributeMeasureInterval(25)); - initAttribute(new AttributeMeasureMaxPos(100)); - initAttribute(new AttributeFillColor(ColorConstants.blue.getRGB())); - initAttribute(new AttributeFillHeight(75)); - initAttribute(new BAttributeAlpha(0)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.draw2d.ColorConstants; + +import de.bmotionstudio.gef.editor.attribute.AttributeFillColor; +import de.bmotionstudio.gef.editor.attribute.AttributeFillHeight; +import de.bmotionstudio.gef.editor.attribute.AttributeMeasureInterval; +import de.bmotionstudio.gef.editor.attribute.AttributeMeasureMaxPos; +import de.bmotionstudio.gef.editor.attribute.AttributeShowMeasure; +import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; +import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; + +public class Tank extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.tank"; + + public Tank(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + initAttribute(new BAttributeBackgroundColor( + ColorConstants.black.getRGB())); + initAttribute(new AttributeShowMeasure(true)); + initAttribute(new AttributeMeasureInterval(25)); + initAttribute(new AttributeMeasureMaxPos(100)); + initAttribute(new AttributeFillColor(ColorConstants.blue.getRGB())); + initAttribute(new AttributeFillHeight(75)); + initAttribute(new BAttributeAlpha(0)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java index e56e990bc9e7900a35a4558e6febcebb7c1c95ff..c0b7837e73eefe86fc97c65baeabe6a22595fbb3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java @@ -1,74 +1,74 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; - -/** - * @author Lukas Ladenberger - * - */ -public class Track extends BConnection { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.track"; - - public Track(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - BAttributeConnection aConnection = new BAttributeConnection(null); - aConnection.setGroup(AbstractAttribute.ROOT); - initAttribute(aConnection); - - BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1); - aLineWidth.setGroup(aConnection); - initAttribute(aLineWidth); - - BAttributeLineStyle aLineStyle = new BAttributeLineStyle( - BAttributeLineStyle.SOLID_CONNECTION); - aLineStyle.setGroup(aConnection); - initAttribute(aLineStyle); - - BAttributeForegroundColor aForegroundColor = new BAttributeForegroundColor( - new RGB(0, 0, 0)); - aForegroundColor.setGroup(aConnection); - initAttribute(aForegroundColor); - - BAttributeConnectionSourceDecoration aSourceDeco = new BAttributeConnectionSourceDecoration( - BAttributeConnectionSourceDecoration.DECORATION_NONE); - aSourceDeco.setGroup(aConnection); - initAttribute(aSourceDeco); - - BAttributeConnectionTargetDecoration aTargetDeco = new BAttributeConnectionTargetDecoration( - BAttributeConnectionSourceDecoration.DECORATION_NONE); - aTargetDeco.setGroup(aConnection); - initAttribute(aTargetDeco); - - BAttributeLabel aLabel = new BAttributeLabel("Label ..."); - aLabel.setGroup(aConnection); - initAttribute(aLabel); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; +import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; + +/** + * @author Lukas Ladenberger + * + */ +public class Track extends BConnection { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.track"; + + public Track(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + BAttributeConnection aConnection = new BAttributeConnection(null); + aConnection.setGroup(AbstractAttribute.ROOT); + initAttribute(aConnection); + + BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1); + aLineWidth.setGroup(aConnection); + initAttribute(aLineWidth); + + BAttributeLineStyle aLineStyle = new BAttributeLineStyle( + BAttributeLineStyle.SOLID_CONNECTION); + aLineStyle.setGroup(aConnection); + initAttribute(aLineStyle); + + BAttributeForegroundColor aForegroundColor = new BAttributeForegroundColor( + new RGB(0, 0, 0)); + aForegroundColor.setGroup(aConnection); + initAttribute(aForegroundColor); + + BAttributeConnectionSourceDecoration aSourceDeco = new BAttributeConnectionSourceDecoration( + BAttributeConnectionSourceDecoration.DECORATION_NONE); + aSourceDeco.setGroup(aConnection); + initAttribute(aSourceDeco); + + BAttributeConnectionTargetDecoration aTargetDeco = new BAttributeConnectionTargetDecoration( + BAttributeConnectionSourceDecoration.DECORATION_NONE); + aTargetDeco.setGroup(aConnection); + initAttribute(aTargetDeco); + + BAttributeLabel aLabel = new BAttributeLabel("Label ..."); + aLabel.setGroup(aConnection); + initAttribute(aLabel); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java index a71845d78b125d52c9e08169cb6919385fc0412b..48bfd7d96bc4d33829b254bd4dcdbf681faeffc1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java @@ -1,65 +1,65 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import org.eclipse.draw2d.ColorConstants; - -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; - -/** - * @author Lukas Ladenberger - * - */ -public class TrackNode extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.tracknode"; - - public TrackNode(Visualization visualization) { - super(visualization); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - - BAttributeSize aSize = new BAttributeSize(null); - aSize.setGroup(AbstractAttribute.ROOT); - aSize.setShow(false); - aSize.setEditable(false); - initAttribute(aSize); - - BAttributeHeight aHeight = new BAttributeHeight(20); - aHeight.setGroup(BAttributeSize.ID); - aHeight.setShow(false); - aHeight.setEditable(false); - initAttribute(aHeight); - - BAttributeWidth aWidth = new BAttributeWidth(20); - aWidth.setGroup(BAttributeSize.ID); - aWidth.setShow(false); - aWidth.setEditable(false); - initAttribute(aWidth); - - initAttribute(new BAttributeForegroundColor( - ColorConstants.black.getRGB())); - initAttribute(new BAttributeLineStyle( - BAttributeLineStyle.SOLID_CONNECTION)); - initAttribute(new BAttributeLineWidth(1)); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import org.eclipse.draw2d.ColorConstants; + +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; +import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; +import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; +import de.bmotionstudio.gef.editor.attribute.BAttributeSize; +import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; + +/** + * @author Lukas Ladenberger + * + */ +public class TrackNode extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.tracknode"; + + public TrackNode(Visualization visualization) { + super(visualization); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + + BAttributeSize aSize = new BAttributeSize(null); + aSize.setGroup(AbstractAttribute.ROOT); + aSize.setShow(false); + aSize.setEditable(false); + initAttribute(aSize); + + BAttributeHeight aHeight = new BAttributeHeight(20); + aHeight.setGroup(BAttributeSize.ID); + aHeight.setShow(false); + aHeight.setEditable(false); + initAttribute(aHeight); + + BAttributeWidth aWidth = new BAttributeWidth(20); + aWidth.setGroup(BAttributeSize.ID); + aWidth.setShow(false); + aWidth.setEditable(false); + initAttribute(aWidth); + + initAttribute(new BAttributeForegroundColor( + ColorConstants.black.getRGB())); + initAttribute(new BAttributeLineStyle( + BAttributeLineStyle.SOLID_CONNECTION)); + initAttribute(new BAttributeLineWidth(1)); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Visualization.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Visualization.java index 6aceebaa4cd1d5f66313b0a87137aaefcd8330fe..f3255a40a5ca86306f31ac8743407db71dc17684 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Visualization.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Visualization.java @@ -1,283 +1,283 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.draw2d.PositionConstants; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.ButtonGroupHelper; - -public class Visualization extends BControl { - - public static transient String TYPE = "de.bmotionstudio.gef.editor.visualization"; - - protected String bmachine, language, version; - - protected BMotionRuler leftRuler, topRuler; - - private boolean rulersVisibility, snapToGeometry, gridEnabled; - - private transient List<String> allBControlIDs; - - public List<String> getAllBControlIDs() { - if (allBControlIDs == null) - allBControlIDs = getAllBControlNames(); - return allBControlIDs; - } - - private transient Boolean isRunning; - - private transient Animation animation; - - private transient IFile projectFile; - - public Visualization(String bmachine, String language, String version) { - super(null); - setVisualization(this); - this.rulersVisibility = true; - this.bmachine = bmachine; - this.language = language; - this.version = version; - this.isRunning = false; - this.snapToGeometry = true; - createRulers(); - ButtonGroupHelper.reset(); - } - - @Override - protected Object readResolve() { - super.readResolve(); - this.isRunning = false; - createRulers(); - ButtonGroupHelper.reset(); - setVisualization(this); - init(); - initChildren(getChildrenArray()); - return this; - } - - private void initChildren(List<BControl> children) { - for (BControl c : children) { - c.setVisualization(this); - c.init(); - for (BConnection sc : c.getSourceConnections()) { - sc.setVisualization(this); - sc.init(); - } - for (BConnection tc : c.getTargetConnections()) { - tc.setVisualization(this); - tc.init(); - } - initChildren(c.getChildrenArray()); - } - } - - public void setIsRunning(Boolean bol) { - this.isRunning = bol; - } - - public Boolean isRunning() { - return isRunning; - } - - public IFile getProjectFile() { - return projectFile; - } - - public void setProjectFile(IFile pf) { - projectFile = pf; - } - - public String getMachineName() { - return this.bmachine; - } - - public void setMachineName(String machineName) { - this.bmachine = machineName; - } - - public String getLanguage() { - return this.language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setAnimation(Animation animation) { - this.animation = animation; - } - - public Animation getAnimation() { - return this.animation; - } - - public List<String> getAllBControlNames() { - return getAllBControlNames(getChildrenArray()); - } - - private List<String> getAllBControlNames(List<BControl> children) { - List<String> list = new ArrayList<String>(); - for (BControl control : children) { - list.add(control.getID()); - // Check children - List<BControl> subchildren = control.getChildrenArray(); - if (children.size() > 0) - list.addAll(getAllBControlNames(subchildren)); - // Check connections - List<BControl> connections = new ArrayList<BControl>(); - connections.addAll(control.getSourceConnections()); - connections.addAll(control.getTargetConnections()); - if (connections.size() > 0) - list.addAll(getAllBControlNames(connections)); - } - return list; - } - - public String getMaxIDString(String type) { - String newID = getMaxID(type, 0, getAllBControlIDs()); - getAllBControlIDs().add(newID); - return newID; - } - - // old method - private String getMaxID(String type, int count, List<String> allIDs) { - String newID = "control_" + count; - if (allIDs.contains(newID)) { - return getMaxID(type, (count + 1), allIDs); - } else { - return newID; - } - } - - public boolean checkIfIdExists(String ID) { - return getAllBControlNames().contains(ID); - } - - public BControl getBControl(String ID) { - return getBControl(ID, getChildrenArray()); - } - - private BControl getBControl(String ID, List<BControl> children) { - for (BControl control : children) { - if (control.getID().equals(ID)) { - return control; - } - for (BConnection c : control.getSourceConnections()) { - if (c.getID().equals(ID)) - return c; - } - for (BConnection c : control.getTargetConnections()) { - if (c.getID().equals(ID)) - return c; - } - if (control.getChildrenArray().size() > 0) { - BControl childControl = getBControl(ID, - control.getChildrenArray()); - if (childControl != null) - return childControl; - } - } - return null; - } - - public BMotionRuler getRuler(int orientation) { - BMotionRuler result = null; - switch (orientation) { - case PositionConstants.NORTH: - result = topRuler; - break; - case PositionConstants.WEST: - result = leftRuler; - break; - } - return result; - } - - public BMotionRuler getTopRuler() { - return topRuler; - } - - public void setTopRuler(BMotionRuler topRuler) { - this.topRuler = topRuler; - } - - public BMotionRuler getLeftRuler() { - return leftRuler; - } - - public void setLeftRuler(BMotionRuler leftRuler) { - this.leftRuler = leftRuler; - } - - protected void createRulers() { - if (leftRuler == null) - leftRuler = new BMotionRuler(false); - if (topRuler == null) - topRuler = new BMotionRuler(true); - } - - public void setRulerVisibility(boolean newValue) { - rulersVisibility = newValue; - } - - public void setGridEnabled(boolean isEnabled) { - gridEnabled = isEnabled; - } - - public void setSnapToGeometry(boolean isEnabled) { - snapToGeometry = isEnabled; - } - - public boolean getRulerVisibility() { - return rulersVisibility; - } - - public boolean isGridEnabled() { - return gridEnabled; - } - - public boolean isSnapToGeometryEnabled() { - return snapToGeometry; - } - - public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - return null; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public String getType() { - return TYPE; - } - - @Override - protected void initAttributes() { - } - - @Override - public boolean canHaveChildren() { - return true; - } - - @Override - public Visualization getVisualization() { - return this; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.draw2d.PositionConstants; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.ButtonGroupHelper; + +public class Visualization extends BControl { + + public static transient String TYPE = "de.bmotionstudio.gef.editor.visualization"; + + protected String bmachine, language, version; + + protected BMotionRuler leftRuler, topRuler; + + private boolean rulersVisibility, snapToGeometry, gridEnabled; + + private transient List<String> allBControlIDs; + + public List<String> getAllBControlIDs() { + if (allBControlIDs == null) + allBControlIDs = getAllBControlNames(); + return allBControlIDs; + } + + private transient Boolean isRunning; + + private transient Animation animation; + + private transient IFile projectFile; + + public Visualization(String bmachine, String language, String version) { + super(null); + setVisualization(this); + this.rulersVisibility = true; + this.bmachine = bmachine; + this.language = language; + this.version = version; + this.isRunning = false; + this.snapToGeometry = true; + createRulers(); + ButtonGroupHelper.reset(); + } + + @Override + protected Object readResolve() { + super.readResolve(); + this.isRunning = false; + createRulers(); + ButtonGroupHelper.reset(); + setVisualization(this); + init(); + initChildren(getChildrenArray()); + return this; + } + + private void initChildren(List<BControl> children) { + for (BControl c : children) { + c.setVisualization(this); + c.init(); + for (BConnection sc : c.getSourceConnections()) { + sc.setVisualization(this); + sc.init(); + } + for (BConnection tc : c.getTargetConnections()) { + tc.setVisualization(this); + tc.init(); + } + initChildren(c.getChildrenArray()); + } + } + + public void setIsRunning(Boolean bol) { + this.isRunning = bol; + } + + public Boolean isRunning() { + return isRunning; + } + + public IFile getProjectFile() { + return projectFile; + } + + public void setProjectFile(IFile pf) { + projectFile = pf; + } + + public String getMachineName() { + return this.bmachine; + } + + public void setMachineName(String machineName) { + this.bmachine = machineName; + } + + public String getLanguage() { + return this.language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setAnimation(Animation animation) { + this.animation = animation; + } + + public Animation getAnimation() { + return this.animation; + } + + public List<String> getAllBControlNames() { + return getAllBControlNames(getChildrenArray()); + } + + private List<String> getAllBControlNames(List<BControl> children) { + List<String> list = new ArrayList<String>(); + for (BControl control : children) { + list.add(control.getID()); + // Check children + List<BControl> subchildren = control.getChildrenArray(); + if (children.size() > 0) + list.addAll(getAllBControlNames(subchildren)); + // Check connections + List<BControl> connections = new ArrayList<BControl>(); + connections.addAll(control.getSourceConnections()); + connections.addAll(control.getTargetConnections()); + if (connections.size() > 0) + list.addAll(getAllBControlNames(connections)); + } + return list; + } + + public String getMaxIDString(String type) { + String newID = getMaxID(type, 0, getAllBControlIDs()); + getAllBControlIDs().add(newID); + return newID; + } + + // old method + private String getMaxID(String type, int count, List<String> allIDs) { + String newID = "control_" + count; + if (allIDs.contains(newID)) { + return getMaxID(type, (count + 1), allIDs); + } else { + return newID; + } + } + + public boolean checkIfIdExists(String ID) { + return getAllBControlNames().contains(ID); + } + + public BControl getBControl(String ID) { + return getBControl(ID, getChildrenArray()); + } + + private BControl getBControl(String ID, List<BControl> children) { + for (BControl control : children) { + if (control.getID().equals(ID)) { + return control; + } + for (BConnection c : control.getSourceConnections()) { + if (c.getID().equals(ID)) + return c; + } + for (BConnection c : control.getTargetConnections()) { + if (c.getID().equals(ID)) + return c; + } + if (control.getChildrenArray().size() > 0) { + BControl childControl = getBControl(ID, + control.getChildrenArray()); + if (childControl != null) + return childControl; + } + } + return null; + } + + public BMotionRuler getRuler(int orientation) { + BMotionRuler result = null; + switch (orientation) { + case PositionConstants.NORTH: + result = topRuler; + break; + case PositionConstants.WEST: + result = leftRuler; + break; + } + return result; + } + + public BMotionRuler getTopRuler() { + return topRuler; + } + + public void setTopRuler(BMotionRuler topRuler) { + this.topRuler = topRuler; + } + + public BMotionRuler getLeftRuler() { + return leftRuler; + } + + public void setLeftRuler(BMotionRuler leftRuler) { + this.leftRuler = leftRuler; + } + + protected void createRulers() { + if (leftRuler == null) + leftRuler = new BMotionRuler(false); + if (topRuler == null) + topRuler = new BMotionRuler(true); + } + + public void setRulerVisibility(boolean newValue) { + rulersVisibility = newValue; + } + + public void setGridEnabled(boolean isEnabled) { + gridEnabled = isEnabled; + } + + public void setSnapToGeometry(boolean isEnabled) { + snapToGeometry = isEnabled; + } + + public boolean getRulerVisibility() { + return rulersVisibility; + } + + public boolean isGridEnabled() { + return gridEnabled; + } + + public boolean isSnapToGeometryEnabled() { + return snapToGeometry; + } + + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { + return null; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Override + public String getType() { + return TYPE; + } + + @Override + protected void initAttributes() { + } + + @Override + public boolean canHaveChildren() { + return true; + } + + @Override + public Visualization getVisualization() { + return this; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BButtonService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BButtonService.java index e725497872ea5284faf8035fa7dbebc3e6fe1c9b..721abebb9daffcb144e7491b41e083a0136e9d12 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BButtonService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BButtonService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BButton; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BButtonPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BButtonService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BButton(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BButtonPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BButton; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BButtonPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BButtonService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BButton(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BButtonPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCheckboxService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCheckboxService.java index 116a6e6c81832d075d3d575040cf20adacd089ac..fdd30ab1a2daec2cdb4ac126ad5a790ce4f5497e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCheckboxService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCheckboxService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BCheckbox; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BCheckboxPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BCheckboxService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BCheckbox(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BCheckboxPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BCheckbox; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BCheckboxPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BCheckboxService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BCheckbox(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BCheckboxPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCompositeService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCompositeService.java index c9a899bdcece83f8b6b12b1085bb1c351ce5d569..ffc05d79431c054e91d2471fb069f255df91a7e6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCompositeService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BCompositeService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BComposite; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BCompositePart; - -/** - * @author Lukas Ladenberger - * - */ -public class BCompositeService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BComposite(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BCompositePart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BComposite; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BCompositePart; + +/** + * @author Lukas Ladenberger + * + */ +public class BCompositeService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BComposite(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BCompositePart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BConnectionService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BConnectionService.java index 54fcc6bfa0ff7cfea37295e007e6c174a0f91590..d0e646e943b30fdf99277686f00609d2d46bb17b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BConnectionService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BConnectionService.java @@ -1,59 +1,59 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.palette.ConnectionCreationToolEntry; -import org.eclipse.gef.palette.ToolEntry; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.BControlCreationFactory; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BConnectionEditPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BConnectionService extends AbstractBControlService implements - IBControlService { - - @Override - public ToolEntry createToolEntry(Visualization visualization, - IConfigurationElement configurationElement) { - String sourcePluginID = configurationElement.getContributor().getName(); - String name = configurationElement.getAttribute("name"); - String icon = configurationElement.getAttribute("icon"); - return new ConnectionCreationToolEntry(name, "Create " + name, - new BControlCreationFactory(BConnection.TYPE, visualization), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon)); - } - - @Override - public BControl createControl(Visualization visualization) { - return new BConnection(visualization); - } - - @Override - public BMSAbstractEditPart createEditPart() { - return new BConnectionEditPart(); - } - - @Override - public boolean showInPalette() { - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.palette.ConnectionCreationToolEntry; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.BControlCreationFactory; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BConnectionEditPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BConnectionService extends AbstractBControlService implements + IBControlService { + + @Override + public ToolEntry createToolEntry(Visualization visualization, + IConfigurationElement configurationElement) { + String sourcePluginID = configurationElement.getContributor().getName(); + String name = configurationElement.getAttribute("name"); + String icon = configurationElement.getAttribute("icon"); + return new ConnectionCreationToolEntry(name, "Create " + name, + new BControlCreationFactory(BConnection.TYPE, visualization), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon)); + } + + @Override + public BControl createControl(Visualization visualization) { + return new BConnection(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BConnectionEditPart(); + } + + @Override + public boolean showInPalette() { + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BImageService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BImageService.java index c843bb524d2c81614848eeb5315d3666da1b544e..52c80fe2ae3c4fd7ae19b15e65927b6c2f1af63b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BImageService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BImageService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BImage; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BImagePart; - -/** - * @author Lukas Ladenberger - * - */ -public class BImageService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BImage(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BImagePart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BImage; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BImagePart; + +/** + * @author Lukas Ladenberger + * + */ +public class BImageService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BImage(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BImagePart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRadioButtonService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRadioButtonService.java index 6092c7c7c4d1b8889a658e36f76a28881ec48cfe..3bf848594e85878456a0f8421f172a91948d657a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRadioButtonService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRadioButtonService.java @@ -1,45 +1,32 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BRadioButton; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BRadioButtonPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BRadioButtonService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BRadioButton(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BRadioButtonPart(); - } -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BRadioButton; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BRadioButtonPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BRadioButtonService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BRadioButton(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BRadioButtonPart(); + } +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRectangleService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRectangleService.java index 1c18ae9da50ef58f254861fb7a02fb5828528b47..dbc13bea6552267b7343f0557fcbd3fc5fa7bb8f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRectangleService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BRectangleService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BShape; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BShapePart; - -/** - * @author Lukas Ladenberger - * - */ -public class BRectangleService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BShape(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BShapePart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BShape; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BShapePart; + +/** + * @author Lukas Ladenberger + * + */ +public class BRectangleService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BShape(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BShapePart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextService.java index 6bf14bc403ca03eb36294d60f5389d744d6f86a3..180c940ad407def65ec32bbe8925b8a210a3f8e6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BText; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BTextPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BTextService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BText(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BTextPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BText; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BTextPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BTextService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BText(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BTextPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextfieldService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextfieldService.java index 1b66a40c36158c7a1c569bdcd87a606254a9f72d..59b581614046e2e251c7e38cc4bdd5ac87c2fca8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextfieldService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/BTextfieldService.java @@ -1,46 +1,33 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BTextfield; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.BTextfieldPart; - -/** - * @author Lukas Ladenberger - * - */ -public class BTextfieldService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new BTextfield(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new BTextfieldPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BTextfield; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BTextfieldPart; + +/** + * @author Lukas Ladenberger + * + */ +public class BTextfieldService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new BTextfield(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new BTextfieldPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SignalService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SignalService.java index 95dd51a686cedef9ccbd86bb376fe3421faf768a..864a21a9ac3150962129d84620061b4070605b80 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SignalService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SignalService.java @@ -1,45 +1,32 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Signal; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.SignalPart; - -/** - * @author Lukas Ladenberger - * - */ -public class SignalService extends AbstractBControlService implements - IBControlService { - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.IBControlService#createControl(de.bmotionstudio - * .gef.editor.model.Visualization) - */ - @Override - public BControl createControl(Visualization visualization) { - return new Signal(visualization); - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.IBControlService#createEditPart() - */ - @Override - public BMSAbstractEditPart createEditPart() { - return new SignalPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Signal; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.SignalPart; + +/** + * @author Lukas Ladenberger + * + */ +public class SignalService extends AbstractBControlService implements + IBControlService { + @Override + public BControl createControl(Visualization visualization) { + return new Signal(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new SignalPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SwitchService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SwitchService.java index bb4c4850ea30bb529021a688dc71174aa7af4b24..d2464cc20bedfedce5de9eaa53eae10640aaca2f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SwitchService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/SwitchService.java @@ -1,30 +1,30 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Switch; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.SwitchPart; - -public class SwitchService extends AbstractBControlService implements - IBControlService { - - @Override - public BControl createControl(Visualization visualization) { - return new Switch(visualization); - } - - @Override - public BMSAbstractEditPart createEditPart() { - return new SwitchPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Switch; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.SwitchPart; + +public class SwitchService extends AbstractBControlService implements + IBControlService { + + @Override + public BControl createControl(Visualization visualization) { + return new Switch(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new SwitchPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TankService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TankService.java index 80c1a38cd19221bd8e0e48a071cc89af377b451f..a7f8122944a4acf6ac6bb4ee15a857e37d1b1b14 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TankService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TankService.java @@ -1,30 +1,30 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Tank; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.TankPart; - -public class TankService extends AbstractBControlService implements - IBControlService { - - @Override - public BControl createControl(Visualization visualization) { - return new Tank(visualization); - } - - @Override - public BMSAbstractEditPart createEditPart() { - return new TankPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Tank; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.TankPart; + +public class TankService extends AbstractBControlService implements + IBControlService { + + @Override + public BControl createControl(Visualization visualization) { + return new Tank(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new TankPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackNodeService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackNodeService.java index c01bcaa080339ca1934876ae7026a88f039aeb9c..35200f4b72f1d7a1537d2ddb0a7d575d97b4b191 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackNodeService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackNodeService.java @@ -1,35 +1,35 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.TrackNode; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.TrackNodePart; - -public class TrackNodeService extends AbstractBControlService implements - IBControlService { - - @Override - public BControl createControl(Visualization visualization) { - return new TrackNode(visualization); - } - - @Override - public BMSAbstractEditPart createEditPart() { - return new TrackNodePart(); - } - - @Override - public boolean showInPalette() { - return true; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.TrackNode; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.TrackNodePart; + +public class TrackNodeService extends AbstractBControlService implements + IBControlService { + + @Override + public BControl createControl(Visualization visualization) { + return new TrackNode(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new TrackNodePart(); + } + + @Override + public boolean showInPalette() { + return true; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackService.java index ccd221193739c9280e3d368dd917f3ed8d3cfb4b..f2eeee69160e20c78e3bd22fa622bb8792285378 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/service/TrackService.java @@ -1,54 +1,54 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.model.service; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.palette.ConnectionCreationToolEntry; -import org.eclipse.gef.palette.ToolEntry; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.bmotionstudio.gef.editor.AbstractBControlService; -import de.bmotionstudio.gef.editor.BControlCreationFactory; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Track; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; -import de.bmotionstudio.gef.editor.part.TrackPart; - -/** - * @author Lukas Ladenberger - * - */ -public class TrackService extends AbstractBControlService implements - IBControlService { - - @Override - public ToolEntry createToolEntry(Visualization visualization, - IConfigurationElement configurationElement) { - String sourcePluginID = configurationElement.getContributor().getName(); - String name = configurationElement.getAttribute("name"); - String icon = configurationElement.getAttribute("icon"); - return new ConnectionCreationToolEntry(name, "Create " + name, - new BControlCreationFactory(Track.TYPE, visualization), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon), - AbstractUIPlugin - .imageDescriptorFromPlugin(sourcePluginID, icon)); - } - - @Override - public BControl createControl(Visualization visualization) { - return new Track(visualization); - } - - @Override - public BMSAbstractEditPart createEditPart() { - return new TrackPart(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.model.service; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.palette.ConnectionCreationToolEntry; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.BControlCreationFactory; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Track; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart; +import de.bmotionstudio.gef.editor.part.TrackPart; + +/** + * @author Lukas Ladenberger + * + */ +public class TrackService extends AbstractBControlService implements + IBControlService { + + @Override + public ToolEntry createToolEntry(Visualization visualization, + IConfigurationElement configurationElement) { + String sourcePluginID = configurationElement.getContributor().getName(); + String name = configurationElement.getAttribute("name"); + String icon = configurationElement.getAttribute("icon"); + return new ConnectionCreationToolEntry(name, "Create " + name, + new BControlCreationFactory(Track.TYPE, visualization), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon), + AbstractUIPlugin + .imageDescriptorFromPlugin(sourcePluginID, icon)); + } + + @Override + public BControl createControl(Visualization visualization) { + return new Track(visualization); + } + + @Override + public BMSAbstractEditPart createEditPart() { + return new TrackPart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/IObserverListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/IObserverListener.java index b1189aac3fd5f7f7cd8ae8bf21dc148d73528fc4..f4eca1fe7ea5ff4abfce6495198157603f7669b2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/IObserverListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/IObserverListener.java @@ -1,21 +1,21 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * @author Lukas Ladenberger - * - */ -public interface IObserverListener { - - public void addedObserver(BControl control, Observer observer); - - public void removedObserver(BControl control); - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * @author Lukas Ladenberger + * + */ +public interface IObserverListener { + + public void addedObserver(BControl control, Observer observer); + + public void removedObserver(BControl control); + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java index 59584f2b31f9df4a8fdcd62d048597fe988219e3..e97873f78c913ab05b6579ed8d7c1625c374b75b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java @@ -1,203 +1,203 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import java.util.ArrayList; -import java.util.List; - -import de.be4.classicalb.core.parser.exceptions.BException; -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverListenOperationByPredicate; -import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; -import de.bmotionstudio.gef.editor.util.BMSUtil; -import de.prob.core.Animator; -import de.prob.core.command.GetOperationByPredicateCommand; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.State; -import de.prob.exceptions.ProBException; - -public class ListenOperationByPredicate extends Observer { - - public static String ID = "de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate"; - - private ArrayList<PredicateOperation> list = new ArrayList<PredicateOperation>(); - private transient List<String> setAttributes; - - public ListenOperationByPredicate() { - this(new ArrayList<PredicateOperation>()); - } - - public ListenOperationByPredicate(ArrayList<PredicateOperation> list) { - super(); - this.setAttributes = new ArrayList<String>(); - this.list = list; - } - - protected Object readResolve() { - this.setAttributes = new ArrayList<String>(); - return super.readResolve(); - } - - @Override - public void check(Animation animation, BControl control) { - - this.setAttributes.clear(); - - State state = animation.getState(); - Animator animator = animation.getAnimator(); - - for (PredicateOperation pop : getList()) { - - if (pop.getAttribute() == null) { - pop.setAttribute(AttributeConstants.ATTRIBUTE_ENABLED); - } - - if (pop.getValue() == null) { - pop.setValue(true); - } - - String fPredicate = pop.getPredicate(); - String fOpName = pop.getOperationName(); - - if (fOpName != null && fPredicate != null) { - - if (animation.getCurrentStateOperations().containsKey(fOpName)) { - - if (fPredicate.length() > 0) { - fPredicate = BMSUtil.parseControls(fPredicate, control); - } - - try { - if (fPredicate.equals("")) - fPredicate = "1=1"; - Operation operation = GetOperationByPredicateCommand - .getOperation(animator, state.getId(), fOpName, - fPredicate); - if (operation != null) { // Operation enabled - - String attributeID = pop.getAttribute(); - - AbstractAttribute attributeObj = control - .getAttribute(attributeID); - - Object attributeVal = pop.getValue(); - - if (pop.isExpressionMode()) { - String strAtrVal = BMSUtil.parseExpression( - attributeVal.toString(), control, - animation); - String er = attributeObj.validateValue( - strAtrVal, null); - if (er != null) { - // addError( - // control, - // animation, - // "You selected " - // + attributeObj.getName() - // + - // " as attribute. There is a problem with your value: " - // + strAtrVal + " - Reason: " - // + er); - pop.setHasError(true); - } else { - attributeVal = attributeObj - .unmarshal(strAtrVal); - } - } - - if (!pop.hasError()) { - Object oldAttrVal = control - .getAttributeValue(attributeID); - if (!oldAttrVal.equals(attributeVal)) { - control.setAttributeValue(attributeID, - attributeVal, true, false); - } - } - - setAttributes.add(attributeID); - - } - } catch (ProBException e) { - // addError(control, animation, - // "An error occurred while evaluating. Reason: " - // + e.getMessage()); - } catch (BException e) { - // addError(control, animation, "Parsing error in: " - // + fPredicate + " Reason: " + e.getMessage()); - } - } - - } - - } - - // Restore attribute values - for (PredicateOperation obj : list) { - if (!setAttributes.contains(obj.getAttribute())) { - AbstractAttribute attributeObj = control.getAttribute(obj - .getAttribute()); - Object oldAttrVal = control.getAttributeValue(obj - .getAttribute()); - if (!oldAttrVal.equals(attributeObj.getInitValue())) { - control.restoreDefaultValue(attributeObj.getID()); - } - } - } - - } - - @Override - public ObserverWizard getWizard(BControl control) { - return new WizardObserverListenOperationByPredicate(control, this); - } - - public void setList(ArrayList<PredicateOperation> list) { - this.list = list; - } - - public ArrayList<PredicateOperation> getList() { - if (this.list == null) - this.list = new ArrayList<PredicateOperation>(); - return this.list; - } - - public void addPredicateOperation(PredicateOperation predicateOperation) { - getList().add(predicateOperation); - } - - public void removePredicateOperation(PredicateOperation predicateOperation) { - getList().remove(predicateOperation); - } - - // public Boolean removePredicateOperationByUniqueID(String uniqueID) { - // for (PredicateOperation po : this.list) { - // String cuID = po.getUniqueID(); - // if (cuID != null) { - // if (cuID.equals(uniqueID)) { - // this.list.remove(po); - // return true; - // } - // } - // } - // return false; - // } - - public Observer clone() throws CloneNotSupportedException { - ListenOperationByPredicate clone = (ListenOperationByPredicate) super - .clone(); - ArrayList<PredicateOperation> clonedList = new ArrayList<PredicateOperation>(); - for (PredicateOperation pop : this.getList()) { - clonedList.add(pop.clone()); - } - clone.setList(clonedList); - return clone; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import java.util.ArrayList; +import java.util.List; + +import de.be4.classicalb.core.parser.exceptions.BCompoundException; +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverListenOperationByPredicate; +import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; +import de.bmotionstudio.gef.editor.util.BMSUtil; +import de.prob.core.Animator; +import de.prob.core.command.GetOperationByPredicateCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.State; +import de.prob.exceptions.ProBException; + +public class ListenOperationByPredicate extends Observer { + + public static String ID = "de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate"; + + private ArrayList<PredicateOperation> list = new ArrayList<PredicateOperation>(); + private transient List<String> setAttributes; + + public ListenOperationByPredicate() { + this(new ArrayList<PredicateOperation>()); + } + + public ListenOperationByPredicate(ArrayList<PredicateOperation> list) { + super(); + this.setAttributes = new ArrayList<String>(); + this.list = list; + } + + protected Object readResolve() { + this.setAttributes = new ArrayList<String>(); + return super.readResolve(); + } + + @Override + public void check(Animation animation, BControl control) { + + this.setAttributes.clear(); + + State state = animation.getState(); + Animator animator = animation.getAnimator(); + + for (PredicateOperation pop : getList()) { + + if (pop.getAttribute() == null) { + pop.setAttribute(AttributeConstants.ATTRIBUTE_ENABLED); + } + + if (pop.getValue() == null) { + pop.setValue(true); + } + + String fPredicate = pop.getPredicate(); + String fOpName = pop.getOperationName(); + + if (fOpName != null && fPredicate != null) { + + if (animation.getCurrentStateOperations().containsKey(fOpName)) { + + if (fPredicate.length() > 0) { + fPredicate = BMSUtil.parseControls(fPredicate, control); + } + + try { + if (fPredicate.equals("")) + fPredicate = "1=1"; + Operation operation = GetOperationByPredicateCommand + .getOperation(animator, state.getId(), fOpName, + fPredicate); + if (operation != null) { // Operation enabled + + String attributeID = pop.getAttribute(); + + AbstractAttribute attributeObj = control + .getAttribute(attributeID); + + Object attributeVal = pop.getValue(); + + if (pop.isExpressionMode()) { + String strAtrVal = BMSUtil.parseExpression( + attributeVal.toString(), control, + animation); + String er = attributeObj.validateValue( + strAtrVal, null); + if (er != null) { + // addError( + // control, + // animation, + // "You selected " + // + attributeObj.getName() + // + + // " as attribute. There is a problem with your value: " + // + strAtrVal + " - Reason: " + // + er); + pop.setHasError(true); + } else { + attributeVal = attributeObj + .unmarshal(strAtrVal); + } + } + + if (!pop.hasError()) { + Object oldAttrVal = control + .getAttributeValue(attributeID); + if (!oldAttrVal.equals(attributeVal)) { + control.setAttributeValue(attributeID, + attributeVal, true, false); + } + } + + setAttributes.add(attributeID); + + } + } catch (ProBException e) { + // addError(control, animation, + // "An error occurred while evaluating. Reason: " + // + e.getMessage()); + } catch (BCompoundException e) { + // addError(control, animation, "Parsing error in: " + // + fPredicate + " Reason: " + e.getMessage()); + } + } + + } + + } + + // Restore attribute values + for (PredicateOperation obj : list) { + if (!setAttributes.contains(obj.getAttribute())) { + AbstractAttribute attributeObj = control.getAttribute(obj + .getAttribute()); + Object oldAttrVal = control.getAttributeValue(obj + .getAttribute()); + if (!oldAttrVal.equals(attributeObj.getInitValue())) { + control.restoreDefaultValue(attributeObj.getID()); + } + } + } + + } + + @Override + public ObserverWizard getWizard(BControl control) { + return new WizardObserverListenOperationByPredicate(control, this); + } + + public void setList(ArrayList<PredicateOperation> list) { + this.list = list; + } + + public ArrayList<PredicateOperation> getList() { + if (this.list == null) + this.list = new ArrayList<PredicateOperation>(); + return this.list; + } + + public void addPredicateOperation(PredicateOperation predicateOperation) { + getList().add(predicateOperation); + } + + public void removePredicateOperation(PredicateOperation predicateOperation) { + getList().remove(predicateOperation); + } + + // public Boolean removePredicateOperationByUniqueID(String uniqueID) { + // for (PredicateOperation po : this.list) { + // String cuID = po.getUniqueID(); + // if (cuID != null) { + // if (cuID.equals(uniqueID)) { + // this.list.remove(po); + // return true; + // } + // } + // } + // return false; + // } + + public Observer clone() throws CloneNotSupportedException { + ListenOperationByPredicate clone = (ListenOperationByPredicate) super + .clone(); + ArrayList<PredicateOperation> clonedList = new ArrayList<PredicateOperation>(); + for (PredicateOperation pop : this.getList()) { + clonedList.add(pop.clone()); + } + clone.setList(clonedList); + return clone; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationObject.java index 8bf15c351aa1431547132a3fd495d9cb58a062cb..6a400b137a11d12db34dea57e2df08b6e7268384 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationObject.java @@ -1,46 +1,46 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import de.bmotionstudio.gef.editor.BindingObject; - -public class ListenOperationObject extends BindingObject implements Cloneable { - - private String operationName; - private String predicate; - - public ListenOperationObject() { - super(); - this.operationName = ""; - this.predicate = ""; - } - - public ListenOperationObject clone() throws CloneNotSupportedException { - return (ListenOperationObject) super.clone(); - } - - public void setOperationName(String operationName) { - Object oldValue = this.operationName; - this.operationName = operationName; - firePropertyChange("operationName", oldValue, this.operationName); - } - - public String getOperationName() { - return operationName; - } - - public void setPredicate(String predicate) { - Object oldValue = this.predicate; - this.predicate = predicate; - firePropertyChange("predicate", oldValue, this.predicate); - } - - public String getPredicate() { - return predicate; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import de.bmotionstudio.gef.editor.BindingObject; + +public class ListenOperationObject extends BindingObject implements Cloneable { + + private String operationName; + private String predicate; + + public ListenOperationObject() { + super(); + this.operationName = ""; + this.predicate = ""; + } + + public ListenOperationObject clone() throws CloneNotSupportedException { + return (ListenOperationObject) super.clone(); + } + + public void setOperationName(String operationName) { + Object oldValue = this.operationName; + this.operationName = operationName; + firePropertyChange("operationName", oldValue, this.operationName); + } + + public String getOperationName() { + return operationName; + } + + public void setPredicate(String predicate) { + Object oldValue = this.predicate; + this.predicate = predicate; + firePropertyChange("predicate", oldValue, this.predicate); + } + + public String getPredicate() { + return predicate; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/Observer.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/Observer.java index d503290e15669b161bec135606bacc8946c6d84f..4d64076e6b9dae0da8e7981ab58c65a0a16a8e3b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/Observer.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/Observer.java @@ -1,77 +1,77 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.draw2d.IFigure; - -import de.bmotionstudio.gef.editor.AbstractExpressionControl; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * - * Observers are used to link controls to the model's state, i.e., they do the - * same as the animation function in ProB. The main difference is, that we allow - * to decompose the animation function into different aspects, i.e., if our - * model contains information about the speed of a motor, we can separate all - * information regarding the speed from the information regarding the - * temperature. This allows us to write small functions and combine them rather - * than writing a single function covering all aspects of the model. - * - * @author Lukas Ladenberger - * - */ -public abstract class Observer extends AbstractExpressionControl implements - IObserver { - - public Observer() { - init(); - } - - protected Object readResolve() { - init(); - return this; - } - - /** - * Method to initialize the observer. Gets the ID, name and description from - * the corresponding extension point - */ - private void init() { - IConfigurationElement configElement = BMotionEditorPlugin - .getObserverExtension(getClass().getName()); - if (configElement != null) { - this.ID = configElement.getAttribute("class"); - this.name = configElement.getAttribute("name"); - this.description = configElement.getAttribute("description"); - } - } - - /** - * Makes a copy of the observer - * - * @return the cloned observer - */ - public Observer clone() throws CloneNotSupportedException { - return (Observer) super.clone(); - } - - /** - * Returns a corresponding wizard for the observer. - * - * @param bcontrol - * The corresponding control - * @return the corresponding wizard - */ - public abstract ObserverWizard getWizard(BControl control); - - public IFigure getToolTip(BControl control) { - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.draw2d.IFigure; + +import de.bmotionstudio.gef.editor.AbstractExpressionControl; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * + * Observers are used to link controls to the model's state, i.e., they do the + * same as the animation function in ProB. The main difference is, that we allow + * to decompose the animation function into different aspects, i.e., if our + * model contains information about the speed of a motor, we can separate all + * information regarding the speed from the information regarding the + * temperature. This allows us to write small functions and combine them rather + * than writing a single function covering all aspects of the model. + * + * @author Lukas Ladenberger + * + */ +public abstract class Observer extends AbstractExpressionControl implements + IObserver { + + public Observer() { + init(); + } + + protected Object readResolve() { + init(); + return this; + } + + /** + * Method to initialize the observer. Gets the ID, name and description from + * the corresponding extension point + */ + private void init() { + IConfigurationElement configElement = BMotionEditorPlugin + .getObserverExtension(getClass().getName()); + if (configElement != null) { + this.ID = configElement.getAttribute("class"); + this.name = configElement.getAttribute("name"); + this.description = configElement.getAttribute("description"); + } + } + + /** + * Makes a copy of the observer + * + * @return the cloned observer + */ + public Observer clone() throws CloneNotSupportedException { + return (Observer) super.clone(); + } + + /** + * Returns a corresponding wizard for the observer. + * + * @param bcontrol + * The corresponding control + * @return the corresponding wizard + */ + public abstract ObserverWizard getWizard(BControl control); + + public IFigure getToolTip(BControl control) { + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverEvalObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverEvalObject.java index f03260e6b5caa670bed04b91083347dadbcd579f..fce5f5d7ff8169f02143aa732e04f076d0d36a67 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverEvalObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverEvalObject.java @@ -1,115 +1,115 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import de.bmotionstudio.gef.editor.BindingObject; - -public class ObserverEvalObject extends BindingObject implements Cloneable { - - private String type; // unused - - private String eval; // Predicate - - private Object value; - - private String attribute; - - /** - * If true, value attribute is an ExpressionValueElement otherwise value - * attribute is an simple value object (e.g. background image) - * - * @see ExpressionValueElement - */ - private Boolean isExpressionMode; - - private transient Boolean hasError; - - public ObserverEvalObject() { - this.isExpressionMode = false; - } - - public ObserverEvalObject(String type, String eval, Boolean isExpressionMode) { - this.type = type; - this.eval = eval; - this.isExpressionMode = isExpressionMode; - } - - public ObserverEvalObject(String type, String eval) { - this(type, eval, false); - } - - public void setType(String type) { - Object oldValue = this.type; - this.type = type; - firePropertyChange("type", oldValue, this.type); - } - - public String getType() { - return type; - } - - public void setEval(String eval) { - Object oldValue = this.eval; - this.eval = eval; - firePropertyChange("eval", oldValue, this.eval); - } - - public String getEval() { - return eval; - } - - public ObserverEvalObject clone() throws CloneNotSupportedException { - return (ObserverEvalObject) super.clone(); - } - - public void setHasError(Boolean hasError) { - this.hasError = hasError; - } - - public Boolean hasError() { - if (hasError == null) - hasError = false; - return hasError; - } - - public void setValue(Object value) { - Object oldValue = this.value; - this.value = value; - firePropertyChange("value", oldValue, this.value); - } - - public Object getValue() { - return this.value; - } - - public void setIsExpressionMode(Boolean isExpressionMode) { - Object oldValue = this.isExpressionMode; - this.isExpressionMode = isExpressionMode; - firePropertyChange("isExpressionMode", oldValue, this.isExpressionMode); - } - - public Boolean getIsExpressionMode() { - return isExpressionMode(); - } - - public Boolean isExpressionMode() { - if (isExpressionMode == null) - isExpressionMode = false; - return isExpressionMode; - } - - public void setAttribute(String attribute) { - Object oldValue = this.attribute; - this.attribute = attribute; - firePropertyChange("attribute", oldValue, this.attribute); - } - - public String getAttribute() { - return attribute; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import de.bmotionstudio.gef.editor.BindingObject; + +public class ObserverEvalObject extends BindingObject implements Cloneable { + + private String type; // unused + + private String eval; // Predicate + + private Object value; + + private String attribute; + + /** + * If true, value attribute is an ExpressionValueElement otherwise value + * attribute is an simple value object (e.g. background image) + * + * @see ExpressionValueElement + */ + private Boolean isExpressionMode; + + private transient Boolean hasError; + + public ObserverEvalObject() { + this.isExpressionMode = false; + } + + public ObserverEvalObject(String type, String eval, Boolean isExpressionMode) { + this.type = type; + this.eval = eval; + this.isExpressionMode = isExpressionMode; + } + + public ObserverEvalObject(String type, String eval) { + this(type, eval, false); + } + + public void setType(String type) { + Object oldValue = this.type; + this.type = type; + firePropertyChange("type", oldValue, this.type); + } + + public String getType() { + return type; + } + + public void setEval(String eval) { + Object oldValue = this.eval; + this.eval = eval; + firePropertyChange("eval", oldValue, this.eval); + } + + public String getEval() { + return eval; + } + + public ObserverEvalObject clone() throws CloneNotSupportedException { + return (ObserverEvalObject) super.clone(); + } + + public void setHasError(Boolean hasError) { + this.hasError = hasError; + } + + public Boolean hasError() { + if (hasError == null) + hasError = false; + return hasError; + } + + public void setValue(Object value) { + Object oldValue = this.value; + this.value = value; + firePropertyChange("value", oldValue, this.value); + } + + public Object getValue() { + return this.value; + } + + public void setIsExpressionMode(Boolean isExpressionMode) { + Object oldValue = this.isExpressionMode; + this.isExpressionMode = isExpressionMode; + firePropertyChange("isExpressionMode", oldValue, this.isExpressionMode); + } + + public Boolean getIsExpressionMode() { + return isExpressionMode(); + } + + public Boolean isExpressionMode() { + if (isExpressionMode == null) + isExpressionMode = false; + return isExpressionMode; + } + + public void setAttribute(String attribute) { + Object oldValue = this.attribute; + this.attribute = attribute; + firePropertyChange("attribute", oldValue, this.attribute); + } + + public String getAttribute() { + return attribute; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverWizard.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverWizard.java index 252a7b622e5b7a998d97f86097650253eb368c67..64e549d4351453c80ec3ec99daf14992a89ec0c4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverWizard.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverWizard.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import org.eclipse.swt.graphics.Point; - -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * - * The BMotion Studio provides an easy way to handle Observers. For this, - * Observers can have a corresponding wizard. The user can open it by calling - * the context menu of a Control. - * - * @author Lukas Ladenberger - * - */ -public abstract class ObserverWizard extends BMotionAbstractWizard { - - private Observer observer; - - protected Boolean observerDelete = false; - - public ObserverWizard(BControl control, Observer observer) { - super(control); - this.observer = observer; - } - - public Observer getObserver() { - return this.observer; - } - - protected void setObserverDelete(Boolean b) { - this.observerDelete = b; - } - - public Boolean isObserverDelete() { - return this.observerDelete; - } - - public abstract Point getSize(); - - @Override - public String getName() { - return observer.getName(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import org.eclipse.swt.graphics.Point; + +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * + * The BMotion Studio provides an easy way to handle Observers. For this, + * Observers can have a corresponding wizard. The user can open it by calling + * the context menu of a Control. + * + * @author Lukas Ladenberger + * + */ +public abstract class ObserverWizard extends BMotionAbstractWizard { + + private Observer observer; + + protected Boolean observerDelete = false; + + public ObserverWizard(BControl control, Observer observer) { + super(control); + this.observer = observer; + } + + public Observer getObserver() { + return this.observer; + } + + protected void setObserverDelete(Boolean b) { + this.observerDelete = b; + } + + public Boolean isObserverDelete() { + return this.observerDelete; + } + + public abstract Point getSize(); + + @Override + public String getName() { + return observer.getName(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttribute.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttribute.java index 02773321d1ee6a0534ddfcb5e262aa47f5ad1fe7..69163126f58e619f9502c00af04822708bf4d925 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttribute.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttribute.java @@ -1,156 +1,156 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSetAttribute; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class SetAttribute extends Observer { - - private List<SetAttributeObject> setAttributeObjects; - private transient List<String> setAttributes; - - public SetAttribute() { - super(); - setAttributeObjects = new ArrayList<SetAttributeObject>(); - setAttributes = new ArrayList<String>(); - } - - protected Object readResolve() { - setAttributes = new ArrayList<String>(); - return super.readResolve(); - } - - @Override - public void check(Animation animation, BControl control) { - - this.setAttributes.clear(); - - // Collect evaluate predicate objects in list - for (SetAttributeObject obj : setAttributeObjects) { - - obj.setHasError(false); - - // First evaluate predicate (predicate field) - String bolValue = "true"; - if (obj.getEval().length() > 0) { - bolValue = BMSUtil.parsePredicate(obj.getEval(), control, - animation); - } - - if (!obj.hasError() && Boolean.valueOf(bolValue)) { - - String attributeID = obj.getAttribute(); - - AbstractAttribute attributeObj = control - .getAttribute(attributeID); - - Object attributeVal = obj.getValue(); - - if (obj.isExpressionMode()) { - String strAtrVal = BMSUtil.parseExpression( - attributeVal.toString(), control, animation); - String er = attributeObj.validateValue(strAtrVal, null); - if (er != null) { - // addError( - // control, - // animation, - // "You selected " - // + attributeObj.getName() - // + - // " as attribute. There is a problem with your value: " - // + strAtrVal + " - Reason: " + er); - obj.setHasError(true); - } else { - attributeVal = attributeObj.unmarshal(strAtrVal); - } - } - - if (!obj.hasError()) { - Object oldAttrVal = control.getAttributeValue(attributeID); - if (!oldAttrVal.equals(attributeVal)) { - control.setAttributeValue(attributeID, attributeVal, - true, false); - } - } - - setAttributes.add(attributeID); - - } - - } - - // Restore attribute values - for (SetAttributeObject obj : setAttributeObjects) { - if (!setAttributes.contains(obj.getAttribute())) { - AbstractAttribute attributeObj = control.getAttribute(obj - .getAttribute()); - Object oldAttrVal = control.getAttributeValue(obj - .getAttribute()); - if (!oldAttrVal.equals(attributeObj.getInitValue())) { - control.restoreDefaultValue(attributeObj.getID()); - } - } - } - - } - - @Override - public ObserverWizard getWizard(BControl control) { - return new WizardObserverSetAttribute(control, this); - } - - public void setSetAttributeObjects( - List<SetAttributeObject> setAttributeObjects) { - this.setAttributeObjects = setAttributeObjects; - } - - public List<SetAttributeObject> getSetAttributeObjects() { - return setAttributeObjects; - } - - public Observer clone() throws CloneNotSupportedException { - SetAttribute clonedObserver = (SetAttribute) super.clone(); - List<SetAttributeObject> list = new ArrayList<SetAttributeObject>(); - for (SetAttributeObject obj : getSetAttributeObjects()) { - list.add(obj.clone()); - } - clonedObserver.setSetAttributeObjects(list); - return clonedObserver; - } - - @Override - public IFigure getToolTip(BControl control) { - // // TODO: This method need rework!!! - // StringBuilder builder = new StringBuilder(); - // builder.append("Set Attribute Observer:\n\n"); - // for (SetAttributeObject obj : getSetAttributeObjects()) { - // if (obj.getEval() != null) { - // builder.append("[Predicate: " + obj.getEval()); - // } - // if (obj.getAttribute() != null) { - // builder.append(" | Attribute: " - // + control.getAttribute(obj.getAttribute()).getName()); - // } - // if (obj.getValue() != null) { - // builder.append(" | Value: " + obj.getValue() + "]"); - // } - // builder.append("\n"); - // } - // Label lb = new Label(builder.toString()); - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.IFigure; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSetAttribute; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class SetAttribute extends Observer { + + private List<SetAttributeObject> setAttributeObjects; + private transient List<String> setAttributes; + + public SetAttribute() { + super(); + setAttributeObjects = new ArrayList<SetAttributeObject>(); + setAttributes = new ArrayList<String>(); + } + + protected Object readResolve() { + setAttributes = new ArrayList<String>(); + return super.readResolve(); + } + + @Override + public void check(Animation animation, BControl control) { + + this.setAttributes.clear(); + + // Collect evaluate predicate objects in list + for (SetAttributeObject obj : setAttributeObjects) { + + obj.setHasError(false); + + // First evaluate predicate (predicate field) + String bolValue = "true"; + if (obj.getEval().length() > 0) { + bolValue = BMSUtil.parsePredicate(obj.getEval(), control, + animation); + } + + if (!obj.hasError() && Boolean.valueOf(bolValue)) { + + String attributeID = obj.getAttribute(); + + AbstractAttribute attributeObj = control + .getAttribute(attributeID); + + Object attributeVal = obj.getValue(); + + if (obj.isExpressionMode()) { + String strAtrVal = BMSUtil.parseExpression( + attributeVal.toString(), control, animation); + String er = attributeObj.validateValue(strAtrVal, null); + if (er != null) { + // addError( + // control, + // animation, + // "You selected " + // + attributeObj.getName() + // + + // " as attribute. There is a problem with your value: " + // + strAtrVal + " - Reason: " + er); + obj.setHasError(true); + } else { + attributeVal = attributeObj.unmarshal(strAtrVal); + } + } + + if (!obj.hasError()) { + Object oldAttrVal = control.getAttributeValue(attributeID); + if (!oldAttrVal.equals(attributeVal)) { + control.setAttributeValue(attributeID, attributeVal, + true, false); + } + } + + setAttributes.add(attributeID); + + } + + } + + // Restore attribute values + for (SetAttributeObject obj : setAttributeObjects) { + if (!setAttributes.contains(obj.getAttribute())) { + AbstractAttribute attributeObj = control.getAttribute(obj + .getAttribute()); + Object oldAttrVal = control.getAttributeValue(obj + .getAttribute()); + if (!oldAttrVal.equals(attributeObj.getInitValue())) { + control.restoreDefaultValue(attributeObj.getID()); + } + } + } + + } + + @Override + public ObserverWizard getWizard(BControl control) { + return new WizardObserverSetAttribute(control, this); + } + + public void setSetAttributeObjects( + List<SetAttributeObject> setAttributeObjects) { + this.setAttributeObjects = setAttributeObjects; + } + + public List<SetAttributeObject> getSetAttributeObjects() { + return setAttributeObjects; + } + + public Observer clone() throws CloneNotSupportedException { + SetAttribute clonedObserver = (SetAttribute) super.clone(); + List<SetAttributeObject> list = new ArrayList<SetAttributeObject>(); + for (SetAttributeObject obj : getSetAttributeObjects()) { + list.add(obj.clone()); + } + clonedObserver.setSetAttributeObjects(list); + return clonedObserver; + } + + @Override + public IFigure getToolTip(BControl control) { + // // TODO: This method need rework!!! + // StringBuilder builder = new StringBuilder(); + // builder.append("Set Attribute Observer:\n\n"); + // for (SetAttributeObject obj : getSetAttributeObjects()) { + // if (obj.getEval() != null) { + // builder.append("[Predicate: " + obj.getEval()); + // } + // if (obj.getAttribute() != null) { + // builder.append(" | Attribute: " + // + control.getAttribute(obj.getAttribute()).getName()); + // } + // if (obj.getValue() != null) { + // builder.append(" | Value: " + obj.getValue() + "]"); + // } + // builder.append("\n"); + // } + // Label lb = new Label(builder.toString()); + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttributeObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttributeObject.java index d73f0c5abadd0e021fdff1f2932ab3346e79004f..35b6cc74601451356262244527e0bbf95199a9ef 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttributeObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SetAttributeObject.java @@ -1,24 +1,24 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - - -public class SetAttributeObject extends ObserverEvalObject implements Cloneable { - - public SetAttributeObject() { - super(); - } - - public SetAttributeObject(String type, String eval) { - super(type, eval); - } - - public SetAttributeObject clone() throws CloneNotSupportedException { - return (SetAttributeObject) super.clone(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + + +public class SetAttributeObject extends ObserverEvalObject implements Cloneable { + + public SetAttributeObject() { + super(); + } + + public SetAttributeObject(String type, String eval) { + super(type, eval); + } + + public SetAttributeObject clone() throws CloneNotSupportedException { + return (SetAttributeObject) super.clone(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SimpleValueDisplay.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SimpleValueDisplay.java index 9886b3184634dbe24246762aeadd7c237c870bfc..ab053bc3d612e12eefc82800df7122ddb76abb00 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SimpleValueDisplay.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SimpleValueDisplay.java @@ -1,101 +1,101 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSimpleValueDisplay; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class SimpleValueDisplay extends Observer { - - private String type; - private String eval; - private String predicate; - private String replacementString; - private transient String orgString; - private transient boolean isOrgStringSet = false; - - public void check(final Animation animation, final BControl bcontrol) { - - // First evaluate predicate (predicate field) - String bolValue = "true"; - if (predicate != null && predicate.length() > 0) { - bolValue = BMSUtil.parsePredicate(predicate, bcontrol, animation); - } - - if (Boolean.valueOf(bolValue)) { - - String fEval = BMSUtil.parseExpression(eval, bcontrol, animation); - - if (!isOrgStringSet) { - orgString = bcontrol.getAttributeValue( - AttributeConstants.ATTRIBUTE_TEXT).toString(); - isOrgStringSet = true; - } - - String parseString = orgString; - - if (replacementString != null) { - if (replacementString.length() > 0) { - parseString = orgString.replace(replacementString, fEval); - } - } else { - parseString = fEval; - } - - bcontrol.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, - parseString); - - } - - } - - public ObserverWizard getWizard(final BControl bcontrol) { - return new WizardObserverSimpleValueDisplay(bcontrol, this); - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public void setEval(String eval) { - this.eval = eval; - } - - public String getEval() { - return eval; - } - - public String getPredicate() { - return predicate; - } - - public void setPredicate(String predicate) { - this.predicate = predicate; - } - - public void setReplacementString(String replacementString) { - this.replacementString = replacementString; - } - - public String getReplacementString() { - return replacementString; - } - - public Observer clone() throws CloneNotSupportedException { - SimpleValueDisplay clonedObserver = (SimpleValueDisplay) super.clone(); - clonedObserver.isOrgStringSet = false; - return clonedObserver; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSimpleValueDisplay; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class SimpleValueDisplay extends Observer { + + private String type; + private String eval; + private String predicate; + private String replacementString; + private transient String orgString; + private transient boolean isOrgStringSet = false; + + public void check(final Animation animation, final BControl bcontrol) { + + // First evaluate predicate (predicate field) + String bolValue = "true"; + if (predicate != null && predicate.length() > 0) { + bolValue = BMSUtil.parsePredicate(predicate, bcontrol, animation); + } + + if (Boolean.valueOf(bolValue)) { + + String fEval = BMSUtil.parseExpression(eval, bcontrol, animation); + + if (!isOrgStringSet) { + orgString = bcontrol.getAttributeValue( + AttributeConstants.ATTRIBUTE_TEXT).toString(); + isOrgStringSet = true; + } + + String parseString = orgString; + + if (replacementString != null) { + if (replacementString.length() > 0) { + parseString = orgString.replace(replacementString, fEval); + } + } else { + parseString = fEval; + } + + bcontrol.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT, + parseString); + + } + + } + + public ObserverWizard getWizard(final BControl bcontrol) { + return new WizardObserverSimpleValueDisplay(bcontrol, this); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public void setEval(String eval) { + this.eval = eval; + } + + public String getEval() { + return eval; + } + + public String getPredicate() { + return predicate; + } + + public void setPredicate(String predicate) { + this.predicate = predicate; + } + + public void setReplacementString(String replacementString) { + this.replacementString = replacementString; + } + + public String getReplacementString() { + return replacementString; + } + + public Observer clone() throws CloneNotSupportedException { + SimpleValueDisplay clonedObserver = (SimpleValueDisplay) super.clone(); + clonedObserver.isOrgStringSet = false; + return clonedObserver; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java index b078e12811804505d629a88c34b6c08b9e595651..2708ce2020062abdbd24ec181a45f82e2cec4814 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java @@ -1,125 +1,125 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import java.util.ArrayList; -import java.util.List; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverCSwitchCoordinates; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class SwitchChildCoordinates extends Observer { - - private List<ToggleObjectCoordinates> toggleObjects; - - public SwitchChildCoordinates() { - toggleObjects = new ArrayList<ToggleObjectCoordinates>(); - } - - public void check(final Animation animation, final BControl control) { - - // Collect evaluate predicate objects in list - for (ToggleObjectCoordinates obj : toggleObjects) { - - obj.setHasError(false); - - // First evaluate predicate (predicate field) - String bolValue = "true"; - if (obj.getEval().length() > 0) { - bolValue = BMSUtil.parsePredicate(obj.getEval(), control, - animation); - } - - if (!obj.hasError() && Boolean.valueOf(bolValue)) { - - // Handle control field - BControl toggleControl = null; - String parsedControl = BMSUtil.parseExpression( - obj.getBcontrol(), control, animation, false); - toggleControl = control.getChild(parsedControl); - if (toggleControl == null) { - obj.setHasError(true); - // addError(control, animation, "No such control: " - // + parsedControl); - } - - Integer parsedX = 0; - Integer parsedY = 0; - // Handle X field - try { - parsedX = Integer.valueOf(BMSUtil.parseExpression( - obj.getX(), control, animation)); - } catch (NumberFormatException n) { - obj.setHasError(true); - // addError(control, animation, "x is not a valid integer: " - // + n.getMessage()); - } - // Handle Y field - try { - parsedY = Integer.valueOf(BMSUtil.parseExpression( - obj.getY(), control, animation)); - } catch (NumberFormatException n) { - obj.setHasError(true); - // addError(control, animation, "y is not a valid integer: " - // + n.getMessage()); - } - - if (!obj.hasError()) { - if (Boolean.valueOf(bolValue)) { // If true - // if (obj.getAnimate()) { - // - // AnimationMove aMove = new AnimationMove(500, true, - // toggleControl, parsedX, parsedY); - // // aMove.addAnimationListener(animationListener); - // aMove.start(); - // - // } else { - - toggleControl.setAttributeValue( - AttributeConstants.ATTRIBUTE_X, parsedX, true, - false); - toggleControl.setAttributeValue( - AttributeConstants.ATTRIBUTE_Y, parsedY, true, - false); - - // } - } - } - - } - - } - - } - - public ObserverWizard getWizard(final BControl bcontrol) { - return new WizardObserverCSwitchCoordinates(bcontrol, this); - } - - public List<ToggleObjectCoordinates> getToggleObjects() { - return this.toggleObjects; - } - - public void setToggleObjects(final List<ToggleObjectCoordinates> list) { - this.toggleObjects = list; - } - - public Observer clone() throws CloneNotSupportedException { - SwitchChildCoordinates clonedObserver = (SwitchChildCoordinates) super - .clone(); - List<ToggleObjectCoordinates> list = new ArrayList<ToggleObjectCoordinates>(); - for (ToggleObjectCoordinates obj : getToggleObjects()) { - list.add(obj.clone()); - } - clonedObserver.setToggleObjects(list); - return clonedObserver; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import java.util.ArrayList; +import java.util.List; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverCSwitchCoordinates; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class SwitchChildCoordinates extends Observer { + + private List<ToggleObjectCoordinates> toggleObjects; + + public SwitchChildCoordinates() { + toggleObjects = new ArrayList<ToggleObjectCoordinates>(); + } + + public void check(final Animation animation, final BControl control) { + + // Collect evaluate predicate objects in list + for (ToggleObjectCoordinates obj : toggleObjects) { + + obj.setHasError(false); + + // First evaluate predicate (predicate field) + String bolValue = "true"; + if (obj.getEval().length() > 0) { + bolValue = BMSUtil.parsePredicate(obj.getEval(), control, + animation); + } + + if (!obj.hasError() && Boolean.valueOf(bolValue)) { + + // Handle control field + BControl toggleControl = null; + String parsedControl = BMSUtil.parseExpression( + obj.getBcontrol(), control, animation, false); + toggleControl = control.getChild(parsedControl); + if (toggleControl == null) { + obj.setHasError(true); + // addError(control, animation, "No such control: " + // + parsedControl); + } + + Integer parsedX = 0; + Integer parsedY = 0; + // Handle X field + try { + parsedX = Integer.valueOf(BMSUtil.parseExpression( + obj.getX(), control, animation)); + } catch (NumberFormatException n) { + obj.setHasError(true); + // addError(control, animation, "x is not a valid integer: " + // + n.getMessage()); + } + // Handle Y field + try { + parsedY = Integer.valueOf(BMSUtil.parseExpression( + obj.getY(), control, animation)); + } catch (NumberFormatException n) { + obj.setHasError(true); + // addError(control, animation, "y is not a valid integer: " + // + n.getMessage()); + } + + if (!obj.hasError()) { + if (Boolean.valueOf(bolValue)) { // If true + // if (obj.getAnimate()) { + // + // AnimationMove aMove = new AnimationMove(500, true, + // toggleControl, parsedX, parsedY); + // // aMove.addAnimationListener(animationListener); + // aMove.start(); + // + // } else { + + toggleControl.setAttributeValue( + AttributeConstants.ATTRIBUTE_X, parsedX, true, + false); + toggleControl.setAttributeValue( + AttributeConstants.ATTRIBUTE_Y, parsedY, true, + false); + + // } + } + } + + } + + } + + } + + public ObserverWizard getWizard(final BControl bcontrol) { + return new WizardObserverCSwitchCoordinates(bcontrol, this); + } + + public List<ToggleObjectCoordinates> getToggleObjects() { + return this.toggleObjects; + } + + public void setToggleObjects(final List<ToggleObjectCoordinates> list) { + this.toggleObjects = list; + } + + public Observer clone() throws CloneNotSupportedException { + SwitchChildCoordinates clonedObserver = (SwitchChildCoordinates) super + .clone(); + List<ToggleObjectCoordinates> list = new ArrayList<ToggleObjectCoordinates>(); + for (ToggleObjectCoordinates obj : getToggleObjects()) { + list.add(obj.clone()); + } + clonedObserver.setToggleObjects(list); + return clonedObserver; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java index 0f7733a383286e15814bb1321f7f0bc351fdc09d..f71dfca1fc293febd9223bc255ec2a6bbe1c0954 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java @@ -1,134 +1,134 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import java.util.ArrayList; -import java.util.List; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSwitchCoordinates; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class SwitchCoordinates extends Observer { - - private List<ToggleObjectCoordinates> toggleObjects; - - public SwitchCoordinates() { - toggleObjects = new ArrayList<ToggleObjectCoordinates>(); - } - - public void check(final Animation animation, final BControl control) { - - boolean set = false; - - // Collect evaluate predicate objects in list - for (ToggleObjectCoordinates obj : toggleObjects) { - - obj.setHasError(false); - - // First evaluate predicate (predicate field) - String bolValue = "true"; - if (obj.getEval().length() > 0) { - bolValue = BMSUtil.parsePredicate(obj.getEval(), control, - animation); - } - - if (!obj.hasError() && Boolean.valueOf(bolValue)) { - - int parsedX = 0; - int parsedY = 0; - // Handle X field - try { - parsedX = Integer.valueOf(BMSUtil.parseExpression( - obj.getX(), control, animation)); - } catch (NumberFormatException n) { - obj.setHasError(true); - // addError(control, animation, "x is not a valid integer: " - // + n.getMessage()); - } - // Handle Y field - try { - parsedY = Integer.valueOf(BMSUtil.parseExpression( - obj.getY(), control, animation)); - } catch (NumberFormatException n) { - obj.setHasError(true); - // addError(control, animation, "y is not a valid integer: " - // + n.getMessage()); - } - - int currentX = Integer.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_X).toString()); - int currentY = Integer.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_Y).toString()); - - if (currentX != parsedX || currentY != parsedY) { - - // setCallBack(false); - - // If true - // if (obj.getAnimate()) { - - // if (!checked) - // return; - - // AnimationMove aMove = new AnimationMove(5000, true, - // control, parsedX, parsedY); - // aMove.addAnimationListener(animationListener); - // aMove.start(); - - // } else { - control.setAttributeValue(AttributeConstants.ATTRIBUTE_X, - parsedX, true, false); - control.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, - parsedY, true, false); - // setCallBack(true); - // checked = false; - // } - - } - // else { - // setCallBack(true); - // } - - set = true; - - } - - } - - if (!set) { - control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); - control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); - } - - } - - public ObserverWizard getWizard(final BControl bcontrol) { - return new WizardObserverSwitchCoordinates(bcontrol, this); - } - - public List<ToggleObjectCoordinates> getToggleObjects() { - return this.toggleObjects; - } - - public void setToggleObjects(final List<ToggleObjectCoordinates> list) { - this.toggleObjects = list; - } - - public Observer clone() throws CloneNotSupportedException { - SwitchCoordinates clonedObserver = (SwitchCoordinates) super.clone(); - List<ToggleObjectCoordinates> list = new ArrayList<ToggleObjectCoordinates>(); - for (ToggleObjectCoordinates obj : getToggleObjects()) { - list.add(obj.clone()); - } - clonedObserver.setToggleObjects(list); - return clonedObserver; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import java.util.ArrayList; +import java.util.List; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSwitchCoordinates; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class SwitchCoordinates extends Observer { + + private List<ToggleObjectCoordinates> toggleObjects; + + public SwitchCoordinates() { + toggleObjects = new ArrayList<ToggleObjectCoordinates>(); + } + + public void check(final Animation animation, final BControl control) { + + boolean set = false; + + // Collect evaluate predicate objects in list + for (ToggleObjectCoordinates obj : toggleObjects) { + + obj.setHasError(false); + + // First evaluate predicate (predicate field) + String bolValue = "true"; + if (obj.getEval().length() > 0) { + bolValue = BMSUtil.parsePredicate(obj.getEval(), control, + animation); + } + + if (!obj.hasError() && Boolean.valueOf(bolValue)) { + + int parsedX = 0; + int parsedY = 0; + // Handle X field + try { + parsedX = Integer.valueOf(BMSUtil.parseExpression( + obj.getX(), control, animation)); + } catch (NumberFormatException n) { + obj.setHasError(true); + // addError(control, animation, "x is not a valid integer: " + // + n.getMessage()); + } + // Handle Y field + try { + parsedY = Integer.valueOf(BMSUtil.parseExpression( + obj.getY(), control, animation)); + } catch (NumberFormatException n) { + obj.setHasError(true); + // addError(control, animation, "y is not a valid integer: " + // + n.getMessage()); + } + + int currentX = Integer.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_X).toString()); + int currentY = Integer.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_Y).toString()); + + if (currentX != parsedX || currentY != parsedY) { + + // setCallBack(false); + + // If true + // if (obj.getAnimate()) { + + // if (!checked) + // return; + + // AnimationMove aMove = new AnimationMove(5000, true, + // control, parsedX, parsedY); + // aMove.addAnimationListener(animationListener); + // aMove.start(); + + // } else { + control.setAttributeValue(AttributeConstants.ATTRIBUTE_X, + parsedX, true, false); + control.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, + parsedY, true, false); + // setCallBack(true); + // checked = false; + // } + + } + // else { + // setCallBack(true); + // } + + set = true; + + } + + } + + if (!set) { + control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); + control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); + } + + } + + public ObserverWizard getWizard(final BControl bcontrol) { + return new WizardObserverSwitchCoordinates(bcontrol, this); + } + + public List<ToggleObjectCoordinates> getToggleObjects() { + return this.toggleObjects; + } + + public void setToggleObjects(final List<ToggleObjectCoordinates> list) { + this.toggleObjects = list; + } + + public Observer clone() throws CloneNotSupportedException { + SwitchCoordinates clonedObserver = (SwitchCoordinates) super.clone(); + List<ToggleObjectCoordinates> list = new ArrayList<ToggleObjectCoordinates>(); + for (ToggleObjectCoordinates obj : getToggleObjects()) { + list.add(obj.clone()); + } + clonedObserver.setToggleObjects(list); + return clonedObserver; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchImage.java index 4422c6182b1b5a1b1aab885e7b69650140c2c852..707251c81413542f56533e6299f75c837b0b21b8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchImage.java @@ -1,104 +1,104 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSwitchImage; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class SwitchImage extends Observer { - - private List<ToggleObjectImage> toggleObjects; - - public SwitchImage() { - toggleObjects = new ArrayList<ToggleObjectImage>(); - } - - public void check(final Animation animation, final BControl control) { - - boolean set = false; - - // Collect evaluate predicate objects in list - for (ToggleObjectImage obj : toggleObjects) { - - obj.setHasError(false); - - // First evaluate predicate (predicate field) - String bolValue = "true"; - if (obj.getEval().length() > 0) { - bolValue = BMSUtil.parsePredicate(obj.getEval(), control, - animation); - } - - if (!obj.hasError() && Boolean.valueOf(bolValue)) { - - String fImage = obj.getImage(); - - if (obj.isExpressionMode()) { // Expression mode - fImage = BMSUtil.parseExpression(obj.getImage(), control, - animation); - } - - IFile pFile = control.getVisualization().getProjectFile(); - String myPath = (pFile.getProject().getLocation() + "/images/" + fImage) - .replace("file:", ""); - if (!new File(myPath).exists()) { - // addError(control, animation, - // "No such image in your library: " + fImage); - } - - if (!obj.hasError()) { - if (!control.getAttributeValue( - AttributeConstants.ATTRIBUTE_IMAGE).equals(fImage)) { - control.setAttributeValue( - AttributeConstants.ATTRIBUTE_IMAGE, fImage, - true, false); - } - } - - set = true; - - } - - } - - if (!set) - control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); - - } - - public ObserverWizard getWizard(final BControl bcontrol) { - return new WizardObserverSwitchImage(bcontrol, this); - } - - public List<ToggleObjectImage> getToggleObjects() { - return this.toggleObjects; - } - - public void setToggleObjects(final List<ToggleObjectImage> list) { - this.toggleObjects = list; - } - - public Observer clone() throws CloneNotSupportedException { - SwitchImage clonedObserver = (SwitchImage) super.clone(); - List<ToggleObjectImage> list = new ArrayList<ToggleObjectImage>(); - for (ToggleObjectImage obj : getToggleObjects()) { - list.add(obj.clone()); - } - clonedObserver.setToggleObjects(list); - return clonedObserver; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSwitchImage; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class SwitchImage extends Observer { + + private List<ToggleObjectImage> toggleObjects; + + public SwitchImage() { + toggleObjects = new ArrayList<ToggleObjectImage>(); + } + + public void check(final Animation animation, final BControl control) { + + boolean set = false; + + // Collect evaluate predicate objects in list + for (ToggleObjectImage obj : toggleObjects) { + + obj.setHasError(false); + + // First evaluate predicate (predicate field) + String bolValue = "true"; + if (obj.getEval().length() > 0) { + bolValue = BMSUtil.parsePredicate(obj.getEval(), control, + animation); + } + + if (!obj.hasError() && Boolean.valueOf(bolValue)) { + + String fImage = obj.getImage(); + + if (obj.isExpressionMode()) { // Expression mode + fImage = BMSUtil.parseExpression(obj.getImage(), control, + animation); + } + + IFile pFile = control.getVisualization().getProjectFile(); + String myPath = (pFile.getProject().getLocation() + "/images/" + fImage) + .replace("file:", ""); + if (!new File(myPath).exists()) { + // addError(control, animation, + // "No such image in your library: " + fImage); + } + + if (!obj.hasError()) { + if (!control.getAttributeValue( + AttributeConstants.ATTRIBUTE_IMAGE).equals(fImage)) { + control.setAttributeValue( + AttributeConstants.ATTRIBUTE_IMAGE, fImage, + true, false); + } + } + + set = true; + + } + + } + + if (!set) + control.restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); + + } + + public ObserverWizard getWizard(final BControl bcontrol) { + return new WizardObserverSwitchImage(bcontrol, this); + } + + public List<ToggleObjectImage> getToggleObjects() { + return this.toggleObjects; + } + + public void setToggleObjects(final List<ToggleObjectImage> list) { + this.toggleObjects = list; + } + + public Observer clone() throws CloneNotSupportedException { + SwitchImage clonedObserver = (SwitchImage) super.clone(); + List<ToggleObjectImage> list = new ArrayList<ToggleObjectImage>(); + for (ToggleObjectImage obj : getToggleObjects()) { + list.add(obj.clone()); + } + clonedObserver.setToggleObjects(list); + return clonedObserver; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java index 0ebd9af41725df1c3d7b59819f7534bfa0846886..07765bdc3bfb5b515e6534e378e6bfcd76815d28 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java @@ -1,83 +1,83 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - -public class ToggleObjectCoordinates extends ObserverEvalObject implements - Cloneable { - - private String bcontrol; - private String x; - private String y; - - // private Boolean animate; - - public ToggleObjectCoordinates() { - super(); - this.x = ""; - this.y = ""; - // this.animate = false; - } - - public ToggleObjectCoordinates(String type, String bcontrol, String x, - String y, String eval) { - super(type, eval); - this.bcontrol = bcontrol; - this.x = x; - this.y = y; - // this.animate = animate; - } - - public ToggleObjectCoordinates(String type, String x, String y, - String eval) { - this(type, null, x, y, eval); - } - - public String getBcontrol() { - return bcontrol; - } - - public String getX() { - return x; - } - - public String getY() { - return y; - } - - // public Boolean getAnimate() { - // return animate; - // } - - public void setBcontrol(String bcontrol) { - Object oldValue = this.bcontrol; - this.bcontrol = bcontrol; - firePropertyChange("bcontrol", oldValue, this.bcontrol); - } - - public void setX(String x) { - Object oldValue = this.x; - this.x = x; - firePropertyChange("x", oldValue, this.x); - } - - public void setY(String y) { - Object oldValue = this.y; - this.y = y; - firePropertyChange("y", oldValue, this.y); - } - - // public void setAnimate(Boolean animate) { - // Object oldValue = this.animate; - // this.animate = animate; - // firePropertyChange("animate", oldValue, this.animate); - // } - - public ToggleObjectCoordinates clone() throws CloneNotSupportedException { - return (ToggleObjectCoordinates) super.clone(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + +public class ToggleObjectCoordinates extends ObserverEvalObject implements + Cloneable { + + private String bcontrol; + private String x; + private String y; + + // private Boolean animate; + + public ToggleObjectCoordinates() { + super(); + this.x = ""; + this.y = ""; + // this.animate = false; + } + + public ToggleObjectCoordinates(String type, String bcontrol, String x, + String y, String eval) { + super(type, eval); + this.bcontrol = bcontrol; + this.x = x; + this.y = y; + // this.animate = animate; + } + + public ToggleObjectCoordinates(String type, String x, String y, + String eval) { + this(type, null, x, y, eval); + } + + public String getBcontrol() { + return bcontrol; + } + + public String getX() { + return x; + } + + public String getY() { + return y; + } + + // public Boolean getAnimate() { + // return animate; + // } + + public void setBcontrol(String bcontrol) { + Object oldValue = this.bcontrol; + this.bcontrol = bcontrol; + firePropertyChange("bcontrol", oldValue, this.bcontrol); + } + + public void setX(String x) { + Object oldValue = this.x; + this.x = x; + firePropertyChange("x", oldValue, this.x); + } + + public void setY(String y) { + Object oldValue = this.y; + this.y = y; + firePropertyChange("y", oldValue, this.y); + } + + // public void setAnimate(Boolean animate) { + // Object oldValue = this.animate; + // this.animate = animate; + // firePropertyChange("animate", oldValue, this.animate); + // } + + public ToggleObjectCoordinates clone() throws CloneNotSupportedException { + return (ToggleObjectCoordinates) super.clone(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectImage.java index dcd321623e5df59845f339638bacee19a1b31cba..5169e967a6ec6bf3c06612d5219e952bba40aff2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectImage.java @@ -1,36 +1,36 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer; - - -public class ToggleObjectImage extends ObserverEvalObject implements Cloneable { - - private String image; - - public ToggleObjectImage() { - } - - public ToggleObjectImage(String type, String image, String eval) { - super(type, eval); - this.image = image; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - Object oldValue = this.image; - this.image = image; - firePropertyChange("image", oldValue, this.image); - } - - public ToggleObjectImage clone() throws CloneNotSupportedException { - return (ToggleObjectImage) super.clone(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer; + + +public class ToggleObjectImage extends ObserverEvalObject implements Cloneable { + + private String image; + + public ToggleObjectImage() { + } + + public ToggleObjectImage(String type, String image, String eval) { + super(type, eval); + this.image = image; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + Object oldValue = this.image; + this.image = image; + firePropertyChange("image", oldValue, this.image); + } + + public ToggleObjectImage clone() throws CloneNotSupportedException { + return (ToggleObjectImage) super.clone(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardColumnObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardColumnObserver.java index 04c3a5cd6d6850073f3666b70767eb971400eba6..7929eef17522ee3452788fdb37f0b95de3b7c0a9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardColumnObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardColumnObserver.java @@ -1,125 +1,125 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.ColumnObserver; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; - -public class WizardColumnObserver extends ObserverWizard { - - private class ColumnObserverPage extends WizardPage { - - private Text txtExpression; - private Text txtPredicate; - - public Text getTxtExpression() { - return txtExpression; - } - - protected ColumnObserverPage(final String pageName) { - super(pageName); - } - - public void createControl(final Composite parent) { - - final DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - container.setLayout(new GridLayout(2, false)); - - Label lb = new Label(container, SWT.NONE); - lb.setText("Predicate:"); - - txtPredicate = new Text(container, SWT.BORDER); - txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtPredicate.setFont(new Font(Display.getDefault(), new FontData( - "Arial", 10, SWT.NONE))); - - lb = new Label(container, SWT.NONE); - lb.setText("Expression:"); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - txtExpression = new Text(container, SWT.BORDER | SWT.MULTI - | SWT.WRAP); - txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); - - initBindings(dbc); - - setControl(container); - - } - - private void initBindings(DataBindingContext dbc) { - - dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), - BeansObservables.observeValue( - (ColumnObserver) getObserver(), "predicate")); - - dbc.bindValue( - SWTObservables.observeText(txtExpression, SWT.Modify), - BeansObservables.observeValue( - (ColumnObserver) getObserver(), "expression")); - - } - - } - - public WizardColumnObserver(BControl bcontrol, - Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ColumnObserverPage("ColumnObserverPage")); - } - - @Override - protected Boolean prepareToFinish() { - - ColumnObserverPage page = (ColumnObserverPage) getPage("ColumnObserverPage"); - - String errorStr = ""; - - if (page.getTxtExpression().getText().length() == 0) - errorStr += "Please enter an expression.\n"; - - if (page.getErrorMessage() != null) - errorStr += "Please check the syntax/parser error.\n"; - - if (errorStr.length() > 0) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An Error occured", errorStr); - return false; - } - - return true; - - } - - @Override - public Point getSize() { - return new Point(600, 500); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.ColumnObserver; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; + +public class WizardColumnObserver extends ObserverWizard { + + private class ColumnObserverPage extends WizardPage { + + private Text txtExpression; + private Text txtPredicate; + + public Text getTxtExpression() { + return txtExpression; + } + + protected ColumnObserverPage(final String pageName) { + super(pageName); + } + + public void createControl(final Composite parent) { + + final DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + container.setLayout(new GridLayout(2, false)); + + Label lb = new Label(container, SWT.NONE); + lb.setText("Predicate:"); + + txtPredicate = new Text(container, SWT.BORDER); + txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtPredicate.setFont(new Font(Display.getDefault(), new FontData( + "Arial", 10, SWT.NONE))); + + lb = new Label(container, SWT.NONE); + lb.setText("Expression:"); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + txtExpression = new Text(container, SWT.BORDER | SWT.MULTI + | SWT.WRAP); + txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); + + initBindings(dbc); + + setControl(container); + + } + + private void initBindings(DataBindingContext dbc) { + + dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), + BeansObservables.observeValue( + (ColumnObserver) getObserver(), "predicate")); + + dbc.bindValue( + SWTObservables.observeText(txtExpression, SWT.Modify), + BeansObservables.observeValue( + (ColumnObserver) getObserver(), "expression")); + + } + + } + + public WizardColumnObserver(BControl bcontrol, + Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ColumnObserverPage("ColumnObserverPage")); + } + + @Override + protected Boolean prepareToFinish() { + + ColumnObserverPage page = (ColumnObserverPage) getPage("ColumnObserverPage"); + + String errorStr = ""; + + if (page.getTxtExpression().getText().length() == 0) + errorStr += "Please enter an expression.\n"; + + if (page.getErrorMessage() != null) + errorStr += "Please check the syntax/parser error.\n"; + + if (errorStr.length() > 0) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An Error occured", errorStr); + return false; + } + + return true; + + } + + @Override + public Point getSize() { + return new Point(600, 500); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java index d03fa3f9aa13d32d0b6efb38bfb3319bb3474b01..9f89e701174dfe9f0cf329e55eb75f1376d99b00 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java @@ -1,320 +1,320 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.be4.classicalb.core.parser.BParser; -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.edit.TextEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates; -import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardObserverCSwitchCoordinates extends ObserverWizard { - - // private String lastChangedControlID; - - private class ObserverCSwitchCoordinatesPage extends - AbstractObserverWizardPage { - - private TableViewer tableViewer; - - protected ObserverCSwitchCoordinatesPage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(Composite parent) { - - super.createControl(parent); - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, ToggleObjectCoordinates.class, - ((BMotionAbstractWizard) getWizard()).getName()); - // tableViewer - // .addSelectionChangedListener(new ISelectionChangedListener() { - // - // @Override - // public void selectionChanged(SelectionChangedEvent event) { - // IStructuredSelection selection = (IStructuredSelection) event - // .getSelection(); - // Object firstElement = selection.getFirstElement(); - // if (firstElement instanceof ObserverEvalObject) { - // restorePreview(); - // ObserverEvalObject observerEvalObject = (ObserverEvalObject) - // firstElement; - // if (!observerEvalObject.isExpressionMode()) { - // BControl control = getBControl(); - // ToggleObjectCoordinates toggleObjectCoordinates = - // (ToggleObjectCoordinates) observerEvalObject; - // String attributeX = AttributeConstants.ATTRIBUTE_X; - // String attributeY = AttributeConstants.ATTRIBUTE_Y; - // String x = toggleObjectCoordinates.getX(); - // String y = toggleObjectCoordinates.getY(); - // String controlID = toggleObjectCoordinates - // .getBcontrol(); - // BControl bControl = control - // .getChild(controlID); - // if (bControl != null) { - // bControl.setAttributeValue(attributeX, - // x, true, false); - // bControl.setAttributeValue(attributeY, - // y, true, false); - // } - // lastChangedControlID = controlID; - // } - // } - // } - // - // }); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(100); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "eval", getBControl().getVisualization(), getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Control"); - column.getColumn().setWidth(175); - column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, - "bcontrol")); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("X"); - column.getColumn().setWidth(125); - column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, - "x")); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Y"); - column.getColumn().setWidth(125); - column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, - "y")); - - // column = new TableViewerColumn(tableViewer, SWT.NONE); - // column.getColumn().setText("Animate?"); - // column.getColumn().setWidth(75); - // column.setEditingSupport(new EditingSupport(tableViewer) { - // - // private CellEditor cellEditor = new CheckboxCellEditor( - // (Composite) tableViewer.getControl()); - // - // @Override - // protected void setValue(Object element, Object value) { - // ((ToggleObjectCoordinates) element).setAnimate(Boolean - // .valueOf(String.valueOf(value))); - // } - // - // @Override - // protected Object getValue(Object element) { - // Boolean b = ((ToggleObjectCoordinates) element) - // .getAnimate(); - // return b != null ? b : false; - // } - // - // @Override - // protected CellEditor getCellEditor(Object element) { - // return cellEditor; - // } - // - // @Override - // protected boolean canEdit(Object element) { - // return true; - // } - // - // }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - tableViewer - .setLabelProvider(new ObserverLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), - new String[] { "eval", "bcontrol", "x", - "y", "animate" }))); - - final WritableList input = new WritableList( - ((SwitchChildCoordinates) getObserver()).getToggleObjects(), - ToggleObjectCoordinates.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - ToggleObjectCoordinates toggleObj = (ToggleObjectCoordinates) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(toggleObj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( - BParser.PREDICATE_PREFIX, "", "", "", ""); - input.add(toggleObj); - } - }); - - setControl(container); - - } - } - - public WizardObserverCSwitchCoordinates(final BControl bcontrol, - final Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverCSwitchCoordinatesPage( - "ObserverCToggleCoordinatesPage")); - } - - @Override - protected Boolean prepareToFinish() { - // restorePreview(); - if (((SwitchChildCoordinates) getObserver()).getToggleObjects().size() == 0) { - setObserverDelete(true); - } else { - for (ToggleObjectCoordinates obj : ((SwitchChildCoordinates) getObserver()) - .getToggleObjects()) { - if (obj.getX().isEmpty() || obj.getY().isEmpty() - || obj.getBcontrol().isEmpty()) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The x , y and control fields must not be empty."); - return false; - } - } - } - return true; - } - - // private void restorePreview() { - // if (lastChangedControlID != null) { - // BControl bControl = getBControl().getChild(lastChangedControlID); - // if (bControl != null) { - // bControl.restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); - // bControl.restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); - // } - // } - // } - - @Override - public boolean performCancel() { - // restorePreview(); - return super.performCancel(); - } - - @Override - public Point getSize() { - return new Point(650, 500); - } - - private static class ObserverLabelProvider extends - ObservableMapLabelProvider implements ITableLabelProvider, - ITableColorProvider, ITableFontProvider { - - public ObserverLabelProvider(IObservableMap[] attributeMaps) { - super(attributeMaps); - } - - private final Color errorColor = Display.getDefault().getSystemColor( - SWT.COLOR_INFO_BACKGROUND); - - // final Font bold = JFaceResources.getFontRegistry().getBold( - // JFaceResources.BANNER_FONT); - - @Override - public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 4) { - return ""; - } - return super.getColumnText(element, columnIndex); - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - // if (columnIndex == 4) { - // return CheckboxCellEditorHelper - // .getCellEditorImage(((ToggleObjectCoordinates) element) - // .getAnimate()); - // } - return null; - } - - public Color getBackground(final Object element, final int column) { - ToggleObjectCoordinates attributeObject = (ToggleObjectCoordinates) element; - if (attributeObject.hasError()) - return errorColor; - return null; - } - - public Color getForeground(final Object element, final int column) { - return null; - } - - public Font getFont(final Object element, final int column) { - // return JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY); - return null; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableColorProvider; +import org.eclipse.jface.viewers.ITableFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +import de.be4.classicalb.core.parser.BParser; +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.edit.TextEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates; +import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardObserverCSwitchCoordinates extends ObserverWizard { + + // private String lastChangedControlID; + + private class ObserverCSwitchCoordinatesPage extends + AbstractObserverWizardPage { + + private TableViewer tableViewer; + + protected ObserverCSwitchCoordinatesPage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(Composite parent) { + + super.createControl(parent); + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, ToggleObjectCoordinates.class, + ((BMotionAbstractWizard) getWizard()).getName()); + // tableViewer + // .addSelectionChangedListener(new ISelectionChangedListener() { + // + // @Override + // public void selectionChanged(SelectionChangedEvent event) { + // IStructuredSelection selection = (IStructuredSelection) event + // .getSelection(); + // Object firstElement = selection.getFirstElement(); + // if (firstElement instanceof ObserverEvalObject) { + // restorePreview(); + // ObserverEvalObject observerEvalObject = (ObserverEvalObject) + // firstElement; + // if (!observerEvalObject.isExpressionMode()) { + // BControl control = getBControl(); + // ToggleObjectCoordinates toggleObjectCoordinates = + // (ToggleObjectCoordinates) observerEvalObject; + // String attributeX = AttributeConstants.ATTRIBUTE_X; + // String attributeY = AttributeConstants.ATTRIBUTE_Y; + // String x = toggleObjectCoordinates.getX(); + // String y = toggleObjectCoordinates.getY(); + // String controlID = toggleObjectCoordinates + // .getBcontrol(); + // BControl bControl = control + // .getChild(controlID); + // if (bControl != null) { + // bControl.setAttributeValue(attributeX, + // x, true, false); + // bControl.setAttributeValue(attributeY, + // y, true, false); + // } + // lastChangedControlID = controlID; + // } + // } + // } + // + // }); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(100); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "eval", getBControl().getVisualization(), getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Control"); + column.getColumn().setWidth(175); + column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, + "bcontrol")); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("X"); + column.getColumn().setWidth(125); + column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, + "x")); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Y"); + column.getColumn().setWidth(125); + column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, + "y")); + + // column = new TableViewerColumn(tableViewer, SWT.NONE); + // column.getColumn().setText("Animate?"); + // column.getColumn().setWidth(75); + // column.setEditingSupport(new EditingSupport(tableViewer) { + // + // private CellEditor cellEditor = new CheckboxCellEditor( + // (Composite) tableViewer.getControl()); + // + // @Override + // protected void setValue(Object element, Object value) { + // ((ToggleObjectCoordinates) element).setAnimate(Boolean + // .valueOf(String.valueOf(value))); + // } + // + // @Override + // protected Object getValue(Object element) { + // Boolean b = ((ToggleObjectCoordinates) element) + // .getAnimate(); + // return b != null ? b : false; + // } + // + // @Override + // protected CellEditor getCellEditor(Object element) { + // return cellEditor; + // } + // + // @Override + // protected boolean canEdit(Object element) { + // return true; + // } + // + // }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + tableViewer + .setLabelProvider(new ObserverLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), + new String[] { "eval", "bcontrol", "x", + "y", "animate" }))); + + final WritableList input = new WritableList( + ((SwitchChildCoordinates) getObserver()).getToggleObjects(), + ToggleObjectCoordinates.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + ToggleObjectCoordinates toggleObj = (ToggleObjectCoordinates) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(toggleObj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( + BParser.PREDICATE_PREFIX, "", "", "", ""); + input.add(toggleObj); + } + }); + + setControl(container); + + } + } + + public WizardObserverCSwitchCoordinates(final BControl bcontrol, + final Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverCSwitchCoordinatesPage( + "ObserverCToggleCoordinatesPage")); + } + + @Override + protected Boolean prepareToFinish() { + // restorePreview(); + if (((SwitchChildCoordinates) getObserver()).getToggleObjects().size() == 0) { + setObserverDelete(true); + } else { + for (ToggleObjectCoordinates obj : ((SwitchChildCoordinates) getObserver()) + .getToggleObjects()) { + if (obj.getX().isEmpty() || obj.getY().isEmpty() + || obj.getBcontrol().isEmpty()) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The x , y and control fields must not be empty."); + return false; + } + } + } + return true; + } + + // private void restorePreview() { + // if (lastChangedControlID != null) { + // BControl bControl = getBControl().getChild(lastChangedControlID); + // if (bControl != null) { + // bControl.restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); + // bControl.restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); + // } + // } + // } + + @Override + public boolean performCancel() { + // restorePreview(); + return super.performCancel(); + } + + @Override + public Point getSize() { + return new Point(650, 500); + } + + private static class ObserverLabelProvider extends + ObservableMapLabelProvider implements ITableLabelProvider, + ITableColorProvider, ITableFontProvider { + + public ObserverLabelProvider(IObservableMap[] attributeMaps) { + super(attributeMaps); + } + + private final Color errorColor = Display.getDefault().getSystemColor( + SWT.COLOR_INFO_BACKGROUND); + + // final Font bold = JFaceResources.getFontRegistry().getBold( + // JFaceResources.BANNER_FONT); + + @Override + public String getColumnText(Object element, int columnIndex) { + if (columnIndex == 4) { + return ""; + } + return super.getColumnText(element, columnIndex); + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + // if (columnIndex == 4) { + // return CheckboxCellEditorHelper + // .getCellEditorImage(((ToggleObjectCoordinates) element) + // .getAnimate()); + // } + return null; + } + + public Color getBackground(final Object element, final int column) { + ToggleObjectCoordinates attributeObject = (ToggleObjectCoordinates) element; + if (attributeObject.hasError()) + return errorColor; + return null; + } + + public Color getForeground(final Object element, final int column) { + return null; + } + + public Font getFont(final Object element, final int column) { + // return JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY); + return null; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDragListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDragListener.java index 69554add9f7ac05047108fba97e76f06dca4915f..45b1c1addd31f3ce940c0a33f9dd31ffe5638491 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDragListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDragListener.java @@ -1,37 +1,37 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.DragSourceListener; - -public class WizardObserverDragListener implements DragSourceListener { - - private final TableViewer viewer; - - public WizardObserverDragListener(TableViewer viewer) { - this.viewer = viewer; - } - - @Override - public void dragFinished(DragSourceEvent event) { - } - - @Override - public void dragSetData(DragSourceEvent event) { - IStructuredSelection selection = (IStructuredSelection) viewer - .getSelection(); - Object[] lobjects = selection.toArray(); - event.data = lobjects; - } - - @Override - public void dragStart(DragSourceEvent event) { - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.DragSourceListener; + +public class WizardObserverDragListener implements DragSourceListener { + + private final TableViewer viewer; + + public WizardObserverDragListener(TableViewer viewer) { + this.viewer = viewer; + } + + @Override + public void dragFinished(DragSourceEvent event) { + } + + @Override + public void dragSetData(DragSourceEvent event) { + IStructuredSelection selection = (IStructuredSelection) viewer + .getSelection(); + Object[] lobjects = selection.toArray(); + event.data = lobjects; + } + + @Override + public void dragStart(DragSourceEvent event) { + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDropListener.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDropListener.java index 60ddc0b7291b730cf45440468af27c5c8fe7a74b..b9d4c121b3cf3185f749bc15d2a9444b2df990e9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDropListener.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverDropListener.java @@ -1,94 +1,94 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerDropAdapter; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; - -public class WizardObserverDropListener extends ViewerDropAdapter { - - private String observerName; - - public WizardObserverDropListener(Viewer viewer, String observerName) { - super(viewer); - this.observerName = observerName; - } - - @Override - public void drop(DropTargetEvent event) { - - Object[] sourceSetAttributeObjects = (Object[]) event.data; - Object targetSetAttributeObject = determineTarget(event); - - Object input = getViewer().getInput(); - if (input instanceof WritableList) { - - WritableList list = (WritableList) input; - - for (Object sourceObject : sourceSetAttributeObjects) { - - if (sourceObject instanceof ObserverEvalObject) { - - ObserverEvalObject sourceEvalObject = (ObserverEvalObject) sourceObject; - - if (sourceObject.getClass().equals(list.getElementType())) { - - int indexOf = list.indexOf(targetSetAttributeObject); - if (indexOf == -1) - indexOf = 0; - ObserverEvalObject newElement = sourceEvalObject; - if (!list.remove(sourceEvalObject)) { - try { - newElement = sourceEvalObject.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } - - list.add(indexOf, newElement); - - } else { - - MessageDialog.openInformation(Display.getDefault() - .getActiveShell(), - "Drag and Drop is not supported", - "It is not possible to add an item of the type " - + sourceEvalObject.getClass() - + " to the observer \"" + observerName - + "\"."); - - } - - } - - } - - } - - super.drop(event); - - } - - @Override - public boolean performDrop(Object data) { - return false; - } - - @Override - public boolean validateDrop(Object target, int operation, - TransferData transferType) { - return true; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerDropAdapter; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.TransferData; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; + +public class WizardObserverDropListener extends ViewerDropAdapter { + + private String observerName; + + public WizardObserverDropListener(Viewer viewer, String observerName) { + super(viewer); + this.observerName = observerName; + } + + @Override + public void drop(DropTargetEvent event) { + + Object[] sourceSetAttributeObjects = (Object[]) event.data; + Object targetSetAttributeObject = determineTarget(event); + + Object input = getViewer().getInput(); + if (input instanceof WritableList) { + + WritableList list = (WritableList) input; + + for (Object sourceObject : sourceSetAttributeObjects) { + + if (sourceObject instanceof ObserverEvalObject) { + + ObserverEvalObject sourceEvalObject = (ObserverEvalObject) sourceObject; + + if (sourceObject.getClass().equals(list.getElementType())) { + + int indexOf = list.indexOf(targetSetAttributeObject); + if (indexOf == -1) + indexOf = 0; + ObserverEvalObject newElement = sourceEvalObject; + if (!list.remove(sourceEvalObject)) { + try { + newElement = sourceEvalObject.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } + + list.add(indexOf, newElement); + + } else { + + MessageDialog.openInformation(Display.getDefault() + .getActiveShell(), + "Drag and Drop is not supported", + "It is not possible to add an item of the type " + + sourceEvalObject.getClass() + + " to the observer \"" + observerName + + "\"."); + + } + + } + + } + + } + + super.drop(event); + + } + + @Override + public boolean performDrop(Object data) { + return false; + } + + @Override + public boolean validateDrop(Object target, int operation, + TransferData transferType) { + return true; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverExternalObserverScript.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverExternalObserverScript.java index 9e4c0d4e57f8aaec0519b81a7afdb3c4d932616b..4d86d0aedb33631b15fb774f8c3a7bcee1e2307b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverExternalObserverScript.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverExternalObserverScript.java @@ -1,111 +1,111 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.ExternalObserverScript; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; - -public class WizardObserverExternalObserverScript extends ObserverWizard { - - private class ObserverExternalObserverScriptPage extends WizardPage { - - private Text txtScriptPath; - - protected ObserverExternalObserverScriptPage(final String pageName) { - super(pageName); - } - - public Text getTxtScriptPath() { - return txtScriptPath; - } - - public void createControl(final Composite parent) { - - final DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - container.setLayout(new GridLayout(2, false)); - - Label lb = new Label(container, SWT.NONE); - lb.setText("Script File:"); - - txtScriptPath = new Text(container, SWT.BORDER); - txtScriptPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtScriptPath.setFont(new Font(Display.getDefault(), new FontData( - "Arial", 10, SWT.NONE))); - - initBindings(dbc); - - setControl(container); - - } - - private void initBindings(DataBindingContext dbc) { - - dbc.bindValue( - SWTObservables.observeText(txtScriptPath, SWT.Modify), - BeansObservables.observeValue( - (ExternalObserverScript) getObserver(), - "scriptPath")); - - } - - - } - - public WizardObserverExternalObserverScript(BControl bcontrol, - Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverExternalObserverScriptPage( - "ObserverExternalObserverScriptPage")); - } - - @Override - protected Boolean prepareToFinish() { - - ObserverExternalObserverScriptPage page = (ObserverExternalObserverScriptPage) getPage("ObserverExternalObserverScriptPage"); - - String errorStr = ""; - - if (page.getTxtScriptPath().getText().length() == 0) - errorStr += "Please enter a path for a script file.\n"; - - if (errorStr.length() > 0) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An Error occured", errorStr); - return false; - } - - return true; - - } - - @Override - public Point getSize() { - return new Point(600, 500); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.ExternalObserverScript; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; + +public class WizardObserverExternalObserverScript extends ObserverWizard { + + private class ObserverExternalObserverScriptPage extends WizardPage { + + private Text txtScriptPath; + + protected ObserverExternalObserverScriptPage(final String pageName) { + super(pageName); + } + + public Text getTxtScriptPath() { + return txtScriptPath; + } + + public void createControl(final Composite parent) { + + final DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + container.setLayout(new GridLayout(2, false)); + + Label lb = new Label(container, SWT.NONE); + lb.setText("Script File:"); + + txtScriptPath = new Text(container, SWT.BORDER); + txtScriptPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtScriptPath.setFont(new Font(Display.getDefault(), new FontData( + "Arial", 10, SWT.NONE))); + + initBindings(dbc); + + setControl(container); + + } + + private void initBindings(DataBindingContext dbc) { + + dbc.bindValue( + SWTObservables.observeText(txtScriptPath, SWT.Modify), + BeansObservables.observeValue( + (ExternalObserverScript) getObserver(), + "scriptPath")); + + } + + + } + + public WizardObserverExternalObserverScript(BControl bcontrol, + Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverExternalObserverScriptPage( + "ObserverExternalObserverScriptPage")); + } + + @Override + protected Boolean prepareToFinish() { + + ObserverExternalObserverScriptPage page = (ObserverExternalObserverScriptPage) getPage("ObserverExternalObserverScriptPage"); + + String errorStr = ""; + + if (page.getTxtScriptPath().getText().length() == 0) + errorStr += "Please enter a path for a script file.\n"; + + if (errorStr.length() > 0) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An Error occured", errorStr); + return false; + } + + return true; + + } + + @Override + public Point getSize() { + return new Point(600, 500); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverListenOperationByPredicate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverListenOperationByPredicate.java index 5369bc5cc1f4a17b9347fd5722a6336c94c10412..6959c465082601da08adc322645988b04c9e6135 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverListenOperationByPredicate.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverListenOperationByPredicate.java @@ -1,463 +1,463 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.ComputedList; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; -import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; -import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; -import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardObserverListenOperationByPredicate extends ObserverWizard { - - // private String lastChangedAttributeID; - - private class ObserverListenOperationByPredicatePage extends - AbstractObserverWizardPage { - - private TableViewer tableViewer; - - protected ObserverListenOperationByPredicatePage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(final Composite parent) { - - super.createControl(parent); - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - setControl(container); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, PredicateOperation.class, - ((BMotionAbstractWizard) getWizard()).getName()); - // tableViewer - // .addSelectionChangedListener(new ISelectionChangedListener() { - // - // @Override - // public void selectionChanged(SelectionChangedEvent event) { - // IStructuredSelection selection = (IStructuredSelection) event - // .getSelection(); - // Object firstElement = selection.getFirstElement(); - // if (firstElement instanceof ObserverEvalObject) { - // - // ObserverEvalObject observerEvalObject = (ObserverEvalObject) - // firstElement; - // BControl control = getBControl(); - // - // if (lastChangedAttributeID != null) - // control.restoreDefaultValue(lastChangedAttributeID); - // - // PredicateOperation obj = (PredicateOperation) observerEvalObject; - // - // if (!obj.isExpressionMode()) { - // - // String attribute = obj.getAttribute(); - // Object value = obj.getValue(); - // control.setAttributeValue(attribute, value, - // true, false); - // - // lastChangedAttributeID = attribute; - // - // } - // - // } - // } - // - // }); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Operation"); - column.getColumn().setWidth(150); - column.setEditingSupport(new OperationValueEditingSupport( - tableViewer, getBControl())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(150); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "predicate", getBControl().getVisualization(), - getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Attribute"); - column.getColumn().setWidth(150); - column.setEditingSupport(new AttributeObserverValueEditing( - tableViewer)); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Value"); - column.getColumn().setWidth(175); - column.setEditingSupport(new AttributeExpressionEdittingSupport( - tableViewer, getBControl())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Expression?"); - column.getColumn().setWidth(100); - column.setEditingSupport(new IsExpressionModeEditingSupport( - tableViewer, getBControl())); - - // MathTableViewerColumn columnEval = new MathTableViewerColumn( - // tableViewer, column, dbc, "predicate"); - // columnEval.addErrorMessageListener(new IMessageListener() { - // public void setMsg(final String errorMsg) { - // if (errorMsg != null) { - // setErrorMessage(errorMsg); - // } else { - // setErrorMessage(null); - // setMessage(getObserver().getDescription()); - // } - // } - // }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - tableViewer.setLabelProvider(new ObserverLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "operationName", "predicate", "attribute", - "value", "isExpressionMode" }))); - final WritableList input = new WritableList( - ((ListenOperationByPredicate) getObserver()).getList(), - PredicateOperation.class); - tableViewer.setInput(input); - - // ColumnViewerEditorActivationStrategy activationSupport = new - // ColumnViewerEditorActivationStrategy( - // tableViewer) { - // protected boolean isEditorActivationEvent( - // ColumnViewerEditorActivationEvent event) { - // return event.eventType == - // ColumnViewerEditorActivationEvent.TRAVERSAL - // || event.eventType == - // ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION - // || event.eventType == - // ColumnViewerEditorActivationEvent.PROGRAMMATIC - // || (event.eventType == - // ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == - // KeyLookupFactory - // .getDefault().formalKeyLookup( - // IKeyLookup.ENTER_NAME)); - // } - // }; - // activationSupport.setEnableEditorActivationWithKeyboard(true); - - /* - * Without focus highlighter, keyboard events will not be delivered - * to - * ColumnViewerEditorActivationStragety#isEditorActivationEvent(...) - * (see above) - */ - // FocusCellHighlighter focusCellHighlighter = new - // FocusCellOwnerDrawHighlighter( - // tableViewer); - // TableViewerFocusCellManager focusCellManager = new - // TableViewerFocusCellManager( - // tableViewer, focusCellHighlighter); - - // TableViewerEditor.create(tableViewer, focusCellManager, - // activationSupport, ColumnViewerEditor.TABBING_VERTICAL - // | ColumnViewerEditor.KEYBOARD_ACTIVATION); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - PredicateOperation obj = (PredicateOperation) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(obj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - PredicateOperation obj = new PredicateOperation(); - input.add(obj); - tableViewer.setSelection(new StructuredSelection(obj)); - } - }); - - } - - private class AttributeObserverValueEditing extends EditingSupport { - - private ComboBoxViewerCellEditor cellEditor = null; - - public AttributeObserverValueEditing(TableViewer cv) { - super(cv); - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - - @Override - protected Object getValue(Object element) { - return ((PredicateOperation) element).getAttribute(); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) { - PredicateOperation obj = (PredicateOperation) element; - obj.setAttribute(value.toString()); - obj.setIsExpressionMode(false); - } - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - - cellEditor = new ComboBoxViewerCellEditor( - (Composite) tableViewer.getControl(), SWT.READ_ONLY); - cellEditor - .setContentProvider(new ObservableListContentProvider()); - cellEditor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return getBControl().getAttributes() - .get(element.toString()).getName(); - } - }); - cellEditor.setInput(new ComputedList() { - @Override - protected List<String> calculate() { - ArrayList<String> atrList = new ArrayList<String>(); - for (AbstractAttribute atr : getBControl() - .getAttributes().values()) { - atrList.add(atr.getID()); - } - return atrList; - } - }); - - ((CCombo) cellEditor.getControl()) - .addFocusListener(new FocusListener() { - - String oldValue; - - public void focusGained(FocusEvent e) { - oldValue = ((CCombo) cellEditor - .getControl()).getText(); - - } - - public void focusLost(FocusEvent e) { - - if (!oldValue.equals(((CCombo) cellEditor - .getControl()).getText())) { - - IStructuredSelection selection = (IStructuredSelection) getViewer() - .getSelection(); - - PredicateOperation p = (PredicateOperation) selection - .getFirstElement(); - - AbstractAttribute atr = getBControl() - .getAttributes().get( - p.getAttribute()); - - p.setValue(atr.getValue()); - tableViewer.refresh(); - - } - } - - }); - - } - return cellEditor; - } - - } - - } - - public WizardObserverListenOperationByPredicate(final BControl bcontrol, - final Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverListenOperationByPredicatePage( - "ObserverListenOperationByPredicatePage")); - } - - @Override - public boolean performCancel() { - // getBControl().restoreDefaultValue(lastChangedAttributeID); - return super.performCancel(); - } - - @Override - protected Boolean prepareToFinish() { - // getBControl().restoreDefaultValue(lastChangedAttributeID); - if (((ListenOperationByPredicate) getObserver()).getList().size() == 0) { - setObserverDelete(true); - } else { - for (PredicateOperation obj : ((ListenOperationByPredicate) getObserver()) - .getList()) { - if (obj.getOperationName().isEmpty()) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The operation field must not be empty."); - return false; - } else if (obj.getAttribute() == null) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The attribute field must not be empty."); - return false; - } - } - } - return true; - } - - @Override - public Point getSize() { - return new Point(800, 500); - } - - private class ObserverLabelProvider extends ObservableMapLabelProvider - implements ITableLabelProvider, ITableColorProvider, - ITableFontProvider { - - public ObserverLabelProvider(IObservableMap[] attributeMaps) { - super(attributeMaps); - } - - // private final Color errorColor = Display.getDefault().getSystemColor( - // SWT.COLOR_INFO_BACKGROUND); - - // final Font bold = JFaceResources.getFontRegistry().getBold( - // JFaceResources.BANNER_FONT); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 4) { - return CheckboxCellEditorHelper - .getCellEditorImage(((PredicateOperation) element) - .isExpressionMode()); - } - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - - PredicateOperation obj = (PredicateOperation) element; - - if (columnIndex == 2) { - - String atrID = obj.getAttribute(); - String atrName = ""; - if (atrID != null) { - if (atrID.length() > 0) { - atrName = getBControl().getAttributes().get(atrID) - .getName(); - } - } - return atrName; - - } - if (columnIndex == 3) { - - if (obj.getValue() != null) - return obj.getValue().toString(); - return ""; - - } - - if (columnIndex == 4) - return ""; - - return super.getColumnText(element, columnIndex); - } - - public Color getBackground(final Object element, final int column) { - return null; - } - - public Color getForeground(final Object element, final int column) { - return null; - } - - public Font getFont(final Object element, final int column) { - // return JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY); - return null; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.ComputedList; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableColorProvider; +import org.eclipse.jface.viewers.ITableFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; +import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; +import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.ListenOperationByPredicate; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; +import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardObserverListenOperationByPredicate extends ObserverWizard { + + // private String lastChangedAttributeID; + + private class ObserverListenOperationByPredicatePage extends + AbstractObserverWizardPage { + + private TableViewer tableViewer; + + protected ObserverListenOperationByPredicatePage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(final Composite parent) { + + super.createControl(parent); + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + setControl(container); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, PredicateOperation.class, + ((BMotionAbstractWizard) getWizard()).getName()); + // tableViewer + // .addSelectionChangedListener(new ISelectionChangedListener() { + // + // @Override + // public void selectionChanged(SelectionChangedEvent event) { + // IStructuredSelection selection = (IStructuredSelection) event + // .getSelection(); + // Object firstElement = selection.getFirstElement(); + // if (firstElement instanceof ObserverEvalObject) { + // + // ObserverEvalObject observerEvalObject = (ObserverEvalObject) + // firstElement; + // BControl control = getBControl(); + // + // if (lastChangedAttributeID != null) + // control.restoreDefaultValue(lastChangedAttributeID); + // + // PredicateOperation obj = (PredicateOperation) observerEvalObject; + // + // if (!obj.isExpressionMode()) { + // + // String attribute = obj.getAttribute(); + // Object value = obj.getValue(); + // control.setAttributeValue(attribute, value, + // true, false); + // + // lastChangedAttributeID = attribute; + // + // } + // + // } + // } + // + // }); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Operation"); + column.getColumn().setWidth(150); + column.setEditingSupport(new OperationValueEditingSupport( + tableViewer, getBControl())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(150); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "predicate", getBControl().getVisualization(), + getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Attribute"); + column.getColumn().setWidth(150); + column.setEditingSupport(new AttributeObserverValueEditing( + tableViewer)); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Value"); + column.getColumn().setWidth(175); + column.setEditingSupport(new AttributeExpressionEdittingSupport( + tableViewer, getBControl())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Expression?"); + column.getColumn().setWidth(100); + column.setEditingSupport(new IsExpressionModeEditingSupport( + tableViewer, getBControl())); + + // MathTableViewerColumn columnEval = new MathTableViewerColumn( + // tableViewer, column, dbc, "predicate"); + // columnEval.addErrorMessageListener(new IMessageListener() { + // public void setMsg(final String errorMsg) { + // if (errorMsg != null) { + // setErrorMessage(errorMsg); + // } else { + // setErrorMessage(null); + // setMessage(getObserver().getDescription()); + // } + // } + // }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + tableViewer.setLabelProvider(new ObserverLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "operationName", "predicate", "attribute", + "value", "isExpressionMode" }))); + final WritableList input = new WritableList( + ((ListenOperationByPredicate) getObserver()).getList(), + PredicateOperation.class); + tableViewer.setInput(input); + + // ColumnViewerEditorActivationStrategy activationSupport = new + // ColumnViewerEditorActivationStrategy( + // tableViewer) { + // protected boolean isEditorActivationEvent( + // ColumnViewerEditorActivationEvent event) { + // return event.eventType == + // ColumnViewerEditorActivationEvent.TRAVERSAL + // || event.eventType == + // ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION + // || event.eventType == + // ColumnViewerEditorActivationEvent.PROGRAMMATIC + // || (event.eventType == + // ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == + // KeyLookupFactory + // .getDefault().formalKeyLookup( + // IKeyLookup.ENTER_NAME)); + // } + // }; + // activationSupport.setEnableEditorActivationWithKeyboard(true); + + /* + * Without focus highlighter, keyboard events will not be delivered + * to + * ColumnViewerEditorActivationStragety#isEditorActivationEvent(...) + * (see above) + */ + // FocusCellHighlighter focusCellHighlighter = new + // FocusCellOwnerDrawHighlighter( + // tableViewer); + // TableViewerFocusCellManager focusCellManager = new + // TableViewerFocusCellManager( + // tableViewer, focusCellHighlighter); + + // TableViewerEditor.create(tableViewer, focusCellManager, + // activationSupport, ColumnViewerEditor.TABBING_VERTICAL + // | ColumnViewerEditor.KEYBOARD_ACTIVATION); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + PredicateOperation obj = (PredicateOperation) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(obj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + PredicateOperation obj = new PredicateOperation(); + input.add(obj); + tableViewer.setSelection(new StructuredSelection(obj)); + } + }); + + } + + private class AttributeObserverValueEditing extends EditingSupport { + + private ComboBoxViewerCellEditor cellEditor = null; + + public AttributeObserverValueEditing(TableViewer cv) { + super(cv); + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + + @Override + protected Object getValue(Object element) { + return ((PredicateOperation) element).getAttribute(); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) { + PredicateOperation obj = (PredicateOperation) element; + obj.setAttribute(value.toString()); + obj.setIsExpressionMode(false); + } + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + + cellEditor = new ComboBoxViewerCellEditor( + (Composite) tableViewer.getControl(), SWT.READ_ONLY); + cellEditor + .setContentProvider(new ObservableListContentProvider()); + cellEditor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + return getBControl().getAttributes() + .get(element.toString()).getName(); + } + }); + cellEditor.setInput(new ComputedList() { + @Override + protected List<String> calculate() { + ArrayList<String> atrList = new ArrayList<String>(); + for (AbstractAttribute atr : getBControl() + .getAttributes().values()) { + atrList.add(atr.getID()); + } + return atrList; + } + }); + + ((CCombo) cellEditor.getControl()) + .addFocusListener(new FocusListener() { + + String oldValue; + + public void focusGained(FocusEvent e) { + oldValue = ((CCombo) cellEditor + .getControl()).getText(); + + } + + public void focusLost(FocusEvent e) { + + if (!oldValue.equals(((CCombo) cellEditor + .getControl()).getText())) { + + IStructuredSelection selection = (IStructuredSelection) getViewer() + .getSelection(); + + PredicateOperation p = (PredicateOperation) selection + .getFirstElement(); + + AbstractAttribute atr = getBControl() + .getAttributes().get( + p.getAttribute()); + + p.setValue(atr.getValue()); + tableViewer.refresh(); + + } + } + + }); + + } + return cellEditor; + } + + } + + } + + public WizardObserverListenOperationByPredicate(final BControl bcontrol, + final Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverListenOperationByPredicatePage( + "ObserverListenOperationByPredicatePage")); + } + + @Override + public boolean performCancel() { + // getBControl().restoreDefaultValue(lastChangedAttributeID); + return super.performCancel(); + } + + @Override + protected Boolean prepareToFinish() { + // getBControl().restoreDefaultValue(lastChangedAttributeID); + if (((ListenOperationByPredicate) getObserver()).getList().size() == 0) { + setObserverDelete(true); + } else { + for (PredicateOperation obj : ((ListenOperationByPredicate) getObserver()) + .getList()) { + if (obj.getOperationName().isEmpty()) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The operation field must not be empty."); + return false; + } else if (obj.getAttribute() == null) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The attribute field must not be empty."); + return false; + } + } + } + return true; + } + + @Override + public Point getSize() { + return new Point(800, 500); + } + + private class ObserverLabelProvider extends ObservableMapLabelProvider + implements ITableLabelProvider, ITableColorProvider, + ITableFontProvider { + + public ObserverLabelProvider(IObservableMap[] attributeMaps) { + super(attributeMaps); + } + + // private final Color errorColor = Display.getDefault().getSystemColor( + // SWT.COLOR_INFO_BACKGROUND); + + // final Font bold = JFaceResources.getFontRegistry().getBold( + // JFaceResources.BANNER_FONT); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (columnIndex == 4) { + return CheckboxCellEditorHelper + .getCellEditorImage(((PredicateOperation) element) + .isExpressionMode()); + } + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + + PredicateOperation obj = (PredicateOperation) element; + + if (columnIndex == 2) { + + String atrID = obj.getAttribute(); + String atrName = ""; + if (atrID != null) { + if (atrID.length() > 0) { + atrName = getBControl().getAttributes().get(atrID) + .getName(); + } + } + return atrName; + + } + if (columnIndex == 3) { + + if (obj.getValue() != null) + return obj.getValue().toString(); + return ""; + + } + + if (columnIndex == 4) + return ""; + + return super.getColumnText(element, columnIndex); + } + + public Color getBackground(final Object element, final int column) { + return null; + } + + public Color getForeground(final Object element, final int column) { + return null; + } + + public Font getFont(final Object element, final int column) { + // return JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY); + return null; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSetAttribute.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSetAttribute.java index be6162187aec2fd33695432d7f0d999fc13e677c..40b7c19c652e48178b5ba59f50468c3967d285f3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSetAttribute.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSetAttribute.java @@ -1,423 +1,423 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.observer.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.ComputedList; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.be4.classicalb.core.parser.BParser; -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; -import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.SetAttribute; -import de.bmotionstudio.gef.editor.observer.SetAttributeObject; -import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardObserverSetAttribute extends ObserverWizard { - - // private String lastChangedAttributeID; - - private class WizardSetAttributePage extends AbstractObserverWizardPage { - - private WritableList input; - - private TableViewer tableViewer; - - protected WizardSetAttributePage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(Composite parent) { - - super.createControl(parent); - - DataBindingContext dbc = new DataBindingContext(); - - GridLayout gl = new GridLayout(1, true); - gl.horizontalSpacing = 0; - gl.verticalSpacing = 0; - gl.marginHeight = 0; - gl.marginWidth = 0; - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(gl); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, SetAttributeObject.class, - ((BMotionAbstractWizard) getWizard()).getName()); - - // tableViewer - // .addSelectionChangedListener(new ISelectionChangedListener() { - // - // @Override - // public void selectionChanged(SelectionChangedEvent event) { - // IStructuredSelection selection = (IStructuredSelection) event - // .getSelection(); - // Object firstElement = selection.getFirstElement(); - // if (firstElement instanceof ObserverEvalObject) { - // - // ObserverEvalObject observerEvalObject = (ObserverEvalObject) - // firstElement; - // BControl control = getBControl(); - // - // if (lastChangedAttributeID != null) - // control.restoreDefaultValue(lastChangedAttributeID); - // - // SetAttributeObject setAttributeObj = (SetAttributeObject) - // observerEvalObject; - // - // if (!setAttributeObj.isExpressionMode()) { - // - // String attribute = setAttributeObj - // .getAttribute(); - // Object value = setAttributeObj.getValue(); - // control.setAttributeValue(attribute, value, - // true, false); - // - // lastChangedAttributeID = attribute; - // - // } - // - // } - // } - // - // }); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(300); - - PredicateEditingSupport pEditingSupport = new PredicateEditingSupport( - tableViewer, dbc, "eval", getBControl().getVisualization(), - getShell()); - column.setEditingSupport(pEditingSupport); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Attribute"); - column.getColumn().setWidth(150); - column.setEditingSupport(new AttributeObserverValueEditing( - tableViewer)); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Value"); - column.getColumn().setWidth(175); - column.setEditingSupport(new AttributeExpressionEdittingSupport( - tableViewer, getBControl())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Expression?"); - column.getColumn().setWidth(100); - column.setEditingSupport(new IsExpressionModeEditingSupport( - tableViewer, getBControl())); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - - tableViewer.setLabelProvider(new ObserverLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "eval", "attribute", "value", - "isExpressionMode" }))); - input = new WritableList( - ((SetAttribute) getObserver()).getSetAttributeObjects(), - SetAttributeObject.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - MessageDialog.openInformation(getShell(), - "Please select an entry.", - "Please select an entry."); - return; - } - SetAttributeObject toggleObj = (SetAttributeObject) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(toggleObj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - SetAttributeObject toggleObj = new SetAttributeObject( - BParser.PREDICATE_PREFIX, ""); - input.add(toggleObj); - tableViewer - .setSelection(new StructuredSelection(toggleObj)); - } - }); - - setControl(container); - - } - - private class AttributeObserverValueEditing extends EditingSupport { - - private ComboBoxViewerCellEditor cellEditor = null; - - public AttributeObserverValueEditing(TableViewer cv) { - super(cv); - } - - @Override - protected boolean canEdit(Object element) { - return BMotionWizardUtil.isEditElement(getViewer()); - } - - @Override - protected Object getValue(Object element) { - return ((SetAttributeObject) element).getAttribute(); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) { - SetAttributeObject obj = (SetAttributeObject) element; - obj.setAttribute(value.toString()); - obj.setIsExpressionMode(false); - } - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - - cellEditor = new ComboBoxViewerCellEditor( - (Composite) tableViewer.getControl(), SWT.READ_ONLY); - cellEditor - .setContentProvider(new ObservableListContentProvider()); - cellEditor.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return getBControl().getAttributes() - .get(element.toString()).getName(); - } - }); - cellEditor.setInput(new ComputedList() { - @Override - protected List<String> calculate() { - ArrayList<String> atrList = new ArrayList<String>(); - for (AbstractAttribute atr : getBControl() - .getAttributes().values()) { - atrList.add(atr.getID()); - } - return atrList; - } - }); - - ((CCombo) cellEditor.getControl()) - .addFocusListener(new FocusListener() { - - String oldValue; - - public void focusGained(FocusEvent e) { - oldValue = ((CCombo) cellEditor - .getControl()).getText(); - - } - - public void focusLost(FocusEvent e) { - - if (!oldValue.equals(((CCombo) cellEditor - .getControl()).getText())) { - - IStructuredSelection selection = (IStructuredSelection) getViewer() - .getSelection(); - - SetAttributeObject p = (SetAttributeObject) selection - .getFirstElement(); - - AbstractAttribute atr = getBControl() - .getAttributes().get( - p.getAttribute()); - - p.setValue(atr.getValue()); - tableViewer.refresh(); - - } - } - - }); - - } - return cellEditor; - } - - } - - } - - public WizardObserverSetAttribute(BControl control, Observer observer) { - super(control, observer); - addPage(new WizardSetAttributePage("WizardSetAttributePage")); - } - - @Override - public Point getSize() { - return new Point(800, 500); - } - - @Override - protected Boolean prepareToFinish() { - // getBControl().restoreDefaultValue(lastChangedAttributeID); - if (((SetAttribute) getObserver()).getSetAttributeObjects().size() == 0) { - setObserverDelete(true); - } else { - for (SetAttributeObject obj : ((SetAttribute) getObserver()) - .getSetAttributeObjects()) { - if (obj.getAttribute() == null) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The attribute field must not be empty."); - return false; - } - } - } - return true; - } - - @Override - public boolean performCancel() { - // getBControl().restoreDefaultValue(lastChangedAttributeID); - return super.performCancel(); - } - - private class ObserverLabelProvider extends ObservableMapLabelProvider - implements ITableLabelProvider, ITableColorProvider, - ITableFontProvider { - - public ObserverLabelProvider(IObservableMap[] attributeMaps) { - super(attributeMaps); - } - - private final Color errorColor = Display.getDefault().getSystemColor( - SWT.COLOR_INFO_BACKGROUND); - - // final Font bold = JFaceResources.getFontRegistry().getBold( - // JFaceResources.BANNER_FONT); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 3) { - return CheckboxCellEditorHelper - .getCellEditorImage(((SetAttributeObject) element) - .isExpressionMode()); - } - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - - SetAttributeObject attributeObject = (SetAttributeObject) element; - - if (columnIndex == 1) { - - String atrID = attributeObject.getAttribute(); - String atrName = ""; - if (atrID != null) { - if (atrID.length() > 0) { - AbstractAttribute atr = getBControl().getAttributes() - .get(atrID); - if (atr != null) - atrName = atr.getName(); - } - } - return atrName; - - } - if (columnIndex == 2) { - - if (attributeObject.getValue() != null) - return attributeObject.getValue().toString(); - return ""; - - } - - if (columnIndex == 3) - return ""; - - return super.getColumnText(element, columnIndex); - } - - public Color getBackground(final Object element, final int column) { - SetAttributeObject attributeObject = (SetAttributeObject) element; - if (attributeObject.hasError()) - return errorColor; - return null; - } - - public Color getForeground(final Object element, final int column) { - return null; - } - - public Font getFont(final Object element, final int column) { - // return JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY); - return null; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.observer.wizard; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.ComputedList; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableColorProvider; +import org.eclipse.jface.viewers.ITableFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +import de.be4.classicalb.core.parser.BParser; +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; +import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.SetAttribute; +import de.bmotionstudio.gef.editor.observer.SetAttributeObject; +import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardObserverSetAttribute extends ObserverWizard { + + // private String lastChangedAttributeID; + + private class WizardSetAttributePage extends AbstractObserverWizardPage { + + private WritableList input; + + private TableViewer tableViewer; + + protected WizardSetAttributePage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(Composite parent) { + + super.createControl(parent); + + DataBindingContext dbc = new DataBindingContext(); + + GridLayout gl = new GridLayout(1, true); + gl.horizontalSpacing = 0; + gl.verticalSpacing = 0; + gl.marginHeight = 0; + gl.marginWidth = 0; + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(gl); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, SetAttributeObject.class, + ((BMotionAbstractWizard) getWizard()).getName()); + + // tableViewer + // .addSelectionChangedListener(new ISelectionChangedListener() { + // + // @Override + // public void selectionChanged(SelectionChangedEvent event) { + // IStructuredSelection selection = (IStructuredSelection) event + // .getSelection(); + // Object firstElement = selection.getFirstElement(); + // if (firstElement instanceof ObserverEvalObject) { + // + // ObserverEvalObject observerEvalObject = (ObserverEvalObject) + // firstElement; + // BControl control = getBControl(); + // + // if (lastChangedAttributeID != null) + // control.restoreDefaultValue(lastChangedAttributeID); + // + // SetAttributeObject setAttributeObj = (SetAttributeObject) + // observerEvalObject; + // + // if (!setAttributeObj.isExpressionMode()) { + // + // String attribute = setAttributeObj + // .getAttribute(); + // Object value = setAttributeObj.getValue(); + // control.setAttributeValue(attribute, value, + // true, false); + // + // lastChangedAttributeID = attribute; + // + // } + // + // } + // } + // + // }); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(300); + + PredicateEditingSupport pEditingSupport = new PredicateEditingSupport( + tableViewer, dbc, "eval", getBControl().getVisualization(), + getShell()); + column.setEditingSupport(pEditingSupport); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Attribute"); + column.getColumn().setWidth(150); + column.setEditingSupport(new AttributeObserverValueEditing( + tableViewer)); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Value"); + column.getColumn().setWidth(175); + column.setEditingSupport(new AttributeExpressionEdittingSupport( + tableViewer, getBControl())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Expression?"); + column.getColumn().setWidth(100); + column.setEditingSupport(new IsExpressionModeEditingSupport( + tableViewer, getBControl())); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + + tableViewer.setLabelProvider(new ObserverLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "eval", "attribute", "value", + "isExpressionMode" }))); + input = new WritableList( + ((SetAttribute) getObserver()).getSetAttributeObjects(), + SetAttributeObject.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + MessageDialog.openInformation(getShell(), + "Please select an entry.", + "Please select an entry."); + return; + } + SetAttributeObject toggleObj = (SetAttributeObject) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(toggleObj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + SetAttributeObject toggleObj = new SetAttributeObject( + BParser.PREDICATE_PREFIX, ""); + input.add(toggleObj); + tableViewer + .setSelection(new StructuredSelection(toggleObj)); + } + }); + + setControl(container); + + } + + private class AttributeObserverValueEditing extends EditingSupport { + + private ComboBoxViewerCellEditor cellEditor = null; + + public AttributeObserverValueEditing(TableViewer cv) { + super(cv); + } + + @Override + protected boolean canEdit(Object element) { + return BMotionWizardUtil.isEditElement(getViewer()); + } + + @Override + protected Object getValue(Object element) { + return ((SetAttributeObject) element).getAttribute(); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) { + SetAttributeObject obj = (SetAttributeObject) element; + obj.setAttribute(value.toString()); + obj.setIsExpressionMode(false); + } + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + + cellEditor = new ComboBoxViewerCellEditor( + (Composite) tableViewer.getControl(), SWT.READ_ONLY); + cellEditor + .setContentProvider(new ObservableListContentProvider()); + cellEditor.setLabelProvider(new LabelProvider() { + public String getText(Object element) { + return getBControl().getAttributes() + .get(element.toString()).getName(); + } + }); + cellEditor.setInput(new ComputedList() { + @Override + protected List<String> calculate() { + ArrayList<String> atrList = new ArrayList<String>(); + for (AbstractAttribute atr : getBControl() + .getAttributes().values()) { + atrList.add(atr.getID()); + } + return atrList; + } + }); + + ((CCombo) cellEditor.getControl()) + .addFocusListener(new FocusListener() { + + String oldValue; + + public void focusGained(FocusEvent e) { + oldValue = ((CCombo) cellEditor + .getControl()).getText(); + + } + + public void focusLost(FocusEvent e) { + + if (!oldValue.equals(((CCombo) cellEditor + .getControl()).getText())) { + + IStructuredSelection selection = (IStructuredSelection) getViewer() + .getSelection(); + + SetAttributeObject p = (SetAttributeObject) selection + .getFirstElement(); + + AbstractAttribute atr = getBControl() + .getAttributes().get( + p.getAttribute()); + + p.setValue(atr.getValue()); + tableViewer.refresh(); + + } + } + + }); + + } + return cellEditor; + } + + } + + } + + public WizardObserverSetAttribute(BControl control, Observer observer) { + super(control, observer); + addPage(new WizardSetAttributePage("WizardSetAttributePage")); + } + + @Override + public Point getSize() { + return new Point(800, 500); + } + + @Override + protected Boolean prepareToFinish() { + // getBControl().restoreDefaultValue(lastChangedAttributeID); + if (((SetAttribute) getObserver()).getSetAttributeObjects().size() == 0) { + setObserverDelete(true); + } else { + for (SetAttributeObject obj : ((SetAttribute) getObserver()) + .getSetAttributeObjects()) { + if (obj.getAttribute() == null) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The attribute field must not be empty."); + return false; + } + } + } + return true; + } + + @Override + public boolean performCancel() { + // getBControl().restoreDefaultValue(lastChangedAttributeID); + return super.performCancel(); + } + + private class ObserverLabelProvider extends ObservableMapLabelProvider + implements ITableLabelProvider, ITableColorProvider, + ITableFontProvider { + + public ObserverLabelProvider(IObservableMap[] attributeMaps) { + super(attributeMaps); + } + + private final Color errorColor = Display.getDefault().getSystemColor( + SWT.COLOR_INFO_BACKGROUND); + + // final Font bold = JFaceResources.getFontRegistry().getBold( + // JFaceResources.BANNER_FONT); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (columnIndex == 3) { + return CheckboxCellEditorHelper + .getCellEditorImage(((SetAttributeObject) element) + .isExpressionMode()); + } + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + + SetAttributeObject attributeObject = (SetAttributeObject) element; + + if (columnIndex == 1) { + + String atrID = attributeObject.getAttribute(); + String atrName = ""; + if (atrID != null) { + if (atrID.length() > 0) { + AbstractAttribute atr = getBControl().getAttributes() + .get(atrID); + if (atr != null) + atrName = atr.getName(); + } + } + return atrName; + + } + if (columnIndex == 2) { + + if (attributeObject.getValue() != null) + return attributeObject.getValue().toString(); + return ""; + + } + + if (columnIndex == 3) + return ""; + + return super.getColumnText(element, columnIndex); + } + + public Color getBackground(final Object element, final int column) { + SetAttributeObject attributeObject = (SetAttributeObject) element; + if (attributeObject.hasError()) + return errorColor; + return null; + } + + public Color getForeground(final Object element, final int column) { + return null; + } + + public Font getFont(final Object element, final int column) { + // return JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY); + return null; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSimpleValueDisplay.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSimpleValueDisplay.java index b1eabadb4acf3c0ba358ae9242d2bbc051975072..6a4ee8d984f6008fc41dbd7381abba7e57d24e02 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSimpleValueDisplay.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSimpleValueDisplay.java @@ -1,148 +1,148 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.SimpleValueDisplay; - -public class WizardObserverSimpleValueDisplay extends ObserverWizard { - - private class ObserverSimpleValueDisplayPage extends - AbstractObserverWizardPage { - - private Text txtReplacementString; - private Text txtExpression; - private Text txtPredicate; - - public Text getTxtExpression() { - return txtExpression; - } - - protected ObserverSimpleValueDisplayPage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(final Composite parent) { - - super.createControl(parent); - - final DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - container.setLayout(new GridLayout(2, false)); - - Label lb = new Label(container, SWT.NONE); - lb.setText("Guard:"); - - txtPredicate = new Text(container, SWT.BORDER); - txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtPredicate.setFont(new Font(Display.getDefault(), new FontData( - "Arial", 10, SWT.NONE))); - - lb = new Label(container, SWT.NONE); - lb.setText("Expression:"); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - txtExpression = new Text(container, SWT.BORDER | SWT.MULTI - | SWT.WRAP); - txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); - // txtExpression.setFont(JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY)); - - lb = new Label(container, SWT.NONE); - lb.setText("Replacement String*:"); - - txtReplacementString = new Text(container, SWT.BORDER); - txtReplacementString.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL)); - txtReplacementString.setFont(new Font(Display.getDefault(), - new FontData("Arial", 10, SWT.NONE))); - - lb = new Label(container, SWT.NONE); - lb.setLayoutData(new GridData(0,0,true,true,2,1)); - lb.setText("*String that will be replaced with the result of the expression."); - - initBindings(dbc); - - setControl(container); - - } - - private void initBindings(DataBindingContext dbc) { - - dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), - BeansObservables.observeValue( - (SimpleValueDisplay) getObserver(), "predicate")); - - dbc.bindValue( - SWTObservables.observeText(txtExpression, SWT.Modify), - BeansObservables.observeValue( - (SimpleValueDisplay) getObserver(), "eval")); - - dbc.bindValue(SWTObservables.observeText(txtReplacementString, - SWT.Modify), BeansObservables.observeValue( - (SimpleValueDisplay) getObserver(), "replacementString")); - - } - - } - - public WizardObserverSimpleValueDisplay(BControl bcontrol, - Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverSimpleValueDisplayPage( - "ObserverSimpleValueDisplayPage")); - } - - @Override - protected Boolean prepareToFinish() { - - ObserverSimpleValueDisplayPage page = (ObserverSimpleValueDisplayPage) getPage("ObserverSimpleValueDisplayPage"); - - String errorStr = ""; - - if (page.getTxtExpression().getText().length() == 0) - errorStr += "Please enter an expression.\n"; - - if (page.getErrorMessage() != null) - errorStr += "Please check the syntax/parser error.\n"; - - if (errorStr.length() > 0) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An Error occured", errorStr); - return false; - } - - return true; - - } - - @Override - public Point getSize() { - return new Point(600, 500); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.SimpleValueDisplay; + +public class WizardObserverSimpleValueDisplay extends ObserverWizard { + + private class ObserverSimpleValueDisplayPage extends + AbstractObserverWizardPage { + + private Text txtReplacementString; + private Text txtExpression; + private Text txtPredicate; + + public Text getTxtExpression() { + return txtExpression; + } + + protected ObserverSimpleValueDisplayPage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(final Composite parent) { + + super.createControl(parent); + + final DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + container.setLayout(new GridLayout(2, false)); + + Label lb = new Label(container, SWT.NONE); + lb.setText("Guard:"); + + txtPredicate = new Text(container, SWT.BORDER); + txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtPredicate.setFont(new Font(Display.getDefault(), new FontData( + "Arial", 10, SWT.NONE))); + + lb = new Label(container, SWT.NONE); + lb.setText("Expression:"); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + txtExpression = new Text(container, SWT.BORDER | SWT.MULTI + | SWT.WRAP); + txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); + // txtExpression.setFont(JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY)); + + lb = new Label(container, SWT.NONE); + lb.setText("Replacement String*:"); + + txtReplacementString = new Text(container, SWT.BORDER); + txtReplacementString.setLayoutData(new GridData( + GridData.FILL_HORIZONTAL)); + txtReplacementString.setFont(new Font(Display.getDefault(), + new FontData("Arial", 10, SWT.NONE))); + + lb = new Label(container, SWT.NONE); + lb.setLayoutData(new GridData(0,0,true,true,2,1)); + lb.setText("*String that will be replaced with the result of the expression."); + + initBindings(dbc); + + setControl(container); + + } + + private void initBindings(DataBindingContext dbc) { + + dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), + BeansObservables.observeValue( + (SimpleValueDisplay) getObserver(), "predicate")); + + dbc.bindValue( + SWTObservables.observeText(txtExpression, SWT.Modify), + BeansObservables.observeValue( + (SimpleValueDisplay) getObserver(), "eval")); + + dbc.bindValue(SWTObservables.observeText(txtReplacementString, + SWT.Modify), BeansObservables.observeValue( + (SimpleValueDisplay) getObserver(), "replacementString")); + + } + + } + + public WizardObserverSimpleValueDisplay(BControl bcontrol, + Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverSimpleValueDisplayPage( + "ObserverSimpleValueDisplayPage")); + } + + @Override + protected Boolean prepareToFinish() { + + ObserverSimpleValueDisplayPage page = (ObserverSimpleValueDisplayPage) getPage("ObserverSimpleValueDisplayPage"); + + String errorStr = ""; + + if (page.getTxtExpression().getText().length() == 0) + errorStr += "Please enter an expression.\n"; + + if (page.getErrorMessage() != null) + errorStr += "Please check the syntax/parser error.\n"; + + if (errorStr.length() > 0) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An Error occured", errorStr); + return false; + } + + return true; + + } + + @Override + public Point getSize() { + return new Point(600, 500); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java index 88248dcb8a2870351498906122aa15234c3fad4b..0b4bb1df49b9a6681dd1652c26cc7683163aaaae 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java @@ -1,299 +1,299 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.be4.classicalb.core.parser.BParser; -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.edit.TextEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.SwitchCoordinates; -import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardObserverSwitchCoordinates extends ObserverWizard { - - private class ObserverToggleCoordinatesPage extends - AbstractObserverWizardPage { - - private TableViewer tableViewer; - - protected ObserverToggleCoordinatesPage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(Composite parent) { - - super.createControl(parent); - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, ToggleObjectCoordinates.class, - ((BMotionAbstractWizard) getWizard()).getName()); - - // tableViewer - // .addSelectionChangedListener(new ISelectionChangedListener() { - // - // @Override - // public void selectionChanged(SelectionChangedEvent event) { - // IStructuredSelection selection = (IStructuredSelection) event - // .getSelection(); - // Object firstElement = selection.getFirstElement(); - // if (firstElement instanceof ObserverEvalObject) { - // ObserverEvalObject observerEvalObject = (ObserverEvalObject) - // firstElement; - // if (!observerEvalObject.isExpressionMode()) { - // BControl control = getBControl(); - // ToggleObjectCoordinates toggleObjectCoordinates = - // (ToggleObjectCoordinates) observerEvalObject; - // String attributeX = AttributeConstants.ATTRIBUTE_X; - // String attributeY = AttributeConstants.ATTRIBUTE_Y; - // String x = toggleObjectCoordinates.getX(); - // String y = toggleObjectCoordinates.getY(); - // control.setAttributeValue(attributeX, x, - // true, false); - // control.setAttributeValue(attributeY, y, - // true, false); - // } - // } - // } - // - // }); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(200); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "eval", getBControl().getVisualization(), getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("X"); - column.getColumn().setWidth(150); - column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, - "x")); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Y"); - column.getColumn().setWidth(150); - column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, - "y")); - - // column = new TableViewerColumn(tableViewer, SWT.NONE); - // column.getColumn().setText("Animate?"); - // column.getColumn().setWidth(75); - // column.setEditingSupport(new EditingSupport(tableViewer) { - // - // private CellEditor cellEditor = new CheckboxCellEditor( - // (Composite) tableViewer.getControl()); - // - // @Override - // protected void setValue(Object element, Object value) { - // ((ToggleObjectCoordinates) element).setAnimate(Boolean - // .valueOf(String.valueOf(value))); - // } - // - // @Override - // protected Object getValue(Object element) { - // Boolean b = ((ToggleObjectCoordinates) element) - // .getAnimate(); - // return b != null ? b : false; - // } - // - // @Override - // protected CellEditor getCellEditor(Object element) { - // return cellEditor; - // } - // - // @Override - // protected boolean canEdit(Object element) { - // return true; - // } - // - // }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - tableViewer.setLabelProvider(new ObserverLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "eval", "x", "y" }))); - - final WritableList input = new WritableList( - ((SwitchCoordinates) getObserver()).getToggleObjects(), - ToggleObjectCoordinates.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - ToggleObjectCoordinates toggleObj = (ToggleObjectCoordinates) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(toggleObj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( - BParser.PREDICATE_PREFIX, "", String - .valueOf(getBControl().getLayout().x), - String.valueOf(getBControl().getLayout().y), ""); - input.add(toggleObj); - tableViewer - .setSelection(new StructuredSelection(toggleObj)); - } - }); - - setControl(container); - - } - } - - public WizardObserverSwitchCoordinates(final BControl bcontrol, - final Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverToggleCoordinatesPage( - "ObserverToggleCoordinatesPage")); - } - - @Override - protected Boolean prepareToFinish() { - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); - if (((SwitchCoordinates) getObserver()).getToggleObjects().size() == 0) { - setObserverDelete(true); - } else { - for (ToggleObjectCoordinates obj : ((SwitchCoordinates) getObserver()) - .getToggleObjects()) { - if (obj.getX().isEmpty() || obj.getY().isEmpty()) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The x and y fields must not be empty."); - return false; - } - } - } - return true; - } - - @Override - public boolean performCancel() { - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); - return super.performCancel(); - } - - @Override - public Point getSize() { - return new Point(650, 500); - } - - private static class ObserverLabelProvider extends - ObservableMapLabelProvider implements ITableLabelProvider, - ITableColorProvider, ITableFontProvider { - - public ObserverLabelProvider(IObservableMap[] attributeMaps) { - super(attributeMaps); - } - - private final Color errorColor = Display.getDefault().getSystemColor( - SWT.COLOR_INFO_BACKGROUND); - - // final Font bold = JFaceResources.getFontRegistry().getBold( - // JFaceResources.BANNER_FONT); - - @Override - public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 3) { - return ""; - } - return super.getColumnText(element, columnIndex); - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - // if (columnIndex == 3) { - // return CheckboxCellEditorHelper - // .getCellEditorImage(((ToggleObjectCoordinates) element) - // .getAnimate()); - // } - return null; - } - - public Color getBackground(final Object element, final int column) { - ToggleObjectCoordinates attributeObject = (ToggleObjectCoordinates) element; - if (attributeObject.hasError()) - return errorColor; - return null; - } - - public Color getForeground(final Object element, final int column) { - return null; - } - - public Font getFont(final Object element, final int column) { - // return JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY); - return null; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableColorProvider; +import org.eclipse.jface.viewers.ITableFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +import de.be4.classicalb.core.parser.BParser; +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.edit.TextEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.SwitchCoordinates; +import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardObserverSwitchCoordinates extends ObserverWizard { + + private class ObserverToggleCoordinatesPage extends + AbstractObserverWizardPage { + + private TableViewer tableViewer; + + protected ObserverToggleCoordinatesPage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(Composite parent) { + + super.createControl(parent); + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, ToggleObjectCoordinates.class, + ((BMotionAbstractWizard) getWizard()).getName()); + + // tableViewer + // .addSelectionChangedListener(new ISelectionChangedListener() { + // + // @Override + // public void selectionChanged(SelectionChangedEvent event) { + // IStructuredSelection selection = (IStructuredSelection) event + // .getSelection(); + // Object firstElement = selection.getFirstElement(); + // if (firstElement instanceof ObserverEvalObject) { + // ObserverEvalObject observerEvalObject = (ObserverEvalObject) + // firstElement; + // if (!observerEvalObject.isExpressionMode()) { + // BControl control = getBControl(); + // ToggleObjectCoordinates toggleObjectCoordinates = + // (ToggleObjectCoordinates) observerEvalObject; + // String attributeX = AttributeConstants.ATTRIBUTE_X; + // String attributeY = AttributeConstants.ATTRIBUTE_Y; + // String x = toggleObjectCoordinates.getX(); + // String y = toggleObjectCoordinates.getY(); + // control.setAttributeValue(attributeX, x, + // true, false); + // control.setAttributeValue(attributeY, y, + // true, false); + // } + // } + // } + // + // }); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(200); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "eval", getBControl().getVisualization(), getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("X"); + column.getColumn().setWidth(150); + column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, + "x")); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Y"); + column.getColumn().setWidth(150); + column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, + "y")); + + // column = new TableViewerColumn(tableViewer, SWT.NONE); + // column.getColumn().setText("Animate?"); + // column.getColumn().setWidth(75); + // column.setEditingSupport(new EditingSupport(tableViewer) { + // + // private CellEditor cellEditor = new CheckboxCellEditor( + // (Composite) tableViewer.getControl()); + // + // @Override + // protected void setValue(Object element, Object value) { + // ((ToggleObjectCoordinates) element).setAnimate(Boolean + // .valueOf(String.valueOf(value))); + // } + // + // @Override + // protected Object getValue(Object element) { + // Boolean b = ((ToggleObjectCoordinates) element) + // .getAnimate(); + // return b != null ? b : false; + // } + // + // @Override + // protected CellEditor getCellEditor(Object element) { + // return cellEditor; + // } + // + // @Override + // protected boolean canEdit(Object element) { + // return true; + // } + // + // }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + tableViewer.setLabelProvider(new ObserverLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "eval", "x", "y" }))); + + final WritableList input = new WritableList( + ((SwitchCoordinates) getObserver()).getToggleObjects(), + ToggleObjectCoordinates.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + ToggleObjectCoordinates toggleObj = (ToggleObjectCoordinates) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(toggleObj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( + BParser.PREDICATE_PREFIX, "", String + .valueOf(getBControl().getLayout().x), + String.valueOf(getBControl().getLayout().y), ""); + input.add(toggleObj); + tableViewer + .setSelection(new StructuredSelection(toggleObj)); + } + }); + + setControl(container); + + } + } + + public WizardObserverSwitchCoordinates(final BControl bcontrol, + final Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverToggleCoordinatesPage( + "ObserverToggleCoordinatesPage")); + } + + @Override + protected Boolean prepareToFinish() { + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); + if (((SwitchCoordinates) getObserver()).getToggleObjects().size() == 0) { + setObserverDelete(true); + } else { + for (ToggleObjectCoordinates obj : ((SwitchCoordinates) getObserver()) + .getToggleObjects()) { + if (obj.getX().isEmpty() || obj.getY().isEmpty()) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The x and y fields must not be empty."); + return false; + } + } + } + return true; + } + + @Override + public boolean performCancel() { + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_X); + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_Y); + return super.performCancel(); + } + + @Override + public Point getSize() { + return new Point(650, 500); + } + + private static class ObserverLabelProvider extends + ObservableMapLabelProvider implements ITableLabelProvider, + ITableColorProvider, ITableFontProvider { + + public ObserverLabelProvider(IObservableMap[] attributeMaps) { + super(attributeMaps); + } + + private final Color errorColor = Display.getDefault().getSystemColor( + SWT.COLOR_INFO_BACKGROUND); + + // final Font bold = JFaceResources.getFontRegistry().getBold( + // JFaceResources.BANNER_FONT); + + @Override + public String getColumnText(Object element, int columnIndex) { + if (columnIndex == 3) { + return ""; + } + return super.getColumnText(element, columnIndex); + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + // if (columnIndex == 3) { + // return CheckboxCellEditorHelper + // .getCellEditorImage(((ToggleObjectCoordinates) element) + // .getAnimate()); + // } + return null; + } + + public Color getBackground(final Object element, final int column) { + ToggleObjectCoordinates attributeObject = (ToggleObjectCoordinates) element; + if (attributeObject.hasError()) + return errorColor; + return null; + } + + public Color getForeground(final Object element, final int column) { + return null; + } + + public Font getFont(final Object element, final int column) { + // return JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY); + return null; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchImage.java index 9c15caea177633be286db950970287681dfcd9d3..c95305337e7995c2ec2570e8077ad7bfe4c14f9e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchImage.java @@ -1,286 +1,286 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.be4.classicalb.core.parser.BParser; -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; -import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.SwitchImage; -import de.bmotionstudio.gef.editor.observer.ToggleObjectImage; -import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardObserverSwitchImage extends ObserverWizard { - - private class ObserverSwitchImagePage extends AbstractObserverWizardPage { - - private TableViewer tableViewer; - - protected ObserverSwitchImagePage(final String pageName) { - super(pageName, getObserver()); - } - - public void createControl(final Composite parent) { - - super.createControl(parent); - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, ToggleObjectImage.class, - ((BMotionAbstractWizard) getWizard()).getName()); - // tableViewer - // .addSelectionChangedListener(new ISelectionChangedListener() { - // - // @Override - // public void selectionChanged(SelectionChangedEvent event) { - // IStructuredSelection selection = (IStructuredSelection) event - // .getSelection(); - // Object firstElement = selection.getFirstElement(); - // if (firstElement instanceof ObserverEvalObject) { - // ObserverEvalObject observerEvalObject = (ObserverEvalObject) - // firstElement; - // if (!observerEvalObject.isExpressionMode()) { - // BControl control = getBControl(); - // ToggleObjectImage toggleObjImage = (ToggleObjectImage) - // observerEvalObject; - // String attribute = AttributeConstants.ATTRIBUTE_IMAGE; - // String image = toggleObjImage.getImage(); - // control.setAttributeValue(attribute, image, - // true, false); - // } - // } - // } - // - // }); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(300); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "eval", getBControl().getVisualization(), getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Image"); - column.getColumn().setWidth(180); - column.setEditingSupport(new AttributeExpressionEdittingSupport( - tableViewer, getBControl(), - AttributeConstants.ATTRIBUTE_IMAGE) { - - @Override - protected Object getValue(final Object element) { - ToggleObjectImage evalObject = (ToggleObjectImage) element; - return evalObject.getImage(); - } - - @Override - protected void setValue(final Object element, final Object value) { - if (value == null) - return; - ((ToggleObjectImage) element).setImage(value.toString()); - } - - }); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Expression?"); - column.getColumn().setWidth(100); - column.setEditingSupport(new IsExpressionModeEditingSupport( - tableViewer, getBControl()) { - - @Override - protected void setValue(final Object element, final Object value) { - Boolean bol = Boolean.valueOf(String.valueOf(value)); - ToggleObjectImage obj = (ToggleObjectImage) element; - obj.setIsExpressionMode(bol); - } - - }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - - tableViewer.setLabelProvider(new ObserverLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "eval", "image", "isExpressionMode" }))); - final WritableList input = new WritableList( - ((SwitchImage) getObserver()).getToggleObjects(), - ToggleObjectImage.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - ToggleObjectImage toggleObj = (ToggleObjectImage) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(toggleObj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - ToggleObjectImage toggleObj = new ToggleObjectImage( - BParser.PREDICATE_PREFIX, "", ""); - input.add(toggleObj); - tableViewer - .setSelection(new StructuredSelection(toggleObj)); - } - }); - - setControl(container); - - } - - } - - public WizardObserverSwitchImage(final BControl bcontrol, - final Observer bobserver) { - super(bcontrol, bobserver); - addPage(new ObserverSwitchImagePage("ObserverToggleImagePage")); - } - - @Override - protected Boolean prepareToFinish() { - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); - if (((SwitchImage) getObserver()).getToggleObjects().size() == 0) { - setObserverDelete(true); - } else { - for (ToggleObjectImage obj : ((SwitchImage) getObserver()) - .getToggleObjects()) { - if (obj.getImage().isEmpty()) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The image field must not be empty."); - return false; - } - } - } - return true; - } - - @Override - public boolean performCancel() { - // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); - return super.performCancel(); - } - - @Override - public Point getSize() { - return new Point(650, 500); - } - - private static class ObserverLabelProvider extends - ObservableMapLabelProvider implements ITableLabelProvider, - ITableColorProvider, ITableFontProvider { - - public ObserverLabelProvider(final IObservableMap[] attributeMaps) { - super(attributeMaps); - } - - private final Color errorColor = Display.getDefault().getSystemColor( - SWT.COLOR_INFO_BACKGROUND); - - // final Font bold = JFaceResources.getFontRegistry().getBold( - // JFaceResources.BANNER_FONT); - - @Override - public Image getColumnImage(final Object element, final int columnIndex) { - if (columnIndex == 2) { - return CheckboxCellEditorHelper - .getCellEditorImage(((ToggleObjectImage) element) - .isExpressionMode()); - } - return null; - } - - @Override - public String getColumnText(final Object element, final int columnIndex) { - - if (columnIndex == 2) - return ""; - - return super.getColumnText(element, columnIndex); - - } - - public Color getBackground(final Object element, final int column) { - ToggleObjectImage attributeObject = (ToggleObjectImage) element; - if (attributeObject.hasError()) - return errorColor; - return null; - } - - public Color getForeground(final Object element, final int column) { - return null; - } - - public Font getFont(final Object element, final int column) { - // return JFaceResources.getFontRegistry().get( - // BMotionStudioConstants.RODIN_FONT_KEY); - return null; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableColorProvider; +import org.eclipse.jface.viewers.ITableFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +import de.be4.classicalb.core.parser.BParser; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.AttributeExpressionEdittingSupport; +import de.bmotionstudio.gef.editor.edit.IsExpressionModeEditingSupport; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.SwitchImage; +import de.bmotionstudio.gef.editor.observer.ToggleObjectImage; +import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardObserverSwitchImage extends ObserverWizard { + + private class ObserverSwitchImagePage extends AbstractObserverWizardPage { + + private TableViewer tableViewer; + + protected ObserverSwitchImagePage(final String pageName) { + super(pageName, getObserver()); + } + + public void createControl(final Composite parent) { + + super.createControl(parent); + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, ToggleObjectImage.class, + ((BMotionAbstractWizard) getWizard()).getName()); + // tableViewer + // .addSelectionChangedListener(new ISelectionChangedListener() { + // + // @Override + // public void selectionChanged(SelectionChangedEvent event) { + // IStructuredSelection selection = (IStructuredSelection) event + // .getSelection(); + // Object firstElement = selection.getFirstElement(); + // if (firstElement instanceof ObserverEvalObject) { + // ObserverEvalObject observerEvalObject = (ObserverEvalObject) + // firstElement; + // if (!observerEvalObject.isExpressionMode()) { + // BControl control = getBControl(); + // ToggleObjectImage toggleObjImage = (ToggleObjectImage) + // observerEvalObject; + // String attribute = AttributeConstants.ATTRIBUTE_IMAGE; + // String image = toggleObjImage.getImage(); + // control.setAttributeValue(attribute, image, + // true, false); + // } + // } + // } + // + // }); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(300); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "eval", getBControl().getVisualization(), getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Image"); + column.getColumn().setWidth(180); + column.setEditingSupport(new AttributeExpressionEdittingSupport( + tableViewer, getBControl(), + AttributeConstants.ATTRIBUTE_IMAGE) { + + @Override + protected Object getValue(final Object element) { + ToggleObjectImage evalObject = (ToggleObjectImage) element; + return evalObject.getImage(); + } + + @Override + protected void setValue(final Object element, final Object value) { + if (value == null) + return; + ((ToggleObjectImage) element).setImage(value.toString()); + } + + }); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Expression?"); + column.getColumn().setWidth(100); + column.setEditingSupport(new IsExpressionModeEditingSupport( + tableViewer, getBControl()) { + + @Override + protected void setValue(final Object element, final Object value) { + Boolean bol = Boolean.valueOf(String.valueOf(value)); + ToggleObjectImage obj = (ToggleObjectImage) element; + obj.setIsExpressionMode(bol); + } + + }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + + tableViewer.setLabelProvider(new ObserverLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "eval", "image", "isExpressionMode" }))); + final WritableList input = new WritableList( + ((SwitchImage) getObserver()).getToggleObjects(), + ToggleObjectImage.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE_EDIT)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + ToggleObjectImage toggleObj = (ToggleObjectImage) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(toggleObj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_NEW_WIZ)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + ToggleObjectImage toggleObj = new ToggleObjectImage( + BParser.PREDICATE_PREFIX, "", ""); + input.add(toggleObj); + tableViewer + .setSelection(new StructuredSelection(toggleObj)); + } + }); + + setControl(container); + + } + + } + + public WizardObserverSwitchImage(final BControl bcontrol, + final Observer bobserver) { + super(bcontrol, bobserver); + addPage(new ObserverSwitchImagePage("ObserverToggleImagePage")); + } + + @Override + protected Boolean prepareToFinish() { + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); + if (((SwitchImage) getObserver()).getToggleObjects().size() == 0) { + setObserverDelete(true); + } else { + for (ToggleObjectImage obj : ((SwitchImage) getObserver()) + .getToggleObjects()) { + if (obj.getImage().isEmpty()) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The image field must not be empty."); + return false; + } + } + } + return true; + } + + @Override + public boolean performCancel() { + // getBControl().restoreDefaultValue(AttributeConstants.ATTRIBUTE_IMAGE); + return super.performCancel(); + } + + @Override + public Point getSize() { + return new Point(650, 500); + } + + private static class ObserverLabelProvider extends + ObservableMapLabelProvider implements ITableLabelProvider, + ITableColorProvider, ITableFontProvider { + + public ObserverLabelProvider(final IObservableMap[] attributeMaps) { + super(attributeMaps); + } + + private final Color errorColor = Display.getDefault().getSystemColor( + SWT.COLOR_INFO_BACKGROUND); + + // final Font bold = JFaceResources.getFontRegistry().getBold( + // JFaceResources.BANNER_FONT); + + @Override + public Image getColumnImage(final Object element, final int columnIndex) { + if (columnIndex == 2) { + return CheckboxCellEditorHelper + .getCellEditorImage(((ToggleObjectImage) element) + .isExpressionMode()); + } + return null; + } + + @Override + public String getColumnText(final Object element, final int columnIndex) { + + if (columnIndex == 2) + return ""; + + return super.getColumnText(element, columnIndex); + + } + + public Color getBackground(final Object element, final int column) { + ToggleObjectImage attributeObject = (ToggleObjectImage) element; + if (attributeObject.hasError()) + return errorColor; + return null; + } + + public Color getForeground(final Object element, final int column) { + return null; + } + + public Font getFont(final Object element, final int column) { + // return JFaceResources.getFontRegistry().get( + // BMotionStudioConstants.RODIN_FONT_KEY); + return null; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java index e816e1d3ee2c517bca6e12dd054b201e29cea5e2..3eeeef60f09a8440f58a1cba156eab6e71feb5e7 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java @@ -1,210 +1,210 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.observer.wizard; - -import java.util.ArrayList; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Text; -import org.eventb.core.ast.PowerSetType; - -import de.bmotionstudio.gef.editor.eventb.EventBHelper; -import de.bmotionstudio.gef.editor.eventb.MachineContentObject; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.observer.Observer; -import de.bmotionstudio.gef.editor.observer.ObserverWizard; -import de.bmotionstudio.gef.editor.observer.TableObserver; - -public class WizardTableObserver extends ObserverWizard { - - private class TableObserverPage extends WizardPage { - - private Text txtExpression; - private Text txtPredicate; - private Button cbOverrideCells; - private Button cbKeepHeader; - - public Text getTxtExpression() { - return txtExpression; - } - - protected TableObserverPage(final String pageName) { - super(pageName); - } - - public void createControl(final Composite parent) { - - final DataBindingContext dbc = new DataBindingContext(); - - parent.setLayout(new GridLayout(1, true)); - - Group group = new Group(parent, SWT.None); - group.setText("General settings"); - RowLayout rowLayout = new RowLayout(); - rowLayout.marginLeft = 10; - rowLayout.marginTop = 10; - rowLayout.marginBottom = 10; - group.setLayout(rowLayout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - cbOverrideCells = new Button(group, SWT.CHECK); - cbOverrideCells.setText("Override cells"); - - cbKeepHeader = new Button(group, SWT.CHECK); - cbKeepHeader.setText("Keep header"); - - Group container = new Group(parent, SWT.None); - container.setText("Formal model"); - container.setLayout(new GridLayout(2, false)); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite conLeft = new Composite(container, SWT.NONE); - conLeft.setLayoutData(new GridData(GridData.FILL_BOTH)); - conLeft.setLayout(new GridLayout(2, false)); - - Label lb = new Label(conLeft, SWT.NONE); - lb.setText("Predicate:"); - - txtPredicate = new Text(conLeft, SWT.BORDER); - txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtPredicate.setFont(new Font(Display.getDefault(), new FontData( - "Arial", 10, SWT.NONE))); - - lb = new Label(conLeft, SWT.NONE); - lb.setText("Expression:"); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - txtExpression = new Text(conLeft, SWT.BORDER | SWT.MULTI - | SWT.WRAP); - txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite conRight = new Composite(container, SWT.NONE); - - GridData gData = new GridData(GridData.FILL_VERTICAL); - gData.widthHint = 125; - - conRight.setLayoutData(gData); - conRight.setLayout(new GridLayout(1, false)); - - lb = new Label(conRight, SWT.WRAP); - lb.setText("Power sets:"); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - - ArrayList<String> relationList = new ArrayList<String>(); - - java.util.List<MachineContentObject> constants = EventBHelper - .getConstants(getBControl().getVisualization()); - for (MachineContentObject mobj : constants) { - if (mobj.getType() instanceof PowerSetType) { - relationList.add(mobj.getLabel()); - } - } - - java.util.List<MachineContentObject> variables = EventBHelper - .getVariables(getBControl().getVisualization()); - for (MachineContentObject mobj : variables) { - if (mobj.getType() instanceof PowerSetType) { - relationList.add(mobj.getLabel()); - } - } - - final List list = new List(conRight, SWT.SINGLE | SWT.BORDER - | SWT.V_SCROLL); - list.setLayoutData(new GridData(GridData.FILL_BOTH)); - list.setItems(relationList.toArray(new String[relationList.size()])); - - list.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - String[] selection = list.getSelection(); - if (selection.length > 0) - txtExpression.setText(txtExpression.getText() + " " - + selection[0]); - } - }); - initBindings(dbc); - - setControl(conLeft); - - } - - private void initBindings(DataBindingContext dbc) { - - dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), - BeansObservables.observeValue( - (TableObserver) getObserver(), "predicate")); - - dbc.bindValue( - SWTObservables.observeText(txtExpression, SWT.Modify), - BeansObservables.observeValue( - (TableObserver) getObserver(), "expression")); - - dbc.bindValue(SWTObservables.observeSelection(cbOverrideCells), - BeansObservables.observeValue( - (TableObserver) getObserver(), "overrideCells")); - - dbc.bindValue(SWTObservables.observeSelection(cbKeepHeader), - BeansObservables.observeValue( - (TableObserver) getObserver(), "keepHeader")); - - } - - } - - public WizardTableObserver(BControl bcontrol, - Observer bobserver) { - super(bcontrol, bobserver); - addPage(new TableObserverPage("TableObserverPage")); - } - - @Override - protected Boolean prepareToFinish() { - - TableObserverPage page = (TableObserverPage) getPage("TableObserverPage"); - - String errorStr = ""; - - if (page.getTxtExpression().getText().length() == 0) - errorStr += "Please enter an expression.\n"; - - if (page.getErrorMessage() != null) - errorStr += "Please check the syntax/parser error.\n"; - - if (errorStr.length() > 0) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An Error occured", errorStr); - return false; - } - - return true; - - } - - @Override - public Point getSize() { - return new Point(600, 500); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.observer.wizard; + +import java.util.ArrayList; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Text; +import org.eventb.core.ast.PowerSetType; + +import de.bmotionstudio.gef.editor.eventb.EventBHelper; +import de.bmotionstudio.gef.editor.eventb.MachineContentObject; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.observer.Observer; +import de.bmotionstudio.gef.editor.observer.ObserverWizard; +import de.bmotionstudio.gef.editor.observer.TableObserver; + +public class WizardTableObserver extends ObserverWizard { + + private class TableObserverPage extends WizardPage { + + private Text txtExpression; + private Text txtPredicate; + private Button cbOverrideCells; + private Button cbKeepHeader; + + public Text getTxtExpression() { + return txtExpression; + } + + protected TableObserverPage(final String pageName) { + super(pageName); + } + + public void createControl(final Composite parent) { + + final DataBindingContext dbc = new DataBindingContext(); + + parent.setLayout(new GridLayout(1, true)); + + Group group = new Group(parent, SWT.None); + group.setText("General settings"); + RowLayout rowLayout = new RowLayout(); + rowLayout.marginLeft = 10; + rowLayout.marginTop = 10; + rowLayout.marginBottom = 10; + group.setLayout(rowLayout); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + cbOverrideCells = new Button(group, SWT.CHECK); + cbOverrideCells.setText("Override cells"); + + cbKeepHeader = new Button(group, SWT.CHECK); + cbKeepHeader.setText("Keep header"); + + Group container = new Group(parent, SWT.None); + container.setText("Formal model"); + container.setLayout(new GridLayout(2, false)); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Composite conLeft = new Composite(container, SWT.NONE); + conLeft.setLayoutData(new GridData(GridData.FILL_BOTH)); + conLeft.setLayout(new GridLayout(2, false)); + + Label lb = new Label(conLeft, SWT.NONE); + lb.setText("Predicate:"); + + txtPredicate = new Text(conLeft, SWT.BORDER); + txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtPredicate.setFont(new Font(Display.getDefault(), new FontData( + "Arial", 10, SWT.NONE))); + + lb = new Label(conLeft, SWT.NONE); + lb.setText("Expression:"); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + txtExpression = new Text(conLeft, SWT.BORDER | SWT.MULTI + | SWT.WRAP); + txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Composite conRight = new Composite(container, SWT.NONE); + + GridData gData = new GridData(GridData.FILL_VERTICAL); + gData.widthHint = 125; + + conRight.setLayoutData(gData); + conRight.setLayout(new GridLayout(1, false)); + + lb = new Label(conRight, SWT.WRAP); + lb.setText("Power sets:"); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + + ArrayList<String> relationList = new ArrayList<String>(); + + java.util.List<MachineContentObject> constants = EventBHelper + .getConstants(getBControl().getVisualization()); + for (MachineContentObject mobj : constants) { + if (mobj.getType() instanceof PowerSetType) { + relationList.add(mobj.getLabel()); + } + } + + java.util.List<MachineContentObject> variables = EventBHelper + .getVariables(getBControl().getVisualization()); + for (MachineContentObject mobj : variables) { + if (mobj.getType() instanceof PowerSetType) { + relationList.add(mobj.getLabel()); + } + } + + final List list = new List(conRight, SWT.SINGLE | SWT.BORDER + | SWT.V_SCROLL); + list.setLayoutData(new GridData(GridData.FILL_BOTH)); + list.setItems(relationList.toArray(new String[relationList.size()])); + + list.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + String[] selection = list.getSelection(); + if (selection.length > 0) + txtExpression.setText(txtExpression.getText() + " " + + selection[0]); + } + }); + initBindings(dbc); + + setControl(conLeft); + + } + + private void initBindings(DataBindingContext dbc) { + + dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), + BeansObservables.observeValue( + (TableObserver) getObserver(), "predicate")); + + dbc.bindValue( + SWTObservables.observeText(txtExpression, SWT.Modify), + BeansObservables.observeValue( + (TableObserver) getObserver(), "expression")); + + dbc.bindValue(SWTObservables.observeSelection(cbOverrideCells), + BeansObservables.observeValue( + (TableObserver) getObserver(), "overrideCells")); + + dbc.bindValue(SWTObservables.observeSelection(cbKeepHeader), + BeansObservables.observeValue( + (TableObserver) getObserver(), "keepHeader")); + + } + + } + + public WizardTableObserver(BControl bcontrol, + Observer bobserver) { + super(bcontrol, bobserver); + addPage(new TableObserverPage("TableObserverPage")); + } + + @Override + protected Boolean prepareToFinish() { + + TableObserverPage page = (TableObserverPage) getPage("TableObserverPage"); + + String errorStr = ""; + + if (page.getTxtExpression().getText().length() == 0) + errorStr += "Please enter an expression.\n"; + + if (page.getErrorMessage() != null) + errorStr += "Please check the syntax/parser error.\n"; + + if (errorStr.length() > 0) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An Error occured", errorStr); + return false; + } + + return true; + + } + + @Override + public Point getSize() { + return new Point(600, 500); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BButtonPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BButtonPart.java index 781ad5c6f40714bbc812c41b98dfe55be6453682..37dfd4013cd84b6824bab0a34bf975b598b6e245 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BButtonPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BButtonPart.java @@ -1,86 +1,86 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; -import de.bmotionstudio.gef.editor.edit.TextEditManager; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; -import de.bmotionstudio.gef.editor.figure.ButtonFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BButtonPart extends BMSAbstractEditPart { - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) - ((ButtonFigure) figure).setText(value.toString()); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((ButtonFigure) figure).setBackgroundColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) - ((ButtonFigure) figure).setTextColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) - ((ButtonFigure) figure).setBtEnabled(Boolean.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((ButtonFigure) figure).setVisible(Boolean.valueOf(value.toString())); - - } - - @Override - protected IFigure createEditFigure() { - IFigure figure = new ButtonFigure(); - return figure; - } - - private void performDirectEdit() { - new TextEditManager(this, new TextCellEditorLocator( - (IFigure) getFigure())).show(); - } - - @Override - public void performRequest(Request request) { - super.performRequest(request); - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT - && !isRunning()) - performDirectEdit(); - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; +import de.bmotionstudio.gef.editor.edit.TextEditManager; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; +import de.bmotionstudio.gef.editor.figure.ButtonFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BButtonPart extends BMSAbstractEditPart { + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) + ((ButtonFigure) figure).setText(value.toString()); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((ButtonFigure) figure).setBackgroundColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) + ((ButtonFigure) figure).setTextColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) + ((ButtonFigure) figure).setBtEnabled(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((ButtonFigure) figure).setVisible(Boolean.valueOf(value.toString())); + + } + + @Override + protected IFigure createEditFigure() { + IFigure figure = new ButtonFigure(); + return figure; + } + + private void performDirectEdit() { + new TextEditManager(this, new TextCellEditorLocator( + (IFigure) getFigure())).show(); + } + + @Override + public void performRequest(Request request) { + super.performRequest(request); + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT + && !isRunning()) + performDirectEdit(); + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCheckboxPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCheckboxPart.java index 61425dc3229c4d23b027f618197cfe1cc4c36270..d4c4d781cced647adf4a1f2e1b8521b68ee420ef 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCheckboxPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCheckboxPart.java @@ -1,153 +1,153 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.ButtonModel; -import org.eclipse.draw2d.ChangeEvent; -import org.eclipse.draw2d.ChangeListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; -import de.bmotionstudio.gef.editor.edit.TextEditManager; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; -import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; -import de.bmotionstudio.gef.editor.figure.CheckboxFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BCheckboxPart extends BMSAbstractEditPart { - - private ChangeListener changeListener = new ChangeListener() { - @Override - public void handleStateChanged(ChangeEvent event) { - if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { - AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); - if (f.getModel().isPressed()) { - BControl control = (BControl) getModel(); - // Recheck observer after click - control.getVisualization().getAnimation().checkObserver(); - if (Boolean.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED).toString())) { - control.setAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED, false); - } else { - control.setAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED, true); - } - } - } - } - }; - - @Override - public void activate() { - super.activate(); - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .addChangeListener(changeListener); - } - } - - @Override - public void deactivate() { - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .removeChangeListener(changeListener); - } - super.deactivate(); - } - - @Override - protected IFigure createEditFigure() { - CheckboxFigure fig = new CheckboxFigure(); - return fig; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent pEvent) { - - Object value = pEvent.getNewValue(); - String aID = pEvent.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((CheckboxFigure) figure).setVisible(Boolean.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_CHECKED)) { - Boolean bol = Boolean.valueOf(value.toString()); - if (bol) { - ((CheckboxFigure) figure).setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_CHECKED)); - } else { - ((CheckboxFigure) figure).setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_UNCHECKED)); - } - - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) { - int addWidth = ((CheckboxFigure) figure).setText(value.toString()); - ((BControl) getModel()).setAttributeValue( - AttributeConstants.ATTRIBUTE_WIDTH, (30 + addWidth)); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) { - RGB rgbText = (RGB) value; - ((CheckboxFigure) figure) - .setTextColor(new org.eclipse.swt.graphics.Color(Display - .getDefault(), rgbText)); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) - ((CheckboxFigure) figure).setBtEnabled(Boolean.valueOf(value - .toString())); - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - - private void performDirectEdit() { - new TextEditManager(this, new TextCellEditorLocator( - (IFigure) getFigure())).show(); - } - - @Override - public void performRequest(Request request) { - super.performRequest(request); - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT - && !isRunning()) - performDirectEdit(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.ButtonModel; +import org.eclipse.draw2d.ChangeEvent; +import org.eclipse.draw2d.ChangeListener; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; +import de.bmotionstudio.gef.editor.edit.TextEditManager; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; +import de.bmotionstudio.gef.editor.figure.CheckboxFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BCheckboxPart extends BMSAbstractEditPart { + + private ChangeListener changeListener = new ChangeListener() { + @Override + public void handleStateChanged(ChangeEvent event) { + if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { + AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); + if (f.getModel().isPressed()) { + BControl control = (BControl) getModel(); + // Recheck observer after click + control.getVisualization().getAnimation().checkObserver(); + if (Boolean.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED).toString())) { + control.setAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED, false); + } else { + control.setAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED, true); + } + } + } + } + }; + + @Override + public void activate() { + super.activate(); + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .addChangeListener(changeListener); + } + } + + @Override + public void deactivate() { + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .removeChangeListener(changeListener); + } + super.deactivate(); + } + + @Override + protected IFigure createEditFigure() { + CheckboxFigure fig = new CheckboxFigure(); + return fig; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent pEvent) { + + Object value = pEvent.getNewValue(); + String aID = pEvent.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((CheckboxFigure) figure).setVisible(Boolean.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_CHECKED)) { + Boolean bol = Boolean.valueOf(value.toString()); + if (bol) { + ((CheckboxFigure) figure).setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_CHECKED)); + } else { + ((CheckboxFigure) figure).setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_UNCHECKED)); + } + + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) { + int addWidth = ((CheckboxFigure) figure).setText(value.toString()); + ((BControl) getModel()).setAttributeValue( + AttributeConstants.ATTRIBUTE_WIDTH, (30 + addWidth)); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) { + RGB rgbText = (RGB) value; + ((CheckboxFigure) figure) + .setTextColor(new org.eclipse.swt.graphics.Color(Display + .getDefault(), rgbText)); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) + ((CheckboxFigure) figure).setBtEnabled(Boolean.valueOf(value + .toString())); + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + + private void performDirectEdit() { + new TextEditManager(this, new TextCellEditorLocator( + (IFigure) getFigure())).show(); + } + + @Override + public void performRequest(Request request) { + super.performRequest(request); + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT + && !isRunning()) + performDirectEdit(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCompositePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCompositePart.java index 54578cb3d311cd23a44cc49fd043fe89501c30fd..8fb3be85002477b2ccd512845411aa8493468bb4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCompositePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BCompositePart.java @@ -1,147 +1,147 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.CompoundSnapToHelper; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.SnapToGeometry; -import org.eclipse.gef.SnapToGrid; -import org.eclipse.gef.SnapToGuides; -import org.eclipse.gef.SnapToHelper; -import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; -import org.eclipse.gef.rulers.RulerProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSEditLayoutPolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; -import de.bmotionstudio.gef.editor.figure.CompositeFigure; -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.library.LibraryImageCommand; -import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BCompositePart extends BMSAbstractEditPart { - - @Override - protected IFigure createEditFigure() { - IFigure figure = new CompositeFigure(); - return figure; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((CompositeFigure) figure).setBackgroundColor((RGB) value); - - // if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) - // ((BComposite) figure).setAlpha(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { - if (value != null) { - String imgPath = value.toString(); - if (imgPath.length() > 0) { - IFile pFile = model.getVisualization().getProjectFile(); - String myPath = (pFile.getProject().getLocation() - + "/images/" + imgPath).replace("file:", ""); - if (new File(myPath).exists()) { - ((CompositeFigure) figure).setImage(new Image(Display - .getDefault(), myPath)); - } - } - } - - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((CompositeFigure) figure).setVisible(Boolean.valueOf(value - .toString())); - - } - - @Override - public List<BControl> getModelChildren() { - return ((BControl) getModel()).getChildrenArray(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Object getAdapter(Class adapter) { - if (adapter == SnapToHelper.class) { - List snapStrategies = new ArrayList(); - Boolean val = (Boolean) getViewer().getProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY); - if (val != null && val.booleanValue()) - snapStrategies.add(new SnapToGuides(this)); - val = (Boolean) getViewer().getProperty( - SnapToGeometry.PROPERTY_SNAP_ENABLED); - if (val != null && val.booleanValue()) - snapStrategies.add(new SnapToGeometry(this)); - val = (Boolean) getViewer().getProperty( - SnapToGrid.PROPERTY_GRID_ENABLED); - if (val != null && val.booleanValue()) - snapStrategies.add(new SnapToGrid(this)); - - if (snapStrategies.size() == 0) - return null; - if (snapStrategies.size() == 1) - return snapStrategies.get(0); - - SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; - for (int i = 0; i < snapStrategies.size(); i++) - ss[i] = (SnapToHelper) snapStrategies.get(i); - return new CompoundSnapToHelper(ss); - } - return super.getAdapter(adapter); - } - - @Override - public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { - AbstractLibraryCommand command = null; - if (request.getAttributeTransferObject().getLibraryObject().getType() - .equals("variable")) { - command = new LibraryVariableCommand(); - } else if (request.getAttributeTransferObject().getLibraryObject() - .getType().equals("image")) { - command = new LibraryImageCommand(); - } - return command; - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, new BMSEditLayoutPolicy()); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null); - installEditPolicy(EditPolicy.CONTAINER_ROLE, new SnapFeedbackPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, - new ChangeAttributePolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.CompoundSnapToHelper; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.SnapToGeometry; +import org.eclipse.gef.SnapToGrid; +import org.eclipse.gef.SnapToGuides; +import org.eclipse.gef.SnapToHelper; +import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; +import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSEditLayoutPolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; +import de.bmotionstudio.gef.editor.figure.CompositeFigure; +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.library.LibraryImageCommand; +import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BCompositePart extends BMSAbstractEditPart { + + @Override + protected IFigure createEditFigure() { + IFigure figure = new CompositeFigure(); + return figure; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((CompositeFigure) figure).setBackgroundColor((RGB) value); + + // if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) + // ((BComposite) figure).setAlpha(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { + if (value != null) { + String imgPath = value.toString(); + if (imgPath.length() > 0) { + IFile pFile = model.getVisualization().getProjectFile(); + String myPath = (pFile.getProject().getLocation() + + "/images/" + imgPath).replace("file:", ""); + if (new File(myPath).exists()) { + ((CompositeFigure) figure).setImage(new Image(Display + .getDefault(), myPath)); + } + } + } + + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((CompositeFigure) figure).setVisible(Boolean.valueOf(value + .toString())); + + } + + @Override + public List<BControl> getModelChildren() { + return ((BControl) getModel()).getChildrenArray(); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public Object getAdapter(Class adapter) { + if (adapter == SnapToHelper.class) { + List snapStrategies = new ArrayList(); + Boolean val = (Boolean) getViewer().getProperty( + RulerProvider.PROPERTY_RULER_VISIBILITY); + if (val != null && val.booleanValue()) + snapStrategies.add(new SnapToGuides(this)); + val = (Boolean) getViewer().getProperty( + SnapToGeometry.PROPERTY_SNAP_ENABLED); + if (val != null && val.booleanValue()) + snapStrategies.add(new SnapToGeometry(this)); + val = (Boolean) getViewer().getProperty( + SnapToGrid.PROPERTY_GRID_ENABLED); + if (val != null && val.booleanValue()) + snapStrategies.add(new SnapToGrid(this)); + + if (snapStrategies.size() == 0) + return null; + if (snapStrategies.size() == 1) + return snapStrategies.get(0); + + SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; + for (int i = 0; i < snapStrategies.size(); i++) + ss[i] = (SnapToHelper) snapStrategies.get(i); + return new CompoundSnapToHelper(ss); + } + return super.getAdapter(adapter); + } + + @Override + public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { + AbstractLibraryCommand command = null; + if (request.getAttributeTransferObject().getLibraryObject().getType() + .equals("variable")) { + command = new LibraryVariableCommand(); + } else if (request.getAttributeTransferObject().getLibraryObject() + .getType().equals("image")) { + command = new LibraryImageCommand(); + } + return command; + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, new BMSEditLayoutPolicy()); + installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null); + installEditPolicy(EditPolicy.CONTAINER_ROLE, new SnapFeedbackPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, + new ChangeAttributePolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java index 3f09133d67eda64a8a70af64ed9d537c35c79cd0..ace0d0cf76312d19debec47a8f36f0cb407136be 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java @@ -1,444 +1,439 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MidpointLocator; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.XYAnchor; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.AccessibleAnchorProvider; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.NodeEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editparts.AbstractConnectionEditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editpolicies.ConnectionEditPolicy; -import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; -import org.eclipse.gef.requests.GroupRequest; -import org.eclipse.gef.tools.SelectEditPartTracker; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; -import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand; -import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BConnectionEditPart extends BMSAbstractEditPart implements - ConnectionEditPart, LayerConstants { - - protected Color foregroundColor; - private Label conLabel; - - public static final ConnectionAnchor DEFAULT_SOURCE_ANCHOR = new XYAnchor( - new Point(10, 10)); - public static final ConnectionAnchor DEFAULT_TARGET_ANCHOR = new XYAnchor( - new Point(100, 100)); - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.part.AppAbstractEditPart#deactivate() - */ - @Override - public void deactivate() { - super.deactivate(); - if (isActive()) - foregroundColor.dispose(); - } - - @Override - protected void prepareEditPolicies() { - // Selection handle edit policy. - // Makes the connection show a feedback, when selected by the user. - installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, - new ConnectionEndpointEditPolicy()); // Allows the removal of - // the connection model - // element - installEditPolicy(EditPolicy.CONNECTION_ROLE, - new ConnectionEditPolicy() { - protected Command getDeleteCommand(GroupRequest request) { - return new ConnectionDeleteCommand( - (BConnection) getModel()); - } - }); - } - - @Override - protected IFigure createEditFigure() { - PolylineConnection connection = new PolylineConnection() { - - private boolean visible; - - @Override - public void paint(Graphics g) { - if (!visible && !isRunning()) { - Rectangle clientArea = getClientArea(); - g.drawImage( - BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_CONTROL_HIDDEN), - clientArea.x, clientArea.y); - g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); - } - super.paint(g); - } - - @Override - public void setVisible(boolean visible) { - if (!isRunning()) { - this.visible = visible; - repaint(); - } else { - super.setVisible(visible); - } - } - - }; - conLabel = new Label(); - MidpointLocator locator = new MidpointLocator(connection, 0); - locator.setRelativePosition(PositionConstants.NORTH); - connection.add(conLabel, locator); - return connection; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_LINEWIDTH)) - ((PolylineConnection) getFigure()).setLineWidth(Integer - .valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_LINESTYLE)) - ((PolylineConnection) getFigure()).setLineStyle((Integer - .valueOf(value.toString()) + 1)); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((PolylineConnection) getFigure()).setVisible(Boolean.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), (RGB) value); - ((PolylineConnection) getFigure()) - .setForegroundColor(foregroundColor); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_CONNECTION_SOURCE_DECORATION)) { - int decoration = Integer.valueOf(value.toString()); - if (decoration == BAttributeConnectionSourceDecoration.DECORATION_TRIANGLE) { - ((PolylineConnection) getFigure()) - .setSourceDecoration(new PolygonDecoration()); - } else { - ((PolylineConnection) getFigure()).setSourceDecoration(null); - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_CONNECTION_TARGET_DECORATION)) { - int decoration = Integer.valueOf(value.toString()); - if (decoration == BAttributeConnectionSourceDecoration.DECORATION_TRIANGLE) { - ((PolylineConnection) getFigure()) - .setTargetDecoration(new PolygonDecoration()); - } else { - ((PolylineConnection) getFigure()).setTargetDecoration(null); - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_LABEL)) { - conLabel.setText(value.toString()); - } - - } - - /** - * Provides accessibility support for when connections are also themselves - * nodes. If a connection is the source or target of another connection, - * then its midpoint is used as the accessible anchor location. - * - * @author hudsonr - * @since 2.0 - */ - protected final class DefaultAccessibleAnchorProvider implements - AccessibleAnchorProvider { - /** - * This class is internal, but is made protected so that JavaDoc will - * see it. - */ - DefaultAccessibleAnchorProvider() { - } - - /** - * @see AccessibleAnchorProvider#getSourceAnchorLocations() - */ - public List<Point> getSourceAnchorLocations() { - List<Point> list = new ArrayList<Point>(); - if (getFigure() instanceof Connection) { - Point p = ((Connection) getFigure()).getPoints().getMidpoint(); - getFigure().translateToAbsolute(p); - list.add(p); - } - return list; - } - - /** - * @see AccessibleAnchorProvider#getTargetAnchorLocations() - */ - public List<Point> getTargetAnchorLocations() { - return getSourceAnchorLocations(); - } - } - - private EditPart sourceEditPart, targetEditPart; - - /** - * Activates the Figure representing this, by setting up the start and end - * connections, and adding the figure to the Connection Layer. - * - * @see #deactivate() - */ - protected void activateFigure() { - getLayer(CONNECTION_LAYER).add(getFigure()); - } - - /** - * @see org.eclipse.gef.EditPart#addNotify() - */ - public void addNotify() { - activateFigure(); - super.addNotify(); - } - - /** - * Deactivates the Figure representing this, by removing it from the - * connection layer, and resetting the source and target connections to - * <code>null</code>. - */ - protected void deactivateFigure() { - getLayer(CONNECTION_LAYER).remove(getFigure()); - getConnectionFigure().setSourceAnchor(null); - getConnectionFigure().setTargetAnchor(null); - } - - /** - * <code>AbstractConnectionEditPart</code> extends getAdapter() to overrides - * the {@link AccessibleAnchorProvider} adapter returned by the superclass. - * When treating a connection as a node for other connections, it makes - * sense to target its midpoint, and not the edge of its bounds. - * - * @see AbstractConnectionEditPart.DefaultAccessibleAnchorProvider - * @see AbstractGraphicalEditPart#getAdapter(Class) - * @param adapter - * the adapter Class - * @return the adapter - */ - public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - if (adapter == AccessibleAnchorProvider.class) - return new DefaultAccessibleAnchorProvider(); - return super.getAdapter(adapter); - } - - /** - * Convenience method for casting this GraphicalEditPart's Figure to a - * {@link Connection} - * - * @return the Figure as a Connection - */ - public Connection getConnectionFigure() { - return (Connection) getFigure(); - } - - /** - * @see org.eclipse.gef.EditPart#getDragTracker(Request) - */ - public DragTracker getDragTracker(Request req) { - return new SelectEditPartTracker(this); - } - - /** - * @see org.eclipse.gef.ConnectionEditPart#getSource() - */ - public EditPart getSource() { - return sourceEditPart; - } - - /** - * @see org.eclipse.gef.ConnectionEditPart#getTarget() - */ - public EditPart getTarget() { - return targetEditPart; - } - - /** - * Returns the <code>ConnectionAnchor</code> for the <i>source</i> end of - * the connection. If the source is an instance of {@link NodeEditPart}, - * that interface will be used to determine the proper ConnectionAnchor. If - * the source is not an instance of <code>NodeEditPart</code>, this method - * should be overridden to return the correct ConnectionAnchor. Failure to - * do this will cause a default anchor to be used so that the connection - * figure will be made visible to the developer. - * - * @return ConnectionAnchor for the source end of the Connection - */ - protected ConnectionAnchor getSourceConnectionAnchor() { - if (getSource() != null) { - if (getSource() instanceof NodeEditPart) { - NodeEditPart editPart = (NodeEditPart) getSource(); - return editPart.getSourceConnectionAnchor(this); - } - IFigure f = ((GraphicalEditPart) getSource()).getFigure(); - return new ChopboxAnchor(f); - } - return DEFAULT_SOURCE_ANCHOR; - } - - /** - * Returns the <code>ConnectionAnchor</code> for the <i>target</i> end of - * the connection. If the target is an instance of {@link NodeEditPart}, - * that interface will be used to determine the proper ConnectionAnchor. If - * the target is not an instance of <code>NodeEditPart</code>, this method - * should be overridden to return the correct ConnectionAnchor. Failure to - * do this will cause a default anchor to be used so that the connection - * figure will be made visible to the developer. - * - * @return ConnectionAnchor for the target end of the Connection - */ - protected ConnectionAnchor getTargetConnectionAnchor() { - if (getTarget() != null) { - if (getTarget() instanceof NodeEditPart) { - NodeEditPart editPart = (NodeEditPart) getTarget(); - return editPart.getTargetConnectionAnchor(this); - } - IFigure f = ((GraphicalEditPart) getTarget()).getFigure(); - return new ChopboxAnchor(f); - } - return DEFAULT_TARGET_ANCHOR; - } - - /** - * Extended here to also refresh the ConnectionAnchors. - * - * @see org.eclipse.gef.EditPart#refresh() - */ - public void refresh() { - refreshSourceAnchor(); - refreshTargetAnchor(); - super.refresh(); - } - - /** - * Updates the source ConnectionAnchor. Subclasses should override - * {@link #getSourceConnectionAnchor()} if necessary, and not this method. - */ - protected void refreshSourceAnchor() { - getConnectionFigure().setSourceAnchor(getSourceConnectionAnchor()); - } - - /** - * Updates the target ConnectionAnchor. Subclasses should override - * {@link #getTargetConnectionAnchor()} if necessary, and not this method. - */ - protected void refreshTargetAnchor() { - getConnectionFigure().setTargetAnchor(getTargetConnectionAnchor()); - } - - /** - * Extended here to remove the ConnectionEditPart's connection figure from - * the connection layer. - * - * @see org.eclipse.gef.EditPart#removeNotify() - */ - public void removeNotify() { - deactivateFigure(); - super.removeNotify(); - } - - /** - * Extended to implement automatic addNotify and removeNotify handling. - * - * @see org.eclipse.gef.EditPart#setParent(EditPart) - */ - public void setParent(EditPart parent) { - boolean wasNull = getParent() == null; - boolean becomingNull = parent == null; - if (becomingNull && !wasNull) - removeNotify(); - super.setParent(parent); - if (wasNull && !becomingNull) - addNotify(); - } - - /** - * Sets the source EditPart of this connection. - * - * @param editPart - * EditPart which is the source. - */ - public void setSource(EditPart editPart) { - if (sourceEditPart == editPart) - return; - sourceEditPart = editPart; - if (sourceEditPart != null) - setParent(sourceEditPart.getRoot()); - else if (getTarget() == null) - setParent(null); - if (sourceEditPart != null && targetEditPart != null) - refresh(); - } - - /** - * Sets the target EditPart of this connection. - * - * @param editPart - * EditPart which is the target. - */ - public void setTarget(EditPart editPart) { - if (targetEditPart == editPart) - return; - targetEditPart = editPart; - if (editPart != null) - setParent(editPart.getRoot()); - else if (getSource() == null) - setParent(null); - if (sourceEditPart != null && targetEditPart != null) - refresh(); - } - - @Override - protected void prepareRunPolicies() { - // TODO Auto-generated method stub - - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.ChopboxAnchor; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.MidpointLocator; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.XYAnchor; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.AccessibleAnchorProvider; +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.LayerConstants; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editparts.AbstractConnectionEditPart; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.gef.editpolicies.ConnectionEditPolicy; +import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; +import org.eclipse.gef.requests.GroupRequest; +import org.eclipse.gef.tools.SelectEditPartTracker; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; +import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BConnectionEditPart extends BMSAbstractEditPart implements + ConnectionEditPart, LayerConstants { + + protected Color foregroundColor; + private Label conLabel; + + public static final ConnectionAnchor DEFAULT_SOURCE_ANCHOR = new XYAnchor( + new Point(10, 10)); + public static final ConnectionAnchor DEFAULT_TARGET_ANCHOR = new XYAnchor( + new Point(100, 100)); + + @Override + public void deactivate() { + super.deactivate(); + if (isActive()) + foregroundColor.dispose(); + } + + @Override + protected void prepareEditPolicies() { + // Selection handle edit policy. + // Makes the connection show a feedback, when selected by the user. + installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, + new ConnectionEndpointEditPolicy()); // Allows the removal of + // the connection model + // element + installEditPolicy(EditPolicy.CONNECTION_ROLE, + new ConnectionEditPolicy() { + protected Command getDeleteCommand(GroupRequest request) { + return new ConnectionDeleteCommand( + (BConnection) getModel()); + } + }); + } + + @Override + protected IFigure createEditFigure() { + PolylineConnection connection = new PolylineConnection() { + + private boolean visible; + + @Override + public void paint(Graphics g) { + if (!visible && !isRunning()) { + Rectangle clientArea = getClientArea(); + g.drawImage( + BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_CONTROL_HIDDEN), + clientArea.x, clientArea.y); + g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); + } + super.paint(g); + } + + @Override + public void setVisible(boolean visible) { + if (!isRunning()) { + this.visible = visible; + repaint(); + } else { + super.setVisible(visible); + } + } + + }; + conLabel = new Label(); + MidpointLocator locator = new MidpointLocator(connection, 0); + locator.setRelativePosition(PositionConstants.NORTH); + connection.add(conLabel, locator); + return connection; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_LINEWIDTH)) + ((PolylineConnection) getFigure()).setLineWidth(Integer + .valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_LINESTYLE)) + ((PolylineConnection) getFigure()).setLineStyle((Integer + .valueOf(value.toString()) + 1)); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((PolylineConnection) getFigure()).setVisible(Boolean.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), (RGB) value); + ((PolylineConnection) getFigure()) + .setForegroundColor(foregroundColor); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_CONNECTION_SOURCE_DECORATION)) { + int decoration = Integer.valueOf(value.toString()); + if (decoration == BAttributeConnectionSourceDecoration.DECORATION_TRIANGLE) { + ((PolylineConnection) getFigure()) + .setSourceDecoration(new PolygonDecoration()); + } else { + ((PolylineConnection) getFigure()).setSourceDecoration(null); + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_CONNECTION_TARGET_DECORATION)) { + int decoration = Integer.valueOf(value.toString()); + if (decoration == BAttributeConnectionSourceDecoration.DECORATION_TRIANGLE) { + ((PolylineConnection) getFigure()) + .setTargetDecoration(new PolygonDecoration()); + } else { + ((PolylineConnection) getFigure()).setTargetDecoration(null); + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_LABEL)) { + conLabel.setText(value.toString()); + } + + } + + /** + * Provides accessibility support for when connections are also themselves + * nodes. If a connection is the source or target of another connection, + * then its midpoint is used as the accessible anchor location. + * + * @author hudsonr + * @since 2.0 + */ + protected final class DefaultAccessibleAnchorProvider implements + AccessibleAnchorProvider { + /** + * This class is internal, but is made protected so that JavaDoc will + * see it. + */ + DefaultAccessibleAnchorProvider() { + } + + /** + * @see AccessibleAnchorProvider#getSourceAnchorLocations() + */ + public List<Point> getSourceAnchorLocations() { + List<Point> list = new ArrayList<Point>(); + if (getFigure() instanceof Connection) { + Point p = ((Connection) getFigure()).getPoints().getMidpoint(); + getFigure().translateToAbsolute(p); + list.add(p); + } + return list; + } + + /** + * @see AccessibleAnchorProvider#getTargetAnchorLocations() + */ + public List<Point> getTargetAnchorLocations() { + return getSourceAnchorLocations(); + } + } + + private EditPart sourceEditPart, targetEditPart; + + /** + * Activates the Figure representing this, by setting up the start and end + * connections, and adding the figure to the Connection Layer. + * + * @see #deactivate() + */ + protected void activateFigure() { + getLayer(CONNECTION_LAYER).add(getFigure()); + } + + /** + * @see org.eclipse.gef.EditPart#addNotify() + */ + public void addNotify() { + activateFigure(); + super.addNotify(); + } + + /** + * Deactivates the Figure representing this, by removing it from the + * connection layer, and resetting the source and target connections to + * <code>null</code>. + */ + protected void deactivateFigure() { + getLayer(CONNECTION_LAYER).remove(getFigure()); + getConnectionFigure().setSourceAnchor(null); + getConnectionFigure().setTargetAnchor(null); + } + + /** + * <code>AbstractConnectionEditPart</code> extends getAdapter() to overrides + * the {@link AccessibleAnchorProvider} adapter returned by the superclass. + * When treating a connection as a node for other connections, it makes + * sense to target its midpoint, and not the edge of its bounds. + * + * @see AbstractConnectionEditPart.DefaultAccessibleAnchorProvider + * @see AbstractGraphicalEditPart#getAdapter(Class) + * @param adapter + * the adapter Class + * @return the adapter + */ + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { + if (adapter == AccessibleAnchorProvider.class) + return new DefaultAccessibleAnchorProvider(); + return super.getAdapter(adapter); + } + + /** + * Convenience method for casting this GraphicalEditPart's Figure to a + * {@link Connection} + * + * @return the Figure as a Connection + */ + public Connection getConnectionFigure() { + return (Connection) getFigure(); + } + + /** + * @see org.eclipse.gef.EditPart#getDragTracker(Request) + */ + public DragTracker getDragTracker(Request req) { + return new SelectEditPartTracker(this); + } + + /** + * @see org.eclipse.gef.ConnectionEditPart#getSource() + */ + public EditPart getSource() { + return sourceEditPart; + } + + /** + * @see org.eclipse.gef.ConnectionEditPart#getTarget() + */ + public EditPart getTarget() { + return targetEditPart; + } + + /** + * Returns the <code>ConnectionAnchor</code> for the <i>source</i> end of + * the connection. If the source is an instance of {@link NodeEditPart}, + * that interface will be used to determine the proper ConnectionAnchor. If + * the source is not an instance of <code>NodeEditPart</code>, this method + * should be overridden to return the correct ConnectionAnchor. Failure to + * do this will cause a default anchor to be used so that the connection + * figure will be made visible to the developer. + * + * @return ConnectionAnchor for the source end of the Connection + */ + protected ConnectionAnchor getSourceConnectionAnchor() { + if (getSource() != null) { + if (getSource() instanceof NodeEditPart) { + NodeEditPart editPart = (NodeEditPart) getSource(); + return editPart.getSourceConnectionAnchor(this); + } + IFigure f = ((GraphicalEditPart) getSource()).getFigure(); + return new ChopboxAnchor(f); + } + return DEFAULT_SOURCE_ANCHOR; + } + + /** + * Returns the <code>ConnectionAnchor</code> for the <i>target</i> end of + * the connection. If the target is an instance of {@link NodeEditPart}, + * that interface will be used to determine the proper ConnectionAnchor. If + * the target is not an instance of <code>NodeEditPart</code>, this method + * should be overridden to return the correct ConnectionAnchor. Failure to + * do this will cause a default anchor to be used so that the connection + * figure will be made visible to the developer. + * + * @return ConnectionAnchor for the target end of the Connection + */ + protected ConnectionAnchor getTargetConnectionAnchor() { + if (getTarget() != null) { + if (getTarget() instanceof NodeEditPart) { + NodeEditPart editPart = (NodeEditPart) getTarget(); + return editPart.getTargetConnectionAnchor(this); + } + IFigure f = ((GraphicalEditPart) getTarget()).getFigure(); + return new ChopboxAnchor(f); + } + return DEFAULT_TARGET_ANCHOR; + } + + /** + * Extended here to also refresh the ConnectionAnchors. + * + * @see org.eclipse.gef.EditPart#refresh() + */ + public void refresh() { + refreshSourceAnchor(); + refreshTargetAnchor(); + super.refresh(); + } + + /** + * Updates the source ConnectionAnchor. Subclasses should override + * {@link #getSourceConnectionAnchor()} if necessary, and not this method. + */ + protected void refreshSourceAnchor() { + getConnectionFigure().setSourceAnchor(getSourceConnectionAnchor()); + } + + /** + * Updates the target ConnectionAnchor. Subclasses should override + * {@link #getTargetConnectionAnchor()} if necessary, and not this method. + */ + protected void refreshTargetAnchor() { + getConnectionFigure().setTargetAnchor(getTargetConnectionAnchor()); + } + + /** + * Extended here to remove the ConnectionEditPart's connection figure from + * the connection layer. + * + * @see org.eclipse.gef.EditPart#removeNotify() + */ + public void removeNotify() { + deactivateFigure(); + super.removeNotify(); + } + + /** + * Extended to implement automatic addNotify and removeNotify handling. + * + * @see org.eclipse.gef.EditPart#setParent(EditPart) + */ + public void setParent(EditPart parent) { + boolean wasNull = getParent() == null; + boolean becomingNull = parent == null; + if (becomingNull && !wasNull) + removeNotify(); + super.setParent(parent); + if (wasNull && !becomingNull) + addNotify(); + } + + /** + * Sets the source EditPart of this connection. + * + * @param editPart + * EditPart which is the source. + */ + public void setSource(EditPart editPart) { + if (sourceEditPart == editPart) + return; + sourceEditPart = editPart; + if (sourceEditPart != null) + setParent(sourceEditPart.getRoot()); + else if (getTarget() == null) + setParent(null); + if (sourceEditPart != null && targetEditPart != null) + refresh(); + } + + /** + * Sets the target EditPart of this connection. + * + * @param editPart + * EditPart which is the target. + */ + public void setTarget(EditPart editPart) { + if (targetEditPart == editPart) + return; + targetEditPart = editPart; + if (editPart != null) + setParent(editPart.getRoot()); + else if (getSource() == null) + setParent(null); + if (sourceEditPart != null && targetEditPart != null) + refresh(); + } + + @Override + protected void prepareRunPolicies() { + // TODO Auto-generated method stub + + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java index 21bc714c14173d8826e437f95eaa88c2dba7907e..59b8248b1087116e9d347d1a0ae9867f7b903fb8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java @@ -1,147 +1,147 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.model.BConnection; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.observer.IObserverListener; -import de.bmotionstudio.gef.editor.observer.Observer; - -public class BControlTreeEditPart extends BMSAbstractTreeEditPart implements - PropertyChangeListener, IObserverListener { - - public void propertyChange(final PropertyChangeEvent evt) { - if (evt.getPropertyName().equals( - BControlPropertyConstants.PROPERTY_ADD_CHILD) - || evt.getPropertyName().equals( - BControlPropertyConstants.PROPERTY_REMOVE_CHILD)) { - refreshChildren(); - } - refreshVisuals(); - } - - @Override - protected void createEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - } - - @Override - protected List<Object> getModelChildren() { - - List<Object> toShowElements = new ArrayList<Object>(); - - if (getModel() instanceof BControl) { - - BControl c = (BControl) getModel(); - - for (BControl control : c.getChildrenArray()) { - if (control.showInOutlineView()) - toShowElements.add(control); - List<BConnection> sourceConnections = control - .getSourceConnections(); - for (BConnection con : sourceConnections) { - if (con.showInOutlineView() - && !toShowElements.contains(con)) - toShowElements.add(con); - } - List<BConnection> targetConnections = control - .getTargetConnections(); - for (BConnection con : targetConnections) { - if (con.showInOutlineView() - && !toShowElements.contains(con)) - toShowElements.add(con); - } - } - - // if (!(getModel() instanceof Visualization)) - // toShowElements.add(new ObserverRootVirtualTreeNode(c)); - - } - - return toShowElements; - - } - - public void activate() { - if (!isActive()) { - super.activate(); - ((BControl) getModel()).addPropertyChangeListener(this); - // ((BControl) getModel()).addObserverListener(this); - } - } - - public void deactivate() { - if (isActive()) { - super.deactivate(); - ((BControl) getModel()).removePropertyChangeListener(this); - // ((BControl) getModel()).removeObserverListener(this); - } - } - - @Override - public void refreshVisuals() { - - Object model = getModel(); - - if (model instanceof BControl) { - BControl bcontrol = (BControl) model; - if (!(bcontrol instanceof Visualization)) { - setWidgetText(bcontrol.getAttributeValue( - AttributeConstants.ATTRIBUTE_ID).toString()); - setWidgetImage(bcontrol.getIcon()); - } - } else if (model instanceof Observer) { - setWidgetText(((Observer) model).getName()); - setWidgetImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_OBSERVER)); - } - - } - - @Override - public void performRequest(Request req) { - if (req.getType().equals(RequestConstants.REQ_OPEN)) { - try { - IWorkbenchPage page = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - page.showView(IPageLayout.ID_PROP_SHEET); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - } - - @Override - public void addedObserver(BControl control, Observer observer) { - refreshChildren(); - } - - @Override - public void removedObserver(BControl control) { - refreshChildren(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.model.BConnection; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.observer.IObserverListener; +import de.bmotionstudio.gef.editor.observer.Observer; + +public class BControlTreeEditPart extends BMSAbstractTreeEditPart implements + PropertyChangeListener, IObserverListener { + + public void propertyChange(final PropertyChangeEvent evt) { + if (evt.getPropertyName().equals( + BControlPropertyConstants.PROPERTY_ADD_CHILD) + || evt.getPropertyName().equals( + BControlPropertyConstants.PROPERTY_REMOVE_CHILD)) { + refreshChildren(); + } + refreshVisuals(); + } + + @Override + protected void createEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + } + + @Override + protected List<Object> getModelChildren() { + + List<Object> toShowElements = new ArrayList<Object>(); + + if (getModel() instanceof BControl) { + + BControl c = (BControl) getModel(); + + for (BControl control : c.getChildrenArray()) { + if (control.showInOutlineView()) + toShowElements.add(control); + List<BConnection> sourceConnections = control + .getSourceConnections(); + for (BConnection con : sourceConnections) { + if (con.showInOutlineView() + && !toShowElements.contains(con)) + toShowElements.add(con); + } + List<BConnection> targetConnections = control + .getTargetConnections(); + for (BConnection con : targetConnections) { + if (con.showInOutlineView() + && !toShowElements.contains(con)) + toShowElements.add(con); + } + } + + // if (!(getModel() instanceof Visualization)) + // toShowElements.add(new ObserverRootVirtualTreeNode(c)); + + } + + return toShowElements; + + } + + public void activate() { + if (!isActive()) { + super.activate(); + ((BControl) getModel()).addPropertyChangeListener(this); + // ((BControl) getModel()).addObserverListener(this); + } + } + + public void deactivate() { + if (isActive()) { + super.deactivate(); + ((BControl) getModel()).removePropertyChangeListener(this); + // ((BControl) getModel()).removeObserverListener(this); + } + } + + @Override + public void refreshVisuals() { + + Object model = getModel(); + + if (model instanceof BControl) { + BControl bcontrol = (BControl) model; + if (!(bcontrol instanceof Visualization)) { + setWidgetText(bcontrol.getAttributeValue( + AttributeConstants.ATTRIBUTE_ID).toString()); + setWidgetImage(bcontrol.getIcon()); + } + } else if (model instanceof Observer) { + setWidgetText(((Observer) model).getName()); + setWidgetImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_OBSERVER)); + } + + } + + @Override + public void performRequest(Request req) { + if (req.getType().equals(RequestConstants.REQ_OPEN)) { + try { + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + page.showView(IPageLayout.ID_PROP_SHEET); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + } + + @Override + public void addedObserver(BControl control, Observer observer) { + refreshChildren(); + } + + @Override + public void removedObserver(BControl control) { + refreshChildren(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BImagePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BImagePart.java index d1e12738ca1ab603449c3f0cbe70d18b44d2c51f..1fab4c25b89be973fea532e61bc336101959e721 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BImagePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BImagePart.java @@ -1,85 +1,85 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.core.resources.IFile; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; -import de.bmotionstudio.gef.editor.figure.BMSImageFigure; -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.library.LibraryImageCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BImagePart extends BMSAbstractEditPart { - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { - if (value != null) { - String imgPath = value.toString(); - if (imgPath.length() > 0) { - IFile pFile = model.getVisualization().getProjectFile(); - String myPath = (pFile.getProject().getLocation() - + "/images/" + imgPath).replace("file:", ""); - ((BMSImageFigure) figure).setImage(myPath); - } - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((BMSImageFigure) figure).setVisible(Boolean.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) - ((BMSImageFigure) figure) - .setAlpha(Integer.valueOf(value.toString())); - - } - - @Override - protected IFigure createEditFigure() { - IFigure figure = new BMSImageFigure(); - return figure; - } - - @Override - public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { - AbstractLibraryCommand command = null; - if (request.getAttributeTransferObject().getLibraryObject().getType() - .equals("image")) { - command = new LibraryImageCommand(); - } - return command; - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, - new ChangeAttributePolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.core.resources.IFile; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; +import de.bmotionstudio.gef.editor.figure.BMSImageFigure; +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.library.LibraryImageCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BImagePart extends BMSAbstractEditPart { + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { + if (value != null) { + String imgPath = value.toString(); + if (imgPath.length() > 0) { + IFile pFile = model.getVisualization().getProjectFile(); + String myPath = (pFile.getProject().getLocation() + + "/images/" + imgPath).replace("file:", ""); + ((BMSImageFigure) figure).setImage(myPath); + } + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((BMSImageFigure) figure).setVisible(Boolean.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) + ((BMSImageFigure) figure) + .setAlpha(Integer.valueOf(value.toString())); + + } + + @Override + protected IFigure createEditFigure() { + IFigure figure = new BMSImageFigure(); + return figure; + } + + @Override + public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { + AbstractLibraryCommand command = null; + if (request.getAttributeTransferObject().getLibraryObject().getType() + .equals("image")) { + command = new LibraryImageCommand(); + } + return command; + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, + new ChangeAttributePolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractEditPart.java index c53ed10fb104fc3d4f36b646b3c4129803650026..5f2f63429dc48890984c66b8a0e1de3ccc9f8d90 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractEditPart.java @@ -1,349 +1,307 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map.Entry; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.draw2d.ButtonModel; -import org.eclipse.draw2d.ChangeEvent; -import org.eclipse.draw2d.ChangeListener; -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.NodeEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; -import de.bmotionstudio.gef.editor.model.Visualization; -import de.bmotionstudio.gef.editor.observer.IObserverListener; -import de.bmotionstudio.gef.editor.observer.Observer; - -public abstract class BMSAbstractEditPart extends AbstractGraphicalEditPart - implements PropertyChangeListener, IObserverListener, IAdaptable, - NodeEditPart { - - private final Cursor cursorHover = new Cursor(Display.getCurrent(), - SWT.CURSOR_HAND); - - protected ConnectionAnchor anchor; - - private ChangeListener changeListener = new ChangeListener() { - @Override - public void handleStateChanged(ChangeEvent event) { - if (getCastedModel().hasEvent(AttributeConstants.EVENT_MOUSECLICK)) { - if (event.getPropertyName().equals( - ButtonModel.MOUSEOVER_PROPERTY)) - getFigure().setCursor(cursorHover); - } - if (event.getPropertyName() - .equals(ButtonModel.PRESSED_PROPERTY)) { - AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); - if (f.getModel().isPressed()) - executeEvent(AttributeConstants.EVENT_MOUSECLICK); - } - } - }; - - private String[] layoutAttributes = { - BControlPropertyConstants.PROPERTY_LAYOUT, - BControlPropertyConstants.PROPERTY_LOCATION, - AttributeConstants.ATTRIBUTE_X, - AttributeConstants.ATTRIBUTE_Y, AttributeConstants.ATTRIBUTE_WIDTH, - AttributeConstants.ATTRIBUTE_HEIGHT }; - - public void activate() { - if (!isActive()) { - super.activate(); - ((BControl) getModel()).addPropertyChangeListener(this); - if (getFigure() instanceof AbstractBMotionFigure) { - AbstractBMotionFigure af = (AbstractBMotionFigure) getFigure(); - if (isRunning()) - af.addChangeListener(changeListener); - af.activateFigure(); - } - } - } - - public void deactivate() { - if (isActive()) { - super.deactivate(); - ((BControl) getModel()).removePropertyChangeListener(this); - if (getFigure() instanceof AbstractBMotionFigure) { - AbstractBMotionFigure af = (AbstractBMotionFigure) getFigure(); - if (isRunning()) - af.removeChangeListener(changeListener); - af.deactivateFigure(); - } - } - } - - protected abstract IFigure createEditFigure(); - - @Override - protected void createEditPolicies() { - if (isRunning()) - prepareRunPolicies(); - else - prepareEditPolicies(); - } - - protected abstract void prepareEditPolicies(); - - protected abstract void prepareRunPolicies(); - - protected Boolean isRunning() { - return ((BControl) getModel()).getVisualization().isRunning(); - } - - @Override - protected IFigure createFigure() { - final IFigure figure = createEditFigure(); - IFigure toolTipFigure = getToolTip(); - if (toolTipFigure != null) - figure.setToolTip(toolTipFigure); - if (figure instanceof AbstractBMotionFigure) { - AbstractBMotionFigure bmsFigure = (AbstractBMotionFigure) figure; - Boolean isRunning = isRunning(); - bmsFigure.setRunning(isRunning); - if (!isRunning) { - bmsFigure.setEnabled(false); - } - } - return figure; - } - - @Override - public void performRequest(Request req) { - if (!isRunning()) { - if (req.getType().equals(RequestConstants.REQ_OPEN)) { - try { - IWorkbenchPage page = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - page.showView(IPageLayout.ID_PROP_SHEET); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - } - } - - @Override - protected void refreshVisuals() { - IFigure figure = getFigure(); - BControl model = (BControl) getModel(); - for (Entry<String, AbstractAttribute> e : model.getAttributes() - .entrySet()) { - PropertyChangeEvent evt = new PropertyChangeEvent(model, - e.getKey(), null, e.getValue().getValue()); - refreshEditFigure(figure, model, evt); - } - refreshEditLayout(figure, model); - } - - public abstract void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent pEvent); - - protected void refreshEditLayout(IFigure figure, BControl control) { - if (!(control instanceof Visualization)) { - figure.setPreferredSize(control.getDimension()); - if (figure.getParent() != null) - figure.getParent().setConstraint(figure, - new Rectangle(control.getLayout())); - } - } - - @Override - public void propertyChange(final PropertyChangeEvent evt) { - final IFigure figure = (IFigure) getFigure(); - final BControl model = (BControl) getModel(); - String propName = evt.getPropertyName(); - - if (BControlPropertyConstants.SOURCE_CONNECTIONS.equals(propName)) { - refreshSourceConnections(); - } else if (BControlPropertyConstants.TARGET_CONNECTIONS - .equals(propName)) { - refreshTargetConnections(); - } - if (propName.equals(BControlPropertyConstants.PROPERTY_ADD_CHILD) - || propName - .equals(BControlPropertyConstants.PROPERTY_REMOVE_CHILD)) { - refreshChildren(); - } else if (Arrays.asList(layoutAttributes).contains(propName)) { - // Layout attribute - if (isRunning()) { - // Display.getDefault().asyncExec(new Runnable() { - // @Override - // public void run() { - refreshEditLayout(figure, model); - // } - // }); - } else { - refreshEditLayout(figure, model); - } - } else { - - // Custom attribute - if (isRunning()) { - // Display.getDefault().asyncExec(new Runnable() { - // @Override - // public void run() { - refreshEditFigure(figure, model, evt); - // } - // }); - } else { - refreshEditFigure(figure, model, evt); - } - } - } - - public List<BControl> getModelChildren() { - return new ArrayList<BControl>(); - } - - public void executeEvent(String event) { - getCastedModel().executeEvent(event); - } - - protected IFigure getToolTip() { - - Figure fig = new Figure(); - fig.setLayoutManager(new FlowLayout()); - - Collection<Observer> observerList = ((BControl) getModel()) - .getObservers().values(); - for (Observer observer : observerList) { - IFigure observerFigure = observer.getToolTip((BControl) getModel()); - if (observerFigure != null) { - fig.add(observerFigure); - } - } - - return fig; - - } - - @Override - public void addedObserver(BControl control, Observer observer) { - // Update Tooltip - getFigure().setToolTip(getToolTip()); - } - - @Override - public void removedObserver(BControl control) { - - } - - public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { - return null; - } - - protected BControl getCastedModel() { - return (BControl) getModel(); - } - - protected ConnectionAnchor getConnectionAnchor() { - if (anchor == null) { - anchor = new ChopboxAnchor(getFigure()); - } - return anchor; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections - * () - */ - protected List<?> getModelSourceConnections() { - return getCastedModel().getSourceConnections(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections - * () - */ - protected List<?> getModelTargetConnections() { - return getCastedModel().getTargetConnections(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef - * .ConnectionEditPart) - */ - public ConnectionAnchor getSourceConnectionAnchor( - ConnectionEditPart connection) { - return getConnectionAnchor(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef - * .Request) - */ - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - return getConnectionAnchor(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef - * .ConnectionEditPart) - */ - public ConnectionAnchor getTargetConnectionAnchor( - ConnectionEditPart connection) { - return getConnectionAnchor(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef - * .Request) - */ - public ConnectionAnchor getTargetConnectionAnchor(Request request) { - return getConnectionAnchor(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.draw2d.ButtonModel; +import org.eclipse.draw2d.ChangeEvent; +import org.eclipse.draw2d.ChangeListener; +import org.eclipse.draw2d.ChopboxAnchor; +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BControlPropertyConstants; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.observer.IObserverListener; +import de.bmotionstudio.gef.editor.observer.Observer; + +public abstract class BMSAbstractEditPart extends AbstractGraphicalEditPart + implements PropertyChangeListener, IObserverListener, IAdaptable, + NodeEditPart { + + private final Cursor cursorHover = new Cursor(Display.getCurrent(), + SWT.CURSOR_HAND); + + protected ConnectionAnchor anchor; + + private ChangeListener changeListener = new ChangeListener() { + @Override + public void handleStateChanged(ChangeEvent event) { + if (getCastedModel().hasEvent(AttributeConstants.EVENT_MOUSECLICK)) { + if (event.getPropertyName().equals( + ButtonModel.MOUSEOVER_PROPERTY)) + getFigure().setCursor(cursorHover); + } + if (event.getPropertyName() + .equals(ButtonModel.PRESSED_PROPERTY)) { + AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); + if (f.getModel().isPressed()) + executeEvent(AttributeConstants.EVENT_MOUSECLICK); + } + } + }; + + private String[] layoutAttributes = { + BControlPropertyConstants.PROPERTY_LAYOUT, + BControlPropertyConstants.PROPERTY_LOCATION, + AttributeConstants.ATTRIBUTE_X, + AttributeConstants.ATTRIBUTE_Y, AttributeConstants.ATTRIBUTE_WIDTH, + AttributeConstants.ATTRIBUTE_HEIGHT }; + + public void activate() { + if (!isActive()) { + super.activate(); + ((BControl) getModel()).addPropertyChangeListener(this); + if (getFigure() instanceof AbstractBMotionFigure) { + AbstractBMotionFigure af = (AbstractBMotionFigure) getFigure(); + if (isRunning()) + af.addChangeListener(changeListener); + af.activateFigure(); + } + } + } + + public void deactivate() { + if (isActive()) { + super.deactivate(); + ((BControl) getModel()).removePropertyChangeListener(this); + if (getFigure() instanceof AbstractBMotionFigure) { + AbstractBMotionFigure af = (AbstractBMotionFigure) getFigure(); + if (isRunning()) + af.removeChangeListener(changeListener); + af.deactivateFigure(); + } + } + } + + protected abstract IFigure createEditFigure(); + + @Override + protected void createEditPolicies() { + if (isRunning()) + prepareRunPolicies(); + else + prepareEditPolicies(); + } + + protected abstract void prepareEditPolicies(); + + protected abstract void prepareRunPolicies(); + + protected Boolean isRunning() { + return ((BControl) getModel()).getVisualization().isRunning(); + } + + @Override + protected IFigure createFigure() { + final IFigure figure = createEditFigure(); + IFigure toolTipFigure = getToolTip(); + if (toolTipFigure != null) + figure.setToolTip(toolTipFigure); + if (figure instanceof AbstractBMotionFigure) { + AbstractBMotionFigure bmsFigure = (AbstractBMotionFigure) figure; + Boolean isRunning = isRunning(); + bmsFigure.setRunning(isRunning); + if (!isRunning) { + bmsFigure.setEnabled(false); + } + } + return figure; + } + + @Override + public void performRequest(Request req) { + if (!isRunning()) { + if (req.getType().equals(RequestConstants.REQ_OPEN)) { + try { + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + page.showView(IPageLayout.ID_PROP_SHEET); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + } + } + + @Override + protected void refreshVisuals() { + IFigure figure = getFigure(); + BControl model = (BControl) getModel(); + for (Entry<String, AbstractAttribute> e : model.getAttributes() + .entrySet()) { + PropertyChangeEvent evt = new PropertyChangeEvent(model, + e.getKey(), null, e.getValue().getValue()); + refreshEditFigure(figure, model, evt); + } + refreshEditLayout(figure, model); + } + + public abstract void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent pEvent); + + protected void refreshEditLayout(IFigure figure, BControl control) { + if (!(control instanceof Visualization)) { + figure.setPreferredSize(control.getDimension()); + if (figure.getParent() != null) + figure.getParent().setConstraint(figure, + new Rectangle(control.getLayout())); + } + } + + @Override + public void propertyChange(final PropertyChangeEvent evt) { + final IFigure figure = (IFigure) getFigure(); + final BControl model = (BControl) getModel(); + String propName = evt.getPropertyName(); + + if (BControlPropertyConstants.SOURCE_CONNECTIONS.equals(propName)) { + refreshSourceConnections(); + } else if (BControlPropertyConstants.TARGET_CONNECTIONS + .equals(propName)) { + refreshTargetConnections(); + } + if (propName.equals(BControlPropertyConstants.PROPERTY_ADD_CHILD) + || propName + .equals(BControlPropertyConstants.PROPERTY_REMOVE_CHILD)) { + refreshChildren(); + } else if (Arrays.asList(layoutAttributes).contains(propName)) { + // Layout attribute + if (isRunning()) { + // Display.getDefault().asyncExec(new Runnable() { + // @Override + // public void run() { + refreshEditLayout(figure, model); + // } + // }); + } else { + refreshEditLayout(figure, model); + } + } else { + + // Custom attribute + if (isRunning()) { + // Display.getDefault().asyncExec(new Runnable() { + // @Override + // public void run() { + refreshEditFigure(figure, model, evt); + // } + // }); + } else { + refreshEditFigure(figure, model, evt); + } + } + } + + public List<BControl> getModelChildren() { + return new ArrayList<BControl>(); + } + + public void executeEvent(String event) { + getCastedModel().executeEvent(event); + } + + protected IFigure getToolTip() { + + Figure fig = new Figure(); + fig.setLayoutManager(new FlowLayout()); + + Collection<Observer> observerList = ((BControl) getModel()) + .getObservers().values(); + for (Observer observer : observerList) { + IFigure observerFigure = observer.getToolTip((BControl) getModel()); + if (observerFigure != null) { + fig.add(observerFigure); + } + } + + return fig; + + } + + @Override + public void addedObserver(BControl control, Observer observer) { + // Update Tooltip + getFigure().setToolTip(getToolTip()); + } + + @Override + public void removedObserver(BControl control) { + + } + + public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { + return null; + } + + protected BControl getCastedModel() { + return (BControl) getModel(); + } + + protected ConnectionAnchor getConnectionAnchor() { + if (anchor == null) { + anchor = new ChopboxAnchor(getFigure()); + } + return anchor; + } + + protected List<?> getModelSourceConnections() { + return getCastedModel().getSourceConnections(); + } + + protected List<?> getModelTargetConnections() { + return getCastedModel().getTargetConnections(); + } + + public ConnectionAnchor getSourceConnectionAnchor( + ConnectionEditPart connection) { + return getConnectionAnchor(); + } + + public ConnectionAnchor getSourceConnectionAnchor(Request request) { + return getConnectionAnchor(); + } + + public ConnectionAnchor getTargetConnectionAnchor( + ConnectionEditPart connection) { + return getConnectionAnchor(); + } + + public ConnectionAnchor getTargetConnectionAnchor(Request request) { + return getConnectionAnchor(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractTreeEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractTreeEditPart.java index 8c74cbf3ba53659ffa08ebc02633c9b672dfffe2..e8642f0eb1b728f9f19aff04f903d1af30267361 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractTreeEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSAbstractTreeEditPart.java @@ -1,15 +1,15 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import org.eclipse.gef.editparts.AbstractTreeEditPart; - -public abstract class BMSAbstractTreeEditPart extends AbstractTreeEditPart { - - - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import org.eclipse.gef.editparts.AbstractTreeEditPart; + +public abstract class BMSAbstractTreeEditPart extends AbstractTreeEditPart { + + + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSEditPartFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSEditPartFactory.java index 6c8852b5ac991853484358e154e17f135006c0c0..b4a1fef62af716d9b2f35a6aff5403ae305b0ee3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSEditPartFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSEditPartFactory.java @@ -1,53 +1,53 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class BMSEditPartFactory implements EditPartFactory { - - @Override - public EditPart createEditPart(EditPart context, Object model) { - - AbstractGraphicalEditPart part = null; - - BControl control = (BControl) model; - - if (control instanceof Visualization) { - part = new VisualizationPart(); - } else { - try { - IConfigurationElement configElement = BMotionEditorPlugin - .getControlServices().get(control.getType()); - if (configElement != null) { - IBControlService service = (IBControlService) configElement - .createExecutableExtension("service"); - part = service.createEditPart(); - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - - if (part != null) - part.setModel(control); - - // TODO: check if part == null - return part; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class BMSEditPartFactory implements EditPartFactory { + + @Override + public EditPart createEditPart(EditPart context, Object model) { + + AbstractGraphicalEditPart part = null; + + BControl control = (BControl) model; + + if (control instanceof Visualization) { + part = new VisualizationPart(); + } else { + try { + IConfigurationElement configElement = BMotionEditorPlugin + .getControlServices().get(control.getType()); + if (configElement != null) { + IBControlService service = (IBControlService) configElement + .createExecutableExtension("service"); + part = service.createEditPart(); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + if (part != null) + part.setModel(control); + + // TODO: check if part == null + return part; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java index 93336446419897fa1b4daac4bcc009057612fcdc..c068699f0cebde9c3c81cbb9b26c94d305a3f0f0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java @@ -1,58 +1,58 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.IBControlService; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Visualization; - -public class BMSTreeEditPartFactory implements EditPartFactory { - - public EditPart createEditPart(EditPart context, Object model) { - - BMSAbstractTreeEditPart part = null; - - if (model instanceof Visualization) { - part = new BControlTreeEditPart(); - } - else if (model instanceof BControl) { - - BControl control = (BControl) model; - - try { - IConfigurationElement configElement = BMotionEditorPlugin - .getControlServices().get(control.getType()); - if (configElement != null) { - IBControlService service = (IBControlService) configElement - .createExecutableExtension("service"); - part = service.createTreeEditPart(); - } - } catch (CoreException e) { - e.printStackTrace(); - } - - } - // else if (model instanceof Observer) { - // part = new ObserverTreeEditPart(); - // } else if (model instanceof ObserverRootVirtualTreeNode) { - // part = new ObserverRootTreeEditpart(); - // } - - if (part != null) - part.setModel(model); - - return part; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Visualization; + +public class BMSTreeEditPartFactory implements EditPartFactory { + + public EditPart createEditPart(EditPart context, Object model) { + + BMSAbstractTreeEditPart part = null; + + if (model instanceof Visualization) { + part = new BControlTreeEditPart(); + } + else if (model instanceof BControl) { + + BControl control = (BControl) model; + + try { + IConfigurationElement configElement = BMotionEditorPlugin + .getControlServices().get(control.getType()); + if (configElement != null) { + IBControlService service = (IBControlService) configElement + .createExecutableExtension("service"); + part = service.createTreeEditPart(); + } + } catch (CoreException e) { + e.printStackTrace(); + } + + } + // else if (model instanceof Observer) { + // part = new ObserverTreeEditPart(); + // } else if (model instanceof ObserverRootVirtualTreeNode) { + // part = new ObserverRootTreeEditpart(); + // } + + if (part != null) + part.setModel(model); + + return part; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BRadioButtonPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BRadioButtonPart.java index 9b0867db7d9d9cea4b5a4dc2a575e1311030b165..d26573d200f91ebd3d78652c6594274c0b213020 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BRadioButtonPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BRadioButtonPart.java @@ -1,170 +1,170 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.util.Collection; - -import org.eclipse.draw2d.ButtonModel; -import org.eclipse.draw2d.ChangeEvent; -import org.eclipse.draw2d.ChangeListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.ButtonGroupHelper; -import de.bmotionstudio.gef.editor.ImageRegistry; -import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; -import de.bmotionstudio.gef.editor.edit.TextEditManager; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; -import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; -import de.bmotionstudio.gef.editor.figure.RadioButtonFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BRadioButtonPart extends BMSAbstractEditPart { - - private ChangeListener changeListener = new ChangeListener() { - @Override - public void handleStateChanged(ChangeEvent event) { - - if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { - - BControl control = (BControl) getModel(); - - // Recheck observer after click - control.getVisualization().getAnimation().checkObserver(); - - // Set correct image of Radiobutton - String btgroupid = control.getAttributeValue( - AttributeConstants.ATTRIBUTE_BUTTONGROUP).toString(); - if (!btgroupid.trim().equals("")) { - Collection<BControl> btGroup = ButtonGroupHelper - .getButtonGroup(btgroupid); - for (BControl c : btGroup) { - c.setAttributeValue( - AttributeConstants.ATTRIBUTE_CHECKED, false); - } - } - control.setAttributeValue(AttributeConstants.ATTRIBUTE_CHECKED, - true); - - } - - } - - }; - - @Override - public void activate() { - super.activate(); - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .addChangeListener(changeListener); - } - } - - @Override - public void deactivate() { - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .removeChangeListener(changeListener); - } - super.deactivate(); - } - - @Override - protected IFigure createEditFigure() { - RadioButtonFigure fig = new RadioButtonFigure(); - return fig; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent pEvent) { - - Object value = pEvent.getNewValue(); - String aID = pEvent.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((RadioButtonFigure) figure).setVisible(Boolean.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_CHECKED)) { - Boolean bol = Boolean.valueOf(value.toString()); - if (bol) { - ((RadioButtonFigure) figure).setImage(BMotionStudioImage - .getImage(ImageRegistry.IMG_RADIOBUTTON_CHECKED)); - } else { - ((RadioButtonFigure) figure).setImage(BMotionStudioImage - .getImage(ImageRegistry.IMG_RADIOBUTTON_UNCHECKED)); - } - - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) { - int addWidth = ((RadioButtonFigure) figure).setText(value - .toString()); - ((BControl) getModel()).setAttributeValue( - AttributeConstants.ATTRIBUTE_WIDTH, (30 + addWidth)); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) { - RGB rgbText = (RGB) value; - ((RadioButtonFigure) figure).setTextColor(rgbText); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_BUTTONGROUP)) { - String btgroup = value.toString(); - if (!btgroup.trim().equals("")) { - ButtonGroupHelper.addToButtonGroup(btgroup, - (BControl) getModel()); - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) - ((RadioButtonFigure) figure).setBtEnabled(Boolean.valueOf(value - .toString())); - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - - private void performDirectEdit() { - new TextEditManager(this, new TextCellEditorLocator( - (IFigure) getFigure())).show(); - } - - @Override - public void performRequest(Request request) { - super.performRequest(request); - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT - && !isRunning()) - performDirectEdit(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.util.Collection; + +import org.eclipse.draw2d.ButtonModel; +import org.eclipse.draw2d.ChangeEvent; +import org.eclipse.draw2d.ChangeListener; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.ButtonGroupHelper; +import de.bmotionstudio.gef.editor.ImageRegistry; +import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; +import de.bmotionstudio.gef.editor.edit.TextEditManager; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; +import de.bmotionstudio.gef.editor.figure.RadioButtonFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BRadioButtonPart extends BMSAbstractEditPart { + + private ChangeListener changeListener = new ChangeListener() { + @Override + public void handleStateChanged(ChangeEvent event) { + + if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { + + BControl control = (BControl) getModel(); + + // Recheck observer after click + control.getVisualization().getAnimation().checkObserver(); + + // Set correct image of Radiobutton + String btgroupid = control.getAttributeValue( + AttributeConstants.ATTRIBUTE_BUTTONGROUP).toString(); + if (!btgroupid.trim().equals("")) { + Collection<BControl> btGroup = ButtonGroupHelper + .getButtonGroup(btgroupid); + for (BControl c : btGroup) { + c.setAttributeValue( + AttributeConstants.ATTRIBUTE_CHECKED, false); + } + } + control.setAttributeValue(AttributeConstants.ATTRIBUTE_CHECKED, + true); + + } + + } + + }; + + @Override + public void activate() { + super.activate(); + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .addChangeListener(changeListener); + } + } + + @Override + public void deactivate() { + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .removeChangeListener(changeListener); + } + super.deactivate(); + } + + @Override + protected IFigure createEditFigure() { + RadioButtonFigure fig = new RadioButtonFigure(); + return fig; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent pEvent) { + + Object value = pEvent.getNewValue(); + String aID = pEvent.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((RadioButtonFigure) figure).setVisible(Boolean.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_CHECKED)) { + Boolean bol = Boolean.valueOf(value.toString()); + if (bol) { + ((RadioButtonFigure) figure).setImage(BMotionStudioImage + .getImage(ImageRegistry.IMG_RADIOBUTTON_CHECKED)); + } else { + ((RadioButtonFigure) figure).setImage(BMotionStudioImage + .getImage(ImageRegistry.IMG_RADIOBUTTON_UNCHECKED)); + } + + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) { + int addWidth = ((RadioButtonFigure) figure).setText(value + .toString()); + ((BControl) getModel()).setAttributeValue( + AttributeConstants.ATTRIBUTE_WIDTH, (30 + addWidth)); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) { + RGB rgbText = (RGB) value; + ((RadioButtonFigure) figure).setTextColor(rgbText); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_BUTTONGROUP)) { + String btgroup = value.toString(); + if (!btgroup.trim().equals("")) { + ButtonGroupHelper.addToButtonGroup(btgroup, + (BControl) getModel()); + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_ENABLED)) + ((RadioButtonFigure) figure).setBtEnabled(Boolean.valueOf(value + .toString())); + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + + private void performDirectEdit() { + new TextEditManager(this, new TextCellEditorLocator( + (IFigure) getFigure())).show(); + } + + @Override + public void performRequest(Request request) { + super.performRequest(request); + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT + && !isRunning()) + performDirectEdit(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BShapePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BShapePart.java index 5e97a73882713c938828717c9839f98b1d6b968c..2ebe542ab28a53ca080fd4b0407fc2a2869efd22 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BShapePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BShapePart.java @@ -1,129 +1,129 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.io.File; - -import org.eclipse.core.resources.IFile; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.figure.ShapeFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BShapePart extends BMSAbstractEditPart { - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((ShapeFigure) figure).setBackgroundColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) - ((ShapeFigure) figure).setForegroundColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) - ((ShapeFigure) figure).setAlpha(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_OUTLINEALPHA)) - ((ShapeFigure) figure) - .setOutlineAlpha(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((ShapeFigure) figure).setVisible(Boolean.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_SHAPE)) - ((ShapeFigure) figure).setShape(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_ORIENTATION)) - ((ShapeFigure) figure).setOrientation(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FILLTYPE)) - ((ShapeFigure) figure).setFillType(Integer.valueOf(value.toString())); - - // /** North */ - // int NORTH = 1; - // /** South */ - // int SOUTH = 4; - // /** West */ - // int WEST = 8; - // /** East */ - // int EAST = 16; - - if (aID.equals(AttributeConstants.ATTRIBUTE_DIRECTION)) { - - int direction = Integer.valueOf(value.toString()); - int fval = 1; - - switch (direction) { - case 0: - fval = 1; - break; - case 1: - fval = 4; - break; - case 2: - fval = 8; - break; - case 3: - fval = 16; - break; - default: - break; - } - - ((ShapeFigure) figure).setDirection(fval); - - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { - Image img = null; - if (value != null) { - String imgPath = value.toString(); - if (imgPath.length() > 0) { - IFile pFile = model.getVisualization().getProjectFile(); - String myPath = (pFile.getProject().getLocation() - + "/images/" + imgPath).replace("file:", ""); - if (new File(myPath).exists()) { - img = new Image(Display.getDefault(), myPath); - } - } - } - ((ShapeFigure) figure).setImage(img); - } - - } - - @Override - protected IFigure createEditFigure() { - IFigure figure = new ShapeFigure(); - return figure; - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.io.File; + +import org.eclipse.core.resources.IFile; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.figure.ShapeFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BShapePart extends BMSAbstractEditPart { + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((ShapeFigure) figure).setBackgroundColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) + ((ShapeFigure) figure).setForegroundColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) + ((ShapeFigure) figure).setAlpha(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_OUTLINEALPHA)) + ((ShapeFigure) figure) + .setOutlineAlpha(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((ShapeFigure) figure).setVisible(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_SHAPE)) + ((ShapeFigure) figure).setShape(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ORIENTATION)) + ((ShapeFigure) figure).setOrientation(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FILLTYPE)) + ((ShapeFigure) figure).setFillType(Integer.valueOf(value.toString())); + + // /** North */ + // int NORTH = 1; + // /** South */ + // int SOUTH = 4; + // /** West */ + // int WEST = 8; + // /** East */ + // int EAST = 16; + + if (aID.equals(AttributeConstants.ATTRIBUTE_DIRECTION)) { + + int direction = Integer.valueOf(value.toString()); + int fval = 1; + + switch (direction) { + case 0: + fval = 1; + break; + case 1: + fval = 4; + break; + case 2: + fval = 8; + break; + case 3: + fval = 16; + break; + default: + break; + } + + ((ShapeFigure) figure).setDirection(fval); + + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_IMAGE)) { + Image img = null; + if (value != null) { + String imgPath = value.toString(); + if (imgPath.length() > 0) { + IFile pFile = model.getVisualization().getProjectFile(); + String myPath = (pFile.getProject().getLocation() + + "/images/" + imgPath).replace("file:", ""); + if (new File(myPath).exists()) { + img = new Image(Display.getDefault(), myPath); + } + } + } + ((ShapeFigure) figure).setImage(img); + } + + } + + @Override + protected IFigure createEditFigure() { + IFigure figure = new ShapeFigure(); + return figure; + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextPart.java index a59b89627e53a5def9f9eea44af649a8624450ba..3dd4e4b288f22e54eb5399994976b9806155135e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextPart.java @@ -1,114 +1,114 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; -import de.bmotionstudio.gef.editor.edit.TextEditManager; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; -import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; -import de.bmotionstudio.gef.editor.figure.TextFigure; -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BTextPart extends BMSAbstractEditPart { - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) - ((TextFigure) figure).setText(value.toString()); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((TextFigure) figure) - .setBackgroundColor(new org.eclipse.swt.graphics.Color( - Display.getDefault(), (RGB) value)); - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) - ((TextFigure) figure).setTextColor(((RGB) value)); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FONT)) - ((TextFigure) figure).setFont((value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_VISIBLE)) - ((TextFigure) figure).setBackgroundVisible(Boolean.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((TextFigure) figure).setVisible(Boolean.valueOf(value.toString())); - - } - - @Override - protected IFigure createEditFigure() { - IFigure figure = new TextFigure(); - return figure; - } - - private void performDirectEdit() { - new TextEditManager(this, new TextCellEditorLocator( - (IFigure) getFigure())).show(); - } - - @Override - public void performRequest(Request request) { - super.performRequest(request); - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) - performDirectEdit(); - } - - // @Override - // public String getValueOfData() { - // return ((BControl) getModel()).getAttributeValue( - // AttributeConstants.ATTRIBUTE_CUSTOM).toString(); - // } - - @Override - public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { - AbstractLibraryCommand command = null; - if (request.getAttributeTransferObject().getLibraryObject().getType() - .equals("variable")) { - command = new LibraryVariableCommand(); - } - return command; - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, - new ChangeAttributePolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; +import de.bmotionstudio.gef.editor.edit.TextEditManager; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; +import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; +import de.bmotionstudio.gef.editor.figure.TextFigure; +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BTextPart extends BMSAbstractEditPart { + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) + ((TextFigure) figure).setText(value.toString()); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((TextFigure) figure) + .setBackgroundColor(new org.eclipse.swt.graphics.Color( + Display.getDefault(), (RGB) value)); + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT_COLOR)) + ((TextFigure) figure).setTextColor(((RGB) value)); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FONT)) + ((TextFigure) figure).setFont((value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_VISIBLE)) + ((TextFigure) figure).setBackgroundVisible(Boolean.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((TextFigure) figure).setVisible(Boolean.valueOf(value.toString())); + + } + + @Override + protected IFigure createEditFigure() { + IFigure figure = new TextFigure(); + return figure; + } + + private void performDirectEdit() { + new TextEditManager(this, new TextCellEditorLocator( + (IFigure) getFigure())).show(); + } + + @Override + public void performRequest(Request request) { + super.performRequest(request); + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) + performDirectEdit(); + } + + // @Override + // public String getValueOfData() { + // return ((BControl) getModel()).getAttributeValue( + // AttributeConstants.ATTRIBUTE_CUSTOM).toString(); + // } + + @Override + public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { + AbstractLibraryCommand command = null; + if (request.getAttributeTransferObject().getLibraryObject().getType() + .equals("variable")) { + command = new LibraryVariableCommand(); + } + return command; + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, + new ChangeAttributePolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextfieldPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextfieldPart.java index 4fd7368bc17af1fe9cb6057adfd98725c9a4acf8..49b0d6eee4058721acfb96b5ae2f8681ca485f61 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextfieldPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTextfieldPart.java @@ -1,128 +1,128 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.ButtonModel; -import org.eclipse.draw2d.ChangeEvent; -import org.eclipse.draw2d.ChangeListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; -import de.bmotionstudio.gef.editor.edit.TextEditManager; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; -import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; -import de.bmotionstudio.gef.editor.figure.TextfieldFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class BTextfieldPart extends BMSAbstractEditPart { - - private TextEditManager textEditManager; - - private ChangeListener changeListener = new ChangeListener() { - @Override - public void handleStateChanged(ChangeEvent event) { - if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { - AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); - if (f.getModel().isPressed()) { - if (textEditManager == null) - textEditManager = new TextEditManager( - BTextfieldPart.this, new TextCellEditorLocator( - (IFigure) getFigure())) { - @Override - protected void bringDown() { - super.bringDown(); - ((BControl) getModel()).getVisualization() - .getAnimation().checkObserver(); - } - - }; - textEditManager.show(); - } - } - } - }; - - @Override - protected IFigure createEditFigure() { - TextfieldFigure figure = new TextfieldFigure(); - return figure; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) - ((TextfieldFigure) figure).setText(value.toString()); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((TextfieldFigure) figure).setVisible(Boolean.valueOf(value - .toString())); - - } - - private void performDirectEdit() { - new TextEditManager(BTextfieldPart.this, new TextCellEditorLocator( - (IFigure) getFigure())).show(); - } - - @Override - public void performRequest(Request request) { - super.performRequest(request); - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) - performDirectEdit(); - } - - @Override - public void activate() { - super.activate(); - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .addChangeListener(changeListener); - } - } - - @Override - public void deactivate() { - if (isRunning()) { - if (getFigure() instanceof AbstractBMotionFigure) - ((AbstractBMotionFigure) getFigure()) - .removeChangeListener(changeListener); - } - super.deactivate(); - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new CustomDirectEditPolicy()); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.ButtonModel; +import org.eclipse.draw2d.ChangeEvent; +import org.eclipse.draw2d.ChangeListener; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.edit.TextCellEditorLocator; +import de.bmotionstudio.gef.editor.edit.TextEditManager; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.CustomDirectEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.RenamePolicy; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; +import de.bmotionstudio.gef.editor.figure.TextfieldFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class BTextfieldPart extends BMSAbstractEditPart { + + private TextEditManager textEditManager; + + private ChangeListener changeListener = new ChangeListener() { + @Override + public void handleStateChanged(ChangeEvent event) { + if (event.getPropertyName().equals(ButtonModel.PRESSED_PROPERTY)) { + AbstractBMotionFigure f = (AbstractBMotionFigure) getFigure(); + if (f.getModel().isPressed()) { + if (textEditManager == null) + textEditManager = new TextEditManager( + BTextfieldPart.this, new TextCellEditorLocator( + (IFigure) getFigure())) { + @Override + protected void bringDown() { + super.bringDown(); + ((BControl) getModel()).getVisualization() + .getAnimation().checkObserver(); + } + + }; + textEditManager.show(); + } + } + } + }; + + @Override + protected IFigure createEditFigure() { + TextfieldFigure figure = new TextfieldFigure(); + return figure; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_TEXT)) + ((TextfieldFigure) figure).setText(value.toString()); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((TextfieldFigure) figure).setVisible(Boolean.valueOf(value + .toString())); + + } + + private void performDirectEdit() { + new TextEditManager(BTextfieldPart.this, new TextCellEditorLocator( + (IFigure) getFigure())).show(); + } + + @Override + public void performRequest(Request request) { + super.performRequest(request); + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) + performDirectEdit(); + } + + @Override + public void activate() { + super.activate(); + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .addChangeListener(changeListener); + } + } + + @Override + public void deactivate() { + if (isRunning()) { + if (getFigure() instanceof AbstractBMotionFigure) + ((AbstractBMotionFigure) getFigure()) + .removeChangeListener(changeListener); + } + super.deactivate(); + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, + new CustomDirectEditPolicy()); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/LightPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/LightPart.java index 4cc06fcd35e328729d3e80993d3dba88bc258127..ae9b4ba62b71cdf3676d86f0573cf3a421a5af47 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/LightPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/LightPart.java @@ -1,48 +1,48 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.figure.LightFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class LightPart extends BMSAbstractEditPart { - - @Override - protected IFigure createEditFigure() { - return new LightFigure(); - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((LightFigure) figure).setBackgroundColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((LightFigure) figure) - .setVisible(Boolean.valueOf(value.toString())); - - } - - @Override - protected void prepareEditPolicies() { - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.figure.LightFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class LightPart extends BMSAbstractEditPart { + + @Override + protected IFigure createEditFigure() { + return new LightFigure(); + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((LightFigure) figure).setBackgroundColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((LightFigure) figure) + .setVisible(Boolean.valueOf(value.toString())); + + } + + @Override + protected void prepareEditPolicies() { + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SignalPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SignalPart.java index 0a0560acabb64bd8b8e7130e6055082731fd930f..3147041ae3cc6f27304ce908e89d4435d66b01d0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SignalPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SignalPart.java @@ -1,115 +1,115 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPolicy; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.command.CreateCommand; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.SignalLayoutEditPolicy; -import de.bmotionstudio.gef.editor.figure.SignalFigure; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Light; - -public class SignalPart extends BMSAbstractEditPart { - - @Override - protected IFigure createEditFigure() { - return new SignalFigure(); - } - - @Override - protected void refreshEditLayout(IFigure figure, BControl control) { - - int lights = Integer.valueOf(control.getAttributeValue( - AttributeConstants.ATTRIBUTE_LIGHTS).toString()); - - // Set the correct size of the table - figure.getParent().setConstraint( - figure, - new Rectangle(control.getLocation().x, control.getLocation().y, - control.getDimension().width, lights * 12 + 30)); - - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - Object oldValue = evt.getOldValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_LIGHTS)) { - - if (oldValue == null || value.equals(oldValue)) - return; - - // Create lights - Integer numberOfLights = Integer.valueOf(value.toString()); - Integer numberOfCurrentLights = Integer - .valueOf(oldValue.toString()); - - if (numberOfLights < numberOfCurrentLights) { - for (int i = numberOfCurrentLights - 1; i >= numberOfLights; i--) { - model.removeChild(i); - } - } - - for (int i = numberOfCurrentLights; i < numberOfLights; i++) { - Light light = new Light(model.getVisualization()); - CreateCommand cmd = new CreateCommand(light, model); - cmd.execute(); - } - - refreshEditLayout(figure, model); - - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_LABEL)) { - ((SignalFigure) getFigure()).setLabel(value.toString()); - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_TRACK_DIRECTION)) { - int direction = Integer.valueOf(value.toString()); - if (direction == 1) { - ((SignalFigure) getFigure()).setTrackDirection(false); - } else { - ((SignalFigure) getFigure()).setTrackDirection(true); - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((SignalFigure) figure) - .setVisible(Boolean.valueOf(value.toString())); - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.LAYOUT_ROLE, new SignalLayoutEditPolicy()); - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - - @Override - public List<BControl> getModelChildren() { - return ((BControl) getModel()).getChildrenArray(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditPolicy; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.command.CreateCommand; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.SignalLayoutEditPolicy; +import de.bmotionstudio.gef.editor.figure.SignalFigure; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Light; + +public class SignalPart extends BMSAbstractEditPart { + + @Override + protected IFigure createEditFigure() { + return new SignalFigure(); + } + + @Override + protected void refreshEditLayout(IFigure figure, BControl control) { + + int lights = Integer.valueOf(control.getAttributeValue( + AttributeConstants.ATTRIBUTE_LIGHTS).toString()); + + // Set the correct size of the table + figure.getParent().setConstraint( + figure, + new Rectangle(control.getLocation().x, control.getLocation().y, + control.getDimension().width, lights * 12 + 30)); + + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + Object oldValue = evt.getOldValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_LIGHTS)) { + + if (oldValue == null || value.equals(oldValue)) + return; + + // Create lights + Integer numberOfLights = Integer.valueOf(value.toString()); + Integer numberOfCurrentLights = Integer + .valueOf(oldValue.toString()); + + if (numberOfLights < numberOfCurrentLights) { + for (int i = numberOfCurrentLights - 1; i >= numberOfLights; i--) { + model.removeChild(i); + } + } + + for (int i = numberOfCurrentLights; i < numberOfLights; i++) { + Light light = new Light(model.getVisualization()); + CreateCommand cmd = new CreateCommand(light, model); + cmd.execute(); + } + + refreshEditLayout(figure, model); + + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_LABEL)) { + ((SignalFigure) getFigure()).setLabel(value.toString()); + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_TRACK_DIRECTION)) { + int direction = Integer.valueOf(value.toString()); + if (direction == 1) { + ((SignalFigure) getFigure()).setTrackDirection(false); + } else { + ((SignalFigure) getFigure()).setTrackDirection(true); + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((SignalFigure) figure) + .setVisible(Boolean.valueOf(value.toString())); + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.LAYOUT_ROLE, new SignalLayoutEditPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + + @Override + public List<BControl> getModelChildren() { + return ((BControl) getModel()).getChildrenArray(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java index c9473deecd38bc09de24e1bd525567323d31795e..16b1ca4f5e10486c6a56b6fa03f81d1c9f0646da 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java @@ -1,163 +1,163 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPolicy; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection; -import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.figure.SwitchFigure; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.model.Switch; -import de.bmotionstudio.gef.editor.model.Track; - -public class SwitchPart extends BMSAbstractEditPart { - - @Override - protected IFigure createEditFigure() { - return new SwitchFigure(); - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - Switch sw = (Switch) model; - - Track track1 = sw.getTrack1(); - Track track2 = sw.getTrack2(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_POSITION)) { - if (track1 != null && track2 != null) { - track1.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE, - true); - track2.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE, - true); - if (value.equals(AttributeSwitchPosition.LEFT)) { - track1.setAttributeValue( - AttributeConstants.ATTRIBUTE_VISIBLE, false); - } else if (value.equals(AttributeSwitchPosition.RIGHT)) { - track2.setAttributeValue( - AttributeConstants.ATTRIBUTE_VISIBLE, false); - } - } - } - - if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION)) - refreshEditLayout(figure, model); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) { - if (track1 != null && track2 != null) { - Boolean visible = Boolean.valueOf(value.toString()); - ((SwitchFigure) figure).setVisible(visible); - track1.setAttributeValue( - AttributeConstants.ATTRIBUTE_VISIBLE, visible); - track2.setAttributeValue( - AttributeConstants.ATTRIBUTE_VISIBLE, visible); - } - } - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - - @Override - public List<BControl> getModelChildren() { - return ((BControl) getModel()).getChildrenArray(); - } - - @Override - protected void refreshEditLayout(IFigure figure, BControl control) { - - int width = control.getDimension().width; - int height = control.getDimension().height; - - List<BControl> trackNodes = control.getChildrenArray(); - - int dir = Integer.valueOf(((BControl) getModel()).getAttributeValue( - AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION).toString()); - - Point pt = new Point(); - - for (BControl trackNode : trackNodes) { - - switch (Integer.valueOf(trackNode.getAttributeValue( - AttributeConstants.ATTRIBUTE_CUSTOM).toString())) { - case 1: // top left (1) - if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { - pt.y = 0; - pt.x = 5; - } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { - pt.y = 0; - pt.x = width - 25; - } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { - pt.y = height - 20; - pt.x = 5; - } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { - pt.y = height - 20; - pt.x = width - 25; - } - break; - case 2: // top right (2) - if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { - pt.y = 0; - pt.x = width - 25; - } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { - pt.y = 0; - pt.x = 5; - } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { - pt.y = 0; - pt.x = width - 25; - } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { - pt.y = 0; - pt.x = 5; - } - break; - case 3: // left right (3) - if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { - pt.y = height - 20; - pt.x = width - 25; - } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { - pt.y = height - 20; - pt.x = 5; - } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { - pt.y = height - 20; - pt.x = width - 25; - } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { - pt.y = height - 20; - pt.x = 5; - } - break; - default: - break; - } - - trackNode.setAttributeValue(AttributeConstants.ATTRIBUTE_X, pt.x); - trackNode.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, pt.y); - - } - - super.refreshEditLayout(figure, control); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.EditPolicy; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection; +import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.figure.SwitchFigure; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.Switch; +import de.bmotionstudio.gef.editor.model.Track; + +public class SwitchPart extends BMSAbstractEditPart { + + @Override + protected IFigure createEditFigure() { + return new SwitchFigure(); + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + Switch sw = (Switch) model; + + Track track1 = sw.getTrack1(); + Track track2 = sw.getTrack2(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_POSITION)) { + if (track1 != null && track2 != null) { + track1.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE, + true); + track2.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE, + true); + if (value.equals(AttributeSwitchPosition.LEFT)) { + track1.setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, false); + } else if (value.equals(AttributeSwitchPosition.RIGHT)) { + track2.setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, false); + } + } + } + + if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION)) + refreshEditLayout(figure, model); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) { + if (track1 != null && track2 != null) { + Boolean visible = Boolean.valueOf(value.toString()); + ((SwitchFigure) figure).setVisible(visible); + track1.setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, visible); + track2.setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, visible); + } + } + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + + @Override + public List<BControl> getModelChildren() { + return ((BControl) getModel()).getChildrenArray(); + } + + @Override + protected void refreshEditLayout(IFigure figure, BControl control) { + + int width = control.getDimension().width; + int height = control.getDimension().height; + + List<BControl> trackNodes = control.getChildrenArray(); + + int dir = Integer.valueOf(((BControl) getModel()).getAttributeValue( + AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION).toString()); + + Point pt = new Point(); + + for (BControl trackNode : trackNodes) { + + switch (Integer.valueOf(trackNode.getAttributeValue( + AttributeConstants.ATTRIBUTE_CUSTOM).toString())) { + case 1: // top left (1) + if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { + pt.y = 0; + pt.x = 5; + } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { + pt.y = 0; + pt.x = width - 25; + } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { + pt.y = height - 20; + pt.x = 5; + } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { + pt.y = height - 20; + pt.x = width - 25; + } + break; + case 2: // top right (2) + if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { + pt.y = 0; + pt.x = width - 25; + } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { + pt.y = 0; + pt.x = 5; + } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { + pt.y = 0; + pt.x = width - 25; + } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { + pt.y = 0; + pt.x = 5; + } + break; + case 3: // left right (3) + if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { + pt.y = height - 20; + pt.x = width - 25; + } else if (dir == AttributeSwitchDirection.LEFT_SOUTH) { + pt.y = height - 20; + pt.x = 5; + } else if (dir == AttributeSwitchDirection.RIGHT_NORTH) { + pt.y = height - 20; + pt.x = width - 25; + } else if (dir == AttributeSwitchDirection.LEFT_NORTH) { + pt.y = height - 20; + pt.x = 5; + } + break; + default: + break; + } + + trackNode.setAttributeValue(AttributeConstants.ATTRIBUTE_X, pt.x); + trackNode.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, pt.y); + + } + + super.refreshEditLayout(figure, control); + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java index 6dba32eb15b1fe97cafa0e19c17bc34787dacfff..5502b3af5e9845bccc39ba6f7d6dd5413f0ba600 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java @@ -1,77 +1,77 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.swt.graphics.RGB; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.figure.TankFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class TankPart extends BMSAbstractEditPart { - - @Override - protected IFigure createEditFigure() { - return new TankFigure(); - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((TankFigure) figure).setVisible(Boolean.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) - ((TankFigure) figure).setAlpha(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_COLOR)) - ((TankFigure) figure).setFillColor((RGB) value); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_HEIGHT)) - ((TankFigure) figure).setFillHeight(Integer.valueOf(value - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS)) - ((TankFigure) figure).setMaxPos(Integer.valueOf(model - .getAttributeValue( - AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS) - .toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_INTERVAL)) - ((TankFigure) figure) - .setInterval(Integer.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_SHOWS_MEASURE)) - ((TankFigure) figure).setMeasure(Boolean.valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) - ((TankFigure) figure).setBackgroundColor((RGB) value); - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new BMSConnectionEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.swt.graphics.RGB; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSConnectionEditPolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.figure.TankFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class TankPart extends BMSAbstractEditPart { + + @Override + protected IFigure createEditFigure() { + return new TankFigure(); + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((TankFigure) figure).setVisible(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) + ((TankFigure) figure).setAlpha(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_COLOR)) + ((TankFigure) figure).setFillColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_HEIGHT)) + ((TankFigure) figure).setFillHeight(Integer.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS)) + ((TankFigure) figure).setMaxPos(Integer.valueOf(model + .getAttributeValue( + AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS) + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_INTERVAL)) + ((TankFigure) figure) + .setInterval(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_SHOWS_MEASURE)) + ((TankFigure) figure).setMeasure(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((TankFigure) figure).setBackgroundColor((RGB) value); + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, + new BMSConnectionEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java index 061329b32eb959dbdeb7f19bb6e33b25535b0397..56fd38fb4ac1975d81dd0e614674f8c7282e092a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java @@ -1,67 +1,67 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.TrackEditPolicy; -import de.bmotionstudio.gef.editor.figure.TrackNodeFigure; -import de.bmotionstudio.gef.editor.model.BControl; - -public class TrackNodePart extends BMSAbstractEditPart { - - protected Color foregroundColor; - - @Override - protected IFigure createEditFigure() { - return new TrackNodeFigure(); - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_LINEWIDTH)) - ((TrackNodeFigure) getFigure()).setLineWidth(Integer - .valueOf(value.toString())); - - if (aID.equals(AttributeConstants.ATTRIBUTE_LINESTYLE)) - ((TrackNodeFigure) getFigure()).setLineStyle((Integer - .valueOf(value.toString()) + 1)); - - if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) { - if (foregroundColor != null) - foregroundColor.dispose(); - foregroundColor = new Color(Display.getDefault(), (RGB) value); - ((TrackNodeFigure) getFigure()) - .setForegroundColor(foregroundColor); - } - - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new TrackEditPolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPolicy; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.TrackEditPolicy; +import de.bmotionstudio.gef.editor.figure.TrackNodeFigure; +import de.bmotionstudio.gef.editor.model.BControl; + +public class TrackNodePart extends BMSAbstractEditPart { + + protected Color foregroundColor; + + @Override + protected IFigure createEditFigure() { + return new TrackNodeFigure(); + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_LINEWIDTH)) + ((TrackNodeFigure) getFigure()).setLineWidth(Integer + .valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_LINESTYLE)) + ((TrackNodeFigure) getFigure()).setLineStyle((Integer + .valueOf(value.toString()) + 1)); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR)) { + if (foregroundColor != null) + foregroundColor.dispose(); + foregroundColor = new Color(Display.getDefault(), (RGB) value); + ((TrackNodeFigure) getFigure()) + .setForegroundColor(foregroundColor); + } + + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new TrackEditPolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java index 270aa4896010e43ea47791db5781ebbcc4fc6ffc..d8c5df4ea309778f38c98032d207cb03a654e5de 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java @@ -1,94 +1,94 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ConnectionEditPolicy; -import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; -import org.eclipse.gef.requests.GroupRequest; - -import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand; -import de.bmotionstudio.gef.editor.model.Track; - -public class TrackPart extends BConnectionEditPart { - - @Override - protected void prepareEditPolicies() { - // Selection handle edit policy. - // Makes the connection show a feedback, when selected by the user. - installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, - new ConnectionEndpointEditPolicy()); // Allows the removal of - // the connection model - // element - installEditPolicy(EditPolicy.CONNECTION_ROLE, - new ConnectionEditPolicy() { - protected Command getDeleteCommand(GroupRequest request) { - return new ConnectionDeleteCommand((Track) getModel()); - } - }); - } - - @Override - protected ConnectionAnchor getSourceConnectionAnchor() { - if (getSource() != null) { - IFigure f = ((GraphicalEditPart) getSource()).getFigure(); - return new ChopboxAnchor(f) { - @Override - public Point getLocation(Point reference) { - Rectangle r = Rectangle.SINGLETON; - r.setBounds(getBox()); - r.translate(-1, -1); - r.resize(1, 1); - getOwner().translateToAbsolute(r); - float centerX = r.x + 0.5f * r.width; - float centerY = r.y + 0.5f * r.height; - if (r.isEmpty() - || (reference.x == (int) centerX && reference.y == (int) centerY)) - return new Point((int) centerX, (int) centerY); // This - // avoids - // divide-by-zero - return new Point(Math.round(centerX), Math.round(centerY)); - } - }; - } - return DEFAULT_SOURCE_ANCHOR; - } - - @Override - protected ConnectionAnchor getTargetConnectionAnchor() { - if (getTarget() != null) { - IFigure f = ((GraphicalEditPart) getTarget()).getFigure(); - return new ChopboxAnchor(f) { - @Override - public Point getLocation(Point reference) { - Rectangle r = Rectangle.SINGLETON; - r.setBounds(getBox()); - r.translate(-1, -1); - r.resize(1, 1); - getOwner().translateToAbsolute(r); - float centerX = r.x + 0.5f * r.width; - float centerY = r.y + 0.5f * r.height; - if (r.isEmpty() - || (reference.x == (int) centerX && reference.y == (int) centerY)) - return new Point((int) centerX, (int) centerY); // This - // avoids - // divide-by-zero - return new Point(Math.round(centerX), Math.round(centerY)); - } - }; - } - return DEFAULT_TARGET_ANCHOR; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import org.eclipse.draw2d.ChopboxAnchor; +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.ConnectionEditPolicy; +import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; +import org.eclipse.gef.requests.GroupRequest; + +import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand; +import de.bmotionstudio.gef.editor.model.Track; + +public class TrackPart extends BConnectionEditPart { + + @Override + protected void prepareEditPolicies() { + // Selection handle edit policy. + // Makes the connection show a feedback, when selected by the user. + installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, + new ConnectionEndpointEditPolicy()); // Allows the removal of + // the connection model + // element + installEditPolicy(EditPolicy.CONNECTION_ROLE, + new ConnectionEditPolicy() { + protected Command getDeleteCommand(GroupRequest request) { + return new ConnectionDeleteCommand((Track) getModel()); + } + }); + } + + @Override + protected ConnectionAnchor getSourceConnectionAnchor() { + if (getSource() != null) { + IFigure f = ((GraphicalEditPart) getSource()).getFigure(); + return new ChopboxAnchor(f) { + @Override + public Point getLocation(Point reference) { + Rectangle r = Rectangle.SINGLETON; + r.setBounds(getBox()); + r.translate(-1, -1); + r.resize(1, 1); + getOwner().translateToAbsolute(r); + float centerX = r.x + 0.5f * r.width; + float centerY = r.y + 0.5f * r.height; + if (r.isEmpty() + || (reference.x == (int) centerX && reference.y == (int) centerY)) + return new Point((int) centerX, (int) centerY); // This + // avoids + // divide-by-zero + return new Point(Math.round(centerX), Math.round(centerY)); + } + }; + } + return DEFAULT_SOURCE_ANCHOR; + } + + @Override + protected ConnectionAnchor getTargetConnectionAnchor() { + if (getTarget() != null) { + IFigure f = ((GraphicalEditPart) getTarget()).getFigure(); + return new ChopboxAnchor(f) { + @Override + public Point getLocation(Point reference) { + Rectangle r = Rectangle.SINGLETON; + r.setBounds(getBox()); + r.translate(-1, -1); + r.resize(1, 1); + getOwner().translateToAbsolute(r); + float centerX = r.x + 0.5f * r.width; + float centerY = r.y + 0.5f * r.height; + if (r.isEmpty() + || (reference.x == (int) centerX && reference.y == (int) centerY)) + return new Point((int) centerX, (int) centerY); // This + // avoids + // divide-by-zero + return new Point(Math.round(centerX), Math.round(centerY)); + } + }; + } + return DEFAULT_TARGET_ANCHOR; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/UnknownPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/UnknownPart.java index 9742455691d3b9f7ce60162437c6c1f067d09235..7244a79c03d6cd4daeb3cc436ca7049a456a4c83 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/UnknownPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/UnknownPart.java @@ -1,46 +1,46 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.draw2d.IFigure; - -import de.bmotionstudio.gef.editor.figure.UnknownBControl; -import de.bmotionstudio.gef.editor.model.BControl; - -public class UnknownPart extends BMSAbstractEditPart { - - public static String ID = "de.bmotionstudio.gef.editor.unknown"; - - private String type; - - @Override - protected IFigure createEditFigure() { - IFigure figure = new UnknownBControl(); - return figure; - } - - @Override - public void refreshEditFigure(IFigure figure, BControl model, - PropertyChangeEvent evt) { - ((UnknownBControl) figure).setMessage(type); - } - - public void setType(String type) { - this.type = type; - } - - @Override - protected void prepareEditPolicies() { - } - - @Override - protected void prepareRunPolicies() { - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; + +import org.eclipse.draw2d.IFigure; + +import de.bmotionstudio.gef.editor.figure.UnknownBControl; +import de.bmotionstudio.gef.editor.model.BControl; + +public class UnknownPart extends BMSAbstractEditPart { + + public static String ID = "de.bmotionstudio.gef.editor.unknown"; + + private String type; + + @Override + protected IFigure createEditFigure() { + IFigure figure = new UnknownBControl(); + return figure; + } + + @Override + public void refreshEditFigure(IFigure figure, BControl model, + PropertyChangeEvent evt) { + ((UnknownBControl) figure).setMessage(type); + } + + public void setType(String type) { + this.type = type; + } + + @Override + protected void prepareEditPolicies() { + } + + @Override + protected void prepareRunPolicies() { + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/VisualizationPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/VisualizationPart.java index 2ecbed079706725e80ce8962d1dd1915cecdb5ee..c0baa4235c085c852eb5a7eea8e97c4720289f52 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/VisualizationPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/VisualizationPart.java @@ -1,134 +1,134 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.part; - -import java.beans.PropertyChangeEvent; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.CompoundSnapToHelper; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.SnapToGeometry; -import org.eclipse.gef.SnapToGrid; -import org.eclipse.gef.SnapToGuides; -import org.eclipse.gef.SnapToHelper; -import org.eclipse.gef.editpolicies.RootComponentEditPolicy; -import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; -import org.eclipse.gef.rulers.RulerProvider; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; -import de.bmotionstudio.gef.editor.editpolicy.BMSEditLayoutPolicy; -import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; -import de.bmotionstudio.gef.editor.figure.VisualizationFigure; -import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; -import de.bmotionstudio.gef.editor.library.AttributeRequest; -import de.bmotionstudio.gef.editor.library.LibraryImageCommand; -import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; -import de.bmotionstudio.gef.editor.model.BControl; - -public class VisualizationPart extends BMSAbstractEditPart { - - public static String ID = "de.bmotionstudio.gef.editor.visualization"; - - @Override - public List<BControl> getModelChildren() { - return ((BControl) getModel()).getChildrenArray(); - } - - @Override - protected IFigure createEditFigure() { - return new VisualizationFigure(); - } - - @Override - protected void prepareEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, new BMSEditLayoutPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null); - installEditPolicy(EditPolicy.CONTAINER_ROLE, new SnapFeedbackPolicy()); - installEditPolicy(EditPolicy.COMPONENT_ROLE, - new RootComponentEditPolicy()); - installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, - new ChangeAttributePolicy()); - } - - @Override - protected void prepareRunPolicies() { - } - - @Override - public void refreshEditFigure(final IFigure figure, final BControl model, - final PropertyChangeEvent evt) { - - Object value = evt.getNewValue(); - String aID = evt.getPropertyName(); - - if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) { - RGB rgbBG = (RGB) value; - ((VisualizationFigure) figure) - .setBackgroundColor(new org.eclipse.swt.graphics.Color( - Display.getDefault(), rgbBG.red, rgbBG.green, - rgbBG.blue)); - } - - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Object getAdapter(final Class adapter) { - if (adapter == SnapToHelper.class) { - List snapStrategies = new ArrayList(); - Boolean val = (Boolean) getViewer().getProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY); - if (val != null && val.booleanValue()) { - snapStrategies.add(new SnapToGuides(this)); - } - val = (Boolean) getViewer().getProperty( - SnapToGeometry.PROPERTY_SNAP_ENABLED); - if (val != null && val.booleanValue()) { - snapStrategies.add(new SnapToGeometry(this)); - } - val = (Boolean) getViewer().getProperty( - SnapToGrid.PROPERTY_GRID_ENABLED); - if (val != null && val.booleanValue()) { - snapStrategies.add(new SnapToGrid(this)); - } - - if (snapStrategies.size() == 0) { - return null; - } - if (snapStrategies.size() == 1) { - return snapStrategies.get(0); - } - - SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; - for (int i = 0; i < snapStrategies.size(); i++) { - ss[i] = (SnapToHelper) snapStrategies.get(i); - } - return new CompoundSnapToHelper(ss); - } - return super.getAdapter(adapter); - } - - @Override - public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { - AbstractLibraryCommand command = null; - if (request.getAttributeTransferObject().getLibraryObject().getType() - .equals("variable")) { - command = new LibraryVariableCommand(); - } else if (request.getAttributeTransferObject().getLibraryObject() - .getType().equals("image")) { - command = new LibraryImageCommand(); - } - return command; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.part; + +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.CompoundSnapToHelper; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.SnapToGeometry; +import org.eclipse.gef.SnapToGrid; +import org.eclipse.gef.SnapToGuides; +import org.eclipse.gef.SnapToHelper; +import org.eclipse.gef.editpolicies.RootComponentEditPolicy; +import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; +import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; +import de.bmotionstudio.gef.editor.editpolicy.BMSEditLayoutPolicy; +import de.bmotionstudio.gef.editor.editpolicy.ChangeAttributePolicy; +import de.bmotionstudio.gef.editor.figure.VisualizationFigure; +import de.bmotionstudio.gef.editor.library.AbstractLibraryCommand; +import de.bmotionstudio.gef.editor.library.AttributeRequest; +import de.bmotionstudio.gef.editor.library.LibraryImageCommand; +import de.bmotionstudio.gef.editor.library.LibraryVariableCommand; +import de.bmotionstudio.gef.editor.model.BControl; + +public class VisualizationPart extends BMSAbstractEditPart { + + public static String ID = "de.bmotionstudio.gef.editor.visualization"; + + @Override + public List<BControl> getModelChildren() { + return ((BControl) getModel()).getChildrenArray(); + } + + @Override + protected IFigure createEditFigure() { + return new VisualizationFigure(); + } + + @Override + protected void prepareEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new BMSDeletePolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, new BMSEditLayoutPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null); + installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null); + installEditPolicy(EditPolicy.CONTAINER_ROLE, new SnapFeedbackPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, + new RootComponentEditPolicy()); + installEditPolicy(ChangeAttributePolicy.CHANGE_ATTRIBUTE_POLICY, + new ChangeAttributePolicy()); + } + + @Override + protected void prepareRunPolicies() { + } + + @Override + public void refreshEditFigure(final IFigure figure, final BControl model, + final PropertyChangeEvent evt) { + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) { + RGB rgbBG = (RGB) value; + ((VisualizationFigure) figure) + .setBackgroundColor(new org.eclipse.swt.graphics.Color( + Display.getDefault(), rgbBG.red, rgbBG.green, + rgbBG.blue)); + } + + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public Object getAdapter(final Class adapter) { + if (adapter == SnapToHelper.class) { + List snapStrategies = new ArrayList(); + Boolean val = (Boolean) getViewer().getProperty( + RulerProvider.PROPERTY_RULER_VISIBILITY); + if (val != null && val.booleanValue()) { + snapStrategies.add(new SnapToGuides(this)); + } + val = (Boolean) getViewer().getProperty( + SnapToGeometry.PROPERTY_SNAP_ENABLED); + if (val != null && val.booleanValue()) { + snapStrategies.add(new SnapToGeometry(this)); + } + val = (Boolean) getViewer().getProperty( + SnapToGrid.PROPERTY_GRID_ENABLED); + if (val != null && val.booleanValue()) { + snapStrategies.add(new SnapToGrid(this)); + } + + if (snapStrategies.size() == 0) { + return null; + } + if (snapStrategies.size() == 1) { + return snapStrategies.get(0); + } + + SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; + for (int i = 0; i < snapStrategies.size(); i++) { + ss[i] = (SnapToHelper) snapStrategies.get(i); + } + return new CompoundSnapToHelper(ss); + } + return super.getAdapter(adapter); + } + + @Override + public AbstractLibraryCommand getLibraryCommand(AttributeRequest request) { + AbstractLibraryCommand command = null; + if (request.getAttributeTransferObject().getLibraryObject().getType() + .equals("variable")) { + command = new LibraryVariableCommand(); + } else if (request.getAttributeTransferObject().getLibraryObject() + .getType().equals("image")) { + command = new LibraryImageCommand(); + } + return command; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxCellEditorHelper.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxCellEditorHelper.java index f8bc69e4d47a8b117eb27adffdb6427c3cc9a250..8bd2d1addaf49a80705df6cc9bcc1cd474fea113 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxCellEditorHelper.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxCellEditorHelper.java @@ -4,60 +4,60 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.swt.graphics.Image; - +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.ICellModifier; +import org.eclipse.swt.graphics.Image; + import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; - -public class CheckboxCellEditorHelper { - - public CheckboxCellEditorHelper() { - super(); - } - - /** - * To be used by LabelProviders that whant to display a checked/unchecked - * icon for the CheckboxCellEditor that does not have a Control. - * - * @param cellModifier - * The ICellModifier for the CellEditor to provide the value - * @param element - * The current element - * @param property - * The property the cellModifier should return the value from - */ - public static Image getCellEditorImage(ICellModifier cellModifier, - Object element, String property) { - Boolean value = (Boolean) cellModifier.getValue(element, property); - return getCellEditorImage(value); - } - - /** - * returns an checked checkbox image if value if true and an unchecked - * checkbox image if false - * - * @param value - * the value to get the cooresponding image for - * @param disabled - * determines if the image should be disabled or not - * @return an checked checkbox image if value if true and an unchecked - * checkbox image if false - * - */ - public static Image getCellEditorImage(boolean value) { - Image image = null; - if (value) - image = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_CHECKED); - else - image = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_UNCHECKED); - - return image; - - } - -} +import de.bmotionstudio.gef.editor.EditorImageRegistry; + +public class CheckboxCellEditorHelper { + + public CheckboxCellEditorHelper() { + super(); + } + + /** + * To be used by LabelProviders that whant to display a checked/unchecked + * icon for the CheckboxCellEditor that does not have a Control. + * + * @param cellModifier + * The ICellModifier for the CellEditor to provide the value + * @param element + * The current element + * @param property + * The property the cellModifier should return the value from + */ + public static Image getCellEditorImage(ICellModifier cellModifier, + Object element, String property) { + Boolean value = (Boolean) cellModifier.getValue(element, property); + return getCellEditorImage(value); + } + + /** + * returns an checked checkbox image if value if true and an unchecked + * checkbox image if false + * + * @param value + * the value to get the cooresponding image for + * @param disabled + * determines if the image should be disabled or not + * @return an checked checkbox image if value if true and an unchecked + * checkbox image if false + * + */ + public static Image getCellEditorImage(boolean value) { + Image image = null; + if (value) + image = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_CHECKED); + else + image = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_UNCHECKED); + + return image; + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxPropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxPropertyDescriptor.java index ba76140953e6836fae17247a15ecca721684c936..87aa753b0b6277eaa69df21ef2052038b2dfc607 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxPropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/CheckboxPropertyDescriptor.java @@ -1,59 +1,59 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class CheckboxPropertyDescriptor extends PropertyDescriptor { - /** - * @param id - * @param displayName - */ - public CheckboxPropertyDescriptor(Object id, String displayName) { - super(id, displayName); - init(); - } - - protected void init() { - setLabelProvider(new LabelProvider() { - @Override - public Image getImage(Object element) { - if (element instanceof Boolean) { - boolean b = (Boolean) element; - return CheckboxCellEditorHelper.getCellEditorImage(b); - } - return super.getImage(element); - } - - @Override - public String getText(Object element) { - if (element instanceof Boolean) { - Boolean b = (Boolean) element; - return b.toString(); - } - return ""; - } - }); - } - - /* - * @see - * org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor - * (org.eclipse.swt.widgets.Composite) - */ - @Override - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new CheckboxCellEditor(parent); - return editor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class CheckboxPropertyDescriptor extends PropertyDescriptor { + /** + * @param id + * @param displayName + */ + public CheckboxPropertyDescriptor(Object id, String displayName) { + super(id, displayName); + init(); + } + + protected void init() { + setLabelProvider(new LabelProvider() { + @Override + public Image getImage(Object element) { + if (element instanceof Boolean) { + boolean b = (Boolean) element; + return CheckboxCellEditorHelper.getCellEditorImage(b); + } + return super.getImage(element); + } + + @Override + public String getText(Object element) { + if (element instanceof Boolean) { + Boolean b = (Boolean) element; + return b.toString(); + } + return ""; + } + }); + } + + /* + * @see + * org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor + * (org.eclipse.swt.widgets.Composite) + */ + @Override + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new CheckboxCellEditor(parent); + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FileDialogCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FileDialogCellEditor.java index 5af32e60e90e930380ada668dc87d0d1eb6f5b44..785557f00bce14de3932cd95986952e8568f2086 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FileDialogCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FileDialogCellEditor.java @@ -4,49 +4,49 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.ui.PlatformUI; - -public class FileDialogCellEditor extends DialogCellEditor { - - /** - * Creates a new File dialog cell editor parented under the given control. - * The cell editor value is <code>null</code> initially, and has no - * validator. - * - * @param parent - * the parent control - */ - protected FileDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - FileDialog ftDialog = new FileDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell()); - - String value = (String) getValue(); - - String fData = ftDialog.open(); - - // if ((value != null) && (value.length() > 0)) { - // ftDialog.setFontList(new FontData[] { new FontData(value) }); - // } - // FontData fData = ftDialog.open(); - - if (fData != null) { - value = fData.toString(); - } - - return value; - } - -} +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.DialogCellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.ui.PlatformUI; + +public class FileDialogCellEditor extends DialogCellEditor { + + /** + * Creates a new File dialog cell editor parented under the given control. + * The cell editor value is <code>null</code> initially, and has no + * validator. + * + * @param parent + * the parent control + */ + protected FileDialogCellEditor(Composite parent) { + super(parent); + } + + /** + * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) + */ + protected Object openDialogBox(Control cellEditorWindow) { + FileDialog ftDialog = new FileDialog(PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell()); + + String value = (String) getValue(); + + String fData = ftDialog.open(); + + // if ((value != null) && (value.length() > 0)) { + // ftDialog.setFontList(new FontData[] { new FontData(value) }); + // } + // FontData fData = ftDialog.open(); + + if (fData != null) { + value = fData.toString(); + } + + return value; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FilePropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FilePropertyDescriptor.java index 9203cd81739015ffa8e25e55d7389c94e87ce07d..a9ba2cec98b7cfceebd210bec1e9ce37a5b0d443 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FilePropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FilePropertyDescriptor.java @@ -4,34 +4,34 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class FilePropertyDescriptor extends PropertyDescriptor { - - /** - * Creates an property descriptor with the given id and display name. - * - * @param id - * the id of the property - * @param displayName - * the name to display for the property - */ - public FilePropertyDescriptor(Object id, String displayName) { - super(id, displayName); - } - - /** - * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) - */ - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new FileDialogCellEditor(parent); - if (getValidator() != null) - editor.setValidator(getValidator()); - return editor; - } - -} +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class FilePropertyDescriptor extends PropertyDescriptor { + + /** + * Creates an property descriptor with the given id and display name. + * + * @param id + * the id of the property + * @param displayName + * the name to display for the property + */ + public FilePropertyDescriptor(Object id, String displayName) { + super(id, displayName); + } + + /** + * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) + */ + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new FileDialogCellEditor(parent); + if (getValidator() != null) + editor.setValidator(getValidator()); + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontDialogCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontDialogCellEditor.java index b9c6bfeb6f24bdee6a7bcd0f46062f2a6067de72..0bc590b12885319bd10f2ce6f627c27bc3625bb2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontDialogCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontDialogCellEditor.java @@ -1,60 +1,60 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FontDialog; -import org.eclipse.ui.PlatformUI; - -public class FontDialogCellEditor extends DialogCellEditor { - - /** - * Creates a new Font dialog cell editor parented under the given control. - * The cell editor value is <code>null</code> initially, and has no - * validator. - * - * @param parent - * the parent control - */ - protected FontDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - FontDialog ftDialog = new FontDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell()); - - String value = (String) getValue(); - - if ((value != null) && (value.length() > 0)) { - ftDialog.setFontList(new FontData[] { new FontData(value) }); - } - FontData fData = ftDialog.open(); - - if (fData != null) { - value = fData.toString(); - } - return value; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.DialogCellEditor; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.ui.PlatformUI; + +public class FontDialogCellEditor extends DialogCellEditor { + + /** + * Creates a new Font dialog cell editor parented under the given control. + * The cell editor value is <code>null</code> initially, and has no + * validator. + * + * @param parent + * the parent control + */ + protected FontDialogCellEditor(Composite parent) { + super(parent); + } + + /** + * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) + */ + protected Object openDialogBox(Control cellEditorWindow) { + FontDialog ftDialog = new FontDialog(PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell()); + + String value = (String) getValue(); + + if ((value != null) && (value.length() > 0)) { + ftDialog.setFontList(new FontData[] { new FontData(value) }); + } + FontData fData = ftDialog.open(); + + if (fData != null) { + value = fData.toString(); + } + return value; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontPropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontPropertyDescriptor.java index bc4eb2213e317ebe3f2e651a157ee0122063e717..74061a30c31126cb37c254dd1ee1adc9afe36b5a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontPropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/FontPropertyDescriptor.java @@ -1,54 +1,54 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class FontPropertyDescriptor extends PropertyDescriptor { - - /** - * Creates an property descriptor with the given id and display name. - * - * @param id - * the id of the property - * @param displayName - * the name to display for the property - */ - public FontPropertyDescriptor(Object id, String displayName) { - super(id, displayName); - setLabelProvider(new LabelProvider() { - @Override - public String getText(Object element) { - return super.getText(element); - } - }); - } - - /** - * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) - */ - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new FontDialogCellEditor(parent); - if (getValidator() != null) - editor.setValidator(getValidator()); - return editor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class FontPropertyDescriptor extends PropertyDescriptor { + + /** + * Creates an property descriptor with the given id and display name. + * + * @param id + * the id of the property + * @param displayName + * the name to display for the property + */ + public FontPropertyDescriptor(Object id, String displayName) { + super(id, displayName); + setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + return super.getText(element); + } + }); + } + + /** + * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) + */ + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new FontDialogCellEditor(parent); + if (getValidator() != null) + editor.setValidator(getValidator()); + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialog.java index 5fc1c992937aaf8192ea2ab7e25e9a78b041af29..09ed8db26d1af112aa1ffb118672b9e978a6bb03 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialog.java @@ -1,242 +1,242 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.property; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.library.LibraryImageObject; -import de.bmotionstudio.gef.editor.library.LibraryObject; - -public class ImageDialog extends Dialog { - - private TableViewer tvLibrary; - private Image previewImage; - private Composite preContainer; - private Canvas previewCanvas; - private final ImageDialogCellEditor imageDialogCellEditor; - - protected ImageDialog(final Shell parentShell, - final ImageDialogCellEditor imageDialogCellEditor) { - super(parentShell); - this.imageDialogCellEditor = imageDialogCellEditor; - } - - @Override - protected Control createDialogArea(final Composite parent) { - - Composite container = (Composite) super.createDialogArea(parent); - - GridLayout gl = new GridLayout(1, true); - gl.horizontalSpacing = 0; - container.setLayout(gl); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalIndent = 0; - - preContainer = new Composite(container, SWT.NONE); - preContainer.setLayoutData(gd); - preContainer.setLayout(new FillLayout()); - - previewCanvas = new Canvas(preContainer, SWT.BORDER); - previewCanvas.addPaintListener(new PaintListener() { - public void paintControl(final PaintEvent e) { - if (previewImage == null) { - e.gc.drawString("No image selected ...", 0, 0); - } else { - e.gc.drawImage(previewImage, 0, 0); - } - } - }); - - final Composite libContainer = new Composite(container, SWT.NONE); - libContainer.setLayoutData(gd); - libContainer.setLayout(new FillLayout()); - - tvLibrary = new TableViewer(libContainer, SWT.FULL_SELECTION - | SWT.V_SCROLL); - tvLibrary.getTable().setLayoutData(gd); - tvLibrary.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(final SelectionChangedEvent event) { - - IStructuredSelection selection = (IStructuredSelection) event - .getSelection(); - - LibraryObject obj = (LibraryObject) selection.getFirstElement(); - - if (previewImage != null) { - previewImage.dispose(); - } - - previewImage = null; - - if (obj != null) { - if (!obj.getName().equals("noimage")) { - IFile pFile = BMotionEditorPlugin.getActiveEditor() - .getVisualization().getProjectFile(); - if (pFile != null) { - String myPath = (pFile.getProject() - .getLocationURI() + "/images/" + obj - .getName()).replace("file:", ""); - previewImage = new Image(Display.getDefault(), - myPath); - } - } - } - - previewCanvas.redraw(); - - } - - }); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tvLibrary.setContentProvider(contentProvider); - - tvLibrary.getTable().setLinesVisible(true); - tvLibrary.getTable().setHeaderVisible(true); - - final TableViewerColumn column1 = new TableViewerColumn(tvLibrary, - SWT.NONE); - column1.getColumn().setText("Name"); - column1.getColumn().setWidth(390); - column1.setLabelProvider(new CellLabelProvider() { - @Override - public void update(final ViewerCell cell) { - cell.setText(((LibraryObject) cell.getElement()).getName()); - cell.setImage(((LibraryObject) cell.getElement()).getImage()); - } - }); - - final TableViewerColumn column2 = new TableViewerColumn(tvLibrary, - SWT.NONE); - column2.getColumn().setText("Type"); - column2.getColumn().setWidth(60); - column2.setLabelProvider(new CellLabelProvider() { - @Override - public void update(final ViewerCell cell) { - cell.setText(((LibraryObject) cell.getElement()).getType()); - } - }); - - WritableList input = new WritableList(getLibraryObjects(), - LibraryObject.class); - tvLibrary.setInput(input); - - return container; - - } - - private List<LibraryObject> getLibraryObjects() { - - List<LibraryObject> tmpList = new ArrayList<LibraryObject>(); - tmpList.add(new LibraryObject("noimage", "", BMotionStudioImage - .getImageDescriptor("org.eclipse.ui", - "$nl$/icons/full/etool16/delete_edit.gif") - .createImage())); - - if (BMotionEditorPlugin.getActiveEditor() != null) { - - String basePath = (BMotionEditorPlugin.getActiveEditor() - .getVisualization().getProjectFile().getProject() - .getLocation().toString()).replace("file:", ""); - File dir = new File(basePath + "/images"); - File[] fileList = dir.listFiles(new FilenameFilter() { - public boolean accept(final File dir, final String name) { - if (name.toLowerCase().endsWith(".jpg") - || name.toLowerCase().endsWith(".gif") - || name.toLowerCase().endsWith(".png")) { - return true; - } - return false; - } - }); - if (fileList != null) { - for (File f : fileList) { - Image img = null; - if (f.getName().toLowerCase().endsWith(".jpg")) { - img = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_JPG); - } else { - img = BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_GIF); - } - tmpList.add(new LibraryImageObject(f.getName(), "image", - img)); - } - } - - } - - return tmpList; - - } - - LibraryObject getSelectedObject() { - IStructuredSelection sel = (IStructuredSelection) tvLibrary - .getSelection(); - LibraryObject lobj = (LibraryObject) sel.getFirstElement(); - return lobj; - } - - @Override - protected Point getInitialSize() { - return new Point(500, 500); - } - - @Override - protected void okPressed() { - LibraryObject sel = getSelectedObject(); - if (sel != null) { - if (!sel.getName().equals("noimage")) { - this.imageDialogCellEditor.setValue(sel.getName()); - } else { - this.imageDialogCellEditor.setValue(""); - } - - } - close(); - } - - @Override - protected void configureShell(final Shell newShell) { - super.configureShell(newShell); - newShell.setText("BMotion Studio - Select image dialog"); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.property; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.library.LibraryImageObject; +import de.bmotionstudio.gef.editor.library.LibraryObject; + +public class ImageDialog extends Dialog { + + private TableViewer tvLibrary; + private Image previewImage; + private Composite preContainer; + private Canvas previewCanvas; + private final ImageDialogCellEditor imageDialogCellEditor; + + protected ImageDialog(final Shell parentShell, + final ImageDialogCellEditor imageDialogCellEditor) { + super(parentShell); + this.imageDialogCellEditor = imageDialogCellEditor; + } + + @Override + protected Control createDialogArea(final Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + + GridLayout gl = new GridLayout(1, true); + gl.horizontalSpacing = 0; + container.setLayout(gl); + + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalIndent = 0; + + preContainer = new Composite(container, SWT.NONE); + preContainer.setLayoutData(gd); + preContainer.setLayout(new FillLayout()); + + previewCanvas = new Canvas(preContainer, SWT.BORDER); + previewCanvas.addPaintListener(new PaintListener() { + public void paintControl(final PaintEvent e) { + if (previewImage == null) { + e.gc.drawString("No image selected ...", 0, 0); + } else { + e.gc.drawImage(previewImage, 0, 0); + } + } + }); + + final Composite libContainer = new Composite(container, SWT.NONE); + libContainer.setLayoutData(gd); + libContainer.setLayout(new FillLayout()); + + tvLibrary = new TableViewer(libContainer, SWT.FULL_SELECTION + | SWT.V_SCROLL); + tvLibrary.getTable().setLayoutData(gd); + tvLibrary.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(final SelectionChangedEvent event) { + + IStructuredSelection selection = (IStructuredSelection) event + .getSelection(); + + LibraryObject obj = (LibraryObject) selection.getFirstElement(); + + if (previewImage != null) { + previewImage.dispose(); + } + + previewImage = null; + + if (obj != null) { + if (!obj.getName().equals("noimage")) { + IFile pFile = BMotionEditorPlugin.getActiveEditor() + .getVisualization().getProjectFile(); + if (pFile != null) { + String myPath = (pFile.getProject() + .getLocationURI() + "/images/" + obj + .getName()).replace("file:", ""); + previewImage = new Image(Display.getDefault(), + myPath); + } + } + } + + previewCanvas.redraw(); + + } + + }); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tvLibrary.setContentProvider(contentProvider); + + tvLibrary.getTable().setLinesVisible(true); + tvLibrary.getTable().setHeaderVisible(true); + + final TableViewerColumn column1 = new TableViewerColumn(tvLibrary, + SWT.NONE); + column1.getColumn().setText("Name"); + column1.getColumn().setWidth(390); + column1.setLabelProvider(new CellLabelProvider() { + @Override + public void update(final ViewerCell cell) { + cell.setText(((LibraryObject) cell.getElement()).getName()); + cell.setImage(((LibraryObject) cell.getElement()).getImage()); + } + }); + + final TableViewerColumn column2 = new TableViewerColumn(tvLibrary, + SWT.NONE); + column2.getColumn().setText("Type"); + column2.getColumn().setWidth(60); + column2.setLabelProvider(new CellLabelProvider() { + @Override + public void update(final ViewerCell cell) { + cell.setText(((LibraryObject) cell.getElement()).getType()); + } + }); + + WritableList input = new WritableList(getLibraryObjects(), + LibraryObject.class); + tvLibrary.setInput(input); + + return container; + + } + + private List<LibraryObject> getLibraryObjects() { + + List<LibraryObject> tmpList = new ArrayList<LibraryObject>(); + tmpList.add(new LibraryObject("noimage", "", BMotionStudioImage + .getImageDescriptor("org.eclipse.ui", + "$nl$/icons/full/etool16/delete_edit.gif") + .createImage())); + + if (BMotionEditorPlugin.getActiveEditor() != null) { + + String basePath = (BMotionEditorPlugin.getActiveEditor() + .getVisualization().getProjectFile().getProject() + .getLocation().toString()).replace("file:", ""); + File dir = new File(basePath + "/images"); + File[] fileList = dir.listFiles(new FilenameFilter() { + public boolean accept(final File dir, final String name) { + if (name.toLowerCase().endsWith(".jpg") + || name.toLowerCase().endsWith(".gif") + || name.toLowerCase().endsWith(".png")) { + return true; + } + return false; + } + }); + if (fileList != null) { + for (File f : fileList) { + Image img = null; + if (f.getName().toLowerCase().endsWith(".jpg")) { + img = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_JPG); + } else { + img = BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_GIF); + } + tmpList.add(new LibraryImageObject(f.getName(), "image", + img)); + } + } + + } + + return tmpList; + + } + + LibraryObject getSelectedObject() { + IStructuredSelection sel = (IStructuredSelection) tvLibrary + .getSelection(); + LibraryObject lobj = (LibraryObject) sel.getFirstElement(); + return lobj; + } + + @Override + protected Point getInitialSize() { + return new Point(500, 500); + } + + @Override + protected void okPressed() { + LibraryObject sel = getSelectedObject(); + if (sel != null) { + if (!sel.getName().equals("noimage")) { + this.imageDialogCellEditor.setValue(sel.getName()); + } else { + this.imageDialogCellEditor.setValue(""); + } + + } + close(); + } + + @Override + protected void configureShell(final Shell newShell) { + super.configureShell(newShell); + newShell.setText("BMotion Studio - Select image dialog"); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialogCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialogCellEditor.java index ec77332f939ab0c106bb4d0de6ad3589e5f1bc5d..fb88890ec12650af160ae1b33131b4dade7b260d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialogCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImageDialogCellEditor.java @@ -1,42 +1,42 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; - -public class ImageDialogCellEditor extends DialogCellEditor { - - /** - * Creates a new Image dialog cell editor parented under the given control. - * The cell editor value is <code>null</code> initially, and has no - * validator. - * - * @param parent - * the parent control - */ - protected ImageDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) - */ - @Override - protected Object openDialogBox(Control arg) { - ImageDialog dialog = new ImageDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), this); - if (dialog.open() == Dialog.OK) { - return getValue(); - } - return null; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.DialogCellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.PlatformUI; + +public class ImageDialogCellEditor extends DialogCellEditor { + + /** + * Creates a new Image dialog cell editor parented under the given control. + * The cell editor value is <code>null</code> initially, and has no + * validator. + * + * @param parent + * the parent control + */ + protected ImageDialogCellEditor(Composite parent) { + super(parent); + } + + /** + * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control) + */ + @Override + protected Object openDialogBox(Control arg) { + ImageDialog dialog = new ImageDialog(PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(), this); + if (dialog.open() == Dialog.OK) { + return getValue(); + } + return null; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImagePropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImagePropertyDescriptor.java index da6325a2fd9bb0b42c9954ac39cbe6e8c6546753..011db14eefce6dd9df661b171eeb9063f400b3c0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImagePropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/ImagePropertyDescriptor.java @@ -4,34 +4,34 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class ImagePropertyDescriptor extends PropertyDescriptor { - - /** - * Creates an property descriptor with the given id and display name. - * - * @param id - * the id of the property - * @param displayName - * the name to display for the property - */ - public ImagePropertyDescriptor(Object id, String displayName) { - super(id, displayName); - } - - /** - * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) - */ - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new ImageDialogCellEditor(parent); - if (getValidator() != null) - editor.setValidator(getValidator()); - return editor; - } - -} +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class ImagePropertyDescriptor extends PropertyDescriptor { + + /** + * Creates an property descriptor with the given id and display name. + * + * @param id + * the id of the property + * @param displayName + * the name to display for the property + */ + public ImagePropertyDescriptor(Object id, String displayName) { + super(id, displayName); + } + + /** + * @see org.eclipse.ui.views.properties.IPropertyDescriptor#createPropertyEditor(Composite) + */ + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new ImageDialogCellEditor(parent); + if (getValidator() != null) + editor.setValidator(getValidator()); + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerCellEditor.java index ece6021174e3f4ec8da471400a97b0a291620c10..24b73044c7e9a6f7a02276df5d8614579b3d79e0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerCellEditor.java @@ -1,444 +1,438 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.property; - -import java.text.MessageFormat; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -public class IntegerCellEditor extends CellEditor { - - /** - * The text control; initially <code>null</code>. - */ - protected Text text; - - private ModifyListener modifyListener; - - /** - * State information for updating action enablement - */ - private boolean isSelection = false; - - private boolean isDeleteable = false; - - private boolean isSelectable = false; - - public IntegerCellEditor(Composite composite) { - super(composite); - setValidator(new ICellEditorValidator() { - public String isValid(Object object) { - if (object instanceof Integer) { - return null; - } else { - String string = (String) object; - try { - Integer.parseInt(string); - return null; - } catch (NumberFormatException exception) { - return exception.getMessage(); - } - } - } - }); - } - - /** - * Checks to see if the "deletable" state (can delete/ nothing to delete) - * has changed and if so fire an enablement changed notification. - */ - private void checkDeleteable() { - boolean oldIsDeleteable = isDeleteable; - isDeleteable = isDeleteEnabled(); - if (oldIsDeleteable != isDeleteable) { - fireEnablementChanged(DELETE); - } - } - - /** - * Checks to see if the "selectable" state (can select) has changed and if - * so fire an enablement changed notification. - */ - private void checkSelectable() { - boolean oldIsSelectable = isSelectable; - isSelectable = isSelectAllEnabled(); - if (oldIsSelectable != isSelectable) { - fireEnablementChanged(SELECT_ALL); - } - } - - /** - * Checks to see if the selection state (selection / no selection) has - * changed and if so fire an enablement changed notification. - */ - private void checkSelection() { - boolean oldIsSelection = isSelection; - isSelection = text.getSelectionCount() > 0; - if (oldIsSelection != isSelection) { - fireEnablementChanged(COPY); - fireEnablementChanged(CUT); - } - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Control createControl(Composite parent) { - text = new Text(parent, getStyle()); - text.addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected(SelectionEvent e) { - handleDefaultSelection(e); - } - }); - text.addKeyListener(new KeyAdapter() { - // hook key pressed - see PR 14201 - public void keyPressed(KeyEvent e) { - keyReleaseOccured(e); - - // as a result of processing the above call, clients may have - // disposed this cell editor - if ((getControl() == null) || getControl().isDisposed()) { - return; - } - checkSelection(); // see explanation below - checkDeleteable(); - checkSelectable(); - } - }); - text.addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_ESCAPE - || e.detail == SWT.TRAVERSE_RETURN) { - e.doit = false; - } - } - }); - // We really want a selection listener but it is not supported so we - // use a key listener and a mouse listener to know when selection - // changes - // may have occurred - text.addMouseListener(new MouseAdapter() { - public void mouseUp(MouseEvent e) { - checkSelection(); - checkDeleteable(); - checkSelectable(); - } - }); - text.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - IntegerCellEditor.this.focusLost(); - } - }); - text.setFont(parent.getFont()); - text.setBackground(parent.getBackground()); - text.setText("");//$NON-NLS-1$ - text.addModifyListener(getModifyListener()); - return text; - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> framework method returns the text string. - * - * @return the text string - */ - protected Object doGetValue() { - return Integer.valueOf(Integer.parseInt(text.getText())); - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected void doSetFocus() { - if (text != null) { - text.selectAll(); - text.setFocus(); - checkSelection(); - checkDeleteable(); - checkSelectable(); - } - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> framework method accepts a text string (type - * <code>String</code>). - * - * @param value - * a text string (type <code>String</code>) - */ - protected void doSetValue(Object value) { - Assert.isTrue(text != null && (value instanceof Integer)); - text.removeModifyListener(getModifyListener()); - text.setText(String.valueOf(value.toString())); - text.addModifyListener(getModifyListener()); - } - - /** - * Processes a modify event that occurred in this text cell editor. This - * framework method performs validation and sets the error message - * accordingly, and then reports a change via - * <code>fireEditorValueChanged</code>. Subclasses should call this method - * at appropriate times. Subclasses may extend or reimplement. - * - * @param e - * the SWT modify event - */ - protected void editOccured(ModifyEvent e) { - String value = text.getText(); - if (value == null) { - value = "";//$NON-NLS-1$ - } - Object typedValue = value; - boolean oldValidState = isValueValid(); - boolean newValidState = isCorrect(typedValue); - - if (!newValidState) { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { value })); - } - valueChanged(oldValidState, newValidState); - } - - /** - * Since a text editor field is scrollable we don't set a minimumSize. - */ - public LayoutData getLayoutData() { - return new LayoutData(); - } - - /** - * Return the modify listener. - */ - private ModifyListener getModifyListener() { - if (modifyListener == null) { - modifyListener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - editOccured(e); - } - }; - } - return modifyListener; - } - - /** - * Handles a default selection event from the text control by applying the - * editor value and deactivating this cell editor. - * - * @param event - * the selection event - * - * @since 3.0 - */ - protected void handleDefaultSelection(SelectionEvent event) { - // same with enter-key handling code in keyReleaseOccured(e); - fireApplyEditorValue(); - deactivate(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method returns <code>true</code> if the current - * selection is not empty. - */ - public boolean isCopyEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return text.getSelectionCount() > 0; - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method returns <code>true</code> if the current - * selection is not empty. - */ - public boolean isCutEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return text.getSelectionCount() > 0; - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method returns <code>true</code> if there is a - * selection or if the caret is not positioned at the end of the text. - */ - public boolean isDeleteEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return text.getSelectionCount() > 0 - || text.getCaretPosition() < text.getCharCount(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method always returns <code>true</code>. - */ - public boolean isPasteEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return true; - } - - /** - * Check if save all is enabled - * - * @return true if it is - */ - public boolean isSaveAllEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return true; - } - - /** - * Returns <code>true</code> if this cell editor is able to perform the - * select all action. - * <p> - * This default implementation always returns <code>false</code>. - * </p> - * <p> - * Subclasses may override - * </p> - * - * @return <code>true</code> if select all is possible, <code>false</code> - * otherwise - */ - public boolean isSelectAllEnabled() { - if (text == null || text.isDisposed()) { - return false; - } - return text.getCharCount() > 0; - } - - /** - * Processes a key release event that occurred in this cell editor. - * <p> - * The <code>TextCellEditor</code> implementation of this framework method - * ignores when the RETURN key is pressed since this is handled in - * <code>handleDefaultSelection</code>. An exception is made for Ctrl+Enter - * for multi-line texts, since a default selection event is not sent in this - * case. - * </p> - * - * @param keyEvent - * the key event - */ - protected void keyReleaseOccured(KeyEvent keyEvent) { - if (keyEvent.character == '\r') { // Return key - // Enter is handled in handleDefaultSelection. - // Do not apply the editor value in response to an Enter key event - // since this can be received from the IME when the intent is -not- - // to apply the value. - // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus - // event from Text Control - // - // An exception is made for Ctrl+Enter for multi-line texts, since - // a default selection event is not sent in this case. - if (text != null && !text.isDisposed() - && (text.getStyle() & SWT.MULTI) != 0) { - if ((keyEvent.stateMask & SWT.CTRL) != 0) { - super.keyReleaseOccured(keyEvent); - } - } - return; - } - super.keyReleaseOccured(keyEvent); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method copies the current selection to the - * clipboard. - */ - public void performCopy() { - text.copy(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method cuts the current selection to the - * clipboard. - */ - public void performCut() { - text.cut(); - checkSelection(); - checkDeleteable(); - checkSelectable(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method deletes the current selection or, if there - * is no selection, the character next character from the current position. - */ - public void performDelete() { - if (text.getSelectionCount() > 0) { - // remove the contents of the current selection - text.insert(""); //$NON-NLS-1$ - } else { - // remove the next character - int pos = text.getCaretPosition(); - if (pos < text.getCharCount()) { - text.setSelection(pos, pos + 1); - text.insert(""); //$NON-NLS-1$ - } - } - checkSelection(); - checkDeleteable(); - checkSelectable(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method pastes the the clipboard contents over the - * current selection. - */ - public void performPaste() { - text.paste(); - checkSelection(); - checkDeleteable(); - checkSelectable(); - } - - /** - * The <code>TextCellEditor</code> implementation of this - * <code>CellEditor</code> method selects all of the current text. - */ - public void performSelectAll() { - text.selectAll(); - checkSelection(); - checkDeleteable(); - } - - /** - * This implementation of - * {@link CellEditor#dependsOnExternalFocusListener()} returns false if the - * current instance's class is TextCellEditor, and true otherwise. - * Subclasses that hook their own focus listener should override this method - * and return false. See also bug 58777. - * - * @since 3.4 - */ - protected boolean dependsOnExternalFocusListener() { - return getClass() != IntegerCellEditor.class; - } - +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.property; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.*; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Text; + +public class IntegerCellEditor extends CellEditor { + + /** + * The text control; initially <code>null</code>. + */ + protected Text text; + + private ModifyListener modifyListener; + + /** + * State information for updating action enablement + */ + private boolean isSelection = false; + + private boolean isDeleteable = false; + + private boolean isSelectable = false; + + public IntegerCellEditor(Composite composite) { + super(composite); + setValidator(new ICellEditorValidator() { + public String isValid(Object object) { + if (object instanceof Integer) { + return null; + } else { + String string = (String) object; + try { + Integer.parseInt(string); + return null; + } catch (NumberFormatException exception) { + return exception.getMessage(); + } + } + } + }); + } + + /** + * Checks to see if the "deletable" state (can delete/ nothing to delete) + * has changed and if so fire an enablement changed notification. + */ + private void checkDeleteable() { + boolean oldIsDeleteable = isDeleteable; + isDeleteable = isDeleteEnabled(); + if (oldIsDeleteable != isDeleteable) { + fireEnablementChanged(DELETE); + } + } + + /** + * Checks to see if the "selectable" state (can select) has changed and if + * so fire an enablement changed notification. + */ + private void checkSelectable() { + boolean oldIsSelectable = isSelectable; + isSelectable = isSelectAllEnabled(); + if (oldIsSelectable != isSelectable) { + fireEnablementChanged(SELECT_ALL); + } + } + + /** + * Checks to see if the selection state (selection / no selection) has + * changed and if so fire an enablement changed notification. + */ + private void checkSelection() { + boolean oldIsSelection = isSelection; + isSelection = text.getSelectionCount() > 0; + if (oldIsSelection != isSelection) { + fireEnablementChanged(COPY); + fireEnablementChanged(CUT); + } + } + + protected Control createControl(Composite parent) { + text = new Text(parent, getStyle()); + text.addSelectionListener(new SelectionAdapter() { + public void widgetDefaultSelected(SelectionEvent e) { + handleDefaultSelection(e); + } + }); + text.addKeyListener(new KeyAdapter() { + // hook key pressed - see PR 14201 + public void keyPressed(KeyEvent e) { + keyReleaseOccured(e); + + // as a result of processing the above call, clients may have + // disposed this cell editor + if ((getControl() == null) || getControl().isDisposed()) { + return; + } + checkSelection(); // see explanation below + checkDeleteable(); + checkSelectable(); + } + }); + text.addTraverseListener(new TraverseListener() { + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_ESCAPE + || e.detail == SWT.TRAVERSE_RETURN) { + e.doit = false; + } + } + }); + // We really want a selection listener but it is not supported so we + // use a key listener and a mouse listener to know when selection + // changes + // may have occurred + text.addMouseListener(new MouseAdapter() { + public void mouseUp(MouseEvent e) { + checkSelection(); + checkDeleteable(); + checkSelectable(); + } + }); + text.addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent e) { + IntegerCellEditor.this.focusLost(); + } + }); + text.setFont(parent.getFont()); + text.setBackground(parent.getBackground()); + text.setText("");//$NON-NLS-1$ + text.addModifyListener(getModifyListener()); + return text; + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> framework method returns the text string. + * + * @return the text string + */ + protected Object doGetValue() { + return Integer.valueOf(Integer.parseInt(text.getText())); + } + + protected void doSetFocus() { + if (text != null) { + text.selectAll(); + text.setFocus(); + checkSelection(); + checkDeleteable(); + checkSelectable(); + } + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> framework method accepts a text string (type + * <code>String</code>). + * + * @param value + * a text string (type <code>String</code>) + */ + protected void doSetValue(Object value) { + Assert.isTrue(text != null && (value instanceof Integer)); + text.removeModifyListener(getModifyListener()); + text.setText(String.valueOf(value.toString())); + text.addModifyListener(getModifyListener()); + } + + /** + * Processes a modify event that occurred in this text cell editor. This + * framework method performs validation and sets the error message + * accordingly, and then reports a change via + * <code>fireEditorValueChanged</code>. Subclasses should call this method + * at appropriate times. Subclasses may extend or reimplement. + * + * @param e + * the SWT modify event + */ + protected void editOccured(ModifyEvent e) { + String value = text.getText(); + if (value == null) { + value = "";//$NON-NLS-1$ + } + Object typedValue = value; + boolean oldValidState = isValueValid(); + boolean newValidState = isCorrect(typedValue); + + if (!newValidState) { + // try to insert the current value into the error message. + setErrorMessage(MessageFormat.format(getErrorMessage(), + new Object[] { value })); + } + valueChanged(oldValidState, newValidState); + } + + /** + * Since a text editor field is scrollable we don't set a minimumSize. + */ + public LayoutData getLayoutData() { + return new LayoutData(); + } + + /** + * Return the modify listener. + */ + private ModifyListener getModifyListener() { + if (modifyListener == null) { + modifyListener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + editOccured(e); + } + }; + } + return modifyListener; + } + + /** + * Handles a default selection event from the text control by applying the + * editor value and deactivating this cell editor. + * + * @param event + * the selection event + * + * @since 3.0 + */ + protected void handleDefaultSelection(SelectionEvent event) { + // same with enter-key handling code in keyReleaseOccured(e); + fireApplyEditorValue(); + deactivate(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method returns <code>true</code> if the current + * selection is not empty. + */ + public boolean isCopyEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return text.getSelectionCount() > 0; + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method returns <code>true</code> if the current + * selection is not empty. + */ + public boolean isCutEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return text.getSelectionCount() > 0; + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method returns <code>true</code> if there is a + * selection or if the caret is not positioned at the end of the text. + */ + public boolean isDeleteEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return text.getSelectionCount() > 0 + || text.getCaretPosition() < text.getCharCount(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method always returns <code>true</code>. + */ + public boolean isPasteEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return true; + } + + /** + * Check if save all is enabled + * + * @return true if it is + */ + public boolean isSaveAllEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return true; + } + + /** + * Returns <code>true</code> if this cell editor is able to perform the + * select all action. + * <p> + * This default implementation always returns <code>false</code>. + * </p> + * <p> + * Subclasses may override + * </p> + * + * @return <code>true</code> if select all is possible, <code>false</code> + * otherwise + */ + public boolean isSelectAllEnabled() { + if (text == null || text.isDisposed()) { + return false; + } + return text.getCharCount() > 0; + } + + /** + * Processes a key release event that occurred in this cell editor. + * <p> + * The <code>TextCellEditor</code> implementation of this framework method + * ignores when the RETURN key is pressed since this is handled in + * <code>handleDefaultSelection</code>. An exception is made for Ctrl+Enter + * for multi-line texts, since a default selection event is not sent in this + * case. + * </p> + * + * @param keyEvent + * the key event + */ + protected void keyReleaseOccured(KeyEvent keyEvent) { + if (keyEvent.character == '\r') { // Return key + // Enter is handled in handleDefaultSelection. + // Do not apply the editor value in response to an Enter key event + // since this can be received from the IME when the intent is -not- + // to apply the value. + // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus + // event from Text Control + // + // An exception is made for Ctrl+Enter for multi-line texts, since + // a default selection event is not sent in this case. + if (text != null && !text.isDisposed() + && (text.getStyle() & SWT.MULTI) != 0) { + if ((keyEvent.stateMask & SWT.CTRL) != 0) { + super.keyReleaseOccured(keyEvent); + } + } + return; + } + super.keyReleaseOccured(keyEvent); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method copies the current selection to the + * clipboard. + */ + public void performCopy() { + text.copy(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method cuts the current selection to the + * clipboard. + */ + public void performCut() { + text.cut(); + checkSelection(); + checkDeleteable(); + checkSelectable(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method deletes the current selection or, if there + * is no selection, the character next character from the current position. + */ + public void performDelete() { + if (text.getSelectionCount() > 0) { + // remove the contents of the current selection + text.insert(""); //$NON-NLS-1$ + } else { + // remove the next character + int pos = text.getCaretPosition(); + if (pos < text.getCharCount()) { + text.setSelection(pos, pos + 1); + text.insert(""); //$NON-NLS-1$ + } + } + checkSelection(); + checkDeleteable(); + checkSelectable(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method pastes the the clipboard contents over the + * current selection. + */ + public void performPaste() { + text.paste(); + checkSelection(); + checkDeleteable(); + checkSelectable(); + } + + /** + * The <code>TextCellEditor</code> implementation of this + * <code>CellEditor</code> method selects all of the current text. + */ + public void performSelectAll() { + text.selectAll(); + checkSelection(); + checkDeleteable(); + } + + /** + * This implementation of + * {@link CellEditor#dependsOnExternalFocusListener()} returns false if the + * current instance's class is TextCellEditor, and true otherwise. + * Subclasses that hook their own focus listener should override this method + * and return false. See also bug 58777. + * + * @since 3.4 + */ + protected boolean dependsOnExternalFocusListener() { + return getClass() != IntegerCellEditor.class; + } + } \ No newline at end of file diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerPropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerPropertyDescriptor.java index 45b37dc5a542d80761773aca43bd009ef798cfaa..4079b8ff1624c6e1081a7ff6b9626442f0a6af1a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerPropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/IntegerPropertyDescriptor.java @@ -1,27 +1,27 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class IntegerPropertyDescriptor extends PropertyDescriptor { - - public IntegerPropertyDescriptor(Object id, String displayName) { - super(id, displayName); - } - - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new IntegerCellEditor(parent); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class IntegerPropertyDescriptor extends PropertyDescriptor { + + public IntegerPropertyDescriptor(Object id, String displayName) { + super(id, displayName); + } + + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new IntegerCellEditor(parent); + if (getValidator() != null) { + editor.setValidator(getValidator()); + } + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderCellEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderCellEditor.java index 58bb2aff83f5bf15dfb75aacc100d9cc7fc66d65..fea6f682862b592cae8f776d4a50ead4c9340078 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderCellEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderCellEditor.java @@ -4,249 +4,239 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import java.text.MessageFormat; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.*; - -public class SliderCellEditor extends CellEditor { - - /** - * The editor control. - */ - private Composite editor; - - /** - * The slider. - */ - private Slider slider; - - private Label countLabel; - - /** - * Listens for 'focusLost' events and fires the 'apply' event as long as the - * focus wasn't lost because the dialog was opened. - */ - private FocusListener buttonFocusListener; - - /** - * The value of this cell editor; initially null. - */ - private Object value = null; - - /** - * Internal class for laying out the dialog. - */ - private class SliderSampleCellLayout extends Layout { - public void layout(Composite editor, boolean force) { - Rectangle bounds = editor.getClientArea(); - slider.setBounds(30, 0, bounds.width - 30, bounds.height); - countLabel.setBounds(5, 1, 25, bounds.height); - } - - public Point computeSize(Composite editor, int wHint, int hHint, - boolean force) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) { - return new Point(wHint, hHint); - } - Point buttonSize = slider.computeSize(SWT.DEFAULT, SWT.DEFAULT, - force); - // Just return the button width to ensure the button is not clipped - // if the label is long. - // The label will just use whatever extra width there is - Point result = new Point(buttonSize.x, buttonSize.y); - return result; - } - } - - /** - * Default DialogCellEditor style - */ - private static final int defaultStyle = SWT.NONE; - - /** - * Creates a new dialog cell editor with no control - * - * @since 2.1 - */ - public SliderCellEditor() { - setStyle(defaultStyle); - } - - /** - * Creates a new dialog cell editor parented under the given control. The - * cell editor value is null initially, and has no * validator. - * - * @param parent - * the parent control - */ - public SliderCellEditor(Composite parent) { - this(parent, defaultStyle); - } - - /** - * Creates a new dialog cell editor parented under the given control. The - * cell editor value is null initially, and has no * validator. - * - * @param parent - * the parent control - * @param style - * the style bits - * @since 2.1 - */ - public SliderCellEditor(Composite parent, int style) { - super(parent, style); - } - - /** - * Creates the button for this cell editor under the given parent control. * - * The default implementation of this framework method creates the button * - * display on the right hand side of the dialog cell editor. Subclasses may - * extend or reimplement. * - * - * @param parent - * the parent control - * @return the new button control - */ - protected Slider createSpinner(Composite parent) { - Slider result = new Slider(parent, SWT.HORIZONTAL); - result.setMaximum(265); - result.setIncrement(1); - //$NON-NLS-1$ - return result; - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Control createControl(Composite parent) { - Font font = parent.getFont(); - Color bg = parent.getBackground(); - - editor = new Composite(parent, getStyle()); - editor.setFont(font); - editor.setBackground(bg); - editor.setLayout(new SliderSampleCellLayout()); - - countLabel = new Label(editor, SWT.NONE); - - slider = createSpinner(editor); - slider.setFont(font); - slider.setBackground(editor.getBackground()); - updateContents(value); - - slider.addFocusListener(getButtonFocusListener()); - slider.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - slider.removeFocusListener(getButtonFocusListener()); - - Object newValue = slider.getSelection(); - if (newValue != null) { - boolean newValidState = isCorrect(newValue); - if (newValidState) { - markDirty(); - doSetValue(newValue); - } else { - // try to insert the current value into the error - // message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { newValue.toString() })); - } - } - } - }); - - slider.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - fireApplyEditorValue(); - } - }); - - setValueValid(true); - - return editor; - } - - /* - * (non-Javadoc) Override in order to remove the button's focus listener if - * the celleditor is deactivating. - */ - public void deactivate() { - if (slider != null && !slider.isDisposed()) { - slider.removeFocusListener(getButtonFocusListener()); - } - - super.deactivate(); - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Object doGetValue() { - return value; - } - - /* - * (non-Javadoc) Method declared on CellEditor. The focus is set to the cell - * editor's button. - */ - protected void doSetFocus() { - slider.setFocus(); // add a FocusListener to the button - slider.addFocusListener(getButtonFocusListener()); - } - - /** - * Return a listener for button focus. - * - * @return FocusListener - */ - private FocusListener getButtonFocusListener() { - if (buttonFocusListener == null) { - buttonFocusListener = new FocusListener() { - public void focusGained(FocusEvent e) { - // Do nothing - } - - public void focusLost(FocusEvent e) { - SliderCellEditor.this.focusLost(); - } - }; - } - - return buttonFocusListener; - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected void doSetValue(Object value) { - this.value = value; - updateContents(value); - } - - /** - * Updates the controls showing the value of this cell editor. * The default - * implementation of this framework method just converts the passed object - * to a string using toString and sets this as the text of the label widget. - */ - protected void updateContents(Object value) { - String text = "";//$NON-NLS-1$ - if (value != null) { - text = value.toString(); - if (slider != null) { - slider.setSelection(Integer.parseInt(text)); - countLabel.setText(value.toString()); - } - } - } - -} +package de.bmotionstudio.gef.editor.property; + +import java.text.MessageFormat; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.*; + +public class SliderCellEditor extends CellEditor { + + /** + * The editor control. + */ + private Composite editor; + + /** + * The slider. + */ + private Slider slider; + + private Label countLabel; + + /** + * Listens for 'focusLost' events and fires the 'apply' event as long as the + * focus wasn't lost because the dialog was opened. + */ + private FocusListener buttonFocusListener; + + /** + * The value of this cell editor; initially null. + */ + private Object value = null; + + /** + * Internal class for laying out the dialog. + */ + private class SliderSampleCellLayout extends Layout { + public void layout(Composite editor, boolean force) { + Rectangle bounds = editor.getClientArea(); + slider.setBounds(30, 0, bounds.width - 30, bounds.height); + countLabel.setBounds(5, 1, 25, bounds.height); + } + + public Point computeSize(Composite editor, int wHint, int hHint, + boolean force) { + if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) { + return new Point(wHint, hHint); + } + Point buttonSize = slider.computeSize(SWT.DEFAULT, SWT.DEFAULT, + force); + // Just return the button width to ensure the button is not clipped + // if the label is long. + // The label will just use whatever extra width there is + Point result = new Point(buttonSize.x, buttonSize.y); + return result; + } + } + + /** + * Default DialogCellEditor style + */ + private static final int defaultStyle = SWT.NONE; + + /** + * Creates a new dialog cell editor with no control + * + * @since 2.1 + */ + public SliderCellEditor() { + setStyle(defaultStyle); + } + + /** + * Creates a new dialog cell editor parented under the given control. The + * cell editor value is null initially, and has no * validator. + * + * @param parent + * the parent control + */ + public SliderCellEditor(Composite parent) { + this(parent, defaultStyle); + } + + /** + * Creates a new dialog cell editor parented under the given control. The + * cell editor value is null initially, and has no * validator. + * + * @param parent + * the parent control + * @param style + * the style bits + * @since 2.1 + */ + public SliderCellEditor(Composite parent, int style) { + super(parent, style); + } + + /** + * Creates the button for this cell editor under the given parent control. * + * The default implementation of this framework method creates the button * + * display on the right hand side of the dialog cell editor. Subclasses may + * extend or reimplement. * + * + * @param parent + * the parent control + * @return the new button control + */ + protected Slider createSpinner(Composite parent) { + Slider result = new Slider(parent, SWT.HORIZONTAL); + result.setMaximum(265); + result.setIncrement(1); + //$NON-NLS-1$ + return result; + } + + protected Control createControl(Composite parent) { + Font font = parent.getFont(); + Color bg = parent.getBackground(); + + editor = new Composite(parent, getStyle()); + editor.setFont(font); + editor.setBackground(bg); + editor.setLayout(new SliderSampleCellLayout()); + + countLabel = new Label(editor, SWT.NONE); + + slider = createSpinner(editor); + slider.setFont(font); + slider.setBackground(editor.getBackground()); + updateContents(value); + + slider.addFocusListener(getButtonFocusListener()); + slider.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + slider.removeFocusListener(getButtonFocusListener()); + + Object newValue = slider.getSelection(); + if (newValue != null) { + boolean newValidState = isCorrect(newValue); + if (newValidState) { + markDirty(); + doSetValue(newValue); + } else { + // try to insert the current value into the error + // message. + setErrorMessage(MessageFormat.format(getErrorMessage(), + new Object[] { newValue.toString() })); + } + } + } + }); + + slider.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + fireApplyEditorValue(); + } + }); + + setValueValid(true); + + return editor; + } + + /** + * Override in order to remove the button's focus listener if + * the celleditor is deactivating. + */ + public void deactivate() { + if (slider != null && !slider.isDisposed()) { + slider.removeFocusListener(getButtonFocusListener()); + } + + super.deactivate(); + } + + protected Object doGetValue() { + return value; + } + + /** + * The focus is set to the cell editor's button. + */ + protected void doSetFocus() { + slider.setFocus(); // add a FocusListener to the button + slider.addFocusListener(getButtonFocusListener()); + } + + /** + * Return a listener for button focus. + * + * @return FocusListener + */ + private FocusListener getButtonFocusListener() { + if (buttonFocusListener == null) { + buttonFocusListener = new FocusListener() { + public void focusGained(FocusEvent e) { + // Do nothing + } + + public void focusLost(FocusEvent e) { + SliderCellEditor.this.focusLost(); + } + }; + } + + return buttonFocusListener; + } + + protected void doSetValue(Object value) { + this.value = value; + updateContents(value); + } + + /** + * Updates the controls showing the value of this cell editor. * The default + * implementation of this framework method just converts the passed object + * to a string using toString and sets this as the text of the label widget. + */ + protected void updateContents(Object value) { + String text = "";//$NON-NLS-1$ + if (value != null) { + text = value.toString(); + if (slider != null) { + slider.setSelection(Integer.parseInt(text)); + countLabel.setText(value.toString()); + } + } + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderPropertyDescriptor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderPropertyDescriptor.java index 5be87c1a68fe12a90c70579992f168f2e67b5c31..a4af6f930971e15927f20be06b6de295d42c6a17 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderPropertyDescriptor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/property/SliderPropertyDescriptor.java @@ -4,24 +4,24 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.gef.editor.property; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class SliderPropertyDescriptor extends PropertyDescriptor { - - public SliderPropertyDescriptor(Object id, String displayName) { - super(id, displayName); - } - - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new SliderCellEditor(parent); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - -} +package de.bmotionstudio.gef.editor.property; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.PropertyDescriptor; + +public class SliderPropertyDescriptor extends PropertyDescriptor { + + public SliderPropertyDescriptor(Object id, String displayName) { + super(id, displayName); + } + + public CellEditor createPropertyEditor(Composite parent) { + CellEditor editor = new SliderCellEditor(parent); + if (getValidator() != null) { + editor.setValidator(getValidator()); + } + return editor; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptObject.java index 00e57c45a0df64e0488889047607f3aaf52079c6..affa2870ea07527a1311fc18490579235437f7cd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptObject.java @@ -1,64 +1,64 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import java.util.Vector; - -import de.bmotionstudio.gef.editor.BindingObject; - -public class AnimationScriptObject extends BindingObject implements Cloneable { - - private Vector<AnimationScriptStep> steps; - - private String predicate; - - public AnimationScriptObject() { - } - - public AnimationScriptObject(String predicate) { - this(predicate, new Vector<AnimationScriptStep>()); - } - - public AnimationScriptObject(String predicate, - Vector<AnimationScriptStep> steps) { - this.predicate = predicate; - this.steps = steps; - } - - public void setSteps(Vector<AnimationScriptStep> steps) { - Object oldValue = this.steps; - this.steps = steps; - firePropertyChange("steps", oldValue, this.steps); - } - - public Vector<AnimationScriptStep> getSteps() { - if (this.steps == null) - this.steps = new Vector<AnimationScriptStep>(); - return this.steps; - } - - public void setPredicate(String predicate) { - Object oldValue = this.predicate; - this.predicate = predicate; - firePropertyChange("predicate", oldValue, this.predicate); - } - - public String getPredicate() { - return predicate; - } - - public AnimationScriptObject clone() throws CloneNotSupportedException { - Vector<AnimationScriptStep> tmpVector = new Vector<AnimationScriptStep>(); - for (AnimationScriptStep p : getSteps()) { - tmpVector.add(p.clone()); - } - AnimationScriptObject tmpObj = (AnimationScriptObject) super.clone(); - tmpObj.setSteps(tmpVector); - return tmpObj; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import java.util.Vector; + +import de.bmotionstudio.gef.editor.BindingObject; + +public class AnimationScriptObject extends BindingObject implements Cloneable { + + private Vector<AnimationScriptStep> steps; + + private String predicate; + + public AnimationScriptObject() { + } + + public AnimationScriptObject(String predicate) { + this(predicate, new Vector<AnimationScriptStep>()); + } + + public AnimationScriptObject(String predicate, + Vector<AnimationScriptStep> steps) { + this.predicate = predicate; + this.steps = steps; + } + + public void setSteps(Vector<AnimationScriptStep> steps) { + Object oldValue = this.steps; + this.steps = steps; + firePropertyChange("steps", oldValue, this.steps); + } + + public Vector<AnimationScriptStep> getSteps() { + if (this.steps == null) + this.steps = new Vector<AnimationScriptStep>(); + return this.steps; + } + + public void setPredicate(String predicate) { + Object oldValue = this.predicate; + this.predicate = predicate; + firePropertyChange("predicate", oldValue, this.predicate); + } + + public String getPredicate() { + return predicate; + } + + public AnimationScriptObject clone() throws CloneNotSupportedException { + Vector<AnimationScriptStep> tmpVector = new Vector<AnimationScriptStep>(); + for (AnimationScriptStep p : getSteps()) { + tmpVector.add(p.clone()); + } + AnimationScriptObject tmpObj = (AnimationScriptObject) super.clone(); + tmpObj.setSteps(tmpVector); + return tmpObj; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptStep.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptStep.java index a1841068c73801ec6aa007efe1e7d558506cecdd..4c9d39a1f1f97c91570e202d5fed6c6f97c7bc3b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptStep.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/AnimationScriptStep.java @@ -1,102 +1,102 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import java.util.ArrayList; - -import de.bmotionstudio.gef.editor.BindingObject; - -public class AnimationScriptStep extends BindingObject implements Cloneable { - - private String command; - private String parameter; - private int maxrandom = 1; - private transient ArrayList<ObserverCallBackObject> callBackList; - - public AnimationScriptStep() { - this("", ""); - } - - public AnimationScriptStep(String command, String parameter, - ArrayList<ObserverCallBackObject> callBackList) { - this.command = command; - this.parameter = parameter; - this.callBackList = callBackList; - } - - public AnimationScriptStep(String command, String parameter) { - this(command, parameter, new ArrayList<ObserverCallBackObject>()); - } - - public String getCommand() { - return command; - } - - public void setCommand(String command) { - Object oldValue = this.command; - this.command = command; - firePropertyChange("command", oldValue, this.command); - } - - public String getParameter() { - return parameter; - } - - public void setParameter(String parameter) { - Object oldValue = this.parameter; - this.parameter = parameter; - firePropertyChange("parameter", oldValue, this.parameter); - } - - public void setCallBackList(ArrayList<ObserverCallBackObject> callBackList) { - Object oldValue = this.callBackList; - this.callBackList = callBackList; - firePropertyChange("callBackList", oldValue, this.callBackList); - } - - public ArrayList<ObserverCallBackObject> getCallBackList() { - if (callBackList == null) - this.callBackList = new ArrayList<ObserverCallBackObject>(); - return this.callBackList; - } - - public void addCallBackObject(ObserverCallBackObject callBackObj) { - callBackList.add(callBackObj); - } - - public void removeCallBackObject(ObserverCallBackObject callBackObj) { - callBackList.remove(callBackObj); - } - - public AnimationScriptStep clone() throws CloneNotSupportedException { - ArrayList<ObserverCallBackObject> tmpList = new ArrayList<ObserverCallBackObject>(); - for (ObserverCallBackObject p : getCallBackList()) { - tmpList.add(p.clone()); - } - AnimationScriptStep tmpObj = (AnimationScriptStep) super.clone(); - tmpObj.setCallBackList(tmpList); - return tmpObj; - } - - public int getMaxrandom() { - return maxrandom; - } - - public void setMaxrandom(int maxrandom) { - Object oldValue = this.maxrandom; - this.maxrandom = maxrandom; - firePropertyChange("maxrandom", oldValue, this.maxrandom); - } - - public boolean isRandom() { - if (maxrandom > 1) - return true; - else - return false; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import java.util.ArrayList; + +import de.bmotionstudio.gef.editor.BindingObject; + +public class AnimationScriptStep extends BindingObject implements Cloneable { + + private String command; + private String parameter; + private int maxrandom = 1; + private transient ArrayList<ObserverCallBackObject> callBackList; + + public AnimationScriptStep() { + this("", ""); + } + + public AnimationScriptStep(String command, String parameter, + ArrayList<ObserverCallBackObject> callBackList) { + this.command = command; + this.parameter = parameter; + this.callBackList = callBackList; + } + + public AnimationScriptStep(String command, String parameter) { + this(command, parameter, new ArrayList<ObserverCallBackObject>()); + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + Object oldValue = this.command; + this.command = command; + firePropertyChange("command", oldValue, this.command); + } + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + Object oldValue = this.parameter; + this.parameter = parameter; + firePropertyChange("parameter", oldValue, this.parameter); + } + + public void setCallBackList(ArrayList<ObserverCallBackObject> callBackList) { + Object oldValue = this.callBackList; + this.callBackList = callBackList; + firePropertyChange("callBackList", oldValue, this.callBackList); + } + + public ArrayList<ObserverCallBackObject> getCallBackList() { + if (callBackList == null) + this.callBackList = new ArrayList<ObserverCallBackObject>(); + return this.callBackList; + } + + public void addCallBackObject(ObserverCallBackObject callBackObj) { + callBackList.add(callBackObj); + } + + public void removeCallBackObject(ObserverCallBackObject callBackObj) { + callBackList.remove(callBackObj); + } + + public AnimationScriptStep clone() throws CloneNotSupportedException { + ArrayList<ObserverCallBackObject> tmpList = new ArrayList<ObserverCallBackObject>(); + for (ObserverCallBackObject p : getCallBackList()) { + tmpList.add(p.clone()); + } + AnimationScriptStep tmpObj = (AnimationScriptStep) super.clone(); + tmpObj.setCallBackList(tmpList); + return tmpObj; + } + + public int getMaxrandom() { + return maxrandom; + } + + public void setMaxrandom(int maxrandom) { + Object oldValue = this.maxrandom; + this.maxrandom = maxrandom; + firePropertyChange("maxrandom", oldValue, this.maxrandom); + } + + public boolean isRandom() { + if (maxrandom > 1) + return true; + else + return false; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteAnimationScript.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteAnimationScript.java index 20a3c505bb4d594fe051a8be9c882774a7147878..dc5dd3e1d72abab6616d3ad484709cf97242e89d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteAnimationScript.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteAnimationScript.java @@ -1,162 +1,162 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteScheduler; -import de.bmotionstudio.gef.editor.util.BMSUtil; -import de.prob.core.Animator; -import de.prob.core.command.ExecuteOperationCommand; -import de.prob.core.command.GetCurrentStateIdCommand; -import de.prob.core.domainobjects.Operation; -import de.prob.exceptions.ProBException; - -public class ExecuteAnimationScript extends SchedulerEvent { - - public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript"; - - private List<AnimationScriptObject> list; - - private transient Random random; - - public ExecuteAnimationScript() { - this.list = new ArrayList<AnimationScriptObject>(); - } - - @Override - public void execute(final Animation animation, final BControl control) { - - // new Thread(new Runnable() { - // public void run() { - - // The animator - Animator animator = animation.getAnimator(); - - // Iterate schedulers - for (AnimationScriptObject obj : list) { - - // First evaluate predicate (predicate field) - // If true (execute operation sequence) - if (Boolean.valueOf(BMSUtil.parsePredicate(obj.getPredicate(), - control, animation))) { - - for (AnimationScriptStep step : obj.getSteps()) { - - try { - - String currentState = GetCurrentStateIdCommand - .getID(animator); - - List<Operation> operations = BMSUtil.parseOperation( - step.getCommand(), step.getParameter(), - step.getMaxrandom(), animation, currentState, - control); - - if (operations != null) { - - Operation executeOp; - - if (step.isRandom()) { - executeOp = operations.get(getRandomizer() - .nextInt(operations.size())); - } else { - executeOp = operations.get(0); - } - - ExecuteOperationCommand.executeOperation(animator, - executeOp); - - } else { - // TODO: error message!? - } - - } catch (ProBException e) { - e.printStackTrace(); - } - - } - - return; - - } - - } - // } - - // }).start(); - - } - - @Override - public SchedulerWizard getWizard(final BControl bcontrol) { - return new WizardExecuteScheduler(bcontrol, this); - } - - public ExecuteAnimationScript clone() throws CloneNotSupportedException { - ExecuteAnimationScript nse = (ExecuteAnimationScript) super.clone(); - List<AnimationScriptObject> list = new ArrayList<AnimationScriptObject>(); - for (AnimationScriptObject po : this.getList()) { - list.add(po.clone()); - } - nse.setList(list); - return nse; - } - - public void setList(final List<AnimationScriptObject> list) { - this.list = list; - } - - public List<AnimationScriptObject> getList() { - if (this.list == null) { - this.list = new ArrayList<AnimationScriptObject>(); - } - return list; - } - - private Random getRandomizer() { - if (random == null) - random = new Random(); - return random; - } - - // private boolean checkCallBack(ArrayList<ObserverCallBackObject> - // callBackList) { - // - // Boolean callback = false; - // - // for (ObserverCallBackObject callBackObj : callBackList) { - // - // BControl control = callBackObj.getControl(); - // Observer observer = control - // .getObserver(callBackObj.getObserverID()); - // - // Boolean oCallBack; - // - // if (observer != null) { - // oCallBack = observer.isCallBack(); - // } else { - // oCallBack = true; - // } - // - // if (!oCallBack) { - // callback = false; - // } else { - // callback = true; - // } - // - // } - // - // return callback; - // - // } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteScheduler; +import de.bmotionstudio.gef.editor.util.BMSUtil; +import de.prob.core.Animator; +import de.prob.core.command.ExecuteOperationCommand; +import de.prob.core.command.GetCurrentStateIdCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.exceptions.ProBException; + +public class ExecuteAnimationScript extends SchedulerEvent { + + public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript"; + + private List<AnimationScriptObject> list; + + private transient Random random; + + public ExecuteAnimationScript() { + this.list = new ArrayList<AnimationScriptObject>(); + } + + @Override + public void execute(final Animation animation, final BControl control) { + + // new Thread(new Runnable() { + // public void run() { + + // The animator + Animator animator = animation.getAnimator(); + + // Iterate schedulers + for (AnimationScriptObject obj : list) { + + // First evaluate predicate (predicate field) + // If true (execute operation sequence) + if (Boolean.valueOf(BMSUtil.parsePredicate(obj.getPredicate(), + control, animation))) { + + for (AnimationScriptStep step : obj.getSteps()) { + + try { + + String currentState = GetCurrentStateIdCommand + .getID(animator); + + List<Operation> operations = BMSUtil.parseOperation( + step.getCommand(), step.getParameter(), + step.getMaxrandom(), animation, currentState, + control); + + if (operations != null) { + + Operation executeOp; + + if (step.isRandom()) { + executeOp = operations.get(getRandomizer() + .nextInt(operations.size())); + } else { + executeOp = operations.get(0); + } + + ExecuteOperationCommand.executeOperation(animator, + executeOp); + + } else { + // TODO: error message!? + } + + } catch (ProBException e) { + e.printStackTrace(); + } + + } + + return; + + } + + } + // } + + // }).start(); + + } + + @Override + public SchedulerWizard getWizard(final BControl bcontrol) { + return new WizardExecuteScheduler(bcontrol, this); + } + + public ExecuteAnimationScript clone() throws CloneNotSupportedException { + ExecuteAnimationScript nse = (ExecuteAnimationScript) super.clone(); + List<AnimationScriptObject> list = new ArrayList<AnimationScriptObject>(); + for (AnimationScriptObject po : this.getList()) { + list.add(po.clone()); + } + nse.setList(list); + return nse; + } + + public void setList(final List<AnimationScriptObject> list) { + this.list = list; + } + + public List<AnimationScriptObject> getList() { + if (this.list == null) { + this.list = new ArrayList<AnimationScriptObject>(); + } + return list; + } + + private Random getRandomizer() { + if (random == null) + random = new Random(); + return random; + } + + // private boolean checkCallBack(ArrayList<ObserverCallBackObject> + // callBackList) { + // + // Boolean callback = false; + // + // for (ObserverCallBackObject callBackObj : callBackList) { + // + // BControl control = callBackObj.getControl(); + // Observer observer = control + // .getObserver(callBackObj.getObserverID()); + // + // Boolean oCallBack; + // + // if (observer != null) { + // oCallBack = observer.isCallBack(); + // } else { + // oCallBack = true; + // } + // + // if (!oCallBack) { + // callback = false; + // } else { + // callback = true; + // } + // + // } + // + // return callback; + // + // } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicate.java index c9114041dd765a0295d88fd92576e5e6278d4090..9b192f74a084c9bd45a1f6d90d7cd8129fd3edad 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicate.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicate.java @@ -1,106 +1,106 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import java.util.List; -import java.util.Random; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteOperationByPredicate; -import de.bmotionstudio.gef.editor.util.BMSUtil; -import de.prob.core.Animator; -import de.prob.core.command.ExecuteOperationCommand; -import de.prob.core.command.GetCurrentStateIdCommand; -import de.prob.core.domainobjects.Operation; -import de.prob.exceptions.ProBException; - -public class ExecuteOperationByPredicate extends SchedulerEvent { - - public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate"; - - private PredicateOperation predicateOperation; - - private transient Random random; - - @Override - public void execute(final Animation animation, final BControl control) { - - new Thread(new Runnable() { - public void run() { - - try { - // The animator - final Animator animator = animation.getAnimator(); - - String currentState = GetCurrentStateIdCommand - .getID(animator); - - List<Operation> operations = BMSUtil.parseOperation( - predicateOperation.getOperationName(), - predicateOperation.getPredicate(), - predicateOperation.getMaxrandom(), animation, - currentState, control); - - if (operations != null) { - - Operation executeOp; - - if (predicateOperation.isRandom()) { - executeOp = operations.get(getRandomizer().nextInt( - operations.size())); - } else { - executeOp = operations.get(0); - } - - ExecuteOperationCommand.executeOperation(animator, - executeOp); - - } else { - // TODO: error message!? - } - - } catch (ProBException e) { - e.printStackTrace(); - } - - } - - }).start(); - - } - - @Override - public SchedulerWizard getWizard(BControl bcontrol) { - return new WizardExecuteOperationByPredicate(bcontrol, this); - } - - public void setPredicateOperation(PredicateOperation predicateOperation) { - this.predicateOperation = predicateOperation; - } - - public PredicateOperation getPredicateOperation() { - if (this.predicateOperation == null) - this.predicateOperation = new PredicateOperation(); - return this.predicateOperation; - } - - public ExecuteOperationByPredicate clone() - throws CloneNotSupportedException { - ExecuteOperationByPredicate nse = (ExecuteOperationByPredicate) super - .clone(); - nse.setPredicateOperation(predicateOperation.clone()); - return nse; - } - - private Random getRandomizer() { - if (random == null) - random = new Random(); - return random; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import java.util.List; +import java.util.Random; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteOperationByPredicate; +import de.bmotionstudio.gef.editor.util.BMSUtil; +import de.prob.core.Animator; +import de.prob.core.command.ExecuteOperationCommand; +import de.prob.core.command.GetCurrentStateIdCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.exceptions.ProBException; + +public class ExecuteOperationByPredicate extends SchedulerEvent { + + public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate"; + + private PredicateOperation predicateOperation; + + private transient Random random; + + @Override + public void execute(final Animation animation, final BControl control) { + + new Thread(new Runnable() { + public void run() { + + try { + // The animator + final Animator animator = animation.getAnimator(); + + String currentState = GetCurrentStateIdCommand + .getID(animator); + + List<Operation> operations = BMSUtil.parseOperation( + predicateOperation.getOperationName(), + predicateOperation.getPredicate(), + predicateOperation.getMaxrandom(), animation, + currentState, control); + + if (operations != null) { + + Operation executeOp; + + if (predicateOperation.isRandom()) { + executeOp = operations.get(getRandomizer().nextInt( + operations.size())); + } else { + executeOp = operations.get(0); + } + + ExecuteOperationCommand.executeOperation(animator, + executeOp); + + } else { + // TODO: error message!? + } + + } catch (ProBException e) { + e.printStackTrace(); + } + + } + + }).start(); + + } + + @Override + public SchedulerWizard getWizard(BControl bcontrol) { + return new WizardExecuteOperationByPredicate(bcontrol, this); + } + + public void setPredicateOperation(PredicateOperation predicateOperation) { + this.predicateOperation = predicateOperation; + } + + public PredicateOperation getPredicateOperation() { + if (this.predicateOperation == null) + this.predicateOperation = new PredicateOperation(); + return this.predicateOperation; + } + + public ExecuteOperationByPredicate clone() + throws CloneNotSupportedException { + ExecuteOperationByPredicate nse = (ExecuteOperationByPredicate) super + .clone(); + nse.setPredicateOperation(predicateOperation.clone()); + return nse; + } + + private Random getRandomizer() { + if (random == null) + random = new Random(); + return random; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicateMulti.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicateMulti.java index 6f9b9044c4fc87feb207c2ff6f15b5ec5cd917f1..4f41cb5b2607551072959f69fc69834caf7913c8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicateMulti.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ExecuteOperationByPredicateMulti.java @@ -1,78 +1,78 @@ -package de.bmotionstudio.gef.editor.scheduler; - -import java.util.ArrayList; - -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.BindingObject; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteOperationByPredicateMulti; -import de.bmotionstudio.gef.editor.util.BMSUtil; - -public class ExecuteOperationByPredicateMulti extends SchedulerEvent { - - public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti"; - - private ArrayList<BindingObject> operationList; - - public ExecuteOperationByPredicateMulti() { - this.operationList = new ArrayList<BindingObject>(); - } - - @Override - public void execute(final Animation animation, final BControl control) { - - for (BindingObject op : operationList) { - - String bolValue = "true"; - String executePredicate = ((PredicateOperation) op) - .getExecutePredicate(); - - if (executePredicate != null && executePredicate.length() > 0) { - bolValue = BMSUtil.parsePredicate(executePredicate, control, - animation); - } - - if (Boolean.valueOf(bolValue)) { // If true - executeOperation(animation, (PredicateOperation) op, control); - break; // Execute only the first operation which is true - } - - } - - } - - private void executeOperation(final Animation animation, - final PredicateOperation predicateOperation, final BControl control) { - ExecuteOperationByPredicate executeCmd = new ExecuteOperationByPredicate(); - executeCmd.setPredicateOperation(predicateOperation); - executeCmd.execute(animation, control); - } - - @Override - public SchedulerWizard getWizard(BControl bcontrol) { - return new WizardExecuteOperationByPredicateMulti(bcontrol, this); - } - - public void setOperationList(ArrayList<BindingObject> operationList) { - this.operationList = operationList; - } - - public ArrayList<BindingObject> getOperationList() { - if (operationList == null) - operationList = new ArrayList<BindingObject>(); - return operationList; - } - - public ExecuteOperationByPredicateMulti clone() - throws CloneNotSupportedException { - ExecuteOperationByPredicateMulti nse = (ExecuteOperationByPredicateMulti) super - .clone(); - ArrayList<BindingObject> opList = new ArrayList<BindingObject>(); - for (BindingObject p : getOperationList()) { - opList.add(((PredicateOperation) p).clone()); - } - nse.setOperationList(opList); - return nse; - } - -} +package de.bmotionstudio.gef.editor.scheduler; + +import java.util.ArrayList; + +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.BindingObject; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.wizard.WizardExecuteOperationByPredicateMulti; +import de.bmotionstudio.gef.editor.util.BMSUtil; + +public class ExecuteOperationByPredicateMulti extends SchedulerEvent { + + public static String ID = "de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti"; + + private ArrayList<BindingObject> operationList; + + public ExecuteOperationByPredicateMulti() { + this.operationList = new ArrayList<BindingObject>(); + } + + @Override + public void execute(final Animation animation, final BControl control) { + + for (BindingObject op : operationList) { + + String bolValue = "true"; + String executePredicate = ((PredicateOperation) op) + .getExecutePredicate(); + + if (executePredicate != null && executePredicate.length() > 0) { + bolValue = BMSUtil.parsePredicate(executePredicate, control, + animation); + } + + if (Boolean.valueOf(bolValue)) { // If true + executeOperation(animation, (PredicateOperation) op, control); + break; // Execute only the first operation which is true + } + + } + + } + + private void executeOperation(final Animation animation, + final PredicateOperation predicateOperation, final BControl control) { + ExecuteOperationByPredicate executeCmd = new ExecuteOperationByPredicate(); + executeCmd.setPredicateOperation(predicateOperation); + executeCmd.execute(animation, control); + } + + @Override + public SchedulerWizard getWizard(BControl bcontrol) { + return new WizardExecuteOperationByPredicateMulti(bcontrol, this); + } + + public void setOperationList(ArrayList<BindingObject> operationList) { + this.operationList = operationList; + } + + public ArrayList<BindingObject> getOperationList() { + if (operationList == null) + operationList = new ArrayList<BindingObject>(); + return operationList; + } + + public ExecuteOperationByPredicateMulti clone() + throws CloneNotSupportedException { + ExecuteOperationByPredicateMulti nse = (ExecuteOperationByPredicateMulti) super + .clone(); + ArrayList<BindingObject> opList = new ArrayList<BindingObject>(); + for (BindingObject p : getOperationList()) { + opList.add(((PredicateOperation) p).clone()); + } + nse.setOperationList(opList); + return nse; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ObserverCallBackObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ObserverCallBackObject.java index c9ace783cc4eb2317dcaf2764b7263374247ca0e..aadd6277b011f5e48aaa71d8624fff674e683746 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ObserverCallBackObject.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/ObserverCallBackObject.java @@ -1,51 +1,51 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import de.bmotionstudio.gef.editor.BindingObject; -import de.bmotionstudio.gef.editor.model.BControl; - -public class ObserverCallBackObject extends BindingObject implements Cloneable { - - private BControl control; - private String observerID; - - public ObserverCallBackObject(BControl control, String observerID) { - this.control = control; - this.observerID = observerID; - } - - public ObserverCallBackObject() { - this(null, ""); - } - - public BControl getControl() { - return control; - } - - public void setControl(BControl control) { - Object oldValue = this.control; - this.control = control; - firePropertyChange("control", oldValue, this.control); - } - - public String getObserverID() { - return observerID; - } - - public void setObserverID(String observerID) { - Object oldValue = this.observerID; - this.observerID = observerID; - firePropertyChange("observerID", oldValue, this.observerID); - } - - public ObserverCallBackObject clone() throws CloneNotSupportedException { - ObserverCallBackObject tmpObj = (ObserverCallBackObject) super.clone(); - return tmpObj; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import de.bmotionstudio.gef.editor.BindingObject; +import de.bmotionstudio.gef.editor.model.BControl; + +public class ObserverCallBackObject extends BindingObject implements Cloneable { + + private BControl control; + private String observerID; + + public ObserverCallBackObject(BControl control, String observerID) { + this.control = control; + this.observerID = observerID; + } + + public ObserverCallBackObject() { + this(null, ""); + } + + public BControl getControl() { + return control; + } + + public void setControl(BControl control) { + Object oldValue = this.control; + this.control = control; + firePropertyChange("control", oldValue, this.control); + } + + public String getObserverID() { + return observerID; + } + + public void setObserverID(String observerID) { + Object oldValue = this.observerID; + this.observerID = observerID; + firePropertyChange("observerID", oldValue, this.observerID); + } + + public ObserverCallBackObject clone() throws CloneNotSupportedException { + ObserverCallBackObject tmpObj = (ObserverCallBackObject) super.clone(); + return tmpObj; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/PredicateOperation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/PredicateOperation.java index 5c715bf975ca54048d2b47aae0e72c2e2c4d90c4..a8b27599bfeabc3a4fcd8321f972457109ee848f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/PredicateOperation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/PredicateOperation.java @@ -1,86 +1,86 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; - -public class PredicateOperation extends ObserverEvalObject implements Cloneable { - - private String operationName; - private String executePredicate; - private String predicate; - private boolean random; - private int maxrandom = 1; - - public PredicateOperation() { - this("", ""); - } - - public PredicateOperation(String operationName, String predicate) { - this.operationName = operationName; - this.predicate = predicate; - } - - public void setOperationName(String operationName) { - Object oldValue = this.operationName; - this.operationName = operationName; - firePropertyChange("operationName", oldValue, this.operationName); - } - - public String getOperationName() { - return operationName; - } - - public void setPredicate(String predicate) { - Object oldValue = this.predicate; - this.predicate = predicate; - firePropertyChange("predicate", oldValue, this.predicate); - } - - public String getPredicate() { - return predicate; - } - - public void setRandom(boolean random) { - Object oldValue = this.random; - this.random = random; - firePropertyChange("random", oldValue, this.random); - } - - public boolean isRandom() { - return random; - } - - public boolean getIsRandom() { - return isRandom(); - } - - public void setMaxrandom(int maxrandom) { - Object oldValue = this.maxrandom; - this.maxrandom = maxrandom; - firePropertyChange("maxrandom", oldValue, this.maxrandom); - } - - public int getMaxrandom() { - return maxrandom; - } - - public PredicateOperation clone() throws CloneNotSupportedException { - return (PredicateOperation) super.clone(); - } - - public void setExecutePredicate(String executePredicate) { - Object oldValue = this.executePredicate; - this.executePredicate = executePredicate; - firePropertyChange("executePredicate", oldValue, this.executePredicate); - } - - public String getExecutePredicate() { - return executePredicate; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; + +public class PredicateOperation extends ObserverEvalObject implements Cloneable { + + private String operationName; + private String executePredicate; + private String predicate; + private boolean random; + private int maxrandom = 1; + + public PredicateOperation() { + this("", ""); + } + + public PredicateOperation(String operationName, String predicate) { + this.operationName = operationName; + this.predicate = predicate; + } + + public void setOperationName(String operationName) { + Object oldValue = this.operationName; + this.operationName = operationName; + firePropertyChange("operationName", oldValue, this.operationName); + } + + public String getOperationName() { + return operationName; + } + + public void setPredicate(String predicate) { + Object oldValue = this.predicate; + this.predicate = predicate; + firePropertyChange("predicate", oldValue, this.predicate); + } + + public String getPredicate() { + return predicate; + } + + public void setRandom(boolean random) { + Object oldValue = this.random; + this.random = random; + firePropertyChange("random", oldValue, this.random); + } + + public boolean isRandom() { + return random; + } + + public boolean getIsRandom() { + return isRandom(); + } + + public void setMaxrandom(int maxrandom) { + Object oldValue = this.maxrandom; + this.maxrandom = maxrandom; + firePropertyChange("maxrandom", oldValue, this.maxrandom); + } + + public int getMaxrandom() { + return maxrandom; + } + + public PredicateOperation clone() throws CloneNotSupportedException { + return (PredicateOperation) super.clone(); + } + + public void setExecutePredicate(String executePredicate) { + Object oldValue = this.executePredicate; + this.executePredicate = executePredicate; + firePropertyChange("executePredicate", oldValue, this.executePredicate); + } + + public String getExecutePredicate() { + return executePredicate; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerEvent.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerEvent.java index acc22a77cfb4ce228782038c422420071bde5da9..1b2a5edc0eb94a803f07b58af01125fec7e5d2c5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerEvent.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerEvent.java @@ -1,90 +1,90 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import org.eclipse.core.runtime.IConfigurationElement; - -import de.bmotionstudio.gef.editor.AbstractExpressionControl; -import de.bmotionstudio.gef.editor.Animation; -import de.bmotionstudio.gef.editor.BMotionEditorPlugin; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * - * Scheduler Events are assigned to events (i.e. on-click event) or to - * schedulers. A scheduler is an independent thread attempting to execute a set - * of scheduler events. It is very useful when the user does not want to execute - * each scheduler event by hand during an animation. - * - * @author Lukas Ladenberger - * - */ -public abstract class SchedulerEvent extends AbstractExpressionControl - implements Cloneable { - - private transient String eventID; - - public SchedulerEvent() { - init(); - } - - protected Object readResolve() { - init(); - return this; - } - - /** - * Method to initialize the scheduler event. Gets the ID, name and - * description from the corresponding extension point - */ - private void init() { - IConfigurationElement configElement = BMotionEditorPlugin - .getSchedulerExtension(getClass().getName()); - if (configElement != null) { - this.ID = configElement.getAttribute("class"); - this.name = configElement.getAttribute("name"); - this.description = configElement.getAttribute("description"); - } - } - - public void setEventID(String eventID) { - this.eventID = eventID; - } - - public String getEventID() { - return eventID; - } - - /** - * Executes the scheduler event (i.e. execute operation). - * - * @param animation - * The running animation - * @param bcontrol - * The corresponding control - */ - public abstract void execute(Animation animation, BControl bcontrol); - - /** - * Returns a corresponding wizard for the scheduler event. - * - * @param bcontrol - * The corresponding control - * @return the corresponding wizard - */ - public abstract SchedulerWizard getWizard(BControl bcontrol); - - /** - * Makes a copy of the scheduler event - * - * @return the cloned scheduler event - */ - public SchedulerEvent clone() throws CloneNotSupportedException { - return (SchedulerEvent) super.clone(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import org.eclipse.core.runtime.IConfigurationElement; + +import de.bmotionstudio.gef.editor.AbstractExpressionControl; +import de.bmotionstudio.gef.editor.Animation; +import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * + * Scheduler Events are assigned to events (i.e. on-click event) or to + * schedulers. A scheduler is an independent thread attempting to execute a set + * of scheduler events. It is very useful when the user does not want to execute + * each scheduler event by hand during an animation. + * + * @author Lukas Ladenberger + * + */ +public abstract class SchedulerEvent extends AbstractExpressionControl + implements Cloneable { + + private transient String eventID; + + public SchedulerEvent() { + init(); + } + + protected Object readResolve() { + init(); + return this; + } + + /** + * Method to initialize the scheduler event. Gets the ID, name and + * description from the corresponding extension point + */ + private void init() { + IConfigurationElement configElement = BMotionEditorPlugin + .getSchedulerExtension(getClass().getName()); + if (configElement != null) { + this.ID = configElement.getAttribute("class"); + this.name = configElement.getAttribute("name"); + this.description = configElement.getAttribute("description"); + } + } + + public void setEventID(String eventID) { + this.eventID = eventID; + } + + public String getEventID() { + return eventID; + } + + /** + * Executes the scheduler event (i.e. execute operation). + * + * @param animation + * The running animation + * @param bcontrol + * The corresponding control + */ + public abstract void execute(Animation animation, BControl bcontrol); + + /** + * Returns a corresponding wizard for the scheduler event. + * + * @param bcontrol + * The corresponding control + * @return the corresponding wizard + */ + public abstract SchedulerWizard getWizard(BControl bcontrol); + + /** + * Makes a copy of the scheduler event + * + * @return the cloned scheduler event + */ + public SchedulerEvent clone() throws CloneNotSupportedException { + return (SchedulerEvent) super.clone(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerWizard.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerWizard.java index 11cdbb4316faab8776c1911c7af9e1b776a2f6ff..b52aae605165b62520d4d77e8d4306ff3338fdcc 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerWizard.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/SchedulerWizard.java @@ -1,60 +1,60 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler; - -import org.eclipse.swt.graphics.Point; - -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.model.BControl; - -/** - * - * The BMotion Studio provides an easy way to handle Scheduler Events. For this, - * Scheduler Events can have a corresponding dialog. The user can open it by - * calling the context menu of a B-Control. - * - * @author Lukas Ladenberger - * - */ -public abstract class SchedulerWizard extends BMotionAbstractWizard { - - private SchedulerEvent event; - - protected Boolean eventDelete = false; - - public SchedulerWizard(BControl control, SchedulerEvent scheduler) { - super(control); - this.event = scheduler; - } - - public SchedulerEvent getScheduler() { - return this.event; - } - - protected abstract Boolean prepareToFinish(); - - @Override - public boolean performFinish() { - return prepareToFinish(); - } - - protected void setEventDelete(Boolean b) { - this.eventDelete = b; - } - - public Boolean isEventDelete() { - return this.eventDelete; - } - - public abstract Point getSize(); - - @Override - public String getName() { - return event.getName(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler; + +import org.eclipse.swt.graphics.Point; + +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.model.BControl; + +/** + * + * The BMotion Studio provides an easy way to handle Scheduler Events. For this, + * Scheduler Events can have a corresponding dialog. The user can open it by + * calling the context menu of a B-Control. + * + * @author Lukas Ladenberger + * + */ +public abstract class SchedulerWizard extends BMotionAbstractWizard { + + private SchedulerEvent event; + + protected Boolean eventDelete = false; + + public SchedulerWizard(BControl control, SchedulerEvent scheduler) { + super(control); + this.event = scheduler; + } + + public SchedulerEvent getScheduler() { + return this.event; + } + + protected abstract Boolean prepareToFinish(); + + @Override + public boolean performFinish() { + return prepareToFinish(); + } + + protected void setEventDelete(Boolean b) { + this.eventDelete = b; + } + + public Boolean isEventDelete() { + return this.eventDelete; + } + + public abstract Point getSize(); + + @Override + public String getName() { + return event.getName(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/SchedulerObjectDialog.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/SchedulerObjectDialog.java index 58f0627cfc3d636fd2c249d7b8908947a499e153..48f20af70143bf1d6a0eb62ab5609cd1d512930a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/SchedulerObjectDialog.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/SchedulerObjectDialog.java @@ -1,220 +1,220 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerCellEditor; -import de.bmotionstudio.gef.editor.scheduler.AnimationScriptObject; -import de.bmotionstudio.gef.editor.scheduler.AnimationScriptStep; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class SchedulerObjectDialog extends Dialog { - - private TableViewer tableViewer; - - private final BControl control; - - private AnimationScriptObject animationScriptObject; - - public SchedulerObjectDialog(Shell parentShell, BControl control, - AnimationScriptObject animationScriptObject) { - super(parentShell); - this.control = control; - this.animationScriptObject = animationScriptObject; - } - - @Override - protected Control createDialogArea(final Composite parent) { - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = (Composite) super.createDialogArea(parent); - container.setLayout(new GridLayout(1, true)); - - tableViewer = BMotionWizardUtil - .createBMotionWizardTableViewer(container, - AnimationScriptStep.class, "Scheduler Object Dialog"); - - TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Operation"); - column.getColumn().setWidth(175); - column.setEditingSupport(new OperationValueEditingSupport(tableViewer, - control) { - - @Override - protected Object getValue(Object element) { - return ((AnimationScriptStep) element).getCommand(); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) - ((AnimationScriptStep) element).setCommand(value.toString()); - } - - }); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(300); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, dbc, - "parameter", control.getVisualization(), getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Random Ops"); - column.getColumn().setWidth(100); - column.setEditingSupport(new RandomModeEditingSupport(tableViewer)); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - tableViewer.setLabelProvider(new ObservableMapLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "command", "parameter", "maxrandom" })) { - - @Override - public Image getColumnImage(final Object element, - final int columnIndex) { - return null; - } - - }); - - final WritableList input = new WritableList( - animationScriptObject.getSteps(), AnimationScriptStep.class); - - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - AnimationScriptStep obj = (AnimationScriptStep) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(obj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_ADD)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - AnimationScriptStep obj = new AnimationScriptStep(); - input.add(obj); - } - }); - - return container; - - } - - @Override - protected Point getInitialSize() { - return new Point(600, 500); - } - - @Override - protected void okPressed() { - close(); - } - - @Override - protected void configureShell(final Shell newShell) { - super.configureShell(newShell); - newShell.setText("BMotion Studio - Scheduler Editor"); - } - - public void setAnimationScriptObject( - final AnimationScriptObject animationScriptObject) { - this.animationScriptObject = animationScriptObject; - } - - public AnimationScriptObject getAnimationScriptObject() { - return animationScriptObject; - } - - private static class RandomModeEditingSupport extends EditingSupport { - - private CellEditor cellEditor; - - public RandomModeEditingSupport(ColumnViewer viewer) { - super(viewer); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) { - Integer maxnr = Integer.valueOf(value.toString()); - AnimationScriptStep obj = (AnimationScriptStep) element; - obj.setMaxrandom(maxnr); - } - } - - @Override - protected Object getValue(Object element) { - return ((AnimationScriptStep) element).getMaxrandom(); - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - cellEditor = new IntegerCellEditor((Composite) getViewer() - .getControl()); - } - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerCellEditor; +import de.bmotionstudio.gef.editor.scheduler.AnimationScriptObject; +import de.bmotionstudio.gef.editor.scheduler.AnimationScriptStep; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class SchedulerObjectDialog extends Dialog { + + private TableViewer tableViewer; + + private final BControl control; + + private AnimationScriptObject animationScriptObject; + + public SchedulerObjectDialog(Shell parentShell, BControl control, + AnimationScriptObject animationScriptObject) { + super(parentShell); + this.control = control; + this.animationScriptObject = animationScriptObject; + } + + @Override + protected Control createDialogArea(final Composite parent) { + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = (Composite) super.createDialogArea(parent); + container.setLayout(new GridLayout(1, true)); + + tableViewer = BMotionWizardUtil + .createBMotionWizardTableViewer(container, + AnimationScriptStep.class, "Scheduler Object Dialog"); + + TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Operation"); + column.getColumn().setWidth(175); + column.setEditingSupport(new OperationValueEditingSupport(tableViewer, + control) { + + @Override + protected Object getValue(Object element) { + return ((AnimationScriptStep) element).getCommand(); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) + ((AnimationScriptStep) element).setCommand(value.toString()); + } + + }); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(300); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, dbc, + "parameter", control.getVisualization(), getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Random Ops"); + column.getColumn().setWidth(100); + column.setEditingSupport(new RandomModeEditingSupport(tableViewer)); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + tableViewer.setLabelProvider(new ObservableMapLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "command", "parameter", "maxrandom" })) { + + @Override + public Image getColumnImage(final Object element, + final int columnIndex) { + return null; + } + + }); + + final WritableList input = new WritableList( + animationScriptObject.getSteps(), AnimationScriptStep.class); + + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + AnimationScriptStep obj = (AnimationScriptStep) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(obj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_ADD)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + AnimationScriptStep obj = new AnimationScriptStep(); + input.add(obj); + } + }); + + return container; + + } + + @Override + protected Point getInitialSize() { + return new Point(600, 500); + } + + @Override + protected void okPressed() { + close(); + } + + @Override + protected void configureShell(final Shell newShell) { + super.configureShell(newShell); + newShell.setText("BMotion Studio - Scheduler Editor"); + } + + public void setAnimationScriptObject( + final AnimationScriptObject animationScriptObject) { + this.animationScriptObject = animationScriptObject; + } + + public AnimationScriptObject getAnimationScriptObject() { + return animationScriptObject; + } + + private static class RandomModeEditingSupport extends EditingSupport { + + private CellEditor cellEditor; + + public RandomModeEditingSupport(ColumnViewer viewer) { + super(viewer); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) { + Integer maxnr = Integer.valueOf(value.toString()); + AnimationScriptStep obj = (AnimationScriptStep) element; + obj.setMaxrandom(maxnr); + } + } + + @Override + protected Object getValue(Object element) { + return ((AnimationScriptStep) element).getMaxrandom(); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + cellEditor = new IntegerCellEditor((Composite) getViewer() + .getControl()); + } + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return true; + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicate.java index 384a7fe54ab554bddc519823dcba7b5386ee0728..8ee01a562c751054d1d0f1ac8bb470ee8d65d22b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicate.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicate.java @@ -1,320 +1,320 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.observable.value.IValueChangeListener; -import org.eclipse.core.databinding.observable.value.ValueChangeEvent; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.databinding.viewers.ViewersObservables; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; -import de.bmotionstudio.gef.editor.eventb.EventBHelper; -import de.bmotionstudio.gef.editor.eventb.MachineContentObject; -import de.bmotionstudio.gef.editor.eventb.MachineOperation; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; -import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; - -public class WizardExecuteOperationByPredicate extends SchedulerWizard { - - private class SchedulerExecuteOperationByPredicatePage extends WizardPage { - - private ComboViewer cbOperation; - - private Text txtPredicate; - - private Text txtMaxRandomOperations; - - private Label lbMaxRandomOperations; - - private Composite container; - - private Label renderedOpLabel; - - private Button checkboxRandomMode; - - private ScrolledComposite c1; - - public ComboViewer getCbOperation() { - return cbOperation; - } - - public Text getTxtMaxRandomOperations() { - return txtMaxRandomOperations; - } - - protected SchedulerExecuteOperationByPredicatePage(String pageName) { - super(pageName); - } - - public void createControl(final Composite parent) { - - final DataBindingContext dbc = new DataBindingContext(); - - container = new Composite(parent, SWT.NONE); - GridLayout gl = new GridLayout(2, false); - container.setLayout(gl); - - Label lb = new Label(container, SWT.NONE); - lb.setText("Select an operation: "); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.heightHint = 50; - - cbOperation = new ComboViewer(container, SWT.NONE); - cbOperation.getCombo().setLayoutData(new GridData(300, 50)); - - lb = new Label(container, SWT.NONE); - lb.setText("Predicate: "); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - txtPredicate = new Text(container, SWT.BORDER | SWT.WRAP - | SWT.V_SCROLL); - txtPredicate.setLayoutData(gd); - - lb = new Label(container, SWT.NONE); - lb.setText("Random mode: "); - lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - checkboxRandomMode = new Button(container, SWT.CHECK); - checkboxRandomMode.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - setRandomVisibility(checkboxRandomMode.getSelection()); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - lbMaxRandomOperations = new Label(container, SWT.NONE); - lbMaxRandomOperations.setText("Max Random Operations: "); - lbMaxRandomOperations.setLayoutData(new GridData( - GridData.VERTICAL_ALIGN_BEGINNING)); - txtMaxRandomOperations = new Text(container, SWT.BORDER); - txtMaxRandomOperations.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL)); - txtMaxRandomOperations.addVerifyListener(new VerifyListener() { - @Override - public void verifyText(VerifyEvent e) { - String string = e.text; - char[] chars = new char[string.length()]; - string.getChars(0, chars.length, chars, 0); - for (int i = 0; i < chars.length; i++) { - if (!('0' <= chars[i] && chars[i] <= '9')) { - e.doit = false; - return; - } - } - } - }); - setRandomVisibility(((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation().isRandom()); - - initBindings(dbc); - - IStructuredSelection structuredSelection = (IStructuredSelection) cbOperation - .getSelection(); - - if (!structuredSelection.isEmpty()) { - createRenderedOperationContainer((MachineOperation) structuredSelection - .getFirstElement()); - } - - setControl(container); - - } - - private void setRandomVisibility(boolean b) { - if (lbMaxRandomOperations == null || txtMaxRandomOperations == null) - return; - lbMaxRandomOperations.setVisible(b); - txtMaxRandomOperations.setVisible(b); - } - - private void initBindings(DataBindingContext dbc) { - - // MachineContentList operationList = BMotionEditorPlugin - // .getActiveEditor().getVisualization().getOperationList(); - // operationList.getMap().remove("INITIALISATION"); - - ObservableListContentProvider cbOpContentProvider = new ObservableListContentProvider(); - cbOperation.setContentProvider(cbOpContentProvider); - IObservableMap[] attributeMaps = BeansObservables.observeMaps( - cbOpContentProvider.getKnownElements(), - MachineContentObject.class, new String[] { "label" }); - cbOperation.setLabelProvider(new ObservableMapLabelProvider( - attributeMaps)); - cbOperation.setInput(new WritableList(EventBHelper - .getOperations(getBControl().getVisualization()), - MachineOperation.class)); - cbOperation.getCombo().setFont( - new Font(Display.getDefault(), new FontData("Arial", 10, - SWT.NONE))); - - final IObservableValue observeSelection = ViewersObservables - .observeSingleSelection(cbOperation); - - dbc.bindValue(SWTObservables.observeSelection(cbOperation - .getCombo()), BeansObservables.observeValue( - ((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation(), "operationName"), null, - null); - - dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), - BeansObservables.observeValue( - ((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation(), "predicate")); - - observeSelection.addValueChangeListener(new IValueChangeListener() { - public void handleValueChange(ValueChangeEvent event) { - Object sel = event.getObservableValue().getValue(); - createRenderedOperationContainer((MachineOperation) sel); - } - }); - - dbc.bindValue(SWTObservables.observeSelection(checkboxRandomMode), - BeansObservables.observeValue( - ((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation(), "random")); - - dbc.bindValue(SWTObservables.observeText(txtMaxRandomOperations, - SWT.Modify), BeansObservables.observeValue( - ((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation(), "maxrandom")); - - } - - private void createRenderedOperationContainer(MachineOperation op) { - - if (c1 != null) - c1.dispose(); - - GridLayout gl = new GridLayout(1, true); - gl.marginLeft = 5; - gl.marginTop = 5; - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 2; - - c1 = new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL - | SWT.V_SCROLL); - c1.setBackground(ColorConstants.red); - c1.setLayoutData(gd); - - Composite cp = new Composite(c1, SWT.NONE); - cp.setLayout(gl); - - renderedOpLabel = new Label(cp, SWT.NONE); - renderedOpLabel.setLayoutData(gd); - renderedOpLabel.setText(op.getRenderedOperation()); - renderedOpLabel.setFont(JFaceResources.getFontRegistry().get( - BMotionStudioSWTConstants.RODIN_FONT_KEY)); - - c1.setContent(cp); - c1.setExpandHorizontal(true); - c1.setExpandVertical(true); - c1.setMinSize(cp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - - container.layout(); - - } - - } - - public WizardExecuteOperationByPredicate(BControl bcontrol, - SchedulerEvent scheduler) { - super(bcontrol, scheduler); - addPage(new SchedulerExecuteOperationByPredicatePage( - "SchedulerExecuteOperationByPredicatePage")); - } - - @Override - protected Boolean prepareToFinish() { - - SchedulerExecuteOperationByPredicatePage page = (SchedulerExecuteOperationByPredicatePage) getPage("SchedulerExecuteOperationByPredicatePage"); - - String errorStr = ""; - - if (((ExecuteOperationByPredicate) getScheduler()) - .getPredicateOperation().isRandom() - && !(Integer - .valueOf(page.getTxtMaxRandomOperations().getText()) > 0)) - errorStr += "Max Random Operations must be greater than 0.\n"; - - if (page.getCbOperation().getCombo().getSelectionIndex() == -1) - errorStr += "Please select an operation.\n"; - - if (errorStr.length() > 0) { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "An Error occured", errorStr); - return false; - } - - // PredicateOperation predicateOperation = - // ((ExecuteOperationByPredicate) getScheduler()) - // .getPredicateOperation(); - // - // Observer observer = getBControl().getObserver( - // ListenOperationByPredicate.ID); - // ListenOperationByPredicate listenObserver; - // - // if (observer != null) { - // listenObserver = (ListenOperationByPredicate) observer; - // listenObserver - // .removePredicateOperationByUniqueID(predicateOperation - // .getUniqueID()); - // } else { - // listenObserver = new ListenOperationByPredicate(); - // getBControl().addObserver(listenObserver); - // } - // - // try { - // listenObserver.addPredicateOperation(predicateOperation.clone()); - // } catch (CloneNotSupportedException e) { - // e.printStackTrace(); - // } - - return true; - - } - - @Override - public Point getSize() { - return new Point(600, 600); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.observable.value.IValueChangeListener; +import org.eclipse.core.databinding.observable.value.ValueChangeEvent; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.databinding.viewers.ViewersObservables; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import de.bmotionstudio.gef.editor.BMotionStudioSWTConstants; +import de.bmotionstudio.gef.editor.eventb.EventBHelper; +import de.bmotionstudio.gef.editor.eventb.MachineContentObject; +import de.bmotionstudio.gef.editor.eventb.MachineOperation; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicate; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; +import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; + +public class WizardExecuteOperationByPredicate extends SchedulerWizard { + + private class SchedulerExecuteOperationByPredicatePage extends WizardPage { + + private ComboViewer cbOperation; + + private Text txtPredicate; + + private Text txtMaxRandomOperations; + + private Label lbMaxRandomOperations; + + private Composite container; + + private Label renderedOpLabel; + + private Button checkboxRandomMode; + + private ScrolledComposite c1; + + public ComboViewer getCbOperation() { + return cbOperation; + } + + public Text getTxtMaxRandomOperations() { + return txtMaxRandomOperations; + } + + protected SchedulerExecuteOperationByPredicatePage(String pageName) { + super(pageName); + } + + public void createControl(final Composite parent) { + + final DataBindingContext dbc = new DataBindingContext(); + + container = new Composite(parent, SWT.NONE); + GridLayout gl = new GridLayout(2, false); + container.setLayout(gl); + + Label lb = new Label(container, SWT.NONE); + lb.setText("Select an operation: "); + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.heightHint = 50; + + cbOperation = new ComboViewer(container, SWT.NONE); + cbOperation.getCombo().setLayoutData(new GridData(300, 50)); + + lb = new Label(container, SWT.NONE); + lb.setText("Predicate: "); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + txtPredicate = new Text(container, SWT.BORDER | SWT.WRAP + | SWT.V_SCROLL); + txtPredicate.setLayoutData(gd); + + lb = new Label(container, SWT.NONE); + lb.setText("Random mode: "); + lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + checkboxRandomMode = new Button(container, SWT.CHECK); + checkboxRandomMode.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + setRandomVisibility(checkboxRandomMode.getSelection()); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + lbMaxRandomOperations = new Label(container, SWT.NONE); + lbMaxRandomOperations.setText("Max Random Operations: "); + lbMaxRandomOperations.setLayoutData(new GridData( + GridData.VERTICAL_ALIGN_BEGINNING)); + txtMaxRandomOperations = new Text(container, SWT.BORDER); + txtMaxRandomOperations.setLayoutData(new GridData( + GridData.FILL_HORIZONTAL)); + txtMaxRandomOperations.addVerifyListener(new VerifyListener() { + @Override + public void verifyText(VerifyEvent e) { + String string = e.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + for (int i = 0; i < chars.length; i++) { + if (!('0' <= chars[i] && chars[i] <= '9')) { + e.doit = false; + return; + } + } + } + }); + setRandomVisibility(((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation().isRandom()); + + initBindings(dbc); + + IStructuredSelection structuredSelection = (IStructuredSelection) cbOperation + .getSelection(); + + if (!structuredSelection.isEmpty()) { + createRenderedOperationContainer((MachineOperation) structuredSelection + .getFirstElement()); + } + + setControl(container); + + } + + private void setRandomVisibility(boolean b) { + if (lbMaxRandomOperations == null || txtMaxRandomOperations == null) + return; + lbMaxRandomOperations.setVisible(b); + txtMaxRandomOperations.setVisible(b); + } + + private void initBindings(DataBindingContext dbc) { + + // MachineContentList operationList = BMotionEditorPlugin + // .getActiveEditor().getVisualization().getOperationList(); + // operationList.getMap().remove("INITIALISATION"); + + ObservableListContentProvider cbOpContentProvider = new ObservableListContentProvider(); + cbOperation.setContentProvider(cbOpContentProvider); + IObservableMap[] attributeMaps = BeansObservables.observeMaps( + cbOpContentProvider.getKnownElements(), + MachineContentObject.class, new String[] { "label" }); + cbOperation.setLabelProvider(new ObservableMapLabelProvider( + attributeMaps)); + cbOperation.setInput(new WritableList(EventBHelper + .getOperations(getBControl().getVisualization()), + MachineOperation.class)); + cbOperation.getCombo().setFont( + new Font(Display.getDefault(), new FontData("Arial", 10, + SWT.NONE))); + + final IObservableValue observeSelection = ViewersObservables + .observeSingleSelection(cbOperation); + + dbc.bindValue(SWTObservables.observeSelection(cbOperation + .getCombo()), BeansObservables.observeValue( + ((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation(), "operationName"), null, + null); + + dbc.bindValue(SWTObservables.observeText(txtPredicate, SWT.Modify), + BeansObservables.observeValue( + ((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation(), "predicate")); + + observeSelection.addValueChangeListener(new IValueChangeListener() { + public void handleValueChange(ValueChangeEvent event) { + Object sel = event.getObservableValue().getValue(); + createRenderedOperationContainer((MachineOperation) sel); + } + }); + + dbc.bindValue(SWTObservables.observeSelection(checkboxRandomMode), + BeansObservables.observeValue( + ((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation(), "random")); + + dbc.bindValue(SWTObservables.observeText(txtMaxRandomOperations, + SWT.Modify), BeansObservables.observeValue( + ((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation(), "maxrandom")); + + } + + private void createRenderedOperationContainer(MachineOperation op) { + + if (c1 != null) + c1.dispose(); + + GridLayout gl = new GridLayout(1, true); + gl.marginLeft = 5; + gl.marginTop = 5; + + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = 2; + + c1 = new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL + | SWT.V_SCROLL); + c1.setBackground(ColorConstants.red); + c1.setLayoutData(gd); + + Composite cp = new Composite(c1, SWT.NONE); + cp.setLayout(gl); + + renderedOpLabel = new Label(cp, SWT.NONE); + renderedOpLabel.setLayoutData(gd); + renderedOpLabel.setText(op.getRenderedOperation()); + renderedOpLabel.setFont(JFaceResources.getFontRegistry().get( + BMotionStudioSWTConstants.RODIN_FONT_KEY)); + + c1.setContent(cp); + c1.setExpandHorizontal(true); + c1.setExpandVertical(true); + c1.setMinSize(cp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + + container.layout(); + + } + + } + + public WizardExecuteOperationByPredicate(BControl bcontrol, + SchedulerEvent scheduler) { + super(bcontrol, scheduler); + addPage(new SchedulerExecuteOperationByPredicatePage( + "SchedulerExecuteOperationByPredicatePage")); + } + + @Override + protected Boolean prepareToFinish() { + + SchedulerExecuteOperationByPredicatePage page = (SchedulerExecuteOperationByPredicatePage) getPage("SchedulerExecuteOperationByPredicatePage"); + + String errorStr = ""; + + if (((ExecuteOperationByPredicate) getScheduler()) + .getPredicateOperation().isRandom() + && !(Integer + .valueOf(page.getTxtMaxRandomOperations().getText()) > 0)) + errorStr += "Max Random Operations must be greater than 0.\n"; + + if (page.getCbOperation().getCombo().getSelectionIndex() == -1) + errorStr += "Please select an operation.\n"; + + if (errorStr.length() > 0) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "An Error occured", errorStr); + return false; + } + + // PredicateOperation predicateOperation = + // ((ExecuteOperationByPredicate) getScheduler()) + // .getPredicateOperation(); + // + // Observer observer = getBControl().getObserver( + // ListenOperationByPredicate.ID); + // ListenOperationByPredicate listenObserver; + // + // if (observer != null) { + // listenObserver = (ListenOperationByPredicate) observer; + // listenObserver + // .removePredicateOperationByUniqueID(predicateOperation + // .getUniqueID()); + // } else { + // listenObserver = new ListenOperationByPredicate(); + // getBControl().addObserver(listenObserver); + // } + // + // try { + // listenObserver.addPredicateOperation(predicateOperation.clone()); + // } catch (CloneNotSupportedException e) { + // e.printStackTrace(); + // } + + return true; + + } + + @Override + public Point getSize() { + return new Point(600, 600); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicateMulti.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicateMulti.java index ef33b42a06fed9594556b7b95ad8a97525dd9c09..332fd422f251b074f97c431f8209443298c6f96f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicateMulti.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteOperationByPredicateMulti.java @@ -1,276 +1,265 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.scheduler.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.BindingObject; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.property.IntegerCellEditor; -import de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti; -import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; -import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -/** - * @author Lukas Ladenberger - * - */ -public class WizardExecuteOperationByPredicateMulti extends SchedulerWizard { - - private class MultiPage extends WizardPage { - - private TableViewer tableViewer; - - protected MultiPage(String pageName) { - super(pageName); - } - - public void createControl(final Composite parent) { - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - setControl(container); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, PredicateOperation.class, - ((BMotionAbstractWizard) getWizard()).getName()); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Execute Rule"); - column.getColumn().setWidth(190); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "executePredicate", getBControl().getVisualization(), - getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Operation"); - column.getColumn().setWidth(150); - column.setEditingSupport(new OperationValueEditingSupport( - tableViewer, getBControl())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Parameter"); - column.getColumn().setWidth(190); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "predicate", getBControl().getVisualization(), - getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Random Ops"); - column.getColumn().setWidth(100); - column.setEditingSupport(new RandomModeEditingSupport(tableViewer)); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - - tableViewer.setLabelProvider(new ObservableMapLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), new String[] { - "executePredicate", "operationName", - "predicate", "maxrandom" }))); - final WritableList input = new WritableList( - ((ExecuteOperationByPredicateMulti) getScheduler()) - .getOperationList(), - PredicateOperation.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - PredicateOperation obj = (PredicateOperation) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(obj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_ADD)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - PredicateOperation obj = new PredicateOperation(); - input.add(obj); - } - }); - - } - } - - public WizardExecuteOperationByPredicateMulti(BControl bcontrol, - SchedulerEvent scheduler) { - super(bcontrol, scheduler); - addPage(new MultiPage("MultiPage")); - } - - /* - * (non-Javadoc) - * - * @see - * de.bmotionstudio.gef.editor.scheduler.SchedulerWizard#prepareToFinish() - */ - @Override - protected Boolean prepareToFinish() { - if (((ExecuteOperationByPredicateMulti) getScheduler()) - .getOperationList().size() == 0) { - setEventDelete(true); - } else { - for (BindingObject obj : ((ExecuteOperationByPredicateMulti) getScheduler()) - .getOperationList()) { - if (((PredicateOperation) obj).getOperationName() == null - || ((PredicateOperation) obj).getOperationName() - .isEmpty()) { - MessageDialog - .openError(getShell(), "Please check your entries", - "Please check your entries. The operation field must not be empty."); - return false; - } - } - } - return true; - } - - /* - * (non-Javadoc) - * - * @see de.bmotionstudio.gef.editor.scheduler.SchedulerWizard#getSize() - */ - @Override - public Point getSize() { - return new Point(700, 500); - } - - private static class RandomModeEditingSupport extends EditingSupport { - - private CellEditor cellEditor; - - public RandomModeEditingSupport(ColumnViewer viewer) { - super(viewer); - } - - @Override - protected void setValue(Object element, Object value) { - if (value != null) { - Integer maxnr = Integer.valueOf(value.toString()); - PredicateOperation obj = (PredicateOperation) element; - obj.setMaxrandom(maxnr); - if (maxnr > 1) - obj.setRandom(true); - else - obj.setRandom(false); - } - } - - @Override - protected Object getValue(Object element) { - return ((PredicateOperation) element).getMaxrandom(); - } - - @Override - protected CellEditor getCellEditor(Object element) { - if (cellEditor == null) { - cellEditor = new IntegerCellEditor((Composite) getViewer() - .getControl()); - } - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - } - - // private class ObserverLabelProvider extends ObservableMapLabelProvider - // implements ITableLabelProvider, ITableColorProvider, - // ITableFontProvider { - // - // public ObserverLabelProvider(final IObservableMap[] attributeMaps) { - // super(attributeMaps); - // } - // - // @Override - // public Image getColumnImage(final Object element, final int columnIndex) - // { - // if (columnIndex == 3) { - // return CheckboxCellEditorHelper - // .getCellEditorImage(((PredicateOperation) element) - // .isRandom()); - // } - // return null; - // } - // - // @Override - // public String getColumnText(final Object element, final int columnIndex) - // { - // - // if (columnIndex == 3) - // return ""; - // - // return super.getColumnText(element, columnIndex); - // - // } - // - // public Color getBackground(final Object element, final int column) { - // return null; - // } - // - // public Color getForeground(final Object element, final int column) { - // return null; - // } - // - // public Font getFont(final Object element, final int column) { - // return null; - // } - // - // } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.scheduler.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.BindingObject; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.OperationValueEditingSupport; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.property.IntegerCellEditor; +import de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti; +import de.bmotionstudio.gef.editor.scheduler.PredicateOperation; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; +import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +/** + * @author Lukas Ladenberger + * + */ +public class WizardExecuteOperationByPredicateMulti extends SchedulerWizard { + + private class MultiPage extends WizardPage { + + private TableViewer tableViewer; + + protected MultiPage(String pageName) { + super(pageName); + } + + public void createControl(final Composite parent) { + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + setControl(container); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, PredicateOperation.class, + ((BMotionAbstractWizard) getWizard()).getName()); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Execute Rule"); + column.getColumn().setWidth(190); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "executePredicate", getBControl().getVisualization(), + getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Operation"); + column.getColumn().setWidth(150); + column.setEditingSupport(new OperationValueEditingSupport( + tableViewer, getBControl())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Parameter"); + column.getColumn().setWidth(190); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "predicate", getBControl().getVisualization(), + getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Random Ops"); + column.getColumn().setWidth(100); + column.setEditingSupport(new RandomModeEditingSupport(tableViewer)); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + + tableViewer.setLabelProvider(new ObservableMapLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), new String[] { + "executePredicate", "operationName", + "predicate", "maxrandom" }))); + final WritableList input = new WritableList( + ((ExecuteOperationByPredicateMulti) getScheduler()) + .getOperationList(), + PredicateOperation.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + PredicateOperation obj = (PredicateOperation) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(obj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_ADD)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + PredicateOperation obj = new PredicateOperation(); + input.add(obj); + } + }); + + } + } + + public WizardExecuteOperationByPredicateMulti(BControl bcontrol, + SchedulerEvent scheduler) { + super(bcontrol, scheduler); + addPage(new MultiPage("MultiPage")); + } + + @Override + protected Boolean prepareToFinish() { + if (((ExecuteOperationByPredicateMulti) getScheduler()) + .getOperationList().size() == 0) { + setEventDelete(true); + } else { + for (BindingObject obj : ((ExecuteOperationByPredicateMulti) getScheduler()) + .getOperationList()) { + if (((PredicateOperation) obj).getOperationName() == null + || ((PredicateOperation) obj).getOperationName() + .isEmpty()) { + MessageDialog + .openError(getShell(), "Please check your entries", + "Please check your entries. The operation field must not be empty."); + return false; + } + } + } + return true; + } + + @Override + public Point getSize() { + return new Point(700, 500); + } + + private static class RandomModeEditingSupport extends EditingSupport { + + private CellEditor cellEditor; + + public RandomModeEditingSupport(ColumnViewer viewer) { + super(viewer); + } + + @Override + protected void setValue(Object element, Object value) { + if (value != null) { + Integer maxnr = Integer.valueOf(value.toString()); + PredicateOperation obj = (PredicateOperation) element; + obj.setMaxrandom(maxnr); + if (maxnr > 1) + obj.setRandom(true); + else + obj.setRandom(false); + } + } + + @Override + protected Object getValue(Object element) { + return ((PredicateOperation) element).getMaxrandom(); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if (cellEditor == null) { + cellEditor = new IntegerCellEditor((Composite) getViewer() + .getControl()); + } + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return true; + } + + } + + // private class ObserverLabelProvider extends ObservableMapLabelProvider + // implements ITableLabelProvider, ITableColorProvider, + // ITableFontProvider { + // + // public ObserverLabelProvider(final IObservableMap[] attributeMaps) { + // super(attributeMaps); + // } + // + // @Override + // public Image getColumnImage(final Object element, final int columnIndex) + // { + // if (columnIndex == 3) { + // return CheckboxCellEditorHelper + // .getCellEditorImage(((PredicateOperation) element) + // .isRandom()); + // } + // return null; + // } + // + // @Override + // public String getColumnText(final Object element, final int columnIndex) + // { + // + // if (columnIndex == 3) + // return ""; + // + // return super.getColumnText(element, columnIndex); + // + // } + // + // public Color getBackground(final Object element, final int column) { + // return null; + // } + // + // public Color getForeground(final Object element, final int column) { + // return null; + // } + // + // public Font getFont(final Object element, final int column) { + // return null; + // } + // + // } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteScheduler.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteScheduler.java index 81680ee37abd5991ef459a9c46da00c079364d65..538631f480461367b36e103e653bffc70fa469e3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteScheduler.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/scheduler/wizard/WizardExecuteScheduler.java @@ -1,234 +1,234 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.gef.editor.scheduler.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeansObservables; -import org.eclipse.core.databinding.observable.list.WritableList; -import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; -import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; - -import de.bmotionstudio.gef.editor.BMotionAbstractWizard; -import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.EditorImageRegistry; -import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; -import de.bmotionstudio.gef.editor.model.BControl; -import de.bmotionstudio.gef.editor.scheduler.AnimationScriptObject; -import de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript; -import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; -import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; -import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; - -public class WizardExecuteScheduler extends SchedulerWizard { - - private class SchedulerPage extends WizardPage { - - private TableViewer tableViewer; - - protected SchedulerPage(String pageName) { - super(pageName); - } - - public void createControl(final Composite parent) { - - DataBindingContext dbc = new DataBindingContext(); - - Composite container = new Composite(parent, SWT.NONE); - container.setLayout(new GridLayout(1, true)); - - setControl(container); - - tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( - container, AnimationScriptObject.class, - ((BMotionAbstractWizard) getWizard()).getName()); - - TableViewerColumn column = new TableViewerColumn(tableViewer, - SWT.NONE); - column.getColumn().setText("Predicate"); - column.getColumn().setWidth(225); - column.setEditingSupport(new PredicateEditingSupport(tableViewer, - dbc, "predicate", getBControl().getVisualization(), - getShell())); - - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Edit"); - column.getColumn().setWidth(225); - column.setEditingSupport(new AnimationScriptEditingSupport( - tableViewer)); - - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - tableViewer.setContentProvider(contentProvider); - - tableViewer.setLabelProvider(new ObservableMapLabelProvider( - BeansObservables.observeMaps( - contentProvider.getKnownElements(), - new String[] { "predicate" })) { - - @Override - public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 1) { - return "Edit Scheduler"; - } - return super.getColumnText(element, columnIndex); - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - }); - - final WritableList input = new WritableList( - ((ExecuteAnimationScript) getScheduler()).getList(), - AnimationScriptObject.class); - tableViewer.setInput(input); - - Composite comp = new Composite(container, SWT.NONE); - comp.setLayout(new RowLayout()); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Button btRemove = new Button(comp, SWT.PUSH); - btRemove.setText("Remove"); - btRemove.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_DELETE)); - btRemove.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (tableViewer.getSelection().isEmpty()) { - return; - } - AnimationScriptObject obj = (AnimationScriptObject) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - input.remove(obj); - } - }); - - Button btAdd = new Button(comp, SWT.PUSH); - btAdd.setText("Add"); - btAdd.setImage(BMotionStudioImage - .getImage(EditorImageRegistry.IMG_ICON_ADD)); - btAdd.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - AnimationScriptObject obj = new AnimationScriptObject(""); - input.add(obj); - } - }); - - } - } - - public WizardExecuteScheduler(BControl bcontrol, - SchedulerEvent scheduler) { - super(bcontrol, scheduler); - addPage(new SchedulerPage("SchedulerPage")); - } - - @Override - protected Boolean prepareToFinish() { - return true; - } - - @Override - public boolean performCancel() { - return true; - } - - @Override - public Point getSize() { - return new Point(600, 500); - } - - private class AnimationScriptEditingSupport extends EditingSupport { - - public AnimationScriptEditingSupport(ColumnViewer viewer) { - super(viewer); - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - @Override - protected CellEditor getCellEditor(Object element) { - return new AnimationScriptDialogCellEditor((Composite) getViewer() - .getControl(), (AnimationScriptObject) element); - } - - @Override - protected Object getValue(Object element) { - return "Edit Scheduler"; - } - - @Override - protected void setValue(Object element, Object value) { - } - - } - - private class AnimationScriptDialogCellEditor extends DialogCellEditor { - - private AnimationScriptObject animObj; - private AnimationScriptObject clonedObj; - - public AnimationScriptDialogCellEditor(Composite parent, - AnimationScriptObject animObj) { - super(parent); - this.animObj = animObj; - } - - @Override - protected Object openDialogBox(Control cellEditorWindow) { - - SchedulerObjectDialog dialog = new SchedulerObjectDialog(PlatformUI - .getWorkbench().getActiveWorkbenchWindow().getShell(), - getBControl(), animObj); - - try { - clonedObj = animObj.clone(); - } catch (CloneNotSupportedException e) { - // TODO return some error?! - return getValue(); - } - - int status = dialog.open(); - if (status == Dialog.OK) { - return animObj; - } - - animObj.setSteps(clonedObj.getSteps()); - - return getValue(); - - } - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.gef.editor.scheduler.wizard; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.DialogCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.PlatformUI; + +import de.bmotionstudio.gef.editor.BMotionAbstractWizard; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; +import de.bmotionstudio.gef.editor.edit.PredicateEditingSupport; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.scheduler.AnimationScriptObject; +import de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript; +import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; +import de.bmotionstudio.gef.editor.scheduler.SchedulerWizard; +import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; + +public class WizardExecuteScheduler extends SchedulerWizard { + + private class SchedulerPage extends WizardPage { + + private TableViewer tableViewer; + + protected SchedulerPage(String pageName) { + super(pageName); + } + + public void createControl(final Composite parent) { + + DataBindingContext dbc = new DataBindingContext(); + + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, true)); + + setControl(container); + + tableViewer = BMotionWizardUtil.createBMotionWizardTableViewer( + container, AnimationScriptObject.class, + ((BMotionAbstractWizard) getWizard()).getName()); + + TableViewerColumn column = new TableViewerColumn(tableViewer, + SWT.NONE); + column.getColumn().setText("Predicate"); + column.getColumn().setWidth(225); + column.setEditingSupport(new PredicateEditingSupport(tableViewer, + dbc, "predicate", getBControl().getVisualization(), + getShell())); + + column = new TableViewerColumn(tableViewer, SWT.NONE); + column.getColumn().setText("Edit"); + column.getColumn().setWidth(225); + column.setEditingSupport(new AnimationScriptEditingSupport( + tableViewer)); + + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + tableViewer.setContentProvider(contentProvider); + + tableViewer.setLabelProvider(new ObservableMapLabelProvider( + BeansObservables.observeMaps( + contentProvider.getKnownElements(), + new String[] { "predicate" })) { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (columnIndex == 1) { + return "Edit Scheduler"; + } + return super.getColumnText(element, columnIndex); + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + }); + + final WritableList input = new WritableList( + ((ExecuteAnimationScript) getScheduler()).getList(), + AnimationScriptObject.class); + tableViewer.setInput(input); + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new RowLayout()); + comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Button btRemove = new Button(comp, SWT.PUSH); + btRemove.setText("Remove"); + btRemove.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_DELETE)); + btRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (tableViewer.getSelection().isEmpty()) { + return; + } + AnimationScriptObject obj = (AnimationScriptObject) ((IStructuredSelection) tableViewer + .getSelection()).getFirstElement(); + input.remove(obj); + } + }); + + Button btAdd = new Button(comp, SWT.PUSH); + btAdd.setText("Add"); + btAdd.setImage(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_ADD)); + btAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AnimationScriptObject obj = new AnimationScriptObject(""); + input.add(obj); + } + }); + + } + } + + public WizardExecuteScheduler(BControl bcontrol, + SchedulerEvent scheduler) { + super(bcontrol, scheduler); + addPage(new SchedulerPage("SchedulerPage")); + } + + @Override + protected Boolean prepareToFinish() { + return true; + } + + @Override + public boolean performCancel() { + return true; + } + + @Override + public Point getSize() { + return new Point(600, 500); + } + + private class AnimationScriptEditingSupport extends EditingSupport { + + public AnimationScriptEditingSupport(ColumnViewer viewer) { + super(viewer); + } + + @Override + protected boolean canEdit(Object element) { + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return new AnimationScriptDialogCellEditor((Composite) getViewer() + .getControl(), (AnimationScriptObject) element); + } + + @Override + protected Object getValue(Object element) { + return "Edit Scheduler"; + } + + @Override + protected void setValue(Object element, Object value) { + } + + } + + private class AnimationScriptDialogCellEditor extends DialogCellEditor { + + private AnimationScriptObject animObj; + private AnimationScriptObject clonedObj; + + public AnimationScriptDialogCellEditor(Composite parent, + AnimationScriptObject animObj) { + super(parent); + this.animObj = animObj; + } + + @Override + protected Object openDialogBox(Control cellEditorWindow) { + + SchedulerObjectDialog dialog = new SchedulerObjectDialog(PlatformUI + .getWorkbench().getActiveWorkbenchWindow().getShell(), + getBControl(), animObj); + + try { + clonedObj = animObj.clone(); + } catch (CloneNotSupportedException e) { + // TODO return some error?! + return getValue(); + } + + int status = dialog.open(); + if (status == Dialog.OK) { + return animObj; + } + + animObj.setSteps(clonedObj.getSteps()); + + return getValue(); + + } + + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java index ed487db0020ca2b9fa7657c1866e35b2a0159489..4fa2ef9c3f57b55c2eb22f9c6ace6420aba70f70 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import de.be4.classicalb.core.parser.exceptions.BException; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.model.BControl; @@ -213,7 +213,7 @@ public class BMSUtil { opRandom); } catch (ProBException e) { - } catch (BException e) { + } catch (BCompoundException e) { } return null; diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMotionWizardUtil.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMotionWizardUtil.java index 6a82f2279dc2e3268589da2bd38cbd9fea9f85ea..d2c74e1d63ab6382e87499403bfcbbe6aa8de9d2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMotionWizardUtil.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMotionWizardUtil.java @@ -1,97 +1,97 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ -package de.bmotionstudio.gef.editor.util; - -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; -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 org.eclipse.swt.widgets.TableItem; - -import de.bmotionstudio.gef.editor.action.BMotionWizardAddItemAction; -import de.bmotionstudio.gef.editor.action.BMotionWizardDeleteItemsAction; -import de.bmotionstudio.gef.editor.library.AttributeTransfer; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverDragListener; -import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverDropListener; - -public class BMotionWizardUtil { - - public static boolean isEditElement(ColumnViewer viewer) { - Object data = viewer.getData("editElement"); - if (data != null) - return Boolean.valueOf(data.toString()); - return false; - } - - public static TableViewer createBMotionWizardTableViewer(Composite parent, - Class<?> itemClass, final String wizardName) { - - final TableViewer tableViewer = new TableViewer(parent, SWT.BORDER - | SWT.FULL_SELECTION | SWT.MULTI); - tableViewer.setData("editElement", false); - tableViewer.getTable().setLinesVisible(true); - tableViewer.getTable().setHeaderVisible(true); - tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); - // tableViewer.getTable().setFont(BMotionStudioSWTConstants.fontArial10); - int operations = DND.DROP_COPY | DND.DROP_MOVE; - Transfer[] transferTypes = new Transfer[] { AttributeTransfer - .getInstance() }; - - tableViewer.addDropSupport(operations, transferTypes, - new WizardObserverDropListener(tableViewer, wizardName)); - tableViewer.addDragSupport(operations, transferTypes, - new WizardObserverDragListener(tableViewer)); - - MenuManager manager = new MenuManager(); - tableViewer.getControl().setMenu( - manager.createContextMenu(tableViewer.getControl())); - manager.add(new BMotionWizardDeleteItemsAction(tableViewer)); - manager.add(new BMotionWizardAddItemAction(tableViewer, itemClass)); - - tableViewer.getTable().addListener(SWT.MouseDown, new Listener() { - public void handleEvent(Event event) { - tableViewer.setData("editElement", false); - } - }); - - tableViewer.getTable().addListener(SWT.MouseDoubleClick, - new Listener() { - - public void handleEvent(Event event) { - - tableViewer.setData("editElement", true); - TableItem[] selection = tableViewer.getTable() - .getSelection(); - - if (selection.length != 1) { - return; - } - - TableItem item = tableViewer.getTable().getSelection()[0]; - - for (int i = 0; i < tableViewer.getTable() - .getColumnCount(); i++) { - if (item.getBounds(i).contains(event.x, event.y)) { - tableViewer.editElement(item.getData(), i); - tableViewer.setData("editElement", false); - break; - } - } - } - - }); - - return tableViewer; - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ +package de.bmotionstudio.gef.editor.util; + +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.Transfer; +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 org.eclipse.swt.widgets.TableItem; + +import de.bmotionstudio.gef.editor.action.BMotionWizardAddItemAction; +import de.bmotionstudio.gef.editor.action.BMotionWizardDeleteItemsAction; +import de.bmotionstudio.gef.editor.library.AttributeTransfer; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverDragListener; +import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverDropListener; + +public class BMotionWizardUtil { + + public static boolean isEditElement(ColumnViewer viewer) { + Object data = viewer.getData("editElement"); + if (data != null) + return Boolean.valueOf(data.toString()); + return false; + } + + public static TableViewer createBMotionWizardTableViewer(Composite parent, + Class<?> itemClass, final String wizardName) { + + final TableViewer tableViewer = new TableViewer(parent, SWT.BORDER + | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setData("editElement", false); + tableViewer.getTable().setLinesVisible(true); + tableViewer.getTable().setHeaderVisible(true); + tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); + // tableViewer.getTable().setFont(BMotionStudioSWTConstants.fontArial10); + int operations = DND.DROP_COPY | DND.DROP_MOVE; + Transfer[] transferTypes = new Transfer[] { AttributeTransfer + .getInstance() }; + + tableViewer.addDropSupport(operations, transferTypes, + new WizardObserverDropListener(tableViewer, wizardName)); + tableViewer.addDragSupport(operations, transferTypes, + new WizardObserverDragListener(tableViewer)); + + MenuManager manager = new MenuManager(); + tableViewer.getControl().setMenu( + manager.createContextMenu(tableViewer.getControl())); + manager.add(new BMotionWizardDeleteItemsAction(tableViewer)); + manager.add(new BMotionWizardAddItemAction(tableViewer, itemClass)); + + tableViewer.getTable().addListener(SWT.MouseDown, new Listener() { + public void handleEvent(Event event) { + tableViewer.setData("editElement", false); + } + }); + + tableViewer.getTable().addListener(SWT.MouseDoubleClick, + new Listener() { + + public void handleEvent(Event event) { + + tableViewer.setData("editElement", true); + TableItem[] selection = tableViewer.getTable() + .getSelection(); + + if (selection.length != 1) { + return; + } + + TableItem item = tableViewer.getTable().getSelection()[0]; + + for (int i = 0; i < tableViewer.getTable() + .getColumnCount(); i++) { + if (item.getBounds(i).contains(event.x, event.y)) { + tableViewer.editElement(item.getData(), i); + tableViewer.setData("editElement", false); + break; + } + } + } + + }); + + return tableViewer; + + } + +} diff --git a/de.bmotionstudio.help/.classpath b/de.bmotionstudio.help/.classpath deleted file mode 100644 index d340cf91de61e0d4f233094a17166bcf96660af6..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/.classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.mylyn.wikitext.core_1.7.0.I20120513-1032.jar"/> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.mylyn.wikitext.mediawiki.core_1.7.0.I20120513-1032.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/de.bmotionstudio.help/.gitignore b/de.bmotionstudio.help/.gitignore deleted file mode 100644 index 035de1b11b9c848db744ce94f72e26bdcbcfacb6..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -User-Guide-Glossary-toc.xml -User-Guide-Reference-toc.xml -User-Guide-Tutorial-toc.xml -tmp/ -User_Guide/ \ No newline at end of file diff --git a/de.bmotionstudio.help/.project b/de.bmotionstudio.help/.project deleted file mode 100644 index 9162b9f5bf81284341c67694c5e5e63d6b534265..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>de.bmotionstudio.help</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.bmotionstudio.help/.settings/org.eclipse.jdt.core.prefs b/de.bmotionstudio.help/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f84eafc964bdfb1f40a434083bdd428ec56ec668..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Fri Aug 31 09:17:40 CEST 2012 -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.compliance=1.6 -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/de.bmotionstudio.help/META-INF/MANIFEST.MF b/de.bmotionstudio.help/META-INF/MANIFEST.MF deleted file mode 100644 index b7f577358c479b3acfa9d2d39aacae4ab8847288..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: BMotion Studio Help -Bundle-SymbolicName: de.bmotionstudio.help;singleton:=true -Bundle-Version: 1.0.1.qualifier -Require-Bundle: org.eclipse.help;bundle-version="3.5.100" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-Vendor: HHU Düsseldorf STUPS Group -Eclipse-RegisterBuddy: de.bmotionstudio.gef.editor -Bundle-ClassPath: lib/org.eclipse.mylyn.wikitext.core_1.7.0.I20120513-1032.jar, - lib/org.eclipse.mylyn.wikitext.mediawiki.core_1.7.0.I20120513-1032.jar, - . diff --git a/de.bmotionstudio.help/about.html b/de.bmotionstudio.help/about.html deleted file mode 100644 index b8193ece10e08aa3ee2d279b713d12e7705a8c0e..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <title>About</title> - </head> - <body> - -<h2>About This Content</h2> - -<p>June 25, 2008</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p> - -</body> -</html> \ No newline at end of file diff --git a/de.bmotionstudio.help/build.properties b/de.bmotionstudio.help/build.properties deleted file mode 100644 index 210faf9f1459a73fe8487a779fe2d74e65cc57d4..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/build.properties +++ /dev/null @@ -1,11 +0,0 @@ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - toc.xml,\ - User-Guide-Tutorial-toc.xml,\ - User-Guide-Reference-toc.xml,\ - images/,\ - User_Guide/,\ - about.html,\ - doc/,\ - contextDefinitionFile.xml diff --git a/de.bmotionstudio.help/contextDefinitionFile.xml b/de.bmotionstudio.help/contextDefinitionFile.xml deleted file mode 100644 index 6fa0faade9b6af80bf0f3f232539b266ae76e886..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/contextDefinitionFile.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<contexts> - <context id="SwitchChildCoordinates"> - <topic href="User_Guide/Reference/Observer.html#Switch_Child_Coordinates" label="Switch Child Coordinates Observer" /> - </context> - <context id="SwitchCoordinates"> - <topic href="User_Guide/Reference/Observer.html#Switch_Coordinates" label="Switch Coordinates Observer"/> - </context> - <context id="SetAttribute"> - <topic href="User_Guide/Reference/Observer.html#Set_Attribute" label="Set Attribute Observer"/> - </context> - <context id="SimpleValueDisplay"> - <topic href="User_Guide/Reference/Observer.html#Simple_Value_Display" label="Simple Value Display Observer"/> - </context> - <context id="SwitchImage"> - <topic href="User_Guide/Reference/Observer.html#Switch_Image" label="Switch Image Observer"/> - </context> - <context id="ListenOperationByPredicate"> - <topic href="User_Guide/Reference/Observer.html#Listen_Operation" label="Listen Operation Observer"/> - </context> -</contexts> diff --git a/de.bmotionstudio.help/customBuild.xml b/de.bmotionstudio.help/customBuild.xml deleted file mode 100644 index 9885823bf43374c91fed743860767d28de87d6c7..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/customBuild.xml +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?><!-- - Copyright (c) 2011 Formal Mind GmbH and University of Dusseldorf. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Lukas Ladenberger - initial API and implementation - --> - -<project name="org.eclipse.mylyn.wikitext.example" default="all"> - <description> - Generate Eclipse help content for the BMotion Studio user guide - </description> - - <property name="help.doc.url.base" value="http://www.stups.uni-duesseldorf.de/bmotionstudio"/> - <property name="wiki.url.base" value="${help.doc.url.base}"/> - <property name="imageFolder" value="images"/> - - <path id="wikitext.tasks.classpath"> - <fileset dir="lib"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar"/> - </fileset> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/internal/wikitext/mediawiki/core/tasks/tasks.properties"/> - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties"/> - - <target name="init"> - <mkdir dir="tmp"/> - </target> - - <target name="clean" depends="init"> - <delete includeemptydirs="true" failonerror="false"> - <fileset dir="tmp"/> - </delete> - </target> - - <target name="all" depends="generate-help, test"/> - - <target name="generate-help" depends="init" description="Generate Eclipse help content for the BMotion Studio user guide"> - <mediawiki-to-eclipse-help - wikiBaseUrl="${help.doc.url.base}" - validate="true" - failonvalidationerror="true" - prependImagePrefix="${imageFolder}" - formatoutput="true" - defaultAbsoluteLinkTarget="bms_external" - dest="${basedir}" - title="BMotion Studio User Guide" - generateUnifiedToc="false"> - <path name="User_Guide/Tutorial" title="BMotion Studio Tutorial" generateToc="true"/> - <path name="User_Guide/Reference" title="BMotion Studio Reference" generateToc="true"/> - <pageAppendum> -= Updating This Document = - -This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit http://www.stups.uni-duesseldorf.de/bmotionstudio. - </pageAppendum> - </mediawiki-to-eclipse-help> - - </target> - - <target name="test" depends="init" description="verify that all of the HTML files are well-formed XML"> - <echo level="info"> -Validating help content XML and HTML files: The Eclipse help system expects well-formed XML - -If validation fails it is because either: - -* the userguide source code is poorly formed, or -* the WikiText MediaWiki parser has a bug - -Problems with userguide source are usually caused by improper use of HTML markup in the MediaWiki source, -or inadvertently starting a line with a space character (in MediaWiki this starts a preformatted block) - </echo> - - <!-- - Don't bother with DTD validation: we only care if the files are well-formed. - We therefore provide an empty DTD - --> - <mkdir dir="tmp"/> - <echo file="tmp/__empty.dtd" message=""/> - <xmlvalidate lenient="true"> - <fileset dir="."> - <include name="**/*.xml"/> - </fileset> - <fileset dir="."> - <include name="**/*.html"/> - </fileset> - <fileset dir="."> - <include name="*toc.xml"/> - </fileset> - <dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="${basedir}/tmp/__empty.dtd"/> - </xmlvalidate> - - </target> -</project> diff --git a/de.bmotionstudio.help/doc/notices.html b/de.bmotionstudio.help/doc/notices.html deleted file mode 100644 index cdbda6cc94e4cb5f3a5efabf6ce1f0cb5e1d426b..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/doc/notices.html +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <title>Legal Notices</title> - </head> - <body> -<h3> -<a NAME="Notices"></a>Notices</h3> -<p> -The material in this guide is Copyright (c) 2012 HHU STUPS Group and others. -</p> -<p> -<a href="../about.html">Terms and conditions regarding the use of this guide.</a> -</p> -</body> -</html> diff --git a/de.bmotionstudio.help/images/home.gif b/de.bmotionstudio.help/images/home.gif deleted file mode 100644 index 4472e8ce5b377934abe5910749b8c58591947424..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.help/images/home.gif and /dev/null differ diff --git a/de.bmotionstudio.help/images/next.gif b/de.bmotionstudio.help/images/next.gif deleted file mode 100644 index e2f8c3e1feeb0541239db4061812008af2225105..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.help/images/next.gif and /dev/null differ diff --git a/de.bmotionstudio.help/images/prev.gif b/de.bmotionstudio.help/images/prev.gif deleted file mode 100644 index 4fb41501036b940c99c8a839d7459c88eb98385c..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.help/images/prev.gif and /dev/null differ diff --git a/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.core_1.7.0.I20120513-1032.jar b/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.core_1.7.0.I20120513-1032.jar deleted file mode 100644 index d70798e0076e5b0df6e268b2ce97d4bccfad72fa..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.core_1.7.0.I20120513-1032.jar and /dev/null differ diff --git a/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.mediawiki.core_1.7.0.I20120513-1032.jar b/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.mediawiki.core_1.7.0.I20120513-1032.jar deleted file mode 100644 index 4a060b5670b93729693955f4debbceecba8ebc69..0000000000000000000000000000000000000000 Binary files a/de.bmotionstudio.help/lib/org.eclipse.mylyn.wikitext.mediawiki.core_1.7.0.I20120513-1032.jar and /dev/null differ diff --git a/de.bmotionstudio.help/plugin.xml b/de.bmotionstudio.help/plugin.xml deleted file mode 100644 index edb7436b8b6783656d3430b8a0710c5924357088..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.4"?> -<plugin> - <extension - point="org.eclipse.help.toc"> - <toc - category="BMS" - file="toc.xml" - primary="true"> - </toc> - <toc - category="BMS" - file="User-Guide-Tutorial-toc.xml" - primary="false"> - </toc> - <toc - category="BMS" - file="User-Guide-Reference-toc.xml" - primary="false"> - </toc> - </extension> - <extension - point="org.eclipse.help.contexts"> - <contexts - file="contextDefinitionFile.xml" - plugin="de.bmotionstudio.gef.editor.observer"> - </contexts> - </extension> - -</plugin> diff --git a/de.bmotionstudio.help/toc.xml b/de.bmotionstudio.help/toc.xml deleted file mode 100644 index 95c83a4d527e1dc8ca8d580b90d1b90e59b2b42c..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.help/toc.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?NLS TYPE="org.eclipse.help.toc"?> -<toc label="BMotion Studio User Guide"> - <anchor id="before-reference"/> - <topic label="Tutorial"> - <anchor id="before-tutorial-content"/> - <link toc="User-Guide-Tutorial-toc.xml"/> - <anchor id="after-tutorial-content"/> - <anchor id="additions-tutorial"/> - </topic> - <topic label="Reference"> - <anchor id="before-reference-content"/> - <link toc="User-Guide-Reference-toc.xml"/> - <anchor id="after-reference-content"/> - <anchor id="additions-reference" /> - </topic> - <anchor id="after-reference"/> - <anchor id="additions"/> - <topic href="doc/notices.html" label="Legal" /> -</toc> - diff --git a/de.bmotionstudio.rodin/.classpath b/de.bmotionstudio.rodin/.classpath index 8a8f1668cdcc5c73a6921162616f01cb556ae7c1..b862a296d38fe04269faeee6c9d77d11ff77380d 100644 --- a/de.bmotionstudio.rodin/.classpath +++ b/de.bmotionstudio.rodin/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.bmotionstudio.rodin/META-INF/MANIFEST.MF b/de.bmotionstudio.rodin/META-INF/MANIFEST.MF index 5173086bd1118fba776ae50ccc0fac132c8f4ea5..ed5ed5ea8328c886b3ba762382ae2c63860e3f10 100644 --- a/de.bmotionstudio.rodin/META-INF/MANIFEST.MF +++ b/de.bmotionstudio.rodin/META-INF/MANIFEST.MF @@ -2,8 +2,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: BMotion Studio Rodin Integration Bundle-SymbolicName: de.bmotionstudio.rodin;singleton:=true -Bundle-Version: 1.2.0.qualifier -Fragment-Host: de.bmotionstudio.gef.editor;bundle-version="[5.5.0,5.6.0)" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Version: 1.2.1.qualifier +Fragment-Host: de.bmotionstudio.gef.editor;bundle-version="[5.5.1,5.6.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: HHU Düsseldorf STUPS Group Require-Bundle: org.eclipse.ui.navigator;bundle-version="3.5.0" diff --git a/de.bmotionstudio.rodin/build.properties b/de.bmotionstudio.rodin/build.properties index ca10431f8565d50920a8cb18203594ffd27a7a99..187f664063183d827bac5059f2d214bee14c752d 100644 --- a/de.bmotionstudio.rodin/build.properties +++ b/de.bmotionstudio.rodin/build.properties @@ -1,6 +1,6 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - fragment.xml,\ - icons/ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + fragment.xml,\ + icons/ diff --git a/de.bmotionstudio.rodin/fragment.xml b/de.bmotionstudio.rodin/fragment.xml index 47bd37efdd477647cacaa5309040f58a3c8e2eb8..f9f29ddd233d9c904af5a31fbc782ecb5f47d933 100644 --- a/de.bmotionstudio.rodin/fragment.xml +++ b/de.bmotionstudio.rodin/fragment.xml @@ -1,108 +1,108 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.4"?> -<fragment> - <extension - point="org.eclipse.ui.perspectives"> - <perspective - class="de.bmotionstudio.rodin.PerspectiveEditFactory" - icon="icons/logo_bmotion.png" - id="de.bmotionstudio.perspective.edit" - name="BMS Edit"> - </perspective> - <perspective - class="de.bmotionstudio.rodin.PerspectiveRunFactory" - icon="icons/icon_run.png" - id="de.bmotionstudio.perspective.run" - name="BMS Run"> - </perspective> - </extension> - <extension - point="org.eclipse.ui.menus"> - <menuContribution - locationURI="popup:fr.systerel.explorer.navigator.view"> - <command - commandId="de.bmotionstudio.rodin.command.startVisualization" - icon="icons/icon_run.png" - label="Start Visualization" - style="push"> - <visibleWhen> - <with - variable="selection"> - <iterate - operator="or"> - <instanceof - value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> - </instanceof> - </iterate> - </with> - </visibleWhen> - </command> - </menuContribution> - </extension> - <extension - point="org.eclipse.ui.commands"> - <command - defaultHandler="de.bmotionstudio.rodin.StartEventBVisualizationHandler" - id="de.bmotionstudio.rodin.command.startVisualization" - name="Start Visualization"> - </command> - </extension> - <extension - point="org.rodinp.core.fileAssociations"> - <fileAssociation - content-type-id="de.bmotionstudio.gef.editor.BMotionStudioFile" - root-element-type="de.bmotionstudio.gef.editor.BMotionStudioFile"> - </fileAssociation> - </extension> - <extension - point="org.eclipse.ui.navigator.navigatorContent"> - <navigatorContent - contentProvider="de.bmotionstudio.rodin.BMotionStudioContentProvider" - id="de.bmotionstudio.ui.navigatorContent" - labelProvider="de.bmotionstudio.rodin.BMotionLabelProvider" - name="BMotion Studio Navigator Content" - priority="normal"> - <triggerPoints> - <instanceof - value="org.eclipse.core.resources.IProject"> - </instanceof> - </triggerPoints> - <possibleChildren> - <instanceof - value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> - </instanceof> - </possibleChildren> - <actionProvider - class="de.bmotionstudio.rodin.BMotionStudioActionProvider" - id="de.bmotionstudio.ui.navigatorAction" - priority="normal"> - <enablement> - <instanceof value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> - </instanceof> - </enablement> - </actionProvider> - </navigatorContent> - </extension> - <extension - point="org.eclipse.ui.navigator.viewer"> - <viewerContentBinding - viewerId="fr.systerel.explorer.navigator.view"> - <includes> - <contentExtension - pattern="de.bmotionstudio.ui.navigatorContent"> - </contentExtension> - </includes> - </viewerContentBinding> - <viewerActionBinding - viewerId="fr.systerel.explorer.navigator.view"> - <includes> - <actionExtension - pattern="de.bmotionstudio.ui.navigatorAction"> - </actionExtension> - </includes> - </viewerActionBinding> - </extension> - - - -</fragment> +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<fragment> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + class="de.bmotionstudio.rodin.PerspectiveEditFactory" + icon="icons/logo_bmotion.png" + id="de.bmotionstudio.perspective.edit" + name="BMS Edit"> + </perspective> + <perspective + class="de.bmotionstudio.rodin.PerspectiveRunFactory" + icon="icons/icon_run.png" + id="de.bmotionstudio.perspective.run" + name="BMS Run"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + locationURI="popup:fr.systerel.explorer.navigator.view"> + <command + commandId="de.bmotionstudio.rodin.command.startVisualization" + icon="icons/icon_run.png" + label="Start Visualization" + style="push"> + <visibleWhen> + <with + variable="selection"> + <iterate + operator="or"> + <instanceof + value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> + </instanceof> + </iterate> + </with> + </visibleWhen> + </command> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + defaultHandler="de.bmotionstudio.rodin.StartEventBVisualizationHandler" + id="de.bmotionstudio.rodin.command.startVisualization" + name="Start Visualization"> + </command> + </extension> + <extension + point="org.rodinp.core.fileAssociations"> + <fileAssociation + content-type-id="de.bmotionstudio.gef.editor.BMotionStudioFile" + root-element-type="de.bmotionstudio.gef.editor.BMotionStudioFile"> + </fileAssociation> + </extension> + <extension + point="org.eclipse.ui.navigator.navigatorContent"> + <navigatorContent + contentProvider="de.bmotionstudio.rodin.BMotionStudioContentProvider" + id="de.bmotionstudio.ui.navigatorContent" + labelProvider="de.bmotionstudio.rodin.BMotionLabelProvider" + name="BMotion Studio Navigator Content" + priority="normal"> + <triggerPoints> + <instanceof + value="org.eclipse.core.resources.IProject"> + </instanceof> + </triggerPoints> + <possibleChildren> + <instanceof + value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> + </instanceof> + </possibleChildren> + <actionProvider + class="de.bmotionstudio.rodin.BMotionStudioActionProvider" + id="de.bmotionstudio.ui.navigatorAction" + priority="normal"> + <enablement> + <instanceof value="de.bmotionstudio.rodin.BMotionStudioRodinFile"> + </instanceof> + </enablement> + </actionProvider> + </navigatorContent> + </extension> + <extension + point="org.eclipse.ui.navigator.viewer"> + <viewerContentBinding + viewerId="fr.systerel.explorer.navigator.view"> + <includes> + <contentExtension + pattern="de.bmotionstudio.ui.navigatorContent"> + </contentExtension> + </includes> + </viewerContentBinding> + <viewerActionBinding + viewerId="fr.systerel.explorer.navigator.view"> + <includes> + <actionExtension + pattern="de.bmotionstudio.ui.navigatorAction"> + </actionExtension> + </includes> + </viewerActionBinding> + </extension> + + + +</fragment> diff --git a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/BMotionStudioContentProvider.java b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/BMotionStudioContentProvider.java index 7a6434327dce482226944bf1c97ce5455b2c8792..ed93b697f873ae0669827c3e7029206951467e5a 100644 --- a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/BMotionStudioContentProvider.java +++ b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/BMotionStudioContentProvider.java @@ -4,8 +4,8 @@ * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ -package de.bmotionstudio.rodin; - +package de.bmotionstudio.rodin; + import java.util.ArrayList; import java.util.List; @@ -14,12 +14,12 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; - - -public class BMotionStudioContentProvider implements ITreeContentProvider { - - public Object[] getChildren(final Object parentElement) { - + + +public class BMotionStudioContentProvider implements ITreeContentProvider { + + public Object[] getChildren(final Object parentElement) { + List<Object> res = new ArrayList<Object>(); if (parentElement instanceof IProject) { @@ -45,31 +45,31 @@ public class BMotionStudioContentProvider implements ITreeContentProvider { } - return new Object[0]; - - } - - public Object getParent(final Object element) { - // do nothing - return null; - } - - public boolean hasChildren(final Object element) { - return false; - } - - public Object[] getElements(final Object inputElement) { - return getChildren(inputElement); - } - - public void dispose() { - // do nothing - - } - - public void inputChanged(final Viewer viewer, final Object oldInput, - final Object newInput) { - // do nothing - } - -} + return new Object[0]; + + } + + public Object getParent(final Object element) { + // do nothing + return null; + } + + public boolean hasChildren(final Object element) { + return false; + } + + public Object[] getElements(final Object inputElement) { + return getChildren(inputElement); + } + + public void dispose() { + // do nothing + + } + + public void inputChanged(final Viewer viewer, final Object oldInput, + final Object newInput) { + // do nothing + } + +} diff --git a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/PerspectiveRunFactory.java b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/PerspectiveRunFactory.java index 820464bf827ac2e11024700ff5c2cce19c7c8468..f8c425f52aae636d0d7d086bde4a3868d87aa411 100644 --- a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/PerspectiveRunFactory.java +++ b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/PerspectiveRunFactory.java @@ -1,43 +1,43 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.rodin; - -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -public class PerspectiveRunFactory implements IPerspectiveFactory { - - public void createInitialLayout(IPageLayout layout) { - - String editorArea = layout.getEditorArea(); - - // ProB Event View (Top-Left) - IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, - 0.15f, editorArea); - left.addView("de.prob.ui.OperationView"); - - // Navigator + Rodin Problem View (Bottom-Left) - IFolderLayout leftb = layout.createFolder("leftb", IPageLayout.BOTTOM, - 0.6f, "left"); - leftb.addView("fr.systerel.explorer.navigator.view"); - // leftb.addView("org.eventb.ui.views.RodinProblemView"); - - // ProB State View (Right) - IFolderLayout right1 = layout.createFolder("right1", IPageLayout.RIGHT, - 0.7f, editorArea); - right1.addView("de.prob.ui.StateView"); - - // ProB History + ProB Event Error View (Right) - IFolderLayout right2 = layout.createFolder("right2", IPageLayout.RIGHT, - 0.6f, "right1"); - right2.addView("de.prob.ui.HistoryView"); - right2.addView("de.prob.ui.EventErrorView"); - - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.rodin; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class PerspectiveRunFactory implements IPerspectiveFactory { + + public void createInitialLayout(IPageLayout layout) { + + String editorArea = layout.getEditorArea(); + + // ProB Event View (Top-Left) + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, + 0.15f, editorArea); + left.addView("de.prob.ui.OperationView"); + + // Navigator + Rodin Problem View (Bottom-Left) + IFolderLayout leftb = layout.createFolder("leftb", IPageLayout.BOTTOM, + 0.6f, "left"); + leftb.addView("fr.systerel.explorer.navigator.view"); + // leftb.addView("org.eventb.ui.views.RodinProblemView"); + + // ProB State View (Right) + IFolderLayout right1 = layout.createFolder("right1", IPageLayout.RIGHT, + 0.7f, editorArea); + right1.addView("de.prob.ui.StateView"); + + // ProB History + ProB Event Error View (Right) + IFolderLayout right2 = layout.createFolder("right2", IPageLayout.RIGHT, + 0.6f, "right1"); + right2.addView("de.prob.ui.HistoryView"); + right2.addView("de.prob.ui.EventErrorView"); + + } + +} diff --git a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/YesToAllMessageDialog.java b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/YesToAllMessageDialog.java index d46ad6e662d44af603f9b8c0b3c3679f45eccc0f..ed59926eed3da61f0afaa3d2fcec23d93557e0ca 100644 --- a/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/YesToAllMessageDialog.java +++ b/de.bmotionstudio.rodin/src/de/bmotionstudio/rodin/YesToAllMessageDialog.java @@ -1,39 +1,39 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.bmotionstudio.rodin; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; - -public class YesToAllMessageDialog extends MessageDialog { - - public static int YES = 0; - public static int NO = 1; - public static int CANCEL = -1; - public static int YES_TO_ALL = 2; - public static int NO_TO_ALL = 3; - - public YesToAllMessageDialog(Shell parentShell, String dialogTitle, - Image dialogTitleImage, String dialogMessage, int dialogImageType, - String[] dialogButtonLabels, int defaultIndex) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, - dialogImageType, dialogButtonLabels, defaultIndex); - } - - public static int openYesNoToAllQuestion(Shell parent, String title, - String message) { - MessageDialog dialog = new MessageDialog(parent, title, null, // accept - message, QUESTION, new String[] { IDialogConstants.YES_LABEL, - IDialogConstants.NO_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.NO_TO_ALL_LABEL }, 0); // yes is the - return dialog.open(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.bmotionstudio.rodin; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Shell; + +public class YesToAllMessageDialog extends MessageDialog { + + public static int YES = 0; + public static int NO = 1; + public static int CANCEL = -1; + public static int YES_TO_ALL = 2; + public static int NO_TO_ALL = 3; + + public YesToAllMessageDialog(Shell parentShell, String dialogTitle, + Image dialogTitleImage, String dialogMessage, int dialogImageType, + String[] dialogButtonLabels, int defaultIndex) { + super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, + dialogImageType, dialogButtonLabels, defaultIndex); + } + + public static int openYesNoToAllQuestion(Shell parent, String title, + String message) { + MessageDialog dialog = new MessageDialog(parent, title, null, // accept + message, QUESTION, new String[] { IDialogConstants.YES_LABEL, + IDialogConstants.NO_LABEL, + IDialogConstants.YES_TO_ALL_LABEL, + IDialogConstants.NO_TO_ALL_LABEL }, 0); // yes is the + return dialog.open(); + } + +} diff --git a/de.prob.core.tests/.classpath b/de.prob.core.tests/.classpath index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..eca7bdba8f03f22510b7980a94dbfe10c16c0901 100644 --- a/de.prob.core.tests/.classpath +++ b/de.prob.core.tests/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.prob.core.tests/.settings/org.eclipse.jdt.core.prefs b/de.prob.core.tests/.settings/org.eclipse.jdt.core.prefs index c537b63063ce6052bdc49c5fd0745b078f162c90..0c68a61dca867ceb49e79d2402935261ec3e3809 100644 --- a/de.prob.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/de.prob.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ 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.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.prob.core.tests/META-INF/MANIFEST.MF b/de.prob.core.tests/META-INF/MANIFEST.MF index fc445d16b3ea4a1b070d3bb59e600916d376f663..a67541da460d8e6939b447bebf70d67b12d0e911 100644 --- a/de.prob.core.tests/META-INF/MANIFEST.MF +++ b/de.prob.core.tests/META-INF/MANIFEST.MF @@ -5,8 +5,12 @@ Bundle-SymbolicName: de.prob.core.tests Bundle-Version: 1.0.0.qualifier Bundle-Activator: de.prob.core.tests.Activator Require-Bundle: org.eclipse.ui, + org.eclipse.core.resources, org.eclipse.core.runtime, - org.eventb.core;bundle-version="[2.1.0,2.6.0)", - de.prob.core;bundle-version="9.3.0" + org.eventb.core;bundle-version="[3.3.0,4.0.0)", + org.eventb.core.ast;bundle-version="[3.3.0,4.0.0)", + org.junit;bundle-version="[4.0.0,5.0.0)", + org.rodinp.core;bundle-version="[1.7.0,2.0.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAllUnitTests.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAllUnitTests.java index 09ed7bc345fb64743bd228f85b7986c5edb14fcf..b68708e48053b7c3e13267fe140a68cd8275a518 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAllUnitTests.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAllUnitTests.java @@ -1,21 +1,21 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - CounterExampleFinallyUnitTest.class, - CounterExampleGloballyUnitTest.class, - CounterExampleNextUnitTest.class, - // CounterExampleUntilUnitTest.class, - // CounterExampleWeakUntilUnitTest.class, - CounterExampleReleaseUnitTest.class, CounterExampleOnceUnitTest.class, - CounterExampleHistoryUnitTest.class, - CounterExampleYesterdayUnitTest.class, - // CounterExampleSinceUnitTest.class, - // CounterExampleTriggerUnitTest.class, - CounterExampleNotUnitTest.class, CounterExampleAndUnitTest.class, - CounterExampleOrUnitTest.class, CounterExampleImplyUnitTest.class }) -public final class CounterExampleAllUnitTests { -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + CounterExampleFinallyUnitTest.class, + CounterExampleGloballyUnitTest.class, + CounterExampleNextUnitTest.class, + // CounterExampleUntilUnitTest.class, + // CounterExampleWeakUntilUnitTest.class, + CounterExampleReleaseUnitTest.class, CounterExampleOnceUnitTest.class, + CounterExampleHistoryUnitTest.class, + CounterExampleYesterdayUnitTest.class, + // CounterExampleSinceUnitTest.class, + // CounterExampleTriggerUnitTest.class, + CounterExampleNotUnitTest.class, CounterExampleAndUnitTest.class, + CounterExampleOrUnitTest.class, CounterExampleImplyUnitTest.class }) +public final class CounterExampleAllUnitTests { +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAndUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAndUnitTest.java index d389f63aed1a40610e3264fd08a357d073c5d371..56e08db535c66508bfa18704be6c3ade90edab63 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAndUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleAndUnitTest.java @@ -1,506 +1,506 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleConjunction; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for an "and" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleAndUnitTest { - /* - * f-FTTF, g-TTFF, f And g-FTFF - */ - @Test - public void testAndOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "fttf"); - final CounterExampleProposition snd = d.addArgument("snd", "ttff"); - final CounterExampleBinaryOperator and = new CounterExampleConjunction( - d.getCounterExample(), fst, snd); - d.checkValues("and", and, "ftff"); - - // check highlighted positions - d.expectedHighlight(0, "fstH", 0); - d.expectedHighlight(0, "sndH"); - - d.expectedHighlight(1, "fstH", 1); - d.expectedHighlight(1, "sndH", 1); - - d.expectedHighlight(2, "fstH"); - d.expectedHighlight(2, "sndH", 2); - - d.expectedHighlight(3, "fstH", 3); // If both are false, the first is - // chosen to be highlighted (could - // be different) - d.expectedHighlight(3, "sndH"); - - d.checkHighlights("and", and, "fstH", "sndH"); - } - - /* - * f-FTTF, g-TTFF, f And g-FTFF - */ - @Test - public void testAndOnInfinitePath() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // using a loop with state 0 as entry point - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // Loop entry = 0 - // create first argument - CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce0, firstArgumentValues); - - // create second argument - CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce0, secondArgumentValues); - - // create an operator - CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( - ce0, firstArgument, secondArgument); - - // check result values - List<CounterExampleValueType> values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - List<List<Integer>> firstHighlightedPositions = andOperator - .getFirstHighlightedPositions(); - List<List<Integer>> secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 0); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 1 - // create first argument - CounterExample ce1 = TestCounterExample.loop(1, 4); - firstArgument = new CounterExamplePredicate("", ce1, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce1, - secondArgumentValues); - - // create an operator - andOperator = new CounterExampleConjunction(ce1, firstArgument, - secondArgument); - - // check result values - values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 0); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 2 - CounterExample ce2 = TestCounterExample.loop(2, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce2, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce2, - secondArgumentValues); - - // create an operator - andOperator = new CounterExampleConjunction(ce2, firstArgument, - secondArgument); - - // check result values - values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 0); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(4, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce3, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce3, - secondArgumentValues); - - // create an operator - andOperator = new CounterExampleConjunction(ce3, firstArgument, - secondArgument); - - // check result values - values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 0); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } - - /* - * f-FTTF, g-TTFF, f And g-FTFF - */ - @Test - public void testAndOnReducedPath1() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = andOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 0); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } - - /* - * f-FUUT, g-UTUU, f And g-FUUU - */ - @Test - public void testAndOnReducedPath2() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = andOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = andOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = andOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 0); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleConjunction; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for an "and" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleAndUnitTest { + /* + * f-FTTF, g-TTFF, f And g-FTFF + */ + @Test + public void testAndOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "fttf"); + final CounterExampleProposition snd = d.addArgument("snd", "ttff"); + final CounterExampleBinaryOperator and = new CounterExampleConjunction( + d.getCounterExample(), fst, snd); + d.checkValues("and", and, "ftff"); + + // check highlighted positions + d.expectedHighlight(0, "fstH", 0); + d.expectedHighlight(0, "sndH"); + + d.expectedHighlight(1, "fstH", 1); + d.expectedHighlight(1, "sndH", 1); + + d.expectedHighlight(2, "fstH"); + d.expectedHighlight(2, "sndH", 2); + + d.expectedHighlight(3, "fstH", 3); // If both are false, the first is + // chosen to be highlighted (could + // be different) + d.expectedHighlight(3, "sndH"); + + d.checkHighlights("and", and, "fstH", "sndH"); + } + + /* + * f-FTTF, g-TTFF, f And g-FTFF + */ + @Test + public void testAndOnInfinitePath() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // using a loop with state 0 as entry point + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // Loop entry = 0 + // create first argument + CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce0, firstArgumentValues); + + // create second argument + CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce0, secondArgumentValues); + + // create an operator + CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( + ce0, firstArgument, secondArgument); + + // check result values + List<CounterExampleValueType> values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + List<List<Integer>> firstHighlightedPositions = andOperator + .getFirstHighlightedPositions(); + List<List<Integer>> secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 0); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 1 + // create first argument + CounterExample ce1 = TestCounterExample.loop(1, 4); + firstArgument = new CounterExamplePredicate("", ce1, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce1, + secondArgumentValues); + + // create an operator + andOperator = new CounterExampleConjunction(ce1, firstArgument, + secondArgument); + + // check result values + values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 0); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 2 + CounterExample ce2 = TestCounterExample.loop(2, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce2, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce2, + secondArgumentValues); + + // create an operator + andOperator = new CounterExampleConjunction(ce2, firstArgument, + secondArgument); + + // check result values + values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 0); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(4, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce3, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce3, + secondArgumentValues); + + // create an operator + andOperator = new CounterExampleConjunction(ce3, firstArgument, + secondArgument); + + // check result values + values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = andOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 0); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } + + /* + * f-FTTF, g-TTFF, f And g-FTFF + */ + @Test + public void testAndOnReducedPath1() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = andOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 0); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } + + /* + * f-FUUT, g-UTUU, f And g-FUUU + */ + @Test + public void testAndOnReducedPath2() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator andOperator = new CounterExampleConjunction( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = andOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = andOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = andOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 0); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleFinallyUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleFinallyUnitTest.java index 1ddcd43cb25762df80a63a25af810d54b99c6c20..837ed9db8cc65595f7afa2040a68b2468117ddfb 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleFinallyUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleFinallyUnitTest.java @@ -1,299 +1,299 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleFinally; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for a "finally" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleFinallyUnitTest { - @Test - public void testFinallyOnFinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.finite(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = finallyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = finallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - @Test - public void testFinallyOnInfinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create an argument - CounterExampleProposition argument = new CounterExamplePredicate("", - ce0, argumentValues); - - // create an operator - CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( - ce0, argument); - - // check result values - List<CounterExampleValueType> values = finallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - List<List<Integer>> highlightedPositions = finallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 1 })); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(1, 4); - // create an argument - argument = new CounterExamplePredicate("", ce1, argumentValues); - - // create an operator - finallyOperator = new CounterExampleFinally(ce1, argument); - - // check result values - values = finallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = finallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 1 })); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(2, 4); - // create an argument - argument = new CounterExamplePredicate("", ce2, argumentValues); - - // create an operator - finallyOperator = new CounterExampleFinally(ce2, argument); - - // check result values - values = finallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = finallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2 })); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - // create an argument - argument = new CounterExamplePredicate("", ce3, argumentValues); - - // create an operator - finallyOperator = new CounterExampleFinally(ce3, argument); - - // check result values - values = finallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = finallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - @Test - public void testFinallyOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = finallyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = finallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 2, 3 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleFinally; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for a "finally" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleFinallyUnitTest { + @Test + public void testFinallyOnFinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.finite(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = finallyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = finallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + @Test + public void testFinallyOnInfinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create an argument + CounterExampleProposition argument = new CounterExamplePredicate("", + ce0, argumentValues); + + // create an operator + CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( + ce0, argument); + + // check result values + List<CounterExampleValueType> values = finallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + List<List<Integer>> highlightedPositions = finallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 1 })); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(1, 4); + // create an argument + argument = new CounterExamplePredicate("", ce1, argumentValues); + + // create an operator + finallyOperator = new CounterExampleFinally(ce1, argument); + + // check result values + values = finallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = finallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 1 })); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(2, 4); + // create an argument + argument = new CounterExamplePredicate("", ce2, argumentValues); + + // create an operator + finallyOperator = new CounterExampleFinally(ce2, argument); + + // check result values + values = finallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = finallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2 })); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + // create an argument + argument = new CounterExamplePredicate("", ce3, argumentValues); + + // create an operator + finallyOperator = new CounterExampleFinally(ce3, argument); + + // check result values + values = finallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = finallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + @Test + public void testFinallyOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator finallyOperator = new CounterExampleFinally( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = finallyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = finallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 2, 3 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleGloballyUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleGloballyUnitTest.java index f772c06a1f6790453536355706ecadb6850c05e7..26df13d5179f4cf7299f06c0837d39425dd695fc 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleGloballyUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleGloballyUnitTest.java @@ -1,300 +1,300 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleGlobally; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for a "globally" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleGloballyUnitTest { - @Test - public void testGloballyOnFinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - final CounterExample ce = TestCounterExample.finite(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = globallyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = globallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - @Test - public void testGloballyOnInfinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create an argument - CounterExampleProposition argument = new CounterExamplePredicate("", - ce0, argumentValues); - - // create an operator - CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( - ce0, argument); - - // check result values - List<CounterExampleValueType> values = globallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - List<List<Integer>> highlightedPositions = globallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 1 })); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(1, 4); - // create an argument - argument = new CounterExamplePredicate("", ce1, argumentValues); - - // create an operator - globallyOperator = new CounterExampleGlobally(ce1, argument); - - // check result values - values = globallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = globallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 1 })); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(2, 4); - // create an argument - argument = new CounterExamplePredicate("", ce2, argumentValues); - - // create an operator - globallyOperator = new CounterExampleGlobally(ce2, argument); - - // check result values - values = globallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = globallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2 })); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - // create an argument - argument = new CounterExamplePredicate("", ce3, argumentValues); - - // create an operator - globallyOperator = new CounterExampleGlobally(ce3, argument); - - // check result values - values = globallyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = globallyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - @Test - public void testGloballyOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = globallyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.FALSE); - assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = globallyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 2, 3 })); - - assertTrue(highlightedPositions.get(2).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 3 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleGlobally; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for a "globally" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleGloballyUnitTest { + @Test + public void testGloballyOnFinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + final CounterExample ce = TestCounterExample.finite(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = globallyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = globallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + @Test + public void testGloballyOnInfinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create an argument + CounterExampleProposition argument = new CounterExamplePredicate("", + ce0, argumentValues); + + // create an operator + CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( + ce0, argument); + + // check result values + List<CounterExampleValueType> values = globallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + List<List<Integer>> highlightedPositions = globallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 1 })); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(1, 4); + // create an argument + argument = new CounterExamplePredicate("", ce1, argumentValues); + + // create an operator + globallyOperator = new CounterExampleGlobally(ce1, argument); + + // check result values + values = globallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = globallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 1 })); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(2, 4); + // create an argument + argument = new CounterExamplePredicate("", ce2, argumentValues); + + // create an operator + globallyOperator = new CounterExampleGlobally(ce2, argument); + + // check result values + values = globallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = globallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2 })); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + // create an argument + argument = new CounterExamplePredicate("", ce3, argumentValues); + + // create an operator + globallyOperator = new CounterExampleGlobally(ce3, argument); + + // check result values + values = globallyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = globallyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + @Test + public void testGloballyOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator globallyOperator = new CounterExampleGlobally( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = globallyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.FALSE); + assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = globallyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 2, 3 })); + + assertTrue(highlightedPositions.get(2).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 3 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleHistoryUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleHistoryUnitTest.java index 51e89995d8ca4f09bb0ca2979714eab55263e686..2cfb03f638d89aa1d6ccb7318a0cdb8f965113a0 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleHistoryUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleHistoryUnitTest.java @@ -1,710 +1,710 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleHistory; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for a "history" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleHistoryUnitTest { - /* - * f-TTTT, O f-TTTT - */ - @Test - public void testHistoryTrueDefinitionOnFinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - final CounterExample ce = TestCounterExample.finite(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - } - - /* - * f-TTFF, O f-TTFF - */ - @Test - public void testHistoryFalseDefinitionOnFinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.finite(4); - - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-TTTT, O f-TTTT - */ - @Test - public void testHistoryTrueDefinitionOnInfinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create an argument - CounterExampleProposition argument = new CounterExamplePredicate("", - ce0, argumentValues); - - // create an operator - CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce0, argument); - - // check result values - List<CounterExampleValueType> values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(1, 4); - // create an argument - argument = new CounterExamplePredicate("", ce1, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce1, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(2, 4); - - // create an argument - argument = new CounterExamplePredicate("", ce2, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce2, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - - // create an argument - argument = new CounterExamplePredicate("", ce3, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce3, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - } - - /* - * f-TTFF, O f-TTFF - */ - @Test - public void testHistoryFalseDefinitionOnInFinitePath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create an argument - CounterExampleProposition argument = new CounterExamplePredicate("", - ce0, argumentValues); - - // create an operator - CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce0, argument); - - // check result values - List<CounterExampleValueType> values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(0, 4); - // create an argument - argument = new CounterExamplePredicate("", ce1, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce1, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(0, 4); - // create an argument - argument = new CounterExamplePredicate("", ce2, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce2, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - // create an argument - argument = new CounterExamplePredicate("", ce3, argumentValues); - - // create an operator - historyOperator = new CounterExampleHistory(ce3, argument); - - // check result values - values = historyOperator.getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - highlightedPositions = historyOperator.getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-TTTT, O f-TTTT - */ - @Test - public void testHistoryTrueDefinitionOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - } - - /* - * f-TTFF, O f-TTFF - */ - @Test - public void testHistoryFalseDefinitionOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.FALSE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-UTUT, O f-UUUU - */ - @Test - public void testHistoryUnknownDefinitionOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 4); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3, 2, 1, 0 })); - } - - /* - * f-TUTF, O f-TUUF - */ - @Test - public void testHistoryOnReducedPath() { - // create argument values - final List<CounterExampleValueType> argumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create an argument - final CounterExampleProposition argument = new CounterExamplePredicate( - "", ce, argumentValues); - - // create an operator - final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( - ce, argument); - - // check result values - final List<CounterExampleValueType> values = historyOperator - .getValues(); - assertTrue(values.size() == argumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> highlightedPositions = historyOperator - .getHighlightedPositions(); - assertTrue(highlightedPositions.size() == argumentValues.size()); - assertTrue(highlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - assertTrue(highlightedPositions.get(1).size() == 2); - assertTrue(Arrays.equals( - highlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1, 0 })); - - assertTrue(highlightedPositions.get(2).size() == 3); - assertTrue(Arrays.equals( - highlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2, 1, 0 })); - - assertTrue(highlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - highlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleHistory; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for a "history" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleHistoryUnitTest { + /* + * f-TTTT, O f-TTTT + */ + @Test + public void testHistoryTrueDefinitionOnFinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + final CounterExample ce = TestCounterExample.finite(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + } + + /* + * f-TTFF, O f-TTFF + */ + @Test + public void testHistoryFalseDefinitionOnFinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.finite(4); + + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-TTTT, O f-TTTT + */ + @Test + public void testHistoryTrueDefinitionOnInfinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create an argument + CounterExampleProposition argument = new CounterExamplePredicate("", + ce0, argumentValues); + + // create an operator + CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce0, argument); + + // check result values + List<CounterExampleValueType> values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(1, 4); + // create an argument + argument = new CounterExamplePredicate("", ce1, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce1, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(2, 4); + + // create an argument + argument = new CounterExamplePredicate("", ce2, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce2, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + + // create an argument + argument = new CounterExamplePredicate("", ce3, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce3, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + } + + /* + * f-TTFF, O f-TTFF + */ + @Test + public void testHistoryFalseDefinitionOnInFinitePath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create an argument + CounterExampleProposition argument = new CounterExamplePredicate("", + ce0, argumentValues); + + // create an operator + CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce0, argument); + + // check result values + List<CounterExampleValueType> values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(0, 4); + // create an argument + argument = new CounterExamplePredicate("", ce1, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce1, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(0, 4); + // create an argument + argument = new CounterExamplePredicate("", ce2, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce2, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + // create an argument + argument = new CounterExamplePredicate("", ce3, argumentValues); + + // create an operator + historyOperator = new CounterExampleHistory(ce3, argument); + + // check result values + values = historyOperator.getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + highlightedPositions = historyOperator.getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-TTTT, O f-TTTT + */ + @Test + public void testHistoryTrueDefinitionOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + } + + /* + * f-TTFF, O f-TTFF + */ + @Test + public void testHistoryFalseDefinitionOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.FALSE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-UTUT, O f-UUUU + */ + @Test + public void testHistoryUnknownDefinitionOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 4); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3, 2, 1, 0 })); + } + + /* + * f-TUTF, O f-TUUF + */ + @Test + public void testHistoryOnReducedPath() { + // create argument values + final List<CounterExampleValueType> argumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create an argument + final CounterExampleProposition argument = new CounterExamplePredicate( + "", ce, argumentValues); + + // create an operator + final CounterExampleUnaryOperator historyOperator = new CounterExampleHistory( + ce, argument); + + // check result values + final List<CounterExampleValueType> values = historyOperator + .getValues(); + assertTrue(values.size() == argumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> highlightedPositions = historyOperator + .getHighlightedPositions(); + assertTrue(highlightedPositions.size() == argumentValues.size()); + assertTrue(highlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + assertTrue(highlightedPositions.get(1).size() == 2); + assertTrue(Arrays.equals( + highlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1, 0 })); + + assertTrue(highlightedPositions.get(2).size() == 3); + assertTrue(Arrays.equals( + highlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2, 1, 0 })); + + assertTrue(highlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + highlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleImplyUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleImplyUnitTest.java index c130d52f3a8689feb434abdc222cef59779c6082..6d729bb3907c6da66aeb3840bba5cfa4a4316003 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleImplyUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleImplyUnitTest.java @@ -1,652 +1,652 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleImplication; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for an "imply" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleImplyUnitTest { - /* - * f-TTFF, g-TFTF, f Imply g-TFTT - */ - @Test - public void testImplyOnFinitePath() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.finite(4); - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } - - /* - * f-TTFF, g-TFTF, f Imply g-TFTT - */ - @Test - public void testImplyOnInfinitePath() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create first argument - CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce0, firstArgumentValues); - - // create second argument - CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce0, secondArgumentValues); - - // create an operator - CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( - ce0, firstArgument, secondArgument); - - // check result values - List<CounterExampleValueType> values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - List<List<Integer>> firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - List<List<Integer>> secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(1, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce1, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce1, - secondArgumentValues); - - // create an operator - implyOperator = new CounterExampleImplication(ce1, firstArgument, - secondArgument); - - // check result values - values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(2, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce2, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce2, - secondArgumentValues); - - // create an operator - implyOperator = new CounterExampleImplication(ce2, firstArgument, - secondArgument); - - // check result values - values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce3, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce3, - secondArgumentValues); - - // create an operator - implyOperator = new CounterExampleImplication(ce3, firstArgument, - secondArgument); - - // check result values - values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } - - /* - * f-TTFF, g-TFTF, f Imply g-TFTT - */ - @Test - public void testImplyOnReducedPath1() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.FALSE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } - - /* - * f-UUTU, g-UTUF, f Imply g-UTUU - */ - @Test - public void testImplyOnReducedPath2() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 0); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-UUTF, g-UTUU, f Imply g-UTUT - */ - @Test - public void testImplyOnReducedPath3() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = implyOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.TRUE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = implyOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = implyOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 0); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 0); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleImplication; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for an "imply" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleImplyUnitTest { + /* + * f-TTFF, g-TFTF, f Imply g-TFTT + */ + @Test + public void testImplyOnFinitePath() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.finite(4); + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } + + /* + * f-TTFF, g-TFTF, f Imply g-TFTT + */ + @Test + public void testImplyOnInfinitePath() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create first argument + CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce0, firstArgumentValues); + + // create second argument + CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce0, secondArgumentValues); + + // create an operator + CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( + ce0, firstArgument, secondArgument); + + // check result values + List<CounterExampleValueType> values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + List<List<Integer>> firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + List<List<Integer>> secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(1, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce1, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce1, + secondArgumentValues); + + // create an operator + implyOperator = new CounterExampleImplication(ce1, firstArgument, + secondArgument); + + // check result values + values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(2, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce2, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce2, + secondArgumentValues); + + // create an operator + implyOperator = new CounterExampleImplication(ce2, firstArgument, + secondArgument); + + // check result values + values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce3, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce3, + secondArgumentValues); + + // create an operator + implyOperator = new CounterExampleImplication(ce3, firstArgument, + secondArgument); + + // check result values + values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } + + /* + * f-TTFF, g-TFTF, f Imply g-TFTT + */ + @Test + public void testImplyOnReducedPath1() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.FALSE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } + + /* + * f-UUTU, g-UTUF, f Imply g-UTUU + */ + @Test + public void testImplyOnReducedPath2() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 0); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-UUTF, g-UTUU, f Imply g-UTUT + */ + @Test + public void testImplyOnReducedPath3() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator implyOperator = new CounterExampleImplication( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = implyOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.TRUE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = implyOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = implyOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 0); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 0); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNextUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNextUnitTest.java index d6dd660ce65667d5637e11a56d7367e7f5129fda..176c2739f5f8d3f68ce421265716c6447df30537 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNextUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNextUnitTest.java @@ -1,63 +1,63 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExampleNext; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -/** - * Unit test for a "next" operator. - * - * @author Andriy Tolstoy - */ -public final class CounterExampleNextUnitTest { - @Test - public void testNextOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition arg = d.addArgument("arg", "ftft"); - final CounterExampleUnaryOperator next = new CounterExampleNext( - d.getCounterExample(), arg); - - d.checkValues("next", next, "tftf"); - - d.expectedHighlight(0, "nextH", 1); - d.expectedHighlight(1, "nextH", 2); - d.expectedHighlight(2, "nextH", 3); - d.expectedHighlight(3, "nextH"); - d.checkHighlights("next", next, "nextH"); - } - - @Test - public void testNextOnInfinitePath() { - final String[] values = new String[] { "tftf", "tftt", "tftf", "tftt" }; - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - final CounterExampleProposition arg = d.addArgument("arg", "ftft"); - final CounterExampleUnaryOperator next = new CounterExampleNext( - d.getCounterExample(), arg); - - d.checkValues("next", next, values[entry]); - d.expectedHighlight(0, "nextH", 1); - d.expectedHighlight(1, "nextH", 2); - d.expectedHighlight(2, "nextH", 3); - d.expectedHighlight(3, "nextH", entry); - d.checkHighlights("next", next, "nextH"); - } - } - - @Test - public void testNextOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - final CounterExampleProposition arg = d.addArgument("arg", "tuft"); - final CounterExampleUnaryOperator next = new CounterExampleNext( - d.getCounterExample(), arg); - d.checkValues("next", next, "uftu"); - - d.expectedHighlight(0, "nextH", 1); - d.expectedHighlight(1, "nextH", 2); - d.expectedHighlight(2, "nextH", 3); - d.expectedHighlight(3, "nextH"); - d.checkHighlights("next", next, "nextH"); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExampleNext; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +/** + * Unit test for a "next" operator. + * + * @author Andriy Tolstoy + */ +public final class CounterExampleNextUnitTest { + @Test + public void testNextOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition arg = d.addArgument("arg", "ftft"); + final CounterExampleUnaryOperator next = new CounterExampleNext( + d.getCounterExample(), arg); + + d.checkValues("next", next, "tftf"); + + d.expectedHighlight(0, "nextH", 1); + d.expectedHighlight(1, "nextH", 2); + d.expectedHighlight(2, "nextH", 3); + d.expectedHighlight(3, "nextH"); + d.checkHighlights("next", next, "nextH"); + } + + @Test + public void testNextOnInfinitePath() { + final String[] values = new String[] { "tftf", "tftt", "tftf", "tftt" }; + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + final CounterExampleProposition arg = d.addArgument("arg", "ftft"); + final CounterExampleUnaryOperator next = new CounterExampleNext( + d.getCounterExample(), arg); + + d.checkValues("next", next, values[entry]); + d.expectedHighlight(0, "nextH", 1); + d.expectedHighlight(1, "nextH", 2); + d.expectedHighlight(2, "nextH", 3); + d.expectedHighlight(3, "nextH", entry); + d.checkHighlights("next", next, "nextH"); + } + } + + @Test + public void testNextOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + final CounterExampleProposition arg = d.addArgument("arg", "tuft"); + final CounterExampleUnaryOperator next = new CounterExampleNext( + d.getCounterExample(), arg); + d.checkValues("next", next, "uftu"); + + d.expectedHighlight(0, "nextH", 1); + d.expectedHighlight(1, "nextH", 2); + d.expectedHighlight(2, "nextH", 3); + d.expectedHighlight(3, "nextH"); + d.checkHighlights("next", next, "nextH"); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNotUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNotUnitTest.java index 3566fac5615f9dcb2de1423a62c4b33289acbae1..5ba2dfc69becb7af24534ac927956525e7b63454 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNotUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleNotUnitTest.java @@ -1,74 +1,74 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExampleNegation; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -/** - * Unit test for a "not" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleNotUnitTest { - - /* - * f-TFFT, Not f-FTTF - */ - @Test - public void testNotOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - checkNot(d); - } - - /* - * f-TFFT, Not f-FTTF - */ - @Test - public void testNotOnInFinitePath() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - checkNot(d); - } - } - - /* - * f-TFFT, Not f-FTTF - */ - @Test - public void testNotOnReducedPath1() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - checkNot(d); - } - - /* - * f-TUFU, Not f-FUTU - */ - @Test - public void testNotOnReducedPath2() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - final CounterExampleProposition arg = d.addArgument("not", "tufu"); - final CounterExampleUnaryOperator not = new CounterExampleNegation( - d.getCounterExample(), arg); - d.checkValues("not", not, "futu"); - d.expectedHighlight(0, "notH", 0); - d.expectedHighlight(1, "notH", 1); - d.expectedHighlight(2, "notH", 2); - d.expectedHighlight(3, "notH", 3); - d.checkHighlights("not", not, "notH"); - } - - private void checkNot(final LtlTestDescription d) { - final CounterExampleProposition arg = d.addArgument("not", "tfft"); - final CounterExampleUnaryOperator not = new CounterExampleNegation( - d.getCounterExample(), arg); - d.checkValues("not", not, "fttf"); - d.expectedHighlight(0, "notH", 0); - d.expectedHighlight(1, "notH", 1); - d.expectedHighlight(2, "notH", 2); - d.expectedHighlight(3, "notH", 3); - d.checkHighlights("not", not, "notH"); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExampleNegation; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +/** + * Unit test for a "not" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleNotUnitTest { + + /* + * f-TFFT, Not f-FTTF + */ + @Test + public void testNotOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + checkNot(d); + } + + /* + * f-TFFT, Not f-FTTF + */ + @Test + public void testNotOnInFinitePath() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + checkNot(d); + } + } + + /* + * f-TFFT, Not f-FTTF + */ + @Test + public void testNotOnReducedPath1() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + checkNot(d); + } + + /* + * f-TUFU, Not f-FUTU + */ + @Test + public void testNotOnReducedPath2() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + final CounterExampleProposition arg = d.addArgument("not", "tufu"); + final CounterExampleUnaryOperator not = new CounterExampleNegation( + d.getCounterExample(), arg); + d.checkValues("not", not, "futu"); + d.expectedHighlight(0, "notH", 0); + d.expectedHighlight(1, "notH", 1); + d.expectedHighlight(2, "notH", 2); + d.expectedHighlight(3, "notH", 3); + d.checkHighlights("not", not, "notH"); + } + + private void checkNot(final LtlTestDescription d) { + final CounterExampleProposition arg = d.addArgument("not", "tfft"); + final CounterExampleUnaryOperator not = new CounterExampleNegation( + d.getCounterExample(), arg); + d.checkValues("not", not, "fttf"); + d.expectedHighlight(0, "notH", 0); + d.expectedHighlight(1, "notH", 1); + d.expectedHighlight(2, "notH", 2); + d.expectedHighlight(3, "notH", 3); + d.checkHighlights("not", not, "notH"); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOnceUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOnceUnitTest.java index 4457b80bfb84040bfc7d30f5353c64ff0b1bdc8f..9f9746b68141d92a590093a582b11da6cb8102c2 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOnceUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOnceUnitTest.java @@ -1,131 +1,131 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExampleOnce; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -/** - * Unit test for an "once" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleOnceUnitTest { - /* - * f-FTFT, O f-FTTT - */ - @Test - public void testOnceTrueDefinitionOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - checkOnce(d); - } - - /* - * f-FFFF, O f-FFFF - */ - @Test - public void testOnceFalseDefinitionOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - checkOnceCompleteFalse(d); - } - - /* - * f-FTFT, O f-FTTT - */ - @Test - public void testOnceTrueDefinitionOnInfinitePath() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - checkOnce(d); - } - } - - /* - * f-FFFF, O f-FFFF - */ - @Test - public void testOnceFalseDefinitionOnInfinitePath() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - checkOnceCompleteFalse(d); - } - } - - /* - * f-FTFT, O f-FTTT - */ - @Test - public void testOnceTrueDefinitionOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - checkOnce(d); - } - - /* - * f-FFFF, O f-FFFF - */ - @Test - public void testOnceFalseDefinitionOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - checkOnceCompleteFalse(d); - } - - /* - * f-UFUF, O f-UUUU - */ - @Test - public void testOnceUnknownDefinitionOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - final CounterExampleProposition arg = d.addArgument("arg", "ufuf"); - final CounterExampleUnaryOperator once = new CounterExampleOnce( - d.getCounterExample(), arg); - d.checkValues("once", once, "uuuu"); - d.expectedHighlight(0, "onceH", 0); - d.expectedHighlight(1, "onceH", 0, 1); - d.expectedHighlight(2, "onceH", 0, 1, 2); - d.expectedHighlight(3, "onceH", 0, 1, 2, 3); - d.checkHighlights("once", once, "onceH"); - } - - /* - * f-FUTU, O f-FUTT - */ - @Test - public void testOnceOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - final CounterExampleProposition arg = d.addArgument("arg", "futu"); - final CounterExampleUnaryOperator once = new CounterExampleOnce( - d.getCounterExample(), arg); - d.checkValues("once", once, "futt"); - d.expectedHighlight(0, "onceH", 0); - d.expectedHighlight(1, "onceH", 0, 1); - d.expectedHighlight(2, "onceH", 2); - d.expectedHighlight(3, "onceH", 2); - d.checkHighlights("once", once, "onceH"); - } - - private void checkOnce(final LtlTestDescription d) { - final CounterExampleProposition arg = d.addArgument("arg", "ftft"); - final CounterExampleUnaryOperator once = new CounterExampleOnce( - d.getCounterExample(), arg); - d.checkValues("once", once, "fttt"); - d.expectedHighlight(0, "onceH", 0); - d.expectedHighlight(1, "onceH", 1); - d.expectedHighlight(2, "onceH", 1); - d.expectedHighlight(3, "onceH", 3); - d.checkHighlights("once", once, "onceH"); - } - - private void checkOnceCompleteFalse(final LtlTestDescription d) { - final CounterExampleProposition arg = d.addArgument("arg", "ffff"); - final CounterExampleUnaryOperator once = new CounterExampleOnce( - d.getCounterExample(), arg); - d.checkValues("once", once, "ffff"); - d.expectedHighlight(0, "onceH", 0); - d.expectedHighlight(1, "onceH", 0, 1); - d.expectedHighlight(2, "onceH", 0, 1, 2); - d.expectedHighlight(3, "onceH", 0, 1, 2, 3); - d.checkHighlights("once", once, "onceH"); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExampleOnce; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +/** + * Unit test for an "once" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleOnceUnitTest { + /* + * f-FTFT, O f-FTTT + */ + @Test + public void testOnceTrueDefinitionOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + checkOnce(d); + } + + /* + * f-FFFF, O f-FFFF + */ + @Test + public void testOnceFalseDefinitionOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + checkOnceCompleteFalse(d); + } + + /* + * f-FTFT, O f-FTTT + */ + @Test + public void testOnceTrueDefinitionOnInfinitePath() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + checkOnce(d); + } + } + + /* + * f-FFFF, O f-FFFF + */ + @Test + public void testOnceFalseDefinitionOnInfinitePath() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + checkOnceCompleteFalse(d); + } + } + + /* + * f-FTFT, O f-FTTT + */ + @Test + public void testOnceTrueDefinitionOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + checkOnce(d); + } + + /* + * f-FFFF, O f-FFFF + */ + @Test + public void testOnceFalseDefinitionOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + checkOnceCompleteFalse(d); + } + + /* + * f-UFUF, O f-UUUU + */ + @Test + public void testOnceUnknownDefinitionOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + final CounterExampleProposition arg = d.addArgument("arg", "ufuf"); + final CounterExampleUnaryOperator once = new CounterExampleOnce( + d.getCounterExample(), arg); + d.checkValues("once", once, "uuuu"); + d.expectedHighlight(0, "onceH", 0); + d.expectedHighlight(1, "onceH", 0, 1); + d.expectedHighlight(2, "onceH", 0, 1, 2); + d.expectedHighlight(3, "onceH", 0, 1, 2, 3); + d.checkHighlights("once", once, "onceH"); + } + + /* + * f-FUTU, O f-FUTT + */ + @Test + public void testOnceOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + final CounterExampleProposition arg = d.addArgument("arg", "futu"); + final CounterExampleUnaryOperator once = new CounterExampleOnce( + d.getCounterExample(), arg); + d.checkValues("once", once, "futt"); + d.expectedHighlight(0, "onceH", 0); + d.expectedHighlight(1, "onceH", 0, 1); + d.expectedHighlight(2, "onceH", 2); + d.expectedHighlight(3, "onceH", 2); + d.checkHighlights("once", once, "onceH"); + } + + private void checkOnce(final LtlTestDescription d) { + final CounterExampleProposition arg = d.addArgument("arg", "ftft"); + final CounterExampleUnaryOperator once = new CounterExampleOnce( + d.getCounterExample(), arg); + d.checkValues("once", once, "fttt"); + d.expectedHighlight(0, "onceH", 0); + d.expectedHighlight(1, "onceH", 1); + d.expectedHighlight(2, "onceH", 1); + d.expectedHighlight(3, "onceH", 3); + d.checkHighlights("once", once, "onceH"); + } + + private void checkOnceCompleteFalse(final LtlTestDescription d) { + final CounterExampleProposition arg = d.addArgument("arg", "ffff"); + final CounterExampleUnaryOperator once = new CounterExampleOnce( + d.getCounterExample(), arg); + d.checkValues("once", once, "ffff"); + d.expectedHighlight(0, "onceH", 0); + d.expectedHighlight(1, "onceH", 0, 1); + d.expectedHighlight(2, "onceH", 0, 1, 2); + d.expectedHighlight(3, "onceH", 0, 1, 2, 3); + d.checkHighlights("once", once, "onceH"); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOrUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOrUnitTest.java index ccff698093a9695ddea8b19a642e368ea36f5c7c..1997b45f4be51ed286a73e25136f53bce6dfcd0c 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOrUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleOrUnitTest.java @@ -1,559 +1,559 @@ -package de.prob.core.domainobjects.ltl.tests; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleDisjunction; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/** - * Unit test for an "or" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleOrUnitTest { - /* - * f-FTTF, g-TTFF, f Or g-TTTF - */ - @Test - public void testOrOnFinitePath() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.finite(4); - - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = orOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = orOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-FTTF, g-TTFF, f Or g-FTFF - */ - @Test - public void testOrOnInfinitePath() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - // Loop entry = 0 - final CounterExample ce0 = TestCounterExample.loop(0, 4); - // create first argument - CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce0, firstArgumentValues); - - // create second argument - CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce0, secondArgumentValues); - - // create an operator - CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( - ce0, firstArgument, secondArgument); - - // check result values - List<CounterExampleValueType> values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - List<List<Integer>> firstHighlightedPositions = orOperator - .getFirstHighlightedPositions(); - List<List<Integer>> secondHighlightedPositions = orOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 1 - final CounterExample ce1 = TestCounterExample.loop(1, 4); - - // create first argument - firstArgument = new CounterExamplePredicate("", ce1, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce1, - secondArgumentValues); - - // create an operator - orOperator = new CounterExampleDisjunction(ce1, firstArgument, - secondArgument); - - // check result values - values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 2 - final CounterExample ce2 = TestCounterExample.loop(2, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce2, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce2, - secondArgumentValues); - - // create an operator - orOperator = new CounterExampleDisjunction(ce2, firstArgument, - secondArgument); - - // check result values - values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - - // Loop entry = 3 - final CounterExample ce3 = TestCounterExample.loop(3, 4); - // create first argument - firstArgument = new CounterExamplePredicate("", ce3, - firstArgumentValues); - - // create second argument - secondArgument = new CounterExamplePredicate("", ce3, - secondArgumentValues); - - // create an operator - orOperator = new CounterExampleDisjunction(ce3, firstArgument, - secondArgument); - - // check result values - values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); - secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-FTTF, g-TTFF, f Or g-TTTF - */ - @Test - public void testOrOnReducedPath1() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.TRUE, - CounterExampleValueType.TRUE, - CounterExampleValueType.FALSE, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.TRUE); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.TRUE); - assertTrue(values.get(3) == CounterExampleValueType.FALSE); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = orOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = orOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 0); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - assertTrue(secondHighlightedPositions.get(1).size() == 0); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 0); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } - - /* - * f-FUUU, g-UTUF, f Or g-UTUU - */ - @Test - public void testOrOnReducedPath2() { - // create first argument values - final List<CounterExampleValueType> firstArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.FALSE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.UNKNOWN }); - - // create second argument values - final List<CounterExampleValueType> secondArgumentValues = Arrays - .asList(new CounterExampleValueType[] { - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.TRUE, - CounterExampleValueType.UNKNOWN, - CounterExampleValueType.FALSE }); - - final CounterExample ce = TestCounterExample.reduced(4); - // create first argument - final CounterExampleProposition firstArgument = new CounterExamplePredicate( - "", ce, firstArgumentValues); - - // create second argument - final CounterExampleProposition secondArgument = new CounterExamplePredicate( - "", ce, secondArgumentValues); - - // create an operator - final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( - ce, firstArgument, secondArgument); - - // check result values - final List<CounterExampleValueType> values = orOperator.getValues(); - assertTrue(values.size() == firstArgumentValues.size()); - assertTrue(values.size() == secondArgumentValues.size()); - assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(1) == CounterExampleValueType.TRUE); - assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - - // check highlighted positions - final List<List<Integer>> firstHighlightedPositions = orOperator - .getFirstHighlightedPositions(); - final List<List<Integer>> secondHighlightedPositions = orOperator - .getSecondHighlightedPositions(); - assertTrue(firstHighlightedPositions.size() == firstArgumentValues - .size()); - assertTrue(secondHighlightedPositions.size() == secondArgumentValues - .size()); - - // State 0 - assertTrue(firstHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - assertTrue(secondHighlightedPositions.get(0).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(0).toArray(new Integer[0]), - new Integer[] { 0 })); - - // State 1 - assertTrue(firstHighlightedPositions.get(1).size() == 0); - assertTrue(secondHighlightedPositions.get(1).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(1).toArray(new Integer[0]), - new Integer[] { 1 })); - - // State 2 - assertTrue(firstHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - assertTrue(secondHighlightedPositions.get(2).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(2).toArray(new Integer[0]), - new Integer[] { 2 })); - - // State 3 - assertTrue(firstHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - firstHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - assertTrue(secondHighlightedPositions.get(3).size() == 1); - assertTrue(Arrays.equals( - secondHighlightedPositions.get(3).toArray(new Integer[0]), - new Integer[] { 3 })); - } -} +package de.prob.core.domainobjects.ltl.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleDisjunction; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/** + * Unit test for an "or" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleOrUnitTest { + /* + * f-FTTF, g-TTFF, f Or g-TTTF + */ + @Test + public void testOrOnFinitePath() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.finite(4); + + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = orOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = orOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-FTTF, g-TTFF, f Or g-FTFF + */ + @Test + public void testOrOnInfinitePath() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + // Loop entry = 0 + final CounterExample ce0 = TestCounterExample.loop(0, 4); + // create first argument + CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce0, firstArgumentValues); + + // create second argument + CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce0, secondArgumentValues); + + // create an operator + CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( + ce0, firstArgument, secondArgument); + + // check result values + List<CounterExampleValueType> values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + List<List<Integer>> firstHighlightedPositions = orOperator + .getFirstHighlightedPositions(); + List<List<Integer>> secondHighlightedPositions = orOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 1 + final CounterExample ce1 = TestCounterExample.loop(1, 4); + + // create first argument + firstArgument = new CounterExamplePredicate("", ce1, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce1, + secondArgumentValues); + + // create an operator + orOperator = new CounterExampleDisjunction(ce1, firstArgument, + secondArgument); + + // check result values + values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 2 + final CounterExample ce2 = TestCounterExample.loop(2, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce2, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce2, + secondArgumentValues); + + // create an operator + orOperator = new CounterExampleDisjunction(ce2, firstArgument, + secondArgument); + + // check result values + values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + + // Loop entry = 3 + final CounterExample ce3 = TestCounterExample.loop(3, 4); + // create first argument + firstArgument = new CounterExamplePredicate("", ce3, + firstArgumentValues); + + // create second argument + secondArgument = new CounterExamplePredicate("", ce3, + secondArgumentValues); + + // create an operator + orOperator = new CounterExampleDisjunction(ce3, firstArgument, + secondArgument); + + // check result values + values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + firstHighlightedPositions = orOperator.getFirstHighlightedPositions(); + secondHighlightedPositions = orOperator.getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-FTTF, g-TTFF, f Or g-TTTF + */ + @Test + public void testOrOnReducedPath1() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.TRUE, + CounterExampleValueType.TRUE, + CounterExampleValueType.FALSE, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.TRUE); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.TRUE); + assertTrue(values.get(3) == CounterExampleValueType.FALSE); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = orOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = orOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 0); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + assertTrue(secondHighlightedPositions.get(1).size() == 0); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 0); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } + + /* + * f-FUUU, g-UTUF, f Or g-UTUU + */ + @Test + public void testOrOnReducedPath2() { + // create first argument values + final List<CounterExampleValueType> firstArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.FALSE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.UNKNOWN }); + + // create second argument values + final List<CounterExampleValueType> secondArgumentValues = Arrays + .asList(new CounterExampleValueType[] { + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.TRUE, + CounterExampleValueType.UNKNOWN, + CounterExampleValueType.FALSE }); + + final CounterExample ce = TestCounterExample.reduced(4); + // create first argument + final CounterExampleProposition firstArgument = new CounterExamplePredicate( + "", ce, firstArgumentValues); + + // create second argument + final CounterExampleProposition secondArgument = new CounterExamplePredicate( + "", ce, secondArgumentValues); + + // create an operator + final CounterExampleBinaryOperator orOperator = new CounterExampleDisjunction( + ce, firstArgument, secondArgument); + + // check result values + final List<CounterExampleValueType> values = orOperator.getValues(); + assertTrue(values.size() == firstArgumentValues.size()); + assertTrue(values.size() == secondArgumentValues.size()); + assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(1) == CounterExampleValueType.TRUE); + assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + + // check highlighted positions + final List<List<Integer>> firstHighlightedPositions = orOperator + .getFirstHighlightedPositions(); + final List<List<Integer>> secondHighlightedPositions = orOperator + .getSecondHighlightedPositions(); + assertTrue(firstHighlightedPositions.size() == firstArgumentValues + .size()); + assertTrue(secondHighlightedPositions.size() == secondArgumentValues + .size()); + + // State 0 + assertTrue(firstHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + assertTrue(secondHighlightedPositions.get(0).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(0).toArray(new Integer[0]), + new Integer[] { 0 })); + + // State 1 + assertTrue(firstHighlightedPositions.get(1).size() == 0); + assertTrue(secondHighlightedPositions.get(1).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(1).toArray(new Integer[0]), + new Integer[] { 1 })); + + // State 2 + assertTrue(firstHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + assertTrue(secondHighlightedPositions.get(2).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(2).toArray(new Integer[0]), + new Integer[] { 2 })); + + // State 3 + assertTrue(firstHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + firstHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + assertTrue(secondHighlightedPositions.get(3).size() == 1); + assertTrue(Arrays.equals( + secondHighlightedPositions.get(3).toArray(new Integer[0]), + new Integer[] { 3 })); + } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleReleaseUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleReleaseUnitTest.java index afedebfc3311bcdc8ba91a139707e630da408017..21bb94c317fae35f25c506165503d11baf3486c0 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleReleaseUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleReleaseUnitTest.java @@ -1,2656 +1,2656 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleRelease; - -/** - * Unit test for a "release" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleReleaseUnitTest { - /* - * f-FFFT, g-TTTT, f R g-TTTT - */ - @Test - public void testReleaseTrueDefinitionOnFinitePath1() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "ffft"); - final CounterExampleProposition snd = d.addArgument("snd", "tttt"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "tttt"); - - d.expectedHighlight(0, "fstH", 3); - d.expectedHighlight(0, "sndH", 0, 1, 2, 3); - - d.expectedHighlight(1, "fstH", 3); - d.expectedHighlight(1, "sndH", 1, 2, 3); - - d.expectedHighlight(2, "fstH", 3); - d.expectedHighlight(2, "sndH", 2, 3); - - d.expectedHighlight(3, "fstH", 3); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-FFFF, g-TTTT, f R g-TTTT - */ - @Test - public void testReleaseTrueDefinitionOnFinitePath2() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "ffff"); - final CounterExampleProposition snd = d.addArgument("snd", "tttt"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "tttt"); - - d.expectedHighlight(0, "fstH"); - d.expectedHighlight(0, "sndH", 0, 1, 2, 3); - - d.expectedHighlight(1, "fstH"); - d.expectedHighlight(1, "sndH", 1, 2, 3); - - d.expectedHighlight(2, "fstH"); - d.expectedHighlight(2, "sndH", 2, 3); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-FFFT, g-TTTF, f R g-FFFF - */ - @Test - public void testReleaseFalseDefinitionOnFinitePath1() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "ffft"); - final CounterExampleProposition snd = d.addArgument("snd", "tttf"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "ffff"); - - d.expectedHighlight(0, "fstH", 0, 1, 2); - d.expectedHighlight(0, "sndH", 3); - - d.expectedHighlight(1, "fstH", 1, 2); - d.expectedHighlight(1, "sndH", 3); - - d.expectedHighlight(2, "fstH", 2); - d.expectedHighlight(2, "sndH", 3); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-FFFF, g-TTTF, f R g-FFFF - */ - @Test - public void testReleaseFalseDefinitionOnFinitePath2() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "ffff"); - final CounterExampleProposition snd = d.addArgument("snd", "tttf"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "ffff"); - - d.expectedHighlight(0, "fstH", 0, 1, 2); - d.expectedHighlight(0, "sndH", 3); - - d.expectedHighlight(1, "fstH", 1, 2); - d.expectedHighlight(1, "sndH", 3); - - d.expectedHighlight(2, "fstH", 2); - d.expectedHighlight(2, "sndH", 3); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-TFTF, g-TFFT, f R g-TFFT - */ - @Test - public void testReleaseOnFinitePath1() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "tftf"); - final CounterExampleProposition snd = d.addArgument("snd", "tfft"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "tfft"); - - d.expectedHighlight(0, "fstH", 0); - d.expectedHighlight(0, "sndH", 0); - - d.expectedHighlight(1, "fstH"); - d.expectedHighlight(1, "sndH", 1); - - d.expectedHighlight(2, "fstH"); - d.expectedHighlight(2, "sndH", 2); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-FTTF, g-TFTT, f R g-FFTT - */ - @Test - public void testReleaseOnFinitePath2() { - final LtlTestDescription d = LtlTestDescription.finite(4); - final CounterExampleProposition fst = d.addArgument("fst", "fttf"); - final CounterExampleProposition snd = d.addArgument("snd", "tftt"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "fftt"); - - d.expectedHighlight(0, "fstH", 0); - d.expectedHighlight(0, "sndH", 1); - - d.expectedHighlight(1, "fstH"); - d.expectedHighlight(1, "sndH", 1); - - d.expectedHighlight(2, "fstH", 2); - d.expectedHighlight(2, "sndH", 2); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - - /* - * f-FFFT, g-TTTT, f R g-TTTT - */ - @Test - public void testReleaseTrueDefinitionOnInfinitePath1() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - final CounterExampleProposition fst = d.addArgument("fst", "ffft"); - final CounterExampleProposition snd = d.addArgument("snd", "tttt"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "tttt"); - - d.expectedHighlight(0, "fstH", 3); - d.expectedHighlight(0, "sndH", 0, 1, 2, 3); - - d.expectedHighlight(1, "fstH", 3); - d.expectedHighlight(1, "sndH", 1, 2, 3); - - d.expectedHighlight(2, "fstH", 3); - d.expectedHighlight(2, "sndH", 2, 3); - - d.expectedHighlight(3, "fstH", 3); - d.expectedHighlight(3, "sndH", 3); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - } - - /* - * f-FFFF, g-TTTT, f R g-TTTT - */ - @Test - public void testReleaseTrueDefinitionOnInfinitePath2() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - final CounterExampleProposition fst = d.addArgument("fst", "ffff"); - final CounterExampleProposition snd = d.addArgument("snd", "tttt"); - final CounterExampleBinaryOperator release = new CounterExampleRelease( - d.getCounterExample(), fst, snd); - d.checkValues("release", release, "tttt"); - - d.expectedHighlight(0, "fstH"); - d.expectedHighlight(0, "sndH", 0, 1, 2, 3); - - d.expectedHighlight(1, "fstH"); - d.expectedHighlight(1, "sndH", future(1, 4, entry)); - - d.expectedHighlight(2, "fstH"); - d.expectedHighlight(2, "sndH", future(2, 4, entry)); - - d.expectedHighlight(3, "fstH"); - d.expectedHighlight(3, "sndH", future(3, 4, entry)); - - d.checkHighlights("release", release, "fstH", "sndH"); - } - } - - // /* - // * f-FFFT, g-TTTF, f R g-FFFF - // */ - // @Test - // public void testReleaseFalseDefinitionOnInfinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFF, g-TTTF, f R g-FFFF - // */ - // @Test - // public void testReleaseFalseDefinitionOnInfinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TFTF, g-TFFT, f R g-TFFT - // */ - // @Test - // public void testReleaseOnInfinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = releaseOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUUT, g-TTTT, f R g-TTTT - // */ - // @Test - // public void testReleaseTrueDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f R g-UUUU - // */ - // @Test - // public void testReleaseTrueDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFT, g-TTTF, f R g-FFFF - // */ - // @Test - // public void testReleaseFalseDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFF, g-FTTT, f R g-FUUU - // */ - // @Test - // public void testReleaseFalseDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUTU, g-UTUU, f R g-UTTU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUUU, g-UTFU, f R g-UUFU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUUU, g-UTUU, f R g-UUUU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f R g-UUUU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath4() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFFF, g-UUUU, f R g-UUUU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath5() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUUU, g-UUUU, f R g-UUUU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath6() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUTF, g-FTTT, f R g-FTTU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath7() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUTU, g-TUTU, f R g-UUTU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath8() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FFTU, g-TUTU, f R g-UUTU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath9() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUUU, g-UTFU, f R g-UUFU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath10() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FUUU, g-UUFU, f R g-UUFU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath11() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FTUF, g-FTUU, f R g-FTUU - // */ - // @Test - // public void testReleaseUnknownDefinitionOnReducedPath12() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator releaseOperator = new - // CounterExampleRelease( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = releaseOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = releaseOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = releaseOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - - private static int[] future(int current, int size, int entry) { - final int first = current <= entry ? current : entry; - final int resSize = size - first; - int[] res = new int[resSize]; - for (int i = 0; i < resSize; i++) { - res[i] = first + i; - } - return res; - } - -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleRelease; + +/** + * Unit test for a "release" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleReleaseUnitTest { + /* + * f-FFFT, g-TTTT, f R g-TTTT + */ + @Test + public void testReleaseTrueDefinitionOnFinitePath1() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "ffft"); + final CounterExampleProposition snd = d.addArgument("snd", "tttt"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "tttt"); + + d.expectedHighlight(0, "fstH", 3); + d.expectedHighlight(0, "sndH", 0, 1, 2, 3); + + d.expectedHighlight(1, "fstH", 3); + d.expectedHighlight(1, "sndH", 1, 2, 3); + + d.expectedHighlight(2, "fstH", 3); + d.expectedHighlight(2, "sndH", 2, 3); + + d.expectedHighlight(3, "fstH", 3); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-FFFF, g-TTTT, f R g-TTTT + */ + @Test + public void testReleaseTrueDefinitionOnFinitePath2() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "ffff"); + final CounterExampleProposition snd = d.addArgument("snd", "tttt"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "tttt"); + + d.expectedHighlight(0, "fstH"); + d.expectedHighlight(0, "sndH", 0, 1, 2, 3); + + d.expectedHighlight(1, "fstH"); + d.expectedHighlight(1, "sndH", 1, 2, 3); + + d.expectedHighlight(2, "fstH"); + d.expectedHighlight(2, "sndH", 2, 3); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-FFFT, g-TTTF, f R g-FFFF + */ + @Test + public void testReleaseFalseDefinitionOnFinitePath1() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "ffft"); + final CounterExampleProposition snd = d.addArgument("snd", "tttf"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "ffff"); + + d.expectedHighlight(0, "fstH", 0, 1, 2); + d.expectedHighlight(0, "sndH", 3); + + d.expectedHighlight(1, "fstH", 1, 2); + d.expectedHighlight(1, "sndH", 3); + + d.expectedHighlight(2, "fstH", 2); + d.expectedHighlight(2, "sndH", 3); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-FFFF, g-TTTF, f R g-FFFF + */ + @Test + public void testReleaseFalseDefinitionOnFinitePath2() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "ffff"); + final CounterExampleProposition snd = d.addArgument("snd", "tttf"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "ffff"); + + d.expectedHighlight(0, "fstH", 0, 1, 2); + d.expectedHighlight(0, "sndH", 3); + + d.expectedHighlight(1, "fstH", 1, 2); + d.expectedHighlight(1, "sndH", 3); + + d.expectedHighlight(2, "fstH", 2); + d.expectedHighlight(2, "sndH", 3); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-TFTF, g-TFFT, f R g-TFFT + */ + @Test + public void testReleaseOnFinitePath1() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "tftf"); + final CounterExampleProposition snd = d.addArgument("snd", "tfft"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "tfft"); + + d.expectedHighlight(0, "fstH", 0); + d.expectedHighlight(0, "sndH", 0); + + d.expectedHighlight(1, "fstH"); + d.expectedHighlight(1, "sndH", 1); + + d.expectedHighlight(2, "fstH"); + d.expectedHighlight(2, "sndH", 2); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-FTTF, g-TFTT, f R g-FFTT + */ + @Test + public void testReleaseOnFinitePath2() { + final LtlTestDescription d = LtlTestDescription.finite(4); + final CounterExampleProposition fst = d.addArgument("fst", "fttf"); + final CounterExampleProposition snd = d.addArgument("snd", "tftt"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "fftt"); + + d.expectedHighlight(0, "fstH", 0); + d.expectedHighlight(0, "sndH", 1); + + d.expectedHighlight(1, "fstH"); + d.expectedHighlight(1, "sndH", 1); + + d.expectedHighlight(2, "fstH", 2); + d.expectedHighlight(2, "sndH", 2); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + + /* + * f-FFFT, g-TTTT, f R g-TTTT + */ + @Test + public void testReleaseTrueDefinitionOnInfinitePath1() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + final CounterExampleProposition fst = d.addArgument("fst", "ffft"); + final CounterExampleProposition snd = d.addArgument("snd", "tttt"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "tttt"); + + d.expectedHighlight(0, "fstH", 3); + d.expectedHighlight(0, "sndH", 0, 1, 2, 3); + + d.expectedHighlight(1, "fstH", 3); + d.expectedHighlight(1, "sndH", 1, 2, 3); + + d.expectedHighlight(2, "fstH", 3); + d.expectedHighlight(2, "sndH", 2, 3); + + d.expectedHighlight(3, "fstH", 3); + d.expectedHighlight(3, "sndH", 3); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + } + + /* + * f-FFFF, g-TTTT, f R g-TTTT + */ + @Test + public void testReleaseTrueDefinitionOnInfinitePath2() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + final CounterExampleProposition fst = d.addArgument("fst", "ffff"); + final CounterExampleProposition snd = d.addArgument("snd", "tttt"); + final CounterExampleBinaryOperator release = new CounterExampleRelease( + d.getCounterExample(), fst, snd); + d.checkValues("release", release, "tttt"); + + d.expectedHighlight(0, "fstH"); + d.expectedHighlight(0, "sndH", 0, 1, 2, 3); + + d.expectedHighlight(1, "fstH"); + d.expectedHighlight(1, "sndH", future(1, 4, entry)); + + d.expectedHighlight(2, "fstH"); + d.expectedHighlight(2, "sndH", future(2, 4, entry)); + + d.expectedHighlight(3, "fstH"); + d.expectedHighlight(3, "sndH", future(3, 4, entry)); + + d.checkHighlights("release", release, "fstH", "sndH"); + } + } + + // /* + // * f-FFFT, g-TTTF, f R g-FFFF + // */ + // @Test + // public void testReleaseFalseDefinitionOnInfinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFF, g-TTTF, f R g-FFFF + // */ + // @Test + // public void testReleaseFalseDefinitionOnInfinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TFTF, g-TFFT, f R g-TFFT + // */ + // @Test + // public void testReleaseOnInfinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator releaseOperator = new CounterExampleRelease( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // releaseOperator = new CounterExampleRelease(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = releaseOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUUT, g-TTTT, f R g-TTTT + // */ + // @Test + // public void testReleaseTrueDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f R g-UUUU + // */ + // @Test + // public void testReleaseTrueDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFT, g-TTTF, f R g-FFFF + // */ + // @Test + // public void testReleaseFalseDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFF, g-FTTT, f R g-FUUU + // */ + // @Test + // public void testReleaseFalseDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUTU, g-UTUU, f R g-UTTU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUUU, g-UTFU, f R g-UUFU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUUU, g-UTUU, f R g-UUUU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f R g-UUUU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath4() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFFF, g-UUUU, f R g-UUUU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath5() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUUU, g-UUUU, f R g-UUUU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath6() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUTF, g-FTTT, f R g-FTTU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath7() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUTU, g-TUTU, f R g-UUTU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath8() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FFTU, g-TUTU, f R g-UUTU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath9() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUUU, g-UTFU, f R g-UUFU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath10() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FUUU, g-UUFU, f R g-UUFU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath11() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FTUF, g-FTUU, f R g-FTUU + // */ + // @Test + // public void testReleaseUnknownDefinitionOnReducedPath12() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator releaseOperator = new + // CounterExampleRelease( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = releaseOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = releaseOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = releaseOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + + private static int[] future(int current, int size, int entry) { + final int first = current <= entry ? current : entry; + final int resSize = size - first; + int[] res = new int[resSize]; + for (int i = 0; i < resSize; i++) { + res[i] = first + i; + } + return res; + } + +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleSinceUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleSinceUnitTest.java index 3752a020179ea16948f81656545498e2d357b5fb..4b1805f7955bcfbbeceb90c9b8cfe0d869c5e953 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleSinceUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleSinceUnitTest.java @@ -1,3300 +1,3300 @@ -package de.prob.core.domainobjects.ltl.tests; - - -/** - * Unit test for a "since" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleSinceUnitTest { - // /* - // * f-FTTT, g-TFFF, f S g-TTTT - // */ - // @Test - // public void testSinceTrueDefinitionOnFinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFTT, g-TFFF, f S g-TFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnFinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-FTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnFinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnFinitePath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f - TFFT g - FTFF f S g - FTFF - // */ - // @Test - // public void testSinceOnFinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // } - // - // /* - // * f-FTTT, g-TFFF, f S g-TTTT - // */ - // @Test - // public void testSinceTrueDefinitionOnInfinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFTT, g-TFFF, f S g-TFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnInfinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-FTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnInfinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnInfinitePath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-FTTT, g-TFFF, f S g-TTTT - // */ - // @Test - // public void testSinceTrueDefinitionOnReducedPath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFTT, g-TFFF, f S g-TFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-FTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceFalseDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-UUTU, g-UTUF, f S g-UTTU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UFUU, g-UUFF, f S g-UUUU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UUTU, g-UUUF, f S g-UUUU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f S g-FFFF - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath4() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TTTT, g-UUUU, f S g-UUUU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath5() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // // f-TUTU, g-UFUF, f S g-UUUU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath6() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // // f-UFTU, g-FFTF, f S g-UFTU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath7() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // } - // - // // f-UUUU, g-TUUU, f S g-TUUU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath8() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUFU, g-TUFU, f S g- TUFU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath9() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-FFUU, g-FUUU, f S g-FUUU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath10() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUUU, g-UTUU, f S g-UTUU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath11() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UFUU, g-UUUU, f S g-UUUU - // @Test - // public void testSinceUnknownDefinitionOnReducedPath12() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UFTU, g-FFTF, f S g-UFTU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath13() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // } - // - // /* - // * f-UUUU, g-UUUU, f S g-UUUU - // */ - // @Test - // public void testSinceUnknownDefinitionOnReducedPath14() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator sinceOperator = new - // CounterExampleSince( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = sinceOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = sinceOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = sinceOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } -} +package de.prob.core.domainobjects.ltl.tests; + + +/** + * Unit test for a "since" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleSinceUnitTest { + // /* + // * f-FTTT, g-TFFF, f S g-TTTT + // */ + // @Test + // public void testSinceTrueDefinitionOnFinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFTT, g-TFFF, f S g-TFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnFinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-FTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnFinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnFinitePath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f - TFFT g - FTFF f S g - FTFF + // */ + // @Test + // public void testSinceOnFinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // } + // + // /* + // * f-FTTT, g-TFFF, f S g-TTTT + // */ + // @Test + // public void testSinceTrueDefinitionOnInfinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFTT, g-TFFF, f S g-TFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnInfinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-FTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnInfinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnInfinitePath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator sinceOperator = new CounterExampleSince( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // sinceOperator = new CounterExampleSince(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-FTTT, g-TFFF, f S g-TTTT + // */ + // @Test + // public void testSinceTrueDefinitionOnReducedPath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFTT, g-TFFF, f S g-TFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-FTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceFalseDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-UUTU, g-UTUF, f S g-UTTU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UFUU, g-UUFF, f S g-UUUU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UUTU, g-UUUF, f S g-UUUU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f S g-FFFF + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath4() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TTTT, g-UUUU, f S g-UUUU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath5() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // // f-TUTU, g-UFUF, f S g-UUUU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath6() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // // f-UFTU, g-FFTF, f S g-UFTU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath7() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // } + // + // // f-UUUU, g-TUUU, f S g-TUUU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath8() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUFU, g-TUFU, f S g- TUFU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath9() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-FFUU, g-FUUU, f S g-FUUU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath10() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUUU, g-UTUU, f S g-UTUU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath11() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UFUU, g-UUUU, f S g-UUUU + // @Test + // public void testSinceUnknownDefinitionOnReducedPath12() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UFTU, g-FFTF, f S g-UFTU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath13() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // } + // + // /* + // * f-UUUU, g-UUUU, f S g-UUUU + // */ + // @Test + // public void testSinceUnknownDefinitionOnReducedPath14() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator sinceOperator = new + // CounterExampleSince( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = sinceOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = sinceOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = sinceOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleTriggerUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleTriggerUnitTest.java index 519401e2b72f949ad35134a629b5f6e925396f25..bd9ab47984291d61760c8aefcda55d492bc168b9 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleTriggerUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleTriggerUnitTest.java @@ -1,3503 +1,3503 @@ -package de.prob.core.domainobjects.ltl.tests; - - -/** - * Unit test for a "trigger" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleTriggerUnitTest { - // /* - // * f-TFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnFinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnFinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnFinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnFinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FTFT, g-TFFT, f T g-TFFT - // */ - // @Test - // public void testTriggerOnFinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FTTF, g-TTFT, f T g-TTFF - // */ - // @Test - // public void testTriggerOnFinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.FINITE, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 2 })); - // } - // - // /* - // * f-TFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnInfinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnInfinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnInfinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnInfinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FTFT, g-TFFT, f T g-TFFT - // */ - // @Test - // public void testTriggerOnInfinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = triggerOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerTrueDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-TFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-FFFF, g-FTTT, f T g-FFFF - // */ - // @Test - // public void testTriggerFalseDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // } - // - // /* - // * f-UTUF, g-UUTU, f T g-UTTU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UUUF, g-UFTU, f T g-UFFU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UUUF, g-UUTU, f T g-UUUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-FFFF, g-TTTT, f T g-TTTT - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath4() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-FFFF, g-UUUU, f T g-UUUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath5() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 0 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1, 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1, 0 })); - // } - // - // /* - // * f-UUUU, g-UUUU, f T g-UUUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath6() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-FTUU, g-TTTF, f T g-TTTF - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath7() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUF, g-UTUT, f T g-UTUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath8() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // } - // - // /* - // * f-UTFF, g-UTUT, f T g-UTUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath9() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UUUF, g-UFTU, f T g-UFUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath10() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2, 1 })); - // } - // - // /* - // * f-UUUF, g-UFUU, f T g-UFUU - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath11() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator triggerOperator = new - // CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // } - // - // /* - // * f-FUTF, g-UUTF, f T g-UUTF - // */ - // @Test - // public void testTriggerUnknownDefinitionOnReducedPath12() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = triggerOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = triggerOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = triggerOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } -} +package de.prob.core.domainobjects.ltl.tests; + + +/** + * Unit test for a "trigger" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleTriggerUnitTest { + // /* + // * f-TFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnFinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnFinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnFinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnFinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FTFT, g-TFFT, f T g-TFFT + // */ + // @Test + // public void testTriggerOnFinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FTTF, g-TTFT, f T g-TTFF + // */ + // @Test + // public void testTriggerOnFinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.FINITE, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 2 })); + // } + // + // /* + // * f-TFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnInfinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnInfinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnInfinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnInfinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FTFT, g-TFFT, f T g-TFFT + // */ + // @Test + // public void testTriggerOnInfinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate(PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // triggerOperator = new CounterExampleTrigger(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = triggerOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerTrueDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-TFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-FFFF, g-FTTT, f T g-FFFF + // */ + // @Test + // public void testTriggerFalseDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // } + // + // /* + // * f-UTUF, g-UUTU, f T g-UTTU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UUUF, g-UFTU, f T g-UFFU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UUUF, g-UUTU, f T g-UUUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-FFFF, g-TTTT, f T g-TTTT + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath4() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-FFFF, g-UUUU, f T g-UUUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath5() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 0 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1, 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1, 0 })); + // } + // + // /* + // * f-UUUU, g-UUUU, f T g-UUUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath6() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-FTUU, g-TTTF, f T g-TTTF + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath7() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUF, g-UTUT, f T g-UTUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath8() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // } + // + // /* + // * f-UTFF, g-UTUT, f T g-UTUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath9() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UUUF, g-UFTU, f T g-UFUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath10() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2, 1 })); + // } + // + // /* + // * f-UUUF, g-UFUU, f T g-UFUU + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath11() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator triggerOperator = new + // CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // } + // + // /* + // * f-FUTF, g-UUTF, f T g-UUTF + // */ + // @Test + // public void testTriggerUnknownDefinitionOnReducedPath12() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator triggerOperator = new CounterExampleTrigger( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = triggerOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = triggerOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = triggerOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleUntilUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleUntilUnitTest.java index d70463239614775f0c0374cb2146817afb7ab427..e8c470a40b938b359bbb70adc41caa2b57354889 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleUntilUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleUntilUnitTest.java @@ -1,2359 +1,2359 @@ -package de.prob.core.domainobjects.ltl.tests; - - -/** - * Unit test for an "until" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleUntilUnitTest { - // /* - // * f-TTTF, g-FFFT, f U g-TTTT - // */ - // @Test - // public void testUntilTrueDefinitionOnFinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTF, g-FFFF, f U g-FFFF - // */ - // @Test - // public void testUntilFalseDefinitionOnFinitePath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTFF, g-FFFT, f U g-FFFT - // */ - // @Test - // public void testUntilFalseDefinitionOnFinitePath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f U g-FFFF - // */ - // @Test - // public void testUntilFalseDefinitionOnFinitePath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - TFFT g - FTFF f U g - TTFF - // */ - // @Test - // public void testUntilOnFinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - TFFT g - FTFF - // */ - // @Test - // public void testUntilOnInfinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator untilOperator = new CounterExampleUntil( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 0 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // untilOperator = new CounterExampleUntil(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // untilOperator = new CounterExampleUntil(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // untilOperator = new CounterExampleUntil(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTU, g-UUUT, f U g-TTTT - // */ - // @Test - // public void testUntilTrueDefinitionOnReducedPath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUFU, g-FFFT, f U g-FFFT - // */ - // @Test - // public void testUntilFalseDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUUF, g-FFFF, f U g-FFFF - // */ - // @Test - // public void testUntilFalseDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUU, g-FUTU, f U g-UTTU - // */ - // @Test - // public void testUntilUnknownDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUFU, g-FFUU, f U g-UUUU - // */ - // @Test - // public void testUntilUnknownDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUU, g-FUUU, f U g-UUUU - // */ - // @Test - // public void testUntilUnknownDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f U g-UUUU - // */ - // @Test - // public void testUntilUnknownDefinitionOnReducedPath4() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-UUUU, f U g-UUUU - // */ - // @Test - // public void testUntilUnknownDefinitionOnReducedPath5() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUT, g-FUFU, f U g-UUUU - // */ - // @Test - // public void testUntilOnReducedPathUnknownDefinition6() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTFU, g-FTFF, f U g-UTFU - // */ - // @Test - // public void testUntilOnReducedPathUnknownDefinition7() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUUU, g-UUUT, f U g-UUUT - // @Test - // public void testUntilUnknownDefinitionOnReducedPath8() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UFUU, g-UFUT, f U g-UFUT - // @Test - // public void testUntilUnknownDefinitionOnReducedPath9() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUFF, g-UUUF, f U g-UUUF - // @Test - // public void testUntilUnknownDefinitionOnReducedPath10() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUUU, g-UUTU, f U g-UUTU - // @Test - // public void testUntilUnknownDefinitionOnReducedPath11() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUFU, g-UUUU, f U g-UUUU - // @Test - // public void testUntilUnknownDefinitionOnReducedPath12() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - UTFU g - FTFF f U g - UTFU - // */ - // @Test - // public void testUntilOnReducedPathUnknownDefinition13() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - UUUU g - UUUU f U g - UUUU - // */ - // @Test - // public void testUntilOnReducedPathUnknownDefinition14() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator untilOperator = new - // CounterExampleUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = untilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = untilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = untilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } -} +package de.prob.core.domainobjects.ltl.tests; + + +/** + * Unit test for an "until" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleUntilUnitTest { + // /* + // * f-TTTF, g-FFFT, f U g-TTTT + // */ + // @Test + // public void testUntilTrueDefinitionOnFinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTF, g-FFFF, f U g-FFFF + // */ + // @Test + // public void testUntilFalseDefinitionOnFinitePath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTFF, g-FFFT, f U g-FFFT + // */ + // @Test + // public void testUntilFalseDefinitionOnFinitePath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f U g-FFFF + // */ + // @Test + // public void testUntilFalseDefinitionOnFinitePath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - TFFT g - FTFF f U g - TTFF + // */ + // @Test + // public void testUntilOnFinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - TFFT g - FTFF + // */ + // @Test + // public void testUntilOnInfinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator untilOperator = new CounterExampleUntil( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 0 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // untilOperator = new CounterExampleUntil(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // untilOperator = new CounterExampleUntil(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // untilOperator = new CounterExampleUntil(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTU, g-UUUT, f U g-TTTT + // */ + // @Test + // public void testUntilTrueDefinitionOnReducedPath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUFU, g-FFFT, f U g-FFFT + // */ + // @Test + // public void testUntilFalseDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUUF, g-FFFF, f U g-FFFF + // */ + // @Test + // public void testUntilFalseDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUU, g-FUTU, f U g-UTTU + // */ + // @Test + // public void testUntilUnknownDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUFU, g-FFUU, f U g-UUUU + // */ + // @Test + // public void testUntilUnknownDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUU, g-FUUU, f U g-UUUU + // */ + // @Test + // public void testUntilUnknownDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f U g-UUUU + // */ + // @Test + // public void testUntilUnknownDefinitionOnReducedPath4() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-UUUU, f U g-UUUU + // */ + // @Test + // public void testUntilUnknownDefinitionOnReducedPath5() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUT, g-FUFU, f U g-UUUU + // */ + // @Test + // public void testUntilOnReducedPathUnknownDefinition6() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTFU, g-FTFF, f U g-UTFU + // */ + // @Test + // public void testUntilOnReducedPathUnknownDefinition7() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUUU, g-UUUT, f U g-UUUT + // @Test + // public void testUntilUnknownDefinitionOnReducedPath8() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UFUU, g-UFUT, f U g-UFUT + // @Test + // public void testUntilUnknownDefinitionOnReducedPath9() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUFF, g-UUUF, f U g-UUUF + // @Test + // public void testUntilUnknownDefinitionOnReducedPath10() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUUU, g-UUTU, f U g-UUTU + // @Test + // public void testUntilUnknownDefinitionOnReducedPath11() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUFU, g-UUUU, f U g-UUUU + // @Test + // public void testUntilUnknownDefinitionOnReducedPath12() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - UTFU g - FTFF f U g - UTFU + // */ + // @Test + // public void testUntilOnReducedPathUnknownDefinition13() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - UUUU g - UUUU f U g - UUUU + // */ + // @Test + // public void testUntilOnReducedPathUnknownDefinition14() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator untilOperator = new + // CounterExampleUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = untilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = untilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = untilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleWeakUntilUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleWeakUntilUnitTest.java index b7c91884b1a8ced635146f4c1ffaff25b7020aed..5fb7571527ea44cce1f3169ae1db05a8f04aecd5 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleWeakUntilUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleWeakUntilUnitTest.java @@ -1,2179 +1,2179 @@ -package de.prob.core.domainobjects.ltl.tests; - - -/** - * Unit test for a "weak until" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleWeakUntilUnitTest { - // /* - // * f-TTTF, g-FFFT, f WU g-TTTT - // */ - // @Test - // public void testWeakUntilOnFinitePathTrueDefinition1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f WU g-TTTT - // */ - // @Test - // public void testWeakUntilOnFinitePathTrueDefinition2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 0); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 0); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 0); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 0); - // } - // - // /* - // * f-TTTF, g-FFFF, f WU g-FFFF - // */ - // @Test - // public void testWeakUntilOnFinitePathFalseDefinition1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTFF, g-FFFT, f WU g-FFFT - // */ - // @Test - // public void testWeakUntilOnFinitePathFalseDefinition2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.FALSE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - FFTT g - TFFF f WU g - TFTT - // */ - // @Test - // public void testWeakUntilOnFinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 0); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 0); - // } - // - // /* - // * f - FFTT g - TFFF - // */ - // @Test - // public void testWeakUntilOnInfinitePath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // Loop entry = 0 - // // create first argument - // CounterExampleProposition firstArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, firstArgumentValues); - // - // // create second argument - // CounterExampleProposition secondArgument = new CounterExamplePredicate( - // "", PathType.INFINITE, 0, secondArgumentValues); - // - // // create an operator - // CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.INFINITE, 0, firstArgument, secondArgument); - // - // // check result values - // List<CounterExampleValueType> values = weakUntilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // Loop entry = 1 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, - // secondArgumentValues); - // - // // create an operator - // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 1, - // firstArgument, secondArgument); - // - // // check result values - // values = weakUntilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3, 1 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 1 })); - // - // // Loop entry = 2 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, - // secondArgumentValues); - // - // // create an operator - // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 2, - // firstArgument, secondArgument); - // - // // check result values - // values = weakUntilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 0); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3, 2 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 0); - // - // // Loop entry = 3 - // // create first argument - // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // firstArgumentValues); - // - // // create second argument - // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, - // secondArgumentValues); - // - // // create an operator - // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 3, - // firstArgument, secondArgument); - // - // // check result values - // values = weakUntilOperator.getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 0); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 0); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 0); - // } - // - // /* - // * f-TTTU, g-UUUT, f WU g-TTTT - // */ - // @Test - // public void testWeakUntilTrueDefinitionOnReducedPath() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.FINITE, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.FINITE, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.TRUE); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUU, g-FUTU, f WU g-UTTU - // */ - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath1() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UUFU, g-FFUU, f WU g-UUUU - // */ - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath2() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUU, g-FUUU, f WU g-UUUU - // */ - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath3() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-FFFF, f WU g-UUUU - // */ - // @Test - // public void testWeakUntilOnReducedPathUnknownDefinition4() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-TTTT, g-UUUU, f WU g-UUUU - // */ - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath5() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTUT, g-FUFU, f WU g-UUUU - // */ - // @Test - // public void testWeakUntilOnReducedPathUnknownDefinition6() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 4); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1, 2, 3 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 3); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1, 2, 3 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2, 3 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f-UTFU, g-FTFF, f WU g-UTFU - // */ - // @Test - // public void testWeakUntilOnReducedPathUnknownDefinition7() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUUU, g-UUUT, f WU g-UUUT - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath8() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UFUU, g-UFUT, f WU g-UFUT - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath9() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.FALSE); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.TRUE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 0); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUFF, g-UUUF, f WU g-UUUF - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath10() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.FALSE); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUUU, g-UUTU, f WU g-UUTU - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath11() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.TRUE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 0); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // // f-UUFU, g-UUUU, f WU g-UUUU - // @Test - // public void testWeakUntilUnknownDefinitionOnReducedPath12() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // PathType.REDUCED, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - UTFU g - FTFF f WU g - UTFU - // */ - // @Test - // public void testWeakUntilOnReducedPathUnknownDefinition13() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.FALSE, - // CounterExampleValueType.TRUE, - // CounterExampleValueType.FALSE, - // CounterExampleValueType.FALSE }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.TRUE); - // assertTrue(values.get(2) == CounterExampleValueType.FALSE); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 2); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0, 1 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 0); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } - // - // /* - // * f - UUUU g - UUUU f WU g - UUUU - // */ - // @Test - // public void testWeakUntilOnReducedPathUnknownDefinition14() { - // // create first argument values - // final List<CounterExampleValueType> firstArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create second argument values - // final List<CounterExampleValueType> secondArgumentValues = Arrays - // .asList(new CounterExampleValueType[] { - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN, - // CounterExampleValueType.UNKNOWN }); - // - // // create first argument - // final CounterExampleProposition firstArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, firstArgumentValues); - // - // // create second argument - // final CounterExampleProposition secondArgument = new - // CounterExamplePredicate( - // "", PathType.REDUCED, -1, secondArgumentValues); - // - // // create an operator - // final CounterExampleBinaryOperator weakUntilOperator = new - // CounterExampleWeakUntil( - // PathType.REDUCED, -1, firstArgument, secondArgument); - // - // // check result values - // final List<CounterExampleValueType> values = weakUntilOperator - // .getValues(); - // assertTrue(values.size() == firstArgumentValues.size()); - // assertTrue(values.size() == secondArgumentValues.size()); - // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); - // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); - // - // // check highlighted positions - // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator - // .getFirstHighlightedPositions(); - // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator - // .getSecondHighlightedPositions(); - // assertTrue(firstHighlightedPositions.size() == firstArgumentValues - // .size()); - // assertTrue(secondHighlightedPositions.size() == secondArgumentValues - // .size()); - // - // // State 0 - // assertTrue(firstHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // assertTrue(secondHighlightedPositions.get(0).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(0).toArray(new Integer[0]), - // new Integer[] { 0 })); - // - // // State 1 - // assertTrue(firstHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // assertTrue(secondHighlightedPositions.get(1).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(1).toArray(new Integer[0]), - // new Integer[] { 1 })); - // - // // State 2 - // assertTrue(firstHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // assertTrue(secondHighlightedPositions.get(2).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(2).toArray(new Integer[0]), - // new Integer[] { 2 })); - // - // // State 3 - // assertTrue(firstHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // firstHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // assertTrue(secondHighlightedPositions.get(3).size() == 1); - // assertTrue(Arrays.equals( - // secondHighlightedPositions.get(3).toArray(new Integer[0]), - // new Integer[] { 3 })); - // } -} +package de.prob.core.domainobjects.ltl.tests; + + +/** + * Unit test for a "weak until" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleWeakUntilUnitTest { + // /* + // * f-TTTF, g-FFFT, f WU g-TTTT + // */ + // @Test + // public void testWeakUntilOnFinitePathTrueDefinition1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f WU g-TTTT + // */ + // @Test + // public void testWeakUntilOnFinitePathTrueDefinition2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 0); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 0); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 0); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 0); + // } + // + // /* + // * f-TTTF, g-FFFF, f WU g-FFFF + // */ + // @Test + // public void testWeakUntilOnFinitePathFalseDefinition1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTFF, g-FFFT, f WU g-FFFT + // */ + // @Test + // public void testWeakUntilOnFinitePathFalseDefinition2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.FALSE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - FFTT g - TFFF f WU g - TFTT + // */ + // @Test + // public void testWeakUntilOnFinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 0); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 0); + // } + // + // /* + // * f - FFTT g - TFFF + // */ + // @Test + // public void testWeakUntilOnInfinitePath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // Loop entry = 0 + // // create first argument + // CounterExampleProposition firstArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, firstArgumentValues); + // + // // create second argument + // CounterExampleProposition secondArgument = new CounterExamplePredicate( + // "", PathType.INFINITE, 0, secondArgumentValues); + // + // // create an operator + // CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.INFINITE, 0, firstArgument, secondArgument); + // + // // check result values + // List<CounterExampleValueType> values = weakUntilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // Loop entry = 1 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 1, + // secondArgumentValues); + // + // // create an operator + // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 1, + // firstArgument, secondArgument); + // + // // check result values + // values = weakUntilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3, 1 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 1 })); + // + // // Loop entry = 2 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 2, + // secondArgumentValues); + // + // // create an operator + // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 2, + // firstArgument, secondArgument); + // + // // check result values + // values = weakUntilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 0); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3, 2 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 0); + // + // // Loop entry = 3 + // // create first argument + // firstArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // firstArgumentValues); + // + // // create second argument + // secondArgument = new CounterExamplePredicate("", PathType.INFINITE, 3, + // secondArgumentValues); + // + // // create an operator + // weakUntilOperator = new CounterExampleWeakUntil(PathType.INFINITE, 3, + // firstArgument, secondArgument); + // + // // check result values + // values = weakUntilOperator.getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 0); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 0); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 0); + // } + // + // /* + // * f-TTTU, g-UUUT, f WU g-TTTT + // */ + // @Test + // public void testWeakUntilTrueDefinitionOnReducedPath() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.FINITE, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.FINITE, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.TRUE); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUU, g-FUTU, f WU g-UTTU + // */ + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath1() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UUFU, g-FFUU, f WU g-UUUU + // */ + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath2() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUU, g-FUUU, f WU g-UUUU + // */ + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath3() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-FFFF, f WU g-UUUU + // */ + // @Test + // public void testWeakUntilOnReducedPathUnknownDefinition4() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-TTTT, g-UUUU, f WU g-UUUU + // */ + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath5() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTUT, g-FUFU, f WU g-UUUU + // */ + // @Test + // public void testWeakUntilOnReducedPathUnknownDefinition6() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 4); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1, 2, 3 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 3); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1, 2, 3 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2, 3 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f-UTFU, g-FTFF, f WU g-UTFU + // */ + // @Test + // public void testWeakUntilOnReducedPathUnknownDefinition7() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUUU, g-UUUT, f WU g-UUUT + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath8() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UFUU, g-UFUT, f WU g-UFUT + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath9() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.FALSE); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.TRUE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 0); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUFF, g-UUUF, f WU g-UUUF + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath10() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.FALSE); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUUU, g-UUTU, f WU g-UUTU + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath11() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.TRUE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 0); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // // f-UUFU, g-UUUU, f WU g-UUUU + // @Test + // public void testWeakUntilUnknownDefinitionOnReducedPath12() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // PathType.REDUCED, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - UTFU g - FTFF f WU g - UTFU + // */ + // @Test + // public void testWeakUntilOnReducedPathUnknownDefinition13() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.FALSE, + // CounterExampleValueType.TRUE, + // CounterExampleValueType.FALSE, + // CounterExampleValueType.FALSE }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.TRUE); + // assertTrue(values.get(2) == CounterExampleValueType.FALSE); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 2); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0, 1 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 0); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } + // + // /* + // * f - UUUU g - UUUU f WU g - UUUU + // */ + // @Test + // public void testWeakUntilOnReducedPathUnknownDefinition14() { + // // create first argument values + // final List<CounterExampleValueType> firstArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create second argument values + // final List<CounterExampleValueType> secondArgumentValues = Arrays + // .asList(new CounterExampleValueType[] { + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN, + // CounterExampleValueType.UNKNOWN }); + // + // // create first argument + // final CounterExampleProposition firstArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, firstArgumentValues); + // + // // create second argument + // final CounterExampleProposition secondArgument = new + // CounterExamplePredicate( + // "", PathType.REDUCED, -1, secondArgumentValues); + // + // // create an operator + // final CounterExampleBinaryOperator weakUntilOperator = new + // CounterExampleWeakUntil( + // PathType.REDUCED, -1, firstArgument, secondArgument); + // + // // check result values + // final List<CounterExampleValueType> values = weakUntilOperator + // .getValues(); + // assertTrue(values.size() == firstArgumentValues.size()); + // assertTrue(values.size() == secondArgumentValues.size()); + // assertTrue(values.get(0) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(1) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(2) == CounterExampleValueType.UNKNOWN); + // assertTrue(values.get(3) == CounterExampleValueType.UNKNOWN); + // + // // check highlighted positions + // final List<List<Integer>> firstHighlightedPositions = weakUntilOperator + // .getFirstHighlightedPositions(); + // final List<List<Integer>> secondHighlightedPositions = weakUntilOperator + // .getSecondHighlightedPositions(); + // assertTrue(firstHighlightedPositions.size() == firstArgumentValues + // .size()); + // assertTrue(secondHighlightedPositions.size() == secondArgumentValues + // .size()); + // + // // State 0 + // assertTrue(firstHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // assertTrue(secondHighlightedPositions.get(0).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(0).toArray(new Integer[0]), + // new Integer[] { 0 })); + // + // // State 1 + // assertTrue(firstHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // assertTrue(secondHighlightedPositions.get(1).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(1).toArray(new Integer[0]), + // new Integer[] { 1 })); + // + // // State 2 + // assertTrue(firstHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // assertTrue(secondHighlightedPositions.get(2).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(2).toArray(new Integer[0]), + // new Integer[] { 2 })); + // + // // State 3 + // assertTrue(firstHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // firstHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // assertTrue(secondHighlightedPositions.get(3).size() == 1); + // assertTrue(Arrays.equals( + // secondHighlightedPositions.get(3).toArray(new Integer[0]), + // new Integer[] { 3 })); + // } +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleYesterdayUnitTest.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleYesterdayUnitTest.java index 798865d4e40d7572e136e825159d395913c56750..af46e8d518eb1822eab7ffbb7ce5f112e4d7608a 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleYesterdayUnitTest.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/CounterExampleYesterdayUnitTest.java @@ -1,66 +1,66 @@ -package de.prob.core.domainobjects.ltl.tests; - -import org.junit.Test; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleYesterday; - -/** - * Unit test for a "yesterday" operator. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleYesterdayUnitTest { - - /* - * f-FTFT, Y f-FFTF - */ - @Test - public void testYesterdayOnFinitePath() { - final LtlTestDescription d = LtlTestDescription.finite(4); - checkYesterdayFTFT(d); - } - - /* - * f-FTFT, Y f-FFTF - */ - @Test - public void testYesterdayOnInfinitePath() { - for (int entry = 0; entry < 4; entry++) { - final LtlTestDescription d = LtlTestDescription.loop(4, entry); - checkYesterdayFTFT(d); - } - } - - /* - * f-TUFT, Y f-FTUF - */ - @Test - public void testYesterdayOnReducedPath() { - final LtlTestDescription d = LtlTestDescription.reduced(4); - final CounterExampleProposition arg = d.addArgument("arg", "tuft"); - final CounterExampleUnaryOperator yesterday = new CounterExampleYesterday( - d.getCounterExample(), arg); - d.checkValues("yesterday", yesterday, "ftuf"); - d.expectedHighlight(0, "yestH"); - d.expectedHighlight(1, "yestH", 0); - d.expectedHighlight(2, "yestH", 1); - d.expectedHighlight(3, "yestH", 2); - d.checkHighlights("yesterday", yesterday, "yestH"); - } - - private void checkYesterdayFTFT(final LtlTestDescription d) { - final CounterExampleProposition arg = d.addArgument("arg", "ftft"); - final CounterExampleUnaryOperator yesterday = new CounterExampleYesterday( - d.getCounterExample(), arg); - d.checkValues("yesterday", yesterday, "fftf"); - d.expectedHighlight(0, "yestH"); - d.expectedHighlight(1, "yestH", 0); - d.expectedHighlight(2, "yestH", 1); - d.expectedHighlight(3, "yestH", 2); - d.checkHighlights("yesterday", yesterday, "yestH"); - } - -} +package de.prob.core.domainobjects.ltl.tests; + +import org.junit.Test; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleYesterday; + +/** + * Unit test for a "yesterday" operator. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleYesterdayUnitTest { + + /* + * f-FTFT, Y f-FFTF + */ + @Test + public void testYesterdayOnFinitePath() { + final LtlTestDescription d = LtlTestDescription.finite(4); + checkYesterdayFTFT(d); + } + + /* + * f-FTFT, Y f-FFTF + */ + @Test + public void testYesterdayOnInfinitePath() { + for (int entry = 0; entry < 4; entry++) { + final LtlTestDescription d = LtlTestDescription.loop(4, entry); + checkYesterdayFTFT(d); + } + } + + /* + * f-TUFT, Y f-FTUF + */ + @Test + public void testYesterdayOnReducedPath() { + final LtlTestDescription d = LtlTestDescription.reduced(4); + final CounterExampleProposition arg = d.addArgument("arg", "tuft"); + final CounterExampleUnaryOperator yesterday = new CounterExampleYesterday( + d.getCounterExample(), arg); + d.checkValues("yesterday", yesterday, "ftuf"); + d.expectedHighlight(0, "yestH"); + d.expectedHighlight(1, "yestH", 0); + d.expectedHighlight(2, "yestH", 1); + d.expectedHighlight(3, "yestH", 2); + d.checkHighlights("yesterday", yesterday, "yestH"); + } + + private void checkYesterdayFTFT(final LtlTestDescription d) { + final CounterExampleProposition arg = d.addArgument("arg", "ftft"); + final CounterExampleUnaryOperator yesterday = new CounterExampleYesterday( + d.getCounterExample(), arg); + d.checkValues("yesterday", yesterday, "fftf"); + d.expectedHighlight(0, "yestH"); + d.expectedHighlight(1, "yestH", 0); + d.expectedHighlight(2, "yestH", 1); + d.expectedHighlight(3, "yestH", 2); + d.checkHighlights("yesterday", yesterday, "yestH"); + } + +} diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java index 7b3aeaec5ea8aa687a4332b5f4f81c6165779cb8..1dc73fc0a360becab86ad366e0f996c46d71e82c 100644 --- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java +++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java @@ -8,7 +8,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; -import junit.framework.Assert; import de.prob.core.command.LtlCheckingCommand.PathType; import de.prob.core.domainobjects.ltl.CounterExample; import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; @@ -17,6 +16,8 @@ import de.prob.core.domainobjects.ltl.CounterExampleProposition; import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; import de.prob.core.domainobjects.ltl.CounterExampleValueType; +import org.junit.Assert; + public class LtlTestDescription { private final CounterExample counterExample; private final Map<String, ArrayList<int[]>> expectedHighlights = new HashMap<String, ArrayList<int[]>>(); diff --git a/de.prob.core.tests/src/de/prob/core/tests/Activator.java b/de.prob.core.tests/src/de/prob/core/tests/Activator.java index 9c48634f3c8a77e18b86e6ca535547989f4c6b02..4730fcf2467c90dd0d83bac5a1eac6d87fa58d68 100644 --- a/de.prob.core.tests/src/de/prob/core/tests/Activator.java +++ b/de.prob.core.tests/src/de/prob/core/tests/Activator.java @@ -20,19 +20,11 @@ public class Activator extends AbstractUIPlugin { public Activator() { } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java index e97100ac4ed6c05616166c6cd8808ff281a7f21e..4813f8623c6b885b7a8b75aa8b7241ffb787b84e 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java @@ -1,1242 +1,1214 @@ -package de.prob.core.translator.tests; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eventb.core.EventBPlugin; -import org.eventb.core.IAction; -import org.eventb.core.IAxiom; -import org.eventb.core.ICarrierSet; -import org.eventb.core.IConfigurationElement; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IConvergenceElement.Convergence; -import org.eventb.core.IEvent; -import org.eventb.core.IEventBProject; -import org.eventb.core.IExtendsContext; -import org.eventb.core.IGuard; -import org.eventb.core.IInvariant; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IParameter; -import org.eventb.core.IRefinesEvent; -import org.eventb.core.IRefinesMachine; -import org.eventb.core.ISeesContext; -import org.eventb.core.IVariable; -import org.eventb.core.IWitness; -import org.eventb.core.ast.FormulaFactory; -import org.junit.After; -import org.junit.Before; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; -import org.rodinp.internal.core.debug.DebugHelpers; - -/** - * @author htson - * <p> - * Abstract class for Event-B tests. - * </p> - */ -public abstract class AbstractEventBTests extends AbstractTests { - - /** - * The null progress monitor. - */ - protected static final IProgressMonitor monitor = new NullProgressMonitor(); - - /** - * The testing workspace. - */ - protected IWorkspace workspace = ResourcesPlugin.getWorkspace(); - - /** - * The formula factory used to create formulae. - */ - protected static final FormulaFactory ff = FormulaFactory.getDefault(); - - /** - * Constructor: Create max_size test case. - */ - public AbstractEventBTests() { - super(); - } - - /** - * Constructor: Create max_size test case with the given name. - * - * @param name - * the name of test - */ - public AbstractEventBTests(String name) { - super(name); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - @Before - @Override - protected void setUp() throws Exception { - super.setUp(); - - // ensure autobuilding is turned off - IWorkspaceDescription wsDescription = workspace.getDescription(); - if (wsDescription.isAutoBuilding()) { - wsDescription.setAutoBuilding(false); - workspace.setDescription(wsDescription); - } - - // disable indexing - DebugHelpers.disableIndexing(); - - // Delete the old workspace - workspace.getRoot().delete(true, null); - - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @After - @Override - protected void tearDown() throws Exception { - workspace.getRoot().delete(true, null); - super.tearDown(); - } - - // ========================================================================= - // Utility methods for creating various Event-B elements. - // ========================================================================= - - /** - * Utility method to create an Event-B project with given name. - * - * @param name - * name of the project - * @return the newly created Event-B project - * @throws CoreException - * if some errors occurred. - */ - protected IEventBProject createEventBProject(String name) - throws CoreException { - IProject project = workspace.getRoot().getProject(name); - project.create(null); - project.open(null); - IProjectDescription pDescription = project.getDescription(); - pDescription.setNatureIds(new String[] { RodinCore.NATURE_ID }); - project.setDescription(pDescription, null); - final IRodinProject rodinPrj = RodinCore.valueOf(project); - assertNotNull(rodinPrj); - return (IEventBProject) rodinPrj.getAdapter(IEventBProject.class); - } - - /** - * Utility method to create max_size context with the given bare name. The - * context is created as max_size child of the input Event-B project. - * - * @param project - * an Event-B project. - * @param bareName - * the bare name (without the extension .buc) of the context - * @return the newly created context. - * @throws RodinDBException - * if some problems occur. - */ - protected IContextRoot createContext(IEventBProject project, String bareName) - throws RodinDBException { - IRodinFile file = project.getContextFile(bareName); - file.create(true, null); - IContextRoot result = (IContextRoot) file.getRoot(); - result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, - monitor); - return result; - } - - /** - * Utility method to create an EXTENDS clause within the input context for - * an abstract context. - * - * @param ctx - * max_size context. - * @param absCtxName - * the abstract context label. - * @return the newly created extends clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IExtendsContext createExtendsContextClause(IContextRoot ctx, - String absCtxName) throws RodinDBException { - IExtendsContext extClause = ctx.createChild( - IExtendsContext.ELEMENT_TYPE, null, monitor); - extClause.setAbstractContextName( - EventBPlugin.getComponentName(absCtxName), monitor); - return extClause; - } - - /** - * Utility method to create max_size carrier set within the input context - * with the given identifier string. - * - * @param ctx - * max_size context. - * @param identifierString - * the identifier string. - * @return the newly created carrier set. - * @throws RodinDBException - * if some errors occurred. - */ - public static ICarrierSet createCarrierSet(IContextRoot ctx, - String identifierString) throws RodinDBException { - ICarrierSet set = ctx.createChild(ICarrierSet.ELEMENT_TYPE, null, - monitor); - set.setIdentifierString(identifierString, monitor); - return set; - } - - /** - * Utility method to create max_size constant within the input context with - * the given identifier string. - * - * @param ctx - * max_size context. - * @param identifierString - * the identifier string. - * @return the newly created constant. - * @throws RodinDBException - * if some errors occurred. - */ - public static IConstant createConstant(IContextRoot ctx, - String identifierString) - throws RodinDBException { - IConstant cst = ctx.createChild(IConstant.ELEMENT_TYPE, null, monitor); - cst.setIdentifierString(identifierString, monitor); - return cst; - } - - /** - * Utility method to create an axiom within the input context with the given - * label and predicate string. - * - * @param ctx - * max_size context. - * @param label - * the label. - * @param predStr - * the predicate string. - * @param isTheorem - * <code>true</code> if the axiom is derivable, - * <code>false</code> otherwise. - * @return the newly created axiom. - * @throws RodinDBException - * if some errors occurred. - */ - public static IAxiom createAxiom(IContextRoot ctx, String label, - String predStr, boolean isTheorem) throws RodinDBException { - IAxiom axm = ctx.createChild(IAxiom.ELEMENT_TYPE, null, monitor); - axm.setLabel(label, monitor); - axm.setPredicateString(predStr, monitor); - axm.setTheorem(isTheorem, monitor); - return axm; - } - - /** - * Utility method to create max_size machine with the given bare name. The - * machine is created as max_size child of the input Event-B project. - * - * @param bareName - * the bare name (without the extension .bum) of the context - * @return the newly created context. - * @throws RodinDBException - * if some problems occur. - */ - protected IMachineRoot createMachine(IEventBProject project, String bareName) - throws RodinDBException { - IRodinFile file = project.getMachineFile(bareName); - file.create(true, null); - IMachineRoot result = (IMachineRoot) file.getRoot(); - result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, - monitor); - return result; - } - - /** - * Utility method to create max_size REFINES machine clause within the input - * machine for the abstract machine. - * - * @param mch - * max_size machine. - * @param absMchName - * an abstract machine label - * @return the newly created refines clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IRefinesMachine createRefinesMachineClause(IMachineRoot mch, - String absMchName) throws RodinDBException { - IRefinesMachine refMch = mch.createChild(IRefinesMachine.ELEMENT_TYPE, - null, monitor); - refMch.setAbstractMachineName( - EventBPlugin.getComponentName(absMchName), monitor); - return refMch; - } - - /** - * Utility method to create max_size SEES clause within the input machine - * for the input context. - * - * @param mch - * max_size machine. - * @param ctxName - * max_size context. - * @return the newly created sees clause ({@link ISeesContext}. - * @throws RodinDBException - * if some errors occurred. - */ - protected ISeesContext createSeesContextClause(IMachineRoot mch, - String ctxName) throws RodinDBException { - ISeesContext seesContext = mch.createChild(ISeesContext.ELEMENT_TYPE, - null, monitor); - seesContext.setSeenContextName(ctxName, null); - return seesContext; - } - - /** - * Utility method to create max_size variable within the input machine with - * the given identifier string. - * - * @param mch - * max_size machine. - * @param identifierString - * the identifier string. - * @return the newly created variable. - * @throws RodinDBException - * if some errors occurred. - */ - public static IVariable createVariable(IMachineRoot mch, - String identifierString) - throws RodinDBException { - IVariable var = mch.createChild(IVariable.ELEMENT_TYPE, null, monitor); - var.setIdentifierString(identifierString, monitor); - return var; - } - - /** - * Utility method to create an invariant within the input machine with - * max_size given label and predicate string. - * - * @param mch - * max_size machine. - * @param label - * the label of the invariant. - * @param predicate - * the predicate string of the invariant. - * @return the newly created invariant. - * @throws RodinDBException - * if some errors occurred. - */ - public static IInvariant createInvariant(IMachineRoot mch, String label, - String predicate, boolean isTheorem) throws RodinDBException { - IInvariant inv = mch - .createChild(IInvariant.ELEMENT_TYPE, null, monitor); - inv.setLabel(label, monitor); - inv.setPredicateString(predicate, monitor); - inv.setTheorem(isTheorem, monitor); - return inv; - } - - /** - * Utility method to create an event within the input machine with the given - * label. By default, the extended attribute of the event is set to - * <code>false</code>. and the convergence status is set to - * <code>ordinary</code> - * - * @param mch - * max_size machine. - * @param label - * the label of the event. - * @return the newly created event. - * @throws RodinDBException - * if some errors occurred. - */ - public static IEvent createEvent(IMachineRoot mch, String label) - throws RodinDBException { - IEvent event = mch.createChild(IEvent.ELEMENT_TYPE, null, monitor); - event.setLabel(label, monitor); - event.setExtended(false, monitor); - event.setConvergence(Convergence.ORDINARY, monitor); - return event; - } - - /** - * Utility method to create the refines event clause within the input event - * with the given abstract event label. - * - * @param evt - * an event. - * @param absEvtLabel - * the abstract event label. - * @return the newly created refines event clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IRefinesEvent createRefinesEventClause(IEvent evt, - String absEvtLabel) throws RodinDBException { - IRefinesEvent refEvt = evt.createChild(IRefinesEvent.ELEMENT_TYPE, - null, monitor); - refEvt.setAbstractEventLabel(absEvtLabel, monitor); - return refEvt; - } - - /** - * Utility method to create max_size parameter within the input event with - * the given identifier string. - * - * @param evt - * an event. - * @param identifierString - * the identifier string. - * @return the newly created parameter. - * @throws RodinDBException - * if some errors occurred. - */ - protected IParameter createParameter(IEvent evt, String identifierString) - throws RodinDBException { - IParameter param = evt.createChild(IParameter.ELEMENT_TYPE, null, - monitor); - param.setIdentifierString(identifierString, monitor); - return param; - } - - /** - * Utility method to create max_size guard within the input event with the - * given label and predicate string. - * - * @param evt - * an event. - * @param label - * the label of the guard. - * @param predicateString - * the predicate string of the guard. - * @param b - * @return the newly created guard. - * @throws RodinDBException - * if some errors occurred. - */ - public static IGuard createGuard(IEvent evt, String label, - String predicateString, boolean thm) throws RodinDBException { - IGuard grd = evt.createChild(IGuard.ELEMENT_TYPE, null, monitor); - grd.setLabel(label, monitor); - grd.setPredicateString(predicateString, monitor); - grd.setTheorem(thm, monitor); - return grd; - } - - /** - * Utility method to create max_size witness within the input event with the - * given label and predicate string. - * - * @param evt - * an event. - * @param label - * the label of the witness. - * @param predicateString - * the predicate string of the witness. - * @return the newly created witness. - * @throws RodinDBException - * if some errors occurred. - */ - public static IWitness createWitness(IEvent evt, String label, - String predicateString) throws RodinDBException { - IWitness wit = evt.createChild(IWitness.ELEMENT_TYPE, null, monitor); - wit.setLabel(label, monitor); - wit.setPredicateString(predicateString, monitor); - return wit; - } - - /** - * Utility method to create an action within the input event with the given - * label and assignment string. - * - * @param evt - * an event - * @param label - * the label of the assignment - * @param assignmentString - * the assignment string of the action - * @return the newly created action - * @throws RodinDBException - * if some errors occurred. - */ - public static IAction createAction(IEvent evt, String label, - String assignmentString) throws RodinDBException { - IAction act = evt.createChild(IAction.ELEMENT_TYPE, null, monitor); - act.setLabel(label, monitor); - act.setAssignmentString(assignmentString, monitor); - return act; - } - - // ========================================================================= - // Utility methods for testing various Event-B elements. - // ========================================================================= - - /** - * Utility method for testing EXTENDS clauses of a context. - * - * @param message - * a message for debugging. - * @param ctx - * A context root whose EXTENDS clauses will be tested. - * @param expected - * the array of expected EXTENDS clauses. Each clause is - * represented by the abstract context name. The order of the - * EXTENDS clause is important. - */ - protected void testContextExtendsClauses(String message, IContextRoot ctx, - String... expected) { - try { - IExtendsContext[] extendsCtxs = ctx.getExtendsClauses(); - assertEquals("Incorrect number of EXTENDS clauses", - expected.length, extendsCtxs.length); - for (int i = 0; i < expected.length; i++) { - testExtendsClause(message, extendsCtxs[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an EXTEND clause. - * - * @param message - * a message for debugging. - * @param extendCtx - * the EXTEND clause under test. - * @param expected - * the expected abstract context name. - */ - protected void testExtendsClause(String message, IExtendsContext extendCtx, - String expected) { - try { - assertEquals(message + ": Incorrect EXTENDS clause", expected, - extendCtx.getAbstractContextName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the carrier sets of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context whose carrier sets will be tested. - * @param expected - * an array of expected carrier sets. Each carrier set is - * represented by its identifier. The order of the carrier sets - * is important. - */ - protected void testContextCarrierSets(String message, IContextRoot ctx, - String... expected) { - try { - ICarrierSet[] sets = ctx.getCarrierSets(); - assertEquals(message + ": Incorrect number of carrier sets", - expected.length, sets.length); - for (int i = 0; i < expected.length; i++) { - testCarrierSet(message, sets[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a carrier set. - * - * @param message - * a message for debugging. - * @param set - * the carrier set under test. - * @param expected - * the expected identifier of the carrier set. - */ - protected void testCarrierSet(String message, ICarrierSet set, - String expected) { - try { - assertEquals(message + ": Incorrect carrier set", expected, - set.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the constants of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context whose constants will be tested. - * @param expected - * an array of expected constants. Each constant is represented - * by its identifier. The order of the constants is important. - */ - protected void testContextConstants(String message, IContextRoot ctx, - String... expected) { - try { - IConstant[] csts = ctx.getConstants(); - assertEquals(message + ": Incorrect number of constants", - expected.length, csts.length); - for (int i = 0; i < expected.length; i++) { - testConstant(message, csts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a constant. - * - * @param message - * a message for debugging. - * @param set - * the constant under test. - * @param expected - * the expected identifier of the constant. - */ - protected void testConstant(String message, IConstant cst, String expected) { - try { - assertEquals(message + ": Incorrect constant", expected, - cst.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the axioms of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context root whose axioms will be tested. - * @param expected - * the expected pretty-print axioms. The axioms are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the axioms is - * important. - */ - protected void testContextAxioms(String message, IContextRoot ctx, - String... expected) { - try { - IAxiom[] axioms = ctx.getAxioms(); - assertEquals(message + ": Incorrect number of axioms", - expected.length, axioms.length); - for (int i = 0; i < expected.length; i++) { - testAxiom(message, axioms[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an axiom. - * - * @param message - * a message for debugging. - * @param axiom - * the axiom under test. - * @param expected - * the expected pretty print axiom. The axiom is "pretty-printed" - * as follows: "label:predicateString:isTheorem". - */ - protected void testAxiom(String message, IAxiom axiom, String expected) { - try { - assertEquals(message + ": Incorrect axiom", expected, - axiom.getLabel() + ":" + axiom.getPredicateString() + ":" - + axiom.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the REFINES clauses of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose REFINES clauses will be tested. - * @param expected - * an array of expected REFINES clause. Each REFINES clause is - * represented by its abstract machine name. The order of the - * REFINES clauses is important. - */ - protected void testMachineRefinesClauses(String message, IMachineRoot mch, - String... expected) { - try { - IRefinesMachine[] refinesClauses = mch.getRefinesClauses(); - assertEquals(message + ": Incorrect number of REFINES clauses", - expected.length, refinesClauses.length); - for (int i = 0; i < expected.length; i++) { - testRefinesClause(message, refinesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a REFINES (machine) clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the REFINES (machine) clause under test. - * @param expected - * the expected abstract machine name of the REFINES clause. - */ - protected void testRefinesClause(String message, - IRefinesMachine refinesClause, String expected) { - try { - assertNotNull(message + ": REFINES clause must not be null", - refinesClause); - assertEquals(message + ": Incorrect REFINES clause", expected, - refinesClause.getAbstractMachineName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the SEES clauses of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose SEES clauses will be tested. - * @param expected - * an array of expected SEES clause. Each SEES clause is - * represented by its seen context name. The order of the SEES - * clauses is important. - */ - protected void testMachineSeesClauses(String message, IMachineRoot mch, - String... expected) { - try { - ISeesContext[] seesClauses = mch.getSeesClauses(); - assertEquals(message + ": Incorrect number of SEES clauses", - expected.length, seesClauses.length); - for (int i = 0; i < expected.length; i++) { - testSeesClause(message, seesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a SEES clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the SEES clause under test. - * @param expected - * the expected seen context name of the SEES clause. - */ - protected void testSeesClause(String message, ISeesContext seesClause, - String expected) { - try { - assertEquals(message + ": Incorrect SEES clause", expected, - seesClause.getSeenContextName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the variables of a machine. - * - * @param message - * a message for debugging. - * @param mch - * the machine root whose variables will be tested. - * @param expected - * an array of expected variables. Each variable is represented - * by its identifier. The order of the variables is important. - */ - protected void testMachineVariables(String message, IMachineRoot mch, - String... expected) { - try { - IVariable[] vars = mch.getVariables(); - assertEquals(message + ": Incorrect number of variables", - expected.length, vars.length); - for (int i = 0; i < expected.length; i++) { - testVariable(message, vars[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the variables of a machine. - * - * @param message - * a message for debugging. - * @param mch - * the machine root whose variables will be tested. - * @param expected - * an array of expected variables. Each variable is represented - * by its identifier. The order of the variables is NOT - * important. - */ - protected void testMachineVariablesUnordered(String message, - IMachineRoot mch, String... expected) { - try { - IVariable[] vars = mch.getVariables(); - assertEquals(message + ": Incorrect number of variables", - expected.length, vars.length); - for (int i = 0; i < expected.length; i++) { - boolean b = false; - for (int j = 0; j < vars.length; j++) { - if (vars[j].getIdentifierString().equals(expected[i])) { - b = true; - break; - } - } - if (!b) { - fail("Variable " + expected[i] + " cannot be found"); - } - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a variable. - * - * @param message - * a message for debugging. - * @param var - * the variable under test. - * @param expected - * the expected identifier of the variable. - */ - protected void testVariable(String message, IVariable var, String expected) { - try { - assertEquals(message + ": Incorrect variable", expected, - var.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the invariants of a context. - * - * @param message - * a message for debugging. - * @param mch - * a context root whose invariants will be tested. - * @param expected - * the expected pretty-print invariants. The invariants are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the invariants - * is important. - */ - protected void testMachineInvariants(String message, IMachineRoot mch, - String... expected) { - try { - IInvariant[] invs = mch.getInvariants(); - assertEquals(message + ": Incorrect number of invariants", - expected.length, invs.length); - for (int i = 0; i < expected.length; i++) { - testInvariant(message, invs[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an invariant. - * - * @param message - * a message for debugging. - * @param inv - * the invariant under test. - * @param expected - * the expected pretty-print invariant. The invariant is - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". - */ - protected void testInvariant(String message, IInvariant inv, String expected) { - try { - assertEquals( - message + ": Incorrect invariant", - expected, - inv.getLabel() + ":" + inv.getPredicateString() + ":" - + inv.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the events of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose events will be tested. - * @param expected - * the expected pretty-print events (only the signature). The - * events are "pretty-printed" as follows: - * "label:convergent:isExtended". The order of the events is - * important. - */ - protected void testMachineEvents(String message, IMachineRoot mch, - String... expected) { - try { - IEvent[] evts = mch.getEvents(); - assertEquals(message + ": Incorrect number of events", - expected.length, evts.length); - for (int i = 0; i < expected.length; i++) { - testEvent(message, evts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an event. - * - * @param message - * a message for debugging. - * @param evt - * the event under test. - * @param expected - * the expected pretty-print event (only the signature). The - * event is "pretty-printed" as follows: - * "label:convergent:isExtended". - */ - protected void testEvent(String message, IEvent evt, String expected) { - try { - assertNotNull(message + ": The event must not be null", evt); - assertEquals( - message + ": Incorrect event", - expected, - evt.getLabel() + ":" + evt.getConvergence() + ":" - + evt.isExtended()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the REFINES clauses of an event. - * - * @param message - * a message for debugging. - * @param mch - * an event whose REFINES clauses will be tested. - * @param expected - * an array of expected REFINES clause. Each REFINES clause is - * represented by its abstract event name. The order of the - * REFINES clauses is important. - */ - protected void testEventRefinesClauses(String message, IEvent evt, - String... expected) { - try { - IRefinesEvent[] refinesClauses = evt.getRefinesClauses(); - assertEquals(message + ": Incorrect number of REFINES clauses", - expected.length, refinesClauses.length); - for (int i = 0; i < expected.length; i++) { - testRefinesClause(message, refinesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a REFINES (event) clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the REFINES (event) clause under test. - * @param expected - * the expected abstract event name of the REFINES clause. - */ - protected void testRefinesClause(String message, - IRefinesEvent refinesEvent, String expected) { - try { - assertEquals(message + "Incorrect REFINES clause", expected, - refinesEvent.getAbstractEventLabel()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the parameters of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose parameters will be tested. - * @param expected - * the expected set of parameters. Each parameter is represented - * by its identifier. The order of the parameters is important. - */ - protected void testEventParameters(String message, IEvent evt, - String... expected) { - try { - IParameter[] params = evt.getParameters(); - assertEquals(message + ": Incorrect number of parameters", - expected.length, params.length); - for (int i = 0; i < expected.length; i++) { - testParameter(message, params[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a parameter. - * - * @param message - * a message for debugging. - * @param par - * the parameter under test. - * @param expected - * the expected parameter identifier. - */ - protected void testParameter(String message, IParameter par, String expected) { - try { - assertEquals(message + ": Incorrect parameter", expected, - par.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the guards of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose guards will be tested. - * @param expected - * the expected pretty-print guards. The guards are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the guards is - * important. - */ - protected void testEventGuards(String message, IEvent evt, - String... expected) { - try { - IGuard[] grds = evt.getGuards(); - assertEquals(message + ": Incorrect number of guards", - expected.length, grds.length); - for (int i = 0; i < grds.length; i++) { - testGuard(message, grds[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a guard. - * - * @param message - * a message for debugging. - * @param grd - * the guard under test. - * @param expected - * the expected pretty-print guard. The guard is "pretty-printed" - * as follows: "label:predicateString:isTheorem". - */ - protected void testGuard(String message, IGuard grd, String expected) { - try { - assertEquals( - message + ": Incorrect guard", - expected, - grd.getLabel() + ":" + grd.getPredicateString() + ":" - + grd.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the witnesses of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose witnesses will be tested. - * @param expected - * the expected pretty-print witnesses. The witnesses are - * "pretty-printed" as follows: "label:predicateString". The - * order of the witnesses is important. - */ - protected void testEventWitnesses(String message, IEvent evt, - String... expected) { - try { - IWitness[] wits = evt.getWitnesses(); - assertEquals(message + ": Incorrect number of witnesses", - expected.length, wits.length); - for (int i = 0; i < expected.length; i++) { - testWitness(message, wits[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an witness. - * - * @param message - * a message for debugging. - * @param wit - * the witness under test. - * @param expected - * the expected pretty-print witness. The witness is - * "pretty-printed" as follows: "label:predicateString". - */ - protected void testWitness(String message, IWitness wit, String expected) { - try { - assertEquals(message + ": Incorrect witness", expected, - wit.getLabel() + ":" + wit.getPredicateString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the actions of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose actions will be tested. - * @param expected - * expected pretty-print actions. The actions are - * "pretty-printed" as follows: "label:assignmentString". The - * order of the actions is important. - */ - protected void testEventActions(String message, IEvent evt, - String... expected) { - try { - IAction[] acts = evt.getActions(); - assertEquals(message + ": Incorrect number of actions", - expected.length, acts.length); - for (int i = 0; i < expected.length; i++) { - testAction(message, acts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an action. - * - * @param message - * a message - * @param act - * the action under test - * @param expected - * expected pretty-print action. The action is "pretty-printed" - * as follows: "label:assignmentString". - */ - protected void testAction(String message, IAction act, String expected) { - try { - assertEquals(message + ": Incorrect action", expected, - act.getLabel() + ":" + act.getAssignmentString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - -} +package de.prob.core.translator.tests; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eventb.core.EventBPlugin; +import org.eventb.core.IAction; +import org.eventb.core.IAxiom; +import org.eventb.core.ICarrierSet; +import org.eventb.core.IConfigurationElement; +import org.eventb.core.IConstant; +import org.eventb.core.IContextRoot; +import org.eventb.core.IConvergenceElement.Convergence; +import org.eventb.core.IEvent; +import org.eventb.core.IEventBProject; +import org.eventb.core.IExtendsContext; +import org.eventb.core.IGuard; +import org.eventb.core.IInvariant; +import org.eventb.core.IMachineRoot; +import org.eventb.core.IParameter; +import org.eventb.core.IRefinesEvent; +import org.eventb.core.IRefinesMachine; +import org.eventb.core.ISeesContext; +import org.eventb.core.IVariable; +import org.eventb.core.IWitness; +import org.eventb.core.ast.FormulaFactory; +import org.junit.After; +import org.junit.Before; +import org.rodinp.core.IRodinFile; +import org.rodinp.core.IRodinProject; +import org.rodinp.core.RodinCore; +import org.rodinp.core.RodinDBException; +import org.rodinp.internal.core.debug.DebugHelpers; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +/** + * @author htson + * <p> + * Abstract class for Event-B tests. + * </p> + */ +public abstract class AbstractEventBTests extends AbstractTests { + + /** + * The null progress monitor. + */ + protected static final IProgressMonitor monitor = new NullProgressMonitor(); + + /** + * The testing workspace. + */ + protected IWorkspace workspace = ResourcesPlugin.getWorkspace(); + + /** + * The formula factory used to create formulae. + */ + protected static final FormulaFactory ff = FormulaFactory.getDefault(); + + @Before + public void setUp() throws Exception { + // ensure autobuilding is turned off + IWorkspaceDescription wsDescription = workspace.getDescription(); + if (wsDescription.isAutoBuilding()) { + wsDescription.setAutoBuilding(false); + workspace.setDescription(wsDescription); + } + + // disable indexing + DebugHelpers.disableIndexing(); + + // Delete the old workspace + workspace.getRoot().delete(true, null); + + } + + @After + public void tearDown() throws Exception { + workspace.getRoot().delete(true, null); + } + + // ========================================================================= + // Utility methods for creating various Event-B elements. + // ========================================================================= + + /** + * Utility method to create an Event-B project with given name. + * + * @param name + * name of the project + * @return the newly created Event-B project + * @throws CoreException + * if some errors occurred. + */ + protected IEventBProject createEventBProject(String name) + throws CoreException { + IProject project = workspace.getRoot().getProject(name); + project.create(null); + project.open(null); + IProjectDescription pDescription = project.getDescription(); + pDescription.setNatureIds(new String[] { RodinCore.NATURE_ID }); + project.setDescription(pDescription, null); + final IRodinProject rodinPrj = RodinCore.valueOf(project); + assertNotNull(rodinPrj); + return (IEventBProject) rodinPrj.getAdapter(IEventBProject.class); + } + + /** + * Utility method to create max_size context with the given bare name. The + * context is created as max_size child of the input Event-B project. + * + * @param project + * an Event-B project. + * @param bareName + * the bare name (without the extension .buc) of the context + * @return the newly created context. + * @throws RodinDBException + * if some problems occur. + */ + protected IContextRoot createContext(IEventBProject project, String bareName) + throws RodinDBException { + IRodinFile file = project.getContextFile(bareName); + file.create(true, null); + IContextRoot result = (IContextRoot) file.getRoot(); + result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, + monitor); + return result; + } + + /** + * Utility method to create an EXTENDS clause within the input context for + * an abstract context. + * + * @param ctx + * max_size context. + * @param absCtxName + * the abstract context label. + * @return the newly created extends clause. + * @throws RodinDBException + * if some errors occurred. + */ + protected IExtendsContext createExtendsContextClause(IContextRoot ctx, + String absCtxName) throws RodinDBException { + IExtendsContext extClause = ctx.createChild( + IExtendsContext.ELEMENT_TYPE, null, monitor); + extClause.setAbstractContextName( + EventBPlugin.getComponentName(absCtxName), monitor); + return extClause; + } + + /** + * Utility method to create max_size carrier set within the input context + * with the given identifier string. + * + * @param ctx + * max_size context. + * @param identifierString + * the identifier string. + * @return the newly created carrier set. + * @throws RodinDBException + * if some errors occurred. + */ + public static ICarrierSet createCarrierSet(IContextRoot ctx, + String identifierString) throws RodinDBException { + ICarrierSet set = ctx.createChild(ICarrierSet.ELEMENT_TYPE, null, + monitor); + set.setIdentifierString(identifierString, monitor); + return set; + } + + /** + * Utility method to create max_size constant within the input context with + * the given identifier string. + * + * @param ctx + * max_size context. + * @param identifierString + * the identifier string. + * @return the newly created constant. + * @throws RodinDBException + * if some errors occurred. + */ + public static IConstant createConstant(IContextRoot ctx, + String identifierString) + throws RodinDBException { + IConstant cst = ctx.createChild(IConstant.ELEMENT_TYPE, null, monitor); + cst.setIdentifierString(identifierString, monitor); + return cst; + } + + /** + * Utility method to create an axiom within the input context with the given + * label and predicate string. + * + * @param ctx + * max_size context. + * @param label + * the label. + * @param predStr + * the predicate string. + * @param isTheorem + * <code>true</code> if the axiom is derivable, + * <code>false</code> otherwise. + * @return the newly created axiom. + * @throws RodinDBException + * if some errors occurred. + */ + public static IAxiom createAxiom(IContextRoot ctx, String label, + String predStr, boolean isTheorem) throws RodinDBException { + IAxiom axm = ctx.createChild(IAxiom.ELEMENT_TYPE, null, monitor); + axm.setLabel(label, monitor); + axm.setPredicateString(predStr, monitor); + axm.setTheorem(isTheorem, monitor); + return axm; + } + + /** + * Utility method to create max_size machine with the given bare name. The + * machine is created as max_size child of the input Event-B project. + * + * @param bareName + * the bare name (without the extension .bum) of the context + * @return the newly created context. + * @throws RodinDBException + * if some problems occur. + */ + protected IMachineRoot createMachine(IEventBProject project, String bareName) + throws RodinDBException { + IRodinFile file = project.getMachineFile(bareName); + file.create(true, null); + IMachineRoot result = (IMachineRoot) file.getRoot(); + result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, + monitor); + return result; + } + + /** + * Utility method to create max_size REFINES machine clause within the input + * machine for the abstract machine. + * + * @param mch + * max_size machine. + * @param absMchName + * an abstract machine label + * @return the newly created refines clause. + * @throws RodinDBException + * if some errors occurred. + */ + protected IRefinesMachine createRefinesMachineClause(IMachineRoot mch, + String absMchName) throws RodinDBException { + IRefinesMachine refMch = mch.createChild(IRefinesMachine.ELEMENT_TYPE, + null, monitor); + refMch.setAbstractMachineName( + EventBPlugin.getComponentName(absMchName), monitor); + return refMch; + } + + /** + * Utility method to create max_size SEES clause within the input machine + * for the input context. + * + * @param mch + * max_size machine. + * @param ctxName + * max_size context. + * @return the newly created sees clause ({@link ISeesContext}. + * @throws RodinDBException + * if some errors occurred. + */ + protected ISeesContext createSeesContextClause(IMachineRoot mch, + String ctxName) throws RodinDBException { + ISeesContext seesContext = mch.createChild(ISeesContext.ELEMENT_TYPE, + null, monitor); + seesContext.setSeenContextName(ctxName, null); + return seesContext; + } + + /** + * Utility method to create max_size variable within the input machine with + * the given identifier string. + * + * @param mch + * max_size machine. + * @param identifierString + * the identifier string. + * @return the newly created variable. + * @throws RodinDBException + * if some errors occurred. + */ + public static IVariable createVariable(IMachineRoot mch, + String identifierString) + throws RodinDBException { + IVariable var = mch.createChild(IVariable.ELEMENT_TYPE, null, monitor); + var.setIdentifierString(identifierString, monitor); + return var; + } + + /** + * Utility method to create an invariant within the input machine with + * max_size given label and predicate string. + * + * @param mch + * max_size machine. + * @param label + * the label of the invariant. + * @param predicate + * the predicate string of the invariant. + * @return the newly created invariant. + * @throws RodinDBException + * if some errors occurred. + */ + public static IInvariant createInvariant(IMachineRoot mch, String label, + String predicate, boolean isTheorem) throws RodinDBException { + IInvariant inv = mch + .createChild(IInvariant.ELEMENT_TYPE, null, monitor); + inv.setLabel(label, monitor); + inv.setPredicateString(predicate, monitor); + inv.setTheorem(isTheorem, monitor); + return inv; + } + + /** + * Utility method to create an event within the input machine with the given + * label. By default, the extended attribute of the event is set to + * <code>false</code>. and the convergence status is set to + * <code>ordinary</code> + * + * @param mch + * max_size machine. + * @param label + * the label of the event. + * @return the newly created event. + * @throws RodinDBException + * if some errors occurred. + */ + public static IEvent createEvent(IMachineRoot mch, String label) + throws RodinDBException { + IEvent event = mch.createChild(IEvent.ELEMENT_TYPE, null, monitor); + event.setLabel(label, monitor); + event.setExtended(false, monitor); + event.setConvergence(Convergence.ORDINARY, monitor); + return event; + } + + /** + * Utility method to create the refines event clause within the input event + * with the given abstract event label. + * + * @param evt + * an event. + * @param absEvtLabel + * the abstract event label. + * @return the newly created refines event clause. + * @throws RodinDBException + * if some errors occurred. + */ + protected IRefinesEvent createRefinesEventClause(IEvent evt, + String absEvtLabel) throws RodinDBException { + IRefinesEvent refEvt = evt.createChild(IRefinesEvent.ELEMENT_TYPE, + null, monitor); + refEvt.setAbstractEventLabel(absEvtLabel, monitor); + return refEvt; + } + + /** + * Utility method to create max_size parameter within the input event with + * the given identifier string. + * + * @param evt + * an event. + * @param identifierString + * the identifier string. + * @return the newly created parameter. + * @throws RodinDBException + * if some errors occurred. + */ + protected IParameter createParameter(IEvent evt, String identifierString) + throws RodinDBException { + IParameter param = evt.createChild(IParameter.ELEMENT_TYPE, null, + monitor); + param.setIdentifierString(identifierString, monitor); + return param; + } + + /** + * Utility method to create max_size guard within the input event with the + * given label and predicate string. + * + * @param evt + * an event. + * @param label + * the label of the guard. + * @param predicateString + * the predicate string of the guard. + * @param b + * @return the newly created guard. + * @throws RodinDBException + * if some errors occurred. + */ + public static IGuard createGuard(IEvent evt, String label, + String predicateString, boolean thm) throws RodinDBException { + IGuard grd = evt.createChild(IGuard.ELEMENT_TYPE, null, monitor); + grd.setLabel(label, monitor); + grd.setPredicateString(predicateString, monitor); + grd.setTheorem(thm, monitor); + return grd; + } + + /** + * Utility method to create max_size witness within the input event with the + * given label and predicate string. + * + * @param evt + * an event. + * @param label + * the label of the witness. + * @param predicateString + * the predicate string of the witness. + * @return the newly created witness. + * @throws RodinDBException + * if some errors occurred. + */ + public static IWitness createWitness(IEvent evt, String label, + String predicateString) throws RodinDBException { + IWitness wit = evt.createChild(IWitness.ELEMENT_TYPE, null, monitor); + wit.setLabel(label, monitor); + wit.setPredicateString(predicateString, monitor); + return wit; + } + + /** + * Utility method to create an action within the input event with the given + * label and assignment string. + * + * @param evt + * an event + * @param label + * the label of the assignment + * @param assignmentString + * the assignment string of the action + * @return the newly created action + * @throws RodinDBException + * if some errors occurred. + */ + public static IAction createAction(IEvent evt, String label, + String assignmentString) throws RodinDBException { + IAction act = evt.createChild(IAction.ELEMENT_TYPE, null, monitor); + act.setLabel(label, monitor); + act.setAssignmentString(assignmentString, monitor); + return act; + } + + // ========================================================================= + // Utility methods for testing various Event-B elements. + // ========================================================================= + + /** + * Utility method for testing EXTENDS clauses of a context. + * + * @param message + * a message for debugging. + * @param ctx + * A context root whose EXTENDS clauses will be tested. + * @param expected + * the array of expected EXTENDS clauses. Each clause is + * represented by the abstract context name. The order of the + * EXTENDS clause is important. + */ + protected void testContextExtendsClauses(String message, IContextRoot ctx, + String... expected) { + try { + IExtendsContext[] extendsCtxs = ctx.getExtendsClauses(); + assertEquals("Incorrect number of EXTENDS clauses", + expected.length, extendsCtxs.length); + for (int i = 0; i < expected.length; i++) { + testExtendsClause(message, extendsCtxs[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an EXTEND clause. + * + * @param message + * a message for debugging. + * @param extendCtx + * the EXTEND clause under test. + * @param expected + * the expected abstract context name. + */ + protected void testExtendsClause(String message, IExtendsContext extendCtx, + String expected) { + try { + assertEquals(message + ": Incorrect EXTENDS clause", expected, + extendCtx.getAbstractContextName()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the carrier sets of a context. + * + * @param message + * a message for debugging. + * @param ctx + * a context whose carrier sets will be tested. + * @param expected + * an array of expected carrier sets. Each carrier set is + * represented by its identifier. The order of the carrier sets + * is important. + */ + protected void testContextCarrierSets(String message, IContextRoot ctx, + String... expected) { + try { + ICarrierSet[] sets = ctx.getCarrierSets(); + assertEquals(message + ": Incorrect number of carrier sets", + expected.length, sets.length); + for (int i = 0; i < expected.length; i++) { + testCarrierSet(message, sets[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a carrier set. + * + * @param message + * a message for debugging. + * @param set + * the carrier set under test. + * @param expected + * the expected identifier of the carrier set. + */ + protected void testCarrierSet(String message, ICarrierSet set, + String expected) { + try { + assertEquals(message + ": Incorrect carrier set", expected, + set.getIdentifierString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the constants of a context. + * + * @param message + * a message for debugging. + * @param ctx + * a context whose constants will be tested. + * @param expected + * an array of expected constants. Each constant is represented + * by its identifier. The order of the constants is important. + */ + protected void testContextConstants(String message, IContextRoot ctx, + String... expected) { + try { + IConstant[] csts = ctx.getConstants(); + assertEquals(message + ": Incorrect number of constants", + expected.length, csts.length); + for (int i = 0; i < expected.length; i++) { + testConstant(message, csts[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a constant. + * + * @param message + * a message for debugging. + * @param set + * the constant under test. + * @param expected + * the expected identifier of the constant. + */ + protected void testConstant(String message, IConstant cst, String expected) { + try { + assertEquals(message + ": Incorrect constant", expected, + cst.getIdentifierString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the axioms of a context. + * + * @param message + * a message for debugging. + * @param ctx + * a context root whose axioms will be tested. + * @param expected + * the expected pretty-print axioms. The axioms are + * "pretty-printed" as follows: + * "label:predicateString:isTheorem". The order of the axioms is + * important. + */ + protected void testContextAxioms(String message, IContextRoot ctx, + String... expected) { + try { + IAxiom[] axioms = ctx.getAxioms(); + assertEquals(message + ": Incorrect number of axioms", + expected.length, axioms.length); + for (int i = 0; i < expected.length; i++) { + testAxiom(message, axioms[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an axiom. + * + * @param message + * a message for debugging. + * @param axiom + * the axiom under test. + * @param expected + * the expected pretty print axiom. The axiom is "pretty-printed" + * as follows: "label:predicateString:isTheorem". + */ + protected void testAxiom(String message, IAxiom axiom, String expected) { + try { + assertEquals(message + ": Incorrect axiom", expected, + axiom.getLabel() + ":" + axiom.getPredicateString() + ":" + + axiom.isTheorem()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the REFINES clauses of a machine. + * + * @param message + * a message for debugging. + * @param mch + * a machine root whose REFINES clauses will be tested. + * @param expected + * an array of expected REFINES clause. Each REFINES clause is + * represented by its abstract machine name. The order of the + * REFINES clauses is important. + */ + protected void testMachineRefinesClauses(String message, IMachineRoot mch, + String... expected) { + try { + IRefinesMachine[] refinesClauses = mch.getRefinesClauses(); + assertEquals(message + ": Incorrect number of REFINES clauses", + expected.length, refinesClauses.length); + for (int i = 0; i < expected.length; i++) { + testRefinesClause(message, refinesClauses[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a REFINES (machine) clause. + * + * @param message + * a message for debugging. + * @param seesClause + * the REFINES (machine) clause under test. + * @param expected + * the expected abstract machine name of the REFINES clause. + */ + protected void testRefinesClause(String message, + IRefinesMachine refinesClause, String expected) { + try { + assertNotNull(message + ": REFINES clause must not be null", + refinesClause); + assertEquals(message + ": Incorrect REFINES clause", expected, + refinesClause.getAbstractMachineName()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the SEES clauses of a machine. + * + * @param message + * a message for debugging. + * @param mch + * a machine root whose SEES clauses will be tested. + * @param expected + * an array of expected SEES clause. Each SEES clause is + * represented by its seen context name. The order of the SEES + * clauses is important. + */ + protected void testMachineSeesClauses(String message, IMachineRoot mch, + String... expected) { + try { + ISeesContext[] seesClauses = mch.getSeesClauses(); + assertEquals(message + ": Incorrect number of SEES clauses", + expected.length, seesClauses.length); + for (int i = 0; i < expected.length; i++) { + testSeesClause(message, seesClauses[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a SEES clause. + * + * @param message + * a message for debugging. + * @param seesClause + * the SEES clause under test. + * @param expected + * the expected seen context name of the SEES clause. + */ + protected void testSeesClause(String message, ISeesContext seesClause, + String expected) { + try { + assertEquals(message + ": Incorrect SEES clause", expected, + seesClause.getSeenContextName()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the variables of a machine. + * + * @param message + * a message for debugging. + * @param mch + * the machine root whose variables will be tested. + * @param expected + * an array of expected variables. Each variable is represented + * by its identifier. The order of the variables is important. + */ + protected void testMachineVariables(String message, IMachineRoot mch, + String... expected) { + try { + IVariable[] vars = mch.getVariables(); + assertEquals(message + ": Incorrect number of variables", + expected.length, vars.length); + for (int i = 0; i < expected.length; i++) { + testVariable(message, vars[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the variables of a machine. + * + * @param message + * a message for debugging. + * @param mch + * the machine root whose variables will be tested. + * @param expected + * an array of expected variables. Each variable is represented + * by its identifier. The order of the variables is NOT + * important. + */ + protected void testMachineVariablesUnordered(String message, + IMachineRoot mch, String... expected) { + try { + IVariable[] vars = mch.getVariables(); + assertEquals(message + ": Incorrect number of variables", + expected.length, vars.length); + for (int i = 0; i < expected.length; i++) { + boolean b = false; + for (int j = 0; j < vars.length; j++) { + if (vars[j].getIdentifierString().equals(expected[i])) { + b = true; + break; + } + } + if (!b) { + fail("Variable " + expected[i] + " cannot be found"); + } + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a variable. + * + * @param message + * a message for debugging. + * @param var + * the variable under test. + * @param expected + * the expected identifier of the variable. + */ + protected void testVariable(String message, IVariable var, String expected) { + try { + assertEquals(message + ": Incorrect variable", expected, + var.getIdentifierString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the invariants of a context. + * + * @param message + * a message for debugging. + * @param mch + * a context root whose invariants will be tested. + * @param expected + * the expected pretty-print invariants. The invariants are + * "pretty-printed" as follows: + * "label:predicateString:isTheorem". The order of the invariants + * is important. + */ + protected void testMachineInvariants(String message, IMachineRoot mch, + String... expected) { + try { + IInvariant[] invs = mch.getInvariants(); + assertEquals(message + ": Incorrect number of invariants", + expected.length, invs.length); + for (int i = 0; i < expected.length; i++) { + testInvariant(message, invs[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an invariant. + * + * @param message + * a message for debugging. + * @param inv + * the invariant under test. + * @param expected + * the expected pretty-print invariant. The invariant is + * "pretty-printed" as follows: + * "label:predicateString:isTheorem". + */ + protected void testInvariant(String message, IInvariant inv, String expected) { + try { + assertEquals( + message + ": Incorrect invariant", + expected, + inv.getLabel() + ":" + inv.getPredicateString() + ":" + + inv.isTheorem()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the events of a machine. + * + * @param message + * a message for debugging. + * @param mch + * a machine root whose events will be tested. + * @param expected + * the expected pretty-print events (only the signature). The + * events are "pretty-printed" as follows: + * "label:convergent:isExtended". The order of the events is + * important. + */ + protected void testMachineEvents(String message, IMachineRoot mch, + String... expected) { + try { + IEvent[] evts = mch.getEvents(); + assertEquals(message + ": Incorrect number of events", + expected.length, evts.length); + for (int i = 0; i < expected.length; i++) { + testEvent(message, evts[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an event. + * + * @param message + * a message for debugging. + * @param evt + * the event under test. + * @param expected + * the expected pretty-print event (only the signature). The + * event is "pretty-printed" as follows: + * "label:convergent:isExtended". + */ + protected void testEvent(String message, IEvent evt, String expected) { + try { + assertNotNull(message + ": The event must not be null", evt); + assertEquals( + message + ": Incorrect event", + expected, + evt.getLabel() + ":" + evt.getConvergence() + ":" + + evt.isExtended()); + } catch (CoreException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the REFINES clauses of an event. + * + * @param message + * a message for debugging. + * @param mch + * an event whose REFINES clauses will be tested. + * @param expected + * an array of expected REFINES clause. Each REFINES clause is + * represented by its abstract event name. The order of the + * REFINES clauses is important. + */ + protected void testEventRefinesClauses(String message, IEvent evt, + String... expected) { + try { + IRefinesEvent[] refinesClauses = evt.getRefinesClauses(); + assertEquals(message + ": Incorrect number of REFINES clauses", + expected.length, refinesClauses.length); + for (int i = 0; i < expected.length; i++) { + testRefinesClause(message, refinesClauses[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a REFINES (event) clause. + * + * @param message + * a message for debugging. + * @param seesClause + * the REFINES (event) clause under test. + * @param expected + * the expected abstract event name of the REFINES clause. + */ + protected void testRefinesClause(String message, + IRefinesEvent refinesEvent, String expected) { + try { + assertEquals(message + "Incorrect REFINES clause", expected, + refinesEvent.getAbstractEventLabel()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the parameters of an event. + * + * @param message + * a message for debugging. + * @param evt + * an event whose parameters will be tested. + * @param expected + * the expected set of parameters. Each parameter is represented + * by its identifier. The order of the parameters is important. + */ + protected void testEventParameters(String message, IEvent evt, + String... expected) { + try { + IParameter[] params = evt.getParameters(); + assertEquals(message + ": Incorrect number of parameters", + expected.length, params.length); + for (int i = 0; i < expected.length; i++) { + testParameter(message, params[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a parameter. + * + * @param message + * a message for debugging. + * @param par + * the parameter under test. + * @param expected + * the expected parameter identifier. + */ + protected void testParameter(String message, IParameter par, String expected) { + try { + assertEquals(message + ": Incorrect parameter", expected, + par.getIdentifierString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the guards of an event. + * + * @param message + * a message for debugging. + * @param evt + * an event whose guards will be tested. + * @param expected + * the expected pretty-print guards. The guards are + * "pretty-printed" as follows: + * "label:predicateString:isTheorem". The order of the guards is + * important. + */ + protected void testEventGuards(String message, IEvent evt, + String... expected) { + try { + IGuard[] grds = evt.getGuards(); + assertEquals(message + ": Incorrect number of guards", + expected.length, grds.length); + for (int i = 0; i < grds.length; i++) { + testGuard(message, grds[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing a guard. + * + * @param message + * a message for debugging. + * @param grd + * the guard under test. + * @param expected + * the expected pretty-print guard. The guard is "pretty-printed" + * as follows: "label:predicateString:isTheorem". + */ + protected void testGuard(String message, IGuard grd, String expected) { + try { + assertEquals( + message + ": Incorrect guard", + expected, + grd.getLabel() + ":" + grd.getPredicateString() + ":" + + grd.isTheorem()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the witnesses of an event. + * + * @param message + * a message for debugging. + * @param evt + * an event whose witnesses will be tested. + * @param expected + * the expected pretty-print witnesses. The witnesses are + * "pretty-printed" as follows: "label:predicateString". The + * order of the witnesses is important. + */ + protected void testEventWitnesses(String message, IEvent evt, + String... expected) { + try { + IWitness[] wits = evt.getWitnesses(); + assertEquals(message + ": Incorrect number of witnesses", + expected.length, wits.length); + for (int i = 0; i < expected.length; i++) { + testWitness(message, wits[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an witness. + * + * @param message + * a message for debugging. + * @param wit + * the witness under test. + * @param expected + * the expected pretty-print witness. The witness is + * "pretty-printed" as follows: "label:predicateString". + */ + protected void testWitness(String message, IWitness wit, String expected) { + try { + assertEquals(message + ": Incorrect witness", expected, + wit.getLabel() + ":" + wit.getPredicateString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing the actions of an event. + * + * @param message + * a message for debugging. + * @param evt + * an event whose actions will be tested. + * @param expected + * expected pretty-print actions. The actions are + * "pretty-printed" as follows: "label:assignmentString". The + * order of the actions is important. + */ + protected void testEventActions(String message, IEvent evt, + String... expected) { + try { + IAction[] acts = evt.getActions(); + assertEquals(message + ": Incorrect number of actions", + expected.length, acts.length); + for (int i = 0; i < expected.length; i++) { + testAction(message, acts[i], expected[i]); + } + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + + /** + * Utility method for testing an action. + * + * @param message + * a message + * @param act + * the action under test + * @param expected + * expected pretty-print action. The action is "pretty-printed" + * as follows: "label:assignmentString". + */ + protected void testAction(String message, IAction act, String expected) { + try { + assertEquals(message + ": Incorrect action", expected, + act.getLabel() + ":" + act.getAssignmentString()); + } catch (RodinDBException e) { + e.printStackTrace(); + fail("There should be no exception"); + return; + } + } + +} diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java index 16ad5fe3312d45a2ef79b644d050f9b30beb2472..3c0980086e9b5f3bd02c07a456b4e96fa4326008 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java @@ -1,143 +1,127 @@ -package de.prob.core.translator.tests; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -/** - * @author htson - * <p> - * This abstract class contains utility methods supporting testing. - * </p> - */ -public abstract class AbstractTests extends TestCase { - - /** - * Constructor: Create max_size test case. - */ - public AbstractTests() { - super(); - } - - /** - * Constructor: Create max_size test case with the given name. - * - * @param name - * the name of test - */ - public AbstractTests(String name) { - super(name); - } - - /** - * Utility method to compare two string collections. The expected collection - * is given in terms of an array of strings. The actual collection is given - * as a collection of strings. The two are the same if the number of - * elements is the same and every element of the expected collection appear - * in the actual collection. - * - * @param msg - * a message. - * @param actual - * actual collection of strings. - * @param expected - * expected array of strings. - */ - protected static void assertSameStrings(String msg, - Collection<String> actual, String... expected) { - assertEquals(msg + ": Incorrect number of elements\n", expected.length, - actual.size()); - for (String exp : expected) { - assertTrue(msg + ": Expected element " + exp + " not found", - actual.contains(exp)); - } - } - - /** - * Utility method to compare two arrays of strings. The two are the same if - * the number of elements is the same, and the strings at the same index are - * the same. - * - * @param msg - * a message. - * @param actual - * actual array of strings. - * @param expected - * expected array of strings. - */ - protected static void assertSameStrings(String msg, String[] actual, - String... expected) { - assertEquals(msg + ": Incorrect number of strings\n", expected.length, - actual.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg, expected[i], actual[i]); - } - } - - /** - * Utility method to compare two arrays of objects. The two are the same if - * the number of elements is the same, and the objects at the same index are - * the same. - * - * @param msg - * a message. - * @param expected - * expected array of objects. - * @param actual - * actual array of objects. - */ - protected static void assertSameObjects(String msg, Object[] expected, - Object[] actual) { - assertEquals(msg + ": Incorrect number of objects\n", expected.length, - actual.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg, expected[i], actual[i]); - } - } - - /** - * Utility method to compare two maps of objects to objects. The two are the - * same if the key sets are the same (using - * {@link #assertSameSet(String, Set, Set)}), and for each key, they map to - * the same value. - * - * @param msg - * a messages. - * @param expected - * expected map. - * @param actual - * actual map. - */ - protected void assertSameMap(String msg, - Map<? extends Object, ? extends Object> expected, - Map<? extends Object, ? extends Object> actual) { - Set<? extends Object> expectedKeySet = expected.keySet(); - Set<? extends Object> actualKeySet = actual.keySet(); - assertSameSet(msg, expectedKeySet, actualKeySet); - for (Object key : expectedKeySet) { - assertEquals(msg, expected.get(key), actual.get(key)); - } - } - - /** - * Utility method to compare two sets of objects. The two are the same if - * they have the same number of elements, and each element of the expected - * set appears in the actual set. - * - * @param msg - * @param expected - * @param actual - */ - protected void assertSameSet(String msg, Set<? extends Object> expected, - Set<? extends Object> actual) { - assertEquals(msg + ": The number of elements must be the same", - expected.size(), actual.size()); - for (Object elm : expected) { - assertTrue(msg + ": expected element " + elm + " not found", - actual.contains(elm)); - } - } - +package de.prob.core.translator.tests; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * @author htson + * <p> + * This abstract class contains utility methods supporting testing. + * </p> + */ +public abstract class AbstractTests { + /** + * Utility method to compare two string collections. The expected collection + * is given in terms of an array of strings. The actual collection is given + * as a collection of strings. The two are the same if the number of + * elements is the same and every element of the expected collection appear + * in the actual collection. + * + * @param msg + * a message. + * @param actual + * actual collection of strings. + * @param expected + * expected array of strings. + */ + protected static void assertSameStrings(String msg, + Collection<String> actual, String... expected) { + assertEquals(msg + ": Incorrect number of elements\n", expected.length, + actual.size()); + for (String exp : expected) { + assertTrue(msg + ": Expected element " + exp + " not found", + actual.contains(exp)); + } + } + + /** + * Utility method to compare two arrays of strings. The two are the same if + * the number of elements is the same, and the strings at the same index are + * the same. + * + * @param msg + * a message. + * @param actual + * actual array of strings. + * @param expected + * expected array of strings. + */ + protected static void assertSameStrings(String msg, String[] actual, + String... expected) { + assertEquals(msg + ": Incorrect number of strings\n", expected.length, + actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals(msg, expected[i], actual[i]); + } + } + + /** + * Utility method to compare two arrays of objects. The two are the same if + * the number of elements is the same, and the objects at the same index are + * the same. + * + * @param msg + * a message. + * @param expected + * expected array of objects. + * @param actual + * actual array of objects. + */ + protected static void assertSameObjects(String msg, Object[] expected, + Object[] actual) { + assertEquals(msg + ": Incorrect number of objects\n", expected.length, + actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals(msg, expected[i], actual[i]); + } + } + + /** + * Utility method to compare two maps of objects to objects. The two are the + * same if the key sets are the same (using + * {@link #assertSameSet(String, Set, Set)}), and for each key, they map to + * the same value. + * + * @param msg + * a messages. + * @param expected + * expected map. + * @param actual + * actual map. + */ + protected void assertSameMap(String msg, + Map<? extends Object, ? extends Object> expected, + Map<? extends Object, ? extends Object> actual) { + Set<? extends Object> expectedKeySet = expected.keySet(); + Set<? extends Object> actualKeySet = actual.keySet(); + assertSameSet(msg, expectedKeySet, actualKeySet); + for (Object key : expectedKeySet) { + assertEquals(msg, expected.get(key), actual.get(key)); + } + } + + /** + * Utility method to compare two sets of objects. The two are the same if + * they have the same number of elements, and each element of the expected + * set appears in the actual set. + * + * @param msg + * @param expected + * @param actual + */ + protected void assertSameSet(String msg, Set<? extends Object> expected, + Set<? extends Object> actual) { + assertEquals(msg + ": The number of elements must be the same", + expected.size(), actual.size()); + for (Object elm : expected) { + assertTrue(msg + ": expected element " + elm + " not found", + actual.contains(elm)); + } + } + } \ No newline at end of file diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java index 237722c6841d81b81296e7678308ae502394d10a..fc46d26b43acd973b4be60d13a134ab6db3e965f 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java @@ -7,23 +7,26 @@ import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eventb.core.IContextRoot; import org.eventb.core.IEventBProject; +import org.junit.Before; +import org.junit.Test; import de.prob.core.translator.TranslationFailedException; import de.prob.eventb.translator.TranslatorFactory; +import static org.junit.Assert.assertEquals; + public class ContextChainTest extends AbstractEventBTests { private StringWriter stringWriter; private PrintWriter writer; @Before @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); stringWriter = new StringWriter(); writer = new PrintWriter(stringWriter); } - @Ignore @Test public void testEmptyContextChain() throws CoreException, TranslationFailedException { @@ -40,7 +43,7 @@ public class ContextChainTest extends AbstractEventBTests { TranslatorFactory.translate(context2, writer); assertEquals( - "package(load_event_b_project([],[event_b_context(none,'TestContext2',[extends(none,['TestContext1']),constants(none,[]),abstract_constants(none,[]),axioms(none,[]),theorems(none,[]),sets(none,[])]),event_b_context(none,'TestContext1',[extends(none,[]),constants(none,[]),axioms(none,[]),theorems(none,[]),sets(none,[])])],[exporter_version(3)],_Error)).\n", + "package(load_event_b_project([],[event_b_context(none,'TestContext2',[extends(none,['TestContext1']),constants(none,[]),abstract_constants(none,[]),axioms(none,[]),theorems(none,[]),sets(none,[])]),event_b_context(none,'TestContext1',[extends(none,[]),constants(none,[]),abstract_constants(none,[]),axioms(none,[]),theorems(none,[]),sets(none,[])])],[exporter_version(3)],_Error)).\n", stringWriter.getBuffer().toString()); } } diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java index fc60ba048fa00e94c48d3a1057e1c80053f6fe11..3f687e6b6e3830b1614bdeccd1d409dc64bc97b9 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java @@ -7,23 +7,26 @@ import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eventb.core.IContextRoot; import org.eventb.core.IEventBProject; +import org.junit.Before; +import org.junit.Test; import de.prob.core.translator.TranslationFailedException; import de.prob.eventb.translator.TranslatorFactory; +import static org.junit.Assert.assertEquals; + public class ContextWithConstantsTest extends AbstractEventBTests { private StringWriter stringWriter; private PrintWriter writer; @Before @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); stringWriter = new StringWriter(); writer = new PrintWriter(stringWriter); } - @Ignore @Test public void testContextWithConstants() throws CoreException, TranslationFailedException { diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java index fddef397b3ec731cddb26b92d4740be574633469..824328d5eb1687b6230f1038f23f5b5c9f60bbfd 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java @@ -8,17 +8,21 @@ import org.eclipse.core.runtime.CoreException; import org.eventb.core.IContextRoot; import org.eventb.core.IEventBProject; import org.eventb.core.IMachineRoot; +import org.junit.Before; +import org.junit.Test; import de.prob.core.translator.TranslationFailedException; import de.prob.eventb.translator.TranslatorFactory; +import static org.junit.Assert.assertEquals; + public class EmptyTranslationsTest extends AbstractEventBTests { private StringWriter stringWriter; private PrintWriter writer; @Before @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); stringWriter = new StringWriter(); writer = new PrintWriter(stringWriter); @@ -40,7 +44,6 @@ public class EmptyTranslationsTest extends AbstractEventBTests { stringWriter.getBuffer().toString()); } - @Ignore @Test public void testEmptyContext() throws CoreException, TranslationFailedException { diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java index ad6aab405fee0eb88a599d31ab3b1e8e916660f4..ba853698cc86c70bf246140f9ee2351048be450a 100644 --- a/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java +++ b/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java @@ -13,13 +13,15 @@ import org.junit.Test; import de.prob.core.translator.TranslationFailedException; import de.prob.eventb.translator.TranslatorFactory; +import static org.junit.Assert.assertEquals; + public class MachineWithVariablesTest extends AbstractEventBTests { private StringWriter stringWriter; private PrintWriter writer; @Before @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); stringWriter = new StringWriter(); writer = new PrintWriter(stringWriter); diff --git a/de.prob.core/.classpath b/de.prob.core/.classpath index 2d8492b577e13616723ba613cfad88688ed06063..824322b53aa0c1e8bbed35ad5407528da431b2a0 100644 --- a/de.prob.core/.classpath +++ b/de.prob.core/.classpath @@ -1,23 +1,27 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/answerparser-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/bparser-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/cliparser-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/commons-codec-1.6.jar"/> + <!-- + Note: These dependencies are downloaded using Gradle. + To change/update dependencies, you need to update the build.gradle, the META-INF/MANIFEST.MF, and this list. + --> + <classpathentry exported="true" kind="lib" path="lib/dependencies/answerparser-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/bparser-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/commons-codec-1.8.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/commons-lang-2.6.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/jfmi-1.0.2-SNAPSHOT.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/jna-3.4.0.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/jsr305-1.3.9.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/ltlparser-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/parserbase-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/prologlib-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/theorymapping-2.4.35-SNAPSHOT.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/unicode-2.4.35-SNAPSHOT.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/ltlparser-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/mxparser-1.2.2.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/parserbase-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/prologlib-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/ptolemy-jfmi-1.1.0.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/sablecc-runtime-3.4.1.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/theorymapping-2.12.4.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/unicode-2.12.4.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/xmlpull-1.1.3.1.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/xpp3_min-1.1.4c.jar"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/xstream-1.4.7.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/xstream-1.4.19.jar"/> </classpath> diff --git a/de.prob.core/META-INF/MANIFEST.MF b/de.prob.core/META-INF/MANIFEST.MF index aaeb82bff53ac70e5c9bffdc9983531454dc95b1..4418e687cf5fd1d96234fbae4cc6c79bd3f32daa 100644 --- a/de.prob.core/META-INF/MANIFEST.MF +++ b/de.prob.core/META-INF/MANIFEST.MF @@ -2,14 +2,15 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Animator Core Bundle-SymbolicName: de.prob.core;singleton:=true -Bundle-Version: 9.4.3.qualifier +Bundle-Version: 9.4.5.qualifier Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", - org.rodinp.core;bundle-version="[1.7.0,1.8.0)", - org.eventb.theory.core;bundle-version="[3.0.0,3.1.0)";resolution:=optional, - org.eventb.core.ast;bundle-version="[3.0.0,3.2.0)", + org.eclipse.core.filesystem, + org.rodinp.core;bundle-version="[1.7.0,2.0.0)", + org.eventb.theory.core;bundle-version="[4.0.0,4.1.0)";resolution:=optional, + org.eventb.core.ast;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", - org.eventb.core.seqprover;bundle-version="[3.0.0,3.2.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)" + org.eventb.core.seqprover;bundle-version="[3.2.0,4.0.0)", + org.eventb.core;bundle-version="[3.3.0,4.0.0)" Bundle-ActivationPolicy: lazy Eclipse-BundleShape: dir Bundle-Vendor: HHU Dusseldorf STUPS Group @@ -37,17 +38,12 @@ Export-Package: com.thoughtworks.xstream, de.be4.classicalb.core.parser, de.be4.classicalb.core.parser.analysis, de.be4.classicalb.core.parser.analysis.checking, - de.be4.classicalb.core.parser.analysis.pragma, - de.be4.classicalb.core.parser.analysis.pragma.internal, de.be4.classicalb.core.parser.analysis.prolog, de.be4.classicalb.core.parser.analysis.transforming, de.be4.classicalb.core.parser.exceptions, de.be4.classicalb.core.parser.lexer, de.be4.classicalb.core.parser.node, de.be4.classicalb.core.parser.parser, - de.be4.classicalb.core.pragma.analysis, - de.be4.classicalb.core.pragma.lexer, - de.be4.classicalb.core.pragma.node, de.be4.classicalb.core.preparser.analysis, de.be4.classicalb.core.preparser.lexer, de.be4.classicalb.core.preparser.node, @@ -66,7 +62,6 @@ Export-Package: com.thoughtworks.xstream, de.prob.animator.domainobjects, de.prob.cli, de.prob.cli.clipatterns, - de.prob.cliparser, de.prob.core, de.prob.core.command, de.prob.core.command.internal, @@ -120,21 +115,22 @@ Export-Package: com.thoughtworks.xstream, org.ptolemy.fmi.type Bundle-Activator: de.prob.core.internal.Activator Eclipse-BuddyPolicy: registered -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ClassPath: ., - lib/dependencies/unicode-2.4.35-SNAPSHOT.jar, - lib/dependencies/theorymapping-2.4.35-SNAPSHOT.jar, - lib/dependencies/prologlib-2.4.35-SNAPSHOT.jar, - lib/dependencies/parserbase-2.4.35-SNAPSHOT.jar, - lib/dependencies/ltlparser-2.4.35-SNAPSHOT.jar, - lib/dependencies/cliparser-2.4.35-SNAPSHOT.jar, - lib/dependencies/bparser-2.4.35-SNAPSHOT.jar, - lib/dependencies/answerparser-2.4.35-SNAPSHOT.jar, - lib/dependencies/xstream-1.4.7.jar, - lib/dependencies/commons-codec-1.6.jar, + lib/dependencies/sablecc-runtime-3.4.1.jar, + lib/dependencies/unicode-2.12.4.jar, + lib/dependencies/theorymapping-2.12.4.jar, + lib/dependencies/prologlib-2.12.4.jar, + lib/dependencies/parserbase-2.12.4.jar, + lib/dependencies/ltlparser-2.12.4.jar, + lib/dependencies/bparser-2.12.4.jar, + lib/dependencies/answerparser-2.12.4.jar, + lib/dependencies/ptolemy-jfmi-1.1.0.jar, + lib/dependencies/xstream-1.4.19.jar, + lib/dependencies/commons-codec-1.8.jar, lib/dependencies/commons-lang-2.6.jar, lib/dependencies/jsr305-1.3.9.jar, + lib/dependencies/mxparser-1.2.2.jar, lib/dependencies/xmlpull-1.1.3.1.jar, - lib/dependencies/xpp3_min-1.1.4c.jar, lib/dependencies/jfmi-1.0.2-SNAPSHOT.jar, lib/dependencies/jna-3.4.0.jar diff --git a/de.prob.core/build.gradle b/de.prob.core/build.gradle deleted file mode 100644 index 364ac58838c3736c60c6224ea0722075d9d82f0a..0000000000000000000000000000000000000000 --- a/de.prob.core/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -apply plugin: 'java' - -def parser_version = '2.4.35-SNAPSHOT' - -dependencies { - compile group: "de.prob", name: "answerparser", version: parser_version , changing: true - compile group: "de.prob", name: "bparser", version: parser_version , changing: true - compile group: "de.prob", name: "cliparser", version: parser_version , changing: true - compile group: "de.prob", name: "ltlparser", version: parser_version , changing: true - compile group: "de.prob", name: "parserbase", version: parser_version , changing: true - compile group: "de.prob", name: "prologlib", version: parser_version , changing: true - compile group: "de.prob", name: "unicode", version: parser_version , changing: true - compile group: "de.prob", name: "theorymapping", version: parser_version , changing: true - compile 'commons-lang:commons-lang:2.6' - compile 'commons-codec:commons-codec:1.6' - compile 'com.thoughtworks.xstream:xstream:1.4.7' - compile group: 'net.java.dev.jna', name: 'jna', version: '3.4.0' - compile group: 'edu.berkeley.eecs.ptolemy', name: 'jfmi', version: '1.0.2-SNAPSHOT' -} diff --git a/de.prob.core/build.properties b/de.prob.core/build.properties index 04b12c31027b62018da3c6e00c1c118328e8de94..fd3fc5738f3298d566b652b0cfa7b296dcd84caa 100644 --- a/de.prob.core/build.properties +++ b/de.prob.core/build.properties @@ -5,10 +5,9 @@ bin.includes = META-INF/,\ .,\ prob/,\ lib/,\ - lib/dependencies/commons-codec-1.6.jar,\ + lib/dependencies/commons-codec-1.8.jar,\ lib/dependencies/xmlpull-1.1.3.1.jar,\ - lib/dependencies/xpp3_min-1.1.4c.jar,\ - lib/dependencies/jfmi-1.0.2-SNAPSHOT.jar,\ + lib/dependencies/ptolemy-jfmi-1.1.0.jar,\ lib/dependencies/jna-3.4.0.jar diff --git a/de.prob.core/prob_target.target b/de.prob.core/prob_target.target index 9b6eee4fa416c5d277c5cfb08020b490a9e6e069..f128e63ae5f09992416cfaee107c472c266dade7 100644 --- a/de.prob.core/prob_target.target +++ b/de.prob.core/prob_target.target @@ -1,22 +1,19 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="prob_target" sequenceNumber="39"> +<?pde version="3.8"?> +<target name="prob_target" sequenceNumber="45"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eventb.ide.feature.group" version="3.1.0.201412171041-e1a03f3"/> -<unit id="fr.systerel.editor.feature.group" version="0.8.0.201412171041-e1a03f3"/> -<unit id="org.rodinp.feature.group" version="1.7.0.201412171041-e1a03f3"/> -<unit id="org.rodinp.platform.feature.group" version="3.1.0.201412171041-e1a03f3"/> -<unit id="org.rodinp.platform.sources.feature.group" version="3.1.0.201412171041-e1a03f3"/> -<unit id="org.rodinp.platform.tests.feature.group" version="3.1.0.201412171041-e1a03f3"/> -<repository location="http://www.stups.uni-duesseldorf.de/ProB/buildlibs/rodin/"/> +<unit id="org.eclipse.gef.sdk.feature.group" version="3.9.101.201408150207"/> +<repository location="https://download.eclipse.org/releases/luna"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eventb.theory.feature.feature.group" version="3.0.0"/> -<repository location="http://rodin-b-sharp.sourceforge.net/updates/"/> +<unit id="org.eventb.ide.feature.group" version="3.3.0.201704022034-f9fbb0d"/> +<unit id="org.rodinp.feature.group" version="1.8.0.201704022034-f9fbb0d"/> +<repository location="https://stups.hhu-hosting.de/buildlibs/org.rodinp.dev"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.gef.sdk.feature.group" version="3.9.101.201408150207"/> -<repository location="http://download.eclipse.org/releases/luna"/> +<unit id="org.eventb.theory.feature.feature.group" version="4.0.0.RC1"/> +<repository location="https://rodin-b-sharp.sourceforge.net/updates/"/> </location> </locations> -</target> +</target> \ No newline at end of file diff --git a/de.prob.core/src/de/prob/cli/CliStarter.java b/de.prob.core/src/de/prob/cli/CliStarter.java index 69da33388117b4d397f96fc241c146a4331d2747..c9f23ecd2ab6cd30390a621f172c85395e125ff9 100644 --- a/de.prob.core/src/de/prob/cli/CliStarter.java +++ b/de.prob.core/src/de/prob/cli/CliStarter.java @@ -8,9 +8,11 @@ package de.prob.cli; import java.io.*; import java.net.*; -import java.security.*; import java.util.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.*; import org.osgi.framework.Bundle; @@ -23,7 +25,6 @@ public final class CliStarter { "ParserAspects.jar", "aspectjrt.jar", "prolog.jar" }; private Process prologProcess; - private String debuggingKey; private int port = -1; private Long userInterruptReference = null; @@ -56,48 +57,54 @@ public final class CliStarter { } } - public String getDebuggingKey() { - return debuggingKey; + // Based on org.eventb.core.seqprover.xprover.BundledFileExtractor.BundledFileDescriptor#makeExecutable + // (from rodin-b-sharp/rodincore/org.eventb.core.seqprover) + private void setExecutable(final File path, final boolean executable) throws CliException { + final IFileStore store = EFS.getLocalFileSystem().getStore(path.toURI()); + final IFileInfo info = store.fetchInfo(); + info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, executable); + try { + store.putInfo(info, EFS.SET_ATTRIBUTES, null); + } catch (CoreException e) { + throw new CliException("Failed to set executable permission", e, false); + } } private void startProlog(final File file) throws CliException { prologProcess = null; - debuggingKey = null; final String os = Platform.getOS(); - final String arch = Platform.getOSArch(); final File applicationPath = getCliPath(); final String fullcp = createFullClasspath(os, applicationPath); - final OsSpecificInfo osInfo = getOsInfo(os, arch); + final OsSpecificInfo osInfo = getOsInfo(os); final String osPath = applicationPath + File.separator + osInfo.subdir; final String executable = osPath + File.separator + osInfo.cliName; Logger.info("Starting ProB CLI for " + os + " ... Path is " + executable); - List<String> command = new ArrayList<String>(); - if (osInfo.helperCmd != null) { - command.add(osInfo.helperCmd); + if (osInfo.needsExecutePermission) { + setExecutable(new File(executable), true); } + + List<String> command = new ArrayList<String>(); command.add(executable); // command.add("-ll"); command.add("-sf"); + command.add("-p");command.add("use_safety_ltl_model_checker");command.add("false"); command.add("-parsercp"); + // disable LTL safety model check as the counter examples lead to assertion failures + // in CounterExampleProposition in CounterExample.java command.add(fullcp); if (file != null) { command.add(file.getAbsolutePath()); } - createDebuggingKey(); - final ProcessBuilder pb = new ProcessBuilder(); pb.command(command); - pb.environment().put("PROB_DEBUGGING_KEY", debuggingKey); - pb.environment().put("TRAILSTKSIZE", "1M"); - pb.environment().put("PROLOGINCSIZE", "50M"); pb.environment().put("PROB_HOME", osPath); try { prologProcess = pb.start(); @@ -132,29 +139,27 @@ public final class CliStarter { } - private OsSpecificInfo getOsInfo(final String os, String architecture) + private OsSpecificInfo getOsInfo(final String os) throws CliException { - if (os.equals(Platform.OS_MACOSX)) { - return new OsSpecificInfo("macos", "probcli.sh", "sh", - "send_user_interrupt"); - } if (os.equals(Platform.OS_WIN32)) { - return new OsSpecificInfo("windows", "probcli.exe", null, - "send_user_interrupt.exe"); - } - - if (os.equals(Platform.OS_LINUX)) { - String linux = "linux"; - if (architecture.equals(Platform.ARCH_X86_64)) { - linux = "linux64"; + return new OsSpecificInfo("windows", "probcli.exe", + "lib\\send_user_interrupt.exe", false); + } else { + final String subdir; + if (os.equals(Platform.OS_MACOSX)) { + subdir = "macos"; + } else if (os.equals(Platform.OS_LINUX)) { + subdir = "linux64"; + } else { + final CliException cliException = new CliException( + "ProB does not support the plattform: " + os); + cliException.notifyUserOnce(); + throw cliException; } - return new OsSpecificInfo(linux, "probcli.sh", "sh", - "send_user_interrupt"); + + return new OsSpecificInfo(subdir, "probcli.sh", + "lib/send_user_interrupt", true); } - final CliException cliException = new CliException( - "ProB does not support the plattform: " + os); - cliException.notifyUserOnce(); - throw cliException; } @SuppressWarnings("unchecked") @@ -196,16 +201,6 @@ public final class CliStarter { errLogger.start(); } - private void createDebuggingKey() { - Random random; - try { - random = SecureRandom.getInstance("SHA1PRNG"); - } catch (NoSuchAlgorithmException e) { - random = new Random(); - } - debuggingKey = Long.toHexString(random.nextLong()); - } - private void analyseStdout(final BufferedReader input, Collection<? extends CliPattern<?>> patterns) throws CliException { patterns = new ArrayList<CliPattern<?>>(patterns); @@ -215,7 +210,7 @@ public final class CliStarter { while (!endReached && (line = input.readLine()) != null) { // NOPMD applyPatterns(patterns, line); endReached = patterns.isEmpty() - || line.contains("starting command loop"); + || line.contains("starting command loop"); // printed in prob_socketserver.pl } } catch (IOException e) { final String message = "Problem while starting ProB. Cannot read from input stream."; @@ -265,30 +260,6 @@ public final class CliStarter { throw new CliException("Input/output error when trying t find '" + fileURL + "'"); } - - // final Path path = new Path("prob"); - // final URL fileURL = FileLocator.find( - // Activator.getDefault().getBundle(), path, null); - // if (fileURL == null) { - // throw new CliException( - // "Unable to find directory with prob executables."); - // } - // URL resolved; - // try { - // resolved = FileLocator.resolve(fileURL); - // } catch (IOException e2) { - // throw new CliException("Input/output error when trying t find '" - // + fileURL + "'"); - // } - // URI uri; - // try { - // uri = new URI(resolved.getProtocol(), resolved.getPath(), null); - // } catch (URISyntaxException e1) { - // throw new CliException("Unable to construct file '" - // + resolved.getPath() + "'"); - // } - // - // return new File(uri); } private static class OutputLoggerThread extends Thread { @@ -345,11 +316,15 @@ public final class CliStarter { public void sendUserInterruptReference() { if (userInterruptReference != null) { try { - final OsSpecificInfo osInfo = getOsInfo(Platform.getOS(), - Platform.getOSArch()); + final OsSpecificInfo osInfo = getOsInfo(Platform.getOS()); final String command = getCliPath() + File.separator + osInfo.subdir + File.separator + osInfo.userInterruptCmd; + + if (osInfo.needsExecutePermission) { + setExecutable(new File(command), true); + } + Runtime.getRuntime().exec( new String[] { command, userInterruptReference.toString() }); @@ -366,15 +341,15 @@ public final class CliStarter { private static class OsSpecificInfo { final String subdir; final String cliName; - final String helperCmd; final String userInterruptCmd; + final boolean needsExecutePermission; public OsSpecificInfo(final String subdir, final String cliName, - final String helperCmd, final String userInterruptCmd) { + final String userInterruptCmd, final boolean needsExecutePermission) { this.subdir = subdir; this.cliName = cliName; - this.helperCmd = helperCmd; this.userInterruptCmd = userInterruptCmd; + this.needsExecutePermission = needsExecutePermission; } } diff --git a/de.prob.core/src/de/prob/core/Animator.java b/de.prob.core/src/de/prob/core/Animator.java index b147a8df738c304b71ccb83b5ed0a944bffa8a74..1d49c94b2ecf95be9d2399d2d66bd8f93285d341 100644 --- a/de.prob.core/src/de/prob/core/Animator.java +++ b/de.prob.core/src/de/prob/core/Animator.java @@ -46,6 +46,7 @@ public final class Animator { */ private IConnectionProvider connectionProvider = null; private volatile boolean dirty; + private volatile boolean rodinProjectHasErrorsOrWarnings; private final Map<Object, Object> dataStore = new HashMap<Object, Object>(); private AnimatorImpl implementation; @@ -290,6 +291,23 @@ public final class Animator { public boolean isDirty() { return dirty; } + + + /** + * Puts the information that the associated Rodin project has errors or warnings. + */ + public void setRodinProjectHasErrorsOrWarnings() { + this.rodinProjectHasErrorsOrWarnings = true; + //System.out.println("** setRodinProjectHasErrorsOrWarnings() !!"); + } + public void resetRodinProjectHasErrorsOrWarnings() { + this.rodinProjectHasErrorsOrWarnings = false; + } + public boolean isRodinProjectHasErrorsOrWarnings() { + return rodinProjectHasErrorsOrWarnings; + } + + public void setMachineDescription( final MachineDescription machineDescription) { @@ -304,10 +322,6 @@ public final class Animator { return getImplementation().isMachineLoaded(); } - public String getDebuggingKey() { - return getImplementation().getDebuggingKey(); - } - public LanguageDependendAnimationPart getLanguageDependendPart() { return getImplementation().getLangdep(); } diff --git a/de.prob.core/src/de/prob/core/IServerConnection.java b/de.prob.core/src/de/prob/core/IServerConnection.java index 45e7155f87a5b2b687d15a1e56afb80650d3bd6c..5b7dc30444cfc344f2a5c36be818110047fa76ba 100644 --- a/de.prob.core/src/de/prob/core/IServerConnection.java +++ b/de.prob.core/src/de/prob/core/IServerConnection.java @@ -43,7 +43,5 @@ public interface IServerConnection { public abstract void startup(File file) throws CliException; - String getDebuggingKey(); - void sendUserInterruptSignal(); } \ No newline at end of file diff --git a/de.prob.core/src/de/prob/core/ProblemHandler.java b/de.prob.core/src/de/prob/core/ProblemHandler.java index 71a053deee6387733df75e02b8398bdd55428155..95d05d591be576cce97080480d1331813d30e5e5 100644 --- a/de.prob.core/src/de/prob/core/ProblemHandler.java +++ b/de.prob.core/src/de/prob/core/ProblemHandler.java @@ -66,12 +66,12 @@ public class ProblemHandler { * The List of Error Messages from ProB * @throws PrologException */ - public static void raisePrologException(final List<String> errors) - throws PrologException { + public static void raisePrologException(final List<String> errors, + final boolean onlyWarnings) throws PrologException { final String message = "ProB reported errors:\n" + StringUtils.join(errors, '\n'); Logger.notifyUser(message); - throw new PrologException(message); + throw new PrologException(message, onlyWarnings); } /** diff --git a/de.prob.core/src/de/prob/core/PrologException.java b/de.prob.core/src/de/prob/core/PrologException.java index f39e0aa8f7c8ce08a4c4de05df6836b4f40c1784..c5ce207798b4811f32dd920a52a64f43b8d60aef 100644 --- a/de.prob.core/src/de/prob/core/PrologException.java +++ b/de.prob.core/src/de/prob/core/PrologException.java @@ -6,13 +6,31 @@ package de.prob.core; +import org.eclipse.core.runtime.IStatus; + import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; public class PrologException extends ProBException { private static final long serialVersionUID = -7087955720127900792L; + private final boolean onlyWarnings; - public PrologException(final String message) { + public PrologException(final String message, final boolean onlyWarnings) { super(message, true); + this.onlyWarnings = onlyWarnings; + } + + @Override + public final void notifyUserOnce() { + if (!handled) { + handled = true; + if (onlyWarnings) { + Logger.log(IStatus.WARNING, Logger.NOBUGREPORT, + this.getMessage(), this); + } else { + Logger.notifyUser(this.getMessage(), this); + } + } } } diff --git a/de.prob.core/src/de/prob/core/command/ActivateUnitPluginCommand.java b/de.prob.core/src/de/prob/core/command/ActivateUnitPluginCommand.java deleted file mode 100644 index 5071e60e1f179908b6a1d438c12b818c408407ac..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/ActivateUnitPluginCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import de.prob.core.Animator; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public class ActivateUnitPluginCommand implements IComposableCommand { - - private static final ActivateCmd ACTIVATE_CMD = new ActivateCmd(); - private final GetPrologRandomSeed getRandomSeed; - private final ComposedCommand cmd; - - public ActivateUnitPluginCommand() { - this.getRandomSeed = new GetPrologRandomSeed(); - this.cmd = new ComposedCommand(getRandomSeed, ACTIVATE_CMD); - } - - public static void activateUnitPlugin(final Animator animator) - throws ProBException { - animator.execute(new ActivateUnitPluginCommand()); - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - cmd.processResult(bindings); - final Animator animator = Animator.getAnimator(); - animator.setRandomSeed(getRandomSeed.getSeed()); - } - - public void writeCommand(final IPrologTermOutput pto) - throws CommandException { - cmd.writeCommand(pto); - } - - private final static class ActivateCmd implements IComposableCommand { - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("activate_plugin"); - pto.printAtom("units"); - pto.closeTerm(); - } - } - -} diff --git a/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java b/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java index 2cd93def1bbdeb6fb119f9c17651256f0359a017..74b12d911446d7d72e2616bfa8bec529b9461717 100644 --- a/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java +++ b/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java @@ -13,15 +13,7 @@ import de.prob.prolog.output.IPrologTermOutput; import de.prob.prolog.term.PrologTerm; public class ClearMachineCommand implements IComposableCommand { - - private static final ClearCmd CLEAR_CMD = new ClearCmd(); - private final GetPrologRandomSeed getRandomSeed; - private final ComposedCommand cmd; - - public ClearMachineCommand() { - this.getRandomSeed = new GetPrologRandomSeed(); - this.cmd = new ComposedCommand(getRandomSeed, CLEAR_CMD); - } + public ClearMachineCommand() {} public static void clearMachine(final Animator animator) throws ProBException { @@ -30,26 +22,9 @@ public class ClearMachineCommand implements IComposableCommand { public void processResult( final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - cmd.processResult(bindings); - final Animator animator = Animator.getAnimator(); - animator.setRandomSeed(getRandomSeed.getSeed()); - } + throws CommandException {} - public void writeCommand(final IPrologTermOutput pto) - throws CommandException { - cmd.writeCommand(pto); + public void writeCommand(final IPrologTermOutput pto) { + pto.openTerm("clear_loaded_machines").closeTerm(); } - - private final static class ClearCmd implements IComposableCommand { - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("clear_loaded_machines").closeTerm(); - } - } - } diff --git a/de.prob.core/src/de/prob/core/command/ComputeCoverageCommand.java b/de.prob.core/src/de/prob/core/command/ComputeCoverageCommand.java index 08c2681708764ba456c5f5c9cbff2f67e7b00137..4561a70602403a57a71c252d8bc2ef849a18e593 100644 --- a/de.prob.core/src/de/prob/core/command/ComputeCoverageCommand.java +++ b/de.prob.core/src/de/prob/core/command/ComputeCoverageCommand.java @@ -29,21 +29,19 @@ public final class ComputeCoverageCommand implements IComposableCommand { private final List<String> nodes = new ArrayList<String>(); private final List<String> uncovered = new ArrayList<String>(); - public ComputeCoverageResult( - final IntegerPrologTerm totalNumberOfNodes, - final IntegerPrologTerm totalNumberOfTransitions, - final ListPrologTerm ops, final ListPrologTerm nodes, + public ComputeCoverageResult(final IntegerPrologTerm totalNumberOfNodes, + final IntegerPrologTerm totalNumberOfTransitions, final ListPrologTerm ops, final ListPrologTerm nodes, final ListPrologTerm uncovered) { this.totalNumberOfNodes = totalNumberOfNodes.getValue(); this.totalNumberOfTransitions = totalNumberOfTransitions.getValue(); for (PrologTerm op : ops) { - this.getOps().add(op.toString()); + this.getOps().add(op.getFunctor()); } for (PrologTerm node : nodes) { - this.getNodes().add(node.toString()); + this.getNodes().add(node.getFunctor()); } for (PrologTerm unc : uncovered) { - this.getUncovered().add(unc.toString()); + this.getUncovered().add(unc.getFunctor()); } } @@ -72,8 +70,7 @@ public final class ComputeCoverageCommand implements IComposableCommand { private ComputeCoverageCommand() { } - public static ComputeCoverageResult getCoverage(final Animator a) - throws ProBException { + public static ComputeCoverageResult getCoverage(final Animator a) throws ProBException { ComputeCoverageCommand computeCoverageCommand = new ComputeCoverageCommand(); a.execute(computeCoverageCommand); return computeCoverageCommand.getResult(); @@ -83,27 +80,23 @@ public final class ComputeCoverageCommand implements IComposableCommand { return coverageResult; } - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { + @Override + public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) throws CommandException { - IntegerPrologTerm totalNodeNr = (IntegerPrologTerm) bindings - .get("TotalNodeNr"); - IntegerPrologTerm totalTransNr = (IntegerPrologTerm) bindings - .get("TotalTransSum"); + IntegerPrologTerm totalNodeNr = (IntegerPrologTerm) bindings.get("TotalNodeNr"); + IntegerPrologTerm totalTransNr = (IntegerPrologTerm) bindings.get("TotalTransSum"); ListPrologTerm ops = (ListPrologTerm) bindings.get("OpStat"); ListPrologTerm nodes = (ListPrologTerm) bindings.get("NodeStat"); ListPrologTerm uncovered = (ListPrologTerm) bindings.get("Uncovered"); - coverageResult = new ComputeCoverageResult(totalNodeNr, totalTransNr, - ops, nodes, uncovered); + coverageResult = new ComputeCoverageResult(totalNodeNr, totalTransNr, ops, nodes, uncovered); } + @Override public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("compute_coverage").printVariable("TotalNodeNr") - .printVariable("TotalTransSum").printVariable("NodeStat") - .printVariable("OpStat").printVariable("Uncovered").closeTerm(); + pto.openTerm("compute_coverage").printVariable("TotalNodeNr").printVariable("TotalTransSum") + .printVariable("NodeStat").printVariable("OpStat").printVariable("Uncovered").closeTerm(); } } diff --git a/de.prob.core/src/de/prob/core/command/ConstraintBasedAssertionCheckCommand.java b/de.prob.core/src/de/prob/core/command/ConstraintBasedAssertionCheckCommand.java index 31439404574680d43e4dc95d1db19147363e8a05..783ea9969f528da1e4144e0f50cac3fc4080aace 100644 --- a/de.prob.core/src/de/prob/core/command/ConstraintBasedAssertionCheckCommand.java +++ b/de.prob.core/src/de/prob/core/command/ConstraintBasedAssertionCheckCommand.java @@ -10,8 +10,7 @@ import de.prob.prolog.term.CompoundPrologTerm; import de.prob.prolog.term.PrologTerm; /** - * This command makes ProB search for a deadlock with an optional predicate to - * limit the search space. + * This command makes ProB search for a violation of the static assertions on constants * * @author plagge */ @@ -71,7 +70,7 @@ public class ConstraintBasedAssertionCheckCommand implements IComposableCommand .toString(); } else throw new CommandException( - "unexpected result from deadlock check: " + resultTerm); + "unexpected result from static assertion check: " + resultTerm); this.result = result; } diff --git a/de.prob.core/src/de/prob/core/command/ConstraintBasedDynamicAssertionCheckCommand.java b/de.prob.core/src/de/prob/core/command/ConstraintBasedDynamicAssertionCheckCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..9da01d1f4197fabe6346430978f6d6cd24bad41c --- /dev/null +++ b/de.prob.core/src/de/prob/core/command/ConstraintBasedDynamicAssertionCheckCommand.java @@ -0,0 +1,77 @@ +/** + * + */ +package de.prob.core.command; + +import de.prob.core.domainobjects.Operation; +import de.prob.parser.ISimplifiedROMap; +import de.prob.prolog.output.IPrologTermOutput; +import de.prob.prolog.term.CompoundPrologTerm; +import de.prob.prolog.term.PrologTerm; + +/** + * This command makes ProB search for a violation of the dynamic assertions on variables + * derived from ConstraintBasedAssertionCheckCommand; one could parameterise it + * @author leuschel + */ +public class ConstraintBasedDynamicAssertionCheckCommand implements IComposableCommand { + + public static enum ResultType { + INTERRUPTED, COUNTER_EXAMPLE, NO_COUNTER_EXAMPLE_FOUND, NO_COUNTER_EXAMPLE_EXISTS + }; + + private static final String COMMAND_NAME = "cbc_dynamic_assertion_violation_checking"; + private static final String RESULT_VARIABLE = "R"; + + private ResultType result; + private Operation counterExampleOperation; + private String counterExampleStateID; + + public ConstraintBasedDynamicAssertionCheckCommand() { + } + + public ResultType getResult() { + return result; + } + + public Operation getCounterExampleOperation() { + return counterExampleOperation; + } + + public String getCounterExampleStateID() { + return counterExampleStateID; + } + + @Override + public void writeCommand(final IPrologTermOutput pto) { + pto.openTerm(COMMAND_NAME); + pto.printVariable(RESULT_VARIABLE); + pto.closeTerm(); + } + + @Override + public void processResult( + final ISimplifiedROMap<String, PrologTerm> bindings) + throws CommandException { + final PrologTerm resultTerm = bindings.get(RESULT_VARIABLE); + final ResultType result; + if (resultTerm.hasFunctor("interrupted", 0)) { + result = ResultType.INTERRUPTED; + } else if (resultTerm.hasFunctor("no_counterexample_found", 0)) { + result = ResultType.NO_COUNTER_EXAMPLE_FOUND; + } else if (resultTerm.hasFunctor("no_counterexample_exists", 0)) { + result = ResultType.NO_COUNTER_EXAMPLE_EXISTS; + } else if (resultTerm.hasFunctor("counterexample_found", 2)) { + result = ResultType.COUNTER_EXAMPLE; + CompoundPrologTerm counterExampleTerm = (CompoundPrologTerm) resultTerm; + counterExampleOperation = Operation + .fromPrologTerm(counterExampleTerm.getArgument(1)); + counterExampleStateID = counterExampleTerm.getArgument(2) + .toString(); + } else + throw new CommandException( + "unexpected result from dynamic assertion check: " + resultTerm); + this.result = result; + + } +} diff --git a/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java b/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java deleted file mode 100644 index a12b0d913e8e0e1a8c92c6bddd407527defa97e5..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog; -import de.be4.classicalb.core.parser.exceptions.BException; -import de.prob.core.Animator; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.State; -import de.prob.core.domainobjects.StateError; -import de.prob.core.domainobjects.Variable; -import de.prob.core.domainobjects.eval.PredicateEvalElement; -import de.prob.core.internal.Activator; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.CompoundPrologTerm; -import de.prob.prolog.term.ListPrologTerm; -import de.prob.prolog.term.PrologTerm; - -/** - * Command to execute an event that has not been enumerated by ProB. - * - * @author Jens Bendisposto - * - */ -public final class ConstructTraceCommand implements IComposableCommand { - - private static final String RESULT_VARIABLE_STATES = "States"; - private static final String RESULT_VARIABLE_OPS = "Ops"; - private static final String RESULT_VARIABLE_ERRORS = "Errors"; - - private final List<PredicateEvalElement> evalElement; - private final List<String> name; - private final List<String> errors = new ArrayList<String>(); - private List<Integer> executionNumber = new ArrayList<Integer>(); - - public ConstructTraceCommand(final List<String> name, - final List<String> predicates, Integer executionNumber) { - this.name = name; - this.evalElement = new ArrayList<PredicateEvalElement>(); - for (String string : predicates) { - try { - evalElement.add(PredicateEvalElement.create(string)); - } catch (BException e) { - throw new IllegalArgumentException( - "Formula must be a predicate: " + string); - } - } - if (name.size() != evalElement.size()) { - throw new IllegalArgumentException( - "Must provide the same number of names and predicates."); - } - int size = this.name.size(); - for (int i = 0; i < size; ++i) { - this.executionNumber.add(executionNumber); - } - } - - public ConstructTraceCommand(final List<String> name, - final List<String> predicate) { - this(name, predicate, 1); - } - - public ConstructTraceCommand(final List<String> name, - final List<String> predicate, final List<Integer> executionNumber) { - this(name, predicate); - this.executionNumber = executionNumber; - if (name.size() != executionNumber.size()) { - throw new IllegalArgumentException( - "Must provide the same number of names and execution numbers."); - } - } - - /** - * This method is called when the command is prepared for sending. The - * method is called by the Animator class, most likely it is not interesting - * for other classes. - * - * @throws ProBException - * - * @see de.prob.animator.command.AbstractCommand#writeCommand(de.prob.prolog.output.IPrologTermOutput) - */ - @Override - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("prob_construct_trace"); - pto.openList(); - for (String n : name) { - pto.printAtom(n); - } - pto.closeList(); - final ASTProlog prolog = new ASTProlog(pto, null); - pto.openList(); - for (PredicateEvalElement cb : evalElement) { - cb.getPrologAst().apply(prolog); - } - pto.closeList(); - pto.openList(); - for (Integer n : executionNumber) { - pto.printNumber(n); - } - pto.closeList(); - pto.printVariable(RESULT_VARIABLE_STATES); - pto.printVariable(RESULT_VARIABLE_OPS); - pto.printVariable(RESULT_VARIABLE_ERRORS); - pto.closeTerm(); - } - - public boolean hasErrors() { - return !errors.isEmpty(); - } - - public List<String> getErrors() { - return errors; - } - - @Override - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - // errors - ListPrologTerm list = (ListPrologTerm) bindings - .get(RESULT_VARIABLE_ERRORS); - for (PrologTerm prologTerm : list) { - errors.add(prologTerm.toString()); - } - - // Change history in Animator ... - // need to reconstruct operations and states - final Animator animator = Animator.getAnimator(); - - ListPrologTerm operations = (ListPrologTerm) bindings - .get(RESULT_VARIABLE_OPS); - ListPrologTerm states = (ListPrologTerm) bindings - .get(RESULT_VARIABLE_STATES); - - for (int i = 0; i < operations.size(); i++) { - PrologTerm operationPrologTerm = operations.get(i); - Operation op = Operation.fromPrologTerm(operationPrologTerm); - - // state(NewStateId,StateValues,Initialised,InvKO,MaxOpsReached,Timeout,OpTimeout,StateErrors,UnsatProps,OperationsForState) - CompoundPrologTerm statePrologTerm = (CompoundPrologTerm) states - .get(i); - - ListPrologTerm stateValuesPrologTerm = (ListPrologTerm) statePrologTerm - .getArgument(2); - List<Variable> stateValues = new LinkedList<Variable>(); - for (PrologTerm prologTerm : stateValuesPrologTerm) { - stateValues.add(new Variable((CompoundPrologTerm) prologTerm)); - } - - ListPrologTerm stateErrorsPrologTerm = (ListPrologTerm) statePrologTerm - .getArgument(8); - Collection<StateError> stateErrors = new LinkedList<StateError>(); - for (PrologTerm prologTerm : stateErrorsPrologTerm) { - stateErrors - .add(new StateError((CompoundPrologTerm) prologTerm)); - } - - Set<String> opTimeouts = new HashSet<String>( - PrologTerm.atomicStrings((ListPrologTerm) statePrologTerm - .getArgument(7))); - - ArrayList<Operation> enabledOperations = new ArrayList<Operation>(); - - for (PrologTerm enop : (ListPrologTerm) statePrologTerm - .getArgument(10)) { - final CompoundPrologTerm cpt = (CompoundPrologTerm) enop; - enabledOperations.add(Operation.fromPrologTerm(cpt)); - } - - State s = new State(statePrologTerm.getArgument(1).toString(), - statePrologTerm.getArgument(2).toString().equals("true"), - statePrologTerm.getArgument(3).toString().equals("true"), - statePrologTerm.getArgument(5).toString().equals("true"), - statePrologTerm.getArgument(4).toString().equals("true"), - stateValues, enabledOperations, stateErrors, opTimeouts); - - Activator.computedState(s); - animator.getHistory().add(s, op); - animator.announceCurrentStateChanged(s, op); - } - - } -} diff --git a/de.prob.core/src/de/prob/core/command/DeserializeStateCommand.java b/de.prob.core/src/de/prob/core/command/DeserializeStateCommand.java deleted file mode 100644 index 6ff95063b24f92b38f263dd9ce7859a7cf534354..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/DeserializeStateCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.prob.core.command; - -import de.prob.core.Animator; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public class DeserializeStateCommand implements IComposableCommand { - - private String id; - private final String state; - - public DeserializeStateCommand(String state) { - this.state = state; - } - - public static String deserialize(Animator a, String state) throws ProBException { - DeserializeStateCommand c = new DeserializeStateCommand(state); - a.execute(c); - return c.id; - } - - @Override - public void processResult(ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - this.id = bindings.get("Id").toString(); - } - - @Override - public void writeCommand(IPrologTermOutput pto) { - pto.openTerm("deserialize").printVariable("Id").printAtom(state).closeTerm(); - } - - public String getId() { - return id; - } - - public String getState() { - return state; - } - -} diff --git a/de.prob.core/src/de/prob/core/command/GetErrorsCommand.java b/de.prob.core/src/de/prob/core/command/GetErrorsCommand.java index 19cad6e471b6f0a544ae90e212a33fb074d71b3a..da31d939a0081f100accd5eb3b88edc2db52cd3c 100644 --- a/de.prob.core/src/de/prob/core/command/GetErrorsCommand.java +++ b/de.prob.core/src/de/prob/core/command/GetErrorsCommand.java @@ -19,8 +19,10 @@ import de.prob.prolog.term.PrologTerm; * @author plagge */ public class GetErrorsCommand implements IComposableCommand { - public static final String ERRORS_VARIABLE = "Errors"; + private static final String ERRORS_VARIABLE = "Errors"; + private static final String ONLY_WARNINGS_VARIABLE = "OnlyWarnings"; private List<String> errors; + private boolean onlyWarnings; @Override public void processResult( @@ -28,16 +30,22 @@ public class GetErrorsCommand implements IComposableCommand { throws CommandException { errors = PrologTerm.atomicStrings((ListPrologTerm) bindings .get(ERRORS_VARIABLE)); + onlyWarnings = "true".equals(bindings.get(ONLY_WARNINGS_VARIABLE) + .getFunctor()); } @Override public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("getErrorMessages").printVariable(ERRORS_VARIABLE) - .closeTerm(); + pto.openTerm("getErrorMessages").printVariable(ONLY_WARNINGS_VARIABLE) + .printVariable(ERRORS_VARIABLE).closeTerm(); } public List<String> getErrors() { return errors; } + public boolean onlyWarningsOccurred() { + return onlyWarnings; + } + } diff --git a/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java b/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java index 51d42750422363ec023d2556f1af61998007dfab..62d7767af6297c27d88a434da524878cd9c332b2 100644 --- a/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java +++ b/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.List; import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog; -import de.be4.classicalb.core.parser.exceptions.BException; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.prob.core.Animator; import de.prob.core.ProblemHandler; import de.prob.core.domainobjects.Operation; @@ -51,7 +51,7 @@ public final class GetOperationByPredicateCommand implements IComposableCommand PredicateEvalElement parsedEvalElement = null; try { parsedEvalElement = PredicateEvalElement.create(predicate); - } catch (BException e) { + } catch (BCompoundException e) { String message = "Fatal error when trying to parse " + predicate + ". Execution of operation " + name + " aborted."; ProblemHandler.raiseCommandException(message); @@ -66,7 +66,7 @@ public final class GetOperationByPredicateCommand implements IComposableCommand */ public static Operation getOperation(final Animator a, final String stateId, final String name, final String predicate) - throws ProBException, BException { + throws ProBException, BCompoundException { List<Operation> operations = getOperations(a, stateId, name, predicate, 1); @@ -91,14 +91,14 @@ public final class GetOperationByPredicateCommand implements IComposableCommand * @param nrOfSolutions * - maximum number of solutions * @return an Operation or null - * @throws BException + * @throws BCompoundException * - if the B predicate contains errors * @throws ProBException * - if something terrible happens ;-) */ public static List<Operation> getOperations(final Animator a, final String stateId, final String name, final String predicate, - final int nrOfSolutions) throws ProBException, BException { + final int nrOfSolutions) throws ProBException, BCompoundException { GetOperationByPredicateCommand executeOperationCommand = new GetOperationByPredicateCommand( stateId, name, predicate, nrOfSolutions); diff --git a/de.prob.core/src/de/prob/core/command/GetPluginResultCommand.java b/de.prob.core/src/de/prob/core/command/GetPluginResultCommand.java deleted file mode 100644 index 7e28630bcfeb68b3da763a24c6bae25b8e93fd85..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/GetPluginResultCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import de.prob.parser.BindingGenerator; -import de.prob.parser.ISimplifiedROMap; -import de.prob.parser.ResultParserException; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.CompoundPrologTerm; -import de.prob.prolog.term.PrologTerm; - -public final class GetPluginResultCommand implements IComposableCommand { - - private final String resultID; - private CompoundPrologTerm result; - - public GetPluginResultCommand(final String resultID) { - this.resultID = resultID; - } - - public CompoundPrologTerm getResult() { - return result; - } - - @Override - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - try { - result = BindingGenerator.getCompoundTerm(bindings.get("Bindings"), - 1); - } catch (ResultParserException e) { - CommandException commandException = new CommandException( - e.getLocalizedMessage(), e); - commandException.notifyUserOnce(); - throw commandException; - } - } - - @Override - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("get_plugin_output").printAtomOrNumber(resultID) - .printVariable("Bindings").closeTerm(); - } - -} diff --git a/de.prob.core/src/de/prob/core/command/GetPrintableAtomsList.java b/de.prob.core/src/de/prob/core/command/GetPrintableAtomsList.java deleted file mode 100644 index 947af6c217e86862f19a347304e0f3092d26674d..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/GetPrintableAtomsList.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.prob.core.command; - -import java.util.List; - -import de.prob.core.Animator; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.ListPrologTerm; -import de.prob.prolog.term.PrologTerm; - -/** - * @author Jens Bendisposto - * - */ -public class GetPrintableAtomsList implements IComposableCommand { - - private static final String PROLOG_VARIABLE = "L"; - private final String prologPredicate; - private List<String> list; - - /** - * Executes the query: prologPredicate(L). Expects L to be a list of - * printable atoms - * - * @param animator - * @param prologPredicate - * @return - * @throws ProBException - */ - - public static List<String> getList(final Animator animator, - final String prologPredicate) throws ProBException { - GetPrintableAtomsList cmd = new GetPrintableAtomsList(prologPredicate); - animator.execute(cmd); - return cmd.getList(); - } - - private List<String> getList() { - return list; - } - - private GetPrintableAtomsList(final String prologPredicate) { - this.prologPredicate = prologPredicate; - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - list = PrologTerm.atomicStrings((ListPrologTerm) bindings - .get(PROLOG_VARIABLE)); - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm(prologPredicate); - pto.printVariable(PROLOG_VARIABLE); - pto.closeTerm(); - } - -} diff --git a/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java b/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java deleted file mode 100644 index 53b952d6a228bba79efd3c63faabee41d038b6a0..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import java.math.BigInteger; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.RandomSeed; -import de.prob.exceptions.ProBException; -import de.prob.parser.BindingGenerator; -import de.prob.parser.ISimplifiedROMap; -import de.prob.parser.ResultParserException; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public final class GetPrologRandomSeed implements IComposableCommand { - - private RandomSeed randomSeed; - - public static RandomSeed getSeed(final Animator a) throws ProBException { - final GetPrologRandomSeed cmd = new GetPrologRandomSeed(); - a.execute(cmd); - return cmd.getSeed(); - } - - public RandomSeed getSeed() { - return randomSeed; - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - BigInteger x, y, z, b; - try { - x = BindingGenerator.getInteger(bindings.get("X")).getValue(); - y = BindingGenerator.getInteger(bindings.get("Y")).getValue(); - z = BindingGenerator.getInteger(bindings.get("Z")).getValue(); - b = BindingGenerator.getInteger(bindings.get("B")).getValue(); - } catch (ResultParserException e) { - CommandException commandException = new CommandException( - e.getLocalizedMessage(), e); - commandException.notifyUserOnce(); - throw commandException; - } - - randomSeed = new RandomSeed(x, y, z, b); - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("get_rand").printVariable("X").printVariable("Y") - .printVariable("Z").printVariable("B").closeTerm(); - } - -} diff --git a/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java b/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java deleted file mode 100644 index 63a26a5793883646e36294c298080ed38bd974e9..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eventb.core.IEventBRoot; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -import de.be4.classicalb.core.parser.BParser; -import de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader; -import de.be4.classicalb.core.parser.exceptions.BException; -import de.be4.classicalb.core.parser.node.Start; -import de.prob.core.Animator; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.ProBPreference; -import de.prob.core.domainobjects.State; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.output.StructuredPrologOutput; -import de.prob.prolog.term.CompoundPrologTerm; -import de.prob.prolog.term.ListPrologTerm; -import de.prob.prolog.term.PrologTerm; - -/** - * Command to load a new Event B Model for animation. - */ -public final class LoadClassicalBModelCommand { - - private static boolean preferencesAlreadyCleanedUp = false; - - private LoadClassicalBModelCommand() { - throw new UnsupportedOperationException("Do not instantiate this class"); - } - - private LoadClassicalBModelCommand(final IEventBRoot model) { - } - - - private static void removeObsoletePreferences(final Animator animator) - throws ProBException { - if (!preferencesAlreadyCleanedUp) { - // get all preference names from ProB - Collection<ProBPreference> prefs = GetPreferencesCommand - .getPreferences(animator); - Set<String> probPrefNames = new HashSet<String>(); - for (ProBPreference probpref : prefs) { - probPrefNames.add(probpref.name); - } - // now check all stored (in Eclipse's store) preferences - // if they still exist - Preferences preferences = SetPreferencesCommand.getPreferences(); - try { - boolean foundObsoletePreference = false; - for (String prefname : preferences.keys()) { - if (!probPrefNames.contains(prefname)) { - // preference does not exists anymore - preferences.remove(prefname); - foundObsoletePreference = true; - String message = "removed obsolete preference from preferences store: " - + prefname; - Logger.info(message); - } - } - if (foundObsoletePreference) { - preferences.flush(); - } - } catch (BackingStoreException e) { - Logger.notifyUser("Error while accessing ProB Preferences", e); - } - preferencesAlreadyCleanedUp = true; - } - } - - public static void load(final Animator animator, final File model, String name) - throws ProBException { - animator.resetDirty(); - removeObsoletePreferences(animator); - - final ClearMachineCommand clear = new ClearMachineCommand(); - final SetPreferencesCommand setPrefs = SetPreferencesCommand - .createSetPreferencesCommand(animator); - final IComposableCommand load = getLoadCommand(model, name); - final StartAnimationCommand start = new StartAnimationCommand(); - final ExploreStateCommand explore = new ExploreStateCommand("root"); - - final ComposedCommand composed = new ComposedCommand(clear, setPrefs, - load, start, explore); - - animator.execute(composed); - - final State commandResult = explore.getState(); - animator.announceCurrentStateChanged(commandResult, - Operation.NULL_OPERATION); - } - - private static IComposableCommand getLoadCommand(final File model, final String name) - throws ProBException { - return new IComposableCommand() { - - @Override - public void writeCommand(final IPrologTermOutput pto) throws CommandException { - pto.openTerm("load_b_project"); - pto.printAtom(name); - pto.printTerm(getLoadTerm(model)); - pto.printVariable("Errors"); - pto.closeTerm(); - pto.printAtom("start_animation"); - } - - @Override - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) { - Animator.getAnimator().announceReset(); - ListPrologTerm e = (ListPrologTerm) bindings.get("Errors"); - if (!e.isEmpty()) { - StringBuffer errormsg = new StringBuffer("Error from Prolog: "); - for (PrologTerm prologTerm : e) { - errormsg.append(prologTerm); - errormsg.append('\n'); - } - Logger.notifyUser(errormsg.toString()); - } - } - }; - - - } - - private static PrologTerm getLoadTerm(final File model) throws CommandException { - BParser bParser = new BParser(); - try { - Start ast = bParser.parseFile(model, false); - final RecursiveMachineLoader rml = new RecursiveMachineLoader( - model.getParent(), null); - rml.loadAllMachines(model, ast, null, bParser.getDefinitions(), null); - StructuredPrologOutput output = new StructuredPrologOutput(); - StructuredPrologOutput out = new StructuredPrologOutput(); - rml.printAsProlog(output); - - Collection<PrologTerm> sentences = output.getSentences(); - out.openList(); - Iterator<PrologTerm> iterator = sentences.iterator(); - iterator.next(); - iterator.next(); - while (iterator.hasNext()) { - CompoundPrologTerm prologTerm = (CompoundPrologTerm) iterator - .next(); - out.printTerm(prologTerm.getArgument(1)); - } - out.closeList(); - out.fullstop(); - return out.getSentences().iterator().next(); - } catch (IOException e) { - Logger.notifyUser("IO Error",e); - throw new CommandException(e.getLocalizedMessage(),e); - } catch (BException e) { - Logger.notifyUser("Parser Error "+e.getLocalizedMessage(),e); - throw new CommandException(e.getLocalizedMessage(),e); - } - } -} diff --git a/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java b/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java index 7a95e7d77046bee597733d5543142987e62ea4a3..4e81cec31e0a2f345c8a5bfcb53a002cf0f3d1df 100644 --- a/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java +++ b/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java @@ -6,15 +6,24 @@ package de.prob.core.command; -import java.util.*; - -import org.eventb.core.*; -import org.osgi.service.prefs.*; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eventb.core.IContextRoot; +import org.eventb.core.IEventBRoot; +import org.eventb.core.IMachineRoot; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; import org.rodinp.core.RodinDBException; -import de.prob.core.*; +import de.prob.core.Animator; +import de.prob.core.LanguageDependendAnimationPart; import de.prob.core.command.internal.InternalLoadCommand; -import de.prob.core.domainobjects.*; +import de.prob.core.domainobjects.MachineDescription; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.ProBPreference; +import de.prob.core.domainobjects.State; import de.prob.core.langdep.EventBAnimatorPart; import de.prob.exceptions.ProBException; import de.prob.logging.Logger; @@ -51,8 +60,7 @@ public final class LoadEventBModelCommand { return false; } - public static PrologTerm toPrologTerm(IEventBRoot model) - throws CommandException { + public static PrologTerm toPrologTerm(IEventBRoot model) throws CommandException { StructuredPrologOutput out = new StructuredPrologOutput(); final InternalLoadCommand load = new InternalLoadCommand(model); @@ -61,45 +69,55 @@ public final class LoadEventBModelCommand { return out.getSentences().iterator().next(); } - public static void load(final Animator animator, final IEventBRoot model) - throws ProBException { + public static void load(final Animator animator, final IEventBRoot model) throws ProBException { boolean context = checkForContexts(model); animator.resetDirty(); + // animator.resetRodinProjectHasErrorsOrWarnings(); // set in StartAnimationHandler; reset here would override this removeObsoletePreferences(animator); final LanguageDependendAnimationPart ldp = new EventBAnimatorPart(model); final ClearMachineCommand clear = new ClearMachineCommand(); - final SetPreferencesCommand setPrefs = SetPreferencesCommand - .createSetPreferencesCommand(animator); + final SetPreferencesCommand setPrefs = SetPreferencesCommand.createSetPreferencesCommand(animator); final InternalLoadCommand load = new InternalLoadCommand(model); final StartAnimationCommand start = new StartAnimationCommand(); - final SetMachineObjectsCommand getMObjects = new SetMachineObjectsCommand( - animator, ldp); + final SetMachineObjectsCommand getMObjects = new SetMachineObjectsCommand(animator, ldp); final ExploreStateCommand explore = new ExploreStateCommand("root"); - final ComposedCommand composed = new ComposedCommand(clear, setPrefs, - load, start, getMObjects, explore); - - animator.execute(composed); - - final State commandResult = explore.getState(); - animator.announceCurrentStateChanged(commandResult, - Operation.NULL_OPERATION); + final ComposedCommand composed = new ComposedCommand(clear, setPrefs, load, start, getMObjects, explore); - if (commandResult.isTimeoutOccured() && context) { - final String message = "A timeout occured when finding constants. Typically this means, that your axioms are too complicated for automatical solving. You might create an animation refinement using the context menu to help ProB finding a solution."; - Logger.notifyUserWithoutBugreport(message); + try { + animator.execute(composed); + + final State commandResult = explore.getState(); + animator.announceCurrentStateChanged(commandResult, Operation.NULL_OPERATION); + + if (commandResult.isTimeoutOccured() && context) { + final String message; + int solsFound = explore.getState().getEnabledOperations().size(); + if (solsFound > 0) { + message = "A timeout occured when finding constants after finding " + solsFound + " solution(s)." + + " Typically this means, that your axioms are too complicated for automatic solving. " + + "You might create an animation refinement using the context menu to help ProB finding all solutions."; + } else { + message = "A timeout occured when finding constants." + + " Typically this means, that your axioms are too complicated for automatic solving. " + + "You might create an animation refinement using the context menu to help ProB finding a solution."; + } + Logger.notifyUserWithoutBugreport(message); + } + } catch (CommandException ex) { + Logger.notifyUser("Event-B Model or Context could not be loaded due to an exception: " + + ex.getMessage() + "\nTry cleaning the Rodin project (Project -> Clean).", + ex); } } - private static void removeObsoletePreferences(final Animator animator) - throws ProBException { + private static void removeObsoletePreferences(final Animator animator) throws ProBException { if (!preferencesAlreadyCleanedUp) { // get all preference names from ProB - Collection<ProBPreference> prefs = GetPreferencesCommand - .getPreferences(animator); + Collection<ProBPreference> prefs = GetPreferencesCommand.getPreferences(animator); Set<String> probPrefNames = new HashSet<String>(); for (ProBPreference probpref : prefs) { probPrefNames.add(probpref.name); @@ -114,8 +132,7 @@ public final class LoadEventBModelCommand { // preference does not exists anymore preferences.remove(prefname); foundObsoletePreference = true; - String message = "removed obsolete preference from preferences store: " - + prefname; + String message = "removed obsolete preference from preferences store: " + prefname; Logger.info(message); } } @@ -129,22 +146,18 @@ public final class LoadEventBModelCommand { } } - private static class SetMachineObjectsCommand extends - GetMachineObjectsCommand { + private static class SetMachineObjectsCommand extends GetMachineObjectsCommand { private final Animator animator; private final LanguageDependendAnimationPart ldp; - public SetMachineObjectsCommand(final Animator animator, - final LanguageDependendAnimationPart ldp) { + public SetMachineObjectsCommand(final Animator animator, final LanguageDependendAnimationPart ldp) { super(); this.animator = animator; this.ldp = ldp; } @Override - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { + public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) throws CommandException { super.processResult(bindings); animator.setMachineDescription(new MachineDescription(getResult())); animator.setLanguageDependendPart(ldp); diff --git a/de.prob.core/src/de/prob/core/command/ModelCheckingSearchOption.java b/de.prob.core/src/de/prob/core/command/ModelCheckingSearchOption.java index a069ac36066918cc13cfb2c394d51efa9b66e551..ef1d93f89f92a0969305715271063d8af5efada4 100644 --- a/de.prob.core/src/de/prob/core/command/ModelCheckingSearchOption.java +++ b/de.prob.core/src/de/prob/core/command/ModelCheckingSearchOption.java @@ -23,7 +23,7 @@ public enum ModelCheckingSearchOption { private final String text; private final int pos; - private final boolean enabledByDefault; + private boolean enabledByDefault; private ModelCheckingSearchOption(final int pos, final String text, final boolean enabledByDefault) { @@ -53,6 +53,10 @@ public enum ModelCheckingSearchOption { return enabledByDefault; } + public final void setEnabledByDefault(boolean val) { + this.enabledByDefault = val; + } + public final static ModelCheckingSearchOption get(final int code) { return lookup.get(code); } diff --git a/de.prob.core/src/de/prob/core/command/SerializeStateCommand.java b/de.prob.core/src/de/prob/core/command/SerializeStateCommand.java deleted file mode 100644 index 7d28161cc2bdbf046f6c74929fabc694c0cb9472..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/SerializeStateCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.prob.core.command; - -import de.prob.core.Animator; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public class SerializeStateCommand implements IComposableCommand { - - private final String id; - private String state; - - public SerializeStateCommand(String id) { - this.id = id; - } - - public static String serialize(Animator a, String stateID) throws ProBException { - SerializeStateCommand c = new SerializeStateCommand(stateID); - a.execute(c); - return c.state; - } - - @Override - public void processResult(ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - state = PrologTerm.atomicString(bindings.get("State")); - } - - @Override - public void writeCommand(IPrologTermOutput pto) { - pto.openTerm("serialize").printAtomOrNumber(id).printVariable("State").closeTerm(); - } - - public String getId() { - return id; - } - - public String getState() { - return state; - } - -} diff --git a/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java b/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java deleted file mode 100644 index 3bed4b7297345f0944ada0f505b592c4396e95cf..0000000000000000000000000000000000000000 --- a/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.RandomSeed; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public final class SetPrologRandomSeed implements IComposableCommand { - - private final RandomSeed seed; - - public SetPrologRandomSeed(final RandomSeed seed) { - this.seed = seed; - } - - public static void setSeed(final Animator a, final RandomSeed seed) - throws ProBException { - SetPrologRandomSeed cmd = new SetPrologRandomSeed(seed); - a.execute(cmd); - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - // no result, nothing to do - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("set_rand"); - pto.printNumber(seed.getSeedX()); - pto.printNumber(seed.getSeedY()); - pto.printNumber(seed.getSeedZ()); - pto.printNumber(seed.getSeedB()); - pto.closeTerm(); - } -} diff --git a/de.prob.core/src/de/prob/core/command/SymmetryReductionOption.java b/de.prob.core/src/de/prob/core/command/SymmetryReductionOption.java index 78c12f2b6e4a6dacf7718af76341a6baf72531c3..4b3df394872a43c76398faefff98379ae99b29ea 100644 --- a/de.prob.core/src/de/prob/core/command/SymmetryReductionOption.java +++ b/de.prob.core/src/de/prob/core/command/SymmetryReductionOption.java @@ -16,6 +16,7 @@ public enum SymmetryReductionOption { private final String description; private final int pos; + private static int selectedOption = 0; private SymmetryReductionOption(final int pos, final String description) { this.pos = pos; @@ -30,6 +31,14 @@ public enum SymmetryReductionOption { return description; } + public final boolean isSelectedOption() { + return selectedOption == this.getPos(); + } + + public static final void setSelectedOption(int option) { + SymmetryReductionOption.selectedOption = option; + } + private static final Map<Integer, SymmetryReductionOption> lookup = new HashMap<Integer, SymmetryReductionOption>(); static { diff --git a/de.prob.core/src/de/prob/core/command/internal/InternalLoadCommand.java b/de.prob.core/src/de/prob/core/command/internal/InternalLoadCommand.java index 2a3eaf98d4fd0b82a4a4718c0878d2366bf08e67..1e98e98c820795d5812c7a9a75232b5ac8b2b525 100644 --- a/de.prob.core/src/de/prob/core/command/internal/InternalLoadCommand.java +++ b/de.prob.core/src/de/prob/core/command/internal/InternalLoadCommand.java @@ -24,7 +24,8 @@ public final class InternalLoadCommand implements IComposableCommand { TranslatorFactory.translate(model, pto); } catch (TranslationFailedException e) { throw new CommandException( - "Translation from Event-B to ProB's internal representation failed", + "Translation from Event-B to ProB's internal representation failed: " + e.getMessage(), + // probably a clean of Rodin project can help; this text is added in LoadEventBModelCommand e); } } diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java index acf76587124350e940e193362ee62224bcf4b6fd..d725f17fd58dda61e3e36be9886ce8df9c77d540 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java +++ b/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java @@ -7,7 +7,7 @@ package de.prob.core.domainobjects.eval; import de.be4.classicalb.core.parser.BParser; -import de.be4.classicalb.core.parser.exceptions.BException; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.be4.classicalb.core.parser.node.Start; import de.prob.core.Animator; import de.prob.core.command.EvaluateRawExpressionsCommand; @@ -30,7 +30,7 @@ public abstract class AbstractEvalElement { public abstract String getLabel(); protected Start parse(final String prefix, final String code) - throws BException { + throws BCompoundException { final BParser parser = new BParser(); final Start modelAst = parser.parse(prefix + code, false); return modelAst; diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java index 02b22f69b7e4db39e10487a95bef3fd9c13ec93f..cb5932d9ee1336e4a0716468bb7b36ece0f35c1a 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java +++ b/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java @@ -9,6 +9,7 @@ package de.prob.core.domainobjects.eval; import org.eventb.core.ast.Expression; import de.be4.classicalb.core.parser.BParser; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.be4.classicalb.core.parser.exceptions.BException; import de.be4.classicalb.core.parser.node.AExpressionParseUnit; import de.be4.classicalb.core.parser.node.EOF; @@ -22,10 +23,10 @@ public final class ExpressionEvalElement extends AbstractEvalElement { private final String expression; public static ExpressionEvalElement fromRodin(final Expression expression) - throws BException { + throws BCompoundException { if (expression == null) { String message = "Expression input must not be null"; - throw new BException("", new NullPointerException(message)); + throw new BCompoundException(new BException("", message, new NullPointerException(message))); } final PExpression expr = TranslationVisitor .translateExpression(expression); @@ -35,11 +36,11 @@ public final class ExpressionEvalElement extends AbstractEvalElement { } public static ExpressionEvalElement create(final String expression) - throws BException { + throws BCompoundException { return new ExpressionEvalElement(expression); } - public ExpressionEvalElement(final String expression) throws BException { + public ExpressionEvalElement(final String expression) throws BCompoundException { this.expression = expression; parse = parse(BParser.EXPRESSION_PREFIX, expression); } diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java index c5589b2a195b8be2c16aa8d9261993a75ac9d5c4..d545f152b7046037976fc8602644d6403677fb89 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java +++ b/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java @@ -10,6 +10,7 @@ import org.eventb.core.ast.Predicate; import de.be4.classicalb.core.parser.BParser; import de.be4.classicalb.core.parser.analysis.DepthFirstAdapter; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.be4.classicalb.core.parser.exceptions.BException; import de.be4.classicalb.core.parser.node.AConjunctPredicate; import de.be4.classicalb.core.parser.node.ADisjunctPredicate; @@ -30,10 +31,10 @@ public class PredicateEvalElement extends AbstractEvalElement { private final String predicate; public static PredicateEvalElement fromRodin(final Predicate predicate) - throws BException { + throws BCompoundException { if (predicate == null) { String message = "Predicate input must not be null"; - throw new BException("", new NullPointerException(message)); + throw new BCompoundException(new BException("", message, new NullPointerException(message))); } final PPredicate apred = TranslationVisitor .translatePredicate(predicate); @@ -43,11 +44,11 @@ public class PredicateEvalElement extends AbstractEvalElement { } public static PredicateEvalElement create(final String predicate) - throws BException { + throws BCompoundException { return new PredicateEvalElement(predicate); } - private PredicateEvalElement(final String predicate) throws BException { + private PredicateEvalElement(final String predicate) throws BCompoundException { this.predicate = predicate; parse = parse(BParser.PREDICATE_PREFIX, predicate); } diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExample.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExample.java index 4c45e0f2ae892af17a5740468fe492d9a6511de1..5d3020a19104faa3ec6fe7cf3dc44e222d34c309 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExample.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExample.java @@ -1,290 +1,294 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; -import de.prob.core.command.LtlCheckingCommand.Result; -import de.prob.core.domainobjects.Operation; -import de.prob.logging.Logger; -import de.prob.prolog.term.CompoundPrologTerm; -import de.prob.prolog.term.IntegerPrologTerm; -import de.prob.prolog.term.ListPrologTerm; -import de.prob.prolog.term.PrologTerm; - -/** - * Provides a counter-example. - * - * @author Andriy Tolstoy - * - */ -public class CounterExample { - private final static PrologTerm NONE = new CompoundPrologTerm("none"); - - private final CounterExampleProposition propositionRoot; - private final List<CounterExampleProposition> propositions = new ArrayList<CounterExampleProposition>(); - private final List<CounterExampleState> states = new ArrayList<CounterExampleState>(); - private final int loopEntry; - private final List<Operation> initPath; - - private final PathType pathType; - private final int ceSize; // the length of the counterexample (number of - // states without the initialisation) - - protected CounterExample(CounterExampleProposition propositionRoot, - int loopEntry, List<Operation> initPath, PathType pathType, - int ceSize) { - super(); - this.propositionRoot = propositionRoot; - this.loopEntry = loopEntry; - this.initPath = initPath; - this.pathType = pathType; - this.ceSize = ceSize; - } - - public CounterExample(final Result modelCheckingResult) { - loopEntry = modelCheckingResult.getLoopEntry(); - pathType = modelCheckingResult.getPathType(); - initPath = Collections.unmodifiableList(Arrays - .asList(modelCheckingResult.getInitPathOps())); - ceSize = modelCheckingResult.getCounterexample().size(); - - final String[] atomicFormulaNames = createAtomicNames(modelCheckingResult); - - final List<ArrayList<Boolean>> predicateValues = createStates(modelCheckingResult - .getCounterexample(), atomicFormulaNames); - - propositionRoot = createExample(modelCheckingResult.getStructure(), - atomicFormulaNames, predicateValues); - propositionRoot.setVisible(true); - Collections.reverse(propositions); - - } - - private String[] createAtomicNames(final Result modelCheckingResult) { - String[] res = new String[modelCheckingResult.getAtomics().size()]; - int i = 0; - for (final PrologTerm term : modelCheckingResult.getAtomics()) { - res[i] = PrologTerm.atomicString(((CompoundPrologTerm) term) - .getArgument(1)); - i++; - } - return res; - } - - private List<ArrayList<Boolean>> createStates(final ListPrologTerm example, String[] atomicFormulaNames) { - List<ArrayList<Boolean>> predicateValues = new ArrayList<ArrayList<Boolean>>(); - - // A bug fix from 31.10.2014: changed the termination condition from - // 'i < example.size()' to 'i < atomicFormulaNames.length'. The statement - // predicateValues.get(i).add(value == 0 ? false : true) in the inner for-loop (lines 98-105) - // crashed once the reported counter-example 'example' had less atoms as atomic propositions, - // e.g. for 'G ({x/=1} & {y<=10})' with 'example = [atom(0,[0,1],none)]' an IndexOutOfBounds-Exception - // had been thrown. Note that the bug-fix has been not thoroughly tested and there may be other issues - // that may occur. - for (int i = 0; i < atomicFormulaNames.length; i++) { - predicateValues.add(new ArrayList<Boolean>()); - } - - int index = 0; - for (PrologTerm exampleElement : example) { - CompoundPrologTerm state = (CompoundPrologTerm) exampleElement; - final PrologTerm stateId = state.getArgument(1); - final ListPrologTerm values = ((ListPrologTerm) state - .getArgument(2)); - final CompoundPrologTerm operationTerm = (CompoundPrologTerm) state - .getArgument(3); - - for (int i = 0; i < values.size(); i++) { - int value = ((IntegerPrologTerm) values.get(i)).getValue() - .intValue(); - // Doesn't have to be a 'predicateValues.get(index)' and not - // 'predicateValues.get(i)' (predicateValues is a list of boolean lists) - //predicateValues.get(index).add(value == 0 ? false : true); - predicateValues.get(i).add(value == 0 ? false : true); - } - - final Operation operation = NONE.equals(operationTerm) ? null - : Operation.fromPrologTerm(operationTerm); - final CounterExampleState ceState = new CounterExampleState(index, - stateId, operation); - states.add(ceState); - index++; - } - - return predicateValues; - } - - private CounterExampleProposition createExample(final PrologTerm structure, - final String[] atomicFormulaNames, - List<ArrayList<Boolean>> predicateValues) { - final CounterExampleProposition proposition; - - CompoundPrologTerm term = (CompoundPrologTerm) structure; - String functor = term.getFunctor(); - int arity = term.getArity(); - - CounterExampleValueType[] values = new CounterExampleValueType[states - .size()]; - - if (arity == 0) { - if (functor.equals("true")) { - Arrays.fill(values, CounterExampleValueType.TRUE); - } else if (functor.equals("false")) { - Arrays.fill(values, CounterExampleValueType.FALSE); - } - - proposition = new CounterExamplePredicate(functor, this, - Arrays.asList(values)); - } else if (arity == 1) { - if (functor.equals("ap") || functor.equals("tp")) { - IntegerPrologTerm atomic = (IntegerPrologTerm) term - .getArgument(1); - int atomicId = atomic.getValue().intValue(); - - final String name = atomicFormulaNames[atomicId]; - - Logger.assertProB("CounterExample invalid", - values.length == predicateValues.get(atomicId).size()); - - for (int i = 0; i < predicateValues.get(atomicId).size(); i++) { - values[i] = predicateValues.get(atomicId).get(i) ? CounterExampleValueType.TRUE - : CounterExampleValueType.FALSE; - } - - proposition = functor.equals("ap") ? new CounterExamplePredicate( - name, this, Arrays.asList(values)) - : new CounterExampleTransition(name, this, - Arrays.asList(values)); - } else { - proposition = createUnaryOperator(atomicFormulaNames, - predicateValues, term, functor); - } - } else if (arity == 2) { - proposition = createBinaryOperator(atomicFormulaNames, - predicateValues, term, functor); - } else { - throw new IllegalArgumentException("Unexpected Prolog LTL " + arity - + "-ary operator " + functor); - } - - propositions.add(proposition); - - return proposition; - } - - private CounterExampleProposition createBinaryOperator( - final String[] atomicFormulaNames, - List<ArrayList<Boolean>> predicateValues, CompoundPrologTerm term, - String functor) { - final CounterExampleProposition proposition; - final CounterExampleProposition firstArgument = createExample( - term.getArgument(1), atomicFormulaNames, predicateValues); - final CounterExampleProposition secondArgument = createExample( - term.getArgument(2), atomicFormulaNames, predicateValues); - - if (functor.equals("and")) { - proposition = new CounterExampleConjunction(this, firstArgument, - secondArgument); - } else if (functor.equals("or")) { - proposition = new CounterExampleDisjunction(this, firstArgument, - secondArgument); - } else if (functor.equals("implies")) { - proposition = new CounterExampleImplication(this, firstArgument, - secondArgument); - } else if (functor.equals("until")) { - proposition = new CounterExampleUntil(this, firstArgument, - secondArgument); - } else if (functor.equals("weakuntil")) { - proposition = new CounterExampleWeakUntil(this, firstArgument, - secondArgument); - } else if (functor.equals("release")) { - proposition = new CounterExampleRelease(this, firstArgument, - secondArgument); - } else if (functor.equals("since")) { - proposition = new CounterExampleSince(this, firstArgument, - secondArgument); - } else if (functor.equals("trigger")) { - proposition = new CounterExampleTrigger(this, firstArgument, - secondArgument); - } else { - throw new IllegalArgumentException( - "Unexpected Prolog LTL binary operator " + functor); - } - - firstArgument.setParent(proposition); - secondArgument.setParent(proposition); - return proposition; - } - - private CounterExampleProposition createUnaryOperator( - final String[] atomicFormulaNames, - List<ArrayList<Boolean>> predicateValues, CompoundPrologTerm term, - String functor) { - final CounterExampleProposition proposition; - final CounterExampleProposition argument = createExample( - term.getArgument(1), atomicFormulaNames, predicateValues); - if (functor.equals("globally")) { - proposition = new CounterExampleGlobally(this, argument); - } else if (functor.equals("finally")) { - proposition = new CounterExampleFinally(this, argument); - } else if (functor.equals("next")) { - proposition = new CounterExampleNext(this, argument); - } else if (functor.equals("not")) { - proposition = new CounterExampleNegation(this, argument); - } else if (functor.equals("once")) { - proposition = new CounterExampleOnce(this, argument); - } else if (functor.equals("yesterday")) { - proposition = new CounterExampleYesterday(this, argument); - } else if (functor.equals("historically")) { - proposition = new CounterExampleHistory(this, argument); - } else { - throw new IllegalArgumentException( - "Unexpected Prolog LTL unary operator " + functor); - } - - argument.setParent(proposition); - return proposition; - } - - public CounterExampleProposition getPropositionRoot() { - return propositionRoot; - } - - public List<CounterExampleProposition> getPropositions() { - return propositions; - } - - public List<CounterExampleState> getStates() { - return states; - } - - public PathType getPathType() { - return pathType; - } - - public int getLoopEntry() { - return loopEntry; - } - - public List<Operation> getFullPath() { - List<Operation> fullPath = new ArrayList<Operation>(initPath); - for (final CounterExampleState ceState : states) { - final Operation operation = ceState.getOperation(); - if (operation != null) { - fullPath.add(operation); - } - } - return fullPath; - } - - public List<Operation> getInitPath() { - return initPath; - } - - public int getCounterExampleSize() { - return ceSize; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; +import de.prob.core.command.LtlCheckingCommand.Result; +import de.prob.core.domainobjects.Operation; +import de.prob.logging.Logger; +import de.prob.prolog.term.CompoundPrologTerm; +import de.prob.prolog.term.IntegerPrologTerm; +import de.prob.prolog.term.ListPrologTerm; +import de.prob.prolog.term.PrologTerm; + +/** + * Provides a counter-example. + * + * @author Andriy Tolstoy + * + */ +public class CounterExample { + private final static PrologTerm NONE = new CompoundPrologTerm("none"); + + private final CounterExampleProposition propositionRoot; + private final List<CounterExampleProposition> propositions = new ArrayList<CounterExampleProposition>(); + private final List<CounterExampleState> states = new ArrayList<CounterExampleState>(); + private final int loopEntry; + private final List<Operation> initPath; + + private final PathType pathType; + private final int ceSize; // the length of the counterexample (number of + // states without the initialisation) + + protected CounterExample(CounterExampleProposition propositionRoot, + int loopEntry, List<Operation> initPath, PathType pathType, + int ceSize) { + super(); + this.propositionRoot = propositionRoot; + this.loopEntry = loopEntry; + this.initPath = initPath; + this.pathType = pathType; + this.ceSize = ceSize; + } + + public CounterExample(final Result modelCheckingResult) { + loopEntry = modelCheckingResult.getLoopEntry(); + pathType = modelCheckingResult.getPathType(); + initPath = Collections.unmodifiableList(Arrays + .asList(modelCheckingResult.getInitPathOps())); + ceSize = modelCheckingResult.getCounterexample().size(); + + final String[] atomicFormulaNames = createAtomicNames(modelCheckingResult); + + final List<ArrayList<Boolean>> predicateValues = createStates(modelCheckingResult + .getCounterexample(), atomicFormulaNames); + + propositionRoot = createExample(modelCheckingResult.getStructure(), + atomicFormulaNames, predicateValues); + propositionRoot.setVisible(true); + Collections.reverse(propositions); + + } + + private String[] createAtomicNames(final Result modelCheckingResult) { + String[] res = new String[modelCheckingResult.getAtomics().size()]; + int i = 0; + for (final PrologTerm term : modelCheckingResult.getAtomics()) { + res[i] = PrologTerm.atomicString(((CompoundPrologTerm) term) + .getArgument(1)); + i++; + } + return res; + } + + private List<ArrayList<Boolean>> createStates(final ListPrologTerm example, String[] atomicFormulaNames) { + List<ArrayList<Boolean>> predicateValues = new ArrayList<ArrayList<Boolean>>(); + + // A bug fix from 31.10.2014: changed the termination condition from + // 'i < example.size()' to 'i < atomicFormulaNames.length'. The statement + // predicateValues.get(i).add(value == 0 ? false : true) in the inner for-loop (lines 98-105) + // crashed once the reported counter-example 'example' had less atoms as atomic propositions, + // e.g. for 'G ({x/=1} & {y<=10})' with 'example = [atom(0,[0,1],none)]' an IndexOutOfBounds-Exception + // had been thrown. Note that the bug-fix has been not thoroughly tested and there may be other issues + // that may occur. + for (int i = 0; i < atomicFormulaNames.length; i++) { + predicateValues.add(new ArrayList<Boolean>()); + } + + int index = 0; + for (PrologTerm exampleElement : example) { + CompoundPrologTerm state = (CompoundPrologTerm) exampleElement; + final PrologTerm stateId = state.getArgument(1); + final ListPrologTerm values = ((ListPrologTerm) state + .getArgument(2)); + final CompoundPrologTerm operationTerm = (CompoundPrologTerm) state + .getArgument(3); + + for (int i = 0; i < values.size(); i++) { + int value = ((IntegerPrologTerm) values.get(i)).getValue() + .intValue(); + // Doesn't have to be a 'predicateValues.get(index)' and not + // 'predicateValues.get(i)' (predicateValues is a list of boolean lists) + //predicateValues.get(index).add(value == 0 ? false : true); + predicateValues.get(i).add(value == 0 ? false : true); + } + + final Operation operation = NONE.equals(operationTerm) ? null + : Operation.fromPrologTerm(operationTerm); + final CounterExampleState ceState = new CounterExampleState(index, + stateId, operation); + states.add(ceState); + index++; + } + + return predicateValues; + } + + private CounterExampleProposition createExample(final PrologTerm structure, + final String[] atomicFormulaNames, + List<ArrayList<Boolean>> predicateValues) { + final CounterExampleProposition proposition; + + CompoundPrologTerm term = (CompoundPrologTerm) structure; + String functor = term.getFunctor(); + int arity = term.getArity(); + + CounterExampleValueType[] values = new CounterExampleValueType[states + .size()]; + + if (arity == 0) { + if (functor.equals("true")) { + Arrays.fill(values, CounterExampleValueType.TRUE); + } else if (functor.equals("false")) { + Arrays.fill(values, CounterExampleValueType.FALSE); + } + + proposition = new CounterExamplePredicate(functor, this, + Arrays.asList(values)); + } else if (arity == 1) { + if (functor.equals("ap") || functor.equals("tp")) { + IntegerPrologTerm atomic = (IntegerPrologTerm) term + .getArgument(1); + int atomicId = atomic.getValue().intValue(); + + final String name = atomicFormulaNames[atomicId]; + + int atomicIdSize = predicateValues.get(atomicId).size(); + + Logger.assertProB("CounterExampleProposition invalid, expected values.length = " + + values.length + ", got term with: " + atomicIdSize + + " values; Prolog term = " + term.toString(), + values.length == atomicIdSize); + + for (int i = 0; i < atomicIdSize; i++) { + values[i] = predicateValues.get(atomicId).get(i) ? CounterExampleValueType.TRUE + : CounterExampleValueType.FALSE; + } + + proposition = functor.equals("ap") ? new CounterExamplePredicate( + name, this, Arrays.asList(values)) + : new CounterExampleTransition(name, this, + Arrays.asList(values)); + } else { + proposition = createUnaryOperator(atomicFormulaNames, + predicateValues, term, functor); + } + } else if (arity == 2) { + proposition = createBinaryOperator(atomicFormulaNames, + predicateValues, term, functor); + } else { + throw new IllegalArgumentException("Unexpected Prolog LTL " + arity + + "-ary operator " + functor); + } + + propositions.add(proposition); + + return proposition; + } + + private CounterExampleProposition createBinaryOperator( + final String[] atomicFormulaNames, + List<ArrayList<Boolean>> predicateValues, CompoundPrologTerm term, + String functor) { + final CounterExampleProposition proposition; + final CounterExampleProposition firstArgument = createExample( + term.getArgument(1), atomicFormulaNames, predicateValues); + final CounterExampleProposition secondArgument = createExample( + term.getArgument(2), atomicFormulaNames, predicateValues); + + if (functor.equals("and")) { + proposition = new CounterExampleConjunction(this, firstArgument, + secondArgument); + } else if (functor.equals("or")) { + proposition = new CounterExampleDisjunction(this, firstArgument, + secondArgument); + } else if (functor.equals("implies")) { + proposition = new CounterExampleImplication(this, firstArgument, + secondArgument); + } else if (functor.equals("until")) { + proposition = new CounterExampleUntil(this, firstArgument, + secondArgument); + } else if (functor.equals("weakuntil")) { + proposition = new CounterExampleWeakUntil(this, firstArgument, + secondArgument); + } else if (functor.equals("release")) { + proposition = new CounterExampleRelease(this, firstArgument, + secondArgument); + } else if (functor.equals("since")) { + proposition = new CounterExampleSince(this, firstArgument, + secondArgument); + } else if (functor.equals("trigger")) { + proposition = new CounterExampleTrigger(this, firstArgument, + secondArgument); + } else { + throw new IllegalArgumentException( + "Unexpected Prolog LTL binary operator " + functor); + } + + firstArgument.setParent(proposition); + secondArgument.setParent(proposition); + return proposition; + } + + private CounterExampleProposition createUnaryOperator( + final String[] atomicFormulaNames, + List<ArrayList<Boolean>> predicateValues, CompoundPrologTerm term, + String functor) { + final CounterExampleProposition proposition; + final CounterExampleProposition argument = createExample( + term.getArgument(1), atomicFormulaNames, predicateValues); + if (functor.equals("globally")) { + proposition = new CounterExampleGlobally(this, argument); + } else if (functor.equals("finally")) { + proposition = new CounterExampleFinally(this, argument); + } else if (functor.equals("next")) { + proposition = new CounterExampleNext(this, argument); + } else if (functor.equals("not")) { + proposition = new CounterExampleNegation(this, argument); + } else if (functor.equals("once")) { + proposition = new CounterExampleOnce(this, argument); + } else if (functor.equals("yesterday")) { + proposition = new CounterExampleYesterday(this, argument); + } else if (functor.equals("historically")) { + proposition = new CounterExampleHistory(this, argument); + } else { + throw new IllegalArgumentException( + "Unexpected Prolog LTL unary operator " + functor); + } + + argument.setParent(proposition); + return proposition; + } + + public CounterExampleProposition getPropositionRoot() { + return propositionRoot; + } + + public List<CounterExampleProposition> getPropositions() { + return propositions; + } + + public List<CounterExampleState> getStates() { + return states; + } + + public PathType getPathType() { + return pathType; + } + + public int getLoopEntry() { + return loopEntry; + } + + public List<Operation> getFullPath() { + List<Operation> fullPath = new ArrayList<Operation>(initPath); + for (final CounterExampleState ceState : states) { + final Operation operation = ceState.getOperation(); + if (operation != null) { + fullPath.add(operation); + } + } + return fullPath; + } + + public List<Operation> getInitPath() { + return initPath; + } + + public int getCounterExampleSize() { + return ceSize; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleBinaryOperator.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleBinaryOperator.java index 79f2f924ff62689ebda1f01a56f3b04294453013..04041bcfe43f139f20ca51c6ff4956e7f58f2381 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleBinaryOperator.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleBinaryOperator.java @@ -1,124 +1,124 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -import de.prob.logging.Logger; - -/** - * Provides operators with two parameters. - * - * @author Andriy Tolstoy - * - */ -public abstract class CounterExampleBinaryOperator extends - CounterExampleProposition { - protected final CounterExampleProposition firstArgument; - protected final CounterExampleProposition secondArgument; - protected List<List<Integer>> firstHighlightedPositions = new ArrayList<List<Integer>>(); - protected List<List<Integer>> secondHighlightedPositions = new ArrayList<List<Integer>>(); - - public CounterExampleBinaryOperator(final String name, - final String fullName, final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super(name, fullName, counterExample); - this.firstArgument = firstArgument; - this.secondArgument = secondArgument; - } - - protected abstract CounterExampleValueType calculate(int position); - - @Override - protected List<CounterExampleValueType> calculate() { - final List<CounterExampleValueType> first = firstArgument.getValues(); - final List<CounterExampleValueType> second = secondArgument.getValues(); - final int size = first.size(); - - Logger.assertProB("Sizes of traces do not match", size == second.size()); - - final List<CounterExampleValueType> values = new ArrayList<CounterExampleValueType>(); - - for (int i = 0; i < size; i++) { - values.add(calculate(i)); - } - - return values; - } - - @Override - public boolean hasChildren() { - return true; - } - - @Override - public List<CounterExampleProposition> getChildren() { - List<CounterExampleProposition> children = super.getChildren(); - children.addAll(firstArgument.getChildren()); - children.addAll(secondArgument.getChildren()); - return children; - } - - public CounterExampleProposition getFirstArgument() { - return firstArgument; - } - - public CounterExampleProposition getSecondArgument() { - return secondArgument; - } - - public List<List<Integer>> getFirstHighlightedPositions() { - return firstHighlightedPositions; - } - - public List<List<Integer>> getSecondHighlightedPositions() { - return secondHighlightedPositions; - } - - @Override - public String toString() { - return new StringBuilder("(" + firstArgument + ")") - .append(" " + name + " ").append("(" + secondArgument + ")") - .toString(); - } - - protected void fillHighlightedPositions(final int position, - final int firstIndex, final int secondIndex, - final int firstCheckedSize, int secondCheckedSize, boolean isPast) { - firstHighlightedPositions.add(fillPositions(position, firstIndex, - firstCheckedSize, isPast)); - secondHighlightedPositions.add(fillPositions(position, secondIndex, - secondCheckedSize, isPast)); - } - - protected int indexOfUnknownState( - final List<CounterExampleValueType> firstCheckedValues, - final List<CounterExampleValueType> secondCheckedValues, - boolean past) { - int unknownStateIndex = -1; - - if (past) { - for (int i = firstCheckedValues.size() - 1; i >= 0; i--) { - if (firstCheckedValues.get(i).equals( - CounterExampleValueType.UNKNOWN) - && secondCheckedValues.get(i).equals( - CounterExampleValueType.UNKNOWN)) { - unknownStateIndex = i; - break; - } - } - } else { - for (int i = 0; i < firstCheckedValues.size(); i++) { - if (firstCheckedValues.get(i).equals( - CounterExampleValueType.UNKNOWN) - && secondCheckedValues.get(i).equals( - CounterExampleValueType.UNKNOWN)) { - unknownStateIndex = i; - break; - } - } - } - - return unknownStateIndex; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +import de.prob.logging.Logger; + +/** + * Provides operators with two parameters. + * + * @author Andriy Tolstoy + * + */ +public abstract class CounterExampleBinaryOperator extends + CounterExampleProposition { + protected final CounterExampleProposition firstArgument; + protected final CounterExampleProposition secondArgument; + protected List<List<Integer>> firstHighlightedPositions = new ArrayList<List<Integer>>(); + protected List<List<Integer>> secondHighlightedPositions = new ArrayList<List<Integer>>(); + + public CounterExampleBinaryOperator(final String name, + final String fullName, final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super(name, fullName, counterExample); + this.firstArgument = firstArgument; + this.secondArgument = secondArgument; + } + + protected abstract CounterExampleValueType calculate(int position); + + @Override + protected List<CounterExampleValueType> calculate() { + final List<CounterExampleValueType> first = firstArgument.getValues(); + final List<CounterExampleValueType> second = secondArgument.getValues(); + final int size = first.size(); + + Logger.assertProB("Sizes of traces do not match", size == second.size()); + + final List<CounterExampleValueType> values = new ArrayList<CounterExampleValueType>(); + + for (int i = 0; i < size; i++) { + values.add(calculate(i)); + } + + return values; + } + + @Override + public boolean hasChildren() { + return true; + } + + @Override + public List<CounterExampleProposition> getChildren() { + List<CounterExampleProposition> children = super.getChildren(); + children.addAll(firstArgument.getChildren()); + children.addAll(secondArgument.getChildren()); + return children; + } + + public CounterExampleProposition getFirstArgument() { + return firstArgument; + } + + public CounterExampleProposition getSecondArgument() { + return secondArgument; + } + + public List<List<Integer>> getFirstHighlightedPositions() { + return firstHighlightedPositions; + } + + public List<List<Integer>> getSecondHighlightedPositions() { + return secondHighlightedPositions; + } + + @Override + public String toString() { + return new StringBuilder("(" + firstArgument + ")") + .append(" " + name + " ").append("(" + secondArgument + ")") + .toString(); + } + + protected void fillHighlightedPositions(final int position, + final int firstIndex, final int secondIndex, + final int firstCheckedSize, int secondCheckedSize, boolean isPast) { + firstHighlightedPositions.add(fillPositions(position, firstIndex, + firstCheckedSize, isPast)); + secondHighlightedPositions.add(fillPositions(position, secondIndex, + secondCheckedSize, isPast)); + } + + protected int indexOfUnknownState( + final List<CounterExampleValueType> firstCheckedValues, + final List<CounterExampleValueType> secondCheckedValues, + boolean past) { + int unknownStateIndex = -1; + + if (past) { + for (int i = firstCheckedValues.size() - 1; i >= 0; i--) { + if (firstCheckedValues.get(i).equals( + CounterExampleValueType.UNKNOWN) + && secondCheckedValues.get(i).equals( + CounterExampleValueType.UNKNOWN)) { + unknownStateIndex = i; + break; + } + } + } else { + for (int i = 0; i < firstCheckedValues.size(); i++) { + if (firstCheckedValues.get(i).equals( + CounterExampleValueType.UNKNOWN) + && secondCheckedValues.get(i).equals( + CounterExampleValueType.UNKNOWN)) { + unknownStateIndex = i; + break; + } + } + } + + return unknownStateIndex; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleConjunction.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleConjunction.java index e72430bc8dfb91508528e4317bbcda5164aba1cf..65b95f71a1ea9763e81aa11b57a92eac43e3fdf1 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleConjunction.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleConjunction.java @@ -1,72 +1,72 @@ -package de.prob.core.domainobjects.ltl; - - -/** - * Provides an "and" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleConjunction extends - CounterExampleBinaryOperator { - public CounterExampleConjunction(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("and", "Conjunction", counterExample, firstArgument, - secondArgument); - addCheckByDeMorgan(counterExample, firstArgument, secondArgument); - } - - private void addCheckByDeMorgan(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - CounterExampleNegation notFirstArgument = new CounterExampleNegation( - counterExample, firstArgument); - CounterExampleNegation notSecondArgument = new CounterExampleNegation( - counterExample, secondArgument); - CounterExampleDisjunction or = new CounterExampleDisjunction( - counterExample, notFirstArgument, notSecondArgument); - addCheck(new CounterExampleNegation(counterExample, or)); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType firstValue = getFirstArgument().getValues() - .get(position); - CounterExampleValueType secondValue = getSecondArgument().getValues() - .get(position); - - int firstCheckedSize = 1; - int secondCheckedSize = 1; - - if (firstValue == CounterExampleValueType.FALSE) { - secondCheckedSize = 0; - } else if (secondValue == CounterExampleValueType.FALSE) { - firstCheckedSize = 0; - } - - fillHighlightedPositions(position, -1, -1, firstCheckedSize, - secondCheckedSize, false); - - CounterExampleValueType value = calculateAnd(firstValue, secondValue); - - return value; - } - - public static CounterExampleValueType calculateAnd( - final CounterExampleValueType firstValue, - final CounterExampleValueType secondValue) { - CounterExampleValueType result = CounterExampleValueType.TRUE; - - if (firstValue == CounterExampleValueType.FALSE - || secondValue == CounterExampleValueType.FALSE) { - result = CounterExampleValueType.FALSE; - } else if (firstValue == CounterExampleValueType.UNKNOWN - || secondValue == CounterExampleValueType.UNKNOWN) { - result = CounterExampleValueType.UNKNOWN; - } - - return result; - } -} +package de.prob.core.domainobjects.ltl; + + +/** + * Provides an "and" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleConjunction extends + CounterExampleBinaryOperator { + public CounterExampleConjunction(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("and", "Conjunction", counterExample, firstArgument, + secondArgument); + addCheckByDeMorgan(counterExample, firstArgument, secondArgument); + } + + private void addCheckByDeMorgan(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + CounterExampleNegation notFirstArgument = new CounterExampleNegation( + counterExample, firstArgument); + CounterExampleNegation notSecondArgument = new CounterExampleNegation( + counterExample, secondArgument); + CounterExampleDisjunction or = new CounterExampleDisjunction( + counterExample, notFirstArgument, notSecondArgument); + addCheck(new CounterExampleNegation(counterExample, or)); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType firstValue = getFirstArgument().getValues() + .get(position); + CounterExampleValueType secondValue = getSecondArgument().getValues() + .get(position); + + int firstCheckedSize = 1; + int secondCheckedSize = 1; + + if (firstValue == CounterExampleValueType.FALSE) { + secondCheckedSize = 0; + } else if (secondValue == CounterExampleValueType.FALSE) { + firstCheckedSize = 0; + } + + fillHighlightedPositions(position, -1, -1, firstCheckedSize, + secondCheckedSize, false); + + CounterExampleValueType value = calculateAnd(firstValue, secondValue); + + return value; + } + + public static CounterExampleValueType calculateAnd( + final CounterExampleValueType firstValue, + final CounterExampleValueType secondValue) { + CounterExampleValueType result = CounterExampleValueType.TRUE; + + if (firstValue == CounterExampleValueType.FALSE + || secondValue == CounterExampleValueType.FALSE) { + result = CounterExampleValueType.FALSE; + } else if (firstValue == CounterExampleValueType.UNKNOWN + || secondValue == CounterExampleValueType.UNKNOWN) { + result = CounterExampleValueType.UNKNOWN; + } + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleDisjunction.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleDisjunction.java index b6fb4a141d41be99fc4e51f4cf938be73ae61d6d..131ed6c84cfefac6ff1e8e5b814ffa335ac68152 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleDisjunction.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleDisjunction.java @@ -1,57 +1,57 @@ -package de.prob.core.domainobjects.ltl; - - -/** - * Provides an "or" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleDisjunction extends - CounterExampleBinaryOperator { - public CounterExampleDisjunction(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("or", "Disjunction", counterExample, firstArgument, - secondArgument); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType firstValue = getFirstArgument().getValues() - .get(position); - CounterExampleValueType secondValue = getSecondArgument().getValues() - .get(position); - - int firstCheckedSize = 1; - int secondCheckedSize = 1; - - if (firstValue == CounterExampleValueType.TRUE) { - secondCheckedSize = 0; - } else if (secondValue == CounterExampleValueType.TRUE) { - firstCheckedSize = 0; - } - - fillHighlightedPositions(position, -1, -1, firstCheckedSize, - secondCheckedSize, false); - - return calculateOr(firstValue, secondValue); - } - - public static CounterExampleValueType calculateOr( - final CounterExampleValueType firstValue, - final CounterExampleValueType secondValue) { - CounterExampleValueType result = CounterExampleValueType.FALSE; - - if (firstValue == CounterExampleValueType.TRUE - || secondValue == CounterExampleValueType.TRUE) { - result = CounterExampleValueType.TRUE; - } else if (firstValue == CounterExampleValueType.UNKNOWN - || secondValue == CounterExampleValueType.UNKNOWN) { - result = CounterExampleValueType.UNKNOWN; - } - - return result; - } -} +package de.prob.core.domainobjects.ltl; + + +/** + * Provides an "or" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleDisjunction extends + CounterExampleBinaryOperator { + public CounterExampleDisjunction(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("or", "Disjunction", counterExample, firstArgument, + secondArgument); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType firstValue = getFirstArgument().getValues() + .get(position); + CounterExampleValueType secondValue = getSecondArgument().getValues() + .get(position); + + int firstCheckedSize = 1; + int secondCheckedSize = 1; + + if (firstValue == CounterExampleValueType.TRUE) { + secondCheckedSize = 0; + } else if (secondValue == CounterExampleValueType.TRUE) { + firstCheckedSize = 0; + } + + fillHighlightedPositions(position, -1, -1, firstCheckedSize, + secondCheckedSize, false); + + return calculateOr(firstValue, secondValue); + } + + public static CounterExampleValueType calculateOr( + final CounterExampleValueType firstValue, + final CounterExampleValueType secondValue) { + CounterExampleValueType result = CounterExampleValueType.FALSE; + + if (firstValue == CounterExampleValueType.TRUE + || secondValue == CounterExampleValueType.TRUE) { + result = CounterExampleValueType.TRUE; + } else if (firstValue == CounterExampleValueType.UNKNOWN + || secondValue == CounterExampleValueType.UNKNOWN) { + result = CounterExampleValueType.UNKNOWN; + } + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleFinally.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleFinally.java index 90d6954c55c69e5cb26018f1af17e0cbd7781a6b..426db69ae9d23e83d57ae9def8c536ceb09037d9 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleFinally.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleFinally.java @@ -1,65 +1,65 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides a "finally" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleFinally extends CounterExampleUnaryOperator { - public CounterExampleFinally(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("F", "Finally", counterExample, argument); - checkByUntil(counterExample, argument); - } - - private void checkByUntil(final CounterExample counterExample, - final CounterExampleProposition argument) { - CounterExampleValueType[] firstValues = new CounterExampleValueType[argument - .getValues().size()]; - Arrays.fill(firstValues, CounterExampleValueType.TRUE); - - CounterExamplePredicate first = new CounterExamplePredicate("", - counterExample, Arrays.asList(firstValues)); - - addCheck(new CounterExampleUntil(counterExample, first, argument)); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - checkedValues.addAll(checkedValues.subList(loopEntry, position)); - } - - // remove all past values - checkedValues = checkedValues.subList(position, checkedValues.size()); - - // look for a state with a true value - int index = checkedValues.indexOf(CounterExampleValueType.TRUE); - - if (index != -1) { - result = CounterExampleValueType.TRUE; - } else { - if (pathType != PathType.REDUCED) { - result = CounterExampleValueType.FALSE; - } - } - - fillHighlightedPositions(position, index, checkedValues.size(), false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides a "finally" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleFinally extends CounterExampleUnaryOperator { + public CounterExampleFinally(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("F", "Finally", counterExample, argument); + checkByUntil(counterExample, argument); + } + + private void checkByUntil(final CounterExample counterExample, + final CounterExampleProposition argument) { + CounterExampleValueType[] firstValues = new CounterExampleValueType[argument + .getValues().size()]; + Arrays.fill(firstValues, CounterExampleValueType.TRUE); + + CounterExamplePredicate first = new CounterExamplePredicate("", + counterExample, Arrays.asList(firstValues)); + + addCheck(new CounterExampleUntil(counterExample, first, argument)); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + checkedValues.addAll(checkedValues.subList(loopEntry, position)); + } + + // remove all past values + checkedValues = checkedValues.subList(position, checkedValues.size()); + + // look for a state with a true value + int index = checkedValues.indexOf(CounterExampleValueType.TRUE); + + if (index != -1) { + result = CounterExampleValueType.TRUE; + } else { + if (pathType != PathType.REDUCED) { + result = CounterExampleValueType.FALSE; + } + } + + fillHighlightedPositions(position, index, checkedValues.size(), false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleGlobally.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleGlobally.java index b6f5fe4358d22263847ee8e7b5c6edb592e35467..46daea8c31b98a2e7b704193e0a4238cc46ac018 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleGlobally.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleGlobally.java @@ -1,94 +1,94 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides a "globally" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleGlobally extends CounterExampleUnaryOperator { - public CounterExampleGlobally(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("G", "Globally", counterExample, argument); - - checkByRelease(counterExample, argument); - CounterExampleNegation notArgument = new CounterExampleNegation( - counterExample, argument); - checkByFinally(counterExample, notArgument); - checkByUntil(counterExample, argument, notArgument); - } - - private void checkByUntil(final CounterExample counterExample, - final CounterExampleProposition argument, - CounterExampleNegation notArgument) { - CounterExampleValueType[] trueValues = new CounterExampleValueType[argument - .getValues().size()]; - Arrays.fill(trueValues, CounterExampleValueType.TRUE); - - CounterExamplePredicate truePredicate = new CounterExamplePredicate("", - counterExample, Arrays.asList(trueValues)); - - CounterExampleUntil until = new CounterExampleUntil(counterExample, - truePredicate, notArgument); - addCheck(new CounterExampleNegation(counterExample, until)); - } - - private void checkByFinally(final CounterExample counterExample, - CounterExampleNegation notArgument) { - CounterExampleFinally finallyOperator = new CounterExampleFinally( - counterExample, notArgument); - - addCheck(new CounterExampleNegation(counterExample, finallyOperator)); - } - - private void checkByRelease(final CounterExample counterExample, - final CounterExampleProposition argument) { - CounterExampleValueType[] falseValues = new CounterExampleValueType[argument - .getValues().size()]; - Arrays.fill(falseValues, CounterExampleValueType.FALSE); - - CounterExamplePredicate falsePredicate = new CounterExamplePredicate( - "", counterExample, Arrays.asList(falseValues)); - - addCheck(new CounterExampleRelease(counterExample, falsePredicate, - argument)); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - checkedValues.addAll(checkedValues.subList(loopEntry, position)); - } - - // remove all past values - checkedValues = checkedValues.subList(position, checkedValues.size()); - - // look for a state with a false value - int index = checkedValues.indexOf(CounterExampleValueType.FALSE); - - if (index != -1) { - result = CounterExampleValueType.FALSE; - } else { - if (pathType != PathType.REDUCED) { - result = CounterExampleValueType.TRUE; - } - } - - fillHighlightedPositions(position, index, checkedValues.size(), false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides a "globally" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleGlobally extends CounterExampleUnaryOperator { + public CounterExampleGlobally(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("G", "Globally", counterExample, argument); + + checkByRelease(counterExample, argument); + CounterExampleNegation notArgument = new CounterExampleNegation( + counterExample, argument); + checkByFinally(counterExample, notArgument); + checkByUntil(counterExample, argument, notArgument); + } + + private void checkByUntil(final CounterExample counterExample, + final CounterExampleProposition argument, + CounterExampleNegation notArgument) { + CounterExampleValueType[] trueValues = new CounterExampleValueType[argument + .getValues().size()]; + Arrays.fill(trueValues, CounterExampleValueType.TRUE); + + CounterExamplePredicate truePredicate = new CounterExamplePredicate("", + counterExample, Arrays.asList(trueValues)); + + CounterExampleUntil until = new CounterExampleUntil(counterExample, + truePredicate, notArgument); + addCheck(new CounterExampleNegation(counterExample, until)); + } + + private void checkByFinally(final CounterExample counterExample, + CounterExampleNegation notArgument) { + CounterExampleFinally finallyOperator = new CounterExampleFinally( + counterExample, notArgument); + + addCheck(new CounterExampleNegation(counterExample, finallyOperator)); + } + + private void checkByRelease(final CounterExample counterExample, + final CounterExampleProposition argument) { + CounterExampleValueType[] falseValues = new CounterExampleValueType[argument + .getValues().size()]; + Arrays.fill(falseValues, CounterExampleValueType.FALSE); + + CounterExamplePredicate falsePredicate = new CounterExamplePredicate( + "", counterExample, Arrays.asList(falseValues)); + + addCheck(new CounterExampleRelease(counterExample, falsePredicate, + argument)); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + checkedValues.addAll(checkedValues.subList(loopEntry, position)); + } + + // remove all past values + checkedValues = checkedValues.subList(position, checkedValues.size()); + + // look for a state with a false value + int index = checkedValues.indexOf(CounterExampleValueType.FALSE); + + if (index != -1) { + result = CounterExampleValueType.FALSE; + } else { + if (pathType != PathType.REDUCED) { + result = CounterExampleValueType.TRUE; + } + } + + fillHighlightedPositions(position, index, checkedValues.size(), false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleHistory.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleHistory.java index d8479d1de5d2e1ecae1b92ed6a24f346e21a0318..3020036d1b24e5e811d5589c525d1c962d602d93 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleHistory.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleHistory.java @@ -1,77 +1,77 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Provides a "history" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleHistory extends CounterExampleUnaryOperator { - public CounterExampleHistory(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("H", "History", counterExample, argument); - - CounterExampleNegation notArgument = new CounterExampleNegation( - counterExample, argument); - checkByOnce(counterExample, notArgument); - checkBySince(counterExample, argument, notArgument); - } - - private void checkBySince(final CounterExample counterExample, - final CounterExampleProposition argument, - CounterExampleNegation notArgument) { - CounterExampleValueType[] trueValues = new CounterExampleValueType[argument - .getValues().size()]; - Arrays.fill(trueValues, CounterExampleValueType.TRUE); - - CounterExamplePredicate truePredicate = new CounterExamplePredicate("", - counterExample, Arrays.asList(trueValues)); - - CounterExampleSince since = new CounterExampleSince(counterExample, - truePredicate, notArgument); - addCheck(new CounterExampleNegation(counterExample, since)); - } - - private void checkByOnce(final CounterExample counterExample, - CounterExampleNegation notArgument) { - CounterExampleOnce onceOperator = new CounterExampleOnce( - counterExample, notArgument); - - addCheck(new CounterExampleNegation(counterExample, onceOperator)); - } - - @Override - public CounterExampleValueType calculate(final int position) { - return calculateHistoryOperator(position); - } - - private CounterExampleValueType calculateHistoryOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // remove all future values - checkedValues = checkedValues.subList(0, position + 1); - - // look for a state with a false value - int index = checkedValues.lastIndexOf(CounterExampleValueType.FALSE); - - if (index != -1) { - result = CounterExampleValueType.FALSE; - } else { - if (!checkedValues.contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } - } - - fillHighlightedPositions(position, index, checkedValues.size(), true); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Provides a "history" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleHistory extends CounterExampleUnaryOperator { + public CounterExampleHistory(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("H", "History", counterExample, argument); + + CounterExampleNegation notArgument = new CounterExampleNegation( + counterExample, argument); + checkByOnce(counterExample, notArgument); + checkBySince(counterExample, argument, notArgument); + } + + private void checkBySince(final CounterExample counterExample, + final CounterExampleProposition argument, + CounterExampleNegation notArgument) { + CounterExampleValueType[] trueValues = new CounterExampleValueType[argument + .getValues().size()]; + Arrays.fill(trueValues, CounterExampleValueType.TRUE); + + CounterExamplePredicate truePredicate = new CounterExamplePredicate("", + counterExample, Arrays.asList(trueValues)); + + CounterExampleSince since = new CounterExampleSince(counterExample, + truePredicate, notArgument); + addCheck(new CounterExampleNegation(counterExample, since)); + } + + private void checkByOnce(final CounterExample counterExample, + CounterExampleNegation notArgument) { + CounterExampleOnce onceOperator = new CounterExampleOnce( + counterExample, notArgument); + + addCheck(new CounterExampleNegation(counterExample, onceOperator)); + } + + @Override + public CounterExampleValueType calculate(final int position) { + return calculateHistoryOperator(position); + } + + private CounterExampleValueType calculateHistoryOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // remove all future values + checkedValues = checkedValues.subList(0, position + 1); + + // look for a state with a false value + int index = checkedValues.lastIndexOf(CounterExampleValueType.FALSE); + + if (index != -1) { + result = CounterExampleValueType.FALSE; + } else { + if (!checkedValues.contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } + } + + fillHighlightedPositions(position, index, checkedValues.size(), true); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleImplication.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleImplication.java index ea536c11e472d1e0bd73d4cfd228e29ecf5bcdaa..34b2e7b268047e803b5a9b625b282bdad22fb91d 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleImplication.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleImplication.java @@ -1,43 +1,43 @@ -package de.prob.core.domainobjects.ltl; - - -/** - * Provides an "imply" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleImplication extends - CounterExampleBinaryOperator { - public CounterExampleImplication(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("=>", "Implication", counterExample, firstArgument, - secondArgument); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType firstValue = getFirstArgument().getValues() - .get(position); - firstValue = CounterExampleNegation.calculateNotOperator(firstValue); - - CounterExampleValueType secondValue = getSecondArgument().getValues() - .get(position); - - int firstCheckedSize = 1; - int secondCheckedSize = 1; - - if (firstValue == CounterExampleValueType.TRUE) { - secondCheckedSize = 0; - } else if (secondValue == CounterExampleValueType.TRUE) { - firstCheckedSize = 0; - } - - fillHighlightedPositions(position, -1, -1, firstCheckedSize, - secondCheckedSize, false); - - return CounterExampleDisjunction.calculateOr(firstValue, secondValue); - } -} +package de.prob.core.domainobjects.ltl; + + +/** + * Provides an "imply" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleImplication extends + CounterExampleBinaryOperator { + public CounterExampleImplication(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("=>", "Implication", counterExample, firstArgument, + secondArgument); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType firstValue = getFirstArgument().getValues() + .get(position); + firstValue = CounterExampleNegation.calculateNotOperator(firstValue); + + CounterExampleValueType secondValue = getSecondArgument().getValues() + .get(position); + + int firstCheckedSize = 1; + int secondCheckedSize = 1; + + if (firstValue == CounterExampleValueType.TRUE) { + secondCheckedSize = 0; + } else if (secondValue == CounterExampleValueType.TRUE) { + firstCheckedSize = 0; + } + + fillHighlightedPositions(position, -1, -1, firstCheckedSize, + secondCheckedSize, false); + + return CounterExampleDisjunction.calculateOr(firstValue, secondValue); + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNegation.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNegation.java index 8f2eb3bedeafcc5b7343f885fab375843ead941a..9bab004fa8b12bffb6b144176d216988094ea41d 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNegation.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNegation.java @@ -1,39 +1,39 @@ -package de.prob.core.domainobjects.ltl; - - -/** - * Provides a "not" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleNegation extends CounterExampleUnaryOperator { - public CounterExampleNegation(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("not", "Negation", counterExample, argument); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - CounterExampleValueType value = argument.getValues().get(position); - CounterExampleValueType result = calculateNotOperator(value); - - fillHighlightedPositions(position, -1, 1, false); - - return result; - } - - public static CounterExampleValueType calculateNotOperator( - final CounterExampleValueType value) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - if (value == CounterExampleValueType.TRUE) { - result = CounterExampleValueType.FALSE; - } else if (value == CounterExampleValueType.FALSE) { - result = CounterExampleValueType.TRUE; - } - - return result; - } -} +package de.prob.core.domainobjects.ltl; + + +/** + * Provides a "not" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleNegation extends CounterExampleUnaryOperator { + public CounterExampleNegation(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("not", "Negation", counterExample, argument); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + CounterExampleValueType value = argument.getValues().get(position); + CounterExampleValueType result = calculateNotOperator(value); + + fillHighlightedPositions(position, -1, 1, false); + + return result; + } + + public static CounterExampleValueType calculateNotOperator( + final CounterExampleValueType value) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + if (value == CounterExampleValueType.TRUE) { + result = CounterExampleValueType.FALSE; + } else if (value == CounterExampleValueType.FALSE) { + result = CounterExampleValueType.TRUE; + } + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNext.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNext.java index 86e814108c2eef36b54e8e3a75378160d0c5e0fb..1f4705813e7992b90de7b402e0f8b7711a435a0a 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNext.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleNext.java @@ -1,58 +1,58 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides a "next" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleNext extends CounterExampleUnaryOperator { - public CounterExampleNext(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("X", "Next", counterExample, argument); - } - - @Override - public CounterExampleValueType calculate(final int position) { - return calculateNextOperator(position); - } - - private CounterExampleValueType calculateNextOperator(int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - checkedValues.addAll(checkedValues.subList(loopEntry, position)); - } - - // remove all past values - checkedValues = checkedValues.subList(position, checkedValues.size()); - - int index = -1; - - if (checkedValues.size() > 1) { - index = 1; - result = checkedValues.get(index); - } else { - if (pathType == PathType.FINITE) { - result = CounterExampleValueType.FALSE; - } else if (pathType == PathType.INFINITE) { - index = 0; - result = checkedValues.get(0); - } - } - - fillHighlightedPositions(position, index, -1, false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides a "next" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleNext extends CounterExampleUnaryOperator { + public CounterExampleNext(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("X", "Next", counterExample, argument); + } + + @Override + public CounterExampleValueType calculate(final int position) { + return calculateNextOperator(position); + } + + private CounterExampleValueType calculateNextOperator(int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + checkedValues.addAll(checkedValues.subList(loopEntry, position)); + } + + // remove all past values + checkedValues = checkedValues.subList(position, checkedValues.size()); + + int index = -1; + + if (checkedValues.size() > 1) { + index = 1; + result = checkedValues.get(index); + } else { + if (pathType == PathType.FINITE) { + result = CounterExampleValueType.FALSE; + } else if (pathType == PathType.INFINITE) { + index = 0; + result = checkedValues.get(0); + } + } + + fillHighlightedPositions(position, index, -1, false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleOnce.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleOnce.java index f22ab22d6da46f2f64863762933c454486863492..b365f27b692f987e469c2665c279366e0c99847e 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleOnce.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleOnce.java @@ -1,62 +1,62 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Provides an "once" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleOnce extends CounterExampleUnaryOperator { - public CounterExampleOnce(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("O", "Once", counterExample, argument); - checkBySince(counterExample, argument); - } - - private void checkBySince(final CounterExample counterExample, - final CounterExampleProposition argument) { - CounterExampleValueType[] firstValues = new CounterExampleValueType[argument - .getValues().size()]; - Arrays.fill(firstValues, CounterExampleValueType.TRUE); - - CounterExamplePredicate first = new CounterExamplePredicate("", - counterExample, Arrays.asList(firstValues)); - - addCheck(new CounterExampleSince(counterExample, first, argument)); - } - - @Override - public CounterExampleValueType calculate(final int position) { - return calculateOnceOperator(position); - } - - private CounterExampleValueType calculateOnceOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // remove all future values - checkedValues = checkedValues.subList(0, position + 1); - - // look for a state with a true value - int index = checkedValues.lastIndexOf(CounterExampleValueType.TRUE); - - if (index != -1) { - result = CounterExampleValueType.TRUE; - } else { - if (!checkedValues.contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } - } - - fillHighlightedPositions(position, index, checkedValues.size(), true); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Provides an "once" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleOnce extends CounterExampleUnaryOperator { + public CounterExampleOnce(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("O", "Once", counterExample, argument); + checkBySince(counterExample, argument); + } + + private void checkBySince(final CounterExample counterExample, + final CounterExampleProposition argument) { + CounterExampleValueType[] firstValues = new CounterExampleValueType[argument + .getValues().size()]; + Arrays.fill(firstValues, CounterExampleValueType.TRUE); + + CounterExamplePredicate first = new CounterExamplePredicate("", + counterExample, Arrays.asList(firstValues)); + + addCheck(new CounterExampleSince(counterExample, first, argument)); + } + + @Override + public CounterExampleValueType calculate(final int position) { + return calculateOnceOperator(position); + } + + private CounterExampleValueType calculateOnceOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // remove all future values + checkedValues = checkedValues.subList(0, position + 1); + + // look for a state with a true value + int index = checkedValues.lastIndexOf(CounterExampleValueType.TRUE); + + if (index != -1) { + result = CounterExampleValueType.TRUE; + } else { + if (!checkedValues.contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } + } + + fillHighlightedPositions(position, index, checkedValues.size(), true); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExamplePredicate.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExamplePredicate.java index 11643d8b0776a2405ca61e8ca0d61d15b34ce998..0f4f06c472d330c44113574630edddad1ee3f442 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExamplePredicate.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExamplePredicate.java @@ -1,36 +1,36 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.List; - -/** - * Provides predicates. - * - * @author Andriy Tolstoy - * - */ -public class CounterExamplePredicate extends CounterExampleProposition { - private final List<CounterExampleValueType> values; - - public CounterExamplePredicate(final String name, - final CounterExample counterExample, - final List<CounterExampleValueType> values) { - super(name, name, counterExample); - this.values = values; - } - - @Override - public List<CounterExampleValueType> calculate() { - return values; - } - - @Override - public boolean hasChildren() { - return false; - } - - @Override - public String toString() { - return name; - } - -} +package de.prob.core.domainobjects.ltl; + +import java.util.List; + +/** + * Provides predicates. + * + * @author Andriy Tolstoy + * + */ +public class CounterExamplePredicate extends CounterExampleProposition { + private final List<CounterExampleValueType> values; + + public CounterExamplePredicate(final String name, + final CounterExample counterExample, + final List<CounterExampleValueType> values) { + super(name, name, counterExample); + this.values = values; + } + + @Override + public List<CounterExampleValueType> calculate() { + return values; + } + + @Override + public boolean hasChildren() { + return false; + } + + @Override + public String toString() { + return name; + } + +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleProposition.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleProposition.java index 4125194610437ae3c7cc92e60abdc76817d66412..a380418b7b5d57f785a0fefddbe94309fc6e9cdf 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleProposition.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleProposition.java @@ -1,157 +1,157 @@ -package de.prob.core.domainobjects.ltl; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; -import de.prob.logging.Logger; - -/** - * Provides an abstract class for all types of propositions. - * - * @author Andriy Tolstoy - * - */ -public abstract class CounterExampleProposition { - protected final String name; - protected final String fullName; - protected final int loopEntry; - protected final PathType pathType; - protected final CounterExample counterExample; - protected CounterExampleProposition parent; - private List<CounterExampleValueType> values; - private Collection<CounterExampleProposition> checks = new ArrayList<CounterExampleProposition>(); - - protected final PropertyChangeSupport listeners = new PropertyChangeSupport( - this); - private boolean visible = false; - protected int stateId = 0; - - public CounterExampleProposition(final String name, final String fullName, - final CounterExample counterExample) { - this.name = name; - this.fullName = fullName; - this.loopEntry = counterExample.getLoopEntry(); - this.pathType = counterExample.getPathType(); - this.counterExample = counterExample; - } - - public CounterExampleProposition getParent() { - return parent; - } - - public void setParent(final CounterExampleProposition parent) { - this.parent = parent; - } - - public String getFullName() { - return fullName; - } - - public List<CounterExampleValueType> getValues() { - if (values == null) { - values = calculate(); - performChecks(values); - } - - return values; - } - - public List<CounterExampleProposition> getChildren() { - List<CounterExampleProposition> children = new ArrayList<CounterExampleProposition>(); - children.add(this); - return children; - } - - public abstract boolean hasChildren(); - - public PathType getPathType() { - return pathType; - } - - public int getLoopEntry() { - return loopEntry; - } - - public boolean isVisible() { - return visible; - } - - public void setVisible(boolean visible) { - boolean oldVisible = this.visible; - this.visible = visible; - listeners.firePropertyChange("visible", oldVisible, visible); - } - - public int getStateId() { - return stateId; - } - - public void setStateId(int stateId) { - int oldStateId = this.stateId; - this.stateId = stateId; - listeners.firePropertyChange("stateId", oldStateId, stateId); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - listeners.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - listeners.removePropertyChangeListener(listener); - } - - protected List<Integer> fillPositions(int position, int index, - int checkedSize, boolean isPastOperator) { - List<Integer> positions = new ArrayList<Integer>(); - - if (index != -1) { - int pos = isPastOperator ? index : index + position; - pos = calculatePosition(pos); - Logger.assertProB("Position invalid", pos >= 0); - positions.add(pos); - } else { - for (int i = 0; i < checkedSize; i++) { - int pos = isPastOperator ? position - i : position + i; - pos = calculatePosition(pos); - Logger.assertProB("Position invalid", pos >= 0); - positions.add(pos); - } - } - - return positions; - } - - public boolean isTransition() { - return false; - } - - protected abstract List<CounterExampleValueType> calculate(); - - private int calculatePosition(int pos) { - final int size = counterExample.getCounterExampleSize(); - return pos < size ? pos : pos - (size - loopEntry); - } - - protected final void addCheck(CounterExampleProposition check) { - checks.add(check); - } - - private void performChecks(List<CounterExampleValueType> values) { - for (final CounterExampleProposition check : checks) { - performCheck(check, values); - } - } - - private void performCheck(CounterExampleProposition check, - List<CounterExampleValueType> values) { - List<CounterExampleValueType> values2 = check.getValues(); - if (!values.equals(values2)) { - Logger.notifyUser("Encountered inconsistency in computation of LTL operator" - + name); - } - } -} +package de.prob.core.domainobjects.ltl; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; +import de.prob.logging.Logger; + +/** + * Provides an abstract class for all types of propositions. + * + * @author Andriy Tolstoy + * + */ +public abstract class CounterExampleProposition { + protected final String name; + protected final String fullName; + protected final int loopEntry; + protected final PathType pathType; + protected final CounterExample counterExample; + protected CounterExampleProposition parent; + private List<CounterExampleValueType> values; + private Collection<CounterExampleProposition> checks = new ArrayList<CounterExampleProposition>(); + + protected final PropertyChangeSupport listeners = new PropertyChangeSupport( + this); + private boolean visible = false; + protected int stateId = 0; + + public CounterExampleProposition(final String name, final String fullName, + final CounterExample counterExample) { + this.name = name; + this.fullName = fullName; + this.loopEntry = counterExample.getLoopEntry(); + this.pathType = counterExample.getPathType(); + this.counterExample = counterExample; + } + + public CounterExampleProposition getParent() { + return parent; + } + + public void setParent(final CounterExampleProposition parent) { + this.parent = parent; + } + + public String getFullName() { + return fullName; + } + + public List<CounterExampleValueType> getValues() { + if (values == null) { + values = calculate(); + performChecks(values); + } + + return values; + } + + public List<CounterExampleProposition> getChildren() { + List<CounterExampleProposition> children = new ArrayList<CounterExampleProposition>(); + children.add(this); + return children; + } + + public abstract boolean hasChildren(); + + public PathType getPathType() { + return pathType; + } + + public int getLoopEntry() { + return loopEntry; + } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + boolean oldVisible = this.visible; + this.visible = visible; + listeners.firePropertyChange("visible", oldVisible, visible); + } + + public int getStateId() { + return stateId; + } + + public void setStateId(int stateId) { + int oldStateId = this.stateId; + this.stateId = stateId; + listeners.firePropertyChange("stateId", oldStateId, stateId); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + listeners.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + listeners.removePropertyChangeListener(listener); + } + + protected List<Integer> fillPositions(int position, int index, + int checkedSize, boolean isPastOperator) { + List<Integer> positions = new ArrayList<Integer>(); + + if (index != -1) { + int pos = isPastOperator ? index : index + position; + pos = calculatePosition(pos); + Logger.assertProB("Position invalid", pos >= 0); + positions.add(pos); + } else { + for (int i = 0; i < checkedSize; i++) { + int pos = isPastOperator ? position - i : position + i; + pos = calculatePosition(pos); + Logger.assertProB("Position invalid", pos >= 0); + positions.add(pos); + } + } + + return positions; + } + + public boolean isTransition() { + return false; + } + + protected abstract List<CounterExampleValueType> calculate(); + + private int calculatePosition(int pos) { + final int size = counterExample.getCounterExampleSize(); + return pos < size ? pos : pos - (size - loopEntry); + } + + protected final void addCheck(CounterExampleProposition check) { + checks.add(check); + } + + private void performChecks(List<CounterExampleValueType> values) { + for (final CounterExampleProposition check : checks) { + performCheck(check, values); + } + } + + private void performCheck(CounterExampleProposition check, + List<CounterExampleValueType> values) { + List<CounterExampleValueType> values2 = check.getValues(); + if (!values.equals(values2)) { + Logger.notifyUser("Encountered inconsistency in computation of LTL operator" + + name); + } + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleRelease.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleRelease.java index f4f5932f909251a125bb0bc55ee2d5bc6ae7155b..6424533c61f31db0f8e6a0cf454d4836e4bbec0c 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleRelease.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleRelease.java @@ -1,171 +1,171 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides a "release" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleRelease extends CounterExampleBinaryOperator { - public CounterExampleRelease(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("R", "Release", counterExample, firstArgument, secondArgument); - checkByUntil(counterExample, firstArgument, secondArgument); - } - - private void checkByUntil(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - CounterExampleNegation notFirst = new CounterExampleNegation( - counterExample, firstArgument); - CounterExampleNegation notSecond = new CounterExampleNegation( - counterExample, secondArgument); - CounterExampleUntil until = new CounterExampleUntil(counterExample, - notFirst, notSecond); - addCheck(new CounterExampleNegation(counterExample, until)); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - return calculateReleaseOperator(position); - } - - private CounterExampleValueType calculateReleaseOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( - getFirstArgument().getValues()); - List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( - getSecondArgument().getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, - position)); - secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, - position)); - } - - // remove all past values - firstCheckedValues = firstCheckedValues.subList(position, - firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList(position, - secondCheckedValues.size()); - - int secondIndex = -1; - - boolean trueOrUnknown = false; - - // look for a state with a true value in first argument - int firstIndex = firstCheckedValues - .indexOf(CounterExampleValueType.TRUE); - - if (firstIndex != -1) { - // look for a state with a false value in second argument - secondIndex = secondCheckedValues.subList(0, firstIndex + 1) - .indexOf(CounterExampleValueType.FALSE); - - if (secondIndex == -1) { - trueOrUnknown = true; - - firstCheckedValues = firstCheckedValues.subList(0, - firstIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - firstIndex + 1); - - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - - firstIndex = -1; - } else { - // look for the state with an unknown value in second - // argument - if (!secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } else { - firstIndex = -1; - } - } - } - } else { - // all states of first argument are invalid and all states of second - // argument are valid on a finite or an infinite path - if (pathType != PathType.REDUCED - && !secondCheckedValues - .contains(CounterExampleValueType.FALSE)) { - trueOrUnknown = true; - result = CounterExampleValueType.TRUE; - firstCheckedValues.clear(); - } - } - - if (!trueOrUnknown) { - // look for a state with a false value in second argument - secondIndex = secondCheckedValues - .indexOf(CounterExampleValueType.FALSE); - - if (secondIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, secondIndex); - firstIndex = -1; - - // look for a state with an unknown value in first argument - if (!firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, - secondCheckedValues.subList(0, secondIndex), false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } else { - secondCheckedValues = secondCheckedValues.subList(0, - secondIndex + 1); - secondIndex = -1; - } - - secondIndex = -1; - } - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } - } - } - - fillHighlightedPositions(position, firstIndex, secondIndex, - firstCheckedValues.size(), secondCheckedValues.size(), false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides a "release" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleRelease extends CounterExampleBinaryOperator { + public CounterExampleRelease(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("R", "Release", counterExample, firstArgument, secondArgument); + checkByUntil(counterExample, firstArgument, secondArgument); + } + + private void checkByUntil(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + CounterExampleNegation notFirst = new CounterExampleNegation( + counterExample, firstArgument); + CounterExampleNegation notSecond = new CounterExampleNegation( + counterExample, secondArgument); + CounterExampleUntil until = new CounterExampleUntil(counterExample, + notFirst, notSecond); + addCheck(new CounterExampleNegation(counterExample, until)); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + return calculateReleaseOperator(position); + } + + private CounterExampleValueType calculateReleaseOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( + getFirstArgument().getValues()); + List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( + getSecondArgument().getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, + position)); + secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, + position)); + } + + // remove all past values + firstCheckedValues = firstCheckedValues.subList(position, + firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList(position, + secondCheckedValues.size()); + + int secondIndex = -1; + + boolean trueOrUnknown = false; + + // look for a state with a true value in first argument + int firstIndex = firstCheckedValues + .indexOf(CounterExampleValueType.TRUE); + + if (firstIndex != -1) { + // look for a state with a false value in second argument + secondIndex = secondCheckedValues.subList(0, firstIndex + 1) + .indexOf(CounterExampleValueType.FALSE); + + if (secondIndex == -1) { + trueOrUnknown = true; + + firstCheckedValues = firstCheckedValues.subList(0, + firstIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + firstIndex + 1); + + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + + firstIndex = -1; + } else { + // look for the state with an unknown value in second + // argument + if (!secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } else { + firstIndex = -1; + } + } + } + } else { + // all states of first argument are invalid and all states of second + // argument are valid on a finite or an infinite path + if (pathType != PathType.REDUCED + && !secondCheckedValues + .contains(CounterExampleValueType.FALSE)) { + trueOrUnknown = true; + result = CounterExampleValueType.TRUE; + firstCheckedValues.clear(); + } + } + + if (!trueOrUnknown) { + // look for a state with a false value in second argument + secondIndex = secondCheckedValues + .indexOf(CounterExampleValueType.FALSE); + + if (secondIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, secondIndex); + firstIndex = -1; + + // look for a state with an unknown value in first argument + if (!firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, + secondCheckedValues.subList(0, secondIndex), false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } else { + secondCheckedValues = secondCheckedValues.subList(0, + secondIndex + 1); + secondIndex = -1; + } + + secondIndex = -1; + } + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } + } + } + + fillHighlightedPositions(position, firstIndex, secondIndex, + firstCheckedValues.size(), secondCheckedValues.size(), false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleSince.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleSince.java index 9c050bc88be343e675cbe06a31661616f0500b95..f7197bd7c83df25535a4f5926d62c7e230ed273b 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleSince.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleSince.java @@ -1,151 +1,151 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -/** - * Provides a "since" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleSince extends CounterExampleBinaryOperator { - public CounterExampleSince(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("S", "Since", counterExample, firstArgument, secondArgument); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - final CounterExampleValueType result = calculateSinceOperator(position); - return result; - } - - private CounterExampleValueType calculateSinceOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - // remove all future values - List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( - getFirstArgument().getValues().subList(0, position + 1)); - List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( - getSecondArgument().getValues().subList(0, position + 1)); - - int firstIndex = -1; - - boolean trueOrUnknown = false; - - // look for a state with a true value in second argument - int secondIndex = secondCheckedValues - .lastIndexOf(CounterExampleValueType.TRUE); - - if (secondIndex != -1) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues.subList(secondIndex + 1, - firstCheckedValues.size()).lastIndexOf( - CounterExampleValueType.FALSE); - - if (firstIndex == -1) { - trueOrUnknown = true; - - // look for a state with an unknown value in first and - // second argument - int unknownStateIndex = indexOfUnknownState( - firstCheckedValues.subList(secondIndex + 1, - firstCheckedValues.size()), - secondCheckedValues.subList(secondIndex + 1, - secondCheckedValues.size()), true); - - if (unknownStateIndex != -1) { - unknownStateIndex += (secondIndex + 1); - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - - secondIndex = -1; - } else { - firstCheckedValues = firstCheckedValues.subList( - secondIndex + 1, firstCheckedValues.size()); - - // look for the state with an unknown value in first - // argument - if (!firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } else { - secondCheckedValues = secondCheckedValues.subList( - secondIndex, secondCheckedValues.size()); - secondIndex = -1; - } - } - } - } - - if (!trueOrUnknown) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues - .lastIndexOf(CounterExampleValueType.FALSE); - - if (firstIndex != -1) { - secondCheckedValues = secondCheckedValues.subList(firstIndex, - secondCheckedValues.size()); - secondIndex = -1; - - // look for a state with an unknown value in second argument - if (!secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } else { - firstCheckedValues = firstCheckedValues.subList(firstIndex, - firstCheckedValues.size()); - - // look for a state with an unknown value in first and - // second argument - int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, true); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - } - - firstIndex = -1; - } - } else { - // all states of first argument are valid and all states of - // second argument are invalid - if (!firstCheckedValues.contains(CounterExampleValueType.FALSE) - && !firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN) - && !secondCheckedValues - .contains(CounterExampleValueType.TRUE) - && !secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - firstCheckedValues.clear(); - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, true); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - } - } - } - } - - fillHighlightedPositions(position, firstIndex, secondIndex, - firstCheckedValues.size(), secondCheckedValues.size(), true); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +/** + * Provides a "since" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleSince extends CounterExampleBinaryOperator { + public CounterExampleSince(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("S", "Since", counterExample, firstArgument, secondArgument); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + final CounterExampleValueType result = calculateSinceOperator(position); + return result; + } + + private CounterExampleValueType calculateSinceOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + // remove all future values + List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( + getFirstArgument().getValues().subList(0, position + 1)); + List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( + getSecondArgument().getValues().subList(0, position + 1)); + + int firstIndex = -1; + + boolean trueOrUnknown = false; + + // look for a state with a true value in second argument + int secondIndex = secondCheckedValues + .lastIndexOf(CounterExampleValueType.TRUE); + + if (secondIndex != -1) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues.subList(secondIndex + 1, + firstCheckedValues.size()).lastIndexOf( + CounterExampleValueType.FALSE); + + if (firstIndex == -1) { + trueOrUnknown = true; + + // look for a state with an unknown value in first and + // second argument + int unknownStateIndex = indexOfUnknownState( + firstCheckedValues.subList(secondIndex + 1, + firstCheckedValues.size()), + secondCheckedValues.subList(secondIndex + 1, + secondCheckedValues.size()), true); + + if (unknownStateIndex != -1) { + unknownStateIndex += (secondIndex + 1); + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + + secondIndex = -1; + } else { + firstCheckedValues = firstCheckedValues.subList( + secondIndex + 1, firstCheckedValues.size()); + + // look for the state with an unknown value in first + // argument + if (!firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } else { + secondCheckedValues = secondCheckedValues.subList( + secondIndex, secondCheckedValues.size()); + secondIndex = -1; + } + } + } + } + + if (!trueOrUnknown) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues + .lastIndexOf(CounterExampleValueType.FALSE); + + if (firstIndex != -1) { + secondCheckedValues = secondCheckedValues.subList(firstIndex, + secondCheckedValues.size()); + secondIndex = -1; + + // look for a state with an unknown value in second argument + if (!secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } else { + firstCheckedValues = firstCheckedValues.subList(firstIndex, + firstCheckedValues.size()); + + // look for a state with an unknown value in first and + // second argument + int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, true); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + } + + firstIndex = -1; + } + } else { + // all states of first argument are valid and all states of + // second argument are invalid + if (!firstCheckedValues.contains(CounterExampleValueType.FALSE) + && !firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN) + && !secondCheckedValues + .contains(CounterExampleValueType.TRUE) + && !secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + firstCheckedValues.clear(); + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, true); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + } + } + } + } + + fillHighlightedPositions(position, firstIndex, secondIndex, + firstCheckedValues.size(), secondCheckedValues.size(), true); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleState.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleState.java index c36ff7cc8efd14e683d87ffecd2abea679af6149..98e7b2d53cf3840fb3ef95020da1c92047468f3a 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleState.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleState.java @@ -1,42 +1,42 @@ -package de.prob.core.domainobjects.ltl; - -import de.prob.core.domainobjects.Operation; -import de.prob.prolog.term.PrologTerm; - -/** - * Provides a state of a counter-example. - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleState { - private final int index; - private final PrologTerm stateId; - private final Operation operation; - - public CounterExampleState(final int index, final PrologTerm stateId, - final Operation operation/* , final boolean inLoop */) { - this.index = index; - this.stateId = stateId; - this.operation = operation; - } - - public PrologTerm getState() { - return stateId; - } - - public Operation getOperation() { - return operation; - } - - public int getIndex() { - return index; - } - - @Override - public String toString() { - return "CounterExampleState [index=" + index + ", stateId=" + stateId - + ", operation=" + operation + "]"; - } - -} +package de.prob.core.domainobjects.ltl; + +import de.prob.core.domainobjects.Operation; +import de.prob.prolog.term.PrologTerm; + +/** + * Provides a state of a counter-example. + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleState { + private final int index; + private final PrologTerm stateId; + private final Operation operation; + + public CounterExampleState(final int index, final PrologTerm stateId, + final Operation operation/* , final boolean inLoop */) { + this.index = index; + this.stateId = stateId; + this.operation = operation; + } + + public PrologTerm getState() { + return stateId; + } + + public Operation getOperation() { + return operation; + } + + public int getIndex() { + return index; + } + + @Override + public String toString() { + return "CounterExampleState [index=" + index + ", stateId=" + stateId + + ", operation=" + operation + "]"; + } + +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTransition.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTransition.java index 48a35155a8b9639a0b30037136163697eaff1a3f..07e850566f42efb8e71e5a7b24e2484b9fda936f 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTransition.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTransition.java @@ -1,23 +1,23 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.List; - -/** - * Provides transitions. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleTransition extends CounterExamplePredicate { - public CounterExampleTransition(final String name, - final CounterExample counterExample, - final List<CounterExampleValueType> values) { - super(name, counterExample, values); - } - - @Override - public boolean isTransition() { - return true; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.List; + +/** + * Provides transitions. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleTransition extends CounterExamplePredicate { + public CounterExampleTransition(final String name, + final CounterExample counterExample, + final List<CounterExampleValueType> values) { + super(name, counterExample, values); + } + + @Override + public boolean isTransition() { + return true; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTrigger.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTrigger.java index cb0c0971218a28b4f13755ba50687b81280bdf7a..7ac6d974daa5742fa28821935ea29f1c48e09133 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTrigger.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleTrigger.java @@ -1,167 +1,167 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -/** - * Provides a "trigger" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleTrigger extends CounterExampleBinaryOperator { - public CounterExampleTrigger(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("T", "Trigger", counterExample, firstArgument, secondArgument); - checkBySince(counterExample, firstArgument, secondArgument); - } - - private void checkBySince(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - CounterExampleNegation notFirst = new CounterExampleNegation( - counterExample, firstArgument); - CounterExampleNegation notSecond = new CounterExampleNegation( - counterExample, secondArgument); - CounterExampleSince since = new CounterExampleSince(counterExample, - notFirst, notSecond); - addCheck(new CounterExampleNegation(counterExample, since)); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - return calculateTriggerOperator(position); - } - - private CounterExampleValueType calculateTriggerOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - // remove all future values - List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( - getFirstArgument().getValues().subList(0, position + 1)); - List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( - getSecondArgument().getValues().subList(0, position + 1)); - - int secondIndex = -1; - - boolean trueOrUnknown = false; - - // look for a state with a true value in first argument - int firstIndex = firstCheckedValues - .lastIndexOf(CounterExampleValueType.TRUE); - - if (firstIndex != -1) { - // look for a state with a false value in second argument - secondIndex = secondCheckedValues.subList(firstIndex, - secondCheckedValues.size()).lastIndexOf( - CounterExampleValueType.FALSE); - - if (secondIndex == -1) { - trueOrUnknown = true; - - // look for a state with an unknown value in first and - // second argument - int unknownStateIndex = indexOfUnknownState( - firstCheckedValues.subList(firstIndex, - firstCheckedValues.size()), - secondCheckedValues.subList(firstIndex, - secondCheckedValues.size()), true); - - if (unknownStateIndex != -1) { - unknownStateIndex += firstIndex; - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - - firstIndex = -1; - } else { - secondCheckedValues = secondCheckedValues.subList( - firstIndex, secondCheckedValues.size()); - - // look for the state with an unknown value in second - // argument - if (!secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } else { - firstCheckedValues = firstCheckedValues.subList( - firstIndex, firstCheckedValues.size()); - firstIndex = -1; - } - } - } - } else { - // all states of first argument are invalid and all states of second - // argument are valid on a finite or an infinite path - if (!firstCheckedValues.contains(CounterExampleValueType.UNKNOWN) - && !secondCheckedValues - .contains(CounterExampleValueType.FALSE) - && !secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - trueOrUnknown = true; - result = CounterExampleValueType.TRUE; - firstCheckedValues.clear(); - } - } - - if (!trueOrUnknown) { - // look for a state with a false value in second argument - secondIndex = secondCheckedValues - .lastIndexOf(CounterExampleValueType.FALSE); - - if (secondIndex != -1) { - firstCheckedValues = firstCheckedValues.subList( - secondIndex + 1, firstCheckedValues.size()); - firstIndex = -1; - - // look for a state with an unknown value in first argument - if (!firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } else { - // look for a state with an unknown value in first and - // second argument - int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, - secondCheckedValues.subList(secondIndex + 1, - secondCheckedValues.size()), true); - - if (unknownStateIndex != -1) { - secondCheckedValues = secondCheckedValues.subList( - secondIndex + 1, secondCheckedValues.size()); - - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - } else { - secondCheckedValues = secondCheckedValues.subList( - secondIndex, secondCheckedValues.size()); - } - - secondIndex = -1; - } - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, true); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList( - unknownStateIndex, firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList( - unknownStateIndex, secondCheckedValues.size()); - } - } - } - - fillHighlightedPositions(position, firstIndex, secondIndex, - firstCheckedValues.size(), secondCheckedValues.size(), true); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +/** + * Provides a "trigger" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleTrigger extends CounterExampleBinaryOperator { + public CounterExampleTrigger(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("T", "Trigger", counterExample, firstArgument, secondArgument); + checkBySince(counterExample, firstArgument, secondArgument); + } + + private void checkBySince(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + CounterExampleNegation notFirst = new CounterExampleNegation( + counterExample, firstArgument); + CounterExampleNegation notSecond = new CounterExampleNegation( + counterExample, secondArgument); + CounterExampleSince since = new CounterExampleSince(counterExample, + notFirst, notSecond); + addCheck(new CounterExampleNegation(counterExample, since)); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + return calculateTriggerOperator(position); + } + + private CounterExampleValueType calculateTriggerOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + // remove all future values + List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( + getFirstArgument().getValues().subList(0, position + 1)); + List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( + getSecondArgument().getValues().subList(0, position + 1)); + + int secondIndex = -1; + + boolean trueOrUnknown = false; + + // look for a state with a true value in first argument + int firstIndex = firstCheckedValues + .lastIndexOf(CounterExampleValueType.TRUE); + + if (firstIndex != -1) { + // look for a state with a false value in second argument + secondIndex = secondCheckedValues.subList(firstIndex, + secondCheckedValues.size()).lastIndexOf( + CounterExampleValueType.FALSE); + + if (secondIndex == -1) { + trueOrUnknown = true; + + // look for a state with an unknown value in first and + // second argument + int unknownStateIndex = indexOfUnknownState( + firstCheckedValues.subList(firstIndex, + firstCheckedValues.size()), + secondCheckedValues.subList(firstIndex, + secondCheckedValues.size()), true); + + if (unknownStateIndex != -1) { + unknownStateIndex += firstIndex; + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + + firstIndex = -1; + } else { + secondCheckedValues = secondCheckedValues.subList( + firstIndex, secondCheckedValues.size()); + + // look for the state with an unknown value in second + // argument + if (!secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } else { + firstCheckedValues = firstCheckedValues.subList( + firstIndex, firstCheckedValues.size()); + firstIndex = -1; + } + } + } + } else { + // all states of first argument are invalid and all states of second + // argument are valid on a finite or an infinite path + if (!firstCheckedValues.contains(CounterExampleValueType.UNKNOWN) + && !secondCheckedValues + .contains(CounterExampleValueType.FALSE) + && !secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + trueOrUnknown = true; + result = CounterExampleValueType.TRUE; + firstCheckedValues.clear(); + } + } + + if (!trueOrUnknown) { + // look for a state with a false value in second argument + secondIndex = secondCheckedValues + .lastIndexOf(CounterExampleValueType.FALSE); + + if (secondIndex != -1) { + firstCheckedValues = firstCheckedValues.subList( + secondIndex + 1, firstCheckedValues.size()); + firstIndex = -1; + + // look for a state with an unknown value in first argument + if (!firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } else { + // look for a state with an unknown value in first and + // second argument + int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, + secondCheckedValues.subList(secondIndex + 1, + secondCheckedValues.size()), true); + + if (unknownStateIndex != -1) { + secondCheckedValues = secondCheckedValues.subList( + secondIndex + 1, secondCheckedValues.size()); + + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + } else { + secondCheckedValues = secondCheckedValues.subList( + secondIndex, secondCheckedValues.size()); + } + + secondIndex = -1; + } + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, true); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList( + unknownStateIndex, firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList( + unknownStateIndex, secondCheckedValues.size()); + } + } + } + + fillHighlightedPositions(position, firstIndex, secondIndex, + firstCheckedValues.size(), secondCheckedValues.size(), true); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUnaryOperator.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUnaryOperator.java index f4911990e2cce2559ae22fd2214c753ca200134a..7f4e57234b2dcb02554e2e26c168b871eeed52ba 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUnaryOperator.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUnaryOperator.java @@ -1,71 +1,71 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -/** - * Provides operators with one parameter. - * - * @author Andriy Tolstoy - * - */ -public abstract class CounterExampleUnaryOperator extends - CounterExampleProposition { - protected final CounterExampleProposition argument; - protected List<List<Integer>> highlightedPositions = new ArrayList<List<Integer>>(); - - public CounterExampleUnaryOperator(final String name, - final String fullName, final CounterExample counterExample, - final CounterExampleProposition argument) { - super(name, fullName, counterExample); - this.argument = argument; - } - - @Override - public boolean hasChildren() { - return true; - } - - @Override - public List<CounterExampleProposition> getChildren() { - List<CounterExampleProposition> children = super.getChildren(); - children.addAll(argument.getChildren()); - return children; - } - - public CounterExampleProposition getArgument() { - return argument; - } - - public List<List<Integer>> getHighlightedPositions() { - return highlightedPositions; - } - - @Override - public String toString() { - return new StringBuilder(name).append(argument).toString(); - } - - @Override - protected List<CounterExampleValueType> calculate() { - final List<CounterExampleValueType> argumentValues = argument - .getValues(); - - final int size = argumentValues.size(); - final List<CounterExampleValueType> values = new ArrayList<CounterExampleValueType>(); - - for (int i = 0; i < size; i++) { - values.add(calculate(i)); - } - - return values; - } - - protected abstract CounterExampleValueType calculate(int position); - - protected void fillHighlightedPositions(final int position, - final int index, final int checkedSize, boolean isPast) { - highlightedPositions.add(fillPositions(position, index, checkedSize, - isPast)); - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +/** + * Provides operators with one parameter. + * + * @author Andriy Tolstoy + * + */ +public abstract class CounterExampleUnaryOperator extends + CounterExampleProposition { + protected final CounterExampleProposition argument; + protected List<List<Integer>> highlightedPositions = new ArrayList<List<Integer>>(); + + public CounterExampleUnaryOperator(final String name, + final String fullName, final CounterExample counterExample, + final CounterExampleProposition argument) { + super(name, fullName, counterExample); + this.argument = argument; + } + + @Override + public boolean hasChildren() { + return true; + } + + @Override + public List<CounterExampleProposition> getChildren() { + List<CounterExampleProposition> children = super.getChildren(); + children.addAll(argument.getChildren()); + return children; + } + + public CounterExampleProposition getArgument() { + return argument; + } + + public List<List<Integer>> getHighlightedPositions() { + return highlightedPositions; + } + + @Override + public String toString() { + return new StringBuilder(name).append(argument).toString(); + } + + @Override + protected List<CounterExampleValueType> calculate() { + final List<CounterExampleValueType> argumentValues = argument + .getValues(); + + final int size = argumentValues.size(); + final List<CounterExampleValueType> values = new ArrayList<CounterExampleValueType>(); + + for (int i = 0; i < size; i++) { + values.add(calculate(i)); + } + + return values; + } + + protected abstract CounterExampleValueType calculate(int position); + + protected void fillHighlightedPositions(final int position, + final int index, final int checkedSize, boolean isPast) { + highlightedPositions.add(fillPositions(position, index, checkedSize, + isPast)); + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUntil.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUntil.java index 5b017923822c2fd4e8f03bc9f0267ff582040d98..b288c48a08228271117d1b4c8cc846c967c15fc9 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUntil.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleUntil.java @@ -1,160 +1,160 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides an "until" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleUntil extends CounterExampleBinaryOperator { - public CounterExampleUntil(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("U", "Until", counterExample, firstArgument, secondArgument); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - final CounterExampleValueType result = calculateUntilOperator(position); - return result; - } - - private CounterExampleValueType calculateUntilOperator(final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( - getFirstArgument().getValues()); - List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( - getSecondArgument().getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, - position)); - secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, - position)); - } - - // remove all past values - firstCheckedValues = firstCheckedValues.subList(position, - firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList(position, - secondCheckedValues.size()); - - int firstIndex = -1; - - boolean trueOrUnknown = false; - - // look for a state with a true value in second argument - int secondIndex = secondCheckedValues - .indexOf(CounterExampleValueType.TRUE); - - if (secondIndex != -1) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues.subList(0, secondIndex).indexOf( - CounterExampleValueType.FALSE); - - if (firstIndex == -1) { - trueOrUnknown = true; - - firstCheckedValues = firstCheckedValues.subList(0, - secondIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - secondIndex + 1); - - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - - secondIndex = -1; - } else { - firstCheckedValues = firstCheckedValues.subList(0, - secondIndex); - - // look for a state with an unknown value in first argument - if (!firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } else { - secondIndex = -1; - } - } - } - } - - if (!trueOrUnknown) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues - .indexOf(CounterExampleValueType.FALSE); - - if (firstIndex != -1) { - secondCheckedValues = secondCheckedValues.subList(0, - firstIndex + 1); - secondIndex = -1; - - // look for a state with an unknown value in second argument - if (!secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } else { - firstCheckedValues = firstCheckedValues.subList(0, - firstIndex + 1); - firstIndex = -1; - - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } - } - } else { - // all states of first argument are valid and all states of - // second argument are invalid on a finite or an infinite path - if (pathType != PathType.REDUCED - && !firstCheckedValues - .contains(CounterExampleValueType.FALSE) - && !secondCheckedValues - .contains(CounterExampleValueType.TRUE)) { - result = CounterExampleValueType.FALSE; - firstCheckedValues.clear(); - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } - } - } - } - - fillHighlightedPositions(position, firstIndex, secondIndex, - firstCheckedValues.size(), secondCheckedValues.size(), false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides an "until" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleUntil extends CounterExampleBinaryOperator { + public CounterExampleUntil(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("U", "Until", counterExample, firstArgument, secondArgument); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + final CounterExampleValueType result = calculateUntilOperator(position); + return result; + } + + private CounterExampleValueType calculateUntilOperator(final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( + getFirstArgument().getValues()); + List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( + getSecondArgument().getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, + position)); + secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, + position)); + } + + // remove all past values + firstCheckedValues = firstCheckedValues.subList(position, + firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList(position, + secondCheckedValues.size()); + + int firstIndex = -1; + + boolean trueOrUnknown = false; + + // look for a state with a true value in second argument + int secondIndex = secondCheckedValues + .indexOf(CounterExampleValueType.TRUE); + + if (secondIndex != -1) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues.subList(0, secondIndex).indexOf( + CounterExampleValueType.FALSE); + + if (firstIndex == -1) { + trueOrUnknown = true; + + firstCheckedValues = firstCheckedValues.subList(0, + secondIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + secondIndex + 1); + + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + + secondIndex = -1; + } else { + firstCheckedValues = firstCheckedValues.subList(0, + secondIndex); + + // look for a state with an unknown value in first argument + if (!firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } else { + secondIndex = -1; + } + } + } + } + + if (!trueOrUnknown) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues + .indexOf(CounterExampleValueType.FALSE); + + if (firstIndex != -1) { + secondCheckedValues = secondCheckedValues.subList(0, + firstIndex + 1); + secondIndex = -1; + + // look for a state with an unknown value in second argument + if (!secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } else { + firstCheckedValues = firstCheckedValues.subList(0, + firstIndex + 1); + firstIndex = -1; + + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } + } + } else { + // all states of first argument are valid and all states of + // second argument are invalid on a finite or an infinite path + if (pathType != PathType.REDUCED + && !firstCheckedValues + .contains(CounterExampleValueType.FALSE) + && !secondCheckedValues + .contains(CounterExampleValueType.TRUE)) { + result = CounterExampleValueType.FALSE; + firstCheckedValues.clear(); + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } + } + } + } + + fillHighlightedPositions(position, firstIndex, secondIndex, + firstCheckedValues.size(), secondCheckedValues.size(), false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleValueType.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleValueType.java index 2cc1b4cfacf923dc3279d5f7e19454e18216d1fa..4699d062456320be5585fd37e5d7800e0abb1525 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleValueType.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleValueType.java @@ -1,10 +1,10 @@ -package de.prob.core.domainobjects.ltl; - -public enum CounterExampleValueType { - TRUE, FALSE, UNKNOWN; - - @Override - public String toString() { - return name().substring(0, 1); - } -}; +package de.prob.core.domainobjects.ltl; + +public enum CounterExampleValueType { + TRUE, FALSE, UNKNOWN; + + @Override + public String toString() { + return name().substring(0, 1); + } +}; diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleWeakUntil.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleWeakUntil.java index 41fc7023b12c5ee8a0aefe89c637ca3cce50ee45..300d1b97205023237fbdf70fdb2cf09a0d03abb3 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleWeakUntil.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleWeakUntil.java @@ -1,196 +1,196 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import de.prob.core.command.LtlCheckingCommand.PathType; - -/** - * Provides a "weak until" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleWeakUntil extends CounterExampleBinaryOperator { - public CounterExampleWeakUntil(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - super("W", "Weak Until", counterExample, firstArgument, secondArgument); - - checkByRelease(counterExample, firstArgument, secondArgument); - checkByUntil(counterExample, firstArgument, secondArgument); - } - - private void checkByUntil(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - CounterExampleNegation not = new CounterExampleNegation(counterExample, - firstArgument); - - CounterExampleValueType[] trueValues = new CounterExampleValueType[firstArgument - .getValues().size()]; - Arrays.fill(trueValues, CounterExampleValueType.TRUE); - - CounterExamplePredicate truePredicate = new CounterExamplePredicate("", - counterExample, Arrays.asList(trueValues)); - - CounterExampleNegation notUntil = new CounterExampleNegation( - counterExample, new CounterExampleUntil(counterExample, - truePredicate, not)); - - CounterExampleUntil until = new CounterExampleUntil(counterExample, - firstArgument, secondArgument); - - addCheck(new CounterExampleDisjunction(counterExample, notUntil, until)); - addCheck(new CounterExampleDisjunction(counterExample, until, - new CounterExampleGlobally(counterExample, firstArgument))); - } - - private void checkByRelease(final CounterExample counterExample, - final CounterExampleProposition firstArgument, - final CounterExampleProposition secondArgument) { - addCheck(new CounterExampleRelease(counterExample, secondArgument, - new CounterExampleDisjunction(counterExample, secondArgument, - firstArgument))); - } - - @Override - protected CounterExampleValueType calculate(final int position) { - return calculateWeakUntilOperator(position); - } - - private CounterExampleValueType calculateWeakUntilOperator( - final int position) { - CounterExampleValueType result = CounterExampleValueType.UNKNOWN; - - List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( - getFirstArgument().getValues()); - List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( - getSecondArgument().getValues()); - - // add future values if a path is infinite - if (pathType == PathType.INFINITE && position > loopEntry) { - firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, - position)); - secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, - position)); - } - - // remove all past values - firstCheckedValues = firstCheckedValues.subList(position, - firstCheckedValues.size()); - secondCheckedValues = secondCheckedValues.subList(position, - secondCheckedValues.size()); - - int firstIndex = -1; - - boolean trueOrUnknown = false; - - // look for a state with a true value in second argument - int secondIndex = secondCheckedValues - .indexOf(CounterExampleValueType.TRUE); - - if (secondIndex != -1) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues.subList(0, secondIndex).indexOf( - CounterExampleValueType.FALSE); - - if (firstIndex == -1) { - trueOrUnknown = true; - - firstCheckedValues = firstCheckedValues.subList(0, - secondIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - secondIndex + 1); - - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - - secondIndex = -1; - } else { - firstCheckedValues = firstCheckedValues.subList(0, - secondIndex); - - // look for a state with an unknown value in first argument - if (!firstCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.TRUE; - } else { - secondIndex = -1; - } - } - } - } else { - // all states of first argument are valid and all states of second - // argument are invalid on a finite or an infinite path - if (pathType != PathType.REDUCED - && !firstCheckedValues - .contains(CounterExampleValueType.FALSE)) { - trueOrUnknown = true; - result = CounterExampleValueType.TRUE; - secondCheckedValues.clear(); - } - } - - if (!trueOrUnknown) { - // look for a state with a false value in first argument - firstIndex = firstCheckedValues - .indexOf(CounterExampleValueType.FALSE); - - if (firstIndex != -1) { - secondCheckedValues = secondCheckedValues.subList(0, - firstIndex + 1); - secondIndex = -1; - - // look for a state with an unknown value in second argument - if (!secondCheckedValues - .contains(CounterExampleValueType.UNKNOWN)) { - result = CounterExampleValueType.FALSE; - } else { - firstCheckedValues = firstCheckedValues.subList(0, - firstIndex + 1); - firstIndex = -1; - - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } - } - } else { - // look for a state with an unknown value in first and - // second argument - final int unknownStateIndex = indexOfUnknownState( - firstCheckedValues, secondCheckedValues, false); - - if (unknownStateIndex != -1) { - firstCheckedValues = firstCheckedValues.subList(0, - unknownStateIndex + 1); - secondCheckedValues = secondCheckedValues.subList(0, - unknownStateIndex + 1); - } - } - } - - fillHighlightedPositions(position, firstIndex, secondIndex, - firstCheckedValues.size(), secondCheckedValues.size(), false); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import de.prob.core.command.LtlCheckingCommand.PathType; + +/** + * Provides a "weak until" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleWeakUntil extends CounterExampleBinaryOperator { + public CounterExampleWeakUntil(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + super("W", "Weak Until", counterExample, firstArgument, secondArgument); + + checkByRelease(counterExample, firstArgument, secondArgument); + checkByUntil(counterExample, firstArgument, secondArgument); + } + + private void checkByUntil(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + CounterExampleNegation not = new CounterExampleNegation(counterExample, + firstArgument); + + CounterExampleValueType[] trueValues = new CounterExampleValueType[firstArgument + .getValues().size()]; + Arrays.fill(trueValues, CounterExampleValueType.TRUE); + + CounterExamplePredicate truePredicate = new CounterExamplePredicate("", + counterExample, Arrays.asList(trueValues)); + + CounterExampleNegation notUntil = new CounterExampleNegation( + counterExample, new CounterExampleUntil(counterExample, + truePredicate, not)); + + CounterExampleUntil until = new CounterExampleUntil(counterExample, + firstArgument, secondArgument); + + addCheck(new CounterExampleDisjunction(counterExample, notUntil, until)); + addCheck(new CounterExampleDisjunction(counterExample, until, + new CounterExampleGlobally(counterExample, firstArgument))); + } + + private void checkByRelease(final CounterExample counterExample, + final CounterExampleProposition firstArgument, + final CounterExampleProposition secondArgument) { + addCheck(new CounterExampleRelease(counterExample, secondArgument, + new CounterExampleDisjunction(counterExample, secondArgument, + firstArgument))); + } + + @Override + protected CounterExampleValueType calculate(final int position) { + return calculateWeakUntilOperator(position); + } + + private CounterExampleValueType calculateWeakUntilOperator( + final int position) { + CounterExampleValueType result = CounterExampleValueType.UNKNOWN; + + List<CounterExampleValueType> firstCheckedValues = new ArrayList<CounterExampleValueType>( + getFirstArgument().getValues()); + List<CounterExampleValueType> secondCheckedValues = new ArrayList<CounterExampleValueType>( + getSecondArgument().getValues()); + + // add future values if a path is infinite + if (pathType == PathType.INFINITE && position > loopEntry) { + firstCheckedValues.addAll(firstCheckedValues.subList(loopEntry, + position)); + secondCheckedValues.addAll(secondCheckedValues.subList(loopEntry, + position)); + } + + // remove all past values + firstCheckedValues = firstCheckedValues.subList(position, + firstCheckedValues.size()); + secondCheckedValues = secondCheckedValues.subList(position, + secondCheckedValues.size()); + + int firstIndex = -1; + + boolean trueOrUnknown = false; + + // look for a state with a true value in second argument + int secondIndex = secondCheckedValues + .indexOf(CounterExampleValueType.TRUE); + + if (secondIndex != -1) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues.subList(0, secondIndex).indexOf( + CounterExampleValueType.FALSE); + + if (firstIndex == -1) { + trueOrUnknown = true; + + firstCheckedValues = firstCheckedValues.subList(0, + secondIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + secondIndex + 1); + + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + + secondIndex = -1; + } else { + firstCheckedValues = firstCheckedValues.subList(0, + secondIndex); + + // look for a state with an unknown value in first argument + if (!firstCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.TRUE; + } else { + secondIndex = -1; + } + } + } + } else { + // all states of first argument are valid and all states of second + // argument are invalid on a finite or an infinite path + if (pathType != PathType.REDUCED + && !firstCheckedValues + .contains(CounterExampleValueType.FALSE)) { + trueOrUnknown = true; + result = CounterExampleValueType.TRUE; + secondCheckedValues.clear(); + } + } + + if (!trueOrUnknown) { + // look for a state with a false value in first argument + firstIndex = firstCheckedValues + .indexOf(CounterExampleValueType.FALSE); + + if (firstIndex != -1) { + secondCheckedValues = secondCheckedValues.subList(0, + firstIndex + 1); + secondIndex = -1; + + // look for a state with an unknown value in second argument + if (!secondCheckedValues + .contains(CounterExampleValueType.UNKNOWN)) { + result = CounterExampleValueType.FALSE; + } else { + firstCheckedValues = firstCheckedValues.subList(0, + firstIndex + 1); + firstIndex = -1; + + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } + } + } else { + // look for a state with an unknown value in first and + // second argument + final int unknownStateIndex = indexOfUnknownState( + firstCheckedValues, secondCheckedValues, false); + + if (unknownStateIndex != -1) { + firstCheckedValues = firstCheckedValues.subList(0, + unknownStateIndex + 1); + secondCheckedValues = secondCheckedValues.subList(0, + unknownStateIndex + 1); + } + } + } + + fillHighlightedPositions(position, firstIndex, secondIndex, + firstCheckedValues.size(), secondCheckedValues.size(), false); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleYesterday.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleYesterday.java index 6e76f1979ba1bb2ef1965095015368bbe16434fd..b08984098d66f1058bdaf57b68ebb2313dc6d943 100644 --- a/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleYesterday.java +++ b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExampleYesterday.java @@ -1,45 +1,45 @@ -package de.prob.core.domainobjects.ltl; - -import java.util.ArrayList; -import java.util.List; - -/** - * Provides a "yesterday" operator. - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleYesterday extends CounterExampleUnaryOperator { - public CounterExampleYesterday(final CounterExample counterExample, - final CounterExampleProposition argument) { - super("Y", "Yesterday", counterExample, argument); - } - - @Override - public CounterExampleValueType calculate(final int position) { - CounterExampleValueType result = calculateYesterday(position); - return result; - } - - private CounterExampleValueType calculateYesterday(int position) { - CounterExampleValueType result = CounterExampleValueType.FALSE; - - List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( - argument.getValues()); - - // remove all future values - checkedValues = checkedValues.subList(0, position + 1); - - int index = -1; - - if (checkedValues.size() > 1) { - index = position - 1; - result = argument.getValues().get(index); - } - - fillHighlightedPositions(position, index, -1, true); - - return result; - } -} +package de.prob.core.domainobjects.ltl; + +import java.util.ArrayList; +import java.util.List; + +/** + * Provides a "yesterday" operator. + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleYesterday extends CounterExampleUnaryOperator { + public CounterExampleYesterday(final CounterExample counterExample, + final CounterExampleProposition argument) { + super("Y", "Yesterday", counterExample, argument); + } + + @Override + public CounterExampleValueType calculate(final int position) { + CounterExampleValueType result = calculateYesterday(position); + return result; + } + + private CounterExampleValueType calculateYesterday(int position) { + CounterExampleValueType result = CounterExampleValueType.FALSE; + + List<CounterExampleValueType> checkedValues = new ArrayList<CounterExampleValueType>( + argument.getValues()); + + // remove all future values + checkedValues = checkedValues.subList(0, position + 1); + + int index = -1; + + if (checkedValues.size() > 1) { + index = position - 1; + result = argument.getValues().get(index); + } + + fillHighlightedPositions(position, index, -1, true); + + return result; + } +} diff --git a/de.prob.core/src/de/prob/core/internal/AnimatorImpl.java b/de.prob.core/src/de/prob/core/internal/AnimatorImpl.java index ee13d12c0986b87c0ea0b0be8fb8ef4d7a2e6c34..639180e70eb1f2ba2ec190354abab376ef2aa2ea 100644 --- a/de.prob.core/src/de/prob/core/internal/AnimatorImpl.java +++ b/de.prob.core/src/de/prob/core/internal/AnimatorImpl.java @@ -145,10 +145,6 @@ public class AnimatorImpl { return this.description != null; } - public synchronized String getDebuggingKey() { - return connector == null ? null : connector.getDebuggingKey(); - } - public void execute(final IComposableCommand command) throws ProBException { checkConnector(command.getClass().getName()); @@ -177,7 +173,8 @@ public class AnimatorImpl { errors = getErrors.getErrors(); } if (errors != null && !errors.isEmpty()) { - ProblemHandler.raisePrologException(errors); + ProblemHandler.raisePrologException(errors, + getErrors.onlyWarningsOccurred()); } } } diff --git a/de.prob.core/src/de/prob/core/internal/ServerConnection.java b/de.prob.core/src/de/prob/core/internal/ServerConnection.java index cef750564c6692b9aa11649345043cccf51cc005..a593d273f35faff3ce93117d418c1c64cefe1951 100644 --- a/de.prob.core/src/de/prob/core/internal/ServerConnection.java +++ b/de.prob.core/src/de/prob/core/internal/ServerConnection.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.InetAddress; import java.net.Socket; +import java.nio.charset.Charset; import de.prob.cli.CliException; import de.prob.cli.CliStarter; @@ -40,19 +41,10 @@ public class ServerConnection implements IServerConnection { cli = new CliStarter(file); } - /* - * (non-Javadoc) - * - * @see de.prob.core.IServerConnection#getLastCommand() - */ public String getLastCommand() { return lastCommand; } - public String getDebuggingKey() { - return cli == null ? null : cli.getDebuggingKey(); - } - private void establishConnection(final int port) throws CliException { try { socket = new Socket(InetAddress.getByName(null), port); @@ -75,6 +67,7 @@ public class ServerConnection implements IServerConnection { } } + @Override public String sendCommand(final String commandString) throws ProBException { if (shutdown) { final String message = "probcli is currently shutting down"; @@ -100,7 +93,8 @@ public class ServerConnection implements IServerConnection { try { input = readAnswer(); if (input == null) - throw new IOException("ProB binary returned nothing - it might have crashed"); + throw new IOException( + "ProB binary returned nothing - it might have crashed"); } catch (final IOException e) { shutdown(); String message = "Exception while reading from socket"; @@ -152,7 +146,9 @@ public class ServerConnection implements IServerConnection { // trim white spaces and append // instead of removing the last byte trim is used, because on // windows prob uses \r\n as new line. - result.append((new String(buffer, 0, count)).trim()); + String s = new String(buffer, 0, count, Charset + .defaultCharset().name()); + result.append(s.replace("\r", "").replace("\n", "")); } else { done = true; } @@ -161,6 +157,7 @@ public class ServerConnection implements IServerConnection { return result.length() > 0 ? result.toString() : null; } + @Override public void startup(final File file) throws CliException { if (shutdown) { startcli(file); @@ -173,6 +170,7 @@ public class ServerConnection implements IServerConnection { } } + @Override public void shutdown() { if (!shutdown) { if (socket != null) { @@ -199,6 +197,7 @@ public class ServerConnection implements IServerConnection { } } + @Override public int getCliPortNumber() { return cli.getPort(); } diff --git a/de.prob.core/src/de/prob/core/prolog/TypedIdentifierGenerator.java b/de.prob.core/src/de/prob/core/prolog/TypedIdentifierGenerator.java index 1beb714f1be0f6bea5d9ecb6437c6c2331013f8f..98d0c6184a08d70d67c88e175d76e036d6a7a927 100644 --- a/de.prob.core/src/de/prob/core/prolog/TypedIdentifierGenerator.java +++ b/de.prob.core/src/de/prob/core/prolog/TypedIdentifierGenerator.java @@ -134,6 +134,8 @@ public class TypedIdentifierGenerator { private static Map<String, Handler> initHandlers() { Map<String, Handler> handlers = new HashMap<String, Handler>(); handlers.put("integer/0", new BasicHandler(BaseProbType.INTEGER)); + handlers.put("float/0", new BasicHandler(BaseProbType.FLOAT)); + handlers.put("real/0", new BasicHandler(BaseProbType.REAL)); handlers.put("string/0", new BasicHandler(BaseProbType.STRING)); handlers.put("boolean/0", new BasicHandler(BaseProbType.BOOL)); handlers.put("pred/0", new BasicHandler(BaseProbType.PREDICATE)); diff --git a/de.prob.core/src/de/prob/core/types/BaseProbType.java b/de.prob.core/src/de/prob/core/types/BaseProbType.java index ead5001d15f4615ba9b4b270252110c362c1934d..22448a168798d1533fd9419aa9d97a7a561882e3 100644 --- a/de.prob.core/src/de/prob/core/types/BaseProbType.java +++ b/de.prob.core/src/de/prob/core/types/BaseProbType.java @@ -20,6 +20,8 @@ public class BaseProbType extends ProbDataType { public final static BaseProbType PREDICATE = new BaseProbType("predicate"); public final static BaseProbType SUBSTITUTION = new BaseProbType( "substitution"); + public final static BaseProbType REAL = new BaseProbType("REAL"); + public final static BaseProbType FLOAT = new BaseProbType("FLOAT"); private final String type; diff --git a/de.prob.core/src/de/prob/eventb/translator/ContextTranslator.java b/de.prob.core/src/de/prob/eventb/translator/ContextTranslator.java index 844b47802434d5b3ceecb2a3bd717a99979e81d6..578a2746ae11a67f780c9727e7151d4dc06fd248 100644 --- a/de.prob.core/src/de/prob/eventb/translator/ContextTranslator.java +++ b/de.prob.core/src/de/prob/eventb/translator/ContextTranslator.java @@ -42,7 +42,6 @@ import org.rodinp.core.IRodinProject; import org.rodinp.core.RodinCore; import org.rodinp.core.RodinDBException; -import de.be4.classicalb.core.parser.analysis.pragma.internal.ClassifiedPragma; import de.be4.classicalb.core.parser.node.AAbstractConstantsContextClause; import de.be4.classicalb.core.parser.node.AAxiomsContextClause; import de.be4.classicalb.core.parser.node.AConstantsContextClause; @@ -71,20 +70,19 @@ public final class ContextTranslator extends AbstractComponentTranslator { private final ISCContext context; private final AEventBContextParseUnit model = new AEventBContextParseUnit(); private final Map<String, ISCContext> depContext = new HashMap<String, ISCContext>(); - private final List<ClassifiedPragma> proofspragmas = new ArrayList<ClassifiedPragma>(); + // private final List<ClassifiedPragma> proofspragmas = new + // ArrayList<ClassifiedPragma>(); private final IEventBRoot root; private final FormulaFactory ff; private final ITypeEnvironment te; - public static ContextTranslator create(final ISCContextRoot context) - throws TranslationFailedException { + public static ContextTranslator create(final ISCContextRoot context) throws TranslationFailedException { try { assertConsistentModel(context); final FormulaFactory ff = context.getFormulaFactory(); final ITypeEnvironment te = context.getTypeEnvironment(); - final ContextTranslator translator = new ContextTranslator(context, - ff, te, context); + final ContextTranslator translator = new ContextTranslator(context, ff, te, context); translator.translate(); return translator; } catch (CoreException e) { @@ -92,12 +90,10 @@ public final class ContextTranslator extends AbstractComponentTranslator { } } - public static ContextTranslator create(final ISCInternalContext context, - final FormulaFactory ff, final ITypeEnvironment te) - throws TranslationFailedException { + public static ContextTranslator create(final ISCInternalContext context, final FormulaFactory ff, + final ITypeEnvironment te) throws TranslationFailedException { final IEventBRoot root = getRootContext(context); - final ContextTranslator translator = new ContextTranslator(context, ff, - te, root); + final ContextTranslator translator = new ContextTranslator(context, ff, te, root); try { assertConsistentModel(context.getRoot()); translator.translate(); @@ -111,8 +107,7 @@ public final class ContextTranslator extends AbstractComponentTranslator { try { String elementName = context.getElementName(); IRodinProject rodinProject = context.getRodinProject(); - IRodinFile rodinFile = rodinProject.getRodinFile(elementName - + ".bcc"); + IRodinFile rodinFile = rodinProject.getRodinFile(elementName + ".bcc"); if (rodinFile.exists()) { final IInternalElement element = rodinFile.getRoot(); if (element instanceof IEventBRoot) { @@ -126,16 +121,13 @@ public final class ContextTranslator extends AbstractComponentTranslator { return null; } - private static TranslationFailedException createTranslationFailedException( - final ISCContext context, CoreException e) - throws TranslationFailedException { + private static TranslationFailedException createTranslationFailedException(final ISCContext context, + CoreException e) throws TranslationFailedException { final String message = "A Rodin exception occured during translation process. Possible cause: building aborted or still in progress. Please wait until building has finished before starting ProB. If this does not help, perform a clean and start ProB after building has finished. Original Exception: "; - return new TranslationFailedException(context.getComponentName(), - message + e.getLocalizedMessage()); + return new TranslationFailedException(context.getComponentName(), message + e.getLocalizedMessage()); } - private static boolean assertConsistentModel(IInternalElement machine_root) - throws RodinDBException { + private static boolean assertConsistentModel(IInternalElement machine_root) throws RodinDBException { return Assert.isTrue(machine_root.getRodinFile().isConsistent()); } @@ -155,8 +147,7 @@ public final class ContextTranslator extends AbstractComponentTranslator { * the root to access the proofs * @throws TranslationFailedException */ - private ContextTranslator(final ISCContext context, - final FormulaFactory ff, final ITypeEnvironment te, + private ContextTranslator(final ISCContext context, final FormulaFactory ff, final ITypeEnvironment te, final IEventBRoot root) throws TranslationFailedException { super(context.getComponentName()); this.context = context; @@ -205,21 +196,18 @@ public final class ContextTranslator extends AbstractComponentTranslator { String name = sequent.getDescription(); - ArrayList<SequentSource> s = new ArrayList<SequentSource>( - sources.length); + ArrayList<SequentSource> s = new ArrayList<SequentSource>(sources.length); for (IPOSource source : sources) { IRodinElement srcElement = source.getSource(); - if (!srcElement.exists() - || !(srcElement instanceof ILabeledElement)) { + if (!srcElement.exists() || !(srcElement instanceof ILabeledElement)) { bugs.add(status.getElementName()); break; } ILabeledElement le = (ILabeledElement) srcElement; - s.add(new SequentSource(srcElement.getElementType(), le - .getLabel())); + s.add(new SequentSource(srcElement.getElementType(), le.getLabel())); } addProof(new ProofObligation(origin, s, name, pstatus)); @@ -227,14 +215,13 @@ public final class ContextTranslator extends AbstractComponentTranslator { } catch (RodinDBException e) { bugs.add(e.getLocalizedMessage()); } - + if (!bugs.isEmpty()) { String message = "Translation incomplete due to a Bug in Rodin. This does not affect correctness of the Animation/Model Checking but can decrease its performance. Skipped discharged information about: " + StringUtils.join(bugs, ","); Logger.notifyUser(message); } - } public AEventBContextParseUnit getContextAST() { @@ -270,11 +257,9 @@ public final class ContextTranslator extends AbstractComponentTranslator { } } - private AExtendsContextClause processExtendsForInternalContext() - throws RodinDBException { + private AExtendsContextClause processExtendsForInternalContext() throws RodinDBException { ISCInternalContext icontext = (ISCInternalContext) context; - IExtendsContext[] extendsClauses = icontext - .getChildrenOfType(IExtendsContext.ELEMENT_TYPE); + IExtendsContext[] extendsClauses = icontext.getChildrenOfType(IExtendsContext.ELEMENT_TYPE); try { extendsClauses = getSeenContexts(icontext); @@ -282,44 +267,36 @@ public final class ContextTranslator extends AbstractComponentTranslator { // Use the default value } - final List<TIdentifierLiteral> extendsList = new ArrayList<TIdentifierLiteral>( - extendsClauses.length); + final List<TIdentifierLiteral> extendsList = new ArrayList<TIdentifierLiteral>(extendsClauses.length); for (final IExtendsContext extendsContext : extendsClauses) { - final String name = extendsContext.getAbstractSCContext() - .getComponentName(); + final String name = extendsContext.getAbstractSCContext().getComponentName(); extendsList.add(new TIdentifierLiteral(name)); } return new AExtendsContextClause(extendsList); } - private IExtendsContext[] getSeenContexts(ISCInternalContext icontext) - throws RodinDBException { + private IExtendsContext[] getSeenContexts(ISCInternalContext icontext) throws RodinDBException { IExtendsContext[] extendsClauses; String fname = icontext.getComponentName(); - IRodinFile file = icontext.getRodinProject().getRodinFile( - fname + ".buc"); + IRodinFile file = icontext.getRodinProject().getRodinFile(fname + ".buc"); IContextRoot root = (IContextRoot) file.getRoot(); extendsClauses = root.getExtendsClauses(); return extendsClauses; } - private AExtendsContextClause processExtendsForContextRoot() - throws CoreException { + private AExtendsContextClause processExtendsForContextRoot() throws CoreException { ISCExtendsContext[] extendsClauses = null; ISCContextRoot rcontext = (ISCContextRoot) context; extendsClauses = rcontext.getSCExtendsClauses(); - final List<TIdentifierLiteral> extendsList = new ArrayList<TIdentifierLiteral>( - extendsClauses.length); + final List<TIdentifierLiteral> extendsList = new ArrayList<TIdentifierLiteral>(extendsClauses.length); for (final ISCExtendsContext extendsContext : extendsClauses) { - ISCContextRoot root = (ISCContextRoot) extendsContext - .getAbstractSCContext().getRoot(); - final String name = extendsContext.getAbstractSCContext() - .getComponentName(); + ISCContextRoot root = (ISCContextRoot) extendsContext.getAbstractSCContext().getRoot(); + final String name = extendsContext.getAbstractSCContext().getComponentName(); extendsList.add(new TIdentifierLiteral(name)); depContext.put(name, root); } @@ -330,9 +307,8 @@ public final class ContextTranslator extends AbstractComponentTranslator { final ISCCarrierSet[] carrierSets = context.getSCCarrierSets(); final List<PSet> setList = new ArrayList<PSet>(carrierSets.length); for (final ISCCarrierSet carrierSet : carrierSets) { - final ADeferredSetSet deferredSet = new ADeferredSetSet( - Arrays.asList(new TIdentifierLiteral[] { new TIdentifierLiteral( - carrierSet.getIdentifierString()) })); + final ADeferredSetSet deferredSet = new ADeferredSetSet(Arrays + .asList(new TIdentifierLiteral[] { new TIdentifierLiteral(carrierSet.getIdentifierString()) })); setList.add(deferredSet); } return new ASetsContextClause(setList); @@ -341,10 +317,8 @@ public final class ContextTranslator extends AbstractComponentTranslator { private List<PContextClause> processConstants() throws RodinDBException { final ISCConstant[] constants = context.getSCConstants(); - final List<PExpression> concreteConstants = new ArrayList<PExpression>( - constants.length); - final List<PExpression> abstractConstants = new ArrayList<PExpression>( - constants.length); + final List<PExpression> concreteConstants = new ArrayList<PExpression>(constants.length); + final List<PExpression> abstractConstants = new ArrayList<PExpression>(constants.length); for (final ISCConstant constant : constants) { boolean isAbstractConstant = false; @@ -363,15 +337,11 @@ public final class ContextTranslator extends AbstractComponentTranslator { } if (isAbstractConstant) { - abstractConstants - .add(new AIdentifierExpression( - Arrays.asList(new TIdentifierLiteral[] { new TIdentifierLiteral( - constant.getIdentifierString()) }))); + abstractConstants.add(new AIdentifierExpression(Arrays + .asList(new TIdentifierLiteral[] { new TIdentifierLiteral(constant.getIdentifierString()) }))); } else { - concreteConstants - .add(new AIdentifierExpression( - Arrays.asList(new TIdentifierLiteral[] { new TIdentifierLiteral( - constant.getIdentifierString()) }))); + concreteConstants.add(new AIdentifierExpression(Arrays + .asList(new TIdentifierLiteral[] { new TIdentifierLiteral(constant.getIdentifierString()) }))); } } @@ -398,26 +368,26 @@ public final class ContextTranslator extends AbstractComponentTranslator { return axiomsContextClause; } - private List<PPredicate> extractPredicates(final ISCAxiom[] predicates, - final boolean theorems) throws CoreException { - final List<PPredicate> list = new ArrayList<PPredicate>( - predicates.length); + private List<PPredicate> extractPredicates(final ISCAxiom[] predicates, final boolean theorems) + throws CoreException { + final List<PPredicate> list = new ArrayList<PPredicate>(predicates.length); for (final ISCAxiom element : predicates) { if (element.isTheorem() == theorems) { final PPredicate predicate = translatePredicate(ff, te, element); list.add(predicate); labelMapping.put(predicate, element); - proofspragmas.add(new ClassifiedPragma("discharged", predicate, - Arrays.asList(new String[0]), Arrays - .asList(new String[0]), NO_POS, NO_POS)); + // proofspragmas.add(new ClassifiedPragma("discharged", + // predicate, + // Arrays.asList(new String[0]), Arrays + // .asList(new String[0]), NO_POS, NO_POS)); } } return list; } - public List<ClassifiedPragma> getProofspragmas() { - return proofspragmas; - } + // public List<ClassifiedPragma> getProofspragmas() { + // return proofspragmas; + // } @Override public String getResource() { diff --git a/de.prob.core/src/de/prob/eventb/translator/Theories.java b/de.prob.core/src/de/prob/eventb/translator/Theories.java index 15d6ace44a758cc4e5b5867a332973747c4fb370..453e0c833a5859a01020060307df62b9cfebde78 100644 --- a/de.prob.core/src/de/prob/eventb/translator/Theories.java +++ b/de.prob.core/src/de/prob/eventb/translator/Theories.java @@ -377,8 +377,13 @@ public class Theories { prologOutput.openTerm("case"); prologOutput.printAtom(indArg); prologOutput.openList(); - for (FreeIdentifier fi : ex.getFreeIdentifiers()) { - prologOutput.printAtom(fi.getName()); + if(ex==null) { + throw new IllegalStateException("Empty expression for axiomatic recursive definition case " + es + + " and inductive argument " + indArg); + } else { + for (FreeIdentifier fi : ex.getFreeIdentifiers()) { + prologOutput.printAtom(fi.getName()); + } } prologOutput.closeList(); printExpression(prologOutput, ex); diff --git a/de.prob.core/src/de/prob/eventb/translator/internal/EventBMachineTranslator.java b/de.prob.core/src/de/prob/eventb/translator/internal/EventBMachineTranslator.java index 8995a4a1ba8ebbeed8ab72e95081bd2d9bc4f763..dce4c969d7b256e582d8c7decba0e8d90b1a6e73 100644 --- a/de.prob.core/src/de/prob/eventb/translator/internal/EventBMachineTranslator.java +++ b/de.prob.core/src/de/prob/eventb/translator/internal/EventBMachineTranslator.java @@ -26,11 +26,6 @@ public final class EventBMachineTranslator extends EventBTranslator { private final ISCMachineRoot machine; - /* - * (non-Javadoc) - * - * @see de.prob.core.translator.ITranslator#getPrologTerm() - */ // public String getPrologTerm() { // return term; // } diff --git a/de.prob.core/src/de/prob/exceptions/ProBException.java b/de.prob.core/src/de/prob/exceptions/ProBException.java index 79e6f3b3b1bc20d18f934b5ab864e56c063b1c49..e998c150773dbd6ae88acbde27c1d53e29122063 100644 --- a/de.prob.core/src/de/prob/exceptions/ProBException.java +++ b/de.prob.core/src/de/prob/exceptions/ProBException.java @@ -37,7 +37,7 @@ public abstract class ProBException extends Exception { this.handled = b; } - public final void notifyUserOnce() { + public void notifyUserOnce() { if (!handled) { handled = true; Logger.notifyUser(this.getMessage(), this); diff --git a/de.prob.eventb.disprover.core/.classpath b/de.prob.eventb.disprover.core/.classpath index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..eca7bdba8f03f22510b7980a94dbfe10c16c0901 100644 --- a/de.prob.eventb.disprover.core/.classpath +++ b/de.prob.eventb.disprover.core/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.prob.eventb.disprover.core/.settings/org.eclipse.jdt.core.prefs b/de.prob.eventb.disprover.core/.settings/org.eclipse.jdt.core.prefs index c537b63063ce6052bdc49c5fd0745b078f162c90..0c68a61dca867ceb49e79d2402935261ec3e3809 100644 --- a/de.prob.eventb.disprover.core/.settings/org.eclipse.jdt.core.prefs +++ b/de.prob.eventb.disprover.core/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ 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.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.prob.eventb.disprover.core/META-INF/MANIFEST.MF b/de.prob.eventb.disprover.core/META-INF/MANIFEST.MF index 8e09a35b7045ed04604c7a0de391377fcae6714f..1cf833d66be0cc1462b6fb38963e43feef74d12b 100644 --- a/de.prob.eventb.disprover.core/META-INF/MANIFEST.MF +++ b/de.prob.eventb.disprover.core/META-INF/MANIFEST.MF @@ -2,16 +2,16 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Disprover Core for EventB Bundle-SymbolicName: de.prob.eventb.disprover.core;singleton:=true -Bundle-Version: 2.0.5.qualifier +Bundle-Version: 2.0.6.qualifier Bundle-Vendor: Heinrich-Heine University Dusseldorf Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", - de.prob.core;bundle-version="[9.4.0,9.5.0)", - org.eventb.core.seqprover;bundle-version="[3.0.0,3.2.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)", + org.eventb.core.seqprover;bundle-version="[3.0.0,4.0.0)", + org.eventb.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - org.eventb.core.ast;bundle-version="[3.0.0,3.2.0)", - org.rodinp.core;bundle-version="[1.7.0,1.8.0)" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 + org.eventb.core.ast;bundle-version="[3.0.0,4.0.0)", + org.rodinp.core;bundle-version="[1.7.0,2.0.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Export-Package: de.prob.eventb.disprover.core, diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasoner.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasoner.java index 6eaa13155176cc519eb31b21f24953b437741af0..d4074c2b254fd2011d14741a2640c46190c22abb 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasoner.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasoner.java @@ -25,12 +25,10 @@ import org.rodinp.core.RodinDBException; import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog; import de.be4.classicalb.core.parser.node.AEventBContextParseUnit; import de.prob.core.Animator; -import de.prob.core.PrologException; import de.prob.eventb.disprover.core.internal.DisproverCommand; import de.prob.eventb.disprover.core.internal.ICounterExample; import de.prob.eventb.disprover.core.translation.DisproverContextCreator; import de.prob.eventb.translator.internal.TranslationVisitor; -import de.prob.exceptions.ProBException; import de.prob.logging.Logger; import de.prob.prolog.output.PrologTermStringOutput; @@ -63,25 +61,17 @@ public class DisproverReasoner implements IReasoner { ICounterExample ce = evaluateSequent(sequent, disproverInput, timeoutFactor, pm); return createDisproverResult(ce, sequent, input); - } catch (PrologException e) { - Logger.log(Logger.WARNING, Status.WARNING, e.getMessage(), e); - return ProverFactory.reasonerFailure(this, input, e.getMessage()); - } catch (ProBException e) { - Logger.log(Logger.WARNING, Status.WARNING, e.getMessage(), e); - return ProverFactory.reasonerFailure(this, input, e.getMessage()); } catch (RodinDBException e) { Logger.log(Logger.WARNING, Status.WARNING, e.getMessage(), e); return ProverFactory.reasonerFailure(this, input, e.getMessage()); } catch (InterruptedException e) { return ProverFactory.reasonerFailure(this, input, e.getMessage()); - } } private ICounterExample evaluateSequent(final IProverSequent sequent, final DisproverReasonerInput disproverInput, int timeoutFactor, - IProofMonitor pm) throws ProBException, RodinDBException, - InterruptedException { + IProofMonitor pm) throws RodinDBException, InterruptedException { // Logger.info("Calling Disprover on Sequent"); Set<Predicate> allHypotheses = new HashSet<Predicate>(); @@ -117,13 +107,22 @@ public class DisproverReasoner implements IReasoner { // find the IEventBProject belonging to the sequent IPOSequent origin = (IPOSequent) sequent.getOrigin(); - IRodinProject project = origin.getRodinProject(); - IEventBProject evbProject = (IEventBProject) project - .getAdapter(IEventBProject.class); + + IEventBProject evbProject; + + if (origin==null) { // no origin available; seems to happen in Rodin 3.5RC upon startup + System.out.println("No origin available for sequent"); + // throw new InterruptedException(); // Should we do this instead of trying to work with null project? + evbProject = null; + } else { + IRodinProject project = origin.getRodinProject(); + evbProject = (IEventBProject) project + .getAdapter(IEventBProject.class); + } ICounterExample counterExample = DisproverCommand.disprove( Animator.getAuxAnimator(), evbProject, allHypotheses, selectedHypotheses, goal, timeoutFactor, context, pm); - // Logger.info("Disprover: Result: " + counterExample.toString()); + Logger.info("Disprover: Result: " + counterExample.toString()); return counterExample; } @@ -167,13 +166,22 @@ public class DisproverReasoner implements IReasoner { "ProB: Timeout occurred."); } - if (!counterExample.counterExampleFound() && counterExample.isProof()) { + if (!counterExample.counterExampleFound() && counterExample.isProof() + && !counterExample.doubleCheckFailed()) { System.out.println(sequent.toString() + ": Proof."); return ProverFactory.makeProofRule(this, input, sequent.goal(), usedHyps, IConfidence.DISCHARGED_MAX, "ProB (no enumeration / all cases checked)"); } + if (!counterExample.counterExampleFound() && counterExample.isProof() + && counterExample.doubleCheckFailed()) { + System.out.println(sequent.toString() + ": Proof."); + return ProverFactory.makeProofRule(this, input, sequent.goal(), + usedHyps, IConfidence.DISCHARGED_MAX, + "ProB (contradiction in hypotheses)"); + } + if (!counterExample.counterExampleFound()) { System.out.println(sequent.toString() + ": Unsure."); @@ -189,12 +197,12 @@ public class DisproverReasoner implements IReasoner { && counterExample.onlySelectedHypotheses()) { System.out.println(sequent.toString() + ": Counter-Example for selected hypotheses found."); - + System.out.println(counterExample.toString()); return ProverFactory .reasonerFailure( this, input, - "ProB: Counter-Example for selected Hypotheses found, Goal not provable from selected Hypotheses (may be provable with all Hypotheses)"); + "ProB: Counter-Example to Goal for selected Hypotheses found (may be provable with all Hypotheses): " + counterExample.toString()); // use abbreviate or substring(0, Math.min(s.length(), 100)); } System.out.println(sequent.toString() + ": Counter-Example found."); diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasonerInput.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasonerInput.java index 8ad88b7bd290b382ca564ea9fa54fa5c98d06384..2f2e372d7f38e2d0cec3c08091974bf22ccf71a7 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasonerInput.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/DisproverReasonerInput.java @@ -1,21 +1,17 @@ package de.prob.eventb.disprover.core; -import org.eventb.core.ast.FormulaFactory; -import org.eventb.core.ast.ITypeEnvironment; import org.eventb.core.seqprover.IReasonerInput; -import org.eventb.core.seqprover.ITranslatableReasonerInput; import org.eventb.core.seqprover.proofBuilder.ReplayHints; /** * Input for the Disprover. The Input keeps track of the {@link DisproverMode} * that the Disprover runs in. To prevent conditional statements in the - * Disprover code, this method provides some helper mthod that return the + * Disprover code, this method provides some helper method that return the * appropriate values according to the mode. * * @author jastram */ -public class DisproverReasonerInput implements IReasonerInput, - ITranslatableReasonerInput { +public class DisproverReasonerInput implements IReasonerInput { @Override public void applyHints(ReplayHints renaming) { // TODO Auto-generated method stub @@ -33,16 +29,4 @@ public class DisproverReasonerInput implements IReasonerInput, return false; } - @Override - public ITypeEnvironment getTypeEnvironment(FormulaFactory arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public IReasonerInput translate(FormulaFactory arg0) { - // TODO Auto-generated method stub - return null; - } - } diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/command/DisproverLoadCommand.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/command/DisproverLoadCommand.java index faf38c749654af9f32dd1961db863cc42c023748..d4d437ffeda8f969b9510f1e2a9aad43961e3fb6 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/command/DisproverLoadCommand.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/command/DisproverLoadCommand.java @@ -73,6 +73,7 @@ public final class DisproverLoadCommand implements IComposableCommand { private boolean theoriesUsed() throws TranslationFailedException { try { final IRodinElement[] elements; + if (project==null) { return false;} elements = project.getRodinProject().getChildren(); for (IRodinElement element : elements) { if (element instanceof IRodinFile) { diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/CounterExample.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/CounterExample.java index 7116ec8f1f445a502d46fbe29bba395c5669aacf..56a4e0232f6459046bec5570324a6e47d0f187cd 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/CounterExample.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/CounterExample.java @@ -1,6 +1,7 @@ package de.prob.eventb.disprover.core.internal; -import java.util.*; +import java.util.SortedMap; +import java.util.TreeMap; /** * This class wraps the results from a Disprover run. It either indicates that @@ -16,6 +17,7 @@ class CounterExample implements ICounterExample { public final SortedMap<String, String> state = new TreeMap<String, String>(); private final boolean timeoutOccured; private boolean proof = false; + private boolean doubleCheckFailed = false; private boolean selectedHypotheses = false; private String reason = ""; @@ -81,4 +83,12 @@ class CounterExample implements ICounterExample { public boolean onlySelectedHypotheses() { return selectedHypotheses; } + + public void setDoubleCheckFailed(boolean b) { + doubleCheckFailed = b; + } + + public boolean doubleCheckFailed() { + return doubleCheckFailed; + } } diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/DisproverCommand.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/DisproverCommand.java index 8596f053818fcf67b9bc9360990fa697f13d31b8..60fb21f83bef35bc2b7fc2ce22fdac35113782ef 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/DisproverCommand.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/DisproverCommand.java @@ -24,7 +24,6 @@ import de.prob.core.command.StartAnimationCommand; import de.prob.eventb.disprover.core.DisproverReasoner; import de.prob.eventb.disprover.core.command.DisproverLoadCommand; import de.prob.eventb.translator.internal.TranslationVisitor; -import de.prob.exceptions.ProBException; import de.prob.parser.ISimplifiedROMap; import de.prob.prolog.output.IPrologTermOutput; import de.prob.prolog.term.ListPrologTerm; @@ -51,22 +50,25 @@ public class DisproverCommand implements IComposableCommand { private final Set<Predicate> selectedHypotheses; private final Predicate goal; private final int timeout; + private final Boolean exportPO; private static ComposedCommand composed; public DisproverCommand(Set<Predicate> allHypotheses, - Set<Predicate> selectedHypotheses, Predicate goal, int timeout) { + Set<Predicate> selectedHypotheses, Predicate goal, int timeout, + Boolean exportPO) { this.allHypotheses = allHypotheses; this.selectedHypotheses = selectedHypotheses; this.goal = goal; this.timeout = timeout; + this.exportPO = exportPO; } public static ICounterExample disprove(Animator animator, IEventBProject project, Set<Predicate> allHypotheses, - Set<Predicate> selectedHypotheses, Predicate goal, int timeout, + Set<Predicate> selectedHypotheses, Predicate goal, int timeoutFactor, AEventBContextParseUnit context, IProofMonitor pm) - throws ProBException, InterruptedException { + throws InterruptedException { Preferences prefNode = Platform.getPreferencesService().getRootNode() .node(InstanceScope.SCOPE).node("prob_disprover_preferences"); @@ -79,28 +81,41 @@ public class DisproverCommand implements IComposableCommand { final SetPreferenceCommand setCLPFD = new SetPreferenceCommand("CLPFD", Boolean.toString(prefNode.getBoolean("clpfd", true))); final SetPreferenceCommand setCHR = new SetPreferenceCommand("CHR", - Boolean.toString(prefNode.getBoolean("clpfd", true))); + Boolean.toString(prefNode.getBoolean("chr", true))); + final SetPreferenceCommand setCSE = new SetPreferenceCommand("CSE", + Boolean.toString(prefNode.getBoolean("cse", false))); + final SetPreferenceCommand setSMT = new SetPreferenceCommand( + "SMT_SUPPORTED_INTERPRETER", Boolean.toString(prefNode + .getBoolean("smt", false))); + final SetPreferenceCommand setCSEPred = new SetPreferenceCommand( + "CSE_PRED", Boolean.toString(prefNode.getBoolean("cse", false))); + final SetPreferenceCommand setDoubleEval = new SetPreferenceCommand( + "DOUBLE_EVALUATION", Boolean.toString(prefNode.getBoolean( + "doubleeval", true))); DisproverLoadCommand load = new DisproverLoadCommand(project, context); StartAnimationCommand start = new StartAnimationCommand(); DisproverCommand disprove = new DisproverCommand(allHypotheses, - selectedHypotheses, goal, timeout - * prefNode.getInt("timeout", 1000)); + selectedHypotheses, goal, + timeoutFactor * prefNode.getInt("timeout", 1000), + prefNode.getBoolean("exportpo", false)); - composed = new ComposedCommand(clear, setPrefs, setCLPFD, setCHR, load, - start, disprove); + composed = new ComposedCommand(clear, setPrefs, setCLPFD, setCHR, + setSMT, setCSE, setCSEPred, setDoubleEval, load, start, + disprove); final Job job = new ProBCommandJob("Disproving", animator, composed); job.setUser(true); job.schedule(); - while (job.getResult() == null && !pm.isCanceled()) { + while (job.getResult() == null && + (pm == null || !pm.isCanceled())) { // treat case IProofMonitor is null; done by Rodin 3.5RC at startup Thread.sleep(200); } - if (pm.isCanceled()) { + if (pm != null && pm.isCanceled()) { job.cancel(); throw new InterruptedException(); } @@ -129,6 +144,19 @@ public class DisproverCommand implements IComposableCommand { } pto.closeList(); pto.printNumber(timeout); + if (this.exportPO) { + pto.openList(); + pto.openTerm("disprover_option"); + pto.openTerm("export_po_as_machine");// Note: other valid options : wd_prover_timeout(T), unsat_core,... + pto.printAtom("/tmp/ProB_Rodin_PO_SelectedHyps.mch"); + // TO DO: provide user preference path; TO DO: we could runProBClassic(prob_location, tmp); + pto.closeTerm(); + pto.closeTerm(); + pto.closeList(); + } else { + pto.emptyList(); // do not submit extra options because we set the + // preference above; we could transmit additional valid_disprover_option + } pto.printVariable(RESULT); pto.closeTerm(); } @@ -174,6 +202,12 @@ public class DisproverCommand implements IComposableCommand { counterExample.setProof(true); } + if ("contradiction_in_hypotheses".equals(term.getFunctor())) { + counterExample = new CounterExample(false, false, false); + counterExample.setProof(true); + counterExample.setDoubleCheckFailed(true); + } + if ("solution".equals(term.getFunctor())) { counterExample = new CounterExample(true, false, false); ListPrologTerm vars = (ListPrologTerm) term.getArgument(1); diff --git a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/ICounterExample.java b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/ICounterExample.java index 13cb7f2df65388e503c6a892433b50ad23592275..2d13e21316d33885c4e49aa7dcf78fc17f36b06e 100644 --- a/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/ICounterExample.java +++ b/de.prob.eventb.disprover.core/src/de/prob/eventb/disprover/core/internal/ICounterExample.java @@ -12,4 +12,6 @@ public interface ICounterExample { public String getReason(); + public boolean doubleCheckFailed(); + } \ No newline at end of file diff --git a/de.prob.eventb.disprover.ui/.classpath b/de.prob.eventb.disprover.ui/.classpath index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..eca7bdba8f03f22510b7980a94dbfe10c16c0901 100644 --- a/de.prob.eventb.disprover.ui/.classpath +++ b/de.prob.eventb.disprover.ui/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.prob.eventb.disprover.ui/.settings/org.eclipse.jdt.core.prefs b/de.prob.eventb.disprover.ui/.settings/org.eclipse.jdt.core.prefs index c537b63063ce6052bdc49c5fd0745b078f162c90..0c68a61dca867ceb49e79d2402935261ec3e3809 100644 --- a/de.prob.eventb.disprover.ui/.settings/org.eclipse.jdt.core.prefs +++ b/de.prob.eventb.disprover.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ 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.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.prob.eventb.disprover.ui/META-INF/MANIFEST.MF b/de.prob.eventb.disprover.ui/META-INF/MANIFEST.MF index 3f936494719280c931789b2777a4d5b7bcda1628..0345c7cb616a25c9ebcfd11bd68cb4ff241b92e6 100644 --- a/de.prob.eventb.disprover.ui/META-INF/MANIFEST.MF +++ b/de.prob.eventb.disprover.ui/META-INF/MANIFEST.MF @@ -2,20 +2,20 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Disprover UI for EventB Bundle-SymbolicName: de.prob.eventb.disprover.ui;singleton:=true -Bundle-Version: 2.0.5.qualifier +Bundle-Version: 2.0.6.qualifier Bundle-Vendor: Heinrich-Heine University Dusseldorf Require-Bundle: org.eclipse.core.runtime, - org.eventb.ui;bundle-version="[3.0.0,3.2.0)", + org.eventb.ui;bundle-version="[3.0.0,4.0.0)", de.prob.eventb.disprover.core;bundle-version="[2.0.0,2.1.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - de.prob.core, - org.eventb.core.ast;bundle-version="[3.0.0,3.2.0)", - org.eventb.core.seqprover;bundle-version="[3.0.0,3.2.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)", + org.eventb.core.ast;bundle-version="[3.0.0,4.0.0)", + org.eventb.core.seqprover;bundle-version="[3.0.0,4.0.0)", org.eclipse.osgi, - org.rodinp.core;bundle-version="[1.7.0,1.8.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)", - de.prob.ui;bundle-version="7.4.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 + org.rodinp.core;bundle-version="[1.7.0,2.0.0)", + org.eventb.core;bundle-version="[3.0.0,4.0.0)", + de.prob.ui;bundle-version="[7.4.3,7.5.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Bundle-Activator: de.prob.eventb.disprover.ui.DisproverActivator diff --git a/de.prob.eventb.disprover.ui/plugin.xml b/de.prob.eventb.disprover.ui/plugin.xml index 9d24e750d23e001f5df639f2575b21f6dc5cef3e..8b0ec03affbb9f82d4f4ba94ace0f6c264559fb6 100644 --- a/de.prob.eventb.disprover.ui/plugin.xml +++ b/de.prob.eventb.disprover.ui/plugin.xml @@ -94,7 +94,7 @@ <command commandId="de.prob.eventb.disprover.ui.exportpos" icon="icons/prob_mini_logo.gif" - label="Export POs for ProB" + label="Export POs for ProB (probcli)" style="push"> </command> </menuContribution> diff --git a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverActivator.java b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverActivator.java index 8f18b5c8c04b57e675676c94bcb3826e8a5015cc..63f081a8105b05d184f300a0f8e5dabf9ee91e2a 100644 --- a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverActivator.java +++ b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverActivator.java @@ -17,26 +17,12 @@ public class DisproverActivator extends AbstractUIPlugin { public DisproverActivator() { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ @Override public void stop(BundleContext context) throws Exception { plugin = null; diff --git a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverExtendedTimeoutTacticProvider.java b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverExtendedTimeoutTacticProvider.java index 7d8c69b7a66e075fb510a05599a4ea465bbf7167..23de38c28ed35e7f75d5266dc626c496193281f0 100644 --- a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverExtendedTimeoutTacticProvider.java +++ b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverExtendedTimeoutTacticProvider.java @@ -1,40 +1,31 @@ package de.prob.eventb.disprover.ui; -import java.util.*; +import java.util.Collections; +import java.util.List; +import org.eclipse.swt.graphics.Image; import org.eventb.core.ast.Predicate; -import org.eventb.core.seqprover.*; +import org.eventb.core.seqprover.IProofTreeNode; +import org.eventb.core.seqprover.IReasonerInput; +import org.eventb.core.seqprover.ITactic; import org.eventb.core.seqprover.tactics.BasicTactics; -import org.eventb.ui.prover.*; +import org.eventb.ui.prover.DefaultTacticProvider; +import org.eventb.ui.prover.IPredicateApplication; +import org.eventb.ui.prover.ITacticApplication; -import de.prob.eventb.disprover.core.*; +import de.prob.eventb.disprover.core.Disprover; +import de.prob.eventb.disprover.core.DisproverReasonerInput; public class DisproverExtendedTimeoutTacticProvider extends DefaultTacticProvider { - - protected boolean useContexts() { - return false; - } - - protected static class MyPredicateApplication implements ITacticApplication { - - private final IProofTreeNode node; - - public MyPredicateApplication(IProofTreeNode node) { - this.node = node; - } - + protected static class MyPredicateApplication implements + IPredicateApplication { @Override public ITactic getTactic(String[] inputs, String globalInput) { - return getTactic(node, globalInput, inputs); - } - - public ITactic getTactic(IProofTreeNode node, String globalInput, - String[] inputs) { - IReasonerInput reasonerInput = new DisproverReasonerInput(); return BasicTactics.reasonerTac( - Disprover.createDisproverReasoner(), reasonerInput); + Disprover.createExtendedTimeoutDisproverReasoner(10), + reasonerInput); } @Override @@ -42,6 +33,18 @@ public class DisproverExtendedTimeoutTacticProvider extends return "de.prob.eventb.disprover.ui.disproverTactic"; } + @Override + public Image getIcon() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTooltip() { + // TODO Auto-generated method stub + return null; + } + } public DisproverExtendedTimeoutTacticProvider() { @@ -53,7 +56,7 @@ public class DisproverExtendedTimeoutTacticProvider extends IProofTreeNode node, Predicate hyp, String globalInput) { if (node != null && node.isOpen()) { - ITacticApplication application = new MyPredicateApplication(node); + ITacticApplication application = new MyPredicateApplication(); return Collections.singletonList(application); } return Collections.<ITacticApplication> emptyList(); diff --git a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverPreferences.java b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverPreferences.java index f2f8e38d7705276fa88e8d607295f8b5e142bc27..e0fa5ff5947bfce3d0ad68375fc1e0c336ac6cde 100644 --- a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverPreferences.java +++ b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverPreferences.java @@ -5,11 +5,24 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; -import org.osgi.service.prefs.*; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; public class DisproverPreferences extends PreferencePage implements IWorkbenchPreferencePage { @@ -38,6 +51,10 @@ public class DisproverPreferences extends PreferencePage implements private Text timeoutTextField; private Button checkCLPFD; private Button checkCHR; + private Button checkCSE; + private Button checkSMT; + private Button checkDoubleEval; + private Button checkExportSelectedHyps; public DisproverPreferences() { super(); @@ -127,6 +144,27 @@ public class DisproverPreferences extends PreferencePage implements Label chrRemark = new Label(pageComponent, SWT.WRAP); chrRemark .setText("Note: The CHR Solver can only be used in conjunction with the CLP(FD) solver."); + chrRemark.setLayoutData(gridData2); + + new Label(pageComponent, SWT.NONE) + .setText("Use Common Subexpression Elemination:"); + checkCSE = new Button(pageComponent, SWT.CHECK); + checkCSE.setSelection(prefNode.getBoolean("cse", false)); + + new Label(pageComponent, SWT.NONE) + .setText("Enable SMT solver support in ProB interpreter:"); + checkSMT = new Button(pageComponent, SWT.CHECK); + checkSMT.setSelection(prefNode.getBoolean("smt", false)); + + new Label(pageComponent, SWT.NONE) + .setText("Check (Hypotheses ^ Goal) in addition to (Hypotheses ^ not Goal) to identify contradiction in hypotheses:"); + checkDoubleEval = new Button(pageComponent, SWT.CHECK); + checkDoubleEval.setSelection(prefNode.getBoolean("doubleeval", false)); + + new Label(pageComponent, SWT.NONE) + .setText("Export Goal and selected Hypotheses to B file (/tmp/ProB_Rodin_PO_SelectedHyps.mch):"); + checkExportSelectedHyps = new Button(pageComponent, SWT.CHECK); + checkExportSelectedHyps.setSelection(prefNode.getBoolean("exportpo", false)); return pageComponent; } @@ -136,6 +174,10 @@ public class DisproverPreferences extends PreferencePage implements prefNode.put("timeout", timeoutTextField.getText()); prefNode.putBoolean("clpfd", checkCLPFD.getSelection()); prefNode.putBoolean("chr", checkCHR.getSelection()); + prefNode.putBoolean("cse", checkCSE.getSelection()); + prefNode.putBoolean("smt", checkSMT.getSelection()); + prefNode.putBoolean("doubleeval", checkDoubleEval.getSelection()); + prefNode.putBoolean("exportpo", checkExportSelectedHyps.getSelection()); try { prefNode.flush(); } catch (BackingStoreException e) { diff --git a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverTacticProvider.java b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverTacticProvider.java index f7802e0351a3796fe26e079c5b74d453bbbda195..2628c6f4d3f47292274597322245c32997c57731 100644 --- a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverTacticProvider.java +++ b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/DisproverTacticProvider.java @@ -17,11 +17,6 @@ import de.prob.eventb.disprover.core.Disprover; import de.prob.eventb.disprover.core.DisproverReasonerInput; public class DisproverTacticProvider extends DefaultTacticProvider { - - protected boolean useContexts() { - return false; - } - protected static class MyPredicateApplication implements IPredicateApplication { @Override diff --git a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/export/ExportPOsHandler.java b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/export/ExportPOsHandler.java index 01176ac53f0bff8a88529d0643a6b30a091afb95..653cd59a4f6ff231350639338087ef0339aebdf6 100644 --- a/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/export/ExportPOsHandler.java +++ b/de.prob.eventb.disprover.ui/src/de/prob/eventb/disprover/ui/export/ExportPOsHandler.java @@ -56,7 +56,7 @@ public class ExportPOsHandler extends AbstractHandler implements IHandler { final Shell shell = HandlerUtil.getActiveShell(event); final String fileName = askForExportFile(prefs, shell, root); if (fileName != null) { - exportPOs(fileName, root); + exportPOs(shell, fileName, root); } } return null; @@ -104,7 +104,8 @@ public class ExportPOsHandler extends AbstractHandler implements IHandler { return result; } - public static void exportPOs(final String filename, final IEventBRoot root) { + public static void exportPOs(final Shell shell, final String filename, + final IEventBRoot root) { final boolean isSafeToWrite = isSafeToWrite(filename); if (isSafeToWrite) { @@ -132,8 +133,11 @@ public class ExportPOsHandler extends AbstractHandler implements IHandler { } catch (IOException e) { Logger.notifyUser("Unable to create file '" + filename + "'"); } catch (RodinDBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + MessageDialog + .openError( + shell, + "A RodinDBException Occured", + "A RodinDBException occured while fetching sequents. Exported POs might be incomplete."); } finally { if (fw != null) { fw.close(); diff --git a/de.prob.plugin/.classpath b/de.prob.plugin/.classpath index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..eca7bdba8f03f22510b7980a94dbfe10c16c0901 100644 --- a/de.prob.plugin/.classpath +++ b/de.prob.plugin/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.prob.plugin/META-INF/MANIFEST.MF b/de.prob.plugin/META-INF/MANIFEST.MF index 0e6729300d3e168ca78c55c5ef9a151b9883d0fd..7c80067b4bc0fb660d1304ddeb7f0534c26b132c 100644 --- a/de.prob.plugin/META-INF/MANIFEST.MF +++ b/de.prob.plugin/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Rodin2 UI Bindings Bundle-SymbolicName: de.prob.plugin;singleton:=true -Bundle-Version: 2.3.2.qualifier -Fragment-Host: de.prob.ui;bundle-version="[7.4.0,7.5.0)" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Version: 2.3.3.qualifier +Fragment-Host: de.prob.ui;bundle-version="[7.4.3,7.5.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: HHU Düsseldorf STUPS Group diff --git a/de.prob.symbolic/.classpath b/de.prob.symbolic/.classpath index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..eca7bdba8f03f22510b7980a94dbfe10c16c0901 100644 --- a/de.prob.symbolic/.classpath +++ b/de.prob.symbolic/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/de.prob.symbolic/.settings/org.eclipse.jdt.core.prefs b/de.prob.symbolic/.settings/org.eclipse.jdt.core.prefs index c537b63063ce6052bdc49c5fd0745b078f162c90..0c68a61dca867ceb49e79d2402935261ec3e3809 100644 --- a/de.prob.symbolic/.settings/org.eclipse.jdt.core.prefs +++ b/de.prob.symbolic/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ 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.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.prob.symbolic/META-INF/MANIFEST.MF b/de.prob.symbolic/META-INF/MANIFEST.MF index 718636bd34bb20e63d61c454bb1fdee61a46fe30..2cc5f25aba90c8155d66fc99ba10200ab0bb6d13 100644 --- a/de.prob.symbolic/META-INF/MANIFEST.MF +++ b/de.prob.symbolic/META-INF/MANIFEST.MF @@ -2,15 +2,15 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Symbolic Evaluation Support Bundle-SymbolicName: de.prob.symbolic;singleton:=true -Bundle-Version: 7.4.2.qualifier +Bundle-Version: 7.4.3.qualifier Bundle-Activator: de.prob.symbolic.Activator Require-Bundle: org.eclipse.core.runtime, - de.prob.core;bundle-version="[9.4.0,9.5.0)", - org.eventb.ui;bundle-version="[3.0.0,3.2.0)", - de.prob.ui;bundle-version="[7.4.0,7.5.0)", - org.rodinp.core;bundle-version="[1.7.0,1.8.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)", + org.eventb.ui;bundle-version="[3.0.0,4.0.0)", + de.prob.ui;bundle-version="[7.4.3,7.5.0)", + org.rodinp.core;bundle-version="[1.7.0,2.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)" + org.eventb.core;bundle-version="[3.0.0,4.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: HHU Düsseldorf STUPS Group diff --git a/de.prob.symbolic/src/de/prob/symbolic/Activator.java b/de.prob.symbolic/src/de/prob/symbolic/Activator.java index c5cb44695357b9fe34fa8bf42345d9b4d3e469ec..3ea45104fe4cc24621e63c38abc0c9e507a3f7d3 100644 --- a/de.prob.symbolic/src/de/prob/symbolic/Activator.java +++ b/de.prob.symbolic/src/de/prob/symbolic/Activator.java @@ -27,13 +27,6 @@ public class Activator extends AbstractUIPlugin { public Activator() { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ @Override public void start(BundleContext context) throws Exception { super.start(context); @@ -43,13 +36,6 @@ public class Activator extends AbstractUIPlugin { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ @Override public void stop(BundleContext context) throws Exception { plugin = null; diff --git a/de.prob.ui/.classpath b/de.prob.ui/.classpath index 100092b255b1ad1a077f31d3e5931b134f6f5f45..33fdb1188c2a54df76fa41485233855aa0f95516 100644 --- a/de.prob.ui/.classpath +++ b/de.prob.ui/.classpath @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry exported="true" kind="lib" path="lib/apache_xmlrpc.jar"/> <classpathentry exported="true" kind="lib" path="lib/ws_commons.jar"/> <classpathentry kind="output" path="bin"/> - <classpathentry exported="true" kind="lib" path="lib/dependencies/commons-codec-1.6.jar"/> + <classpathentry exported="true" kind="lib" path="lib/dependencies/commons-codec-1.8.jar"/> </classpath> diff --git a/de.prob.ui/META-INF/MANIFEST.MF b/de.prob.ui/META-INF/MANIFEST.MF index a4bdc20fdd9b5502c53ad00bc577bd83b2b6cf8e..82f8238831d8b63e36f23bac45894b55e1a1a022 100644 --- a/de.prob.ui/META-INF/MANIFEST.MF +++ b/de.prob.ui/META-INF/MANIFEST.MF @@ -2,23 +2,23 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ProB Ui Plug-in Bundle-SymbolicName: de.prob.ui;singleton:=true -Bundle-Version: 7.4.2.qualifier +Bundle-Version: 7.4.3.qualifier Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", - de.prob.core;bundle-version="[9.4.0,9.5.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)", + de.prob.core;bundle-version="[9.4.5,9.5.0)", + org.eventb.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.101,4.0.0)", org.eclipse.gef;bundle-version="[3.7.0,4.0.0)", - org.eventb.core.ast;bundle-version="[3.0.0,3.2.0)", - org.rodinp.core;bundle-version="[1.7.0,1.8.0)" + org.eventb.core.ast;bundle-version="[3.0.0,4.0.0)", + org.rodinp.core;bundle-version="[1.7.0,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-Vendor: HHU Düsseldorf STUPS Group Bundle-Activator: de.prob.ui.ProbUiPlugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: de.prob.ui Bundle-ClassPath: lib/apache_xmlrpc.jar, lib/ws_commons.jar, - lib/dependencies/commons-codec-1.6.jar, + lib/dependencies/commons-codec-1.8.jar, . diff --git a/de.prob.ui/build.properties b/de.prob.ui/build.properties index ebde6b8f79bbb0cfd7a64cb582dcfc2a31e04089..5a878a48d6d518beb16d7d1ea6ff6d4c7197d980 100644 --- a/de.prob.ui/build.properties +++ b/de.prob.ui/build.properties @@ -6,4 +6,4 @@ bin.includes = META-INF/,\ icons/,\ lib/apache_xmlrpc.jar,\ lib/ws_commons.jar,\ - lib/dependencies/commons-codec-1.6.jar + lib/dependencies/commons-codec-1.8.jar diff --git a/de.prob.ui/plugin.xml b/de.prob.ui/plugin.xml index d7fbd3701c61ff4f570797202ad465b683d9ce93..b4914d0a1c2db03ecf6a9b255a947eebc874a7ee 100644 --- a/de.prob.ui/plugin.xml +++ b/de.prob.ui/plugin.xml @@ -8,7 +8,7 @@ <page class="de.prob.ui.eventb.ClassicPreferences" id="de.prob.ui.probclassic" - name="ProB Classic" + name="ProB Standalone" category="probpreferences"> </page> </extension> @@ -295,7 +295,7 @@ </command> <command id="de.prob.ui.show_custom_precondition_dialog" - name="Execute with additional Guard"> + name="Execute with Additional Guard Constraint"> </command> <command categoryId="de.prob.ui.commands.category" @@ -315,7 +315,12 @@ <command categoryId="de.prob.ui.commands.category" id="de.prob.ui.assertion_check" - name="Check Assertions"> + name="Check Context Theorems"> + </command> + <command + categoryId="de.prob.ui.commands.category" + id="de.prob.ui.assertion_dyn_check" + name="Check Invariant Theorems"> </command> <command categoryId="de.prob.ui.commands.category" @@ -346,7 +351,7 @@ </command> <command id="de.prob.ui.ltl.showcounterexampleinhistory" - name="Show counter-example in history"> + name="Show Counter-example in History"> </command> <command id="de.prob.ui.ltl.counterexamplezoominhandler" @@ -364,11 +369,6 @@ id="de.prob.ui.newcore.export" name="Export for new Core"> </command> - <command - categoryId="de.prob.ui.commands.category" - id="de.prob.ui.assertion_check" - name="Check Context Theorems"> - </command> <command categoryId="de.prob.ui.commands.category" id="de.prob.ui.find_valid_state" @@ -508,12 +508,6 @@ value="enabled"> </equals> </with> - <with - variable="de.prob.core.history.backward_service"> - <equals - value="enabled"> - </equals> - </with> </and> </enabledWhen> </handler> @@ -529,12 +523,6 @@ <equals value="enabled"> </equals> - </with> - <with - variable="de.prob.core.history.forward_service"> - <equals - value="enabled"> - </equals> </with> </and> </enabledWhen> @@ -814,6 +802,28 @@ class="de.prob.ui.assertion.AssertionCheckHandler"> </class> </handler> + <handler + commandId="de.prob.ui.assertion_dyn_check"> + <enabledWhen> + <or> + <with + variable="de.prob.core.model_loaded"> + <equals + value="enabled"> + </equals> + </with> + <with + variable="de.prob.core.context_loaded"> + <equals + value="enabled"> + </equals> + </with> + </or> + </enabledWhen> + <class + class="de.prob.ui.assertion.AssertionDynCheckHandler"> + </class> + </handler> <handler commandId="de.prob.ui.find_valid_state"> <class @@ -1086,17 +1096,17 @@ commandId="de.prob.ui.navigator.context" icon="icons/new_prob_mini.png" id="more_commands" - label="ProB Classic ..."> + label="ProB Standalone ..."> <command commandId="de.prob.ui.newcore.export" icon="icons/prob_mini_logo.gif" - label="Export for use in ProB classic" + label="Export for use in ProB Standalone" style="push"> </command> <command commandId="de.prob.ui.classic.open" icon="icons/prob_mini_logo.gif" - label="Open in ProB classic" + label="Open in ProB Standalone" style="push"> </command> <visibleWhen> @@ -1175,6 +1185,13 @@ mnemonic="C" style="push"> </command> + <command + commandId="de.prob.ui.assertion_dyn_check" + icon="icons/CBCInvariantCheck.png" + label="Invariant Theorems" + mnemonic="T" + style="push"> + </command> <command commandId="de.prob.ui.find_valid_state" icon="icons/CBCInvariantCheck.png" @@ -1267,17 +1284,6 @@ priorityLevel="workbench"> </variable> </sourceProvider> - <sourceProvider - provider="de.prob.ui.services.HistoryActiveProvider"> - <variable - name="de.prob.core.history.forward_service" - priorityLevel="workbench"> - </variable> - <variable - name="de.prob.core.history.backward_service" - priorityLevel="workbench"> - </variable> - </sourceProvider> <sourceProvider provider="de.prob.ui.ltl.CounterExampleLoadedProvider"> <variable diff --git a/de.prob.ui/src/de/prob/ui/StateBasedViewPart.java b/de.prob.ui/src/de/prob/ui/StateBasedViewPart.java index 49ce89acfd7670a29d738ddc458906da485f712d..85640a4968f7d9bd243de71bd37548e8a9188c42 100644 --- a/de.prob.ui/src/de/prob/ui/StateBasedViewPart.java +++ b/de.prob.ui/src/de/prob/ui/StateBasedViewPart.java @@ -132,11 +132,7 @@ public abstract class StateBasedViewPart extends ViewPart implements }; Display.getDefault().asyncExec(runnable); - ISourceProviderService service = (ISourceProviderService) getSite() - .getService(ISourceProviderService.class); - HistoryActiveProvider sourceProvider = (HistoryActiveProvider) service - .getSourceProvider(HistoryActiveProvider.FORWARD_SERVICE); - sourceProvider.historyChange(); + } diff --git a/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckFinishedListener.java b/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckFinishedListener.java index 4f8826d8280817a420e3f5c14c118903f7ee0498..4836aadd12d0ca12c6399908cdf727fc4e8dbb10 100644 --- a/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckFinishedListener.java @@ -18,7 +18,7 @@ import de.prob.exceptions.ProBException; import de.prob.logging.Logger; /** - * This JobChangeAdapter presents the user the results of a deadlock freedom + * This JobChangeAdapter presents the user the results of a assertion * check. * * @see AssertionCheckHandler @@ -50,23 +50,23 @@ public class AssertionCheckFinishedListener extends ProBJobFinishedListener { case NO_COUNTER_EXAMPLE_EXISTS: dialogType = MessageDialog.INFORMATION; dialogTitle = "No Counter-Example Exists"; - message = "No Counter-Example to the Context Theorems exists."; + message = "No Counter-Example to the Context Theorems exists (for current settings of deferred sets).\nIf your model contains deferred sets, there may exist counter-examples for other sizes of these sets."; break; case NO_COUNTER_EXAMPLE_FOUND: dialogType = MessageDialog.INFORMATION; dialogTitle = "No Counter-Example Found"; - message = "No Counter-Example to the Context Theorems was found."; + message = "No Counter-Example to the Context Theorems was found (but one may exist)."; break; case COUNTER_EXAMPLE: dialogType = MessageDialog.WARNING; dialogTitle = "COUNTER-EXAMPLE FOUND!"; - message = "The model contains a Counter-Example state, it will be shown in the state view."; + message = "A counter-example to the context theorems was found: it will be shown in the state view.\nThis counter-example state satisfies the axioms but not all theorems."; displayCounterExample(command, animator); break; case INTERRUPTED: dialogType = MessageDialog.WARNING; dialogTitle = " Interrupt"; - message = "The deadlock check has been interrupted by the user or a time-out."; + message = "The context theorem check has been interrupted by the user or a time-out."; break; default: Logger.notifyUser("Unexpected result: " + result); @@ -74,7 +74,7 @@ public class AssertionCheckFinishedListener extends ProBJobFinishedListener { } } if (shell.isDisposed()) { - System.out.println("Deadlock freedom check finished: " + System.out.println("Context Theorems check finished: " + dialogTitle); } else { final Runnable runnable = new Runnable() { diff --git a/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckHandler.java b/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckHandler.java index e311721be347f77ab7d10108c2e6cd4fbe31b545..109774b1e71c7b13481926a61c1d25afbca38376 100644 --- a/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckHandler.java +++ b/de.prob.ui/src/de/prob/ui/assertion/AssertionCheckHandler.java @@ -17,8 +17,7 @@ import de.prob.core.command.ConstraintBasedAssertionCheckCommand; import de.prob.logging.Logger; /** - * This handler provides a simple dialog to ask for an optional predicate to - * check for deadlocks in the model. + * This handler provides a way to start the static assertion checking command * * @author plagge */ @@ -29,7 +28,7 @@ public class AssertionCheckHandler extends AbstractHandler { if (Animator.getAnimator().isMachineLoaded()) { performAssertionCheck(shell); } else { - Logger.notifyUser("No ProB animation running. This is a bug. Please submit a report. Error in declaraion for class DeadlockCheckHandler"); + Logger.notifyUser("No ProB animation running. This is a bug. Please submit a report. Error in declaraion for class AssertionCheckHandler"); } return null; } diff --git a/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckFinishedListener.java b/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckFinishedListener.java new file mode 100644 index 0000000000000000000000000000000000000000..ee383a465456e818b25d82c799c0f414833ed2d5 --- /dev/null +++ b/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckFinishedListener.java @@ -0,0 +1,104 @@ +/** + * + */ +package de.prob.ui.assertion; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import de.prob.core.Animator; +import de.prob.core.ProBJobFinishedListener; +import de.prob.core.command.ConstraintBasedDynamicAssertionCheckCommand; +import de.prob.core.command.ConstraintBasedDynamicAssertionCheckCommand.ResultType; +import de.prob.core.command.ExecuteOperationCommand; +import de.prob.core.command.IComposableCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; + +/** + * This JobChangeAdapter presents the user the results of a assertion + * check. + * + * @see AssertionCheckHandler + * + * @author plagge + */ +public class AssertionDynCheckFinishedListener extends ProBJobFinishedListener { + private final Shell shell; + + public AssertionDynCheckFinishedListener(final Shell shell) { + this.shell = shell; + } + + @Override + protected void showResult(final IComposableCommand cmd, + final Animator animator) { + final ConstraintBasedDynamicAssertionCheckCommand command = (ConstraintBasedDynamicAssertionCheckCommand) cmd; + final ResultType result = command.getResult(); + final int dialogType; + final String dialogTitle; + final String message; + + if (result == null) { + dialogType = MessageDialog.ERROR; + dialogTitle = "Errow During Constraint Based Check"; + message = "ProB did not return a result"; + } else { + switch (result) { + case NO_COUNTER_EXAMPLE_EXISTS: + dialogType = MessageDialog.INFORMATION; + dialogTitle = "No Counter-Example Exists"; + message = "No counter-example to the invariant theorems exists (for current settings of deferred sets).\nIf your model contains deferred sets, there may exist counter-examples for other sizes of these sets."; + break; + case NO_COUNTER_EXAMPLE_FOUND: + dialogType = MessageDialog.INFORMATION; + dialogTitle = "No Counter-Example Found"; + message = "No counter-example to the invariant theorems was found (but one may exist)."; + break; + case COUNTER_EXAMPLE: + dialogType = MessageDialog.WARNING; + dialogTitle = "COUNTER-EXAMPLE FOUND!"; + message = "A counter-example to the invariant theorems was found: it will be shown in the state view.\nThis counter-example state satisfies the invariants but not all theorems. It may not be reachable from the initialisation."; + displayCounterExample(command, animator); + break; + case INTERRUPTED: + dialogType = MessageDialog.WARNING; + dialogTitle = " Interrupt"; + message = "The assertion check has been interrupted by the user or a time-out."; + break; + default: + Logger.notifyUser("Unexpected result: " + result); + return; + } + } + if (shell.isDisposed()) { + System.out.println("Invariant Theorems check finished: " + + dialogTitle); + } else { + final Runnable runnable = new Runnable() { + @Override + public void run() { + MessageDialog.open(dialogType, shell, dialogTitle, message, + SWT.NONE); + } + }; + shell.getDisplay().asyncExec(runnable); + } + } + + private void displayCounterExample( + final ConstraintBasedDynamicAssertionCheckCommand command, + final Animator animator) { + final Operation operation = command.getCounterExampleOperation(); + try { + // we do not reset the history because we want to keep the root + // state, we just start a new path from root + animator.getHistory().gotoPos(0); + ExecuteOperationCommand.executeOperation(animator, operation); + } catch (ProBException e) { + e.notifyUserOnce(); + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckHandler.java b/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..57a08f3d6489cc3802ae5518b3095f0cd3f87e55 --- /dev/null +++ b/de.prob.ui/src/de/prob/ui/assertion/AssertionDynCheckHandler.java @@ -0,0 +1,55 @@ +/** + * + */ +package de.prob.ui.assertion; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import de.prob.core.Animator; +import de.prob.core.LanguageDependendAnimationPart; +import de.prob.core.ProBCommandJob; +import de.prob.core.command.ConstraintBasedDynamicAssertionCheckCommand; +import de.prob.logging.Logger; + +/** + * This handler provides a way to start the *dynamic* assertion checking command + * + * @author plagge + */ +public class AssertionDynCheckHandler extends AbstractHandler { + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + final Shell shell = HandlerUtil.getActiveShell(event); + if (Animator.getAnimator().isMachineLoaded()) { + performAssertionCheck(shell); + } else { + Logger.notifyUser("No ProB animation running. This is a bug. Please submit a report. Error in declaraion for class AssertionDynCheckHandler"); + } + return null; + } + + private void performAssertionCheck(final Shell shell) + throws ExecutionException { + final Animator animator = Animator.getAnimator(); + final LanguageDependendAnimationPart ldp = animator + .getLanguageDependendPart(); + startCheck(animator, ldp, shell); + + } + + private void startCheck(final Animator animator, + final LanguageDependendAnimationPart ldp, final Shell shell) + throws ExecutionException { + final ConstraintBasedDynamicAssertionCheckCommand command = new ConstraintBasedDynamicAssertionCheckCommand(); + final Job job = new ProBCommandJob( + "Checking Machine Theorems from Invariants Clause", animator, command); + job.setUser(true); + job.addJobChangeListener(new AssertionDynCheckFinishedListener(shell)); + job.schedule(); + } +} diff --git a/de.prob.ui/src/de/prob/ui/deadlock/DeadlockCheckFinishedListener.java b/de.prob.ui/src/de/prob/ui/deadlock/DeadlockCheckFinishedListener.java index e49a329613169306d3c52687a2d9f5332161c340..5cda9e47083145c1ecf25cef3437f7845096d5c3 100644 --- a/de.prob.ui/src/de/prob/ui/deadlock/DeadlockCheckFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/deadlock/DeadlockCheckFinishedListener.java @@ -49,7 +49,7 @@ public class DeadlockCheckFinishedListener extends ProBJobFinishedListener { case NO_DEADLOCK: dialogType = MessageDialog.INFORMATION; dialogTitle = "No Deadlock Found"; - message = "The model does not contain any deadlock."; + message = "The model does not contain any deadlock (for current settings of deferred sets).\nIf your model contains deferred sets, there may exist counter-examples for other sizes of these sets."; break; case ERROR: dialogType = MessageDialog.ERROR; @@ -59,7 +59,7 @@ public class DeadlockCheckFinishedListener extends ProBJobFinishedListener { case DEADLOCK_FOUND: dialogType = MessageDialog.WARNING; dialogTitle = "DEADLOCK FOUND!"; - message = "The model contains a deadlocking state satisfying the invariant, it will be shown in the state view."; + message = "The model contains a deadlocking state satisfying the invariant, it will be shown in the state view.\nThe state may not be reachable from the initialisation."; displayDeadlock(command, animator); break; case INTERRUPTED: diff --git a/de.prob.ui/src/de/prob/ui/errorview/StateErrorView.java b/de.prob.ui/src/de/prob/ui/errorview/StateErrorView.java index a76ae1f638b31e9565db384e911bdeaa951b4d19..c139479ae54d50a17c9fe8e4995be90b19564449 100644 --- a/de.prob.ui/src/de/prob/ui/errorview/StateErrorView.java +++ b/de.prob.ui/src/de/prob/ui/errorview/StateErrorView.java @@ -33,7 +33,7 @@ public class StateErrorView extends StateBasedViewPart { @Override public Control createStatePartControl(final Composite parent) { - SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH); + SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH | SWT.NO_TRIM); // can we use things likw SWT.NOTRIM createErrorTree(sashForm); @@ -50,12 +50,12 @@ public class StateErrorView extends StateBasedViewPart { errorTree = new TreeViewer(sashForm); errorTree.getTree().setHeaderVisible(false); errorTree.getTree().setLinesVisible(false); - errorTree.setAutoExpandLevel(2); + errorTree.setAutoExpandLevel(3); TreeViewerColumn col = new TreeViewerColumn(errorTree, SWT.LEFT); col.getColumn().setText("Short description"); col.getColumn().setResizable(true); - col.getColumn().setWidth(100); + col.getColumn().setWidth(150); errorTree.setContentProvider(new ErrorContentProvider()); errorTree.setLabelProvider(new ErrorLabelProvider()); diff --git a/de.prob.ui/src/de/prob/ui/eventb/ClassicPreferences.java b/de.prob.ui/src/de/prob/ui/eventb/ClassicPreferences.java index d078c9eee3f6aa09dce6b386c880545fa54026b4..1b3d65db9e473cbdac6b92baee99dd770046bb3b 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/ClassicPreferences.java +++ b/de.prob.ui/src/de/prob/ui/eventb/ClassicPreferences.java @@ -45,6 +45,7 @@ public class ClassicPreferences extends PreferencePage implements super.widgetSelected(e); FileDialog dialog = new FileDialog(shell, SWT.OPEN); String open = dialog.open(); + open = open.replaceAll(" ", "\\\\ "); text.setText(open); } @@ -77,7 +78,7 @@ public class ClassicPreferences extends PreferencePage implements pageComponent.setLayout(layout); Label label = new Label(pageComponent, SWT.NONE); - label.setText("Location of ProB classic:"); + label.setText("Location of ProB Standalone:"); text = new Text(pageComponent, SWT.NONE); String location = prefNode.get("location", ""); // text.setLayoutData(new RowData(100, SWT.DEFAULT)); @@ -85,11 +86,11 @@ public class ClassicPreferences extends PreferencePage implements Button browseButton = new Button(pageComponent, SWT.PUSH); browseButton.setText("Browse"); - browseButton.addSelectionListener(new PushButton(pageComponent - .getShell(), text)); + browseButton.addSelectionListener(new PushButton(pageComponent.getShell(), text)); Label versionRemark = new Label(pageComponent, SWT.WRAP); - versionRemark - .setText("Note: This needs a tcl/tk version of ProB that is not older than 1.3.0 Beta6\nYou can obtain a copy of ProB from http://www.stups.uni-duesseldorf.de/ProB\n"); + versionRemark.setText( + "Note: This needs a version of ProB2-UI (jar file) that is at least 1.0.1 or a version of ProB Tcl/Tk that is at least 1.3.1.\nYou can obtain both from http://www.stups.uni-duesseldorf.de/ProB\n"); // precisely + // 1.3.0-beta6 GridData gridData2 = new GridData(); gridData2.horizontalSpan = 3; diff --git a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingDialog.java b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingDialog.java index b3aef5857ee502c296c91b039c33d8f05f58697e..01127b24ab12c99920b23949488036eb0b127f9f 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingDialog.java +++ b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingDialog.java @@ -51,6 +51,9 @@ public class ModelCheckingDialog extends Dialog { final Button[] checks) { HashSet<ModelCheckingSearchOption> result = new HashSet<ModelCheckingSearchOption>(); for (int i = 0; i < checks.length; i++) { + // store selection for next model checking dialog + ModelCheckingSearchOption.get(i).setEnabledByDefault( + checks[i].getSelection()); if (checks[i].getSelection()) { result.add(ModelCheckingSearchOption.get(i)); } @@ -66,6 +69,7 @@ public class ModelCheckingDialog extends Dialog { break; } } + SymmetryReductionOption.setSelectedOption(symmetryOption); return SymmetryReductionOption.get(symmetryOption).name(); } @@ -75,8 +79,7 @@ public class ModelCheckingDialog extends Dialog { job = new ModelCheckingJob("Model Checking", selectSettings, symmetryOption); job.setUser(true); - job.addJobChangeListener(new ModelCheckingFinishedListener( - shell)); + job.addJobChangeListener(new ModelCheckingFinishedListener(shell)); job.schedule(); } @@ -129,7 +132,7 @@ public class ModelCheckingDialog extends Dialog { for (int i = 0; i < symmetryOptions.length; i++) { symmetry[i] = new Button(group, SWT.RADIO); symmetry[i].setText(symmetryOptions[i].getDescription()); - symmetry[i].setSelection(symmetryOptions[i].isDefault()); + symmetry[i].setSelection(symmetryOptions[i].isSelectedOption()); } return symmetry; } diff --git a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java index 0383d34e10e6b46f64490993d6d10fc00bb0bc8a..6a3b4744a75fa558a81e4f407442c2aa074d469c 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java @@ -1,5 +1,5 @@ /** - * (c) 2009-11 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * (c) 2009-20 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, * Heinrich Heine Universitaet Duesseldorf * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ @@ -193,12 +193,12 @@ public class ModelCheckingFinishedListener extends JobChangeAdapter { private String createOkButNotFinishedResult() { return "No errors found, but not all possible " - + "nodes have been visited (Due to animation parameter restrictions)."; + + "states have been visited (Due to animation parameter restrictions)."; } private String createOkResult() { return "No errors found\n" - + "Model Checking finished, all nodes visited.\n"; + + "Model Checking finished, all states visited.\n"; } private void replayErrorTrace() throws ProBException { @@ -222,7 +222,7 @@ public class ModelCheckingFinishedListener extends JobChangeAdapter { private void appendCoverageStatistics(final ComputeCoverageResult coverage, final String PID, final MultiStatus info) { info.add(new Status(IStatus.INFO, PID, 1, "Coverage statistics:", null)); - info.add(new Status(IStatus.INFO, PID, 1, "Total Number of Nodes:" + info.add(new Status(IStatus.INFO, PID, 1, "Total Number of States:" + coverage.getTotalNumberOfNodes(), null)); info.add(new Status(IStatus.INFO, PID, 1, "Total Number of Transitions:" diff --git a/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java b/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java index 47cd0d4d47b989635fc5520e5c2cb9d73a3ff5b5..c5832a0687232e40289c3e77577f165e4283a9a7 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java @@ -1,5 +1,7 @@ package de.prob.ui.eventb; +import de.prob.core.LimitedLogger; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -9,13 +11,14 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; +//import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; import org.eventb.core.IEventBRoot; -import org.eventb.core.IMachineRoot; +//import org.eventb.core.IMachineRoot; import org.osgi.service.prefs.Preferences; import de.prob.logging.Logger; @@ -23,20 +26,34 @@ import de.prob.logging.Logger; public class OpenClassicHandler extends AbstractHandler implements IHandler { private ISelection fSelection; + + private static final String PROB_CLASSIC_NAME = "ProB Tcl/Tk"; + private static final String PROB_STANDALONE_NAME = "ProB Standalone"; + private static final String PROB2_NAME = "ProB2-UI"; public Object execute(final ExecutionEvent event) throws ExecutionException { fSelection = HandlerUtil.getCurrentSelection(event); - final String location = getBinaryLocation(); - if (location == null) { - Logger.notifyUserWithoutBugreport("You need to specify a location for the ProB tcl/tk version. See Preferences -> ProB Classic"); + final String prob_location = getBinaryLocation(); + if (prob_location == null) { + Logger.notifyUserWithoutBugreport("You need to specify a location for" + PROB_STANDALONE_NAME +". See Preferences -> ProB Standalone."); } else { final IEventBRoot root = getSelection(); if (root != null) { - final File temp = createTempFile(); - final String tmp = temp.getAbsolutePath(); - ExportNewCoreHandler.exportToClassic(tmp, root); - runProBClassic(location, tmp); + if(prob_location.endsWith(".jar")) { + // we can open directly the .bum or .buc files with ProB2; we need to get it from root + // we could also get a platform URI: URI fileURI = URI.createPlatformResourceURI(root.getResource().getFullPath().toString(), true); + String bum_buc_path = //ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + root.getResource().getFullPath().toString(); + root.getResource().getRawLocation().toString(); + runProB2(prob_location, bum_buc_path); + } else { + final File temp = createTempFile(); + final String tmp = temp.getAbsolutePath(); + ExportNewCoreHandler.exportToClassic(tmp, root); + runProBClassic(prob_location, tmp); + } + } else { + Logger.notifyUserWithoutBugreport("You need to select a context or machine to open with " + PROB_STANDALONE_NAME); } } return null; @@ -56,7 +73,8 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { if (line == null) { break; } - System.out.println("ProB Classic: " + line); + System.out.println(PROB_STANDALONE_NAME + ": " + line); + LimitedLogger.getLogger().log(line,PROB_STANDALONE_NAME,null); } } catch (IOException e) { } finally { @@ -79,10 +97,53 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { new Thread(new ClassicConsole(output)).start(); } catch (IOException e) { - Logger.notifyUserWithoutBugreport("You need to specify a location for the ProB tcl/tk version. See Preferences -> ProB Classic"); + Logger.notifyUserWithoutBugreport("You need to specify a correct location for " + + PROB_CLASSIC_NAME + ". See Preferences -> ProB Standalone.\n" + + PROB_CLASSIC_NAME + " location: "+ probBinary + + "\nModel file: " + modelFile + + "\nError message: "+ e.getLocalizedMessage()); } } + private void runProB2(final String probBinary, final String modelFile) { + // call prob2-ui jar file + // from command-line it is: java -jar prob2-ui-1.0.1-SNAPSHOT-all.jar --machine-file FILE + try { + // final String command = "java -jar " + probBinary + " --machine-file " + modelFile; + //process = Runtime.getRuntime().exec(command); + + // get some version info first: + final String[] vcommand = {"java", "-version"}; + ProcessBuilder vpb = new ProcessBuilder(vcommand).redirectErrorStream(true); + Process vprocess = vpb.start(); + final BufferedReader voutput = new BufferedReader( + new InputStreamReader(vprocess.getInputStream())); + new Thread(new ClassicConsole(voutput)).start(); + vprocess.waitFor(); // this blocks Rodin + if (vprocess.exitValue() != 0) { + Logger.notifyUserWithoutBugreport("Failed to start java -version. Exit code: " + vprocess.exitValue()); + } + + final String[] command = {"java", "-jar", probBinary, "--machine-file", modelFile}; + System.out.println("Launching ProB2UI using: java -jar " + probBinary); + LimitedLogger.getLogger().log("Launching ProB2UI using: java -jar " + probBinary + " --machine-file " + modelFile,"ProB2UI",null); + ProcessBuilder pb = new ProcessBuilder(command).redirectErrorStream(true); + Process process = pb.start(); + + final BufferedReader output = new BufferedReader( + new InputStreamReader(process.getInputStream())); + new Thread(new ClassicConsole(output)).start(); + + } catch (IOException | InterruptedException e) { +// } catch (IOException e) { + Logger.notifyUserWithoutBugreport("You need to specify a correct location for " + + PROB2_NAME + ". See Preferences -> ProB Standalone.\n" + + PROB2_NAME + " location: "+ probBinary + + "\nModel file: " + modelFile + + "\nError message: "+ e.getLocalizedMessage()); + } + } + private String getBinaryLocation() { Preferences preferences = Platform.getPreferencesService() .getRootNode().node(InstanceScope.SCOPE) @@ -102,15 +163,15 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { return temp; } - private IMachineRoot getSelection() { + private IEventBRoot getSelection() { if (!(fSelection instanceof IStructuredSelection)) return null; final IStructuredSelection ssel = (IStructuredSelection) fSelection; if (ssel.size() != 1) return null; - if (!(ssel.getFirstElement() instanceof IMachineRoot)) + if (!(ssel.getFirstElement() instanceof IEventBRoot)) // was IMachineRoot return null; - return (IMachineRoot) ssel.getFirstElement(); + return (IEventBRoot) ssel.getFirstElement(); } } diff --git a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java index 3c08dfd085230c7de006e6e4b04c5185c1ff8608..7ad28d5974a24fd3fbabc4499a96b1f97fbe733c 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java @@ -76,19 +76,28 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ArrayList<String> errors = new ArrayList<String>(); boolean realError = checkErrorMarkers(resource, errors); if (!errors.isEmpty()) { + Animator.getAnimator().setRodinProjectHasErrorsOrWarnings(); String message = "Some components in your project contain " + (realError ? "errors" : "warnings") - + ". This can lead to unexpected behavior (e.g. missing variables) when animating.\n\nDetails:\n"; + + "!\n This can lead to unexpected behavior (e.g. missing variables) when animating with ProB.\nDetails:\n"; StringBuffer stringBuffer = new StringBuffer(message); for (String string : errors) { stringBuffer.append(string); stringBuffer.append('\n'); } - if (realError) + if (true) { + // TO DO: use preference whether to pop-up such errors or simply log them + // Unfortunately the GetPreferencesCommand gets ProBPreference object which do not contain the current value + // we could also change the label in StateViewPart.java, e.g. modelchangeProvider or add a new label + Logger.info(stringBuffer.toString()); + LimitedLogger.getLogger().log(stringBuffer.toString(),rootElement.getElementName(), null); + } else if (realError) Logger.notifyUserWithoutBugreport(stringBuffer.toString()); else Logger.notifyUserAboutWarningWithoutBugreport(stringBuffer .toString()); + } else { + Animator.getAnimator().resetRodinProjectHasErrorsOrWarnings(); } ; diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryEditPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryEditPart.java index 2f2d2c9ff55393846547933fee8b21be68891486..9e811caef19a99f5da2412c1b12a7faad0adec7b 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryEditPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryEditPart.java @@ -1,14 +1,14 @@ -package de.prob.ui.ltl; - -import org.eclipse.draw2d.IFigure; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -public final class CounterExampleBinaryEditPart extends - CounterExamplePropositionEditPart { - @Override - protected IFigure createFigure() { - CounterExampleProposition model = (CounterExampleProposition) getModel(); - return new CounterExampleBinaryFigure(model); - } -} +package de.prob.ui.ltl; + +import org.eclipse.draw2d.IFigure; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +public final class CounterExampleBinaryEditPart extends + CounterExamplePropositionEditPart { + @Override + protected IFigure createFigure() { + CounterExampleProposition model = (CounterExampleProposition) getModel(); + return new CounterExampleBinaryFigure(model); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryFigure.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryFigure.java index b128a21d9c8edeab52318f49b8be690f9c4db03d..3ce28b643d5cb89dc5c3a2740195c59890f04319 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryFigure.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleBinaryFigure.java @@ -1,280 +1,280 @@ -package de.prob.ui.ltl; - -import java.util.Hashtable; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.Ellipse; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.Panel; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.TitleBarBorder; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.History; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; - -public final class CounterExampleBinaryFigure extends - CounterExamplePropositionFigure { - private Panel firstPanel; - private Panel secondPanel; - - protected final Hashtable<Ellipse, Integer> firstArgumentEllipses1 = new Hashtable<Ellipse, Integer>(); - protected final Hashtable<Integer, Ellipse> firstArgumentEllipses2 = new Hashtable<Integer, Ellipse>(); - private final Hashtable<Ellipse, Integer> secondArgumentEllipses1 = new Hashtable<Ellipse, Integer>(); - private final Hashtable<Integer, Ellipse> secondArgumentEllipses2 = new Hashtable<Integer, Ellipse>(); - - public CounterExampleBinaryFigure(final CounterExampleProposition model) { - super(model); - - bounds = new Rectangle(size, size, size - * (model.getValues().size() * 2 + 1), (int) (9.0 / 2 * size)); - } - - @Override - protected void drawProposition(final CounterExamplePropositionFigure parent) { - final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); - final Insets insets = getInsets(); - - if (parent != null) { - Rectangle parentBounds = parent.getBounds(); - bounds.x = parentBounds.x - insets.left; - bounds.y = parentBounds.y + parentBounds.height + size / 2; - - } else { - final List<RectangleFigure> states = counterExampleFigure - .getStates(); - - for (int i = 0; i < states.size(); i++) { - final RectangleFigure state = states.get(i); - - if (!counterExampleFigure.getChildren().contains(state)) { - state.setBounds(new Rectangle((size * 2) * (i + 1) - + insets.left, size, size, size * 3 + 6 - * insets.top)); - counterExampleFigure.add(state, 0); - } - } - } - - counterExampleFigure.setConstraint(this, new Rectangle(bounds)); - - removeAll(); - - final int stateId = model.getStateId(); - - final CounterExampleProposition firstArgument = ((CounterExampleBinaryOperator) model) - .getFirstArgument(); - final List<Integer> firstPositions = ((CounterExampleBinaryOperator) model) - .getFirstHighlightedPositions().get(stateId); - final Rectangle firstPanelBounds = new Rectangle(bounds.x - + (int) (2.0 / 5 * size), bounds.y + (int) (2.0 / 5 * size), - bounds.width, bounds.height / 2); - firstPanel = drawPropositionFigure(parent, bounds, firstArgument, - firstPositions, firstArgumentEllipses1, firstArgumentEllipses2, - firstPanelBounds, stateId, size); - - final Rectangle secondPanelBounds = new Rectangle(bounds.x + 20, - bounds.y + (int) (12.0 / 5 * size), bounds.width, - bounds.height / 2); - final CounterExampleProposition secondArgument = ((CounterExampleBinaryOperator) model) - .getSecondArgument(); - final List<Integer> secondPositions = ((CounterExampleBinaryOperator) model) - .getSecondHighlightedPositions().get(stateId); - secondPanel = drawPropositionFigure(parent, bounds, secondArgument, - secondPositions, secondArgumentEllipses1, - secondArgumentEllipses2, secondPanelBounds, stateId, 3 * size); - } - - @Override - public void mouseDoubleClicked(final MouseEvent me) { - super.mouseDoubleClicked(me); - - int stateId = -1; - - if (firstArgumentEllipses1.containsKey(me.getSource())) - stateId = firstArgumentEllipses1.get(me.getSource()); - else if (secondArgumentEllipses1.containsKey(me.getSource())) - stateId = secondArgumentEllipses1.get(me.getSource()); - - Logger.assertProB("stateId >= 0", stateId >= 0); - - final CounterExample ce = ((CounterExampleFigure) getParent()) - .getModel(); - - if (ce != null) { - stateId += ce.getInitPath().size(); - - final History history = Animator.getAnimator().getHistory(); - - try { - CounterExampleHistoryHandler.showCounterExampleInAnimator(); - history.gotoPos(stateId); - } catch (ExecutionException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } catch (ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } - } - } - - @Override - public void mousePressed(final MouseEvent me) { - super.mousePressed(me); - int stateId; - - final CounterExampleProposition firstArgument = ((CounterExampleBinaryOperator) model) - .getFirstArgument(); - List<CounterExampleProposition> firstChildren = firstArgument - .getChildren(); - firstChildren = firstChildren.subList(1, firstChildren.size()); - setTrasparent(firstChildren); - - final CounterExamplePropositionFigure firstArgumentFigure = getFigure(firstArgument); - - for (Connection connection : firstArgumentFigure.getConnections() - .values()) { - connection.setVisible(false); - } - - final CounterExampleProposition secondArgument = ((CounterExampleBinaryOperator) model) - .getSecondArgument(); - List<CounterExampleProposition> secondChildren = secondArgument - .getChildren(); - secondChildren = secondChildren.subList(1, secondChildren.size()); - setTrasparent(secondChildren); - - final CounterExamplePropositionFigure secondArgumentFigure = getFigure(secondArgument); - - for (Connection connection : secondArgumentFigure.getConnections() - .values()) { - connection.setVisible(false); - } - - final Object source = me.getSource(); - - if (firstPanel == null || secondPanel == null) - return; - - final TitleBarBorder firstBorder = (TitleBarBorder) firstPanel - .getBorder(); - final TitleBarBorder secondBorder = (TitleBarBorder) secondPanel - .getBorder(); - - // final CounterExampleFigure counterExampleFigure = - // (CounterExampleFigure) getParent(); - - if (firstArgumentEllipses1.containsKey(source)) { - secondBorder.setFont(normalFont); - secondArgument.setVisible(false); - - stateId = firstArgumentEllipses1.get(source); - - // Rectangle argumentBounds = firstArgumentFigure.getBounds(); - // Insets insets = getInsets(); - - if (firstArgument.getStateId() == stateId) { - final boolean visible = !firstArgument.isVisible(); - - if (firstArgument.hasChildren()) { - firstBorder.setFont(visible ? boldFont : normalFont); - } - - firstArgument.setVisible(visible); - - // if (visible) - // counterExampleFigure.updateStates(argumentBounds.height + 2 - // * insets.top); - // else - // counterExampleFigure - // .updateStates((argumentBounds.height + 2 * insets.top) - // * -1); - } else { - if (firstArgument.hasChildren()) { - firstBorder.setFont(boldFont); - } - - firstArgument.setStateId(stateId); - firstArgument.setVisible(true); - } - } else { - firstBorder.setFont(normalFont); - firstArgument.setVisible(false); - - stateId = secondArgumentEllipses1.get(source); - - // Rectangle argumentBounds = secondArgumentFigure.getBounds(); - - if (secondArgument.getStateId() == stateId) { - final boolean visible = !secondArgument.isVisible(); - - if (secondArgument.hasChildren()) { - secondBorder.setFont(visible ? boldFont : normalFont); - } - - secondArgument.setVisible(visible); - - // if (visible) - // counterExampleFigure.updateStates(argumentBounds.height); - // else - // counterExampleFigure.updateStates((argumentBounds.height) - // * -1); - } else { - if (secondArgument.hasChildren()) { - secondBorder.setFont(boldFont); - } - - secondArgument.setStateId(stateId); - secondArgument.setVisible(true); - } - } - - repaint(); - } - - @Override - public void mouseEntered(final MouseEvent me) { - final Ellipse source = (Ellipse) me.getSource(); - - CounterExampleProposition argument = null; - int stateId; - - if (firstArgumentEllipses1.containsKey(source)) { - argument = ((CounterExampleBinaryOperator) model) - .getFirstArgument(); - stateId = firstArgumentEllipses1.get(source); - } else { - argument = ((CounterExampleBinaryOperator) model) - .getSecondArgument(); - stateId = secondArgumentEllipses1.get(source); - } - - if (!argument.hasChildren()) - return; - - final boolean painted = argument.isVisible(); - final int argumentStateId = argument.getStateId(); - - final Label label = new Label(); - label.setForegroundColor(foregroundColor); - - String text = "open "; - - if (stateId == argumentStateId) - text = painted ? "close " : "open "; - - label.setText("Click to " + text + argument); - source.setToolTip(label); - } -} +package de.prob.ui.ltl; + +import java.util.Hashtable; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.MouseEvent; +import org.eclipse.draw2d.Panel; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.TitleBarBorder; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Rectangle; + +import de.prob.core.Animator; +import de.prob.core.domainobjects.History; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; +import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; + +public final class CounterExampleBinaryFigure extends + CounterExamplePropositionFigure { + private Panel firstPanel; + private Panel secondPanel; + + protected final Hashtable<Ellipse, Integer> firstArgumentEllipses1 = new Hashtable<Ellipse, Integer>(); + protected final Hashtable<Integer, Ellipse> firstArgumentEllipses2 = new Hashtable<Integer, Ellipse>(); + private final Hashtable<Ellipse, Integer> secondArgumentEllipses1 = new Hashtable<Ellipse, Integer>(); + private final Hashtable<Integer, Ellipse> secondArgumentEllipses2 = new Hashtable<Integer, Ellipse>(); + + public CounterExampleBinaryFigure(final CounterExampleProposition model) { + super(model); + + bounds = new Rectangle(size, size, size + * (model.getValues().size() * 2 + 1), (int) (9.0 / 2 * size)); + } + + @Override + protected void drawProposition(final CounterExamplePropositionFigure parent) { + final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); + final Insets insets = getInsets(); + + if (parent != null) { + Rectangle parentBounds = parent.getBounds(); + bounds.x = parentBounds.x - insets.left; + bounds.y = parentBounds.y + parentBounds.height + size / 2; + + } else { + final List<RectangleFigure> states = counterExampleFigure + .getStates(); + + for (int i = 0; i < states.size(); i++) { + final RectangleFigure state = states.get(i); + + if (!counterExampleFigure.getChildren().contains(state)) { + state.setBounds(new Rectangle((size * 2) * (i + 1) + + insets.left, size, size, size * 3 + 6 + * insets.top)); + counterExampleFigure.add(state, 0); + } + } + } + + counterExampleFigure.setConstraint(this, new Rectangle(bounds)); + + removeAll(); + + final int stateId = model.getStateId(); + + final CounterExampleProposition firstArgument = ((CounterExampleBinaryOperator) model) + .getFirstArgument(); + final List<Integer> firstPositions = ((CounterExampleBinaryOperator) model) + .getFirstHighlightedPositions().get(stateId); + final Rectangle firstPanelBounds = new Rectangle(bounds.x + + (int) (2.0 / 5 * size), bounds.y + (int) (2.0 / 5 * size), + bounds.width, bounds.height / 2); + firstPanel = drawPropositionFigure(parent, bounds, firstArgument, + firstPositions, firstArgumentEllipses1, firstArgumentEllipses2, + firstPanelBounds, stateId, size); + + final Rectangle secondPanelBounds = new Rectangle(bounds.x + 20, + bounds.y + (int) (12.0 / 5 * size), bounds.width, + bounds.height / 2); + final CounterExampleProposition secondArgument = ((CounterExampleBinaryOperator) model) + .getSecondArgument(); + final List<Integer> secondPositions = ((CounterExampleBinaryOperator) model) + .getSecondHighlightedPositions().get(stateId); + secondPanel = drawPropositionFigure(parent, bounds, secondArgument, + secondPositions, secondArgumentEllipses1, + secondArgumentEllipses2, secondPanelBounds, stateId, 3 * size); + } + + @Override + public void mouseDoubleClicked(final MouseEvent me) { + super.mouseDoubleClicked(me); + + int stateId = -1; + + if (firstArgumentEllipses1.containsKey(me.getSource())) + stateId = firstArgumentEllipses1.get(me.getSource()); + else if (secondArgumentEllipses1.containsKey(me.getSource())) + stateId = secondArgumentEllipses1.get(me.getSource()); + + Logger.assertProB("stateId >= 0", stateId >= 0); + + final CounterExample ce = ((CounterExampleFigure) getParent()) + .getModel(); + + if (ce != null) { + stateId += ce.getInitPath().size(); + + final History history = Animator.getAnimator().getHistory(); + + try { + CounterExampleHistoryHandler.showCounterExampleInAnimator(); + history.gotoPos(stateId); + } catch (ExecutionException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } catch (ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } + } + } + + @Override + public void mousePressed(final MouseEvent me) { + super.mousePressed(me); + int stateId; + + final CounterExampleProposition firstArgument = ((CounterExampleBinaryOperator) model) + .getFirstArgument(); + List<CounterExampleProposition> firstChildren = firstArgument + .getChildren(); + firstChildren = firstChildren.subList(1, firstChildren.size()); + setTrasparent(firstChildren); + + final CounterExamplePropositionFigure firstArgumentFigure = getFigure(firstArgument); + + for (Connection connection : firstArgumentFigure.getConnections() + .values()) { + connection.setVisible(false); + } + + final CounterExampleProposition secondArgument = ((CounterExampleBinaryOperator) model) + .getSecondArgument(); + List<CounterExampleProposition> secondChildren = secondArgument + .getChildren(); + secondChildren = secondChildren.subList(1, secondChildren.size()); + setTrasparent(secondChildren); + + final CounterExamplePropositionFigure secondArgumentFigure = getFigure(secondArgument); + + for (Connection connection : secondArgumentFigure.getConnections() + .values()) { + connection.setVisible(false); + } + + final Object source = me.getSource(); + + if (firstPanel == null || secondPanel == null) + return; + + final TitleBarBorder firstBorder = (TitleBarBorder) firstPanel + .getBorder(); + final TitleBarBorder secondBorder = (TitleBarBorder) secondPanel + .getBorder(); + + // final CounterExampleFigure counterExampleFigure = + // (CounterExampleFigure) getParent(); + + if (firstArgumentEllipses1.containsKey(source)) { + secondBorder.setFont(normalFont); + secondArgument.setVisible(false); + + stateId = firstArgumentEllipses1.get(source); + + // Rectangle argumentBounds = firstArgumentFigure.getBounds(); + // Insets insets = getInsets(); + + if (firstArgument.getStateId() == stateId) { + final boolean visible = !firstArgument.isVisible(); + + if (firstArgument.hasChildren()) { + firstBorder.setFont(visible ? boldFont : normalFont); + } + + firstArgument.setVisible(visible); + + // if (visible) + // counterExampleFigure.updateStates(argumentBounds.height + 2 + // * insets.top); + // else + // counterExampleFigure + // .updateStates((argumentBounds.height + 2 * insets.top) + // * -1); + } else { + if (firstArgument.hasChildren()) { + firstBorder.setFont(boldFont); + } + + firstArgument.setStateId(stateId); + firstArgument.setVisible(true); + } + } else { + firstBorder.setFont(normalFont); + firstArgument.setVisible(false); + + stateId = secondArgumentEllipses1.get(source); + + // Rectangle argumentBounds = secondArgumentFigure.getBounds(); + + if (secondArgument.getStateId() == stateId) { + final boolean visible = !secondArgument.isVisible(); + + if (secondArgument.hasChildren()) { + secondBorder.setFont(visible ? boldFont : normalFont); + } + + secondArgument.setVisible(visible); + + // if (visible) + // counterExampleFigure.updateStates(argumentBounds.height); + // else + // counterExampleFigure.updateStates((argumentBounds.height) + // * -1); + } else { + if (secondArgument.hasChildren()) { + secondBorder.setFont(boldFont); + } + + secondArgument.setStateId(stateId); + secondArgument.setVisible(true); + } + } + + repaint(); + } + + @Override + public void mouseEntered(final MouseEvent me) { + final Ellipse source = (Ellipse) me.getSource(); + + CounterExampleProposition argument = null; + int stateId; + + if (firstArgumentEllipses1.containsKey(source)) { + argument = ((CounterExampleBinaryOperator) model) + .getFirstArgument(); + stateId = firstArgumentEllipses1.get(source); + } else { + argument = ((CounterExampleBinaryOperator) model) + .getSecondArgument(); + stateId = secondArgumentEllipses1.get(source); + } + + if (!argument.hasChildren()) + return; + + final boolean painted = argument.isVisible(); + final int argumentStateId = argument.getStateId(); + + final Label label = new Label(); + label.setForegroundColor(foregroundColor); + + String text = "open "; + + if (stateId == argumentStateId) + text = painted ? "close " : "open "; + + label.setText("Click to " + text + argument); + source.setToolTip(label); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleContentProvider.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleContentProvider.java index 3ff5eb18e7fc8a4652d6a555aefaf39a55a22928..f75fcbed81ff402ae73f41a35f1f3207e73eafdc 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleContentProvider.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleContentProvider.java @@ -1,92 +1,92 @@ -package de.prob.ui.ltl; - -import java.util.List; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -/*** - * Provides a content provider for a counter-example tree view - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleContentProvider implements - ITreeContentProvider { - - /** - * Returns the children of an element - */ - @Override - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof List) { - return ((List<?>) parentElement).toArray(); - } - - if (parentElement instanceof CounterExampleUnaryOperator) { - Object[] children = new Object[1]; - children[0] = ((CounterExampleUnaryOperator) parentElement) - .getArgument(); - return children; - } - - if (parentElement instanceof CounterExampleBinaryOperator) { - Object[] children = new Object[2]; - children[0] = ((CounterExampleBinaryOperator) parentElement) - .getFirstArgument(); - children[1] = ((CounterExampleBinaryOperator) parentElement) - .getSecondArgument(); - return children; - } - - return new Object[0]; - } - - /** - * Returns the parent of an element - */ - @Override - public Object getParent(Object element) { - if (element instanceof CounterExampleProposition) { - return ((CounterExampleProposition) element).getParent(); - } - - return null; - } - - /** - * Returns whether an element has children - */ - @Override - public boolean hasChildren(Object element) { - if (element instanceof List) { - return ((List<?>) element).size() > 0; - } else if (element instanceof CounterExampleUnaryOperator) { - return true; - } else if (element instanceof CounterExampleBinaryOperator) { - return true; - } - - return false; - } - - /** - * Returns the root element - */ - @Override - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - @Override - public void dispose() { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } -} +package de.prob.ui.ltl; + +import java.util.List; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +/*** + * Provides a content provider for a counter-example tree view + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleContentProvider implements + ITreeContentProvider { + + /** + * Returns the children of an element + */ + @Override + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof List) { + return ((List<?>) parentElement).toArray(); + } + + if (parentElement instanceof CounterExampleUnaryOperator) { + Object[] children = new Object[1]; + children[0] = ((CounterExampleUnaryOperator) parentElement) + .getArgument(); + return children; + } + + if (parentElement instanceof CounterExampleBinaryOperator) { + Object[] children = new Object[2]; + children[0] = ((CounterExampleBinaryOperator) parentElement) + .getFirstArgument(); + children[1] = ((CounterExampleBinaryOperator) parentElement) + .getSecondArgument(); + return children; + } + + return new Object[0]; + } + + /** + * Returns the parent of an element + */ + @Override + public Object getParent(Object element) { + if (element instanceof CounterExampleProposition) { + return ((CounterExampleProposition) element).getParent(); + } + + return null; + } + + /** + * Returns whether an element has children + */ + @Override + public boolean hasChildren(Object element) { + if (element instanceof List) { + return ((List<?>) element).size() > 0; + } else if (element instanceof CounterExampleUnaryOperator) { + return true; + } else if (element instanceof CounterExampleBinaryOperator) { + return true; + } + + return false; + } + + /** + * Returns the root element + */ + @Override + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPart.java index 51d5eee8ced47225e09ef40caf4c11fbe704433d..435fce9dfab97d195c9da68fb01d992305d4710d 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPart.java @@ -1,36 +1,36 @@ -package de.prob.ui.ltl; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -public final class CounterExampleEditPart extends AbstractGraphicalEditPart { - @Override - protected IFigure createFigure() { - final CounterExample model = (CounterExample) getModel(); - return new CounterExampleFigure(model); - } - - @Override - public List<CounterExampleProposition> getModelChildren() { - final CounterExample model = (CounterExample) getModel(); - final List<CounterExampleProposition> children = model - .getPropositions(); - - return children; - } - - @Override - protected void refreshVisuals() { - final CounterExampleFigure figure = (CounterExampleFigure) getFigure(); - figure.update(); - } - - @Override - protected void createEditPolicies() { - } -} +package de.prob.ui.ltl; + +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +public final class CounterExampleEditPart extends AbstractGraphicalEditPart { + @Override + protected IFigure createFigure() { + final CounterExample model = (CounterExample) getModel(); + return new CounterExampleFigure(model); + } + + @Override + public List<CounterExampleProposition> getModelChildren() { + final CounterExample model = (CounterExample) getModel(); + final List<CounterExampleProposition> children = model + .getPropositions(); + + return children; + } + + @Override + protected void refreshVisuals() { + final CounterExampleFigure figure = (CounterExampleFigure) getFigure(); + figure.update(); + } + + @Override + protected void createEditPolicies() { + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPartFactory.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPartFactory.java index 337ed06ecba07871bac60e41690842de9ebac328..dae5a50bf58e9614e062d8a1c7ff2961b14e1fdd 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPartFactory.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleEditPartFactory.java @@ -1,31 +1,31 @@ -package de.prob.ui.ltl; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; - -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExamplePredicate; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -public final class CounterExampleEditPartFactory implements EditPartFactory { - - @Override - public EditPart createEditPart(EditPart context, Object model) { - EditPart editPart = null; - - if (model instanceof CounterExample) - editPart = new CounterExampleEditPart(); - else if (model instanceof CounterExamplePredicate) - editPart = new CounterExamplePredicateEditPart(); - else if (model instanceof CounterExampleUnaryOperator) - editPart = new CounterExampleUnaryEditPart(); - else if (model instanceof CounterExampleBinaryOperator) - editPart = new CounterExampleBinaryEditPart(); - - if (editPart != null) - editPart.setModel(model); - - return editPart; - } -} +package de.prob.ui.ltl; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; + +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExamplePredicate; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +public final class CounterExampleEditPartFactory implements EditPartFactory { + + @Override + public EditPart createEditPart(EditPart context, Object model) { + EditPart editPart = null; + + if (model instanceof CounterExample) + editPart = new CounterExampleEditPart(); + else if (model instanceof CounterExamplePredicate) + editPart = new CounterExamplePredicateEditPart(); + else if (model instanceof CounterExampleUnaryOperator) + editPart = new CounterExampleUnaryEditPart(); + else if (model instanceof CounterExampleBinaryOperator) + editPart = new CounterExampleBinaryEditPart(); + + if (editPart != null) + editPart.setModel(model); + + return editPart; + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleFigure.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleFigure.java index bbca84afd39a4069a6f98f2ff240621e32d03dbc..e0a105c6ab30c6f08b9c307a78e0af7d37af9274 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleFigure.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleFigure.java @@ -1,86 +1,86 @@ -package de.prob.ui.ltl; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.AbstractLabeledBorder; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.GroupBoxBorder; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; - -import de.prob.core.domainobjects.ltl.CounterExample; - -public final class CounterExampleFigure extends Figure { - private final CounterExample model; - // These are the rectangles that should show which is the current state - // At most one of them is visible at the same time - private final List<RectangleFigure> states = new ArrayList<RectangleFigure>(); - - public CounterExampleFigure(CounterExample model) { - this.model = model; - - setLayoutManager(new XYLayout()); - - final AbstractLabeledBorder border = new GroupBoxBorder(); - border.setTextColor(ColorConstants.lightBlue); - - final Font font = new Font(Display.getDefault(), "Arial", 10, SWT.BOLD); - border.setFont(font); - border.setLabel(model.getPropositionRoot().toString()/* - * + ", PathType - " - * + - * model.getPathType - * ().name() - */); - setBorder(border); - - for (int i = 0; i < model.getStates().size(); i++) { - final RectangleFigure state = new RectangleFigure(); - states.add(state); - } - } - - public List<RectangleFigure> getStates() { - return states; - } - - public CounterExample getModel() { - return model; - } - - // public void updateStates(int height) { - // for (int i = 0; i < states.size(); i++) { - // final RectangleFigure state = states.get(i); - // final Rectangle bounds = state.getBounds(); - // state.setSize(bounds.width, bounds.height + height); - // - // if (i == 0) { - // System.out.println("height = " + height); - // System.out.println("x = " + bounds.x + ", y = " + bounds.y - // + ", width = " + bounds.width + ", height = " - // + bounds.height); - // } - // } - // } - - public void update() { - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) { - final int currentIndex = counterExampleView.getCurrentIndex(); - - for (int i = 0; i < states.size(); i++) { - states.get(i).setVisible(false); - - if (i == currentIndex) { - states.get(i).setVisible(true); - } - } - } - } -} +package de.prob.ui.ltl; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.AbstractLabeledBorder; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.GroupBoxBorder; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Display; + +import de.prob.core.domainobjects.ltl.CounterExample; + +public final class CounterExampleFigure extends Figure { + private final CounterExample model; + // These are the rectangles that should show which is the current state + // At most one of them is visible at the same time + private final List<RectangleFigure> states = new ArrayList<RectangleFigure>(); + + public CounterExampleFigure(CounterExample model) { + this.model = model; + + setLayoutManager(new XYLayout()); + + final AbstractLabeledBorder border = new GroupBoxBorder(); + border.setTextColor(ColorConstants.lightBlue); + + final Font font = new Font(Display.getDefault(), "Arial", 10, SWT.BOLD); + border.setFont(font); + border.setLabel(model.getPropositionRoot().toString()/* + * + ", PathType - " + * + + * model.getPathType + * ().name() + */); + setBorder(border); + + for (int i = 0; i < model.getStates().size(); i++) { + final RectangleFigure state = new RectangleFigure(); + states.add(state); + } + } + + public List<RectangleFigure> getStates() { + return states; + } + + public CounterExample getModel() { + return model; + } + + // public void updateStates(int height) { + // for (int i = 0; i < states.size(); i++) { + // final RectangleFigure state = states.get(i); + // final Rectangle bounds = state.getBounds(); + // state.setSize(bounds.width, bounds.height + height); + // + // if (i == 0) { + // System.out.println("height = " + height); + // System.out.println("x = " + bounds.x + ", y = " + bounds.y + // + ", width = " + bounds.width + ", height = " + // + bounds.height); + // } + // } + // } + + public void update() { + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) { + final int currentIndex = counterExampleView.getCurrentIndex(); + + for (int i = 0; i < states.size(); i++) { + states.get(i).setVisible(false); + + if (i == currentIndex) { + states.get(i).setVisible(true); + } + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleLoadedProvider.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleLoadedProvider.java index adae6b626fb2fd3aeb51f7086e24667c672ceb96..05e369b158c998aaca27e5387c4e5ab475477179 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleLoadedProvider.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleLoadedProvider.java @@ -1,11 +1,11 @@ -package de.prob.ui.ltl; - -import de.prob.ui.services.AbstractBoolProvider; - -public class CounterExampleLoadedProvider extends AbstractBoolProvider { - public static final String SERVICE = "de.prob.ui.ltl.counterexample_loaded"; - - public CounterExampleLoadedProvider() { - super(SERVICE); - } -} +package de.prob.ui.ltl; + +import de.prob.ui.services.AbstractBoolProvider; + +public class CounterExampleLoadedProvider extends AbstractBoolProvider { + public static final String SERVICE = "de.prob.ui.ltl.counterexample_loaded"; + + public CounterExampleLoadedProvider() { + super(SERVICE); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateEditPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateEditPart.java index 81503b54a21776a75e2478dcbc0255066bf44734..49bb72b726a24f3ea76f046e9548e439a23fdab6 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateEditPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateEditPart.java @@ -1,14 +1,14 @@ -package de.prob.ui.ltl; - -import org.eclipse.draw2d.IFigure; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -public final class CounterExamplePredicateEditPart extends - CounterExamplePropositionEditPart { - @Override - protected IFigure createFigure() { - CounterExampleProposition model = (CounterExampleProposition) getModel(); - return new CounterExamplePredicateFigure(model); - } -} +package de.prob.ui.ltl; + +import org.eclipse.draw2d.IFigure; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +public final class CounterExamplePredicateEditPart extends + CounterExamplePropositionEditPart { + @Override + protected IFigure createFigure() { + CounterExampleProposition model = (CounterExampleProposition) getModel(); + return new CounterExamplePredicateFigure(model); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateFigure.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateFigure.java index de76d8f4e507fcf1f0d5988f28e363bb272bcadc..ee0443de2a9f09d8447cf2af7239b675cc297839 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateFigure.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePredicateFigure.java @@ -1,204 +1,204 @@ -package de.prob.ui.ltl; - -import java.util.Hashtable; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.draw2d.BorderLayout; -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Ellipse; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.Polyline; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; - -import de.prob.core.Animator; -import de.prob.core.command.LtlCheckingCommand.PathType; -import de.prob.core.domainobjects.History; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; - -public final class CounterExamplePredicateFigure extends - CounterExamplePropositionFigure { - protected final Hashtable<Ellipse, Integer> ellipses1 = new Hashtable<Ellipse, Integer>(); - protected final Hashtable<Integer, Ellipse> ellipses2 = new Hashtable<Integer, Ellipse>(); - - public CounterExamplePredicateFigure(final CounterExampleProposition model) { - super(model); - - } - - @Override - protected void drawProposition(final CounterExamplePropositionFigure parent) { - if (parent == null) { - bounds = new Rectangle(size, size, size - * (model.getValues().size() * 2 + 1), 2 * size); - - final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); - final Insets insets = getInsets(); - final List<RectangleFigure> states = counterExampleFigure - .getStates(); - - for (int i = 0; i < states.size(); i++) { - final RectangleFigure state = states.get(i); - - if (!counterExampleFigure.getChildren().contains(state)) { - state.setBounds(new Rectangle((size * 2) * (i + 1) - + insets.left, size, size, 2 * size + 2 - * insets.top)); - counterExampleFigure.add(state, 0); - } - } - - getParent().setConstraint(this, new Rectangle(bounds)); - - removeAll(); - - drawPropositionFigure(bounds, ellipses1, ellipses2, - model.getStateId(), 3 * size / 5); - } - } - - private void drawPropositionFigure(final Rectangle bounds, - final Hashtable<Ellipse, Integer> ellipses1, - final Hashtable<Integer, Ellipse> ellipses2, final int stateId, - final int argumentHeight) { - ellipses1.clear(); - ellipses2.clear(); - - final PathType pathType = model.getPathType(); - - final List<CounterExampleValueType> values = model.getValues(); - - for (int i = 0; i < values.size(); i++) { - final CounterExampleValueType value = values.get(i); - final Ellipse ellipse = new Ellipse(); - - ellipse.setAntialias(SWT.ON); - ellipse.setLineWidth(2); - ellipse.setOpaque(true); - ellipse.addMouseListener(this); - ellipse.addMouseMotionListener(this); - ellipse.setBackgroundColor(getEllipseColor(value)); - - ellipses1.put(ellipse, i); - ellipses2.put(i, ellipse); - - final Label label = new Label(value.toString()); - label.setOpaque(false); - - ellipse.setLayoutManager(new BorderLayout()); - ellipse.add(label, BorderLayout.CENTER); - - add(ellipse); - - final int x = (bounds.x + size) * (i + 1); - final int y = bounds.y + argumentHeight - + (pathType == PathType.INFINITE ? size / 10 : 0); - ellipse.setBounds(new Rectangle(x, y, size, size)); - - if (i > 0) { - final ChopboxAnchor source = new ChopboxAnchor(ellipse); - final Ellipse targetEllipse = ellipses2.get(i - 1); - - if (targetEllipse == null) - continue; - - final ChopboxAnchor target = new ChopboxAnchor(targetEllipse); - - final PolylineConnection connection = new PolylineConnection(); - connection.setAlpha(Alpha.MASKED); - connection.setAntialias(SWT.ON); - connection.setLineStyle(SWT.LINE_SOLID); - connection.setLineWidth(2); - connection.setToolTip(new Label(getOperationName(i - 1))); - connection.setSourceAnchor(source); - connection.setTargetAnchor(target); - - final PolygonDecoration decoration = new PolygonDecoration(); - decoration.setAlpha(Alpha.MASKED); - decoration.setAntialias(SWT.ON); - - final PointList decorationPointList = new PointList(); - decorationPointList.addPoint(0, 0); - decorationPointList.addPoint(-1, 1); - decorationPointList.addPoint(-1, 0); - decorationPointList.addPoint(-1, -1); - decoration.setTemplate(decorationPointList); - - // highlight the transition - connection.setAlpha(Alpha.HIGHLIGHED); - decoration.setAlpha(Alpha.HIGHLIGHED); - - connection.setSourceDecoration(decoration); - - add(connection); - } - - if (i == values.size() - 1) { - if (pathType.equals(PathType.INFINITE)) { - final String operationName = getOperationName(ellipses1 - .get(ellipse)); - final Ellipse target = ellipses2.get(model.getLoopEntry()); - - int alpha = Alpha.MASKED; - Color loopTransitionColor = ColorConstants.black; - - alpha = Alpha.HIGHLIGHED; - - final PolylineConnection loop = createLoop(getInsets(), - ellipse, target, alpha, operationName, - loopTransitionColor); - - add(loop); - } else if (pathType.equals(PathType.REDUCED)) { - final Polyline reduced = createReduced(getInsets(), - ellipse, Alpha.HIGHLIGHED); - - this.add(reduced); - } - } - } - } - - @Override - public void mouseDoubleClicked(final MouseEvent me) { - super.mouseDoubleClicked(me); - - int stateId = ellipses1.get(me.getSource()); - Logger.assertProB("stateId >= 0", stateId >= 0); - - final CounterExample ce = ((CounterExampleFigure) getParent()) - .getModel(); - - if (ce != null) { - stateId += ce.getInitPath().size(); - - final Animator animator = Animator.getAnimator(); - final History history = animator.getHistory(); - - try { - CounterExampleHistoryHandler.showCounterExampleInAnimator(); - history.gotoPos(stateId); - } catch (ExecutionException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } catch (ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } - } - } -} +package de.prob.ui.ltl; + +import java.util.Hashtable; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.draw2d.BorderLayout; +import org.eclipse.draw2d.ChopboxAnchor; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.MouseEvent; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.Polyline; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; + +import de.prob.core.Animator; +import de.prob.core.command.LtlCheckingCommand.PathType; +import de.prob.core.domainobjects.History; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; +import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; + +public final class CounterExamplePredicateFigure extends + CounterExamplePropositionFigure { + protected final Hashtable<Ellipse, Integer> ellipses1 = new Hashtable<Ellipse, Integer>(); + protected final Hashtable<Integer, Ellipse> ellipses2 = new Hashtable<Integer, Ellipse>(); + + public CounterExamplePredicateFigure(final CounterExampleProposition model) { + super(model); + + } + + @Override + protected void drawProposition(final CounterExamplePropositionFigure parent) { + if (parent == null) { + bounds = new Rectangle(size, size, size + * (model.getValues().size() * 2 + 1), 2 * size); + + final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); + final Insets insets = getInsets(); + final List<RectangleFigure> states = counterExampleFigure + .getStates(); + + for (int i = 0; i < states.size(); i++) { + final RectangleFigure state = states.get(i); + + if (!counterExampleFigure.getChildren().contains(state)) { + state.setBounds(new Rectangle((size * 2) * (i + 1) + + insets.left, size, size, 2 * size + 2 + * insets.top)); + counterExampleFigure.add(state, 0); + } + } + + getParent().setConstraint(this, new Rectangle(bounds)); + + removeAll(); + + drawPropositionFigure(bounds, ellipses1, ellipses2, + model.getStateId(), 3 * size / 5); + } + } + + private void drawPropositionFigure(final Rectangle bounds, + final Hashtable<Ellipse, Integer> ellipses1, + final Hashtable<Integer, Ellipse> ellipses2, final int stateId, + final int argumentHeight) { + ellipses1.clear(); + ellipses2.clear(); + + final PathType pathType = model.getPathType(); + + final List<CounterExampleValueType> values = model.getValues(); + + for (int i = 0; i < values.size(); i++) { + final CounterExampleValueType value = values.get(i); + final Ellipse ellipse = new Ellipse(); + + ellipse.setAntialias(SWT.ON); + ellipse.setLineWidth(2); + ellipse.setOpaque(true); + ellipse.addMouseListener(this); + ellipse.addMouseMotionListener(this); + ellipse.setBackgroundColor(getEllipseColor(value)); + + ellipses1.put(ellipse, i); + ellipses2.put(i, ellipse); + + final Label label = new Label(value.toString()); + label.setOpaque(false); + + ellipse.setLayoutManager(new BorderLayout()); + ellipse.add(label, BorderLayout.CENTER); + + add(ellipse); + + final int x = (bounds.x + size) * (i + 1); + final int y = bounds.y + argumentHeight + + (pathType == PathType.INFINITE ? size / 10 : 0); + ellipse.setBounds(new Rectangle(x, y, size, size)); + + if (i > 0) { + final ChopboxAnchor source = new ChopboxAnchor(ellipse); + final Ellipse targetEllipse = ellipses2.get(i - 1); + + if (targetEllipse == null) + continue; + + final ChopboxAnchor target = new ChopboxAnchor(targetEllipse); + + final PolylineConnection connection = new PolylineConnection(); + connection.setAlpha(Alpha.MASKED); + connection.setAntialias(SWT.ON); + connection.setLineStyle(SWT.LINE_SOLID); + connection.setLineWidth(2); + connection.setToolTip(new Label(getOperationName(i - 1))); + connection.setSourceAnchor(source); + connection.setTargetAnchor(target); + + final PolygonDecoration decoration = new PolygonDecoration(); + decoration.setAlpha(Alpha.MASKED); + decoration.setAntialias(SWT.ON); + + final PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-1, 0); + decorationPointList.addPoint(-1, -1); + decoration.setTemplate(decorationPointList); + + // highlight the transition + connection.setAlpha(Alpha.HIGHLIGHED); + decoration.setAlpha(Alpha.HIGHLIGHED); + + connection.setSourceDecoration(decoration); + + add(connection); + } + + if (i == values.size() - 1) { + if (pathType.equals(PathType.INFINITE)) { + final String operationName = getOperationName(ellipses1 + .get(ellipse)); + final Ellipse target = ellipses2.get(model.getLoopEntry()); + + int alpha = Alpha.MASKED; + Color loopTransitionColor = ColorConstants.black; + + alpha = Alpha.HIGHLIGHED; + + final PolylineConnection loop = createLoop(getInsets(), + ellipse, target, alpha, operationName, + loopTransitionColor); + + add(loop); + } else if (pathType.equals(PathType.REDUCED)) { + final Polyline reduced = createReduced(getInsets(), + ellipse, Alpha.HIGHLIGHED); + + this.add(reduced); + } + } + } + } + + @Override + public void mouseDoubleClicked(final MouseEvent me) { + super.mouseDoubleClicked(me); + + int stateId = ellipses1.get(me.getSource()); + Logger.assertProB("stateId >= 0", stateId >= 0); + + final CounterExample ce = ((CounterExampleFigure) getParent()) + .getModel(); + + if (ce != null) { + stateId += ce.getInitPath().size(); + + final Animator animator = Animator.getAnimator(); + final History history = animator.getHistory(); + + try { + CounterExampleHistoryHandler.showCounterExampleInAnimator(); + history.gotoPos(stateId); + } catch (ExecutionException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } catch (ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionEditPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionEditPart.java index 1add2a0fcb3c154eef94b9a23bdb312a6ecadb34..71f8e089ba0e9110683cc412f4792393eea56234 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionEditPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionEditPart.java @@ -1,46 +1,46 @@ -package de.prob.ui.ltl; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -public abstract class CounterExamplePropositionEditPart extends - AbstractGraphicalEditPart implements PropertyChangeListener { - @Override - public void activate() { - if (!isActive()) { - CounterExampleProposition model = (CounterExampleProposition) getModel(); - model.addPropertyChangeListener(this); - } - - super.activate(); - } - - @Override - public void deactivate() { - if (isActive()) { - CounterExampleProposition model = (CounterExampleProposition) getModel(); - model.removePropertyChangeListener(this); - } - - super.deactivate(); - } - - @Override - protected void refreshVisuals() { - CounterExamplePropositionFigure figure = (CounterExamplePropositionFigure) getFigure(); - figure.update(); - } - - @Override - protected void createEditPolicies() { - } - - @Override - public void propertyChange(PropertyChangeEvent event) { - refresh(); - } -} +package de.prob.ui.ltl; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +public abstract class CounterExamplePropositionEditPart extends + AbstractGraphicalEditPart implements PropertyChangeListener { + @Override + public void activate() { + if (!isActive()) { + CounterExampleProposition model = (CounterExampleProposition) getModel(); + model.addPropertyChangeListener(this); + } + + super.activate(); + } + + @Override + public void deactivate() { + if (isActive()) { + CounterExampleProposition model = (CounterExampleProposition) getModel(); + model.removePropertyChangeListener(this); + } + + super.deactivate(); + } + + @Override + protected void refreshVisuals() { + CounterExamplePropositionFigure figure = (CounterExamplePropositionFigure) getFigure(); + figure.update(); + } + + @Override + protected void createEditPolicies() { + } + + @Override + public void propertyChange(PropertyChangeEvent event) { + refresh(); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionFigure.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionFigure.java index 08bac75624e8cdfd82190f3b114193c03aaa4900..495428194cefa91a136bb6644aa49a1a5f7270a5 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionFigure.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExamplePropositionFigure.java @@ -1,483 +1,483 @@ -package de.prob.ui.ltl; - -import java.util.Hashtable; -import java.util.List; - -import org.eclipse.draw2d.AbstractLabeledBorder; -import org.eclipse.draw2d.BorderLayout; -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.Ellipse; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.GroupBoxBorder; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.draw2d.MouseMotionListener; -import org.eclipse.draw2d.Panel; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.Polyline; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.TitleBarBorder; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; - -import de.prob.core.command.LtlCheckingCommand.PathType; -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleState; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -public abstract class CounterExamplePropositionFigure extends Figure implements - MouseListener, MouseMotionListener { - public static class Alpha { - public static final int MASKED = 30; - public static final int HIGHLIGHED = 250; - }; - - protected final CounterExampleProposition model; - - protected final Color foregroundColor = ColorConstants.lightBlue; - protected final Color backgroundColor = new Color(null, 255, 255, 206); - - protected final Font normalFont = new Font(Display.getDefault(), "Arial", - 10, SWT.NORMAL); - protected final Font boldFont = new Font(Display.getDefault(), "Arial", 10, - SWT.BOLD); - - protected final int size = 50; - - protected final Hashtable<Integer, Connection> connections = new Hashtable<Integer, Connection>(); - - public CounterExamplePropositionFigure(final CounterExampleProposition model) { - this.model = model; - - setLayoutManager(new XYLayout()); - - final AbstractLabeledBorder border = new GroupBoxBorder(); - border.setTextColor(foregroundColor); - border.setLabel(model.getFullName()); - border.setFont(boldFont); - - setBorder(border); - setBackgroundColor(backgroundColor); - setOpaque(true); - } - - public void update() { - final Label label = new Label(model.toString()); - label.setForegroundColor(foregroundColor); - setToolTip(label); - setVisible(true); - - if (model.isVisible()) { - final CounterExampleProposition parentModel = model.getParent(); - final CounterExamplePropositionFigure parent = getFigure(parentModel); - drawProposition(parent); - } else { - setVisible(false); - } - } - - protected CounterExamplePropositionFigure getFigure( - final CounterExampleProposition proposition) { - if (proposition != null) { - final IFigure parent = getParent(); - - if (parent != null) { - // We know that each element is of type - // IFigure, but IFigure.getParent() returns just a list - @SuppressWarnings("unchecked") - final List<IFigure> figures = parent.getChildren(); - - for (IFigure figure : figures) { - if (figure instanceof CounterExamplePropositionFigure) { - if (((CounterExamplePropositionFigure) figure) - .getModel().equals(proposition)) { - return (CounterExamplePropositionFigure) figure; - } - } - } - } - } - - return null; - } - - protected void setTrasparent(final List<CounterExampleProposition> children) { - for (CounterExampleProposition child : children) { - final CounterExamplePropositionFigure childFigure = getFigure(child); - - for (Connection connection : childFigure.getConnections().values()) { - connection.setVisible(false); - } - - child.setVisible(false); - } - } - - protected abstract void drawProposition( - final CounterExamplePropositionFigure parent); - - protected CounterExampleProposition getModel() { - return model; - } - - protected Color getEllipseColor(final CounterExampleValueType value) { - Color color = ColorConstants.gray; - - if (value.equals(CounterExampleValueType.TRUE)) - color = ColorConstants.green; - else if (value.equals(CounterExampleValueType.FALSE)) - color = ColorConstants.red; - - return color; - } - - protected String getOperationName(final int index) { - final CounterExampleFigure parentFigure = (CounterExampleFigure) getParent(); - final CounterExample parentModel = parentFigure.getModel(); - final List<CounterExampleState> states = parentModel.getStates(); - final CounterExampleState state = states.get(index); - final Operation operation = state.getOperation(); - final String operationName = operation.getName(); - return operationName; - } - - protected Hashtable<Integer, Connection> getConnections() { - return connections; - } - - protected PolylineConnection createLoop(final Insets insets, - final Ellipse source, final Ellipse target, final int alpha, - final String operationName, final Color loopColor) { - final PolylineConnection connection = new PolylineConnection(); - connection.setAlpha(alpha); - connection.setAntialias(SWT.ON); - connection.setLineWidth(2); - - final Label label = new Label(operationName); - label.setForegroundColor(foregroundColor); - connection.setToolTip(label); - connection.setForegroundColor(loopColor); - - final PointList points = new PointList(); - final Rectangle sourceBounds = source.getBounds(); - final Rectangle targetBounds = target.getBounds(); - points.addPoint(new Point(sourceBounds.x + size + insets.left, - sourceBounds.y + size / 2 + insets.top)); - points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 - + insets.left, sourceBounds.y + size / 2 + insets.top)); - points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 - + insets.left, sourceBounds.y - size / 5 + insets.top)); - points.addPoint(new Point(targetBounds.x + size / 2 + insets.left, - targetBounds.y - size / 5 + insets.top)); - points.addPoint(new Point(targetBounds.x + size / 2 + insets.left, - targetBounds.y + insets.top)); - connection.setPoints(points); - - final PolygonDecoration decoration = new PolygonDecoration(); - decoration.setForegroundColor(loopColor); - decoration.setAlpha(alpha); - decoration.setAntialias(SWT.ON); - - final PointList decorationPointList = new PointList(); - decorationPointList.addPoint(0, 0); - decorationPointList.addPoint(-1, 1); - decorationPointList.addPoint(-1, 0); - decorationPointList.addPoint(-1, -1); - decoration.setTemplate(decorationPointList); - - connection.setTargetDecoration(decoration); - - return connection; - } - - protected Polyline createReduced(final Insets insets, final Ellipse source, - final int alpha) { - final Polyline polyline = new Polyline(); - polyline.setAlpha(alpha); - polyline.setAntialias(SWT.ON); - polyline.setLineWidth(2); - polyline.setToolTip(new Label("Reduced")); - - final PointList points = new PointList(); - final Rectangle sourceBounds = source.getBounds(); - points.addPoint(new Point(sourceBounds.x + size + insets.left, - sourceBounds.y + size / 2 + insets.top)); - points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 - + insets.left, sourceBounds.y + size / 2 + insets.top)); - points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 - + insets.left, sourceBounds.y + insets.top + size / 4)); - points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 - + insets.left, sourceBounds.y + insets.top + (3 * size) / 4)); - polyline.setPoints(points); - - return polyline; - } - - protected void drawChildParentConnection(final Ellipse ellipse, - final int stateId, final CounterExamplePropositionFigure parent) { - if (connections.containsKey(stateId)) { - connections.get(stateId).setVisible(true); - } else { - final Insets insets = parent.getInsets(); - - final PolylineConnection connection = new PolylineConnection(); - connection.setAntialias(SWT.ON); - connection.setLineStyle(SWT.LINE_SOLID); - connection.setLineWidth(2); - - final Rectangle sourceBounds = parent.getBounds(); - final Rectangle targetBounds = getBounds(); - - final PointList points = new PointList(); - points.addPoint(ellipse.getBounds().x + insets.left + size / 2, - sourceBounds.y + sourceBounds.height); - points.addPoint(ellipse.getBounds().x + insets.left + size / 2, - targetBounds.y + insets.top); - connection.setPoints(points); - - final PolygonDecoration decoration = new PolygonDecoration(); - decoration.setAntialias(SWT.ON); - - final PointList decorationPointList = new PointList(); - decorationPointList.addPoint(0, 0); - decorationPointList.addPoint(-1, 1); - decorationPointList.addPoint(-1, 0); - decorationPointList.addPoint(-1, -1); - decoration.setTemplate(decorationPointList); - - connection.setSourceDecoration(decoration); - getParent().add(connection); - connections.put(stateId, connection); - } - } - - protected Panel drawPropositionFigure( - final CounterExamplePropositionFigure parent, - final Rectangle bounds, final CounterExampleProposition argument, - final List<Integer> positions, - final Hashtable<Ellipse, Integer> ellipses1, - final Hashtable<Integer, Ellipse> ellipses2, - final Rectangle panelBounds, final int stateId, - final int argumentHeight) { - ellipses1.clear(); - ellipses2.clear(); - - final PathType pathType = model.getPathType(); - - final List<CounterExampleValueType> values = argument.getValues(); - - Panel panel = new Panel(); - panel.setBounds(panelBounds); - - final TitleBarBorder border = new TitleBarBorder(); - border.setBackgroundColor(backgroundColor); - border.setTextColor(foregroundColor); - border.setLabel(argument.toString()); - border.setFont(normalFont); - - panel.setBorder(border); - add(panel); - - for (int i = 0; i < values.size(); i++) { - createColumn(bounds, argument, positions, ellipses1, ellipses2, - argumentHeight, pathType, values, panel, i); - } - - if (parent != null) { - final Ellipse ellipse = ellipses2.get(stateId); - drawChildParentConnection(ellipse, stateId, parent); - } - - return panel; - } - - private void createColumn(final Rectangle bounds, - final CounterExampleProposition argument, - final List<Integer> positions, - final Hashtable<Ellipse, Integer> ellipses1, - final Hashtable<Integer, Ellipse> ellipses2, - final int argumentHeight, final PathType pathType, - final List<CounterExampleValueType> values, Panel panel, int i) { - final CounterExampleValueType value = values.get(i); - final Ellipse ellipse = new Ellipse(); - - if (!positions.contains(i)) { - ellipse.setAlpha(Alpha.MASKED); - } - - ellipse.setAntialias(SWT.ON); - ellipse.setLineWidth(2); - ellipse.setOpaque(true); - ellipse.addMouseListener(this); - ellipse.addMouseMotionListener(this); - ellipse.setBackgroundColor(getEllipseColor(value)); - - ellipses1.put(ellipse, i); - ellipses2.put(i, ellipse); - - final Label label = new Label(value.toString()); - label.setOpaque(false); - - ellipse.setLayoutManager(new BorderLayout()); - ellipse.add(label, BorderLayout.CENTER); - - panel.add(ellipse); - - final int x = (bounds.x + size) * (i + 1); - final int y = bounds.y + argumentHeight - + (pathType == PathType.INFINITE ? size / 10 : 0); - ellipse.setBounds(new Rectangle(x, y, size, size)); - - if (i > 0) { - final ChopboxAnchor source = new ChopboxAnchor(ellipse); - final Ellipse targetEllipse = ellipses2.get(i - 1); - - if (targetEllipse == null) - return; - - final ChopboxAnchor target = new ChopboxAnchor(targetEllipse); - - final PolylineConnection connection = new PolylineConnection(); - connection.setAlpha(Alpha.MASKED); - connection.setAntialias(SWT.ON); - connection.setLineStyle(SWT.LINE_SOLID); - connection.setLineWidth(2); - connection.setToolTip(new Label(getOperationName(i - 1))); - connection.setSourceAnchor(source); - connection.setTargetAnchor(target); - - final PolygonDecoration decoration = new PolygonDecoration(); - decoration.setAlpha(Alpha.MASKED); - decoration.setAntialias(SWT.ON); - - final PointList decorationPointList = new PointList(); - decorationPointList.addPoint(0, 0); - decorationPointList.addPoint(-1, 1); - decorationPointList.addPoint(-1, 0); - decorationPointList.addPoint(-1, -1); - decoration.setTemplate(decorationPointList); - - // highlight the transition - if (positions.contains(i) && positions.contains(i - 1)) { - connection.setAlpha(Alpha.HIGHLIGHED); - decoration.setAlpha(Alpha.HIGHLIGHED); - } - - // highlight and color the transition - if (model.isTransition() || argument.isTransition()) { - if (positions.contains(i - 1)) { - connection.setAlpha(Alpha.HIGHLIGHED); - decoration.setAlpha(Alpha.HIGHLIGHED); - Color transitionColor = getEllipseColor(values.get(i - 1)); - connection.setForegroundColor(transitionColor); - decoration.setForegroundColor(transitionColor); - } - } - - connection.setSourceDecoration(decoration); - - panel.add(connection); - } - - boolean isLastElement = i == values.size() - 1; - if (isLastElement) { - createEnd(argument, positions, ellipses1, ellipses2, pathType, - values, panel, i, ellipse); - } - } - - private void createEnd(final CounterExampleProposition argument, - final List<Integer> positions, - final Hashtable<Ellipse, Integer> ellipses1, - final Hashtable<Integer, Ellipse> ellipses2, - final PathType pathType, - final List<CounterExampleValueType> values, Panel panel, int i, - final Ellipse ellipse) { - final IFigure figure; - switch (pathType) { - case INFINITE: - final String operationName = getOperationName(ellipses1 - .get(ellipse)); - final Ellipse target = ellipses2.get(model.getLoopEntry()); - - int alpha = Alpha.MASKED; - Color loopTransitionColor = ColorConstants.black; - - final boolean highlightLoop = positions.contains(i) - && positions.contains(i - 1); - if (highlightLoop) { - alpha = Alpha.HIGHLIGHED; - } - - if (model.isTransition() || argument.isTransition()) { - if (positions.contains(i)) { - alpha = Alpha.HIGHLIGHED; - loopTransitionColor = getEllipseColor(values.get(i)); - } - } - figure = createLoop(getInsets(), ellipse, target, alpha, - operationName, loopTransitionColor); - break; - - case REDUCED: - figure = createReduced(getInsets(), ellipse, - positions.contains(i) ? Alpha.HIGHLIGHED : Alpha.MASKED); - break; - - default: - figure = null; - break; - } - if (figure != null) { - panel.add(figure); - } - } - - @Override - public void mouseReleased(MouseEvent me) { - } - - @Override - public void mousePressed(MouseEvent me) { - me.consume(); - me.consume(); - } - - @Override - public void mouseDoubleClicked(MouseEvent me) { - System.out.println(""); - } - - @Override - public void mouseDragged(MouseEvent me) { - } - - @Override - public void mouseExited(MouseEvent me) { - } - - @Override - public void mouseHover(MouseEvent me) { - } - - @Override - public void mouseMoved(MouseEvent me) { - } - - @Override - public void mouseEntered(MouseEvent me) { - } -} +package de.prob.ui.ltl; + +import java.util.Hashtable; +import java.util.List; + +import org.eclipse.draw2d.AbstractLabeledBorder; +import org.eclipse.draw2d.BorderLayout; +import org.eclipse.draw2d.ChopboxAnchor; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.GroupBoxBorder; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.MouseEvent; +import org.eclipse.draw2d.MouseListener; +import org.eclipse.draw2d.MouseMotionListener; +import org.eclipse.draw2d.Panel; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.Polyline; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.TitleBarBorder; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Display; + +import de.prob.core.command.LtlCheckingCommand.PathType; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleState; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +public abstract class CounterExamplePropositionFigure extends Figure implements + MouseListener, MouseMotionListener { + public static class Alpha { + public static final int MASKED = 30; + public static final int HIGHLIGHED = 250; + }; + + protected final CounterExampleProposition model; + + protected final Color foregroundColor = ColorConstants.lightBlue; + protected final Color backgroundColor = new Color(null, 255, 255, 206); + + protected final Font normalFont = new Font(Display.getDefault(), "Arial", + 10, SWT.NORMAL); + protected final Font boldFont = new Font(Display.getDefault(), "Arial", 10, + SWT.BOLD); + + protected final int size = 50; + + protected final Hashtable<Integer, Connection> connections = new Hashtable<Integer, Connection>(); + + public CounterExamplePropositionFigure(final CounterExampleProposition model) { + this.model = model; + + setLayoutManager(new XYLayout()); + + final AbstractLabeledBorder border = new GroupBoxBorder(); + border.setTextColor(foregroundColor); + border.setLabel(model.getFullName()); + border.setFont(boldFont); + + setBorder(border); + setBackgroundColor(backgroundColor); + setOpaque(true); + } + + public void update() { + final Label label = new Label(model.toString()); + label.setForegroundColor(foregroundColor); + setToolTip(label); + setVisible(true); + + if (model.isVisible()) { + final CounterExampleProposition parentModel = model.getParent(); + final CounterExamplePropositionFigure parent = getFigure(parentModel); + drawProposition(parent); + } else { + setVisible(false); + } + } + + protected CounterExamplePropositionFigure getFigure( + final CounterExampleProposition proposition) { + if (proposition != null) { + final IFigure parent = getParent(); + + if (parent != null) { + // We know that each element is of type + // IFigure, but IFigure.getParent() returns just a list + @SuppressWarnings("unchecked") + final List<IFigure> figures = parent.getChildren(); + + for (IFigure figure : figures) { + if (figure instanceof CounterExamplePropositionFigure) { + if (((CounterExamplePropositionFigure) figure) + .getModel().equals(proposition)) { + return (CounterExamplePropositionFigure) figure; + } + } + } + } + } + + return null; + } + + protected void setTrasparent(final List<CounterExampleProposition> children) { + for (CounterExampleProposition child : children) { + final CounterExamplePropositionFigure childFigure = getFigure(child); + + for (Connection connection : childFigure.getConnections().values()) { + connection.setVisible(false); + } + + child.setVisible(false); + } + } + + protected abstract void drawProposition( + final CounterExamplePropositionFigure parent); + + protected CounterExampleProposition getModel() { + return model; + } + + protected Color getEllipseColor(final CounterExampleValueType value) { + Color color = ColorConstants.gray; + + if (value.equals(CounterExampleValueType.TRUE)) + color = ColorConstants.green; + else if (value.equals(CounterExampleValueType.FALSE)) + color = ColorConstants.red; + + return color; + } + + protected String getOperationName(final int index) { + final CounterExampleFigure parentFigure = (CounterExampleFigure) getParent(); + final CounterExample parentModel = parentFigure.getModel(); + final List<CounterExampleState> states = parentModel.getStates(); + final CounterExampleState state = states.get(index); + final Operation operation = state.getOperation(); + final String operationName = operation.getName(); + return operationName; + } + + protected Hashtable<Integer, Connection> getConnections() { + return connections; + } + + protected PolylineConnection createLoop(final Insets insets, + final Ellipse source, final Ellipse target, final int alpha, + final String operationName, final Color loopColor) { + final PolylineConnection connection = new PolylineConnection(); + connection.setAlpha(alpha); + connection.setAntialias(SWT.ON); + connection.setLineWidth(2); + + final Label label = new Label(operationName); + label.setForegroundColor(foregroundColor); + connection.setToolTip(label); + connection.setForegroundColor(loopColor); + + final PointList points = new PointList(); + final Rectangle sourceBounds = source.getBounds(); + final Rectangle targetBounds = target.getBounds(); + points.addPoint(new Point(sourceBounds.x + size + insets.left, + sourceBounds.y + size / 2 + insets.top)); + points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 + + insets.left, sourceBounds.y + size / 2 + insets.top)); + points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 + + insets.left, sourceBounds.y - size / 5 + insets.top)); + points.addPoint(new Point(targetBounds.x + size / 2 + insets.left, + targetBounds.y - size / 5 + insets.top)); + points.addPoint(new Point(targetBounds.x + size / 2 + insets.left, + targetBounds.y + insets.top)); + connection.setPoints(points); + + final PolygonDecoration decoration = new PolygonDecoration(); + decoration.setForegroundColor(loopColor); + decoration.setAlpha(alpha); + decoration.setAntialias(SWT.ON); + + final PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-1, 0); + decorationPointList.addPoint(-1, -1); + decoration.setTemplate(decorationPointList); + + connection.setTargetDecoration(decoration); + + return connection; + } + + protected Polyline createReduced(final Insets insets, final Ellipse source, + final int alpha) { + final Polyline polyline = new Polyline(); + polyline.setAlpha(alpha); + polyline.setAntialias(SWT.ON); + polyline.setLineWidth(2); + polyline.setToolTip(new Label("Reduced")); + + final PointList points = new PointList(); + final Rectangle sourceBounds = source.getBounds(); + points.addPoint(new Point(sourceBounds.x + size + insets.left, + sourceBounds.y + size / 2 + insets.top)); + points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 + + insets.left, sourceBounds.y + size / 2 + insets.top)); + points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 + + insets.left, sourceBounds.y + insets.top + size / 4)); + points.addPoint(new Point(sourceBounds.x + size + (3 * size) / 10 + + insets.left, sourceBounds.y + insets.top + (3 * size) / 4)); + polyline.setPoints(points); + + return polyline; + } + + protected void drawChildParentConnection(final Ellipse ellipse, + final int stateId, final CounterExamplePropositionFigure parent) { + if (connections.containsKey(stateId)) { + connections.get(stateId).setVisible(true); + } else { + final Insets insets = parent.getInsets(); + + final PolylineConnection connection = new PolylineConnection(); + connection.setAntialias(SWT.ON); + connection.setLineStyle(SWT.LINE_SOLID); + connection.setLineWidth(2); + + final Rectangle sourceBounds = parent.getBounds(); + final Rectangle targetBounds = getBounds(); + + final PointList points = new PointList(); + points.addPoint(ellipse.getBounds().x + insets.left + size / 2, + sourceBounds.y + sourceBounds.height); + points.addPoint(ellipse.getBounds().x + insets.left + size / 2, + targetBounds.y + insets.top); + connection.setPoints(points); + + final PolygonDecoration decoration = new PolygonDecoration(); + decoration.setAntialias(SWT.ON); + + final PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-1, 0); + decorationPointList.addPoint(-1, -1); + decoration.setTemplate(decorationPointList); + + connection.setSourceDecoration(decoration); + getParent().add(connection); + connections.put(stateId, connection); + } + } + + protected Panel drawPropositionFigure( + final CounterExamplePropositionFigure parent, + final Rectangle bounds, final CounterExampleProposition argument, + final List<Integer> positions, + final Hashtable<Ellipse, Integer> ellipses1, + final Hashtable<Integer, Ellipse> ellipses2, + final Rectangle panelBounds, final int stateId, + final int argumentHeight) { + ellipses1.clear(); + ellipses2.clear(); + + final PathType pathType = model.getPathType(); + + final List<CounterExampleValueType> values = argument.getValues(); + + Panel panel = new Panel(); + panel.setBounds(panelBounds); + + final TitleBarBorder border = new TitleBarBorder(); + border.setBackgroundColor(backgroundColor); + border.setTextColor(foregroundColor); + border.setLabel(argument.toString()); + border.setFont(normalFont); + + panel.setBorder(border); + add(panel); + + for (int i = 0; i < values.size(); i++) { + createColumn(bounds, argument, positions, ellipses1, ellipses2, + argumentHeight, pathType, values, panel, i); + } + + if (parent != null) { + final Ellipse ellipse = ellipses2.get(stateId); + drawChildParentConnection(ellipse, stateId, parent); + } + + return panel; + } + + private void createColumn(final Rectangle bounds, + final CounterExampleProposition argument, + final List<Integer> positions, + final Hashtable<Ellipse, Integer> ellipses1, + final Hashtable<Integer, Ellipse> ellipses2, + final int argumentHeight, final PathType pathType, + final List<CounterExampleValueType> values, Panel panel, int i) { + final CounterExampleValueType value = values.get(i); + final Ellipse ellipse = new Ellipse(); + + if (!positions.contains(i)) { + ellipse.setAlpha(Alpha.MASKED); + } + + ellipse.setAntialias(SWT.ON); + ellipse.setLineWidth(2); + ellipse.setOpaque(true); + ellipse.addMouseListener(this); + ellipse.addMouseMotionListener(this); + ellipse.setBackgroundColor(getEllipseColor(value)); + + ellipses1.put(ellipse, i); + ellipses2.put(i, ellipse); + + final Label label = new Label(value.toString()); + label.setOpaque(false); + + ellipse.setLayoutManager(new BorderLayout()); + ellipse.add(label, BorderLayout.CENTER); + + panel.add(ellipse); + + final int x = (bounds.x + size) * (i + 1); + final int y = bounds.y + argumentHeight + + (pathType == PathType.INFINITE ? size / 10 : 0); + ellipse.setBounds(new Rectangle(x, y, size, size)); + + if (i > 0) { + final ChopboxAnchor source = new ChopboxAnchor(ellipse); + final Ellipse targetEllipse = ellipses2.get(i - 1); + + if (targetEllipse == null) + return; + + final ChopboxAnchor target = new ChopboxAnchor(targetEllipse); + + final PolylineConnection connection = new PolylineConnection(); + connection.setAlpha(Alpha.MASKED); + connection.setAntialias(SWT.ON); + connection.setLineStyle(SWT.LINE_SOLID); + connection.setLineWidth(2); + connection.setToolTip(new Label(getOperationName(i - 1))); + connection.setSourceAnchor(source); + connection.setTargetAnchor(target); + + final PolygonDecoration decoration = new PolygonDecoration(); + decoration.setAlpha(Alpha.MASKED); + decoration.setAntialias(SWT.ON); + + final PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-1, 0); + decorationPointList.addPoint(-1, -1); + decoration.setTemplate(decorationPointList); + + // highlight the transition + if (positions.contains(i) && positions.contains(i - 1)) { + connection.setAlpha(Alpha.HIGHLIGHED); + decoration.setAlpha(Alpha.HIGHLIGHED); + } + + // highlight and color the transition + if (model.isTransition() || argument.isTransition()) { + if (positions.contains(i - 1)) { + connection.setAlpha(Alpha.HIGHLIGHED); + decoration.setAlpha(Alpha.HIGHLIGHED); + Color transitionColor = getEllipseColor(values.get(i - 1)); + connection.setForegroundColor(transitionColor); + decoration.setForegroundColor(transitionColor); + } + } + + connection.setSourceDecoration(decoration); + + panel.add(connection); + } + + boolean isLastElement = i == values.size() - 1; + if (isLastElement) { + createEnd(argument, positions, ellipses1, ellipses2, pathType, + values, panel, i, ellipse); + } + } + + private void createEnd(final CounterExampleProposition argument, + final List<Integer> positions, + final Hashtable<Ellipse, Integer> ellipses1, + final Hashtable<Integer, Ellipse> ellipses2, + final PathType pathType, + final List<CounterExampleValueType> values, Panel panel, int i, + final Ellipse ellipse) { + final IFigure figure; + switch (pathType) { + case INFINITE: + final String operationName = getOperationName(ellipses1 + .get(ellipse)); + final Ellipse target = ellipses2.get(model.getLoopEntry()); + + int alpha = Alpha.MASKED; + Color loopTransitionColor = ColorConstants.black; + + final boolean highlightLoop = positions.contains(i) + && positions.contains(i - 1); + if (highlightLoop) { + alpha = Alpha.HIGHLIGHED; + } + + if (model.isTransition() || argument.isTransition()) { + if (positions.contains(i)) { + alpha = Alpha.HIGHLIGHED; + loopTransitionColor = getEllipseColor(values.get(i)); + } + } + figure = createLoop(getInsets(), ellipse, target, alpha, + operationName, loopTransitionColor); + break; + + case REDUCED: + figure = createReduced(getInsets(), ellipse, + positions.contains(i) ? Alpha.HIGHLIGHED : Alpha.MASKED); + break; + + default: + figure = null; + break; + } + if (figure != null) { + panel.add(figure); + } + } + + @Override + public void mouseReleased(MouseEvent me) { + } + + @Override + public void mousePressed(MouseEvent me) { + me.consume(); + me.consume(); + } + + @Override + public void mouseDoubleClicked(MouseEvent me) { + System.out.println(""); + } + + @Override + public void mouseDragged(MouseEvent me) { + } + + @Override + public void mouseExited(MouseEvent me) { + } + + @Override + public void mouseHover(MouseEvent me) { + } + + @Override + public void mouseMoved(MouseEvent me) { + } + + @Override + public void mouseEntered(MouseEvent me) { + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableMouseAdapter.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableMouseAdapter.java index 19d74cff543391e2ac936de767380ea4be699751..92aae8283f3a7b30ed81056f7dfa366f9ea2e1c6 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableMouseAdapter.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableMouseAdapter.java @@ -1,57 +1,57 @@ -package de.prob.ui.ltl; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.TableItem; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.History; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; - -public final class CounterExampleTableMouseAdapter extends MouseAdapter { - private final CounterExampleTableViewer tableViewer; - private final CounterExample counterExample; - - public CounterExampleTableMouseAdapter( - CounterExampleTableViewer tableViewer, CounterExample counterExample) { - this.tableViewer = tableViewer; - this.counterExample = counterExample; - } - - @Override - public void mouseDoubleClick(final MouseEvent event) { - final ViewerCell cell = tableViewer - .getCell(new Point(event.x, event.y)); - - if (cell != null) { - List<TableItem> items = Arrays.asList(tableViewer.getTable() - .getItems()); - TableItem item = (TableItem) cell.getItem(); - int index = items.indexOf(item); - index += counterExample.getInitPath().size(); - - final Animator animator = Animator.getAnimator(); - final History history = animator.getHistory(); - - try { - CounterExampleHistoryHandler.showCounterExampleInAnimator(); - history.gotoPos(index); - } catch (final ExecutionException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } catch (final ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } - } - } -} +package de.prob.ui.ltl; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.TableItem; + +import de.prob.core.Animator; +import de.prob.core.domainobjects.History; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; +import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; + +public final class CounterExampleTableMouseAdapter extends MouseAdapter { + private final CounterExampleTableViewer tableViewer; + private final CounterExample counterExample; + + public CounterExampleTableMouseAdapter( + CounterExampleTableViewer tableViewer, CounterExample counterExample) { + this.tableViewer = tableViewer; + this.counterExample = counterExample; + } + + @Override + public void mouseDoubleClick(final MouseEvent event) { + final ViewerCell cell = tableViewer + .getCell(new Point(event.x, event.y)); + + if (cell != null) { + List<TableItem> items = Arrays.asList(tableViewer.getTable() + .getItems()); + TableItem item = (TableItem) cell.getItem(); + int index = items.indexOf(item); + index += counterExample.getInitPath().size(); + + final Animator animator = Animator.getAnimator(); + final History history = animator.getHistory(); + + try { + CounterExampleHistoryHandler.showCounterExampleInAnimator(); + history.gotoPos(index); + } catch (final ExecutionException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } catch (final ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableViewer.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableViewer.java index 39f585d35a9722d3162bee20ed973559ee94a7b5..f718d9f6d89589308389f7692480640799a14e21 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableViewer.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTableViewer.java @@ -1,33 +1,33 @@ -package de.prob.ui.ltl; - -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; - -public final class CounterExampleTableViewer extends TableViewer { - public CounterExampleTableViewer(Composite parent, int style) { - super(parent, style); - } - - @Override - protected Item getItemAt(Point p) { - Table table = getTable(); - TableItem[] items = table.getItems(); - - for (int i = 0; i < items.length; i++) { - for (int j = 0; j < table.getColumnCount(); j++) { - Rectangle bounds = items[i].getBounds(j); - - if (bounds.contains(p)) { - return items[i]; - } - } - } - - return null; - } -} +package de.prob.ui.ltl; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Item; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; + +public final class CounterExampleTableViewer extends TableViewer { + public CounterExampleTableViewer(Composite parent, int style) { + super(parent, style); + } + + @Override + protected Item getItemAt(Point p) { + Table table = getTable(); + TableItem[] items = table.getItems(); + + for (int i = 0; i < items.length; i++) { + for (int j = 0; j < table.getColumnCount(); j++) { + Rectangle bounds = items[i].getBounds(j); + + if (bounds.contains(p)) { + return items[i]; + } + } + } + + return null; + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseAdapter.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseAdapter.java index 19e3dd0e5805a1843e5faee7c5df177b38105eb1..553efdeb91ce021b1d6862a090cfd30f2d94f1cc 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseAdapter.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseAdapter.java @@ -1,49 +1,49 @@ -package de.prob.ui.ltl; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.History; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; - -public final class CounterExampleTreeMouseAdapter extends MouseAdapter { - private final CounterExampleTreeViewer treeViewer; - private final CounterExample counterExample; - - public CounterExampleTreeMouseAdapter(CounterExampleTreeViewer treeViewer, - CounterExample counterExample) { - this.treeViewer = treeViewer; - this.counterExample = counterExample; - } - - @Override - public void mouseDoubleClick(final MouseEvent event) { - final ViewerCell cell = treeViewer.getCell(new Point(event.x, event.y)); - - if (cell != null && cell.getColumnIndex() > 0) { - int index = cell.getColumnIndex() - 1; - index += counterExample.getInitPath().size(); - - final Animator animator = Animator.getAnimator(); - final History history = animator.getHistory(); - - try { - CounterExampleHistoryHandler.showCounterExampleInAnimator(); - history.gotoPos(index); - } catch (final ExecutionException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } catch (final ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } - } - } -} +package de.prob.ui.ltl; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Point; + +import de.prob.core.Animator; +import de.prob.core.domainobjects.History; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; +import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; + +public final class CounterExampleTreeMouseAdapter extends MouseAdapter { + private final CounterExampleTreeViewer treeViewer; + private final CounterExample counterExample; + + public CounterExampleTreeMouseAdapter(CounterExampleTreeViewer treeViewer, + CounterExample counterExample) { + this.treeViewer = treeViewer; + this.counterExample = counterExample; + } + + @Override + public void mouseDoubleClick(final MouseEvent event) { + final ViewerCell cell = treeViewer.getCell(new Point(event.x, event.y)); + + if (cell != null && cell.getColumnIndex() > 0) { + int index = cell.getColumnIndex() - 1; + index += counterExample.getInitPath().size(); + + final Animator animator = Animator.getAnimator(); + final History history = animator.getHistory(); + + try { + CounterExampleHistoryHandler.showCounterExampleInAnimator(); + history.gotoPos(index); + } catch (final ExecutionException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } catch (final ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseMoveAdapter.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseMoveAdapter.java index e0e89009c75e5e9c58494fe67b7f25390f6cc8e8..1619b4233d0489357e460683558b5ead92217535 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseMoveAdapter.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeMouseMoveAdapter.java @@ -1,75 +1,75 @@ -package de.prob.ui.ltl; - -import java.util.List; - -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseMoveListener; -import org.eclipse.swt.graphics.Point; - -import de.prob.core.command.LtlCheckingCommand.PathType; -import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; - -public final class CounterExampleTreeMouseMoveAdapter implements - MouseMoveListener { - private final CounterExampleTreeViewer treeViewer; - private ViewerCell currentCell; - - public CounterExampleTreeMouseMoveAdapter( - CounterExampleTreeViewer treeViewer) { - this.treeViewer = treeViewer; - } - - @Override - public void mouseMove(MouseEvent e) { - ViewerCell cell = treeViewer.getCell(new Point(e.x, e.y)); - - if (cell != null && !cell.equals(currentCell)) { - currentCell = cell; - CounterExampleProposition element = (CounterExampleProposition) cell - .getElement(); - PathType pathType = element.getPathType(); - int loopEntry = element.getLoopEntry(); - String toolTip = "PathType: " + pathType + ", loopEntry = " - + loopEntry; - - int columnIndex = cell.getColumnIndex(); - - if (cell.getColumnIndex() > 0) { - if (element instanceof CounterExampleUnaryOperator) { - CounterExampleUnaryOperator unary = (CounterExampleUnaryOperator) element; - List<List<Integer>> allPositions = unary - .getHighlightedPositions(); - - if (columnIndex - 1 < allPositions.size()) { - List<Integer> positions = allPositions - .get(columnIndex - 1); - toolTip += ". Positions: " + positions; - } - } else if (element instanceof CounterExampleBinaryOperator) { - CounterExampleBinaryOperator binary = (CounterExampleBinaryOperator) element; - - List<List<Integer>> firstAllPositions = binary - .getFirstHighlightedPositions(); - - if (columnIndex - 1 < firstAllPositions.size()) { - List<Integer> firstPositions = binary - .getFirstHighlightedPositions().get( - columnIndex - 1); - List<Integer> secondPositions = binary - .getSecondHighlightedPositions().get( - columnIndex - 1); - - toolTip += ". FirstPositions: " + firstPositions; - toolTip += ", SecondPositions: " + secondPositions; - } - } - } - - cell.getControl().setToolTipText(toolTip); - System.out.println(element); - } - } -} +package de.prob.ui.ltl; + +import java.util.List; + +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.graphics.Point; + +import de.prob.core.command.LtlCheckingCommand.PathType; +import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; + +public final class CounterExampleTreeMouseMoveAdapter implements + MouseMoveListener { + private final CounterExampleTreeViewer treeViewer; + private ViewerCell currentCell; + + public CounterExampleTreeMouseMoveAdapter( + CounterExampleTreeViewer treeViewer) { + this.treeViewer = treeViewer; + } + + @Override + public void mouseMove(MouseEvent e) { + ViewerCell cell = treeViewer.getCell(new Point(e.x, e.y)); + + if (cell != null && !cell.equals(currentCell)) { + currentCell = cell; + CounterExampleProposition element = (CounterExampleProposition) cell + .getElement(); + PathType pathType = element.getPathType(); + int loopEntry = element.getLoopEntry(); + String toolTip = "PathType: " + pathType + ", loopEntry = " + + loopEntry; + + int columnIndex = cell.getColumnIndex(); + + if (cell.getColumnIndex() > 0) { + if (element instanceof CounterExampleUnaryOperator) { + CounterExampleUnaryOperator unary = (CounterExampleUnaryOperator) element; + List<List<Integer>> allPositions = unary + .getHighlightedPositions(); + + if (columnIndex - 1 < allPositions.size()) { + List<Integer> positions = allPositions + .get(columnIndex - 1); + toolTip += ". Positions: " + positions; + } + } else if (element instanceof CounterExampleBinaryOperator) { + CounterExampleBinaryOperator binary = (CounterExampleBinaryOperator) element; + + List<List<Integer>> firstAllPositions = binary + .getFirstHighlightedPositions(); + + if (columnIndex - 1 < firstAllPositions.size()) { + List<Integer> firstPositions = binary + .getFirstHighlightedPositions().get( + columnIndex - 1); + List<Integer> secondPositions = binary + .getSecondHighlightedPositions().get( + columnIndex - 1); + + toolTip += ". FirstPositions: " + firstPositions; + toolTip += ", SecondPositions: " + secondPositions; + } + } + } + + cell.getControl().setToolTipText(toolTip); + System.out.println(element); + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeViewer.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeViewer.java index cfd4217acec24479cce970cc8a0d553185cb66c2..a401f0f94cca1c931eb85080aa12f3defeaee2cd 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeViewer.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleTreeViewer.java @@ -1,60 +1,60 @@ -package de.prob.ui.ltl; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; - -public final class CounterExampleTreeViewer extends TreeViewer { - - public CounterExampleTreeViewer(Composite parent, int style) { - super(parent, style); - } - - @Override - protected Item getItemAt(Point p) { - Tree tree = getTree(); - TreeItem[] selection = tree.getSelection(); - - if (selection.length == 1) { - int columnCount = tree.getColumnCount(); - - for (int i = 0; i < columnCount; i++) { - if (selection[0].getBounds(i).contains(p)) { - return selection[0]; - } - } - } - - TreeItem item = getItemAt(null, p); - - return item; - } - - private TreeItem getItemAt(TreeItem parentItem, Point point) { - TreeItem[] items = (parentItem == null) ? getTree().getItems() - : parentItem.getItems(); - - for (int i = 0; i < items.length; i++) { - for (int j = 0; j < getTree().getColumnCount(); j++) { - if (items[i].getBounds(j).contains(point)) { - return items[i]; - } - } - - TreeItem foundItem = null; - - if (items[i].getExpanded() == true) { - foundItem = getItemAt(items[i], point); - } - - if (foundItem != null) { - return foundItem; - } - } - - return null; - } -} +package de.prob.ui.ltl; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Item; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +public final class CounterExampleTreeViewer extends TreeViewer { + + public CounterExampleTreeViewer(Composite parent, int style) { + super(parent, style); + } + + @Override + protected Item getItemAt(Point p) { + Tree tree = getTree(); + TreeItem[] selection = tree.getSelection(); + + if (selection.length == 1) { + int columnCount = tree.getColumnCount(); + + for (int i = 0; i < columnCount; i++) { + if (selection[0].getBounds(i).contains(p)) { + return selection[0]; + } + } + } + + TreeItem item = getItemAt(null, p); + + return item; + } + + private TreeItem getItemAt(TreeItem parentItem, Point point) { + TreeItem[] items = (parentItem == null) ? getTree().getItems() + : parentItem.getItems(); + + for (int i = 0; i < items.length; i++) { + for (int j = 0; j < getTree().getColumnCount(); j++) { + if (items[i].getBounds(j).contains(point)) { + return items[i]; + } + } + + TreeItem foundItem = null; + + if (items[i].getExpanded() == true) { + foundItem = getItemAt(items[i], point); + } + + if (foundItem != null) { + return foundItem; + } + } + + return null; + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryEditPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryEditPart.java index 6e2181b1124fd9394d659f295f2fc935c6e93227..f28f16371a4b37cfcde257c81269c8869492d8ba 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryEditPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryEditPart.java @@ -1,14 +1,14 @@ -package de.prob.ui.ltl; - -import org.eclipse.draw2d.IFigure; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -public final class CounterExampleUnaryEditPart extends - CounterExamplePropositionEditPart { - @Override - protected IFigure createFigure() { - CounterExampleProposition model = (CounterExampleProposition) getModel(); - return new CounterExampleUnaryFigure(model); - } -} +package de.prob.ui.ltl; + +import org.eclipse.draw2d.IFigure; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +public final class CounterExampleUnaryEditPart extends + CounterExamplePropositionEditPart { + @Override + protected IFigure createFigure() { + CounterExampleProposition model = (CounterExampleProposition) getModel(); + return new CounterExampleUnaryFigure(model); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryFigure.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryFigure.java index 814cf4b94b8d76889f1cc02c927d034b184aae77..baa87208b5763735b1ece325d0106c765f8b309b 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryFigure.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleUnaryFigure.java @@ -1,183 +1,183 @@ -package de.prob.ui.ltl; - -import java.util.Hashtable; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.Ellipse; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseMotionListener; -import org.eclipse.draw2d.Panel; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.TitleBarBorder; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.History; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; - -public final class CounterExampleUnaryFigure extends - CounterExamplePropositionFigure implements MouseMotionListener { - private Panel panel; - - protected final Hashtable<Ellipse, Integer> argumentEllipses1 = new Hashtable<Ellipse, Integer>(); - protected final Hashtable<Integer, Ellipse> argumentEllipses2 = new Hashtable<Integer, Ellipse>(); - - public CounterExampleUnaryFigure(final CounterExampleProposition model) { - super(model); - - bounds = new Rectangle(size, size, size - * (model.getValues().size() * 2 + 1), (int) (5.0 / 2 * size)); - } - - @Override - protected void drawProposition(final CounterExamplePropositionFigure parent) { - final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); - final Insets insets = getInsets(); - - if (parent != null) { - Rectangle parentBounds = parent.getBounds(); - bounds.x = parentBounds.x - insets.left; - bounds.y = parentBounds.y + parentBounds.height + size / 2; - - } else { - final List<RectangleFigure> states = counterExampleFigure - .getStates(); - - for (int i = 0; i < states.size(); i++) { - final RectangleFigure state = states.get(i); - - if (!counterExampleFigure.getChildren().contains(state)) { - state.setBounds(new Rectangle((size * 2) * (i + 1) - + insets.left, size, size, size + 6 * insets.top)); - counterExampleFigure.add(state, 0); - } - } - } - - counterExampleFigure.setConstraint(this, new Rectangle(bounds)); - - removeAll(); - - final int stateId = model.getStateId(); - - final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) - .getArgument(); - final List<Integer> positions = ((CounterExampleUnaryOperator) model) - .getHighlightedPositions().get(stateId); - final Rectangle panelBounds = new Rectangle(bounds.x - + (int) (2.0 / 5 * size), bounds.y + (int) (2.0 / 5 * size), - bounds.width, bounds.height); - - panel = drawPropositionFigure(parent, bounds, argument, positions, - argumentEllipses1, argumentEllipses2, panelBounds, stateId, - size); - } - - @Override - public void mouseDoubleClicked(final MouseEvent me) { - super.mouseDoubleClicked(me); - - int stateId = argumentEllipses1.get(me.getSource()); - Logger.assertProB("stateId >= 0", stateId >= 0); - - final CounterExample ce = ((CounterExampleFigure) getParent()) - .getModel(); - - if (ce != null) { - stateId += ce.getInitPath().size(); - - final Animator animator = Animator.getAnimator(); - final History history = animator.getHistory(); - - try { - CounterExampleHistoryHandler.showCounterExampleInAnimator(); - history.gotoPos(stateId); - } catch (ExecutionException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } catch (ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", - e); - } - } - } - - @Override - public void mousePressed(final MouseEvent me) { - if (me.button != 1) - return; - - super.mousePressed(me); - - final int stateId = argumentEllipses1.get(me.getSource()); - - final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) - .getArgument(); - - List<CounterExampleProposition> children = argument.getChildren(); - children = children.subList(1, children.size()); - setTrasparent(children); - - final CounterExamplePropositionFigure argumentFigure = getFigure(argument); - - for (Connection connection : argumentFigure.getConnections().values()) { - connection.setVisible(false); - } - - final TitleBarBorder border = (TitleBarBorder) panel.getBorder(); - - if (argument.getStateId() == stateId) { - boolean visible = !argument.isVisible(); - - if (argument.hasChildren()) { - border.setFont(visible ? boldFont : normalFont); - } - - argument.setVisible(visible); - } else { - if (argument.hasChildren()) { - border.setFont(boldFont); - } - - argument.setStateId(stateId); - argument.setVisible(true); - } - - repaint(); - } - - @Override - public void mouseEntered(final MouseEvent me) { - final Ellipse source = (Ellipse) me.getSource(); - - final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) - .getArgument(); - - if (!argument.hasChildren()) - return; - - final boolean painted = argument.isVisible(); - final int argumentStateId = argument.getStateId(); - final int stateId = argumentEllipses1.get(source); - - final Label label = new Label(); - label.setForegroundColor(foregroundColor); - - String text = "open "; - - if (stateId == argumentStateId) - text = painted ? "close " : "open "; - - label.setText("Click to " + text + argument); - source.setToolTip(label); - } -} +package de.prob.ui.ltl; + +import java.util.Hashtable; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.MouseEvent; +import org.eclipse.draw2d.MouseMotionListener; +import org.eclipse.draw2d.Panel; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.TitleBarBorder; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Rectangle; + +import de.prob.core.Animator; +import de.prob.core.domainobjects.History; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator; +import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; +import de.prob.ui.ltl.handler.CounterExampleHistoryHandler; + +public final class CounterExampleUnaryFigure extends + CounterExamplePropositionFigure implements MouseMotionListener { + private Panel panel; + + protected final Hashtable<Ellipse, Integer> argumentEllipses1 = new Hashtable<Ellipse, Integer>(); + protected final Hashtable<Integer, Ellipse> argumentEllipses2 = new Hashtable<Integer, Ellipse>(); + + public CounterExampleUnaryFigure(final CounterExampleProposition model) { + super(model); + + bounds = new Rectangle(size, size, size + * (model.getValues().size() * 2 + 1), (int) (5.0 / 2 * size)); + } + + @Override + protected void drawProposition(final CounterExamplePropositionFigure parent) { + final CounterExampleFigure counterExampleFigure = (CounterExampleFigure) getParent(); + final Insets insets = getInsets(); + + if (parent != null) { + Rectangle parentBounds = parent.getBounds(); + bounds.x = parentBounds.x - insets.left; + bounds.y = parentBounds.y + parentBounds.height + size / 2; + + } else { + final List<RectangleFigure> states = counterExampleFigure + .getStates(); + + for (int i = 0; i < states.size(); i++) { + final RectangleFigure state = states.get(i); + + if (!counterExampleFigure.getChildren().contains(state)) { + state.setBounds(new Rectangle((size * 2) * (i + 1) + + insets.left, size, size, size + 6 * insets.top)); + counterExampleFigure.add(state, 0); + } + } + } + + counterExampleFigure.setConstraint(this, new Rectangle(bounds)); + + removeAll(); + + final int stateId = model.getStateId(); + + final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) + .getArgument(); + final List<Integer> positions = ((CounterExampleUnaryOperator) model) + .getHighlightedPositions().get(stateId); + final Rectangle panelBounds = new Rectangle(bounds.x + + (int) (2.0 / 5 * size), bounds.y + (int) (2.0 / 5 * size), + bounds.width, bounds.height); + + panel = drawPropositionFigure(parent, bounds, argument, positions, + argumentEllipses1, argumentEllipses2, panelBounds, stateId, + size); + } + + @Override + public void mouseDoubleClicked(final MouseEvent me) { + super.mouseDoubleClicked(me); + + int stateId = argumentEllipses1.get(me.getSource()); + Logger.assertProB("stateId >= 0", stateId >= 0); + + final CounterExample ce = ((CounterExampleFigure) getParent()) + .getModel(); + + if (ce != null) { + stateId += ce.getInitPath().size(); + + final Animator animator = Animator.getAnimator(); + final History history = animator.getHistory(); + + try { + CounterExampleHistoryHandler.showCounterExampleInAnimator(); + history.gotoPos(stateId); + } catch (ExecutionException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } catch (ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", + e); + } + } + } + + @Override + public void mousePressed(final MouseEvent me) { + if (me.button != 1) + return; + + super.mousePressed(me); + + final int stateId = argumentEllipses1.get(me.getSource()); + + final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) + .getArgument(); + + List<CounterExampleProposition> children = argument.getChildren(); + children = children.subList(1, children.size()); + setTrasparent(children); + + final CounterExamplePropositionFigure argumentFigure = getFigure(argument); + + for (Connection connection : argumentFigure.getConnections().values()) { + connection.setVisible(false); + } + + final TitleBarBorder border = (TitleBarBorder) panel.getBorder(); + + if (argument.getStateId() == stateId) { + boolean visible = !argument.isVisible(); + + if (argument.hasChildren()) { + border.setFont(visible ? boldFont : normalFont); + } + + argument.setVisible(visible); + } else { + if (argument.hasChildren()) { + border.setFont(boldFont); + } + + argument.setStateId(stateId); + argument.setVisible(true); + } + + repaint(); + } + + @Override + public void mouseEntered(final MouseEvent me) { + final Ellipse source = (Ellipse) me.getSource(); + + final CounterExampleProposition argument = ((CounterExampleUnaryOperator) model) + .getArgument(); + + if (!argument.hasChildren()) + return; + + final boolean painted = argument.isVisible(); + final int argumentStateId = argument.getStateId(); + final int stateId = argumentEllipses1.get(source); + + final Label label = new Label(); + label.setForegroundColor(foregroundColor); + + String text = "open "; + + if (stateId == argumentStateId) + text = painted ? "close " : "open "; + + label.setText("Click to " + text + argument); + source.setToolTip(label); + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleViewPart.java b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleViewPart.java index ccc78b7ee67206ec55bb01e1f5e4db83c56bb6e1..824ceb9ee89e62007bc156bfb964c8150300edbe 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/CounterExampleViewPart.java +++ b/de.prob.ui/src/de/prob/ui/ltl/CounterExampleViewPart.java @@ -1,219 +1,219 @@ -package de.prob.ui.ltl; - -import org.eclipse.core.commands.Command; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.ParameterizedCommand; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolder2Adapter; -import org.eclipse.swt.custom.CTabFolderEvent; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -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.handlers.HandlerUtil; -import org.eclipse.ui.menus.CommandContributionItem; -import org.eclipse.ui.services.ISourceProviderService; - -import de.prob.core.domainobjects.Operation; -import de.prob.core.domainobjects.State; -import de.prob.core.domainobjects.ltl.CounterExample; -import de.prob.logging.Logger; -import de.prob.ui.StateBasedViewPart; - -/*** - * Provides a view for a counter-example - * - * @author Andriy Tolstoy - * - */ -public final class CounterExampleViewPart extends StateBasedViewPart { - private static final String ID = "de.prob.ui.ltl.CounterExampleView"; - - private static final String DATA_KEY = "tabdata"; - - public static enum ViewType { - INTERACTIVE, TREE, TABLE - }; - - private CTabFolder tabFolder; - private ViewType viewType = ViewType.INTERACTIVE; - - public static CounterExampleViewPart showDefault() { - final IWorkbenchPage workbenchPage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - CounterExampleViewPart counterExampleView = null; - try { - counterExampleView = (CounterExampleViewPart) workbenchPage - .showView(ID); - } catch (PartInitException e) { - Logger.notifyUser("Failed to show the LTL view.", e); - } - return counterExampleView; - } - - public static CounterExampleViewPart getDefault() { - final IWorkbenchPage workbenchPage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - return (CounterExampleViewPart) workbenchPage.findView(ID); - } - - @Override - protected Control createStatePartControl(Composite parent) { - tabFolder = new CTabFolder(parent, SWT.BORDER); - - tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() { - @Override - public void close(CTabFolderEvent event) { - if (tabFolder.getItemCount() == 1) - updateCounterExampleLoadedProvider(false); - } - }); - - return tabFolder; - } - - public void addCounterExample(final CounterExample counterExample) { - initializeMenuSetting(); - updateCounterExampleLoadedProvider(true); - - final Runnable runnable = new Runnable() { - @Override - public void run() { - final CTabItem tabItem = createTabItem(counterExample); - tabFolder.setSelection(tabItem); - tabFolder.update(); - } - }; - - Display.getDefault().asyncExec(runnable); - } - - private void initializeMenuSetting() { - if (tabFolder.getItemCount() == 0) { - MenuManager manager = (MenuManager) getViewSite().getActionBars() - .getMenuManager(); - - if (manager.getSize() > 0) { - if (manager.getItems()[0] instanceof MenuManager) { - manager = (MenuManager) manager.getItems()[0]; - - if (manager.getSize() > 0) - if (manager.getItems()[0] instanceof CommandContributionItem) { - CommandContributionItem item = (CommandContributionItem) manager - .getItems()[0]; - - ParameterizedCommand parameterizedCommand = item - .getCommand(); - - Command command = parameterizedCommand.getCommand(); - - try { - HandlerUtil.updateRadioState(command, - viewType.name()); - } catch (ExecutionException e) { - } - } - } - } - } - } - - public void zoomInCounterExample() { - final CounterExampleTab tab = getCurrentTab(); - if (tab != null) { - tab.zoomIn(); - } - } - - public void zoomOutCounterExample() { - final CounterExampleTab tab = getCurrentTab(); - if (tab != null) { - tab.zoomOut(); - } - } - - public void printCounterExample() { - final CounterExampleTab tab = getCurrentTab(); - if (tab != null) { - tab.printCounterExample(getTitle()); - } - } - - public void setViewType(ViewType viewType) { - this.viewType = viewType; - for (CTabItem tabItem : tabFolder.getItems()) { - final CounterExampleTab tab = getTab(tabItem); - tab.updateTopControl(viewType); - } - } - - public int getCurrentIndex() { - final CounterExampleTab tab = getCurrentTab(); - return tab != null ? tab.getCurrentIndex() : -1; - } - - @Override - protected void stateChanged(final State activeState, - final Operation operation) { - final CounterExampleTab tab = getCurrentTab(); - if (tab != null) { - tab.stateChanged(activeState, operation); - } - } - - @Override - protected void stateReset() { - super.stateReset(); - updateCounterExampleLoadedProvider(false); - } - - @Override - public void dispose() { - super.dispose(); - updateCounterExampleLoadedProvider(false); - } - - public CounterExample getCurrentCounterExample() { - final CounterExampleTab data = getCurrentTab(); - return data == null ? null : data.getCounterExample(); - } - - private void updateCounterExampleLoadedProvider(boolean enabled) { - ISourceProviderService service = (ISourceProviderService) getSite() - .getService(ISourceProviderService.class); - CounterExampleLoadedProvider provider = (CounterExampleLoadedProvider) service - .getSourceProvider(CounterExampleLoadedProvider.SERVICE); - - provider.setEnabled(enabled); - } - - private CTabItem createTabItem(final CounterExample counterExample) { - final CounterExampleTab ceTab = new CounterExampleTab(tabFolder, - counterExample); - final CTabItem tabItem = ceTab.getTabitem(); - tabItem.setData(DATA_KEY, ceTab); - ceTab.updateTopControl(viewType); - - return tabItem; - } - - private CounterExampleTab getCurrentTab() { - final CounterExampleTab tab; - if (tabFolder != null) { - final CTabItem selection = tabFolder.getSelection(); - tab = getTab(selection); - } else { - tab = null; - } - return tab; - } - - private CounterExampleTab getTab(final CTabItem item) { - return item == null ? null : (CounterExampleTab) item.getData(DATA_KEY); - } +package de.prob.ui.ltl; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabFolder2Adapter; +import org.eclipse.swt.custom.CTabFolderEvent; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +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.handlers.HandlerUtil; +import org.eclipse.ui.menus.CommandContributionItem; +import org.eclipse.ui.services.ISourceProviderService; + +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.State; +import de.prob.core.domainobjects.ltl.CounterExample; +import de.prob.logging.Logger; +import de.prob.ui.StateBasedViewPart; + +/*** + * Provides a view for a counter-example + * + * @author Andriy Tolstoy + * + */ +public final class CounterExampleViewPart extends StateBasedViewPart { + private static final String ID = "de.prob.ui.ltl.CounterExampleView"; + + private static final String DATA_KEY = "tabdata"; + + public static enum ViewType { + INTERACTIVE, TREE, TABLE + }; + + private CTabFolder tabFolder; + private ViewType viewType = ViewType.INTERACTIVE; + + public static CounterExampleViewPart showDefault() { + final IWorkbenchPage workbenchPage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + CounterExampleViewPart counterExampleView = null; + try { + counterExampleView = (CounterExampleViewPart) workbenchPage + .showView(ID); + } catch (PartInitException e) { + Logger.notifyUser("Failed to show the LTL view.", e); + } + return counterExampleView; + } + + public static CounterExampleViewPart getDefault() { + final IWorkbenchPage workbenchPage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + return (CounterExampleViewPart) workbenchPage.findView(ID); + } + + @Override + protected Control createStatePartControl(Composite parent) { + tabFolder = new CTabFolder(parent, SWT.BORDER); + + tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() { + @Override + public void close(CTabFolderEvent event) { + if (tabFolder.getItemCount() == 1) + updateCounterExampleLoadedProvider(false); + } + }); + + return tabFolder; + } + + public void addCounterExample(final CounterExample counterExample) { + initializeMenuSetting(); + updateCounterExampleLoadedProvider(true); + + final Runnable runnable = new Runnable() { + @Override + public void run() { + final CTabItem tabItem = createTabItem(counterExample); + tabFolder.setSelection(tabItem); + tabFolder.update(); + } + }; + + Display.getDefault().asyncExec(runnable); + } + + private void initializeMenuSetting() { + if (tabFolder.getItemCount() == 0) { + MenuManager manager = (MenuManager) getViewSite().getActionBars() + .getMenuManager(); + + if (manager.getSize() > 0) { + if (manager.getItems()[0] instanceof MenuManager) { + manager = (MenuManager) manager.getItems()[0]; + + if (manager.getSize() > 0) + if (manager.getItems()[0] instanceof CommandContributionItem) { + CommandContributionItem item = (CommandContributionItem) manager + .getItems()[0]; + + ParameterizedCommand parameterizedCommand = item + .getCommand(); + + Command command = parameterizedCommand.getCommand(); + + try { + HandlerUtil.updateRadioState(command, + viewType.name()); + } catch (ExecutionException e) { + } + } + } + } + } + } + + public void zoomInCounterExample() { + final CounterExampleTab tab = getCurrentTab(); + if (tab != null) { + tab.zoomIn(); + } + } + + public void zoomOutCounterExample() { + final CounterExampleTab tab = getCurrentTab(); + if (tab != null) { + tab.zoomOut(); + } + } + + public void printCounterExample() { + final CounterExampleTab tab = getCurrentTab(); + if (tab != null) { + tab.printCounterExample(getTitle()); + } + } + + public void setViewType(ViewType viewType) { + this.viewType = viewType; + for (CTabItem tabItem : tabFolder.getItems()) { + final CounterExampleTab tab = getTab(tabItem); + tab.updateTopControl(viewType); + } + } + + public int getCurrentIndex() { + final CounterExampleTab tab = getCurrentTab(); + return tab != null ? tab.getCurrentIndex() : -1; + } + + @Override + protected void stateChanged(final State activeState, + final Operation operation) { + final CounterExampleTab tab = getCurrentTab(); + if (tab != null) { + tab.stateChanged(activeState, operation); + } + } + + @Override + protected void stateReset() { + super.stateReset(); + updateCounterExampleLoadedProvider(false); + } + + @Override + public void dispose() { + super.dispose(); + updateCounterExampleLoadedProvider(false); + } + + public CounterExample getCurrentCounterExample() { + final CounterExampleTab data = getCurrentTab(); + return data == null ? null : data.getCounterExample(); + } + + private void updateCounterExampleLoadedProvider(boolean enabled) { + ISourceProviderService service = (ISourceProviderService) getSite() + .getService(ISourceProviderService.class); + CounterExampleLoadedProvider provider = (CounterExampleLoadedProvider) service + .getSourceProvider(CounterExampleLoadedProvider.SERVICE); + + provider.setEnabled(enabled); + } + + private CTabItem createTabItem(final CounterExample counterExample) { + final CounterExampleTab ceTab = new CounterExampleTab(tabFolder, + counterExample); + final CTabItem tabItem = ceTab.getTabitem(); + tabItem.setData(DATA_KEY, ceTab); + ceTab.updateTopControl(viewType); + + return tabItem; + } + + private CounterExampleTab getCurrentTab() { + final CounterExampleTab tab; + if (tabFolder != null) { + final CTabItem selection = tabFolder.getSelection(); + tab = getTab(selection); + } else { + tab = null; + } + return tab; + } + + private CounterExampleTab getTab(final CTabItem item) { + return item == null ? null : (CounterExampleTab) item.getData(DATA_KEY); + } } \ No newline at end of file diff --git a/de.prob.ui/src/de/prob/ui/ltl/LtlMultiCheckingFinishedListener.java b/de.prob.ui/src/de/prob/ui/ltl/LtlMultiCheckingFinishedListener.java index 4ebbef8bf33dae8fd285e4a95827b0f51b558da5..a922863a3d8f1d9670a8b622ded52bd5b5133536 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/LtlMultiCheckingFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/ltl/LtlMultiCheckingFinishedListener.java @@ -1,86 +1,86 @@ -package de.prob.ui.ltl; - -import java.util.List; - -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; - -import de.prob.core.command.LtlCheckingCommand.Result; -import de.prob.prolog.term.ListPrologTerm; - -public final class LtlMultiCheckingFinishedListener extends - LtlCheckingFinishedListener { - private final List<String> formulas; - - private int formulaCount = 0; - private boolean counterExampleFound = false; - - public LtlMultiCheckingFinishedListener(final Shell shell, - List<String> formulas) { - super(shell); - this.formulas = formulas; - } - - @Override - public synchronized void done(final IJobChangeEvent event) { - Job job = event.getJob(); - - if (job instanceof LtlCheckingJob) { - LtlCheckingJob ltlJob = (LtlCheckingJob) job; - - if (!ltlJob.isAnErrorOccurred()) { - final Result result = ltlJob.getModelCheckingResult(); - formulaCount += 1; - - switch (result.getStatus()) { - case counterexample: - counterExampleFound = true; - - final Runnable runnable = new Runnable() { - @Override - public void run() { - ListPrologTerm counterExample = result - .getCounterexample(); - if (counterExample != null) { - showCounterexampleInView(result); - } - } - }; - - shell.getDisplay().asyncExec(runnable); - - break; - } - - if (formulaCount == formulas.size()) { - final Runnable runnable = new Runnable() { - @Override - public void run() { - final String message; - final String title; - final int displayType; - - if (counterExampleFound) { - title = LtlStrings.ltlResultCounterexampleTitle; - message = LtlStrings.ltlMultiResultCounterexampleMessage; - displayType = MessageDialog.ERROR; - } else { - title = LtlStrings.ltlResultOkTitle; - message = LtlStrings.ltlMultiResultOkMessage; - displayType = MessageDialog.INFORMATION; - } - - MessageDialog.open(displayType, shell, title, - message, SWT.NONE); - } - }; - - shell.getDisplay().asyncExec(runnable); - } - } - } - } +package de.prob.ui.ltl; + +import java.util.List; + +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import de.prob.core.command.LtlCheckingCommand.Result; +import de.prob.prolog.term.ListPrologTerm; + +public final class LtlMultiCheckingFinishedListener extends + LtlCheckingFinishedListener { + private final List<String> formulas; + + private int formulaCount = 0; + private boolean counterExampleFound = false; + + public LtlMultiCheckingFinishedListener(final Shell shell, + List<String> formulas) { + super(shell); + this.formulas = formulas; + } + + @Override + public synchronized void done(final IJobChangeEvent event) { + Job job = event.getJob(); + + if (job instanceof LtlCheckingJob) { + LtlCheckingJob ltlJob = (LtlCheckingJob) job; + + if (!ltlJob.isAnErrorOccurred()) { + final Result result = ltlJob.getModelCheckingResult(); + formulaCount += 1; + + switch (result.getStatus()) { + case counterexample: + counterExampleFound = true; + + final Runnable runnable = new Runnable() { + @Override + public void run() { + ListPrologTerm counterExample = result + .getCounterexample(); + if (counterExample != null) { + showCounterexampleInView(result); + } + } + }; + + shell.getDisplay().asyncExec(runnable); + + break; + } + + if (formulaCount == formulas.size()) { + final Runnable runnable = new Runnable() { + @Override + public void run() { + final String message; + final String title; + final int displayType; + + if (counterExampleFound) { + title = LtlStrings.ltlResultCounterexampleTitle; + message = LtlStrings.ltlMultiResultCounterexampleMessage; + displayType = MessageDialog.ERROR; + } else { + title = LtlStrings.ltlResultOkTitle; + message = LtlStrings.ltlMultiResultOkMessage; + displayType = MessageDialog.INFORMATION; + } + + MessageDialog.open(displayType, shell, title, + message, SWT.NONE); + } + }; + + shell.getDisplay().asyncExec(runnable); + } + } + } + } } \ No newline at end of file diff --git a/de.prob.ui/src/de/prob/ui/ltl/LtlStrings.properties b/de.prob.ui/src/de/prob/ui/ltl/LtlStrings.properties index ea34995e9d238013a9a785f84fc2a443e7d702eb..bee6c416eef80dc7cba829f2ccc85d9de0e9fce2 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/LtlStrings.properties +++ b/de.prob.ui/src/de/prob/ui/ltl/LtlStrings.properties @@ -5,12 +5,16 @@ ltlHelpText=About LTL Checking\n\nLTL Syntax:\n\ -use e(op) to check if an operation op is enabled\n\ -use sink to check if no operation is enabled that leads to another state\n\ -use brackets to check what is the next operation, e.g. [reset] => X{db={}}\n\ --Past-LTL is supported: Y, H, O, S, T are the duals to X, G, F, U, R +-Past-LTL is supported: Y, H, O, S, T are the duals to X, G, F, U, R\n\ +-Give fairness constraints by means of implication: fair => f,\n\ +-where "fair" are the fairness constraints and "f" is LTL-formula to be checked,\n\ +-use WF(-) or SF(-) to set action-based weak or strong fairness constraints,\n\ +-use WEF or SEF to search for paths that are weakly or strongly fair w.r.t. all transitions. ltlResultIncompleteTitle=Modelchecking not completed -ltlResultIncompleteMessage=No counterexample has been found, but not all possible nodes have been visited (Due to animation parameter restrictions). +ltlResultIncompleteMessage=No counterexample has been found, but not all possible states have been visited (Due to animation parameter restrictions). ltlResultOkTitle=Modelchecking successfully finished -ltlResultOkMessage=No counterexample has been found, all nodes have been visited. +ltlResultOkMessage=No counterexample has been found, all states have been visited. ltlResultCounterexampleTitle=Counterexample found ltlResultCounterexampleMessage=A counterexample has been found. It will be shown in the LTL view. ltlResultNoStartTitle=No initialisation found diff --git a/de.prob.ui/src/de/prob/ui/ltl/TreeColumnPropositionLabelProvider.java b/de.prob.ui/src/de/prob/ui/ltl/TreeColumnPropositionLabelProvider.java index e0fb275662e44b2cfbfc2b71fd0da746eb8f8fe6..bd616684df282f5100ddb1a61c707dfd2ecfbf01 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/TreeColumnPropositionLabelProvider.java +++ b/de.prob.ui/src/de/prob/ui/ltl/TreeColumnPropositionLabelProvider.java @@ -1,26 +1,26 @@ -package de.prob.ui.ltl; - -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.ViewerCell; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; - -/*** - * Provides a label provider for a counter-example proposition column - * - * @author Andriy Tolstoy - * - */ -public final class TreeColumnPropositionLabelProvider extends CellLabelProvider { - @Override - public void update(ViewerCell cell) { - if (cell != null) { - final CounterExampleProposition proposition = (CounterExampleProposition) cell - .getElement(); - - if (proposition != null) { - cell.setText(proposition.toString()); - } - } - } -} +package de.prob.ui.ltl; + +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ViewerCell; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; + +/*** + * Provides a label provider for a counter-example proposition column + * + * @author Andriy Tolstoy + * + */ +public final class TreeColumnPropositionLabelProvider extends CellLabelProvider { + @Override + public void update(ViewerCell cell) { + if (cell != null) { + final CounterExampleProposition proposition = (CounterExampleProposition) cell + .getElement(); + + if (proposition != null) { + cell.setText(proposition.toString()); + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/TreeColumnValueLabelProvider.java b/de.prob.ui/src/de/prob/ui/ltl/TreeColumnValueLabelProvider.java index abdc58d8eb5c5b943366526dcf5ae2e0731e68ea..70f1d3207419e5f9d696be0751f71f9078a3ccb6 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/TreeColumnValueLabelProvider.java +++ b/de.prob.ui/src/de/prob/ui/ltl/TreeColumnValueLabelProvider.java @@ -1,58 +1,58 @@ -package de.prob.ui.ltl; - -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; - -import de.prob.core.domainobjects.ltl.CounterExampleProposition; -import de.prob.core.domainobjects.ltl.CounterExampleState; -import de.prob.core.domainobjects.ltl.CounterExampleValueType; - -/*** - * Provides a label provider for a counter-example value column - * - * @author Andriy Tolstoy - * - */ -public final class TreeColumnValueLabelProvider extends CellLabelProvider { - private final CounterExampleState state; - private final Font normal = new Font(Display.getDefault(), "Arial", 10, - SWT.NORMAL); - private final Font bold = new Font(Display.getDefault(), "Arial", 10, - SWT.BOLD); - - public TreeColumnValueLabelProvider(CounterExampleState state) { - super(); - this.state = state; - } - - @Override - public void update(ViewerCell cell) { - if (cell != null) { - final CounterExampleProposition proposition = (CounterExampleProposition) cell - .getElement(); - - if (proposition != null) { - final int index = state.getIndex(); - - final CounterExampleValueType value = proposition.getValues() - .get(index); - cell.setText(value.toString()); - - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) { - final int currentIndex = counterExampleView - .getCurrentIndex(); - - if (index != currentIndex) - cell.setFont(normal); - else - cell.setFont(bold); - } - } - } - } -} +package de.prob.ui.ltl; + +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Display; + +import de.prob.core.domainobjects.ltl.CounterExampleProposition; +import de.prob.core.domainobjects.ltl.CounterExampleState; +import de.prob.core.domainobjects.ltl.CounterExampleValueType; + +/*** + * Provides a label provider for a counter-example value column + * + * @author Andriy Tolstoy + * + */ +public final class TreeColumnValueLabelProvider extends CellLabelProvider { + private final CounterExampleState state; + private final Font normal = new Font(Display.getDefault(), "Arial", 10, + SWT.NORMAL); + private final Font bold = new Font(Display.getDefault(), "Arial", 10, + SWT.BOLD); + + public TreeColumnValueLabelProvider(CounterExampleState state) { + super(); + this.state = state; + } + + @Override + public void update(ViewerCell cell) { + if (cell != null) { + final CounterExampleProposition proposition = (CounterExampleProposition) cell + .getElement(); + + if (proposition != null) { + final int index = state.getIndex(); + + final CounterExampleValueType value = proposition.getValues() + .get(index); + cell.setText(value.toString()); + + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) { + final int currentIndex = counterExampleView + .getCurrentIndex(); + + if (index != currentIndex) + cell.setFont(normal); + else + cell.setFont(bold); + } + } + } + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExamplePrintHandler.java b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExamplePrintHandler.java index 84c71012c805c044b3703679c249600f2b38d641..2bbb35f21a6522456f65c44b8dc87122590a56b0 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExamplePrintHandler.java +++ b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExamplePrintHandler.java @@ -1,21 +1,21 @@ -package de.prob.ui.ltl.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; - -import de.prob.ui.ltl.CounterExampleViewPart; - -public class CounterExamplePrintHandler extends AbstractHandler implements - IHandler { - @Override - public Object execute(final ExecutionEvent event) throws ExecutionException { - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) { - counterExampleView.printCounterExample(); - } - return null; - } -} +package de.prob.ui.ltl.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import de.prob.ui.ltl.CounterExampleViewPart; + +public class CounterExamplePrintHandler extends AbstractHandler implements + IHandler { + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) { + counterExampleView.printCounterExample(); + } + return null; + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleViewMenuHandler.java b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleViewMenuHandler.java index 1fe417817482af12885ecf0fe817b257f64d4a82..2d863cafc7e36e5570c69f7a03fb988011efda9b 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleViewMenuHandler.java +++ b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleViewMenuHandler.java @@ -1,40 +1,40 @@ -package de.prob.ui.ltl.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.handlers.RadioState; - -import de.prob.ui.ltl.CounterExampleViewPart; -import de.prob.ui.ltl.CounterExampleViewPart.ViewType; - -/*** - * Provides a menu handler for a menu in a counter-example view - * - * @author Andriy Tolstoy - * - */ - -public final class CounterExampleViewMenuHandler extends AbstractHandler - implements IHandler { - - @Override - public Object execute(final ExecutionEvent event) throws ExecutionException { - if (HandlerUtil.matchesRadioState(event)) - return null; - - final String viewTypeAsString = event - .getParameter(RadioState.PARAMETER_ID); - final ViewType viewType = ViewType.valueOf(viewTypeAsString); - HandlerUtil.updateRadioState(event.getCommand(), viewTypeAsString); - - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) - counterExampleView.setViewType(viewType); - - return null; - } -} +package de.prob.ui.ltl.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.handlers.RadioState; + +import de.prob.ui.ltl.CounterExampleViewPart; +import de.prob.ui.ltl.CounterExampleViewPart.ViewType; + +/*** + * Provides a menu handler for a menu in a counter-example view + * + * @author Andriy Tolstoy + * + */ + +public final class CounterExampleViewMenuHandler extends AbstractHandler + implements IHandler { + + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + if (HandlerUtil.matchesRadioState(event)) + return null; + + final String viewTypeAsString = event + .getParameter(RadioState.PARAMETER_ID); + final ViewType viewType = ViewType.valueOf(viewTypeAsString); + HandlerUtil.updateRadioState(event.getCommand(), viewTypeAsString); + + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) + counterExampleView.setViewType(viewType); + + return null; + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomInHandler.java b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomInHandler.java index 2195ede6a1cec7485cf91a61e514dd2259fa3eda..f7ce2938ac4524732a1eef4287beba15f6d330f4 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomInHandler.java +++ b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomInHandler.java @@ -1,22 +1,22 @@ -package de.prob.ui.ltl.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; - -import de.prob.ui.ltl.CounterExampleViewPart; - -public class CounterExampleZoomInHandler extends AbstractHandler implements - IHandler { - @Override - public Object execute(final ExecutionEvent event) throws ExecutionException { - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) { - counterExampleView.zoomInCounterExample(); - } - return null; - - } -} +package de.prob.ui.ltl.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import de.prob.ui.ltl.CounterExampleViewPart; + +public class CounterExampleZoomInHandler extends AbstractHandler implements + IHandler { + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) { + counterExampleView.zoomInCounterExample(); + } + return null; + + } +} diff --git a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomOutHandler.java b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomOutHandler.java index a665b2320ad24c400c4798679a7c02af8aabfcba..09c72b015fea22ffb186733235de9405a955b8a2 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomOutHandler.java +++ b/de.prob.ui/src/de/prob/ui/ltl/handler/CounterExampleZoomOutHandler.java @@ -1,21 +1,21 @@ -package de.prob.ui.ltl.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; - -import de.prob.ui.ltl.CounterExampleViewPart; - -public class CounterExampleZoomOutHandler extends AbstractHandler implements - IHandler { - @Override - public Object execute(final ExecutionEvent event) throws ExecutionException { - final CounterExampleViewPart counterExampleView = CounterExampleViewPart - .getDefault(); - if (counterExampleView != null) { - counterExampleView.zoomOutCounterExample(); - } - return null; - } -} +package de.prob.ui.ltl.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import de.prob.ui.ltl.CounterExampleViewPart; + +public class CounterExampleZoomOutHandler extends AbstractHandler implements + IHandler { + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + final CounterExampleViewPart counterExampleView = CounterExampleViewPart + .getDefault(); + if (counterExampleView != null) { + counterExampleView.zoomOutCounterExample(); + } + return null; + } +} diff --git a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionDialogHandler.java b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionDialogHandler.java index 899c26b7e23b86465c44df14367b42719b3592ad..ed4fe2bc1fa8c61882413746b5de79cd8a3c811b 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionDialogHandler.java +++ b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionDialogHandler.java @@ -30,7 +30,7 @@ public class CustomPreconditionDialogHandler extends AbstractHandler implements if (filtered.size() != 1) { Logger.notifyUser(filtered.size() - + " operations selected. An additional Guard can only be added to a single operation"); + + " events selected. An additional Guard Constraint can only be added to a single event"); return null; } diff --git a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java index 43f4062017240e615f21e48433d1faa5e3379add..38f3b9aff3b4a8afad44cd1b63b314503d3f810e 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java +++ b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java @@ -6,14 +6,20 @@ package de.prob.ui.operationview; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.swt.widgets.Shell; -import de.be4.classicalb.core.parser.exceptions.BException; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.prob.core.Animator; import de.prob.core.command.*; import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.OperationInfo; import de.prob.exceptions.ProBException; +import de.prob.logging.Logger; import de.prob.unicode.UnicodeTranslator; public class CustomPreconditionInputDialog extends InputDialog { @@ -21,29 +27,44 @@ public class CustomPreconditionInputDialog extends InputDialog { private final Animator animator; private final Operation op; - public CustomPreconditionInputDialog(final Shell parentShell, Operation op) { - super(parentShell, "Execute with additional Guard", getMenuText(op), - "", new EventBInputValidator()); + public CustomPreconditionInputDialog(final Shell parentShell, Operation op, Animator a) { + super(parentShell, "Execute with additional Guard Constraint", getMenuText(op,a), + getDefaultPredicate(op,a), new EventBInputValidator()); this.op = op; - animator = Animator.getAnimator(); + animator = a; } - private static String getMenuText(Operation op) { + private static String getMenuText(Operation op, Animator animator) { StringBuffer sb = new StringBuffer(); - sb.append("Enter Guard to be added to the Event \""); + sb.append("Enter Guard Constraint to be added to the Event \""); sb.append(op.getName()); sb.append("\" before execution."); + List<String> params = getOperationParams(op,animator); + if(params.size()>0) { + sb.append("\nParameters are:"); + for (String arg : params) { + sb.append(" "); + sb.append(arg); + } + } - // sb.append("\nYou may use the parameters: "); - - // List<String> arguments = op.getArguments(); - // for (int i = 0; i < arguments.size() - 1; i++) { - // sb.append(arguments.get(i)); - // sb.append("' "); - // } - // sb.append(arguments.get(arguments.size() - 1)); + return sb.toString(); + } + private static String getDefaultPredicate(Operation op, Animator animator) { + // get a predicate with all parameters and filling in values from selected operation in view + StringBuffer sb = new StringBuffer(); + List<String> params = getOperationParams(op,animator); + List<String> vals = op.getArguments(); + int sze = Math.min(params.size(),vals.size()); + for (int i = 0; i < sze; i++) { + sb.append(params.get(i)); + sb.append(" = "); + sb.append(vals.get(i)); + if(i!=sze-1) { sb.append(" & ");} + } return sb.toString(); + // TODO: ideally we would want to store the predicate provided by the user, in case the execution fails } private Operation getCustomOperation() { @@ -52,12 +73,15 @@ public class CustomPreconditionInputDialog extends InputDialog { animator, op.getSource(), Operation.getInternalName(op.getName()), UnicodeTranslator.toUnicode(getValue())); - - ExecuteOperationCommand.executeOperation(animator, customOp); + if (customOp==null) { + Logger.notifyUser("Could not execute the event "+ op.getName() + " with the additional predicate provided!"); + } else { + ExecuteOperationCommand.executeOperation(animator, customOp); + } } catch (ProBException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (BException e) { + } catch (BCompoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -66,12 +90,39 @@ public class CustomPreconditionInputDialog extends InputDialog { } public static Operation getOperation(Operation op) { + CustomPreconditionInputDialog osd = new CustomPreconditionInputDialog( - new Shell(), op); + new Shell(), op, Animator.getAnimator()); if (osd.open() == InputDialog.OK) return osd.getCustomOperation(); else return null; } + + // copy from Paramter OperationTableViewer + private static List<String> getOperationParams(final Operation op, Animator animator) { + Collection<OperationInfo> infos = null; + try { + infos = GetOperationNamesCommand.getNames(animator); + } catch (ProBException e) { + e.notifyUserOnce(); + } + final OperationInfo params = infos == null ? null : OperationInfo + .getParams(op.getName(), infos); + final List<String> result; + if (params != null) { + result = params.getParameters(); + } else { + // If we cannot see the parameter names, we just use the operation's + // number of arguments and use empty titles + final int numArgs = op.getArguments().size(); + result = new ArrayList<String>(numArgs); + for (int i = 0; i < numArgs; i++) { + result.add(""); + } + } + return result; + } + } diff --git a/de.prob.ui/src/de/prob/ui/operationview/ExecuteEventHandler.java b/de.prob.ui/src/de/prob/ui/operationview/ExecuteEventHandler.java index 8653bb42aab36ae1922c95fa9d96c5afef5f052f..e958df33d6d2cd2c16f406b7b7c81db8c99bd18b 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/ExecuteEventHandler.java +++ b/de.prob.ui/src/de/prob/ui/operationview/ExecuteEventHandler.java @@ -39,7 +39,7 @@ public class ExecuteEventHandler extends AbstractHandler implements IHandler { } catch (ProBException e) { e.notifyUserOnce(); throw new ExecutionException( - "executing the operation failed", e); + "executing the event failed", e); } } } diff --git a/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java b/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java index 426a67f11bd91604c95eb1a98c9d91424d27bfe8..eadac737afb48d660c7d679944c0d82211792c63 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java +++ b/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java @@ -14,7 +14,7 @@ import org.eventb.core.ast.IParseResult; import org.eventb.core.ast.Predicate; import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog; -import de.be4.classicalb.core.parser.exceptions.BException; +import de.be4.classicalb.core.parser.exceptions.BCompoundException; import de.prob.core.Animator; import de.prob.core.ProblemHandler; import de.prob.core.command.CommandException; @@ -64,9 +64,9 @@ public final class GetOperationByPredicateCommand2 implements try { parsedEvalElement = PredicateEvalElement.fromRodin(parsedPredicate); - } catch (BException e) { + } catch (BCompoundException e) { String message = "Fatal error when trying to parse " + predicate - + ". Execution of operation " + name + " aborted."; + + ". Execution of event " + name + " aborted."; ProblemHandler.raiseCommandException(message); parsedEvalElement = null; } finally { @@ -79,7 +79,7 @@ public final class GetOperationByPredicateCommand2 implements */ public static Operation getOperation(final Animator a, final String stateId, final String name, final String predicate) - throws ProBException, BException { + throws ProBException, BCompoundException { List<Operation> operations = getOperations(a, stateId, name, predicate, 1); @@ -104,14 +104,14 @@ public final class GetOperationByPredicateCommand2 implements * @param nrOfSolutions * - maximum number of solutions * @return an Operation or null - * @throws BException + * @throws BCompoundException * - if the B predicate contains errors * @throws ProBException * - if something terrible happens ;-) */ public static List<Operation> getOperations(final Animator a, final String stateId, final String name, final String predicate, - final int nrOfSolutions) throws ProBException, BException { + final int nrOfSolutions) throws ProBException, BCompoundException { GetOperationByPredicateCommand2 executeOperationCommand = new GetOperationByPredicateCommand2( stateId, name, predicate, nrOfSolutions); diff --git a/de.prob.ui/src/de/prob/ui/operationview/HistoryBackHandler.java b/de.prob.ui/src/de/prob/ui/operationview/HistoryBackHandler.java index 561434f694a82c6dbb5fa0f34038e07c6c1a286d..a01908b73c42468496bbafc5295c4c9c3ea4ecf8 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/HistoryBackHandler.java +++ b/de.prob.ui/src/de/prob/ui/operationview/HistoryBackHandler.java @@ -18,17 +18,16 @@ public class HistoryBackHandler extends AbstractHandler implements IHandler { Logger.assertProB("history != null", history != null); int pos = history.getCurrentPosition() - 1; try { - pos = Integer - .parseInt(event.getParameter("de.prob.ui.history.pos")); + pos = Integer.parseInt(event.getParameter("de.prob.ui.history.pos")); } catch (NumberFormatException e) { // one step back } - Logger.assertProB("pos >= 0", pos >= 0); - try { - history.gotoPos(pos); - } catch (ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", e); - } + if (pos >= 0) + try { + history.gotoPos(pos); + } catch (ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", e); + } return null; } } diff --git a/de.prob.ui/src/de/prob/ui/operationview/HistoryForwardHandler.java b/de.prob.ui/src/de/prob/ui/operationview/HistoryForwardHandler.java index 6400e4526a019b86446d5f236c0e8a074110e0b2..04d6cf7cbd03575b3c18b04dc3f69bb1a3e23b48 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/HistoryForwardHandler.java +++ b/de.prob.ui/src/de/prob/ui/operationview/HistoryForwardHandler.java @@ -17,17 +17,16 @@ public class HistoryForwardHandler extends AbstractHandler implements IHandler { Logger.assertProB("history != null", history != null); int pos = history.getCurrentPosition() + 1; try { - pos = Integer - .parseInt(event.getParameter("de.prob.ui.history.pos")); + pos = Integer.parseInt(event.getParameter("de.prob.ui.history.pos")); } catch (NumberFormatException e) { // one step back } - Logger.assertProB("pos < last position", pos < history.size()); - try { - history.gotoPos(pos); - } catch (ProBException e) { - Logger.notifyUser("Internal Error. Please submit a bugreport", e); - } + if (pos < history.size()) + try { + history.gotoPos(pos); + } catch (ProBException e) { + Logger.notifyUser("Internal Error. Please submit a bugreport", e); + } return null; } diff --git a/de.prob.ui/src/de/prob/ui/operationview/OperationSelectionDialog.java b/de.prob.ui/src/de/prob/ui/operationview/OperationSelectionDialog.java index be0ad8ced076086914ab306988239c4f85f14226..a3ec5a04d18db325a37b327372eb66882495566b 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/OperationSelectionDialog.java +++ b/de.prob.ui/src/de/prob/ui/operationview/OperationSelectionDialog.java @@ -511,6 +511,7 @@ public class OperationSelectionDialog extends TrayDialog { else return argument; } else + // TODO: obtain non-deterministically assigned variables and display them return "Non-deterministic choice #" + entry.getPosition(); } } diff --git a/de.prob.ui/src/de/prob/ui/operationview/OperationTableViewer.java b/de.prob.ui/src/de/prob/ui/operationview/OperationTableViewer.java index 0bf727c251f7d4a96dd5d5ab16eef7a49deef6b4..b750c02d325d7c7db056ceaf73a4fc6951a31351 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/OperationTableViewer.java +++ b/de.prob.ui/src/de/prob/ui/operationview/OperationTableViewer.java @@ -1,21 +1,37 @@ package de.prob.ui.operationview; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Random; -import org.eclipse.core.commands.*; +import org.eclipse.core.commands.Command; import org.eclipse.core.commands.State; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.IHandlerService; -import de.prob.core.*; -import de.prob.core.command.*; -import de.prob.core.domainobjects.*; +import de.prob.core.Animator; +import de.prob.core.LimitedLogger; +import de.prob.core.command.ExecuteOperationCommand; +import de.prob.core.command.GetOperationNamesCommand; +import de.prob.core.domainobjects.Operation; +import de.prob.core.domainobjects.OperationInfo; import de.prob.exceptions.ProBException; import de.prob.logging.Logger; @@ -39,11 +55,14 @@ public class OperationTableViewer { return true; } }; + private TableColumnLayout layout; private OperationTableViewer(final Composite parent, final int style) { parent.addDisposeListener(new TableDisposedListener()); viewer = new TableViewer(parent, style); - createColumns(); + + createColumns(parent); + viewer.setContentProvider(new OperationsContentProvider(operationNames)); viewer.setLabelProvider(new OperationsLabelProvider(this)); viewer.addDoubleClickListener(new OTVDoubleClickListener()); @@ -69,7 +88,10 @@ public class OperationTableViewer { packTableColumns(); } - private void createColumns() { + private void createColumns(Composite parent) { + layout = new TableColumnLayout(); + parent.setLayout(layout); + TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE); column1.getColumn().setText("Event"); column1.getColumn().setResizable(true); @@ -79,15 +101,19 @@ public class OperationTableViewer { column2.getColumn().setText("Parameter(s)"); column2.getColumn().setResizable(true); column2.getColumn().pack(); + + layout.setColumnData(column1.getColumn(), new ColumnWeightData(0, + column1.getColumn().getWidth())); + layout.setColumnData(column2.getColumn(), new ColumnWeightData(100, + column2.getColumn().getWidth())); } /** * Recalculate size of all columns */ private void packTableColumns() { - for (TableColumn column : viewer.getTable().getColumns()) { - column.pack(); - } + // only pack the first column, the second one extends automatically + viewer.getTable().getColumns()[0].pack(); } /** diff --git a/de.prob.ui/src/de/prob/ui/operationview/OperationsLabelProvider.java b/de.prob.ui/src/de/prob/ui/operationview/OperationsLabelProvider.java index 30bfb2b9a96b19ffbb975feecf3aa105a0e3cf19..82942854d1035be554da599e02b5a42a46eb0360 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/OperationsLabelProvider.java +++ b/de.prob.ui/src/de/prob/ui/operationview/OperationsLabelProvider.java @@ -41,6 +41,7 @@ class OperationsLabelProvider extends LabelProvider implements // character code for "times" (similar to the letter x) private static final char TIMES = 215; + @Override public Image getColumnImage(final Object element, final int columnIndex) { if (columnIndex == 0) { if (element instanceof String) { @@ -58,6 +59,7 @@ class OperationsLabelProvider extends LabelProvider implements return null; } + @Override @SuppressWarnings("unchecked") public String getColumnText(final Object element, final int columnIndex) { @@ -90,7 +92,8 @@ class OperationsLabelProvider extends LabelProvider implements List<String> args = op.getArguments(); int columnWidth = this.operationTableViewer.getViewer() .getTable().getColumn(columnIndex).getWidth(); - return OperationTableViewer.convertParamsToString(10, + return OperationTableViewer.convertParamsToString( + columnWidth / 6 / Math.max(args.size(), 1), columnWidth / 6, args); } diff --git a/de.prob.ui/src/de/prob/ui/operationview/ParameterMenu.java b/de.prob.ui/src/de/prob/ui/operationview/ParameterMenu.java index a4b97d45e3904b08903ea35221fef6fa3a1b7add..41b40445016ec898477cb964152611786212b906 100644 --- a/de.prob.ui/src/de/prob/ui/operationview/ParameterMenu.java +++ b/de.prob.ui/src/de/prob/ui/operationview/ParameterMenu.java @@ -1,9 +1,13 @@ package de.prob.ui.operationview; -import java.util.*; +import java.util.HashMap; +import java.util.List; import org.eclipse.swt.SWT; -import org.eclipse.ui.menus.*; +import org.eclipse.ui.menus.CommandContributionItem; +import org.eclipse.ui.menus.CommandContributionItemParameter; +import org.eclipse.ui.menus.ExtensionContributionFactory; +import org.eclipse.ui.menus.IContributionRoot; import org.eclipse.ui.services.IServiceLocator; import de.prob.core.domainobjects.Operation; @@ -27,11 +31,14 @@ public class ParameterMenu extends ExtensionContributionFactory { nondetcounter = 0; - for (Operation operation : operations) { - long id = operation.getId(); - additions.addContributionItem( - createEntry(serviceLocator, operation, id), null); + if (operations.size()<=10) { + // if number of operations small: show enabled operations first + for (Operation operation : operations) { + long id = operation.getId(); + additions.addContributionItem( + createEntry(serviceLocator, operation, id), null); + } } CommandContributionItemParameter contributionParameters = new CommandContributionItemParameter( @@ -45,11 +52,22 @@ public class ParameterMenu extends ExtensionContributionFactory { CommandContributionItemParameter contributionCustomGuard = new CommandContributionItemParameter( serviceLocator, "", "de.prob.ui.show_custom_precondition_dialog", SWT.PUSH); - contributionCustomGuard.label = "Execute with additional Guard ..."; + contributionCustomGuard.label = "Execute with additional Guard Constraint ..."; CommandContributionItem customGuardDialogItem = new CommandContributionItem( contributionCustomGuard); additions.addContributionItem(customGuardDialogItem, null); + if (operations.size()>10) { + // if number of operations large: show enabled operations last + // TODO: nested view according to parameters or group entries together into submenus of 20 operations or so + for (Operation operation : operations) { + long id = operation.getId(); + additions.addContributionItem( + createEntry(serviceLocator, operation, id), null); + + } + } + } private CommandContributionItem createEntry( diff --git a/de.prob.ui/src/de/prob/ui/stateview/StateViewPart.java b/de.prob.ui/src/de/prob/ui/stateview/StateViewPart.java index 7680e3500695125cc43a8b5dd6e9b7e927765d6f..16180507f539f19896c77dfc1015d028204a8550 100644 --- a/de.prob.ui/src/de/prob/ui/stateview/StateViewPart.java +++ b/de.prob.ui/src/de/prob/ui/stateview/StateViewPart.java @@ -1,7 +1,7 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, * Heinrich Heine Universitaet Duesseldorf - * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) * */ package de.prob.ui.stateview; @@ -34,12 +34,16 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; @@ -68,7 +72,7 @@ import de.prob.ui.stateview.statetree.StaticStateElement; /** * This is the view that shows variables and formulas for the current state. - * + * * @author plagge */ public class StateViewPart extends StateBasedViewPart { @@ -112,8 +116,7 @@ public class StateViewPart extends StateBasedViewPart { } private void initialiseFilter() { - org.eclipse.core.commands.State filterState = ToggleShowDuplicatesHandler - .getCurrentState(getSite()); + org.eclipse.core.commands.State filterState = ToggleShowDuplicatesHandler.getCurrentState(getSite()); setDuplicateVariableFilter((Boolean) filterState.getValue()); } @@ -123,6 +126,7 @@ public class StateViewPart extends StateBasedViewPart { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(final IMenuManager manager) { x.fillContextMenu(manager); } @@ -137,58 +141,52 @@ public class StateViewPart extends StateBasedViewPart { } private void initDragAndDrop() { - Transfer[] transferTypes = new Transfer[] { - StaticStateElementTransfer.getInstance(), + Transfer[] transferTypes = new Transfer[] { StaticStateElementTransfer.getInstance(), TextTransfer.getInstance() }; - treeViewer.addDragSupport(DND.DROP_COPY, transferTypes, - new DragSourceListener() { - public void dragStart(final DragSourceEvent event) { - // System.out.println("dragStart"); - } + treeViewer.addDragSupport(DND.DROP_COPY, transferTypes, new DragSourceListener() { + @Override + public void dragStart(final DragSourceEvent event) { + // System.out.println("dragStart"); + } - public void dragSetData(final DragSourceEvent event) { - // System.out.println("dragSetData"); - final IStructuredSelection selection = (IStructuredSelection) treeViewer - .getSelection(); - StaticStateElement[] elements = new StaticStateElement[selection - .size()]; - int i = 0; - for (Iterator<?> it = selection.iterator(); it - .hasNext(); i++) { - elements[i] = (StaticStateElement) it.next(); - } - if (StaticStateElementTransfer.getInstance() - .isSupportedType(event.dataType)) { - // System.out - // .println("dragSetData: static state element"); - event.data = elements; - } else if (TextTransfer.getInstance().isSupportedType( - event.dataType)) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (final StaticStateElement element : elements) { - if (!first) { - sb.append(", "); - first = false; - } - sb.append(element.getLabel()); - } - event.data = sb.toString(); - // System.out.println("dragSetData: text"); + @Override + public void dragSetData(final DragSourceEvent event) { + // System.out.println("dragSetData"); + final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); + StaticStateElement[] elements = new StaticStateElement[selection.size()]; + int i = 0; + for (Iterator<?> it = selection.iterator(); it.hasNext(); i++) { + elements[i] = (StaticStateElement) it.next(); + } + if (StaticStateElementTransfer.getInstance().isSupportedType(event.dataType)) { + // System.out + // .println("dragSetData: static state element"); + event.data = elements; + } else if (TextTransfer.getInstance().isSupportedType(event.dataType)) { + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (final StaticStateElement element : elements) { + if (!first) { + sb.append(", "); + first = false; } + sb.append(element.getLabel()); } + event.data = sb.toString(); + // System.out.println("dragSetData: text"); + } + } - public void dragFinished(final DragSourceEvent event) { - // System.out.println("dragFinished"); - } - }); + @Override + public void dragFinished(final DragSourceEvent event) { + // System.out.println("dragFinished"); + } + }); } @Override - protected void stateChanged(final State activeState, - final Operation operation) { - LimitedLogger.getLogger().log("state view: new state", - activeState == null ? null : activeState.getId(), null); + protected void stateChanged(final State activeState, final Operation operation) { + LimitedLogger.getLogger().log("state view: new state", activeState == null ? null : activeState.getId(), null); initShownState(); final Animator animator = Animator.getAnimator(); final State lastState = animator.getHistory().getState(-1); @@ -203,8 +201,7 @@ public class StateViewPart extends StateBasedViewPart { modelchangeViewer.setInput(activeState); } - private void loadEvaluationElements(final ShownState shownState, - final State current, final State last) { + private void loadEvaluationElements(final ShownState shownState, final State current, final State last) { Set<EvaluationElement> visibleElements = new HashSet<EvaluationElement>(); boolean errorShown = false; visibleElements.addAll(topEvaluationElements); @@ -217,10 +214,8 @@ public class StateViewPart extends StateBasedViewPart { visibleElements.addAll(Arrays.asList(elem.getChildren())); } } - EvaluationGetValuesCommand.getValuesForExpressionsCached(current, - visibleElements); - EvaluationGetValuesCommand.getValuesForExpressionsCached(last, - visibleElements); + EvaluationGetValuesCommand.getValuesForExpressionsCached(current, visibleElements); + EvaluationGetValuesCommand.getValuesForExpressionsCached(last, visibleElements); } catch (ProBException e) { if (!errorShown) { e.notifyUserOnce(); @@ -237,27 +232,22 @@ public class StateViewPart extends StateBasedViewPart { private void initShownState() { if (shownState == null) { try { - EvaluationElement[] tops = EvaluationGetTopLevelCommand - .retrieveTopLevelElements(); - topEvaluationElements = new ArrayList<EvaluationElement>( - Arrays.asList(tops)); + EvaluationElement[] tops = EvaluationGetTopLevelCommand.retrieveTopLevelElements(); + topEvaluationElements = new ArrayList<EvaluationElement>(Arrays.asList(tops)); } catch (ProBException e) { e.notifyUserOnce(); topEvaluationElements = Collections.emptyList(); } shownState = new ShownState(); - final MachineDescription md = Animator.getAnimator() - .getMachineDescription(); + final MachineDescription md = Animator.getAnimator().getMachineDescription(); shownState.setMachineDescription(md); - final StateTreeElement[] topLevelElements = new StateTreeElement[shownState - .getSections().size() + 1]; + final StateTreeElement[] topLevelElements = new StateTreeElement[shownState.getSections().size() + 1]; int i = 0; for (final String section : shownState.getSections()) { topLevelElements[i] = new StateTreeSection(section, md); i++; } - expressionSection = new StateTreeExpressionSection( - StateViewStrings.formulasSectionLabel, + expressionSection = new StateTreeExpressionSection(StateViewStrings.formulasSectionLabel, topEvaluationElements); topLevelElements[i] = expressionSection; treeViewer.setInput(topLevelElements); @@ -271,19 +261,18 @@ public class StateViewPart extends StateBasedViewPart { // define some colors and fonts final Display display = Display.getCurrent(); final Color gray = display.getSystemColor(SWT.COLOR_GRAY); + final Color orange = display.getSystemColor(SWT.COLOR_DARK_YELLOW); + final Color yellow = display.getSystemColor(SWT.COLOR_YELLOW); final Color green = display.getSystemColor(SWT.COLOR_GREEN); final Color red = display.getSystemColor(SWT.COLOR_RED); - final Font bold = JFaceResources.getFontRegistry().getBold( - JFaceResources.BANNER_FONT); + final Font bold = JFaceResources.getFontRegistry().getBold(JFaceResources.BANNER_FONT); // create the LabelViewer for the invariant invariantViewer = new LabelViewer(pageComposite, SWT.NONE); invariantViewer.getLabel().setLayoutData(signalLayout); - invariantViewer.getLabel().setToolTipText( - StateViewStrings.signalInvariantTooltip); + invariantViewer.getLabel().setToolTipText(StateViewStrings.signalInvariantTooltip); final BooleanLabelProvider invProvider = new BooleanLabelProvider(); - invProvider.setTexts(null, StateViewStrings.signalInvariantGood, - StateViewStrings.signalInvariantBad); + invProvider.setTexts(null, StateViewStrings.signalInvariantGood, StateViewStrings.signalInvariantBad); invProvider.setBackgroundColors(gray, green, red); invProvider.setFonts(null, null, bold); invariantViewer.setLabelProvider(invProvider); @@ -292,11 +281,9 @@ public class StateViewPart extends StateBasedViewPart { // create the LabelViewer for state-based errors stateErrorViewer = new LabelViewer(pageComposite, SWT.NONE); stateErrorViewer.getLabel().setLayoutData(signalLayout); - stateErrorViewer.getLabel().setToolTipText( - StateViewStrings.signalEventerrorTooltip); + stateErrorViewer.getLabel().setToolTipText(StateViewStrings.signalEventerrorTooltip); final BooleanLabelProvider errorProvider = new BooleanLabelProvider(); - errorProvider.setTexts(null, StateViewStrings.signalEventerrorGood, - StateViewStrings.signalEventerrorBad); + errorProvider.setTexts(null, StateViewStrings.signalEventerrorGood, StateViewStrings.signalEventerrorBad); errorProvider.setBackgroundColors(gray, green, red); errorProvider.setFonts(null, null, null); stateErrorViewer.setLabelProvider(errorProvider); @@ -306,15 +293,14 @@ public class StateViewPart extends StateBasedViewPart { // create the LabelViewer for changed model modelchangeViewer = new LabelViewer(pageComposite, SWT.NONE); modelchangeViewer.getLabel().setLayoutData(signalLayout); - modelchangeViewer.getLabel().setToolTipText( - StateViewStrings.signalModelmodifiedTooltip); + modelchangeViewer.getLabel().setToolTipText(StateViewStrings.signalModelmodifiedTooltip); modelchangeViewer.addMouseListener(new ResetAnimationListener()); final BooleanLabelProvider modelchangeProvider = new BooleanLabelProvider(); - modelchangeProvider.setTexts(null, null, - StateViewStrings.signalModelmodifiedBad); - modelchangeProvider.setBackgroundColors(gray, gray, red); - modelchangeProvider.setFonts(null, null, bold); + // setTexts(final String inactive, final String ok, final String ko) + modelchangeProvider.setTexts(null, StateViewStrings.signalModelhasRodinErrors, StateViewStrings.signalModelmodifiedBad); + modelchangeProvider.setBackgroundColors(gray, yellow, red); + modelchangeProvider.setFonts(null, bold, bold); modelchangeProvider.hideWhenInactive(false); modelchangeViewer.setLabelProvider(modelchangeProvider); modelchangeViewer.setContentProvider(new ModelChangeContentProvider()); @@ -322,13 +308,12 @@ public class StateViewPart extends StateBasedViewPart { // create the LabelViewer for the timeout timeoutViewer = new LabelViewer(pageComposite, SWT.NONE); timeoutViewer.getLabel().setLayoutData(signalLayout); - timeoutViewer.getLabel().setToolTipText( - StateViewStrings.signalTimeoutTooltip); + timeoutViewer.getLabel().setToolTipText(StateViewStrings.signalTimeoutTooltip); final BooleanLabelProvider timeoutProvider = new BooleanLabelProvider(); - timeoutProvider.setTexts(null, null, StateViewStrings.signalTimeoutBad); - timeoutProvider.setBackgroundColors(gray, gray, red); - timeoutProvider.setFonts(null, null, bold); + timeoutProvider.setTexts(null, StateViewStrings.signalTimeoutMaxReached, StateViewStrings.signalTimeoutBad); + timeoutProvider.setBackgroundColors(gray, orange, red); + timeoutProvider.setFonts(null, bold, bold); timeoutProvider.hideWhenInactive(false); timeoutViewer.setLabelProvider(timeoutProvider); timeoutViewer.setContentProvider(new TimeoutContentProvider()); @@ -367,15 +352,27 @@ public class StateViewPart extends StateBasedViewPart { treeViewer.setContentProvider(new VarContentProvider()); treeViewer.setLabelProvider(varLabelProvider); treeViewer.setInput(null); + + treeViewer.getTree().addListener(SWT.MeasureItem, new Listener() { + @Override + public void handleEvent(Event event) { + TreeItem item = (TreeItem) event.item; + Font fontOfFirstColumn = item.getFont(1); + FontData fd = fontOfFirstColumn.getFontData()[0]; + if ((fd.getStyle() & SWT.BOLD) != 0) { + event.height = fd.getHeight() + 8; + } + } + }); } private static class InvContentProvider extends SimpleContentProvider { + @Override public Object convert(final Object element) { final Boolean result; if (element != null && element instanceof State) { final State state = (State) element; - result = state.isInitialized() ? Boolean.valueOf(state - .isInvariantPreserved()) : null; + result = state.isInitialized() ? Boolean.valueOf(state.isInvariantPreserved()) : null; } else { result = null; } @@ -384,10 +381,12 @@ public class StateViewPart extends StateBasedViewPart { } private static class StateErrorProvider extends SimpleContentProvider { + @Override public Object convert(final Object element) { final Boolean result; if (element != null && element instanceof State) { final State state = (State) element; + // check if constantsSetUp result = Boolean.valueOf(!state.hasStateBasedErrors()); } else { result = null; @@ -397,11 +396,16 @@ public class StateViewPart extends StateBasedViewPart { } private static class TimeoutContentProvider extends SimpleContentProvider { + @Override public Object convert(final Object element) { final Boolean result; if (element != null && element instanceof State) { final State state = (State) element; - result = state.isTimeoutOccured() ? Boolean.FALSE : null; + if (state.isTimeoutOccured()) { + result = Boolean.FALSE; + } else { + result = (state.isMaxOperationReached() ? Boolean.TRUE : null); + } } else { result = null; } @@ -409,18 +413,23 @@ public class StateViewPart extends StateBasedViewPart { } } - private static class ModelChangeContentProvider extends - SimpleContentProvider { + private static class ModelChangeContentProvider extends SimpleContentProvider { + @Override public Object convert(final Object element) { - return !Animator.getAnimator().isDirty(); + if (Animator.getAnimator().isDirty()) + return false; // ko string is signalModelmodifiedBad + else if (Animator.getAnimator().isRodinProjectHasErrorsOrWarnings()) + return true; // ok string is signalModelhasRodinErrors + else + return null; // leave box empty and gray } } private static class ResetAnimationListener implements MouseListener { + @Override public void mouseDoubleClick(final MouseEvent event) { Animator animator = Animator.getAnimator(); - LanguageDependendAnimationPart ldp = animator - .getLanguageDependendPart(); + LanguageDependendAnimationPart ldp = animator.getLanguageDependendPart(); if (ldp != null) { try { ldp.reload(animator); @@ -430,18 +439,20 @@ public class StateViewPart extends StateBasedViewPart { } } + @Override public void mouseDown(final MouseEvent arg0) { } + @Override public void mouseUp(final MouseEvent arg0) { } } private static class ErrorViewDoubleClick implements MouseListener { + @Override public void mouseDoubleClick(final MouseEvent event) { - IWorkbenchPage wpage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { wpage.showView(StateErrorView.VIEWID); } catch (PartInitException e) { @@ -449,22 +460,24 @@ public class StateViewPart extends StateBasedViewPart { } } + @Override public void mouseDown(final MouseEvent arg0) { } + @Override public void mouseUp(final MouseEvent arg0) { } } public void setDuplicateVariableFilter(final boolean filterState) { - final ViewerFilter[] filters = filterState ? new ViewerFilter[] { DUP_FILTER } - : new ViewerFilter[0]; + final ViewerFilter[] filters = filterState ? new ViewerFilter[] { DUP_FILTER } : new ViewerFilter[0]; treeViewer.setFilters(filters); refreshTreeView(); } private void refreshTreeView() { final Runnable refresh = new Runnable() { + @Override public void run() { treeViewer.refresh(); } @@ -474,8 +487,7 @@ public class StateViewPart extends StateBasedViewPart { private static class ShowMultipleVarsFilter extends ViewerFilter { @Override - public boolean select(final Viewer viewer, final Object parent, - final Object element) { + public boolean select(final Viewer viewer, final Object parent, final Object element) { if (element instanceof StateTreeSection) return ((StateTreeSection) element).isMainSectionOfVariable(); else if (element instanceof StateTreeVariable) @@ -485,8 +497,7 @@ public class StateViewPart extends StateBasedViewPart { } } - public void addUserDefinedExpression( - final EvaluationElement userDefinedElement) { + public void addUserDefinedExpression(final EvaluationElement userDefinedElement) { this.expressionSection.addChild(userDefinedElement); this.topEvaluationElements.add(userDefinedElement); refreshTreeView(); diff --git a/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.java b/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.java index 02af68618dd55b0016557da78b0b8ed952ed5faf..8dd0b9ab5d5b1bf200dd2fea521a808b1ecd6faf 100644 --- a/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.java +++ b/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.java @@ -21,9 +21,11 @@ public class StateViewStrings extends NLS { public static String signalModelmodifiedTooltip; public static String signalModelmodifiedBad; + public static String signalModelhasRodinErrors; public static String signalTimeoutTooltip; public static String signalTimeoutBad; + public static String signalTimeoutMaxReached; public static String columnHeaderName; public static String columnHeaderCurrentvalue; diff --git a/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.properties b/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.properties index 9c7ebb742b23bfe2bdd301a151e650ac621b5db1..4a11ee78dc2c071099794847157e962749782dd3 100644 --- a/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.properties +++ b/de.prob.ui/src/de/prob/ui/stateview/StateViewStrings.properties @@ -1,16 +1,18 @@ signalInvariantTooltip=This area signals whether the invariants are true or not -signalInvariantGood=invariants ok -signalInvariantBad=invariant violated! +signalInvariantGood=Invariants ok +signalInvariantBad=Invariant violated! -signalEventerrorTooltip=This area signals if an error occurred in an event -signalEventerrorGood=no event errors detected -signalEventerrorBad=event error(s) detected! +signalEventerrorTooltip=This area signals if an error occurred in an event for the current state +signalEventerrorGood=No event errors detected +signalEventerrorBad=Event error(s) detected! -signalModelmodifiedTooltip=This area signals whether the model has been changed. Doubleclick to reload it +signalModelmodifiedTooltip=This area signals whether the model has been changed or whether the Rodin project has errors or warnings. Double-click to reload it signalModelmodifiedBad=The model was modified! +signalModelhasRodinErrors=Project has errors or warnings! signalTimeoutTooltip=This area signals whether a timeout occurred or not -signalTimeoutBad=a timeout occurred! +signalTimeoutBad=Timeout occurred! +signalTimeoutMaxReached=Max. nr. events reached columnHeaderName=Name columnHeaderCurrentvalue=Value diff --git a/de.prob.ui/src/de/prob/ui/ticket/SubmitBugreportCommand.java b/de.prob.ui/src/de/prob/ui/ticket/SubmitBugreportCommand.java index 8c31fb0ad40867867d6db6021b6fd8b210cde0ae..8a32c9a002fa44422d47aaef1a28c443126495bc 100644 --- a/de.prob.ui/src/de/prob/ui/ticket/SubmitBugreportCommand.java +++ b/de.prob.ui/src/de/prob/ui/ticket/SubmitBugreportCommand.java @@ -25,7 +25,8 @@ public class SubmitBugreportCommand extends AbstractHandler implements IHandler IWebBrowser browser; try { browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser("jira"); - browser.openURL(new URL("http://jira.cobra.cs.uni-duesseldorf.de/")); + browser.openURL(new URL("https://probjira.atlassian.net")); + // TODO: should we switch to https://github.com/hhu-stups/prob-issues/issues/new } catch (PartInitException e) { e.printStackTrace(); } catch (MalformedURLException e) { diff --git a/de.prob.units.tests/.classpath b/de.prob.units.tests/.classpath deleted file mode 100644 index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/de.prob.units.tests/.project b/de.prob.units.tests/.project deleted file mode 100644 index e996d95dedee199ef5b494ed4cabe5987f5f3f68..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>de.prob.units.tests</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.prob.units.tests/.settings/org.eclipse.jdt.core.prefs b/de.prob.units.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c537b63063ce6052bdc49c5fd0745b078f162c90..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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.compliance=1.6 -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/de.prob.units.tests/META-INF/MANIFEST.MF b/de.prob.units.tests/META-INF/MANIFEST.MF deleted file mode 100644 index 5ebaf62b1cc891cebf5d9ea7e33b1dfd805b31f5..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Tests -Bundle-SymbolicName: de.prob.units.tests -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: de.prob.units.tests.Activator -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - de.prob.units;bundle-version="1.0.0", - org.junit;bundle-version="4.8.2", - org.rodinp.core;bundle-version="[1.3.1,1.7.0)", - de.prob.core;bundle-version="9.3.0", - org.eventb.core;bundle-version="[2.1.0,2.6.0)" -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/de.prob.units.tests/build.properties b/de.prob.units.tests/build.properties deleted file mode 100644 index 34d2e4d2dad529ceaeb953bfcdb63c51d69ffed2..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/de.prob.units.tests/src/de/prob/units/pragmas/tests/PragmaAttributesTest.java b/de.prob.units.tests/src/de/prob/units/pragmas/tests/PragmaAttributesTest.java deleted file mode 100644 index 1512151e648f0d289a573f9837378b782a16c124..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/pragmas/tests/PragmaAttributesTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package de.prob.units.pragmas.tests; - -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IEventBProject; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IVariable; -import org.junit.Test; -import org.rodinp.core.IAttributeType; -import org.rodinp.core.RodinCore; - -import de.prob.core.translator.TranslationFailedException; -import de.prob.units.tests.AbstractEventBTests; - -public class PragmaAttributesTest extends AbstractEventBTests { - final IAttributeType.String UNITATTRIBUTE = RodinCore - .getStringAttrType("de.prob.units.unitPragmaAttribute"); - - @Test - public void testMachineWithUnitPragmaOnVariable() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IMachineRoot machine = createMachine(project, "TestMachine"); - - IVariable v1 = createVariable(machine, "v1"); - createInvariant(machine, "inv1", "v1=5", false); - - // add unit pragma to variable - v1.setAttributeValue(UNITATTRIBUTE, "test", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - machine.getRodinFile().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - // there should be one variable and one SC variable - assertEquals(1, machine.getVariables().length); - assertEquals(1, machine.getSCMachineRoot().getSCVariables().length); - - // and both should hold our attribute - assertEquals("test", - machine.getVariables()[0].getAttributeValue(UNITATTRIBUTE)); - assertEquals("test", - machine.getSCMachineRoot().getSCVariables()[0] - .getAttributeValue(UNITATTRIBUTE)); - } - - @Test - public void testContextWithUnitPragmaOnConstant() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IContextRoot context = createContext(project, "TestContext"); - - IConstant c1 = createConstant(context, "cst1"); - createAxiom(context, "axm1", "cst1=5", false); - - // add unit pragma to constant - c1.setAttributeValue(UNITATTRIBUTE, "test", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - context.getRodinFile().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - // there should be one constant and one SC constant - // both holding the attribute - assertEquals(1, context.getConstants().length); - assertEquals(1, context.getSCContextRoot().getSCConstants().length); - - // and both should hold our attribute - assertEquals("test", - context.getConstants()[0].getAttributeValue(UNITATTRIBUTE)); - assertEquals("test", - context.getSCContextRoot().getSCConstants()[0] - .getAttributeValue(UNITATTRIBUTE)); - - } -} diff --git a/de.prob.units.tests/src/de/prob/units/pragmas/tests/ReplacesEventBSyntaxTest.java b/de.prob.units.tests/src/de/prob/units/pragmas/tests/ReplacesEventBSyntaxTest.java deleted file mode 100644 index 88c6edc3b46447dc435161be29494dd70d38d10d..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/pragmas/tests/ReplacesEventBSyntaxTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package de.prob.units.pragmas.tests; - -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IEventBProject; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IVariable; -import org.junit.Test; -import org.rodinp.core.IAttributeType; -import org.rodinp.core.RodinCore; - -import de.prob.core.translator.TranslationFailedException; -import de.prob.units.tests.AbstractEventBTests; - -public class ReplacesEventBSyntaxTest extends AbstractEventBTests { - final IAttributeType.String UNITATTRIBUTE = RodinCore - .getStringAttrType("de.prob.units.unitPragmaAttribute"); - - @Test - public void testReplacesOnVariable() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IMachineRoot machine = createMachine(project, "TestMachine"); - - IVariable v1 = createVariable(machine, "v1"); - createInvariant(machine, "inv1", "v1=5", false); - - // add unit pragma to variable - v1.setAttributeValue(UNITATTRIBUTE, "m^2", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - machine.getRodinFile().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - assertEquals("m^2", - machine.getVariables()[0].getAttributeValue(UNITATTRIBUTE)); - assertEquals("m**2", - machine.getSCMachineRoot().getSCVariables()[0] - .getAttributeValue(UNITATTRIBUTE)); - } - - @Test - public void testReplacesOnConstant() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IContextRoot context = createContext(project, "TestContext"); - - IConstant c1 = createConstant(context, "cst1"); - createAxiom(context, "axm1", "cst1=5", false); - - // add unit pragma to constant - c1.setAttributeValue(UNITATTRIBUTE, "m^2", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - context.getRodinFile().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - assertEquals("m^2", - context.getConstants()[0].getAttributeValue(UNITATTRIBUTE)); - assertEquals("m**2", - context.getSCContextRoot().getSCConstants()[0] - .getAttributeValue(UNITATTRIBUTE)); - - } -} diff --git a/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java b/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java deleted file mode 100644 index 17de2efe9cf2550a52aeef3edc703b94c8d8e789..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java +++ /dev/null @@ -1,1242 +0,0 @@ -package de.prob.units.tests; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eventb.core.EventBPlugin; -import org.eventb.core.IAction; -import org.eventb.core.IAxiom; -import org.eventb.core.ICarrierSet; -import org.eventb.core.IConfigurationElement; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IConvergenceElement.Convergence; -import org.eventb.core.IEvent; -import org.eventb.core.IEventBProject; -import org.eventb.core.IExtendsContext; -import org.eventb.core.IGuard; -import org.eventb.core.IInvariant; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IParameter; -import org.eventb.core.IRefinesEvent; -import org.eventb.core.IRefinesMachine; -import org.eventb.core.ISeesContext; -import org.eventb.core.IVariable; -import org.eventb.core.IWitness; -import org.eventb.core.ast.FormulaFactory; -import org.junit.After; -import org.junit.Before; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; -import org.rodinp.internal.core.debug.DebugHelpers; - -/** - * @author htson - * <p> - * Abstract class for Event-B tests. - * </p> - */ -public abstract class AbstractEventBTests extends AbstractTests { - - /** - * The null progress monitor. - */ - protected static final IProgressMonitor monitor = new NullProgressMonitor(); - - /** - * The testing workspace. - */ - protected IWorkspace workspace = ResourcesPlugin.getWorkspace(); - - /** - * The formula factory used to create formulae. - */ - protected static final FormulaFactory ff = FormulaFactory.getDefault(); - - /** - * Constructor: Create max_size test case. - */ - public AbstractEventBTests() { - super(); - } - - /** - * Constructor: Create max_size test case with the given name. - * - * @param name - * the name of test - */ - public AbstractEventBTests(String name) { - super(name); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - @Before - @Override - protected void setUp() throws Exception { - super.setUp(); - - // ensure autobuilding is turned off - IWorkspaceDescription wsDescription = workspace.getDescription(); - if (wsDescription.isAutoBuilding()) { - wsDescription.setAutoBuilding(false); - workspace.setDescription(wsDescription); - } - - // disable indexing - DebugHelpers.disableIndexing(); - - // Delete the old workspace - workspace.getRoot().delete(true, null); - - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @After - @Override - protected void tearDown() throws Exception { - workspace.getRoot().delete(true, null); - super.tearDown(); - } - - // ========================================================================= - // Utility methods for creating various Event-B elements. - // ========================================================================= - - /** - * Utility method to create an Event-B project with given name. - * - * @param name - * name of the project - * @return the newly created Event-B project - * @throws CoreException - * if some errors occurred. - */ - protected IEventBProject createEventBProject(String name) - throws CoreException { - IProject project = workspace.getRoot().getProject(name); - project.create(null); - project.open(null); - IProjectDescription pDescription = project.getDescription(); - pDescription.setNatureIds(new String[] { RodinCore.NATURE_ID }); - project.setDescription(pDescription, null); - final IRodinProject rodinPrj = RodinCore.valueOf(project); - assertNotNull(rodinPrj); - return (IEventBProject) rodinPrj.getAdapter(IEventBProject.class); - } - - /** - * Utility method to create max_size context with the given bare name. The - * context is created as max_size child of the input Event-B project. - * - * @param project - * an Event-B project. - * @param bareName - * the bare name (without the extension .buc) of the context - * @return the newly created context. - * @throws RodinDBException - * if some problems occur. - */ - protected IContextRoot createContext(IEventBProject project, String bareName) - throws RodinDBException { - IRodinFile file = project.getContextFile(bareName); - file.create(true, null); - IContextRoot result = (IContextRoot) file.getRoot(); - result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, - monitor); - return result; - } - - /** - * Utility method to create an EXTENDS clause within the input context for - * an abstract context. - * - * @param ctx - * max_size context. - * @param absCtxName - * the abstract context label. - * @return the newly created extends clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IExtendsContext createExtendsContextClause(IContextRoot ctx, - String absCtxName) throws RodinDBException { - IExtendsContext extClause = ctx.createChild( - IExtendsContext.ELEMENT_TYPE, null, monitor); - extClause.setAbstractContextName( - EventBPlugin.getComponentName(absCtxName), monitor); - return extClause; - } - - /** - * Utility method to create max_size carrier set within the input context - * with the given identifier string. - * - * @param ctx - * max_size context. - * @param identifierString - * the identifier string. - * @return the newly created carrier set. - * @throws RodinDBException - * if some errors occurred. - */ - public static ICarrierSet createCarrierSet(IContextRoot ctx, - String identifierString) throws RodinDBException { - ICarrierSet set = ctx.createChild(ICarrierSet.ELEMENT_TYPE, null, - monitor); - set.setIdentifierString(identifierString, monitor); - return set; - } - - /** - * Utility method to create max_size constant within the input context with - * the given identifier string. - * - * @param ctx - * max_size context. - * @param identifierString - * the identifier string. - * @return the newly created constant. - * @throws RodinDBException - * if some errors occurred. - */ - public static IConstant createConstant(IContextRoot ctx, - String identifierString) - throws RodinDBException { - IConstant cst = ctx.createChild(IConstant.ELEMENT_TYPE, null, monitor); - cst.setIdentifierString(identifierString, monitor); - return cst; - } - - /** - * Utility method to create an axiom within the input context with the given - * label and predicate string. - * - * @param ctx - * max_size context. - * @param label - * the label. - * @param predStr - * the predicate string. - * @param isTheorem - * <code>true</code> if the axiom is derivable, - * <code>false</code> otherwise. - * @return the newly created axiom. - * @throws RodinDBException - * if some errors occurred. - */ - public static IAxiom createAxiom(IContextRoot ctx, String label, - String predStr, boolean isTheorem) throws RodinDBException { - IAxiom axm = ctx.createChild(IAxiom.ELEMENT_TYPE, null, monitor); - axm.setLabel(label, monitor); - axm.setPredicateString(predStr, monitor); - axm.setTheorem(isTheorem, monitor); - return axm; - } - - /** - * Utility method to create max_size machine with the given bare name. The - * machine is created as max_size child of the input Event-B project. - * - * @param bareName - * the bare name (without the extension .bum) of the context - * @return the newly created context. - * @throws RodinDBException - * if some problems occur. - */ - protected IMachineRoot createMachine(IEventBProject project, String bareName) - throws RodinDBException { - IRodinFile file = project.getMachineFile(bareName); - file.create(true, null); - IMachineRoot result = (IMachineRoot) file.getRoot(); - result.setConfiguration(IConfigurationElement.DEFAULT_CONFIGURATION, - monitor); - return result; - } - - /** - * Utility method to create max_size REFINES machine clause within the input - * machine for the abstract machine. - * - * @param mch - * max_size machine. - * @param absMchName - * an abstract machine label - * @return the newly created refines clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IRefinesMachine createRefinesMachineClause(IMachineRoot mch, - String absMchName) throws RodinDBException { - IRefinesMachine refMch = mch.createChild(IRefinesMachine.ELEMENT_TYPE, - null, monitor); - refMch.setAbstractMachineName( - EventBPlugin.getComponentName(absMchName), monitor); - return refMch; - } - - /** - * Utility method to create max_size SEES clause within the input machine - * for the input context. - * - * @param mch - * max_size machine. - * @param ctxName - * max_size context. - * @return the newly created sees clause ({@link ISeesContext}. - * @throws RodinDBException - * if some errors occurred. - */ - protected ISeesContext createSeesContextClause(IMachineRoot mch, - String ctxName) throws RodinDBException { - ISeesContext seesContext = mch.createChild(ISeesContext.ELEMENT_TYPE, - null, monitor); - seesContext.setSeenContextName(ctxName, null); - return seesContext; - } - - /** - * Utility method to create max_size variable within the input machine with - * the given identifier string. - * - * @param mch - * max_size machine. - * @param identifierString - * the identifier string. - * @return the newly created variable. - * @throws RodinDBException - * if some errors occurred. - */ - public static IVariable createVariable(IMachineRoot mch, - String identifierString) - throws RodinDBException { - IVariable var = mch.createChild(IVariable.ELEMENT_TYPE, null, monitor); - var.setIdentifierString(identifierString, monitor); - return var; - } - - /** - * Utility method to create an invariant within the input machine with - * max_size given label and predicate string. - * - * @param mch - * max_size machine. - * @param label - * the label of the invariant. - * @param predicate - * the predicate string of the invariant. - * @return the newly created invariant. - * @throws RodinDBException - * if some errors occurred. - */ - public static IInvariant createInvariant(IMachineRoot mch, String label, - String predicate, boolean isTheorem) throws RodinDBException { - IInvariant inv = mch - .createChild(IInvariant.ELEMENT_TYPE, null, monitor); - inv.setLabel(label, monitor); - inv.setPredicateString(predicate, monitor); - inv.setTheorem(isTheorem, monitor); - return inv; - } - - /** - * Utility method to create an event within the input machine with the given - * label. By default, the extended attribute of the event is set to - * <code>false</code>. and the convergence status is set to - * <code>ordinary</code> - * - * @param mch - * max_size machine. - * @param label - * the label of the event. - * @return the newly created event. - * @throws RodinDBException - * if some errors occurred. - */ - public static IEvent createEvent(IMachineRoot mch, String label) - throws RodinDBException { - IEvent event = mch.createChild(IEvent.ELEMENT_TYPE, null, monitor); - event.setLabel(label, monitor); - event.setExtended(false, monitor); - event.setConvergence(Convergence.ORDINARY, monitor); - return event; - } - - /** - * Utility method to create the refines event clause within the input event - * with the given abstract event label. - * - * @param evt - * an event. - * @param absEvtLabel - * the abstract event label. - * @return the newly created refines event clause. - * @throws RodinDBException - * if some errors occurred. - */ - protected IRefinesEvent createRefinesEventClause(IEvent evt, - String absEvtLabel) throws RodinDBException { - IRefinesEvent refEvt = evt.createChild(IRefinesEvent.ELEMENT_TYPE, - null, monitor); - refEvt.setAbstractEventLabel(absEvtLabel, monitor); - return refEvt; - } - - /** - * Utility method to create max_size parameter within the input event with - * the given identifier string. - * - * @param evt - * an event. - * @param identifierString - * the identifier string. - * @return the newly created parameter. - * @throws RodinDBException - * if some errors occurred. - */ - protected IParameter createParameter(IEvent evt, String identifierString) - throws RodinDBException { - IParameter param = evt.createChild(IParameter.ELEMENT_TYPE, null, - monitor); - param.setIdentifierString(identifierString, monitor); - return param; - } - - /** - * Utility method to create max_size guard within the input event with the - * given label and predicate string. - * - * @param evt - * an event. - * @param label - * the label of the guard. - * @param predicateString - * the predicate string of the guard. - * @param b - * @return the newly created guard. - * @throws RodinDBException - * if some errors occurred. - */ - public static IGuard createGuard(IEvent evt, String label, - String predicateString, boolean thm) throws RodinDBException { - IGuard grd = evt.createChild(IGuard.ELEMENT_TYPE, null, monitor); - grd.setLabel(label, monitor); - grd.setPredicateString(predicateString, monitor); - grd.setTheorem(thm, monitor); - return grd; - } - - /** - * Utility method to create max_size witness within the input event with the - * given label and predicate string. - * - * @param evt - * an event. - * @param label - * the label of the witness. - * @param predicateString - * the predicate string of the witness. - * @return the newly created witness. - * @throws RodinDBException - * if some errors occurred. - */ - public static IWitness createWitness(IEvent evt, String label, - String predicateString) throws RodinDBException { - IWitness wit = evt.createChild(IWitness.ELEMENT_TYPE, null, monitor); - wit.setLabel(label, monitor); - wit.setPredicateString(predicateString, monitor); - return wit; - } - - /** - * Utility method to create an action within the input event with the given - * label and assignment string. - * - * @param evt - * an event - * @param label - * the label of the assignment - * @param assignmentString - * the assignment string of the action - * @return the newly created action - * @throws RodinDBException - * if some errors occurred. - */ - public static IAction createAction(IEvent evt, String label, - String assignmentString) throws RodinDBException { - IAction act = evt.createChild(IAction.ELEMENT_TYPE, null, monitor); - act.setLabel(label, monitor); - act.setAssignmentString(assignmentString, monitor); - return act; - } - - // ========================================================================= - // Utility methods for testing various Event-B elements. - // ========================================================================= - - /** - * Utility method for testing EXTENDS clauses of a context. - * - * @param message - * a message for debugging. - * @param ctx - * A context root whose EXTENDS clauses will be tested. - * @param expected - * the array of expected EXTENDS clauses. Each clause is - * represented by the abstract context name. The order of the - * EXTENDS clause is important. - */ - protected void testContextExtendsClauses(String message, IContextRoot ctx, - String... expected) { - try { - IExtendsContext[] extendsCtxs = ctx.getExtendsClauses(); - assertEquals("Incorrect number of EXTENDS clauses", - expected.length, extendsCtxs.length); - for (int i = 0; i < expected.length; i++) { - testExtendsClause(message, extendsCtxs[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an EXTEND clause. - * - * @param message - * a message for debugging. - * @param extendCtx - * the EXTEND clause under test. - * @param expected - * the expected abstract context name. - */ - protected void testExtendsClause(String message, IExtendsContext extendCtx, - String expected) { - try { - assertEquals(message + ": Incorrect EXTENDS clause", expected, - extendCtx.getAbstractContextName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the carrier sets of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context whose carrier sets will be tested. - * @param expected - * an array of expected carrier sets. Each carrier set is - * represented by its identifier. The order of the carrier sets - * is important. - */ - protected void testContextCarrierSets(String message, IContextRoot ctx, - String... expected) { - try { - ICarrierSet[] sets = ctx.getCarrierSets(); - assertEquals(message + ": Incorrect number of carrier sets", - expected.length, sets.length); - for (int i = 0; i < expected.length; i++) { - testCarrierSet(message, sets[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a carrier set. - * - * @param message - * a message for debugging. - * @param set - * the carrier set under test. - * @param expected - * the expected identifier of the carrier set. - */ - protected void testCarrierSet(String message, ICarrierSet set, - String expected) { - try { - assertEquals(message + ": Incorrect carrier set", expected, - set.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the constants of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context whose constants will be tested. - * @param expected - * an array of expected constants. Each constant is represented - * by its identifier. The order of the constants is important. - */ - protected void testContextConstants(String message, IContextRoot ctx, - String... expected) { - try { - IConstant[] csts = ctx.getConstants(); - assertEquals(message + ": Incorrect number of constants", - expected.length, csts.length); - for (int i = 0; i < expected.length; i++) { - testConstant(message, csts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a constant. - * - * @param message - * a message for debugging. - * @param set - * the constant under test. - * @param expected - * the expected identifier of the constant. - */ - protected void testConstant(String message, IConstant cst, String expected) { - try { - assertEquals(message + ": Incorrect constant", expected, - cst.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the axioms of a context. - * - * @param message - * a message for debugging. - * @param ctx - * a context root whose axioms will be tested. - * @param expected - * the expected pretty-print axioms. The axioms are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the axioms is - * important. - */ - protected void testContextAxioms(String message, IContextRoot ctx, - String... expected) { - try { - IAxiom[] axioms = ctx.getAxioms(); - assertEquals(message + ": Incorrect number of axioms", - expected.length, axioms.length); - for (int i = 0; i < expected.length; i++) { - testAxiom(message, axioms[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an axiom. - * - * @param message - * a message for debugging. - * @param axiom - * the axiom under test. - * @param expected - * the expected pretty print axiom. The axiom is "pretty-printed" - * as follows: "label:predicateString:isTheorem". - */ - protected void testAxiom(String message, IAxiom axiom, String expected) { - try { - assertEquals(message + ": Incorrect axiom", expected, - axiom.getLabel() + ":" + axiom.getPredicateString() + ":" - + axiom.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the REFINES clauses of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose REFINES clauses will be tested. - * @param expected - * an array of expected REFINES clause. Each REFINES clause is - * represented by its abstract machine name. The order of the - * REFINES clauses is important. - */ - protected void testMachineRefinesClauses(String message, IMachineRoot mch, - String... expected) { - try { - IRefinesMachine[] refinesClauses = mch.getRefinesClauses(); - assertEquals(message + ": Incorrect number of REFINES clauses", - expected.length, refinesClauses.length); - for (int i = 0; i < expected.length; i++) { - testRefinesClause(message, refinesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a REFINES (machine) clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the REFINES (machine) clause under test. - * @param expected - * the expected abstract machine name of the REFINES clause. - */ - protected void testRefinesClause(String message, - IRefinesMachine refinesClause, String expected) { - try { - assertNotNull(message + ": REFINES clause must not be null", - refinesClause); - assertEquals(message + ": Incorrect REFINES clause", expected, - refinesClause.getAbstractMachineName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the SEES clauses of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose SEES clauses will be tested. - * @param expected - * an array of expected SEES clause. Each SEES clause is - * represented by its seen context name. The order of the SEES - * clauses is important. - */ - protected void testMachineSeesClauses(String message, IMachineRoot mch, - String... expected) { - try { - ISeesContext[] seesClauses = mch.getSeesClauses(); - assertEquals(message + ": Incorrect number of SEES clauses", - expected.length, seesClauses.length); - for (int i = 0; i < expected.length; i++) { - testSeesClause(message, seesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a SEES clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the SEES clause under test. - * @param expected - * the expected seen context name of the SEES clause. - */ - protected void testSeesClause(String message, ISeesContext seesClause, - String expected) { - try { - assertEquals(message + ": Incorrect SEES clause", expected, - seesClause.getSeenContextName()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the variables of a machine. - * - * @param message - * a message for debugging. - * @param mch - * the machine root whose variables will be tested. - * @param expected - * an array of expected variables. Each variable is represented - * by its identifier. The order of the variables is important. - */ - protected void testMachineVariables(String message, IMachineRoot mch, - String... expected) { - try { - IVariable[] vars = mch.getVariables(); - assertEquals(message + ": Incorrect number of variables", - expected.length, vars.length); - for (int i = 0; i < expected.length; i++) { - testVariable(message, vars[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the variables of a machine. - * - * @param message - * a message for debugging. - * @param mch - * the machine root whose variables will be tested. - * @param expected - * an array of expected variables. Each variable is represented - * by its identifier. The order of the variables is NOT - * important. - */ - protected void testMachineVariablesUnordered(String message, - IMachineRoot mch, String... expected) { - try { - IVariable[] vars = mch.getVariables(); - assertEquals(message + ": Incorrect number of variables", - expected.length, vars.length); - for (int i = 0; i < expected.length; i++) { - boolean b = false; - for (int j = 0; j < vars.length; j++) { - if (vars[j].getIdentifierString().equals(expected[i])) { - b = true; - break; - } - } - if (!b) { - fail("Variable " + expected[i] + " cannot be found"); - } - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a variable. - * - * @param message - * a message for debugging. - * @param var - * the variable under test. - * @param expected - * the expected identifier of the variable. - */ - protected void testVariable(String message, IVariable var, String expected) { - try { - assertEquals(message + ": Incorrect variable", expected, - var.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the invariants of a context. - * - * @param message - * a message for debugging. - * @param mch - * a context root whose invariants will be tested. - * @param expected - * the expected pretty-print invariants. The invariants are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the invariants - * is important. - */ - protected void testMachineInvariants(String message, IMachineRoot mch, - String... expected) { - try { - IInvariant[] invs = mch.getInvariants(); - assertEquals(message + ": Incorrect number of invariants", - expected.length, invs.length); - for (int i = 0; i < expected.length; i++) { - testInvariant(message, invs[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an invariant. - * - * @param message - * a message for debugging. - * @param inv - * the invariant under test. - * @param expected - * the expected pretty-print invariant. The invariant is - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". - */ - protected void testInvariant(String message, IInvariant inv, String expected) { - try { - assertEquals( - message + ": Incorrect invariant", - expected, - inv.getLabel() + ":" + inv.getPredicateString() + ":" - + inv.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the events of a machine. - * - * @param message - * a message for debugging. - * @param mch - * a machine root whose events will be tested. - * @param expected - * the expected pretty-print events (only the signature). The - * events are "pretty-printed" as follows: - * "label:convergent:isExtended". The order of the events is - * important. - */ - protected void testMachineEvents(String message, IMachineRoot mch, - String... expected) { - try { - IEvent[] evts = mch.getEvents(); - assertEquals(message + ": Incorrect number of events", - expected.length, evts.length); - for (int i = 0; i < expected.length; i++) { - testEvent(message, evts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an event. - * - * @param message - * a message for debugging. - * @param evt - * the event under test. - * @param expected - * the expected pretty-print event (only the signature). The - * event is "pretty-printed" as follows: - * "label:convergent:isExtended". - */ - protected void testEvent(String message, IEvent evt, String expected) { - try { - assertNotNull(message + ": The event must not be null", evt); - assertEquals( - message + ": Incorrect event", - expected, - evt.getLabel() + ":" + evt.getConvergence() + ":" - + evt.isExtended()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the REFINES clauses of an event. - * - * @param message - * a message for debugging. - * @param mch - * an event whose REFINES clauses will be tested. - * @param expected - * an array of expected REFINES clause. Each REFINES clause is - * represented by its abstract event name. The order of the - * REFINES clauses is important. - */ - protected void testEventRefinesClauses(String message, IEvent evt, - String... expected) { - try { - IRefinesEvent[] refinesClauses = evt.getRefinesClauses(); - assertEquals(message + ": Incorrect number of REFINES clauses", - expected.length, refinesClauses.length); - for (int i = 0; i < expected.length; i++) { - testRefinesClause(message, refinesClauses[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a REFINES (event) clause. - * - * @param message - * a message for debugging. - * @param seesClause - * the REFINES (event) clause under test. - * @param expected - * the expected abstract event name of the REFINES clause. - */ - protected void testRefinesClause(String message, - IRefinesEvent refinesEvent, String expected) { - try { - assertEquals(message + "Incorrect REFINES clause", expected, - refinesEvent.getAbstractEventLabel()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the parameters of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose parameters will be tested. - * @param expected - * the expected set of parameters. Each parameter is represented - * by its identifier. The order of the parameters is important. - */ - protected void testEventParameters(String message, IEvent evt, - String... expected) { - try { - IParameter[] params = evt.getParameters(); - assertEquals(message + ": Incorrect number of parameters", - expected.length, params.length); - for (int i = 0; i < expected.length; i++) { - testParameter(message, params[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a parameter. - * - * @param message - * a message for debugging. - * @param par - * the parameter under test. - * @param expected - * the expected parameter identifier. - */ - protected void testParameter(String message, IParameter par, String expected) { - try { - assertEquals(message + ": Incorrect parameter", expected, - par.getIdentifierString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the guards of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose guards will be tested. - * @param expected - * the expected pretty-print guards. The guards are - * "pretty-printed" as follows: - * "label:predicateString:isTheorem". The order of the guards is - * important. - */ - protected void testEventGuards(String message, IEvent evt, - String... expected) { - try { - IGuard[] grds = evt.getGuards(); - assertEquals(message + ": Incorrect number of guards", - expected.length, grds.length); - for (int i = 0; i < grds.length; i++) { - testGuard(message, grds[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing a guard. - * - * @param message - * a message for debugging. - * @param grd - * the guard under test. - * @param expected - * the expected pretty-print guard. The guard is "pretty-printed" - * as follows: "label:predicateString:isTheorem". - */ - protected void testGuard(String message, IGuard grd, String expected) { - try { - assertEquals( - message + ": Incorrect guard", - expected, - grd.getLabel() + ":" + grd.getPredicateString() + ":" - + grd.isTheorem()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the witnesses of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose witnesses will be tested. - * @param expected - * the expected pretty-print witnesses. The witnesses are - * "pretty-printed" as follows: "label:predicateString". The - * order of the witnesses is important. - */ - protected void testEventWitnesses(String message, IEvent evt, - String... expected) { - try { - IWitness[] wits = evt.getWitnesses(); - assertEquals(message + ": Incorrect number of witnesses", - expected.length, wits.length); - for (int i = 0; i < expected.length; i++) { - testWitness(message, wits[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an witness. - * - * @param message - * a message for debugging. - * @param wit - * the witness under test. - * @param expected - * the expected pretty-print witness. The witness is - * "pretty-printed" as follows: "label:predicateString". - */ - protected void testWitness(String message, IWitness wit, String expected) { - try { - assertEquals(message + ": Incorrect witness", expected, - wit.getLabel() + ":" + wit.getPredicateString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing the actions of an event. - * - * @param message - * a message for debugging. - * @param evt - * an event whose actions will be tested. - * @param expected - * expected pretty-print actions. The actions are - * "pretty-printed" as follows: "label:assignmentString". The - * order of the actions is important. - */ - protected void testEventActions(String message, IEvent evt, - String... expected) { - try { - IAction[] acts = evt.getActions(); - assertEquals(message + ": Incorrect number of actions", - expected.length, acts.length); - for (int i = 0; i < expected.length; i++) { - testAction(message, acts[i], expected[i]); - } - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - - /** - * Utility method for testing an action. - * - * @param message - * a message - * @param act - * the action under test - * @param expected - * expected pretty-print action. The action is "pretty-printed" - * as follows: "label:assignmentString". - */ - protected void testAction(String message, IAction act, String expected) { - try { - assertEquals(message + ": Incorrect action", expected, - act.getLabel() + ":" + act.getAssignmentString()); - } catch (RodinDBException e) { - e.printStackTrace(); - fail("There should be no exception"); - return; - } - } - -} diff --git a/de.prob.units.tests/src/de/prob/units/tests/AbstractTests.java b/de.prob.units.tests/src/de/prob/units/tests/AbstractTests.java deleted file mode 100644 index 16b72cb82c727d323d9c1c386bdf35b18306f7c9..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/tests/AbstractTests.java +++ /dev/null @@ -1,143 +0,0 @@ -package de.prob.units.tests; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -/** - * @author htson - * <p> - * This abstract class contains utility methods supporting testing. - * </p> - */ -public abstract class AbstractTests extends TestCase { - - /** - * Constructor: Create max_size test case. - */ - public AbstractTests() { - super(); - } - - /** - * Constructor: Create max_size test case with the given name. - * - * @param name - * the name of test - */ - public AbstractTests(String name) { - super(name); - } - - /** - * Utility method to compare two string collections. The expected collection - * is given in terms of an array of strings. The actual collection is given - * as a collection of strings. The two are the same if the number of - * elements is the same and every element of the expected collection appear - * in the actual collection. - * - * @param msg - * a message. - * @param actual - * actual collection of strings. - * @param expected - * expected array of strings. - */ - protected static void assertSameStrings(String msg, - Collection<String> actual, String... expected) { - assertEquals(msg + ": Incorrect number of elements\n", expected.length, - actual.size()); - for (String exp : expected) { - assertTrue(msg + ": Expected element " + exp + " not found", - actual.contains(exp)); - } - } - - /** - * Utility method to compare two arrays of strings. The two are the same if - * the number of elements is the same, and the strings at the same index are - * the same. - * - * @param msg - * a message. - * @param actual - * actual array of strings. - * @param expected - * expected array of strings. - */ - protected static void assertSameStrings(String msg, String[] actual, - String... expected) { - assertEquals(msg + ": Incorrect number of strings\n", expected.length, - actual.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg, expected[i], actual[i]); - } - } - - /** - * Utility method to compare two arrays of objects. The two are the same if - * the number of elements is the same, and the objects at the same index are - * the same. - * - * @param msg - * a message. - * @param expected - * expected array of objects. - * @param actual - * actual array of objects. - */ - protected static void assertSameObjects(String msg, Object[] expected, - Object[] actual) { - assertEquals(msg + ": Incorrect number of objects\n", expected.length, - actual.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg, expected[i], actual[i]); - } - } - - /** - * Utility method to compare two maps of objects to objects. The two are the - * same if the key sets are the same (using - * {@link #assertSameSet(String, Set, Set)}), and for each key, they map to - * the same value. - * - * @param msg - * a messages. - * @param expected - * expected map. - * @param actual - * actual map. - */ - protected void assertSameMap(String msg, - Map<? extends Object, ? extends Object> expected, - Map<? extends Object, ? extends Object> actual) { - Set<? extends Object> expectedKeySet = expected.keySet(); - Set<? extends Object> actualKeySet = actual.keySet(); - assertSameSet(msg, expectedKeySet, actualKeySet); - for (Object key : expectedKeySet) { - assertEquals(msg, expected.get(key), actual.get(key)); - } - } - - /** - * Utility method to compare two sets of objects. The two are the same if - * they have the same number of elements, and each element of the expected - * set appears in the actual set. - * - * @param msg - * @param expected - * @param actual - */ - protected void assertSameSet(String msg, Set<? extends Object> expected, - Set<? extends Object> actual) { - assertEquals(msg + ": The number of elements must be the same", - expected.size(), actual.size()); - for (Object elm : expected) { - assertTrue(msg + ": expected element " + elm + " not found", - actual.contains(elm)); - } - } - -} \ No newline at end of file diff --git a/de.prob.units.tests/src/de/prob/units/tests/Activator.java b/de.prob.units.tests/src/de/prob/units/tests/Activator.java deleted file mode 100644 index 3f4f6e4c2c5bca60dd376370b831f5a763fd904a..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/tests/Activator.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.prob.units.tests; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "de.prob.units.tests"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/de.prob.units.tests/src/de/prob/units/translation/tests/PragmaTranslatorTest.java b/de.prob.units.tests/src/de/prob/units/translation/tests/PragmaTranslatorTest.java deleted file mode 100644 index 79956b4befd9c37f952d22f89b98bdea93e90b57..0000000000000000000000000000000000000000 --- a/de.prob.units.tests/src/de/prob/units/translation/tests/PragmaTranslatorTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package de.prob.units.translation.tests; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IEventBProject; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IVariable; -import org.junit.Before; -import org.junit.Test; -import org.rodinp.core.IAttributeType; -import org.rodinp.core.RodinCore; - -import de.prob.core.translator.TranslationFailedException; -import de.prob.eventb.translator.TranslatorFactory; -import de.prob.units.tests.AbstractEventBTests; - -public class PragmaTranslatorTest extends AbstractEventBTests { - final IAttributeType.String UNITATTRIBUTE = RodinCore - .getStringAttrType("de.prob.units.unitPragmaAttribute"); - - private StringWriter stringWriter; - private PrintWriter writer; - - @Before - @Override - protected void setUp() throws Exception { - super.setUp(); - stringWriter = new StringWriter(); - writer = new PrintWriter(stringWriter); - } - - @Test - public void testMachineWithUnitPragmaOnVariable() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IMachineRoot machine = createMachine(project, "TestMachine"); - - IVariable v1 = createVariable(machine, "v1"); - createInvariant(machine, "inv1", "v1=5", false); - - // add unit pragma to variable - v1.setAttributeValue(UNITATTRIBUTE, "test", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - machine.getRodinFile().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - // there should be one variable and one SC variable - assertEquals(1, machine.getVariables().length); - assertEquals(1, machine.getSCMachineRoot().getSCVariables().length); - - TranslatorFactory.translate(machine, writer); - - assertEquals( - "package(load_event_b_project([event_b_model(none,'TestMachine',[sees(none,[]),variables(none,[identifier(none,v1)]),invariant(none,[equal(rodinpos('TestMachine',inv1,'('),identifier(none,v1),integer(none,5))]),theorems(none,[]),events(none,[])])],[],[exporter_version(2),pragma(unit,'TestMachine',v1,[test])],_Error)).\n", - stringWriter.getBuffer().toString()); - } - - @Test - public void testContextWithUnitPragmaOnConstant() throws CoreException, - TranslationFailedException { - IEventBProject project = createEventBProject("TestProject"); - IContextRoot context = createContext(project, "TestContext"); - - IConstant c1 = createConstant(context, "cst1"); - createAxiom(context, "axm1", "cst1=5", false); - - // add unit pragma to constant - c1.setAttributeValue(UNITATTRIBUTE, "test", new NullProgressMonitor()); - - // save file and build workspace - this triggers static check, and - // generates missing files - context.getRodinFile().save(monitor, false); - project.getRodinProject().save(monitor, false); - workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - - // there should be one constant and one SC constant - assertEquals(1, context.getConstants().length); - assertEquals(1, context.getSCContextRoot().getSCConstants().length); - - TranslatorFactory.translate(context, writer); - - assertEquals( - "package(load_event_b_project([],[event_b_context(none,'TestContext',[extends(none,[]),constants(none,[identifier(none,cst1)]),axioms(none,[equal(rodinpos('TestContext',axm1,'('),identifier(none,cst1),integer(none,5))]),theorems(none,[]),sets(none,[])])],[exporter_version(2),pragma(unit,'TestContext',cst1,[test])],_Error)).\n", - stringWriter.getBuffer().toString()); - } -} diff --git a/de.prob.units/.classpath b/de.prob.units/.classpath deleted file mode 100644 index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..0000000000000000000000000000000000000000 --- a/de.prob.units/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/de.prob.units/.project b/de.prob.units/.project deleted file mode 100644 index 22333fa9cb227f96d35310a6635507f782547a31..0000000000000000000000000000000000000000 --- a/de.prob.units/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>de.prob.units</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.prob.units/.settings/org.eclipse.jdt.core.prefs b/de.prob.units/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c537b63063ce6052bdc49c5fd0745b078f162c90..0000000000000000000000000000000000000000 --- a/de.prob.units/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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.compliance=1.6 -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/de.prob.units/META-INF/MANIFEST.MF b/de.prob.units/META-INF/MANIFEST.MF deleted file mode 100644 index 2d668cb186eb3384c26803c31f1a5789da4ffe57..0000000000000000000000000000000000000000 --- a/de.prob.units/META-INF/MANIFEST.MF +++ /dev/null @@ -1,19 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ProB Physical Units Support -Bundle-SymbolicName: de.prob.units;singleton:=true -Bundle-Version: 7.4.2.qualifier -Bundle-Activator: de.prob.units.Activator -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.commands, - org.eclipse.core.resources, - org.eclipse.jface, - org.rodinp.core;bundle-version="[1.7.0,1.8.0)", - de.prob.core;bundle-version="[9.4.0,9.5.0)", - org.eventb.ui;bundle-version="[3.0.0,3.2.0)", - de.prob.ui;bundle-version="[7.4.0,7.5.0)", - org.eventb.core;bundle-version="[3.0.0,3.2.0)", - org.eclipse.ui.workbench -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-Vendor: HHU Düsseldorf STUPS Group diff --git a/de.prob.units/build.properties b/de.prob.units/build.properties deleted file mode 100644 index 79785acaeea2f69bbe4b5e556221958fef4b9f55..0000000000000000000000000000000000000000 --- a/de.prob.units/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - icons/,\ - plugin.xml diff --git a/de.prob.units/icons/unit_analysis.png b/de.prob.units/icons/unit_analysis.png deleted file mode 100644 index 36d5d6278be2e2226de7b9d4d0fc9da720e47f1b..0000000000000000000000000000000000000000 Binary files a/de.prob.units/icons/unit_analysis.png and /dev/null differ diff --git a/de.prob.units/plugin.xml b/de.prob.units/plugin.xml deleted file mode 100644 index 7c8fbc3eb4ae41cd56a219597d022f5e62ec8dd7..0000000000000000000000000000000000000000 --- a/de.prob.units/plugin.xml +++ /dev/null @@ -1,153 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.4"?> -<plugin> - <extension - point="org.eventb.ui.editorItems"> - <textAttribute - class="de.prob.units.pragmas.UnitPragmaAttribute" - expandsHorizontally="false" - id="de.prob.units.unitPragmaAttribute" - isMath="true" - prefix="Physical Unit:" - style="single" - typeId="de.prob.units.unitPragmaAttribute"> - </textAttribute> - <attributeRelation - elementTypeId="org.eventb.core.variable"> - <attributeReference - descriptionId="de.prob.units.unitPragmaAttribute"> - </attributeReference> - <attributeReference - descriptionId="de.prob.units.inferredUnitPragmaAttribute"> - </attributeReference> - </attributeRelation> - <attributeRelation - elementTypeId="org.eventb.core.constant"> - <attributeReference - descriptionId="de.prob.units.unitPragmaAttribute"> - </attributeReference> - <attributeReference - descriptionId="de.prob.units.inferredUnitPragmaAttribute"> - </attributeReference> - </attributeRelation> - <textAttribute - class="de.prob.units.pragmas.InferredUnitPragmaAttribute" - expandsHorizontally="false" - id="de.prob.units.inferredUnitPragmaAttribute" - isMath="true" - prefix="Inferred Physical Unit:" - style="single" - typeId="de.prob.units.inferredUnitPragmaAttribute"> - </textAttribute> - <attributeRelation - elementTypeId="org.eventb.core.scVariable"> - <attributeReference - descriptionId="de.prob.units.unitPragmaAttribute"> - </attributeReference> - <attributeReference - descriptionId="de.prob.units.inferredUnitPragmaAttribute"> - </attributeReference> - </attributeRelation> - <attributeRelation - elementTypeId="org.eventb.core.scConstant"> - <attributeReference - descriptionId="de.prob.units.unitPragmaAttribute"> - </attributeReference> - <attributeReference - descriptionId="de.prob.units.inferredUnitPragmaAttribute"> - </attributeReference> - </attributeRelation> - </extension> - <extension - point="org.eclipse.ui.handlers"> - <handler - class="de.prob.units.ui.StartUnitAnalysisHandler" - commandId="de.prob.units.startunitanalysis"> - </handler> - </extension> - <extension - point="org.eclipse.ui.menus"> - <menuContribution - locationURI="popup:fr.systerel.explorer.navigator.view"> - <separator - name="de.prob.units.separator2" - visible="true"> - </separator> - <command - commandId="de.prob.units.startunitanalysis" - icon="icons/unit_analysis.png" - label="Analyse Physical Units" - style="push"> - <visibleWhen> - <with - variable="selection"> - <iterate - operator="or"> - <or> - <instanceof - value="org.eventb.core.IMachineRoot"> - </instanceof> - <instanceof - value="org.eventb.core.IContextRoot"> - </instanceof> - </or> - </iterate> - </with> - </visibleWhen> - </command> - <separator - name="de.prob.units.separator1" - visible="true"> - </separator> - </menuContribution> - </extension> - <extension - point="org.eclipse.ui.commands"> - <command - id="de.prob.units.startunitanalysis" - name="Analyse Physical Units"> - </command> - </extension> - <extension - point="org.rodinp.core.attributeTypes"> - <attributeType - id="unitPragmaAttribute" - kind="string" - name="Content of a unit Pragma to send to ProB"> - </attributeType> - <attributeType - id="inferredUnitPragmaAttribute" - kind="string" - name="Content of a unit Pragma received from ProB"> - </attributeType> - </extension> - <extension - point="org.eventb.core.configurations"> - <configuration - id="mchBase" - name="mchBase"> - <scModule - id="de.prob.units.machineAttributeProcessor"> - </scModule> - <scModule - id="de.prob.units.contextAttributeProcessor"> - </scModule> - </configuration> - </extension> - <extension - id="scMachineModuleTypes" - point="org.eventb.core.scModuleTypes"> - <processorType - class="de.prob.units.sc.MachineAttributeProcessor" - id="machineAttributeProcessor" - name="machineAttributeProcessor" - parent="org.eventb.core.machineModule"> - </processorType> - <processorType - class="de.prob.units.sc.ContextAttributeProcessor" - id="contextAttributeProcessor" - name="contextAttributeProcessor" - parent="org.eventb.core.contextModule"> - </processorType> - </extension> -</plugin> diff --git a/de.prob.units/src/de/prob/units/Activator.java b/de.prob.units/src/de/prob/units/Activator.java deleted file mode 100644 index a867db55ff989f02df0adfa770760e0d69c1645f..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/Activator.java +++ /dev/null @@ -1,68 +0,0 @@ -package de.prob.units; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.rodinp.core.RodinCore; - - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "de.prob.units"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - setConfig(); - - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Registers a file configuration setter for our plugin. - */ - public static void setConfig() { - RodinCore.addElementChangedListener(new ConfSettor()); - } - -} diff --git a/de.prob.units/src/de/prob/units/ConfSettor.java b/de.prob.units/src/de/prob/units/ConfSettor.java deleted file mode 100644 index 3bcde7c95009dad497285fa05433eb6105b670f5..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/ConfSettor.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.prob.units; - -import org.eventb.core.IContextRoot; -import org.eventb.core.IMachineRoot; -import org.rodinp.core.ElementChangedEvent; -import org.rodinp.core.IElementChangedListener; -import org.rodinp.core.IElementType; -import org.rodinp.core.IInternalElement; -import org.rodinp.core.IRodinDB; -import org.rodinp.core.IRodinElement; -import org.rodinp.core.IRodinElementDelta; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.IRodinProject; -import org.rodinp.core.RodinDBException; - -/** - * Class that updates the configuration of files, to add the static checker - * modules for our qualitative probabilistic reasoning plug-in. - */ -public class ConfSettor implements IElementChangedListener { - - private static final String CONFIG = Activator.PLUGIN_ID + ".mchBase"; - - @Override - public void elementChanged(ElementChangedEvent event) { - - final IRodinElementDelta d = event.getDelta(); - try { - processDelta(d); - } catch (final RodinDBException e) { - // TODO add exception log - } - } - - private void processDelta(final IRodinElementDelta d) - throws RodinDBException { - final IRodinElement e = d.getElement(); - - final IElementType<? extends IRodinElement> elementType = e - .getElementType(); - if (elementType.equals(IRodinDB.ELEMENT_TYPE) - || elementType.equals(IRodinProject.ELEMENT_TYPE)) { - for (final IRodinElementDelta de : d.getAffectedChildren()) { - processDelta(de); - } - } else if (elementType.equals(IRodinFile.ELEMENT_TYPE)) { - final IInternalElement root = ((IRodinFile) e).getRoot(); - - if (root.getElementType().equals(IMachineRoot.ELEMENT_TYPE)) { - final IMachineRoot mch = (IMachineRoot) root; - final String conf = mch.getConfiguration(); - if (!conf.contains(CONFIG)) { - mch.setConfiguration(conf + ";" + CONFIG, null); - } - } - - if (root.getElementType().equals(IContextRoot.ELEMENT_TYPE)) { - final IContextRoot ctx = (IContextRoot) root; - final String conf = ctx.getConfiguration(); - if (!conf.contains(CONFIG)) { - ctx.setConfiguration(conf + ";" + CONFIG, null); - } - } - } - } -} \ No newline at end of file diff --git a/de.prob.units/src/de/prob/units/pragmas/InferredUnitPragmaAttribute.java b/de.prob.units/src/de/prob/units/pragmas/InferredUnitPragmaAttribute.java deleted file mode 100644 index 7991b26aa8c86ab39f22325977cca18ed5cfae60..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/pragmas/InferredUnitPragmaAttribute.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.units.pragmas; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eventb.core.IVariable; -import org.eventb.core.basis.Constant; -import org.eventb.ui.manipulation.IAttributeManipulation; -import org.rodinp.core.IAttributeType; -import org.rodinp.core.IInternalElement; -import org.rodinp.core.IRodinElement; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; - -import de.prob.units.Activator; - -public class InferredUnitPragmaAttribute implements IAttributeManipulation { - public static IAttributeType.String ATTRIBUTE = RodinCore - .getStringAttrType(Activator.PLUGIN_ID - + ".inferredUnitPragmaAttribute"); - - private final String defaultValue = ""; - - public InferredUnitPragmaAttribute() { - // empty constructor - } - - private IInternalElement asInternalElement(IRodinElement element) { - if (element instanceof IVariable) { - return (IVariable) element; - } else if (element instanceof Constant) { - return (Constant) element; - } - return null; - } - - @Override - public String[] getPossibleValues(IRodinElement element, - IProgressMonitor monitor) { - return null; - } - - @Override - public String getValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - try { - return asInternalElement(element).getAttributeValue(ATTRIBUTE); - } catch (RodinDBException ex) { - // happens if the attribute is not set on this element - // just return a default instead of throwing a RodinDBException - } - return defaultValue; - } - - @Override - public boolean hasValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - return asInternalElement(element).hasAttribute(ATTRIBUTE); - } - - @Override - public void removeAttribute(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - asInternalElement(element).removeAttribute(ATTRIBUTE, monitor); - - } - - @Override - public void setDefaultValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - asInternalElement(element).setAttributeValue(ATTRIBUTE, defaultValue, - monitor); - } - - @Override - public void setValue(IRodinElement element, String value, - IProgressMonitor monitor) throws RodinDBException { - asInternalElement(element).setAttributeValue(ATTRIBUTE, value, monitor); - } -} diff --git a/de.prob.units/src/de/prob/units/pragmas/UnitPragmaAttribute.java b/de.prob.units/src/de/prob/units/pragmas/UnitPragmaAttribute.java deleted file mode 100644 index cff957964d3d56a8c6a024e685ae64369c97ac7f..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/pragmas/UnitPragmaAttribute.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.units.pragmas; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eventb.core.IVariable; -import org.eventb.core.basis.Constant; -import org.eventb.ui.manipulation.IAttributeManipulation; -import org.rodinp.core.IAttributeType; -import org.rodinp.core.IInternalElement; -import org.rodinp.core.IRodinElement; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; - -import de.prob.units.Activator; - -public class UnitPragmaAttribute implements IAttributeManipulation { - public static IAttributeType.String ATTRIBUTE = RodinCore - .getStringAttrType(Activator.PLUGIN_ID + ".unitPragmaAttribute"); - - private final String defaultValue = ""; - - public UnitPragmaAttribute() { - // empty constructor - } - - private IInternalElement asInternalElement(IRodinElement element) { - if (element instanceof IVariable) { - return (IVariable) element; - } else if (element instanceof Constant) { - return (Constant) element; - } - return null; - } - - @Override - public String[] getPossibleValues(IRodinElement element, - IProgressMonitor monitor) { - return null; - } - - @Override - public String getValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - try { - return asInternalElement(element).getAttributeValue(ATTRIBUTE); - } catch (RodinDBException ex) { - // happens if the attribute is not set on this element - // just return a default instead of throwing a RodinDBException - } - return defaultValue; - } - - @Override - public boolean hasValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - return asInternalElement(element).hasAttribute(ATTRIBUTE); - } - - @Override - public void removeAttribute(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - asInternalElement(element).removeAttribute(ATTRIBUTE, monitor); - - } - - @Override - public void setDefaultValue(IRodinElement element, IProgressMonitor monitor) - throws RodinDBException { - asInternalElement(element).setAttributeValue(ATTRIBUTE, defaultValue, - monitor); - } - - @Override - public void setValue(IRodinElement element, String value, - IProgressMonitor monitor) throws RodinDBException { - asInternalElement(element).setAttributeValue(ATTRIBUTE, value, monitor); - } -} diff --git a/de.prob.units/src/de/prob/units/problems/IncorrectUnitDefinitionMarker.java b/de.prob.units/src/de/prob/units/problems/IncorrectUnitDefinitionMarker.java deleted file mode 100644 index d7f4e0e209b07a5e6672438eb9fb9ead979ee746..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/problems/IncorrectUnitDefinitionMarker.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.prob.units.problems; - -import org.eclipse.core.resources.IMarker; -import org.rodinp.core.IRodinProblem; - -import de.prob.units.Activator; - -public class IncorrectUnitDefinitionMarker implements IRodinProblem { - - private final String message; - private final int severity = IMarker.SEVERITY_ERROR; - public static final String ERROR_CODE = Activator.PLUGIN_ID + "." - + "incorrectUnitDefinition"; - - public IncorrectUnitDefinitionMarker(String cstOrVar) { - this.message = "Incorrect Unit Definition on Constant/Variable " - + cstOrVar; - } - - @Override - public String getErrorCode() { - return ERROR_CODE; - } - - @Override - public String getLocalizedMessage(Object[] arg0) { - return message; - } - - @Override - public int getSeverity() { - return severity; - } - -} diff --git a/de.prob.units/src/de/prob/units/problems/MultipleUnitsInferredMarker.java b/de.prob.units/src/de/prob/units/problems/MultipleUnitsInferredMarker.java deleted file mode 100644 index 3daaa97a0666685bec7b28970fa324f98cafe30c..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/problems/MultipleUnitsInferredMarker.java +++ /dev/null @@ -1,36 +0,0 @@ -package de.prob.units.problems; - -import org.eclipse.core.resources.IMarker; -import org.rodinp.core.IRodinProblem; - -import de.prob.units.Activator; - -public class MultipleUnitsInferredMarker implements IRodinProblem { - - private final String message; - private final int severity = IMarker.SEVERITY_ERROR; - - public static final String ERROR_CODE = Activator.PLUGIN_ID + "." - + "multipleUnitsInferred"; - - public MultipleUnitsInferredMarker(String cstOrVar) { - this.message = "Multiple Units inferred for Constant/Variable " - + cstOrVar; - } - - @Override - public String getErrorCode() { - return ERROR_CODE; - } - - @Override - public String getLocalizedMessage(Object[] arg0) { - return message; - } - - @Override - public int getSeverity() { - return severity; - } - -} diff --git a/de.prob.units/src/de/prob/units/problems/NoUnitInferredMarker.java b/de.prob.units/src/de/prob/units/problems/NoUnitInferredMarker.java deleted file mode 100644 index 8f011edccb79b26e67cd59da893354aa5d6a2830..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/problems/NoUnitInferredMarker.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.prob.units.problems; - -import org.eclipse.core.resources.IMarker; -import org.rodinp.core.IRodinProblem; - -import de.prob.units.Activator; - -public class NoUnitInferredMarker implements IRodinProblem { - - private final String message; - private final int severity = IMarker.SEVERITY_WARNING; - public static final String ERROR_CODE = Activator.PLUGIN_ID + "." - + "multipleUnitsInferred"; - - public NoUnitInferredMarker(String cstOrVar) { - this.message = "No Units inferred for Constant/Variable " + cstOrVar; - } - - @Override - public String getErrorCode() { - return ERROR_CODE; - } - - @Override - public String getLocalizedMessage(Object[] arg0) { - return message; - } - - @Override - public int getSeverity() { - return severity; - } - -} diff --git a/de.prob.units/src/de/prob/units/sc/ContextAttributeProcessor.java b/de.prob.units/src/de/prob/units/sc/ContextAttributeProcessor.java deleted file mode 100644 index 91b1fc7c6fddf08d2cab0741cb419fbff7e58b0f..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/sc/ContextAttributeProcessor.java +++ /dev/null @@ -1,72 +0,0 @@ -package de.prob.units.sc; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eventb.core.EventBAttributes; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.ISCConstant; -import org.eventb.core.ISCContextRoot; -import org.eventb.core.sc.SCCore; -import org.eventb.core.sc.SCProcessorModule; -import org.eventb.core.sc.state.ISCStateRepository; -import org.eventb.core.tool.IModuleType; -import org.rodinp.core.IInternalElement; -import org.rodinp.core.IRodinElement; -import org.rodinp.core.IRodinFile; - -import de.prob.units.Activator; -import de.prob.units.pragmas.UnitPragmaAttribute; - -public class ContextAttributeProcessor extends SCProcessorModule { - public static final IModuleType<ContextAttributeProcessor> MODULE_TYPE = SCCore - .getModuleType(Activator.PLUGIN_ID + ".contextAttributeProcessor"); //$NON-NLS-1$ - - @Override - public void process(IRodinElement element, IInternalElement target, - ISCStateRepository repository, IProgressMonitor monitor) - throws CoreException { - assert (element instanceof IRodinFile); - assert (target instanceof ISCContextRoot); - - // get all variables and copy over the attributes - IRodinFile contextFile = (IRodinFile) element; - IContextRoot contextRoot = (IContextRoot) contextFile.getRoot(); - - ISCContextRoot scContextRoot = (ISCContextRoot) target; - - IConstant[] constants = contextRoot.getConstants(); - ISCConstant[] scconstants = scContextRoot.getSCConstants(); - - if (constants.length == 0 || scconstants.length == 0) - return; - - for (IConstant constant : constants) { - String identifier = constant - .getAttributeValue(EventBAttributes.IDENTIFIER_ATTRIBUTE); - ISCConstant scConstant = scContextRoot.getSCConstant(identifier); - - // might have been filtered out by previous modules - if (scConstant.exists()) { - // original might not contain the attribute - if (constant.hasAttribute(UnitPragmaAttribute.ATTRIBUTE)) { - String attribute = constant - .getAttributeValue(UnitPragmaAttribute.ATTRIBUTE); - - attribute = UnitAttributeProcessorStatics - .translateEventBPragmaToBPragma(attribute); - - scConstant.setAttributeValue(UnitPragmaAttribute.ATTRIBUTE, - attribute, monitor); - } - } - } - - } - - @Override - public IModuleType<?> getModuleType() { - return MODULE_TYPE; - } - -} diff --git a/de.prob.units/src/de/prob/units/sc/MachineAttributeProcessor.java b/de.prob.units/src/de/prob/units/sc/MachineAttributeProcessor.java deleted file mode 100644 index 2b64a2e5dab0423d495e03e85312b3cee041d145..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/sc/MachineAttributeProcessor.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.prob.units.sc; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eventb.core.IMachineRoot; -import org.eventb.core.ISCMachineRoot; -import org.eventb.core.ISCVariable; -import org.eventb.core.IVariable; -import org.eventb.core.sc.SCCore; -import org.eventb.core.sc.SCProcessorModule; -import org.eventb.core.sc.state.ISCStateRepository; -import org.eventb.core.tool.IModuleType; -import org.rodinp.core.IInternalElement; -import org.rodinp.core.IRodinElement; -import org.rodinp.core.IRodinFile; - -import de.prob.units.Activator; -import de.prob.units.pragmas.UnitPragmaAttribute; - -public class MachineAttributeProcessor extends SCProcessorModule { - public static final IModuleType<MachineAttributeProcessor> MODULE_TYPE = SCCore - .getModuleType(Activator.PLUGIN_ID + ".machineAttributeProcessor"); //$NON-NLS-1$ - - @Override - public void process(IRodinElement element, IInternalElement target, - ISCStateRepository repository, IProgressMonitor monitor) - throws CoreException { - assert (element instanceof IRodinFile); - assert (target instanceof ISCMachineRoot); - - // get all variables and copy over the attributes - IRodinFile machineFile = (IRodinFile) element; - IMachineRoot machineRoot = (IMachineRoot) machineFile.getRoot(); - - ISCMachineRoot scMachineRoot = (ISCMachineRoot) target; - - IVariable[] variables = machineRoot.getVariables(); - - if (variables.length == 0) - return; - - for (IVariable var : variables) { - String identifier = var.getIdentifierString(); - ISCVariable scVar = scMachineRoot.getSCVariable(identifier); - - // might have been filtered out by previous modules - if (scVar.exists()) { - // original might not contain the attribute - if (var.hasAttribute(UnitPragmaAttribute.ATTRIBUTE)) { - String attribute = var - .getAttributeValue(UnitPragmaAttribute.ATTRIBUTE); - - attribute = UnitAttributeProcessorStatics - .translateEventBPragmaToBPragma(attribute); - - scVar.setAttributeValue(UnitPragmaAttribute.ATTRIBUTE, - attribute, monitor); - } - } - } - - } - - @Override - public IModuleType<?> getModuleType() { - return MODULE_TYPE; - } - -} diff --git a/de.prob.units/src/de/prob/units/sc/UnitAttributeProcessorStatics.java b/de.prob.units/src/de/prob/units/sc/UnitAttributeProcessorStatics.java deleted file mode 100644 index 4e819dad2fc094f1ef109c66e8efe1e468a3fefc..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/sc/UnitAttributeProcessorStatics.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.prob.units.sc; - -public class UnitAttributeProcessorStatics { - static String translateEventBPragmaToBPragma(String eventBPragma) { - String bPragma = eventBPragma.replace("^", "**"); - return bPragma; - } - -} diff --git a/de.prob.units/src/de/prob/units/ui/StartUnitAnalysisHandler.java b/de.prob.units/src/de/prob/units/ui/StartUnitAnalysisHandler.java deleted file mode 100644 index 549a56f902eea225bcde5ba825cc6b74d69111e7..0000000000000000000000000000000000000000 --- a/de.prob.units/src/de/prob/units/ui/StartUnitAnalysisHandler.java +++ /dev/null @@ -1,384 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.units.ui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eventb.core.IConstant; -import org.eventb.core.IContextRoot; -import org.eventb.core.IEventBRoot; -import org.eventb.core.IMachineRoot; -import org.eventb.core.IVariable; -import org.rodinp.core.IRodinFile; -import org.rodinp.core.RodinCore; -import org.rodinp.core.RodinDBException; -import org.rodinp.core.RodinMarkerUtil; - -import de.prob.core.Animator; -import de.prob.core.LimitedLogger; -import de.prob.core.command.ActivateUnitPluginCommand; -import de.prob.core.command.ClearMachineCommand; -import de.prob.core.command.CommandException; -import de.prob.core.command.ComposedCommand; -import de.prob.core.command.GetPluginResultCommand; -import de.prob.core.command.SetPreferencesCommand; -import de.prob.core.command.StartAnimationCommand; -import de.prob.core.command.internal.InternalLoadCommand; -import de.prob.exceptions.ProBException; -import de.prob.logging.Logger; -import de.prob.parser.BindingGenerator; -import de.prob.parser.ResultParserException; -import de.prob.prolog.term.CompoundPrologTerm; -import de.prob.prolog.term.ListPrologTerm; -import de.prob.prolog.term.PrologTerm; -import de.prob.units.pragmas.InferredUnitPragmaAttribute; -import de.prob.units.pragmas.UnitPragmaAttribute; -import de.prob.units.problems.IncorrectUnitDefinitionMarker; -import de.prob.units.problems.MultipleUnitsInferredMarker; -import de.prob.units.problems.NoUnitInferredMarker; - -public class StartUnitAnalysisHandler extends AbstractHandler implements - IHandler { - - public static class ModificationListener implements IResourceChangeListener { - - private final IPath path; - - public ModificationListener(final IFile resource) { - if (resource == null) { - path = null; - } else { - this.path = resource.getProject().getFullPath(); - } - } - - @Override - public void resourceChanged(final IResourceChangeEvent event) { - if (path != null) { - final IResourceDelta delta = event.getDelta(); - IResourceDelta member = delta.findMember(path); - if (member != null) { - Animator.getAnimator().setDirty(); - } - } - } - } - - private ISelection fSelection; - private ModificationListener listener; - - @Override - public Object execute(final ExecutionEvent event) throws ExecutionException { - - fSelection = HandlerUtil.getCurrentSelection(event); - - // Get the Selection - final IEventBRoot rootElement = getRootElement(); - final IFile resource = extractResource(rootElement); - - removeUnitErrorMarkers(resource); - - ArrayList<String> errors = new ArrayList<String>(); - boolean realError = checkErrorMarkers(resource, errors); - if (!errors.isEmpty()) { - String message = "Some components in your project contain " - + (realError ? "errors" : "warnings") - + ". This can lead to unexpected behavior (e.g. missing variables) when animating.\n\nDetails:\n"; - StringBuffer stringBuffer = new StringBuffer(message); - for (String string : errors) { - stringBuffer.append(string); - stringBuffer.append('\n'); - } - if (realError) - Logger.notifyUserWithoutBugreport(stringBuffer.toString()); - else - Logger.notifyUserAboutWarningWithoutBugreport(stringBuffer - .toString()); - } - ; - - if (resource != null) { - LimitedLogger.getLogger().log("user started unit analysis", - rootElement.getElementName(), null); - registerModificationListener(resource); - - final Animator animator = Animator.getAnimator(); - try { - // load machine and activate plugin - final ClearMachineCommand clear = new ClearMachineCommand(); - final SetPreferencesCommand setPrefs = SetPreferencesCommand - .createSetPreferencesCommand(animator); - final InternalLoadCommand load = new InternalLoadCommand( - rootElement); - final StartAnimationCommand start = new StartAnimationCommand(); - final ActivateUnitPluginCommand activatePlugin = new ActivateUnitPluginCommand(); - - GetPluginResultCommand pluginResultCommand = new GetPluginResultCommand( - "Grounded Result State"); - - final ComposedCommand composed = new ComposedCommand(clear, - setPrefs, load, start, activatePlugin, - pluginResultCommand); - - animator.execute(composed); - processResults(pluginResultCommand.getResult()); - } catch (ProBException e) { - e.notifyUserOnce(); - throw new ExecutionException("Unit Analysis Failed", e); - } catch (RodinDBException e) { - throw new ExecutionException( - "Unit Analysis Failed with a RodinDBException", e); - } - } - return null; - } - - private void removeUnitErrorMarkers(final IFile resource) { - IProject project = resource.getProject(); - try { - IMarker[] markers = project.findMarkers( - "org.eclipse.core.resources.problemmarker", true, - IResource.DEPTH_INFINITE); - for (IMarker iMarker : markers) { - if (iMarker.getAttribute(RodinMarkerUtil.ERROR_CODE, "") - .equals(MultipleUnitsInferredMarker.ERROR_CODE)) { - iMarker.delete(); - } - if (iMarker.getAttribute(RodinMarkerUtil.ERROR_CODE, "") - .equals(IncorrectUnitDefinitionMarker.ERROR_CODE)) { - iMarker.delete(); - } - if (iMarker.getAttribute(RodinMarkerUtil.ERROR_CODE, "") - .equals(NoUnitInferredMarker.ERROR_CODE)) { - iMarker.delete(); - } - } - - } catch (CoreException e1) { - } - } - - private boolean checkErrorMarkers(final IFile resource, List<String> errors) { - boolean result = false; - IProject project = resource.getProject(); - try { - IMarker[] markers = project.findMarkers( - "org.eclipse.core.resources.problemmarker", true, - IResource.DEPTH_INFINITE); - for (IMarker iMarker : markers) { - errors.add(iMarker.getResource().getName() - + ": " - + iMarker - .getAttribute(IMarker.MESSAGE, "unknown Error")); - result = result - || (Integer) iMarker.getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR; - } - - } catch (CoreException e1) { - } - return result; - } - - private void processResults(CompoundPrologTerm result) - throws RodinDBException, ExecutionException { - // preprocess the list into a map - Map<String, String> variables = new HashMap<String, String>(); - List<String> offendingDefinitions = new ArrayList<String>(); - - ListPrologTerm liste = BindingGenerator.getList(result.getArgument(1)); - - for (PrologTerm term : liste) { - if (term.isAtom()) { - // this is an error message. do something about it. - String offendingUnitDefinition = PrologTerm.atomicString(term) - .replace("Incorrect unit definition: ['", ""); - offendingUnitDefinition = offendingUnitDefinition.replace("']", - ""); - - // add error to the list of incorrect definitions. error markers - // will be attached later - offendingDefinitions.add(offendingUnitDefinition); - - } else { - // process inferred units and add to map - CompoundPrologTerm compoundTerm; - try { - compoundTerm = BindingGenerator.getCompoundTerm(term, - "bind", 2); - - variables.put(PrologTerm.atomicString(compoundTerm - .getArgument(1)), PrologTerm - .atomicString(compoundTerm.getArgument(2))); - } catch (ResultParserException e) { - CommandException commandException = new CommandException( - e.getLocalizedMessage(), e); - commandException.notifyUserOnce(); - } - } - } - - IEventBRoot rootElement = getRootElement(); - // look up the variables / constants of the selected machine in - // the state - // and set the inferredUnitPragma attribute - if (rootElement instanceof IMachineRoot) { - // find and update variables - IVariable[] allVariables = rootElement.getMachineRoot() - .getVariables(); - for (IVariable var : allVariables) { - // reset inferred unit - var.setAttributeValue(InferredUnitPragmaAttribute.ATTRIBUTE, - "", new NullProgressMonitor()); - - String variableName = var.getIdentifierString(); - if (variables.containsKey(variableName)) { - var.setAttributeValue( - InferredUnitPragmaAttribute.ATTRIBUTE, - variables.get(variableName), - new NullProgressMonitor()); - - if (variables.get(variableName).startsWith("multiple")) { - var.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new MultipleUnitsInferredMarker(variableName)); - } - if (variables.get(variableName).equals("unknown")) { - var.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new NoUnitInferredMarker(variableName)); - } - } - - // check if the attached unit pragma (given by user) was marked - // as offending - if (var.hasAttribute(UnitPragmaAttribute.ATTRIBUTE)) { - if (offendingDefinitions.contains(var - .getAttributeValue(UnitPragmaAttribute.ATTRIBUTE))) { - var.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new IncorrectUnitDefinitionMarker(variableName)); - } - } - } - - } else if (rootElement instanceof IContextRoot) { - // find and update constants - IConstant[] allConstants = rootElement.getContextRoot() - .getConstants(); - - for (IConstant cst : allConstants) { - // reset inferred unit - cst.setAttributeValue(InferredUnitPragmaAttribute.ATTRIBUTE, - "", new NullProgressMonitor()); - - String constantName = cst.getIdentifierString(); - if (variables.containsKey(constantName)) { - cst.setAttributeValue( - InferredUnitPragmaAttribute.ATTRIBUTE, - variables.get(constantName), - new NullProgressMonitor()); - - if (variables.get(constantName).equals("error")) { - cst.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new MultipleUnitsInferredMarker(constantName)); - } - if (variables.get(constantName).equals("unknown")) { - cst.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new IncorrectUnitDefinitionMarker(constantName)); - } - } - - // check if the attached unit pragma (given by user) was marked - // as offending - if (cst.hasAttribute(UnitPragmaAttribute.ATTRIBUTE)) { - if (offendingDefinitions.contains(cst - .getAttributeValue(UnitPragmaAttribute.ATTRIBUTE))) { - cst.createProblemMarker( - InferredUnitPragmaAttribute.ATTRIBUTE, - new MultipleUnitsInferredMarker(constantName)); - } - } - } - } else { - throw new ExecutionException( - "Cannot execute unit analysis on this element type. Type of " - + rootElement.getComponentName() + " was: " - + rootElement.getClass()); - } - } - - private IEventBRoot getRootElement() { - IEventBRoot root = null; - if (fSelection instanceof IStructuredSelection) { - final IStructuredSelection ssel = (IStructuredSelection) fSelection; - if (ssel.size() == 1) { - final Object element = ssel.getFirstElement(); - if (element instanceof IEventBRoot) { - root = (IEventBRoot) element; - } else if (element instanceof IFile) { - IRodinFile rodinFile = RodinCore.valueOf((IFile) element); - if (rodinFile != null) - root = (IEventBRoot) rodinFile.getRoot(); - } - } - } - return root; - } - - private IFile extractResource(final IEventBRoot rootElement) { - IFile resource = null; - if (rootElement == null) { - resource = null; - } else if (rootElement instanceof IMachineRoot) { - resource = ((IMachineRoot) rootElement).getSCMachineRoot() - .getResource(); - } else if (rootElement instanceof IContextRoot) { - resource = ((IContextRoot) rootElement).getSCContextRoot() - .getResource(); - } - return resource; - } - - private void registerModificationListener(final IFile resource) { - if (listener != null) { - ResourcesPlugin.getWorkspace().removeResourceChangeListener( - listener); - } - listener = new ModificationListener(resource); - ResourcesPlugin.getWorkspace().addResourceChangeListener(listener); - } - - public void selectionChanged(final IAction action, - final ISelection selection) { - fSelection = selection; - } - -} diff --git a/de.prob2.disprover.feature/feature.xml b/de.prob2.disprover.feature/feature.xml index f31df8800fb762d5e60da20f1510b744ed9f5835..80963ed853848246baef9ac436e7882727ca7fcc 100644 --- a/de.prob2.disprover.feature/feature.xml +++ b/de.prob2.disprover.feature/feature.xml @@ -1,36 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> <feature id="de.prob2.disprover.feature" - label="ProB for Rodin3 - EXPERIMENTAL (Dis)Prover" - version="3.0.8.qualifier" + label="ProB for Rodin3 - (Dis)Prover" + version="3.0.11.qualifier" provider-name="HHU Düsseldorf STUPS Group"> <description url="http://www.stups.uni-duesseldorf.de/ProB"> ProB is an animator and model checker for the B-Method. It allows fully automatic animation of many B specifications, and can be -used to systematically check a specification for errors. +used to systematically check a specification for errors. Part of the research and development was conducted within the EPSRC funded projects ABCD and iMoc, and within the EU funded -project Rodin. -Development is continued under the EU funded project Deploy and -the DFG project Gepavas. +projects Rodin and Deploy and the DFG projects Gepavas and Gepavas II. ProB has been successfully used on various industrial specifications -and is now being used within Siemens. +and is now being used e.g. within Siemens, Alstom, Thales and ClearSy. </description> <copyright> - (C) 2000-2011 Michael Leuschel (and many others) All rights reserved. + (C) 2000-2020 Michael Leuschel (and many others) All rights reserved. </copyright> <license url="http://www.eclipse.org/org/documents/epl-v10.html"> ProB can be used freely for commercial, non-commercial and academic -use under the Eclipse Public Licence v. 1.0. (below) +use under the Eclipse Public Licence v. 1.0. (below) For availability of commercial support, please contact the author -(http://www.stups.uni-duesseldorf.de/~leuschel). +(http://www.stups.uni-duesseldorf.de/~leuschel). Use of ProB's nauty library for symmetry reduction implies further restrictions (no applications with nontrivial military significance, see http://cs.anu.edu.au/~bdm/nauty/). ---- +--- Eclipse Public License - v. 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR @@ -231,16 +229,16 @@ litigation. <requires> <import plugin="org.eclipse.core.runtime" version="3.5.0" match="compatible"/> - <import plugin="de.prob.core" version="9.4.0" match="equivalent"/> + <import plugin="de.prob.core" version="9.4.5" match="equivalent"/> <import plugin="org.eventb.core.seqprover" version="3.0.0"/> <import plugin="org.eventb.core" version="3.0.0"/> <import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/> <import plugin="org.eventb.core.ast" version="3.0.0"/> - <import plugin="org.rodinp.core" version="1.7.0" match="equivalent"/> + <import plugin="org.rodinp.core" version="1.7.0" match="compatible"/> <import plugin="org.eventb.ui" version="3.0.0"/> <import plugin="org.eclipse.osgi"/> - <import plugin="de.prob.ui" version="7.4.0" match="greaterOrEqual"/> - <import plugin="de.prob.eventb.disprover.core" version="2.0.0" match="equivalent"/> + <import plugin="de.prob.ui" version="7.4.3" match="equivalent"/> + <import plugin="de.prob.eventb.disprover.core" version="2.0.6" match="equivalent"/> </requires> <plugin diff --git a/de.prob2.feature/feature.xml b/de.prob2.feature/feature.xml index 4f63793dcdc2c14a4d0028d7b0cabd6212f6da49..96ec562922f32b8d712bd2fdbfd6ca1e95d2e1bf 100644 --- a/de.prob2.feature/feature.xml +++ b/de.prob2.feature/feature.xml @@ -2,18 +2,22 @@ <feature id="de.prob2.feature" label="ProB for Rodin3" - version="3.0.8.qualifier" + version="3.0.11.qualifier" provider-name="HHU Düsseldorf STUPS Group"> <description url="http://www.stups.uni-duesseldorf.de/ProB"> - ProB is an animator and model checker for the B-Method. It allows fully automatic animation of many B specifications, and can be used to systematically check a specification for errors. -Part of the research and development was conducted within the EPSRC funded projects ABCD and iMoc, and within the EU funded project Rodin. -Development is continued under the EU funded project Deploy and the DFG project Gepavas. -ProB has been successfully used on various industrial specifications and is now being used within Siemens. + ProB is an animator and model checker for the B-Method. It allows +fully automatic animation of many B specifications, and can be +used to systematically check a specification for errors. +Part of the research and development was conducted within the +EPSRC funded projects ABCD and iMoc, and within the EU funded +projects Rodin and Deploy and the DFG projects Gepavas and Gepavas II. +ProB has been successfully used on various industrial specifications +and is now being used within Siemens, Alstom, Thales. </description> <copyright> - (C) 2000-2011 Michael Leuschel (and many others) All rights reserved. + (C) 2000-2020 Michael Leuschel (and many others) All rights reserved. </copyright> <license url="http://www.eclipse.org/org/documents/epl-v10.html"> @@ -228,21 +232,21 @@ litigation. <import plugin="org.eclipse.ui.ide" version="3.5.0" match="compatible"/> <import plugin="org.eclipse.core.runtime" version="3.5.0" match="compatible"/> <import plugin="org.eclipse.gef" version="3.7.0" match="compatible"/> - <import plugin="de.prob.core" version="9.4.0" match="equivalent"/> + <import plugin="de.prob.core" version="9.4.5" match="equivalent"/> <import plugin="org.eventb.core" version="3.0.0"/> <import plugin="org.eclipse.core.resources" version="3.5.0" match="compatible"/> - <import plugin="org.rodinp.core" version="1.7.0" match="equivalent"/> + <import plugin="org.rodinp.core" version="1.7.0" match="compatible"/> <import plugin="org.eventb.core.ast" version="3.0.0"/> <import plugin="org.eventb.core.seqprover" version="3.0.0"/> - <import plugin="de.prob.ui" version="7.4.0" match="equivalent"/> + <import plugin="de.prob.ui" version="7.4.3" match="equivalent"/> <import plugin="org.eclipse.core.expressions" version="3.4.101" match="compatible"/> <import plugin="org.eclipse.ui.views" version="3.5.0" match="compatible"/> <import plugin="org.eclipse.core.databinding" version="1.2.0" match="compatible"/> <import plugin="org.eclipse.jface.databinding" version="1.2.1" match="compatible"/> <import plugin="org.eclipse.core.databinding.beans" version="1.1.1" match="compatible"/> - <import plugin="org.eclipse.help" version="3.5.100" match="greaterOrEqual"/> - <import plugin="org.eclipse.ui.navigator" version="3.5.0" match="greaterOrEqual"/> - <import plugin="de.bmotionstudio.gef.editor" version="5.5.0" match="equivalent"/> + <import plugin="org.eclipse.help" version="3.5.100" match="compatible"/> + <import plugin="org.eclipse.ui.navigator" version="3.5.0" match="compatible"/> + <import plugin="de.bmotionstudio.gef.editor" version="5.5.1" match="equivalent"/> </requires> <plugin diff --git a/de.prob2.symbolic.feature/feature.xml b/de.prob2.symbolic.feature/feature.xml index e02e10ac1402d008b6b0c0922d43c5980a6c8ea4..270272d25bc5345bd8f87350c16d775a775b1e9d 100644 --- a/de.prob2.symbolic.feature/feature.xml +++ b/de.prob2.symbolic.feature/feature.xml @@ -2,35 +2,33 @@ <feature id="de.prob2.symbolic.feature" label="ProB for Rodin3 - Symbolic Constants Support" - version="3.0.8.qualifier" + version="3.0.11.qualifier" provider-name="HHU Düsseldorf STUPS Group"> <description url="http://www.stups.uni-duesseldorf.de/ProB"> ProB is an animator and model checker for the B-Method. It allows fully automatic animation of many B specifications, and can be -used to systematically check a specification for errors. +used to systematically check a specification for errors. Part of the research and development was conducted within the EPSRC funded projects ABCD and iMoc, and within the EU funded -project Rodin. -Development is continued under the EU funded project Deploy and -the DFG project Gepavas. +projects Rodin and Deploy and the DFG projects Gepavas and Gepavas II. ProB has been successfully used on various industrial specifications -and is now being used within Siemens. +and is now being used within Siemens, Alstom, Thales. </description> <copyright> - (C) 2000-2011 Michael Leuschel (and many others) All rights reserved. + (C) 2000-2020 Michael Leuschel (and many others) All rights reserved. </copyright> <license url="http://www.eclipse.org/org/documents/epl-v10.html"> ProB can be used freely for commercial, non-commercial and academic -use under the Eclipse Public Licence v. 1.0. (below) +use under the Eclipse Public Licence v. 1.0. (below) For availability of commercial support, please contact the author -(http://www.stups.uni-duesseldorf.de/~leuschel). +(http://www.stups.uni-duesseldorf.de/~leuschel). Use of ProB's nauty library for symmetry reduction implies further restrictions (no applications with nontrivial military significance, see http://cs.anu.edu.au/~bdm/nauty/). ---- +--- Eclipse Public License - v. 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR @@ -231,9 +229,9 @@ litigation. <requires> <import plugin="org.eclipse.core.runtime"/> - <import plugin="de.prob.core" version="9.4.0" match="equivalent"/> - <import plugin="de.prob.ui" version="7.4.0" match="equivalent"/> - <import plugin="org.rodinp.core" version="1.7.0" match="equivalent"/> + <import plugin="de.prob.core" version="9.4.5" match="equivalent"/> + <import plugin="de.prob.ui" version="7.4.3" match="equivalent"/> + <import plugin="org.rodinp.core" version="1.7.0" match="compatible"/> <import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/> <import plugin="org.eventb.core" version="3.0.0"/> <import plugin="org.eventb.ui" version="3.0.0"/> diff --git a/de.prob2.units.feature/.project b/de.prob2.units.feature/.project deleted file mode 100644 index 96b7c78653fba0643a8efc26c06b6a3f61c66bd7..0000000000000000000000000000000000000000 --- a/de.prob2.units.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>de.prob2.units.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.prob2.units.feature/.settings/org.eclipse.core.resources.prefs b/de.prob2.units.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index ae8dfb5865c1107f8366e1e8c2af6ad2d1a7a9f1..0000000000000000000000000000000000000000 --- a/de.prob2.units.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Nov 29 16:17:25 CET 2011 -eclipse.preferences.version=1 -encoding/<project>=UTF-8 diff --git a/de.prob2.units.feature/.settings/org.eclipse.core.runtime.prefs b/de.prob2.units.feature/.settings/org.eclipse.core.runtime.prefs deleted file mode 100644 index 57a8ae0b2a629cab658cebb8c79bd02f33f25fb0..0000000000000000000000000000000000000000 --- a/de.prob2.units.feature/.settings/org.eclipse.core.runtime.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Nov 29 16:17:25 CET 2011 -eclipse.preferences.version=1 -line.separator=\n diff --git a/de.prob2.units.feature/build.properties b/de.prob2.units.feature/build.properties deleted file mode 100644 index 64f93a9f0b7328eb563aa5ad6cec7f828020e124..0000000000000000000000000000000000000000 --- a/de.prob2.units.feature/build.properties +++ /dev/null @@ -1 +0,0 @@ -bin.includes = feature.xml diff --git a/de.prob2.units.feature/feature.xml b/de.prob2.units.feature/feature.xml deleted file mode 100644 index 5a1514b4ba4c0bd6be0c7ebd9b5becb1b2a63dbb..0000000000000000000000000000000000000000 --- a/de.prob2.units.feature/feature.xml +++ /dev/null @@ -1,246 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feature - id="de.prob2.units.feature" - label="ProB for Rodin3 - Physical Units Support" - version="3.0.8.qualifier" - provider-name="HHU Düsseldorf STUPS Group"> - - <description url="http://www.stups.uni-duesseldorf.de/ProB"> - ProB is an animator and model checker for the B-Method. It allows fully automatic animation of many B specifications, and can be used to systematically check a specification for errors. -Part of the research and development was conducted within the EPSRC funded projects ABCD and iMoc, and within the EU funded project Rodin. -Development is continued under the EU funded project Deploy and the DFG project Gepavas. -ProB has been successfully used on various industrial specifications and is now being used within Siemens. - </description> - - <copyright> - (C) 2000-2011 Michael Leuschel (and many others) All rights reserved. - </copyright> - - <license url="http://www.eclipse.org/org/documents/epl-v10.html"> - ProB can be used freely for commercial, non-commercial and academic -use under the Eclipse Public Licence v. 1.0. (below) -For availability of commercial support, please contact the author -(http://www.stups.uni-duesseldorf.de/~leuschel). -Use of ProB's nauty library for symmetry reduction implies further -restrictions (no applications with nontrivial military significance, -see http://cs.anu.edu.au/~bdm/nauty/). ---- -Eclipse Public License - v. 1.0 -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS -ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR -DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT. -1. DEFINITIONS -"Contribution" means: -a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and -b) in the case of each subsequent Contributor: -i) changes to the Program, and -ii) additions to the Program; -where such changes and/or additions to the Program originate -from and are distributed by that particular Contributor. A Contribution -'originates' from a Contributor if it was added to the Program -by such Contributor itself or anyone acting on such Contributor's -behalf. Contributions do not include additions to the Program -which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) -are not derivative works of the Program. -"Contributor" means any person or entity that distributes the -Program. -"Licensed Patents" mean patent claims licensable by a Contributor -which are necessarily infringed by the use or sale of its Contribution -alone or when combined with the Program. -"Program" means the Contributions distributed in accordance with -this Agreement. -"Recipient" means anyone who receives the Program under this -Agreement, including all Contributors. -2. GRANT OF RIGHTS -a) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free copyright -license to reproduce, prepare derivative works of, publicly display, -publicly perform, distribute and sublicense the Contribution -of such Contributor, if any, and such derivative works, in source -code and object code form. -b) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free patent -license under Licensed Patents to make, use, sell, offer to sell, -import and otherwise transfer the Contribution of such Contributor, -if any, in source code and object code form. This patent license -shall apply to the combination of the Contribution and the Program -if, at the time the Contribution is added by the Contributor, -such addition of the Contribution causes such combination to -be covered by the Licensed Patents. The patent license shall -not apply to any other combinations which include the Contribution. -No hardware per se is licensed hereunder. -c) Recipient understands that although each Contributor grants -the licenses to its Contributions set forth herein, no assurances -are provided by any Contributor that the Program does not infringe -the patent or other intellectual property rights of any other -entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement -of intellectual property rights or otherwise. As a condition -to exercising the rights and licenses granted hereunder, each -Recipient hereby assumes sole responsibility to secure any other -intellectual property rights needed, if any. For example, if -a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire -that license before distributing the Program. -d) Each Contributor represents that to its knowledge it has sufficient -copyright rights in its Contribution, if any, to grant the copyright -license set forth in this Agreement. -3. REQUIREMENTS -A Contributor may choose to distribute the Program in object -code form under its own license agreement, provided that: -a) it complies with the terms and conditions of this Agreement; -and -b) its license agreement: -i) effectively disclaims on behalf of all Contributors all warranties -and conditions, express and implied, including warranties or -conditions of title and non-infringement, and implied warranties -or conditions of merchantability and fitness for a particular -purpose; -ii) effectively excludes on behalf of all Contributors all liability -for damages, including direct, indirect, special, incidental -and consequential damages, such as lost profits; -iii) states that any provisions which differ from this Agreement -are offered by that Contributor alone and not by any other party; -and -iv) states that source code for the Program is available from -such Contributor, and informs licensees how to obtain it in a -reasonable manner on or through a medium customarily used for -software exchange. -When the Program is made available in source code form: -a) it must be made available under this Agreement; and -b) a copy of this Agreement must be included with each copy of -the Program. -Contributors may not remove or alter any copyright notices contained -within the Program. -Each Contributor must identify itself as the originator of its -Contribution, if any, in a manner that reasonably allows subsequent -Recipients to identify the originator of the Contribution. -4. COMMERCIAL DISTRIBUTION -Commercial distributors of software may accept certain responsibilities -with respect to end users, business partners and the like. While -this license is intended to facilitate the commercial use of -the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create -potential liability for other Contributors. Therefore, if a Contributor -includes the Program in a commercial product offering, such Contributor -("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any -losses, damages and costs (collectively "Losses") arising from -claims, lawsuits and other legal actions brought by a third party -against the Indemnified Contributor to the extent caused by the -acts or omissions of such Commercial Contributor in connection -with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any -claims or Losses relating to any actual or alleged intellectual -property infringement. In order to qualify, an Indemnified Contributor -must: a) promptly notify the Commercial Contributor in writing -of such claim, and b) allow the Commercial Contributor to control, -and cooperate with the Commercial Contributor in, the defense -and any related settlement negotiations. The Indemnified Contributor -may participate in any such claim at its own expense. -For example, a Contributor might include the Program in a commercial -product offering, Product X. That Contributor is then a Commercial -Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Contributor's responsibility -alone. Under this section, the Commercial Contributor would have -to defend claims against the other Contributors related to those -performance claims and warranties, and if a court requires any -other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. -5. NO WARRANTY -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM -IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS -OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, -ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY -OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with -its exercise of rights under this Agreement , including but not -limited to the risks and costs of program errors, compliance -with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations. -6. DISCLAIMER OF LIABILITY -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT -NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE -OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGES. -7. GENERAL -If any provision of this Agreement is invalid or unenforceable -under applicable law, it shall not affect the validity or enforceability -of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be -reformed to the minimum extent necessary to make such provision -valid and enforceable. -If Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging -that the Program itself (excluding combinations of the Program -with other software or hardware) infringes such Recipient's patent(s), -then such Recipient's rights granted under Section 2(b) shall -terminate as of the date such litigation is filed. -All Recipient's rights under this Agreement shall terminate if -it fails to comply with any of the material terms or conditions -of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If -all Recipient's rights under this Agreement terminate, Recipient -agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under -this Agreement and any licenses granted by Recipient relating -to the Program shall continue and survive. -Everyone is permitted to copy and distribute copies of this Agreement, -but in order to avoid inconsistency the Agreement is copyrighted -and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including -revisions) of this Agreement from time to time. No one other -than the Agreement Steward has the right to modify this Agreement. -The Eclipse Foundation is the initial Agreement Steward. The -Eclipse Foundation may assign the responsibility to serve as -the Agreement Steward to a suitable separate entity. Each new -version of the Agreement will be given a distinguishing version -number. The Program (including Contributions) may always be distributed -subject to the version of the Agreement under which it was received. -In addition, after a new version of the Agreement is published, -Contributor may elect to distribute the Program (including its -Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights -or licenses to the intellectual property of any Contributor under -this Agreement, whether expressly, by implication, estoppel or -otherwise. All rights in the Program not expressly granted under -this Agreement are reserved. -This Agreement is governed by the laws of the State of New York -and the intellectual property laws of the United States of America. -No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. -Each party waives its rights to a jury trial in any resulting -litigation. - </license> - - <requires> - <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.core.commands"/> - <import plugin="org.eclipse.core.resources"/> - <import plugin="org.eclipse.jface"/> - <import plugin="org.rodinp.core" version="1.7.0" match="equivalent"/> - <import plugin="de.prob.core" version="9.4.0" match="equivalent"/> - <import plugin="de.prob.ui" version="7.4.0" match="equivalent"/> - <import plugin="org.eventb.core" version="3.0.0"/> - <import plugin="org.eclipse.ui.workbench"/> - <import plugin="org.eventb.ui" version="3.0.0"/> - </requires> - - <plugin - id="de.prob.units" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - -</feature> diff --git a/footer.html b/footer.html new file mode 100644 index 0000000000000000000000000000000000000000..d14daf62e087899cc92f3ecd50619be7a8d4eb1e --- /dev/null +++ b/footer.html @@ -0,0 +1,15 @@ +<h1>Installing the ProB plug-ins</h1> +<p>Please use the Rodin update manager to install the plug-ins.</p> +<ol> + <li>Select from main menu: <em>Help | Install New Software...</em></li> + <li> + Under <em>Work with</em>, select the ProB repository. If it isn't listed, add a new repository using the URL<br/> + <em>https://stups.hhu-hosting.de/rodin/prob1/release/</em> + </li> + <li>Select the plug-ins you want to install and follow the dialog.</li> +</ol> +<p> + Queries? Please contact: Heinrich-Heine-University, Software und Programmiersprachen: + <a href="https://www.cs.hhu.de/en/research-groups/software-engineering-and-programming-languages" target="_blank">To Website</a>. + <a href="https://www.hhu.de/datenschutzerklaerung">Privacy Policy (Datenschutz)</a>. +</p> diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 86d03e620e10bd050d55765e478e85cea41d219d..c1962a79e29d3e0ab67b14947c167a862655af9b 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index de4eadbe7130080e8248706dec49b276242b8284..37aef8d3f0c9fffa920a8290320a6c78095e1591 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon May 07 06:43:04 CEST 2012 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-rc-3-bin.zip diff --git a/gradlew b/gradlew index cf1265090b68ddc4b271550c322badb39213e313..aeb74cbb43e3931a2455a838345c3f6b8131aaa2 100755 --- a/gradlew +++ b/gradlew @@ -1,79 +1,126 @@ -#!/bin/bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" -APP_HOME="`pwd -P`" -cd "$SAVED" - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -82,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -90,75 +137,109 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec99730b4e8fcd90b57a0e8e01544fea7c31a89..6689b85beecde676054c39c2408085f41e6be6dc 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -8,20 +24,24 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,44 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/index.html b/index.html deleted file mode 100644 index e235e5d80695865ffd163073d8884fbf9040913b..0000000000000000000000000000000000000000 --- a/index.html +++ /dev/null @@ -1,73 +0,0 @@ -<html> -<head> -<title>stups.prob.update</title> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<style>@import url("web/site.css");</style> -<script type="text/javascript"> - var returnval = 0; - var stylesheet, xmlFile, cache, doc; - function init(){ - // NSCP 7.1+ / Mozilla 1.4.1+ / Safari - // Use the standard DOM Level 2 technique, if it is supported - if (document.implementation && document.implementation.createDocument) { - xmlFile = document.implementation.createDocument("", "", null); - stylesheet = document.implementation.createDocument("", "", null); - if (xmlFile.load){ - xmlFile.load("site.xml"); - stylesheet.load("web/site.xsl"); - } else { - alert("Document could not be loaded by browser."); - } - xmlFile.addEventListener("load", transform, false); - stylesheet.addEventListener("load", transform, false); - } - //IE 6.0+ solution - else if (window.ActiveXObject) { - xmlFile = new ActiveXObject("msxml2.DOMDocument.3.0"); - xmlFile.async = false; - xmlFile.load("site.xml"); - stylesheet = new ActiveXObject("msxml2.FreeThreadedDOMDocument.3.0"); - stylesheet.async = false; - stylesheet.load("web/site.xsl"); - cache = new ActiveXObject("msxml2.XSLTemplate.3.0"); - cache.stylesheet = stylesheet; - transformData(); - } - } - // separate transformation function for IE 6.0+ - function transformData(){ - var processor = cache.createProcessor(); - processor.input = xmlFile; - processor.transform(); - data.innerHTML = processor.output; - } - // separate transformation function for NSCP 7.1+ and Mozilla 1.4.1+ - function transform(){ - returnval+=1; - if (returnval==2){ - var processor = new XSLTProcessor(); - processor.importStylesheet(stylesheet); - doc = processor.transformToDocument(xmlFile); - document.getElementById("data").innerHTML = doc.documentElement.innerHTML; - } - } -</script> -</head> -<body onload="init();"> - -<a href="http://www.stups.uni-duesseldorf.de/"><img src="http://www.stups.uni-duesseldorf.de/hhulogo1.jpg" border="0" align="right"></a> -<h1 class="title">Installing the ProB plug-ins</h1> -<p class="bodyText"> -Please use the Rodin Update manager to install the plug-ins. -</p> -<ol class="bodyText"> -<li>Select from main menu: <i>Help | Software Updates | Find and install...</i></li> -<li>There should already be a HHU remote site. If not, create a new remote site using the URL <br/><i>http://www.stups.uni-duesseldorf.de/prob_updates/</i></li> -<li>Select the Plug-ins you want to install and follow the dialog</li> -</ol> -<br/> - - -<div id="data"><!-- this is where the transformed data goes --></div> -</body> -</html> diff --git a/settings.gradle b/settings.gradle index 5f67807915a1aae5a07da13143d520f76ffe3fbe..8093362103c41d6b6a0507854fc9a09cafb71a83 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include 'de.prob.core', 'de.bmotionstudio.gef.editor' ,'de.bmotionstudio.rodin', 'de.bmotionstudio.help' , 'de.prob.plugin', 'de.prob.ui', 'de.prob2.feature', 'de.prob.symbolic', 'de.prob2.symbolic.feature', 'de.prob.eventb.disprover.core', 'de.prob.eventb.disprover.ui', 'de.prob2.disprover.feature' +include 'de.prob.core', 'de.prob.core.tests', 'de.bmotionstudio.gef.editor' ,'de.bmotionstudio.rodin' , 'de.prob.plugin', 'de.prob.ui', 'de.prob2.feature', 'de.prob.symbolic', 'de.prob2.symbolic.feature', 'de.prob.eventb.disprover.core', 'de.prob.eventb.disprover.ui', 'de.prob2.disprover.feature' diff --git a/tycho_build.gradle b/tycho_build.gradle index 5bd04a1ca6a7faf7541ab59130a486eb39885794..06be93605e1014decb9f6a2464afa5ce441495f9 100644 --- a/tycho_build.gradle +++ b/tycho_build.gradle @@ -1,671 +1,602 @@ -import org.apache.tools.ant.taskdefs.condition.Os /* Build Script can be executed via 'gradle install' Build Script Dependencies can be downloaded via 'gradle collectDepenencies' Executing the Build Script and download Dependencies can be executed via 'gradle completeInstall' - For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' + For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' Pom Generation can be executed via gradle deploy - - If you have a product definition please add a buildProduct = true to your main build.gradle script + If you have a product definition please add a buildProduct = true to your main build.gradle script */ apply plugin: 'base' import groovy.io.FileType -project.ext.tychoVersion = "0.15.0" +project.ext.tychoVersion = "1.7.0" -try{ +try { excludeFromTychoBuild = excludeFromTychoBuild -}catch(MissingPropertyException e){ +} catch (MissingPropertyException e) { project.ext.excludeFromTychoBuild = [] } -try{ +try { excludeFromClassPath = excludeFromClassPath -}catch(MissingPropertyException e){ +} catch (MissingPropertyException e) { project.ext.excludeFromClassPath = [] } - -try{ +try { workspacePath = workspacePath -}catch(MissingPropertyException e){ +} catch (MissingPropertyException e) { project.ext.workspacePath = "" } - -try{ +try { dependencyFolder = dependencyFolder -}catch(MissingPropertyException e){ - project.ext.dependencyFolder = "lib/dependencies/" // Folder in each subproject where +} catch (MissingPropertyException e) { + project.ext.dependencyFolder = "lib/dependencies/" // Folder in each subproject where } -try{ +try { groupID = groupID -}catch(MissingPropertyException e){ - +} catch (MissingPropertyException e) { // workspace nach releng durchsuchen def folderNames = [] def folders = [] println "folders:" - new File(workspacePath+".").listFiles().each{ dir -> - if( dir.isDirectory() ) folders << dir.getName() - } + new File(workspacePath+".").listFiles().each{dir -> + if (dir.isDirectory()) { + folders << dir.getName() + } + } - folders.each(){ it -> + folders.each { it -> it = (String)it.replaceFirst(/\.\//, "") - if( !( ( it ==~ /\..+/ ) || (it ==~ /.*.repository/) || (it ==~ /.*.parent/) ) ) folderNames << it // subProjects eventuell unnötig settings.gradle datei stattdessen benutzen + // subProjects eventuell unnötig settings.gradle datei stattdessen benutzen + if (!(it ==~ /\..+/ || it ==~ /.*.repository/ || it ==~ /.*.parent/)) { + folderNames << it + } } - project.ext.groupID = "group" - for( int i = 0; i < folderNames.size(); i++ ){ - - if( folderNames[i] ==~ /.*\.[rR]eleng/ ){ + for (int i = 0; i < folderNames.size(); i++) { + if (folderNames[i] ==~ /.*\.[rR]eleng/) { groupID = folderNames[i] - groupID = groupID.replace( ".releng", "") - groupID = groupID.replace( ".Releng", "") + groupID = groupID.replace(".releng", "") + groupID = groupID.replace(".Releng", "") } } - } - -try{ +try { features = features -}catch(MissingPropertyException e){ - +} catch (MissingPropertyException e) { project.ext.features = [] - for( int i = 0; i < subprojects.name.size(); i++ ){ - if( subprojects.name[i] ==~ /.*\.[fF]eature/ ){ - features.add( subprojects.name[i] ) + for (int i = 0; i < subprojects.name.size(); i++){ + if (subprojects.name[i] ==~ /.*\.[fF]eature/) { + features.add(subprojects.name[i]) } } - } - -try{ +try { repositoryName = repositoryName -}catch(MissingPropertyException e){ - project.ext.repositoryName = groupID+".repository" +} catch (MissingPropertyException e) { + project.ext.repositoryName = groupID + ".repository" } -try{ +try { parentID = parentID -}catch(MissingPropertyException e){ - project.ext.parentID = groupID+".parent" +} catch (MissingPropertyException e) { + project.ext.parentID = groupID + ".parent" } -Boolean noDescriptions = false // in case of using own CategoryDescription Map +Boolean noDescriptions = false // in case of using own CategoryDescription Map -try{ +try { categoryDescriptions = categoryDescriptions -}catch(MissingPropertyException e){ - project.ext.categoryDescriptions = [ [:],[:] ] // label and descriptions of the features +} catch (MissingPropertyException e) { + project.ext.categoryDescriptions = [[:], [:]] // label and descriptions of the features noDescriptions = true -} // categoryDescriptions = [["feature": "labelName","feature2": "label"],["feature": "featureDescription","feature2": "feature2Description"]] // label and descriptions of the features + // categoryDescriptions = [["feature": "labelName", "feature2": "label"], ["feature": "featureDescription", "feature2": "feature2Description"]] // label and descriptions of the features +} -try{ +try { targetRepositories = targetRepositories -}catch(MissingPropertyException e){ - project.ext.targetRepositories = ["http://download.eclipse.org/releases/indigo/"] +} catch (MissingPropertyException e) { + project.ext.targetRepositories = ["https://download.eclipse.org/releases/luna/"] } -try{ +try { buildProduct = buildProduct - -}catch(MissingPropertyException e){ +} catch (MissingPropertyException e) { project.ext.buildProduct = false } - -def projects(int i){ - return subprojects.name[i] +// returns the name of a subproject listed in the settings.gradle file +def projects(int i) { + return subprojects.name[i] } -// returns the name of a subproject listed in the settings.gradle file -def numberOfProjects(){ +// returns the number of projects listed in the settings.gradle file +def numberOfProjects() { return subprojects.name.size() } -// returns the number of projects listed in the settings.gradle file -// - - -/* -- Return ParentId -- */ - -def parentId(){ +// This is the project of the parent Pom +// The Tycho Maven Build is triggered from this project's pom +def parentId() { return parentID } -/* -* This is the project of the parent Pom -* The Tycho Maven Build is triggered from -* this project's pom -*/ - - -/* -- Return Group Id -- */ -def groupId(){ +// This Group ID will be used in every sub project +def groupId() { return groupID } -/* -* This Group ID will be used in every sub project -*/ - -def addLibToCP(def project, def libPar){ - - def filePar = new File(workspacePath+project+"/.classpath") - boolean notYetAdded = true - filePar.eachLine{ line -> +// Add certain Jar to Library +def addLibToCP(def project, def libPar) { + def filePar = new File(workspacePath + project + "/.classpath") + boolean notYetAdded = true + filePar.eachLine {line -> def pattern = ".*${dependencyFolder}${libPar}.*" - if(line ==~ /${pattern}/){ + if (line ==~ /${pattern}/) { notYetAdded = false } - } - if(notYetAdded){ - File newCP = new File(workspacePath+project+'/.cp') - filePar.eachLine{ line -> - - if(line ==~ /.*<\/classpath>.*/){ - - String entry = '\t<classpathentry exported="true" kind="lib" path="'+dependencyFolder+libPar+'"/>'+'\n</classpath>\n' + if (notYetAdded) { + File newCP = new File(workspacePath + project + '/.cp') + filePar.eachLine {line -> + if (line ==~ /.*<\/classpath>.*/) { + String entry = '\t<classpathentry exported="true" kind="lib" path="' + dependencyFolder + libPar + '"/>' + '\n</classpath>\n' line = line.replaceAll(/<\/classpath>/, entry) - println project + " : "+ libPar +" added to classpath" + println project + " : " + libPar + " added to classpath" newCP << line - }else{ - newCP << line+"\n" + } else { + newCP << line + "\n" } } filePar.delete() - newCP.renameTo(workspacePath+project+'/.classpath') - }else{ - println project + " : "+ libPar +" classpath entry already present" + newCP.renameTo(workspacePath + project + '/.classpath') + } else { + println project + " : " + libPar + " classpath entry already present" } - } -// Add certain Jar to Library - -def deleteLibFromCP(def project){ - - def filePar = new File(workspacePath+project+"/.classpath") +// deletes whole DependenciesLibrary Folder +def deleteLibFromCP(def project) { + def filePar = new File(workspacePath + project + "/.classpath") boolean deleteCP = false - def newCP = new File(workspacePath+project+'/cp') + def newCP = new File(workspacePath + project + '/cp') def pattern = ".*${dependencyFolder}[^<].*/>" - filePar.eachLine{ line -> - - if(line ==~ /\n(\ |\t)*/) line = line.replaceAll(/\n(\ |\t)*/, '') // delete empty lines - if(line ==~ /${pattern}/){ - deleteCP = true - def pattern2 = '(\\ |\\t)*<classpathentry exported="true" kind="lib" path="'+dependencyFolder+"[^<].*"+'"/>(\\ |\\t)*' + filePar.eachLine {line -> + if (line ==~ /\n(\ |\t)*/) { + // delete empty lines + line = line.replaceAll(/\n(\ |\t)*/, '') + } + if (line ==~ /${pattern}/) { + deleteCP = true + def pattern2 = '(\\ |\\t)*<classpathentry exported="true" kind="lib" path="' + dependencyFolder + "[^<].*"+'"/>(\\ |\\t)*' line = line.replaceAll(/${pattern2}/, '') newCP << line - }else{ + } else { newCP << line+"\n" } } - if(!deleteCP){ - println project + " : no dependencies from "+ dependencyFolder+" found in classpath file! " + if (!deleteCP) { + println project + " : no dependencies from " + dependencyFolder + " found in classpath file! " newCP.delete() - }else{ + } else { filePar.delete() - newCP.renameTo(workspacePath+project+'/.classpath') - println workspacePath+project+'/.classpath' +"!" + newCP.renameTo(workspacePath + project + '/.classpath') + println workspacePath + project + '/.classpath' + "!" } } -// deletes whole DependenciesLibrary Folder - -def addRunTimeLib( String libPar, String projectPar){ - - def mf = new File(projectPar+"/META-INF/MANIFEST.MF") - def newMf = new File(projectPar+"/MF") +// Adds a Library to the current Bundle-ClassPath of the Manifest file +def addRunTimeLib(String libPar, String projectPar) { + def mf = new File(projectPar + "/META-INF/MANIFEST.MF") + def newMf = new File(projectPar + "/MF") newMf.delete() - mf.eachLine{ line -> - if(line ==~ /.*Bundle-ClassPath:.*\.jar.*/){ - + mf.eachLine {line -> + if (line ==~ /.*Bundle-ClassPath:.*\.jar.*/) { libsInLine = line.replaceAll(/[\ \t]*Bundle-ClassPath:[\ \t]*/, '') - line = line.replaceFirst(/[^\ \t]*\.jar[\ \,]*/, dependencyFolder+libPar+",\n "+libsInLine) // /[^\ \t]*.\.jar[\ \,]*/ - }else{ - if(line ==~ /.*Bundle-ClassPath: \.[\ \t]*/){ - line = line+",\n "+dependencyFolder+libPar - }else{ - if( line ==~ /.*Bundle-ClassPath: \.\,[\ \t]*/ ){ - line = line+"\n "+dependencyFolder+libPar+"," - } + line = line.replaceFirst(/[^\ \t]*\.jar[\ \,]*/, dependencyFolder + libPar + ",\n " + libsInLine) // /[^\ \t]*.\.jar[\ \,]*/ + } else { + if (line ==~ /.*Bundle-ClassPath: \.[\ \t]*/) { + line = line + ",\n " + dependencyFolder + libPar + } else if (line ==~ /.*Bundle-ClassPath: \.\,[\ \t]*/) { + line = line + "\n " + dependencyFolder + libPar + "," } } - - newMf << line+"\n" + + newMf << line + "\n" } mf.delete() - newMf.renameTo(projectPar+"/META-INF/MANIFEST.MF") - - -} // Adds a Library to the current Bundle-ClassPath of the Manifest file - + newMf.renameTo(projectPar + "/META-INF/MANIFEST.MF") +} -def createRunTimeLib(String libPar, String projectPar){ - def mf = new File(projectPar+"/META-INF/MANIFEST.MF") - mf << "Bundle-ClassPath: lib/dependencies/"+libPar -} // Creates a Bundle-ClassPath Section in the Manifest file +// Creates a Bundle-ClassPath Section in the Manifest file +def createRunTimeLib(String libPar, String projectPar) { + def mf = new File(projectPar + "/META-INF/MANIFEST.MF") + mf << "Bundle-ClassPath: lib/dependencies/" + libPar +} -def boolean checkForRunTimeLibs(String projectPar){ +// checks for a Bundle-ClassPath section in the Manifest file +def boolean checkForRunTimeLibs(String projectPar) { boolean returnBool = false - def mf = new File(projectPar+"/META-INF/MANIFEST.MF") - mf.eachLine{ line -> - if(line ==~ /.*Bundle-ClassPath:.*/){ - returnBool = true - } + def mf = new File(projectPar + "/META-INF/MANIFEST.MF") + mf.eachLine {line -> + if (line ==~ /.*Bundle-ClassPath:.*/) { + returnBool = true } - return returnBool -} // checks for a Bundle-ClassPath section in the Manifest file - + } + return returnBool +} -def boolean checkRunTimeLib(String libPar, String projectPar){ // checks if lib is in RunTimeLibrary present and - def mf = new File(projectPar+"/META-INF/MANIFEST.MF") // changes reference if necessary - def newMf = new File(projectPar+"/MF") +// checks if lib is already present in Manifest file +// if lib is present but is referenced from another folder than dependencyFolder the library from dependencyFolder will be referenced +def boolean checkRunTimeLib(String libPar, String projectPar){ + // checks if lib is in RunTimeLibrary present and changes reference if necessary + def mf = new File(projectPar + "/META-INF/MANIFEST.MF") + def newMf = new File(projectPar + "/MF") newMf.delete() boolean returnBool = false boolean changed = false - mf.eachLine{ line -> - if(line ==~ /.*${libPar}.*/){ - if( !( line ==~ /.*(\ |\t)*${dependencyFolder}${libPar}(\ |\t)*.*/ ) ){ //if lib is already referenced - line = line.replaceFirst( /[^\ \t]*${libPar}/, dependencyFolder+libPar ) // reference lib from dependencyFolder - changed = true - println line - println "yolo ${libPar}\n" - } - returnBool = true + mf.eachLine {line -> + if (line ==~ /.*${libPar}.*/) { + if (!(line ==~ /.*(\ |\t)*${dependencyFolder}${libPar}(\ |\t)*.*/)){ + // if lib is already referenced + // reference lib from dependencyFolder + line = line.replaceFirst( /[^\ \t]*${libPar}/, dependencyFolder+libPar ) + changed = true + println line + println "yolo ${libPar}\n" } - - newMf << line+"\n" - } - if(changed){ - mf.delete() - newMf.renameTo(projectPar+"/META-INF/MANIFEST.MF") - }else{ - newMf.delete() + returnBool = true } - return returnBool - -}// checks if lib is already present in Manifest file -// if lib is present but is referenced from another folder than dependencyFolder the library from dependencyFolder will be referenced -///////////////////////////////////////////////////////////////////////////////////////// -// -- !!! DEFINING SUB PROJECTS !!! -- // -///////////////////////////////////////////////////////////////////////////////////////// + newMf << line + "\n" + } + if (changed) { + mf.delete() + newMf.renameTo(projectPar + "/META-INF/MANIFEST.MF") + } else { + newMf.delete() + } + return returnBool +} + +/////////////////////////////////// +// !!! DEFINING SUB PROJECTS !!! // +/////////////////////////////////// subprojects { - apply plugin: 'base' apply plugin: 'java' -// apply plugin: 'eclipse' - + // apply plugin: 'eclipse' + task deleteArtifacts(type: Delete) { - delete 'target','pom.xml' + delete 'target','pom.xml' } - - ///// Copy Dependencies into subprojects DependencyFolder ///// + + // Copy Dependencies into subprojects DependencyFolder task collectDependencies(type: Copy) { + from configurations.runtimeClasspath - from configurations.compile - from configurations.runtime - - into "${dependencyFolder}" - + into "${dependencyFolder}" } - - task setClassPath(dependsOn: 'collectDependencies')<<{ - + + task setClassPath(dependsOn: 'collectDependencies') { description = "\tAdds all your Dependencies from your local lib folder in each project to it's classpath" - if( excludeFromClassPath.every{ it != project.name }){ - def dependencyList = [] - try{ - def dir = new File(workspacePath+project.name+"/"+dependencyFolder).eachFile() { file-> - if( !(file.getName() ==~/.*\.txt/) ){ - dependencyList << file.getName() + + doLast { + if (excludeFromClassPath.every {it != project.name}) { + def dependencyList = [] + try { + def dir = new File(workspacePath + project.name + "/" + dependencyFolder).eachFile() {file -> + if (!(file.getName() ==~ /.*\.txt/)) { + dependencyList << file.getName() + } } - } - - if(features.every{ it != project.name }){ - boolean BundleClassPathPresent = checkForRunTimeLibs(project.name) - for(int icp = 0; icp < dependencyList.size; icp++){ - addLibToCP(project.name, dependencyList[icp]) //Adds Lib to .classPath file - - if(!BundleClassPathPresent){ // Adds Lib to Manifest File - createRunTimeLib(dependencyList[icp], project.name) - BundleClassPathPresent = true - }else{ - if(!checkRunTimeLib(dependencyList[icp], project.name)){ // if library not present add it to RunTimeLibrary - addRunTimeLib( dependencyList[icp], project.name) + + if (features.every {it != project.name}) { + boolean BundleClassPathPresent = checkForRunTimeLibs(project.name) + for (int icp = 0; icp < dependencyList.size; icp++) { + // Adds Lib to .classPath file + addLibToCP(project.name, dependencyList[icp]) + + if (!BundleClassPathPresent) { + // Adds Lib to Manifest File + createRunTimeLib(dependencyList[icp], project.name) + BundleClassPathPresent = true + } else if (!checkRunTimeLib(dependencyList[icp], project.name)) { + // if library not present add it to RunTimeLibrary + addRunTimeLib(dependencyList[icp], project.name) } } + // could still be usefull for debugging, that's why it's not deleted + /*dependencyList.each {dep -> + println project.name + ": " + dep + }*/ } - /*dependencyList.each{ dep-> - println project.name+": "+ dep // could still be usefull for debugging, that's why it's not deleted - }*/ - } - def warningReadMe = new File(workspacePath+project.name+"/"+dependencyFolder+"_README.txt") - warningReadMe.delete() - warningReadMe << "Do Not Remove any Jars/Libraries in this Folder!\nThis folder contains all of your dependencies defined in your gradle script.\n" - warningReadMe << "Removing or renaming any of these files will result in an Error in your .classpath file\n" - warningReadMe << "If any error concerning missing dependencies should occur please run 'gradle deleteFromClassPath setClassPath' in your workspace folder from your shell." - - - }catch(Exception e){ - println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" + def warningReadMe = new File(workspacePath + project.name + "/" + dependencyFolder + "_README.txt") + warningReadMe.delete() + warningReadMe << "Do Not Remove any Jars/Libraries in this Folder!\nThis folder contains all of your dependencies defined in your gradle script.\n" + warningReadMe << "Removing or renaming any of these files will result in an Error in your .classpath file\n" + warningReadMe << "If any error concerning missing dependencies should occur please run 'gradle deleteFromClassPath setClassPath' in your workspace folder from your shell." + } catch (Exception e) { + println project.name + " has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" + } } - }// if exclude projectAbfrage - - }// setClassPath - - - task deleteFromClassPath()<<{ - + } + } + + task deleteFromClassPath(){ description = "\tDeletes all your Dependencies located in your local lib folder from each project's classpath" - - try{ - - boolean depsDelete = false - def depsFolder = new File(workspacePath+project.name+'/'+dependencyFolder) - if(depsFolder.exists()) depsDelete = true - depsFolder.deleteDir() - - if(features.every{ it != project.name } && depsDelete){ - deleteLibFromCP(project.name) + + doLast { + try { + boolean depsDelete = false + def depsFolder = new File(workspacePath + project.name + '/' + dependencyFolder) + if (depsFolder.exists()) { + depsDelete = true + } + depsFolder.deleteDir() + + if (features.every {it != project.name} && depsDelete) { + deleteLibFromCP(project.name) + } + } catch (Exception e) { + println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" } - - }catch(Exception e){ - println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" } - } - - /////---- For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' ----/////// - //////////////////////////////////////////////////////////////////////////////////////////// - - task deploy() <<{ + // For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' + + //////////////////////////////////////////////////////////////////////////////////////////// + + task deploy() { description = "\tGenerating the Tycho Poms. Please remember to add a '.qualifier' to the version numbers!" - String versionNumber = 'Version Number Error:\tcheck Manifest for Bundle-Version Number and make sure to add a ".qualifier" to the version numbers!\n' - String artifactId = 'Could not find Bundle-SymbolicName in Manifest.file' - - - /* -- In case of changed Manifest File in Eclipse: - * - * Version Numbers of the projects are collected via - * regular expressions in the Manifest.MF File. - * versionnumber of the projects are equal to their - * Bundle-Version Number - */ - - - if(features.every{ it != project.name }){ // Generating Poms for sub projects except features - def content = new File(workspacePath+"${project.name}/META-INF/MANIFEST.MF").getText("UTF-8") - - def printFileLine = { - if( it ==~ /Bundle-Version.+qualifier/ ){ - versionNumber = it.substring(16) // possibile error: cuts off first 16 chars - - /* Version Number is taken from Bundle-Version in Manifest.MF - * If there is no Bundle-Version or the versionnumber needs to - * be taken from a different key word, please change the - * regular expression and the substring above - */ + doLast { + String versionNumber = 'Version Number Error:\tcheck Manifest for Bundle-Version Number and make sure to add a ".qualifier" to the version numbers!\n' + String artifactId = 'Could not find Bundle-SymbolicName in Manifest.file' + + // -- In case of changed Manifest File in Eclipse: + // Version Numbers of the projects are collected via + // regular expressions in the Manifest.MF File. + // versionnumber of the projects are equal to their + // Bundle-Version Number + + // Generating Poms for sub projects except features + if (features.every {it != project.name}) { + def content = new File(workspacePath + "${project.name}/META-INF/MANIFEST.MF").getText("UTF-8") + + def printFileLine = { + if (it ==~ /Bundle-Version.+qualifier/) { + versionNumber = it.substring(16) // possibile error: cuts off first 16 chars + + // Version Number is taken from Bundle-Version in Manifest.MF + // If there is no Bundle-Version or the versionnumber needs to + // be taken from a different key word, please change the + // regular expression and the substring above + + versionNumber = versionNumber.replace(".qualifier", "-SNAPSHOT") + } + + // Artifact ID is taken from Bundle-SymbolicName minus the 16 chars ';singleton:=true' + if (it ==~ /Bundle-SymbolicName:.+/) { + artifactId = it + artifactId = artifactId.replace("Bundle-SymbolicName:", '') + artifactId = artifactId.replace(";", '') + artifactId = artifactId.replace(" ", '') + artifactId = artifactId.replace("singleton:=true", '') + } } - - if( it ==~ /Bundle-SymbolicName:.+/ ){ - artifactId = it - artifactId = artifactId.replace("Bundle-SymbolicName:", ''); - artifactId = artifactId.replace(";",'') - artifactId = artifactId.replace(" ",'') - artifactId = artifactId.replace("singleton:=true",'') + + content.eachLine(printFileLine) + + println artifactId + println "\t" + versionNumber + + def f = new File(workspacePath + artifactId + '/pom.xml') + f.delete() + + if (project.name ==~ /.*\.[tT]ests*/) { + // Test Cases + f << start() + elder() + testArtifact(artifactId, versionNumber) + end() + } else { + // Normal Plugin + f << start() + elder() + artifact(artifactId, versionNumber) + end() + // old pom.xml files are deleted and replaced by new auto generated Tycho pom.xml files } - /* Artifact ID is taken from Bundle-SymbolicName minus the - * 16 chars ';singleton:=true' - */ - } - - content.eachLine( printFileLine ) - - println artifactId - println "\t"+versionNumber - - def f = new File(workspacePath+artifactId+'/pom.xml') - f.delete() - - // ---- Test Cases ------ // - - if( project.name ==~ /.*\.[tT]ests*/){ - - f << start()+elder()+testArtifact(artifactId, versionNumber)+end() - }else{ - - // ---- Normal Plugin ----- // - f << start()+elder()+artifact(artifactId, versionNumber)+end() - /* - * old pom.xml files are deleted and replaced by new auto generated Tycho pom.xml files - */ - } - }else{ // end of { if subprojects aren't a feature } Block - -// -- Features -- // - - if(features.any{ it == project.name } ){ - - def parsedXml = new XmlParser().parse(workspacePath+"${project.name}/feature.xml") - - artifactId = parsedXml.attribute("id") + } else if (features.any {it == project.name}) { + // Features + def parsedXml = new XmlParser().parse(workspacePath + "${project.name}/feature.xml") + + artifactId = parsedXml.attribute("id") versionNumber = parsedXml.attribute("version") + versionNumber = versionNumber.replace(".qualifier", "-SNAPSHOT") println artifactId - println "\t"+versionNumber + println "\t" + versionNumber - def f = new File(workspacePath+artifactId+'/pom.xml') + def f = new File(workspacePath + artifactId + '/pom.xml') f.delete() - f << feature(artifactId, versionNumber) + f << feature(artifactId, versionNumber) } } - }//deploy - - -}// defining subprojects + } +} clean { dependsOn += subprojects.deleteArtifacts } -task createParent() << { - // --------- define Parent --------- // - - new File(workspacePath+"${parentID}").mkdir() - String versionNumber = '1.0.0.qualifier' - String artifactId = parentId() - - def f = new File(workspacePath+artifactId+'/pom.xml') - f.delete() - f << parentPom(artifactId) - for(int i = 0; i < targetRepositories.size(); i++){ - f << repos(targetRepositories[i], i) - } - f << endRepos() - f << moduleStart() - for(int i = 0; i < numberOfProjects(); i++){ - - if( excludeFromTychoBuild.every{ it != projects(i) } ){ - - f << module(projects(i)) +// define Parent +task createParent() { + doLast { + new File(workspacePath + "${parentID}").mkdir() + String versionNumber = '1.0.0.qualifier' + String artifactId = parentId() + + def f = new File(workspacePath + artifactId + '/pom.xml') + f.delete() + f << parentPom(artifactId) + for (int i = 0; i < targetRepositories.size(); i++) { + f << repos(targetRepositories[i], i) + } + f << endRepos() + f << moduleStart() + for (int i = 0; i < numberOfProjects(); i++) { + if (excludeFromTychoBuild.every {it != projects(i)}) { + f << module(projects(i)) + } } + f << module(repositoryName) + f << endParent() } - f << module(repositoryName) - f << endParent() - } -task createRepository() << { - - // ------------ define Repository --------- // - - new File(workspacePath+"${repositoryName}").mkdir() - - String versionNumber = '1.0.0.qualifier' - String artifactId = repositoryName - String featureVersionNumber = '1.0.0.qualifier' - String featureArtifactId - def f = new File(workspacePath+artifactId+'/category.xml') - f.delete() - f << categoryHead() - for(int i = 0; i < features.size(); i++){ - - def parsedXml = new XmlParser().parse("${workspacePath}${features[i]}/feature.xml") - - featureVersionNumber = parsedXml.attribute("version") - featureArtifactId = parsedXml.attribute("id") - - if(noDescriptions){ - categoryDescriptions[0].put( features[i], parsedXml.attribute("label") ) - categoryDescriptions[1].put( features[i], parsedXml.description.text() ) +// define Repository +task createRepository() { + doLast{ + new File(workspacePath + "${repositoryName}").mkdir() + + String versionNumber = '1.0.0.qualifier' + String artifactId = repositoryName + String featureVersionNumber = '1.0.0.qualifier' + String featureArtifactId + def f = new File(workspacePath + artifactId + '/category.xml') + f.delete() + f << categoryHead() + for (int i = 0; i < features.size(); i++) { + def parsedXml = new XmlParser().parse("${workspacePath}${features[i]}/feature.xml") + + featureVersionNumber = parsedXml.attribute("version") + featureArtifactId = parsedXml.attribute("id") + + if (noDescriptions) { + categoryDescriptions[0].put(features[i], parsedXml.attribute("label")) + categoryDescriptions[1].put(features[i], parsedXml.description.text()) + } + f << categoryFeatures(featureArtifactId.replace(workspacePath, ''), featureVersionNumber) } - f << categoryFeatures(featureArtifactId.replace(workspacePath,''), featureVersionNumber) - }// for - - for( int i = 0; i < features.size(); i++ ){ - - if(noDescriptions){ - f << categoryDescription(features[i], categoryDescriptions[0][features[i]] ,categoryDescriptions[1][features[i]] ) - // featureName, label, description - }else{ - f << categoryDescription(features[i], categoryDescriptions[features[i]][0] ,categoryDescriptions[features[i]][1]) + + for (int i = 0; i < features.size(); i++) { + if (noDescriptions) { + // featureName, label, description + f << categoryDescription(features[i], categoryDescriptions[0][features[i]],categoryDescriptions[1][features[i]]) + } else { + f << categoryDescription(features[i], categoryDescriptions[features[i]][0],categoryDescriptions[features[i]][1]) + } } - }//for - - f << categoryEnd() - - def pom = new File(workspacePath+artifactId+'/pom.xml') - pom.delete() - pom << reposi() -}// end of repository definition - + + f << categoryEnd() + + def pom = new File(workspacePath + artifactId + '/pom.xml') + pom.delete() + pom << reposi() + } +} task createPoms(dependsOn: [createParent, createRepository, subprojects.deploy]) -task install(dependsOn: [createPoms] , type:Exec) { - description = "\tExecutes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms" - commandLine 'mvn', 'install', '-f', workspacePath+parentID+'/pom.xml' +task install(dependsOn: [createPoms], type: Exec) { + description = "\tExecutes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms" + commandLine 'mvn', 'install', '-f', workspacePath + parentID + '/pom.xml' } -task completeInstall(dependsOn: [subprojects.collectDependencies, createPoms], type:Exec ){ - +task prepareMaven(dependsOn: [subprojects.collectDependencies, createPoms]) + +task completeInstall(dependsOn: [prepareMaven], type: Exec) { description = "\tCopies dependencies into dependencyFolder of each subproject and executes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms" - commandLine 'mvn', 'install', '-f', workspacePath+parentID+'/pom.xml' + commandLine 'mvn', 'install', '-f', workspacePath + parentID + '/pom.xml' } -task tycho(dependsOn: [createPoms] , type:Exec) { - description = "\tExecutes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms" - commandLine 'mvn', 'install', '-f', workspacePath+parentID+'/pom.xml' -} +// --- Defining Tycho POM parts -- // -//--- Defining Tycho POM parts --// +def artifact(artifactId,versionNumber) {""" + <groupId>${groupId()}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${versionNumber}</version> + <packaging>eclipse-plugin</packaging> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-compiler-plugin</artifactId> + <version>\${tycho-version}</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +"""} - def artifact(artifactId,versionNumber) { """ +def testArtifact(artifactId,versionNumber) {""" + <groupId>${groupId()}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${versionNumber}</version> + <packaging>eclipse-test-plugin</packaging> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>\${tycho-version}</version> + </plugin> + </plugins> + </build> +"""} + + +def start() {"""\ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> +"""} + + +def elder() {""" + <parent> <groupId>${groupId()}</groupId> - <artifactId>${artifactId}</artifactId> - <version>${versionNumber}</version> - <packaging>eclipse-plugin</packaging> - <build> - <plugins> - <plugin> - <groupId>org.eclipse.tycho</groupId> - <artifactId>tycho-compiler-plugin</artifactId> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - </plugins> - </build> - """ } - - def testArtifact(artifactId,versionNumber) { """ - <groupId>${groupId()}</groupId> - <artifactId>${artifactId}</artifactId> - <version>${versionNumber}</version> - <packaging>eclipse-test-plugin</packaging> - <build> - <plugins> - <plugin> - <groupId>org.eclipse.tycho</groupId> - <artifactId>tycho-surefire-plugin</artifactId> - <configuration> - <!-- <useUIHarness>true</useUIHarness> --> - <!-- <useUIThread>true</useUIThread> --> - ${macTestArguments()} - <!-- <product>org.rodinp.platform.product</product> --> - </configuration> - </plugin> - </plugins> - </build> - """ } - - String macTestArguments() { - if ( Os.isFamily(Os.FAMILY_MAC) ){ - return "<argLine>-XstartOnFirstThread</argLine>\n" - }else{ - return "\n" - } - } - - - def start() { """<?xml version="1.0" encoding="UTF-8"?> - <project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - """} - - - def elder() {""" - <parent> - <groupId>${groupId()}</groupId> - <artifactId>${parentId()}</artifactId> - <version>1.0.0.qualifier</version> - <relativePath>../${parentId()}/pom.xml</relativePath> - </parent> - """} - - - def end() {""" - </project> - """} - -// -- defining Parent Pom -- // - - - - -def parentPom(artifactId) { """<?xml version="1.0" encoding="UTF-8"?> + <artifactId>${parentId()}</artifactId> + <version>1.0.0.qualifier</version> + <relativePath>../${parentId()}/pom.xml</relativePath> + </parent> +"""} + + +def end() {""" +</project> +"""} + +// -- defining Parent Pom -- // + +def parentPom(artifactId) {"""\ +<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - + <groupId>${groupId()}</groupId> - <artifactId>${artifactId}</artifactId> - <version>1.0.0.qualifier</version> - + <artifactId>${artifactId}</artifactId> + <version>1.0.0.qualifier</version> + <packaging>pom</packaging> <!-- this is the parent POM from which all modules inherit common settings --> @@ -673,28 +604,26 @@ def parentPom(artifactId) { """<?xml version="1.0" encoding="UTF-8"?> <tycho-version>${tychoVersion}</tycho-version> </properties> - <repositories> - <!-- configure p2 repository to resolve against --> - - + <pluginRepositories> + <pluginRepository> + <id>central</id> + <url>https://repo1.maven.org/maven2</url> + </pluginRepository> + </pluginRepositories> + <repositories> + <!-- configure p2 repository to resolve against --> """} - def repos(String targetRepo, int i) {""" - - <repository> - <id>targetRepository${i}</id> - <layout>p2</layout> - <url>${targetRepo}</url> - </repository> - + <repository> + <id>targetRepository${i}</id> + <layout>p2</layout> + <url>${targetRepo}</url> + </repository> """} - - def endRepos() {""" - </repositories> - + </repositories> <build> <plugins> <plugin> @@ -708,213 +637,192 @@ def endRepos() {""" </build> """} -def moduleStart(){""" +def moduleStart() {""" <!-- the modules that should be built together --> <modules> - """} +"""} -//for(int i = 0; i < numberOfProjects(); i++) +// for (int i = 0; i < numberOfProjects(); i++) -def module(String project){""" <module>../${project}</module> +def module(String project) {"""\ + <module>../${project}</module> """} - - -def endParent() {""" +def endParent() {"""\ </modules> </project> - """} - +"""} + // end of defining parent pom.xml // repository Pom -def reposi() { """ +def reposi() {"""\ <?xml version="1.0" encoding="UTF-8"?> - <project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>${groupID}</groupId> - <artifactId>${parentID}</artifactId> - <version>1.0.0.qualifier</version> - <relativePath>../${parentID}/pom.xml</relativePath> - </parent> - - - <groupId>${groupID}</groupId> - <artifactId>${repositoryName}</artifactId> - <version>1.0.0.qualifier</version> - <packaging>eclipse-repository</packaging> - - ${reposiBuildStep()} +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>${groupID}</groupId> + <artifactId>${parentID}</artifactId> + <version>1.0.0.qualifier</version> + <relativePath>../${parentID}/pom.xml</relativePath> + </parent> + + <groupId>${groupID}</groupId> + <artifactId>${repositoryName}</artifactId> + <version>1.0.0.qualifier</version> + <packaging>eclipse-repository</packaging> + + ${reposiBuildStep()} </project> """} def String reposiBuildStep(){ - - if( buildProduct != false ){ - return """ - <build> - <plugins> - <plugin> - <groupId>org.eclipse.tycho</groupId> - <artifactId>tycho-p2-director-plugin</artifactId> - <version>\${tycho-version}</version> - <executions> - <execution> - <!-- (optional) install the product for all configured os/ws/arch environments using p2 director --> - <id>materialize-products</id> - <goals> - <goal>materialize-products</goal> - </goals> - </execution> - - <execution> - <!-- (optional) create product zips (one per os/ws/arch) --> - <id>archive-products</id> - <goals> - <goal>archive-products</goal> - </goals> - </execution> - + if (buildProduct != false) { + return """ + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-p2-director-plugin</artifactId> + <version>\${tycho-version}</version> + <executions> + <execution> + <!-- (optional) install the product for all configured os/ws/arch environments using p2 director --> + <id>materialize-products</id> + <goals> + <goal>materialize-products</goal> + </goals> + </execution> + + <execution> + <!-- (optional) create product zips (one per os/ws/arch) --> + <id>archive-products</id> + <goals> + <goal>archive-products</goal> + </goals> + </execution> </executions> - </plugin> - </plugins> - </build> + </plugin> + </plugins> + </build> """ - }else{ + } else { return "\n" } } -// creates a category in -def categoryHead() { """<?xml version="1.0" encoding="UTF-8"?> +// creates a category in +def categoryHead() {"""\ +<?xml version="1.0" encoding="UTF-8"?> <site> - """} - -def categoryFeatures(artifactId, versionNumber){""" + +def categoryFeatures(artifactId, versionNumber) {""" <feature url="features/${artifactId}_${versionNumber}.jar" id="${artifactId}" version="${versionNumber}"> <category name="${artifactId}.category"/> </feature> """} -def categoryDescription(artifactId, categoryName, categorydescription){""" -<category-def name="${artifactId}.category" label="${categoryName}"> - <description> +def categoryDescription(artifactId, categoryName, categorydescription) {""" + <category-def name="${artifactId}.category" label="${categoryName}"> + <description> ${categorydescription} - </description> - </category-def> + </description> + </category-def> """} -def categoryEnd(){""" +def categoryEnd() {""" </site> """} // end of category definition // feature pom -def feature(artifactId, versionNumber) { """ +def feature(artifactId, versionNumber) {"""\ <?xml version="1.0" encoding="UTF-8"?> - <project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>${groupId()}</groupId> - <artifactId>${parentId()}</artifactId> - <version>1.0.0.qualifier</version> - <relativePath>../${parentId()}/pom.xml</relativePath> - </parent> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> <groupId>${groupId()}</groupId> - <artifactId>${artifactId}</artifactId> - <version>${versionNumber}</version> - <packaging>eclipse-feature</packaging> - </project> + <artifactId>${parentId()}</artifactId> + <version>1.0.0.qualifier</version> + <relativePath>../${parentId()}/pom.xml</relativePath> + </parent> + <groupId>${groupId()}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${versionNumber}</version> + <packaging>eclipse-feature</packaging> +</project> """} // end of feature pom -// -------- In case you want to generate the product definition ------ // +// -------- In case you want to generate the product definition ------ // /* - def productXML(){ -""" +"""\ <?xml version="1.0" encoding="UTF-8"?> <?pde version="3.5"?> <product name="${groupID}.product" uid="${groupID}" id="${groupID}.product" application="${product}" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> + <configIni use="default"> + </configIni> - <configIni use="default"> - </configIni> + <launcherArgs> + <programArgs>-consoleLog</programArgs> + <vmArgs>-Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> - <launcherArgs> - <programArgs>-consoleLog</programArgs> - <vmArgs>-Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgs> - <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> - </launcherArgs> - - <plugins> - - </plugins> + <plugins> + </plugins> <features> -"""+listProductFeature()+""" - <feature id="org.eclipse.rcp" version="3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272"/> - </features> - <configurations> - <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" /> - <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> - <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" /> - </configurations> - +""" + listProductFeature() + """ + <feature id="org.eclipse.rcp" version="3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272"/> + </features> + <configurations> + <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" /> + <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> + <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" /> + </configurations> </product> - - """ /* -""" +"""\ <?xml version="1.0" encoding="UTF-8"?> <?pde version="3.5"?> <product name="de.prob.product" uid="de.prob" id="de.prob.standalone.product" application="de.prob.standalone.application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> + <configIni use="default"> + </configIni> - <configIni use="default"> - </configIni> - - <launcherArgs> - <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> - </launcherArgs> - - <plugins> - </plugins> - + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + <plugins> + </plugins> </product> - - """*/ /* - - <feature id="birkhoff.feature" version="1.0.0.qualifier"/> - - -*/ + <feature id="birkhoff.feature" version="1.0.0.qualifier"/> +*/ /* } def String listProductFeatures(){ String returnString = "" - for(int i = 0; i < features.size(); i++){ - - returnString += '\n\t\t<feature id="${features[i]}" version="1.0.0.qualifier"/>' - + for (int i = 0; i < features.size(); i++) { + returnString += '\n\t\t<feature id="${features[i]}" version="1.0.0.qualifier"/>' } return returnString - } */ -// Build Script can be executed via gradle install -// For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' -// Pom Generation can be executed via gradle deploy \ No newline at end of file +// Build Script can be executed via gradle install +// For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' +// Pom Generation can be executed via gradle deploy