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/plugin.xml b/de.bmotionstudio.gef.editor/plugin.xml index 7e6f904114c127a90d6b6b32d537a015e353921f..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 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> +<?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 41b2b588ea69db648f28e8ca829f89ab76781eaa..6a07a8b6ba09b8665d6e6fc22fc441bb274e27b2 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,230 +1,230 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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 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); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine 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 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..cf3da3748ee579ce7eb4182820a6fa747ac497c2 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,842 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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(); + } + } + + /* + * (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(); + } + +} 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..79437821943342f5cf322497b9470add4702bbf7 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,152 @@ -/******************************************************************************* - * 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; + } + + /* + * (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; + } + +} 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..1682cad05ba4a6ded53f3e836053a8ee6b452122 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,61 @@ -/******************************************************************************* - * 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; + } + + /* + * (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(); + } +} 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..c914f587a3913bf654a6a52eb73975add3175d96 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,208 @@ -/******************************************************************************* - * 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; + + /* + * (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; + } + +} 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..9d735cf10c408b07f63832c3e99696bbf401aff8 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,127 @@ -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); + } + + /* + * (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); + } + +} 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..392a2d1eb208f3523ee84c3d279122f5fa35f218 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,98 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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 { + + /* + * (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; + } + +} 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..c303653226c73a74c21155044904f82f6e742e3d 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,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.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)); + } + + } + + } + + /* + * (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(); + } + +} 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..1f7602a791c16a1e62669406ef4f58d82b98615d 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,89 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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(); + } + + /* + * (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); + } + +} 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..6f6414e7bf4ac385d707586ab4e6fb5e3fb31f14 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,145 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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); + } + + /* + * (non-Javadoc) + * + * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() + */ + @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..6f386d965ba619df87519d620cb72d78089b370a 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,113 @@ -/******************************************************************************* - * 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(); + } + + /* + * (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(); + } + +} 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..bbd022db5f5abc095591ef2fa797b62978ff232a 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,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.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(); + } + + /* + * (non-Javadoc) + * + * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() + */ + @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..09b6881c184b5e171d18774206bdfb289c6edb45 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,440 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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(); + } + + /* + * (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(); + } + +} 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..e17cccfb5d20b7b743717a9ccaee0ebeba18a9cb 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,130 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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); + } + + /* + * (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); + } + +} 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..0c8a51e21e6ab99ff2037ad9bc5b8a33d9466edb 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,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.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); + } + + /* + * (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(); + } + +} 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..fe656bee5079b44a5fcafd3c6961322ac0c1d03b 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,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.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(); + } + + /* + * (non-Javadoc) + * + * @see de.bmotionstudio.gef.editor.figure.IBMotionFigure#deactivateFigure() + */ + @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 3fe92e414a9b7c52120e23922c05dad4e2e179a9..8bf210d51a64f111bd7ec6a73f277a020b998f2b 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 = "https://www3.hhu.de/stups/prob/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; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine 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://www3.hhu.de/stups/prob/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 8fe6b854501f7139065d5debe25b99cf935e89c0..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,323 +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); - 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(); - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine 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 cb7169e3009f11d9a790e6083cfa675b34776486..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 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; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine 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 6c97d812ce355187882914260eedacf79312efdc..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,311 +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.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; - } - -} +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine 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..299cdadbb6c857ee2e451161c38c7adb1312780c 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,91 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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); + } + + /* + * (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 ""; + } + +} 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..c44553a3609ee5a4d5cc9880bcb1b76b498f08e6 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,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.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 { + + /* + * (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(); + } + +} 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..3d42eff0766c51f37c12ab77d065bef8a93d9d9a 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,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.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 { + + /* + * (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(); + } + +} 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..fedf8787952fd4154e70d05f04609456fefcb439 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,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.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 { + + /* + * (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(); + } + +} 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..3fcb660d7a583375901ba72afd0986d79d1e8b69 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,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.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 { + + /* + * (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(); + } + +} 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..8627292d326c9d1097af9d8d06cca360980a716d 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,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.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 { + + /* + * (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(); + } +} 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..b3e5da0f89b2c28ee83c23fe6af551da32c8a2eb 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,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.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 { + + /* + * (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(); + } + +} 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..4d96c05d8e079ccd160d3701f17b7a066ce33ab6 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,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.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 { + + /* + * (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(); + } + +} 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..6c8f632cde2a57427b8e1a33439afebc2750357b 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,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.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 { + + /* + * (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(); + } + +} 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..660a442778f6c7698dab2606e75c03fda0eb06b8 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,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.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 { + + /* + * (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(); + } + +} 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..83542e852adb82a1f600507b4fd50705f7331ff2 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.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; + } + +} 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..ce6a2e0f373468f0e8757de4bdb13d73b91185ff 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,444 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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)); + + /* + * (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 + + } + } \ 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..3f35e65390effd97b5b9dd6183c163a212c49030 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,349 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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; + } + + /* + * (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(); + } + +} 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..26850379a5c949270c531b2314eb446559dfb057 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,444 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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); + } + } + + /* + * (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; + } + } \ 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..7472b79502beafac514efabbe6499bd5641f8569 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,249 @@ * 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; + } + + /* + * (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()); + } + } + } + +} 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..09f2f88f6cd15385317a7bd692780a0054c4d928 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,276 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, - * Heinrich Heine 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")); + } + + /* + * (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; + // } + // + // } + +} 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/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.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/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/translator/tests/AbstractEventBTests.java b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java index e97100ac4ed6c05616166c6cd8808ff281a7f21e..ec7daa2202a62075ddd2fac03da0a8ad1a4527ca 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,1242 @@ -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; + +/** + * @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.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..2978f9bab4d93a7d183f8368b2c6f4160d79d1cc 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,143 @@ -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 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.core/src/de/prob/core/domainobjects/ltl/CounterExample.java b/de.prob.core/src/de/prob/core/domainobjects/ltl/CounterExample.java index 165afd982f29eab218d31a11a6741129ea74c2fe..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,294 +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]; - - 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; - } -} +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.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/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.units.tests/src/de/prob/units/tests/AbstractEventBTests.java b/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java index 17de2efe9cf2550a52aeef3edc703b94c8d8e789..cd63d624238fc37ab2d326afe21b8f1f423437b1 100644 --- a/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java +++ b/de.prob.units.tests/src/de/prob/units/tests/AbstractEventBTests.java @@ -1,1242 +1,1242 @@ -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; - } - } - -} +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 index 16b72cb82c727d323d9c1c386bdf35b18306f7c9..eceb7e839e98407ed719f71b35032c29179cbdbe 100644 --- a/de.prob.units.tests/src/de/prob/units/tests/AbstractTests.java +++ b/de.prob.units.tests/src/de/prob/units/tests/AbstractTests.java @@ -1,143 +1,143 @@ -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)); - } - } - +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