Commit 863fc97c authored by Simon Barner's avatar Simon Barner
Browse files

Outdated task-internal task-to-component allocation

- Mark metamodel entities for  as deprecated
- Remove editors

TODO: Adjust model-transformations and remove deprecated metamodel entities
refs 3067
parent ab2e7928
ComponentTaskSelectionAdapter.java cd1489f74edd2f6254a27849e40b17e24556044f RED
ComponentTaskSelectionAdapter.java 428128d1dd15611298438a7e0969b89cb9a362a9 RED
ComponentToTaskAllocationTableEditor.java ea944b2e4db32c487f11801176507ad86f459f0a YELLOW
ComponentToTaskAllocationTableEditorBinding.java 56332d55867378cb62831760c8d81dc970d8a6e8 YELLOW
TaskAllocationEditor.java 7b02b5f0be80cbf13bdfe32f60c1757e5d30e308 RED
......
......@@ -40,6 +40,8 @@ import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* TODO Migrate this code into a ComponentArchitecture -> TaskArchitecture model transformation
*
* Selection Adapter for component to task allocation editor/table.
*
* @author eder
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.task.ui.editor;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.tooling.base.ui.dnd.jface.ViewerElementCompositionDropAdapter;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.extension.base.EditorBase;
import org.fortiss.tooling.kernel.ui.util.DragAndDropUtils;
/**
*
* @author eder
*/
public class TaskAllocationEditor extends EditorBase<TaskArchitecture> {
/** The GUI. */
private TaskAllocationEditorGUI gui;
/** Adapter for listening to component to task allocations. */
private EContentAdapter refreshAdapter;
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
gui = new TaskAllocationEditorGUI(parent, SWT.NONE, editedObject);
gui.getTableViewer().setInput(editedObject.getTasks());
refreshAdapter = createRefreshAdapter();
editedObject.eAdapters().add(refreshAdapter);
ViewerElementCompositionDropAdapter dndAdapter =
new ViewerElementCompositionDropAdapter(gui.getTableViewer()) {
Object lastTarget;
/** {@inheritDoc} */
@Override
public boolean validateDrop(Object target, int operation,
TransferData transferType) {
if(target == null) {
target = getViewer().getInput();
}
lastTarget = target;
if(lastTarget instanceof List<?>) {
return true;
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean performDrop(Object data) {
if(lastTarget instanceof List<?>) {
final EObject dropped = DragAndDropUtils.extractDroppedEObject(data);
if(IElementCompositorService.getInstance().canCompose(editedObject,
dropped, null)) {
runAsCommand(editedObject, () -> IElementCompositorService
.getInstance().compose(editedObject, dropped, null));
return true;
}
}
return false;
}
};
gui.getTableViewer().addDropSupport(dndAdapter.getSupportedDNDOperations(),
dndAdapter.getPreferredTransfers(), dndAdapter);
}
/** Creates the refresh adapter that listens for model changes. */
private EContentAdapter createRefreshAdapter() {
return new EContentAdapter() {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
switch(notification.getEventType()) {
case Notification.ADD:
if(notification.getNewValue() instanceof Task) {
gui.getTableViewer().add(notification.getNewValue());
gui.getTableViewer().refresh();
gui.getTableViewer().update(notification.getNewValue(), null);
}
break;
case Notification.SET:
updateSignals();
// TODO
// check if component allocation implies communication between two tasks
// if so: check if there is a connection between those two tasks
// if not: create a communication between those two tasks
break;
case Notification.REMOVE:
// TODO
// check if removed allocation removes communication between two tasks
// if so: delete communication between those two tasks
break;
default:
// Ignore other commands.
}
}
};
}
/** {@inheritDoc} */
@Override
public void dispose() {
editedObject.eAdapters().remove(refreshAdapter);
}
protected void updateSignals() {
// TODO Auto-generated method stub
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.task.ui.editor;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
* Task - Component Allocation editor binding
*
* @author eder
*/
public class TaskAllocationEditorBinding extends ModelEditorBindingBase<TaskArchitecture> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return TaskAllocationEditor.class;
}
/** {@inheritDoc} */
@Override
public String getLabel() {
return "Task Allocation";
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.task.ui.editor;
import static org.fortiss.af3.component.utils.ComponentUtils.getAllSubComponentsRecursively;
import static org.fortiss.af3.task.util.TaskAllocationUtils.getAllocationOf;
import java.util.List;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
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.custom.TableEditor;
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.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskAllocation;
import org.fortiss.af3.task.model.TaskArchitecture;
/**
* GENERATED CODE (WindowBuilder)
*
* @author eder
*/
@SuppressWarnings("javadoc")
public class TaskAllocationEditorGUI extends Composite {
private Table table;
private TableViewer tableViewer;
private TaskArchitecture taskArchitecture;
/** Constructor. */
public TaskAllocationEditorGUI(Composite parent, int style, TaskArchitecture taskArchitecture) {
super(parent, style);
this.taskArchitecture = taskArchitecture;
setLayout(new GridLayout(1, false));
tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer.setContentProvider(new ArrayContentProvider());
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnTask = tableViewerColumn.getColumn();
tblclmnTask.setWidth(100);
tblclmnTask.setText("Task");
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
Task t = (Task)element;
return t.getName();
}
});
Component topComponent =
taskArchitecture.getComponentArchitectureReference().getTopComponent();
List<Component> componentsRecursively = getAllSubComponentsRecursively(topComponent);
for(Component c : componentsRecursively) {
TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnStart = tableViewerColumn_1.getColumn();
tblclmnStart.setWidth(50);
tblclmnStart.setText(c.getName());
tableViewerColumn_1.setLabelProvider(createComponentColumn(taskArchitecture, c));
}
}
/** Creates a column for a {@link Component} {@code c} with a tick box for each task assignment. */
private ColumnLabelProvider
createComponentColumn(TaskArchitecture taskArchitecture, Component c) {
return new ColumnLabelProvider() {
private Task task;
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem)cell.getItem();
task = (Task)item.getData();
Button button = new Button(tableViewer.getTable(), SWT.CHECK);
button.addSelectionListener(new ComponentTaskSelectionAdapter(task, c,
taskArchitecture));
TaskAllocation tAlloc = getAllocationOf(taskArchitecture, c);
if(tAlloc != null && tAlloc.getTask() == task) {
button.setSelection(true);
}
TableEditor editor = new TableEditor(tableViewer.getTable());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(button, item, cell.getColumnIndex());
editor.layout();
}
};
}
/** Returns tableViewer. */
public TableViewer getTableViewer() {
return tableViewer;
}
/** {@inheritDoc} */
@Override
public boolean setFocus() {
tableViewer.refresh();
return super.setFocus();
}
}
......@@ -13,20 +13,46 @@
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="taskAllocations" upperBound="-1"
eType="#//TaskAllocation" containment="true"/>
eType="#//TaskAllocation" containment="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="signalAllocations" upperBound="-1"
eType="#//SignalAllocation" containment="true"/>
eType="#//SignalAllocation" containment="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="componentArchitectureReference"
eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//ComponentArchitecture"/>
eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//ComponentArchitecture">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Task" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//layout/ILayoutedModelElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElement"/>
<eClassifiers xsi:type="ecore:EClass" name="SignalAllocation">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="channels" lowerBound="1"
upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Channel"/>
upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Channel">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="TODO: write documentation (in the model!)"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="signal" lowerBound="1"
eType="#//Signal"/>
eType="#//Signal">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="TODO: write documentation (in the model!)"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TaskAllocation">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="components" lowerBound="1"
upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="task" lowerBound="1" eType="#//Task"/>
......@@ -34,10 +60,18 @@
<eClassifiers xsi:type="ecore:EClass" name="Signal" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/ConnectionSegmentBase"/>
<eClassifiers xsi:type="ecore:EClass" name="SignalPort" abstract="true" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/ConnectorBase"/>
<eClassifiers xsi:type="ecore:EClass" name="InputSignalPort" eSuperTypes="#//SignalPort platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/EntryConnectorBase">
<eStructuralFeatures xsi:type="ecore:EReference" name="inputPortReference" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//InputPort"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="inputPortReference" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//InputPort">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="OutputSignalPort" eSuperTypes="#//SignalPort platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/ExitConnectorBase">
<eStructuralFeatures xsi:type="ecore:EReference" name="outputPortReference" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//OutputPort"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="outputPortReference" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//OutputPort">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Use ComponentToTaskAllocationTable instead"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="InputBufferedSignalPort" eSuperTypes="#//InputSignalPort">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bufferSize" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment