Skip to content

Commit

Permalink
1774 ge flow creation fix (#2228)
Browse files Browse the repository at this point in the history
Closes #1774 #1202

Initial selection from tool dialogs fixed and elements can be selected using the outline view (elements that are not on the diagram).
  • Loading branch information
RyanMcilnay committed Mar 12, 2020
1 parent 44af9ff commit abf1187
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 221 deletions.
4 changes: 2 additions & 2 deletions ge/org.osate.ge.doc/docs-gen/user_guide.html
Expand Up @@ -443,7 +443,7 @@ <h2 id="define-the-integrated-system"><span class="header-section-number">2.3</s
<li>Select <em>Application</em> diagram element.</li>
<li>Select <em>Bind…</em> from the toolbar.</li>
<li>Select <em>Actual_Processor_Binding</em>.</li>
<li>Select <em>CPU</em>.</li>
<li>Select <em>CPU</em> in the diagram or outline view.</li>
<li>Select <em>OK</em>.</li>
</ol></li>
<li><p><strong>Create a Processor Binding Diagram</strong> A <em>Processor Binding Diagram</em> is a type of diagram which is preconfigured to visualize the bindings. For more information about diagram types, see section section <a href="#sec:diagram_types">7.1</a>. Create the diagram using the following steps.</p>
Expand All @@ -468,7 +468,7 @@ <h2 id="creating-classifier-implementations"><span class="header-section-number"
<h2 id="creating-mode-transitions"><span class="header-section-number">3.2</span> Creating Mode Transitions</h2>
<p>Select <em>Mode Transition</em> from the palette and select the starting mode then the ending mode.</p>
<h2 id="creating-flow-implementations-and-end-to-end-flow-specifications"><span class="header-section-number">3.3</span> Creating Flow Implementations and End-To-End Flow Specifications</h2>
<p>When editing a component implementation, flow implementations and end-to-end flow specifications can be created graphically by selecting the <em>Create Flow Implementation</em> and <em>Create End-To-End Flow Specification</em> tools from the toolbar and following the prompts to select a series of elements from the diagram. The dialog and colors of elements in the diagram will update as valid selections are made. The starting flow specification will be highlighted dark orange and flow elements will be highlighted purple. The <em>Undo</em> button will remove the elements in the order they were selected.</p>
<p>When editing a component implementation, flow implementations and end-to-end flow specifications can be created graphically by selecting the <em>Create Flow Implementation</em> and <em>Create End-To-End Flow Specification</em> tools from the toolbar and following the prompts to select a series of elements from the diagram or outline view. The dialog and colors of elements in the diagram will update as valid selections are made. The starting flow specification will be highlighted dark orange and flow elements will be highlighted purple. The <em>Undo</em> button will remove the elements in the order they were selected.</p>
<h3 id="creating-flow-implementations"><span class="header-section-number">3.3.1</span> Creating Flow Implementations</h3>
<p>Select <em>Create Flow Implementation</em> from the toolbar, the dialog will appear.</p>
<p><img src="../images/CreateFlowImplementationToolbar.png" /></p>
Expand Down
4 changes: 2 additions & 2 deletions ge/org.osate.ge.doc/docs/user_guide.md
Expand Up @@ -289,7 +289,7 @@ Now that we will define an integrated system which contains both the execution p
3. Select *Application* diagram element.
4. Select *Bind...* from the toolbar.
5. Select *Actual_Processor_Binding*.
6. Select *CPU*.
6. Select *CPU* in the diagram or outline view.
7. Select *OK*.

4. **Create a Processor Binding Diagram**
Expand All @@ -314,7 +314,7 @@ Select the desired implementation from the palette and place it on the diagram o
Select *Mode Transition* from the palette and select the starting mode then the ending mode.

## Creating Flow Implementations and End-To-End Flow Specifications
When editing a component implementation, flow implementations and end-to-end flow specifications can be created graphically by selecting the *Create Flow Implementation* and *Create End-To-End Flow Specification* tools from the toolbar and following the prompts to select a series of elements from the diagram. The dialog and colors of elements in the diagram will update as valid selections are made. The starting flow specification will be highlighted dark orange and flow elements will be highlighted purple. The *Undo* button will remove the elements in the order they were selected.
When editing a component implementation, flow implementations and end-to-end flow specifications can be created graphically by selecting the *Create Flow Implementation* and *Create End-To-End Flow Specification* tools from the toolbar and following the prompts to select a series of elements from the diagram or outline view. The dialog and colors of elements in the diagram will update as valid selections are made. The starting flow specification will be highlighted dark orange and flow elements will be highlighted purple. The *Undo* button will remove the elements in the order they were selected.

### Creating Flow Implementations
Select *Create Flow Implementation* from the toolbar, the dialog will appear.
Expand Down
@@ -1,18 +1,18 @@
/**
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
Expand Down
@@ -1,18 +1,18 @@
/**
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
Expand Down Expand Up @@ -158,8 +158,8 @@
import org.osate.ge.internal.ui.editor.actions.RedoAction;
import org.osate.ge.internal.ui.editor.actions.SelectAllAction;
import org.osate.ge.internal.ui.editor.actions.UndoAction;
import org.osate.ge.internal.ui.handlers.AgeHandlerUtil;
import org.osate.ge.internal.ui.util.ContextHelpUtil;
import org.osate.ge.internal.ui.util.SelectionUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

Expand Down Expand Up @@ -193,7 +193,7 @@ public class AgeDiagramBehavior extends DiagramBehavior implements GraphitiAgeDi
};

private final ISelectionListener toolPostSelectionListener = (part, selection) -> {
toolHandler.setSelectedDiagramElements(SelectionUtil.getSelectedDiagramElements(selection, false));
toolHandler.setSelectedElements(AgeHandlerUtil.getSelectedBusinessObjectContexts());
};

@Override
Expand Down Expand Up @@ -530,8 +530,7 @@ public void partOpened(final IWorkbenchPart part) {

editor.getSite().getWorkbenchWindow().getSelectionService()
.addPostSelectionListener(toolPostSelectionListener);
toolHandler.setSelectedDiagramElements(SelectionUtil.getSelectedDiagramElements(
editor.getSite().getWorkbenchWindow().getSelectionService().getSelection(), false));
toolHandler.setSelectedElements(AgeHandlerUtil.getSelectedBusinessObjectContexts());

// Deactivate the tool when the part is deactivated or closed
editor.getSite().getWorkbenchWindow().getPartService().addPartListener(toolPartListener);
Expand Down
@@ -1,18 +1,18 @@
/**
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
Expand Down Expand Up @@ -199,6 +199,10 @@ public void deactivateActiveTool() {

public void clearSelection() {
selectPictogramElements(new PictogramElement[0]);
if (outlinePage != null) {
// Clear outline selection
outlinePage.setSelection(null);
}
}

public void setDiagramContextIsValid(final boolean value) {
Expand Down
@@ -1,18 +1,18 @@
/**
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
Expand All @@ -30,11 +30,11 @@
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior;
import org.osate.ge.BusinessObjectContext;
import org.osate.ge.di.Activate;
import org.osate.ge.di.Names;
import org.osate.ge.internal.di.Deactivate;
import org.osate.ge.internal.di.InternalNames;
import org.osate.ge.internal.di.SelectionChanged;
import org.osate.ge.internal.diagram.runtime.DiagramElement;
import org.osate.ge.internal.services.ExtensionService;

/**
Expand All @@ -45,7 +45,7 @@ public class ToolHandler {
private final DefaultPaletteBehavior paletteBehavior;
private final IEclipseContext context;
private Object activeTool = null;
private DiagramElement[] diagramElements = null;
private BusinessObjectContext[] bocs = null;

public ToolHandler(final ExtensionService extensionService,
final DefaultPaletteBehavior paletteBehavior) {
Expand All @@ -57,7 +57,7 @@ public ToolHandler(final ExtensionService extensionService,

public void dispose() {
this.context.dispose();
diagramElements = null;
bocs = null;
}

public boolean isToolActive() {
Expand Down Expand Up @@ -101,21 +101,20 @@ public void deactivate(final Object tool) {
paletteBehavior.refreshPalette();
}

public void setSelectedElements(final List<BusinessObjectContext> bocs) {
final BusinessObjectContext[] newBocs = bocs.toArray(new BusinessObjectContext[bocs.size()]);

public void setSelectedDiagramElements(final List<DiagramElement> diagramElements) {
if (diagramElements.size() == 0) {
// Ignore the selection if nothing has changed
if (Arrays.equals(this.bocs, newBocs)) {
return;
}

final DiagramElement[] newDiagramElements = diagramElements.toArray(new DiagramElement[diagramElements.size()]);
this.bocs = newBocs;

// Ignore the selection if nothing has changed
if (Arrays.equals(this.diagramElements, newDiagramElements)) {
if (bocs.isEmpty()) {
return;
}

this.diagramElements = newDiagramElements;

// Notify the active tool
if(activeTool != null) {
try {
Expand All @@ -129,17 +128,17 @@ public void setSelectedDiagramElements(final List<DiagramElement> diagramElement
}

private void populateContext() {
if(diagramElements != null) {
if(bocs != null) {
// Update the context
if(diagramElements.length == 1) {
context.set(InternalNames.SELECTED_DIAGRAM_ELEMENT, diagramElements[0]);
if(bocs.length == 1) {
context.set(Names.BUSINESS_OBJECT_CONTEXT, bocs[0]);
}
context.set(InternalNames.SELECTED_DIAGRAM_ELEMENTS, diagramElements);
context.set(Names.BUSINESS_OBJECT_CONTEXTS, bocs);
}
}

private void resetContext() {
context.remove(InternalNames.SELECTED_DIAGRAM_ELEMENT);
context.remove(InternalNames.SELECTED_DIAGRAM_ELEMENTS);
context.remove(Names.BUSINESS_OBJECT_CONTEXT);
context.remove(Names.BUSINESS_OBJECT_CONTEXTS);
}
}

0 comments on commit abf1187

Please sign in to comment.