Commit 9ed76899 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

YELLOW.

refs 2490
parent 8e6c51e0
......@@ -27,10 +27,9 @@ import org.osgi.framework.BundleContext;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9DC68662D9F1765A0A286793C828A64B
* @ConQAT.Rating YELLOW Hash: E598D5FAA197E58EF5B04C4E9E46EAED
*/
public class ToolingBaseUIActivator extends AbstractUIPlugin {
/** The plug-in ID. */
public static final String PLUGIN_ID = ToolingBaseUIActivator.class.getPackage().getName(); //$NON-NLS-1$
......
......@@ -35,7 +35,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 824BD55548FDD6AE4D4FF4C9DEFBE16E
* @ConQAT.Rating YELLOW Hash: 8102CB44C7931250F4224AA5019C5011
*/
public abstract class AnnotationEditingSupportBase extends EditingSupport {
......@@ -98,25 +98,21 @@ public abstract class AnnotationEditingSupportBase extends EditingSupport {
final AnnotationEntry annotationEntry = (AnnotationEntry)element;
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(annotationEntry
.getModelElement());
modelContext.runAsCommand(new Runnable() {
@Override
public void run() {
try {
doSetValue(annotationEntry, value);
} catch(IllegalArgumentException e) {
String msg =
"The value you entered does not have the desired type.\nDetailed message:\n" +
e.getMessage();
openError(new Shell(), "ERROR", msg);
} catch(Exception e) {
openError(new Shell(), "ERROR", e.getMessage());
}
}
});
IPersistencyService.getInstance().getTopLevelElementFor(
annotationEntry.getModelElement());
modelContext
.runAsCommand(() -> {
try {
doSetValue(annotationEntry, value);
} catch(IllegalArgumentException e) {
String msg =
"The value you entered does not have the desired type.\nDetailed message:\n" +
e.getMessage();
openError(new Shell(), "ERROR", msg);
} catch(Exception e) {
openError(new Shell(), "ERROR", e.getMessage());
}
});
this.getViewer().refresh(true);
}
}
......
......@@ -37,7 +37,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 8DBC1CF96C363577F23800CBF25DC376
* @ConQAT.Rating YELLOW Hash: 9C6273D44DD9340894CD37DDFA216B73
*
*/
public class MultiSelectionEditingSupport extends AnnotationEditingSupportBase {
......@@ -138,7 +138,8 @@ public class MultiSelectionEditingSupport extends AnnotationEditingSupportBase {
final AnnotationEntry entry = (AnnotationEntry)element;
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(entry.getModelElement());
IPersistencyService.getInstance()
.getTopLevelElementFor(entry.getModelElement());
modelContext.runAsCommand(new Runnable() {
@Override
......
......@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation.view.generic;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.NotificationImpl;
import org.eclipse.emf.common.util.EMap;
......@@ -24,7 +26,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
......@@ -64,10 +65,9 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author diewald, barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: A24FA05DE5A868FBA7F8EE21F78CDDD0
* @ConQAT.Rating YELLOW Hash: 5737954A300FB54DF6EEB82B0B95CF77
*/
public class CreateAnnotationInstanceColumn extends ViewerColumn {
/** The column to be added to the table. */
private TableColumn column;
......@@ -226,75 +226,71 @@ public class CreateAnnotationInstanceColumn extends ViewerColumn {
// for the input key provided by the user. A write transaction / a switch to the
// model context is required to modify the from the GUI context.
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(columnSpecAnnEntry
.getModelElement());
modelContext.runAsCommand(new Runnable() {
@Override
public void run() {
try {
// Populate new instance (in order to make the corresponding cells
// editable
String value = "";
if(!columnSpec.eClass().getEStructuralFeatures().isEmpty()) {
// get(0) is safe because list is guaranteed to be non-empty.
// Furthermore, the first element is the one to use, since...
EStructuralFeature dynamicInstanceFeature =
columnSpec.eClass().getEStructuralFeatures().get(0);
// ...annotations that can be dynamically instantiated are
// implemented using an appropriate EMap (which by convention
// has to be the // first (and only)) feature of the
// corresponding annotation class.
if(dynamicInstanceFeature.getEType().getInstanceTypeName()
.equals("java.util.Map$Entry")) {
// Determine value type
EStructuralFeature valueFeature =
((EClass)dynamicInstanceFeature.getEType())
.getEStructuralFeature("value");
if(Number.class.isAssignableFrom(valueFeature.getEType()
.getInstanceClass())) {
IPersistencyService.getInstance().getTopLevelElementFor(
columnSpecAnnEntry.getModelElement());
modelContext
.runAsCommand(() -> {
try {
String value = populateInstance();
AnnotationEntry entry =
IAnnotationValueService.getInstance()
.getAnnotationEntry(
columnSpecAnnEntry.getModelElement());
// Initialize numbers with 0
// (initialization fails with "")
value = "0";
}
}
entry.setSpecificationValue(value, columnSpec.getClass(),
instanceKey);
// Inform others, e.g. the respective annotation view that a new
// instance of this annotation has been created.
columnSpecAnnEntry.getModelElement().eNotify(
new NotificationImpl(Notification.SET, null, null) {
@Override
public Object getNotifier() {
return columnSpecAnnEntry.getModelElement();
}
});
} catch(IllegalArgumentException e) {
openError(
new Shell(),
"ERROR",
"The value you entered does not have the desired type.\nDetailed message:\n" +
e.getMessage());
} catch(Exception e) {
openError(new Shell(), "ERROR", e.getMessage());
}
});
}
}
}
}
/** Populate new instance (in order to make the corresponding cells editable */
private String populateInstance() {
String value = "";
if(!columnSpec.eClass().getEStructuralFeatures().isEmpty()) {
// get(0) is safe because list is guaranteed to be non-empty.
// Furthermore, the first element is the one to use, since...
EStructuralFeature dynamicInstanceFeature =
columnSpec.eClass().getEStructuralFeatures().get(0);
AnnotationEntry entry =
IAnnotationValueService.getInstance()
.getAnnotationEntry(columnSpecAnnEntry
.getModelElement());
// ...annotations that can be dynamically instantiated are
// implemented using an appropriate EMap (which by convention
// has to be the // first (and only)) feature of the
// corresponding annotation class.
if(dynamicInstanceFeature.getEType().getInstanceTypeName()
.equals("java.util.Map$Entry")) {
entry.setSpecificationValue(value, columnSpec.getClass(),
instanceKey);
// Determine value type
EStructuralFeature valueFeature =
((EClass)dynamicInstanceFeature.getEType()).getEStructuralFeature("value");
if(Number.class.isAssignableFrom(valueFeature.getEType().getInstanceClass())) {
// Inform others, e.g. the respective annotation view that a new
// instance of this annotation has been created.
columnSpecAnnEntry.getModelElement().eNotify(
new NotificationImpl(Notification.SET, null, null) {
@Override
public Object getNotifier() {
return columnSpecAnnEntry.getModelElement();
}
});
} catch(IllegalArgumentException e) {
MessageDialog
.openError(
new Shell(),
"ERROR",
"The value you entered does not have the desired type.\nDetailed message:\n" +
e.getMessage());
} catch(Exception e) {
MessageDialog.openError(new Shell(), "ERROR", e.getMessage());
}
}
});
// Initialize numbers with 0
// (initialization fails with "")
value = "0";
}
}
}
return value;
}
/**
......
......@@ -17,7 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.dialog;
import java.util.Collections;
import static java.util.Collections.emptyList;
import java.util.List;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
......@@ -34,11 +35,10 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 21565202D54B03924D0B32263189AEF1
* @ConQAT.Rating YELLOW Hash: 20F6C6A825B2B1BCF5A1F74257590066
*/
public class ModelElementTreeContentProvider extends TreeContentProviderBase {
/** the root elements */
/** The root elements. */
private final List<? extends EObject> roots;
/** Constructor */
......@@ -54,7 +54,6 @@ public class ModelElementTreeContentProvider extends TreeContentProviderBase {
return null;
return ((EObject)element).eContainer();
}
return new Object[0];
}
......@@ -65,7 +64,6 @@ public class ModelElementTreeContentProvider extends TreeContentProviderBase {
return getChildren((EObject)parentElement).toArray();
}
return new Object[0];
}
......@@ -79,7 +77,6 @@ public class ModelElementTreeContentProvider extends TreeContentProviderBase {
if(base != null) {
return base.getSubnodes(parentElement);
}
return Collections.emptyList();
return emptyList();
}
}
......@@ -32,11 +32,10 @@ import org.fortiss.tooling.kernel.extension.data.ILogMessageContext;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 569C07E297B68D0F11D18A7AFC5306DA
* @ConQAT.Rating YELLOW Hash: 1E890F6C055CF4A8138A6939E43D3D67
*/
public class ModelElementWithRefCopyMessageHandler implements
LogMessageHandler<ModelElementWithRefCopyMessage> {
/** Title of the dialog. */
private static final String TITLE = "References to external model elements.";
......
......@@ -45,7 +45,7 @@ import org.fortiss.tooling.kernel.ui.util.DragAndDropUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: C4903F41B0DF5893AA96A545E918CD8E
* @ConQAT.Rating YELLOW Hash: B4683FBAC511C000EA21DF37A5521627
*/
public class ViewerElementCompositionDropAdapter extends ViewerDropAdapter {
......
......@@ -36,7 +36,7 @@ import org.fortiss.tooling.kernel.ui.service.IAllocationEditPartFactoryService;
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 70265E0D2F1FF61BF1586D41044AAE66
* @ConQAT.Rating YELLOW Hash: 0C7DA8DF72C3DC255562F36F8F1EF235
*/
public class AllocationDiagramEditorBase<T extends EObject> extends CommonDiagramEditorBase<T> {
......
......@@ -117,7 +117,7 @@ import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
* @author hoelzl
* @author $Author: aravantinos $
* @version $Rev: 13954 $
* @ConQAT.Rating RED Hash: 3889454412BA494335D8DF83F89CD6F2
* @ConQAT.Rating YELLOW Hash: AA59F547B0610F86EC4E42B739733731
*/
abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<T> implements
IPostSelectionProvider, ContextMenuContextProvider {
......
......@@ -34,10 +34,9 @@ import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 1AD878C6EE8579898FD319E38246D449
* @ConQAT.Rating YELLOW Hash: 1B3A77322699F6EB9D7280C07A2484FD
*/
public class DiagramEditorBase<T extends EObject> extends CommonDiagramEditorBase<T> {
/** Constructor. */
public DiagramEditorBase() {
super(new ScrollingGraphicalViewer(), IEditPartFactoryService.getInstance());
......
......@@ -43,17 +43,14 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 5EE41557BB4A7BDE48CCD6404F0034BC
* @ConQAT.Rating YELLOW Hash: CC77BCDDC8E3E2E4D8C7C94535532E4B
*/
public class DiagramKeyHandler extends KeyHandler {
/** The embedded viewer. */
private GraphicalViewer viewer;
/**
* @param viewer
* Constructs a {@link KeyHandler} for viewer.
*/
/** Constructor. */
public DiagramKeyHandler(GraphicalViewer viewer) {
this.viewer = viewer;
}
......@@ -71,13 +68,8 @@ public class DiagramKeyHandler extends KeyHandler {
return scrollElementIfNeeded(event);
}
// TODO: @param is too much here
/**
* @param event
* Scrolls the viewer according to the event if no editpart is selected.
*/
// TODO (FH): private?
boolean scrollViewerIfNeeded(KeyEvent event) {
/** Scrolls the viewer according to the event if no editpart is selected. */
private boolean scrollViewerIfNeeded(KeyEvent event) {
if(!(viewer.getSelectedEditParts().isEmpty() && viewer.getControl() instanceof FigureCanvas))
return false;
FigureCanvas figCanvas = (FigureCanvas)viewer.getControl();
......@@ -89,11 +81,7 @@ public class DiagramKeyHandler extends KeyHandler {
return true;
}
// TODO: @param is too much here
/**
* @param event
* Scrolls the model of the selected editpart according to the event.
*/
/** Scrolls the model of the selected editpart according to the event. */
private boolean scrollElementIfNeeded(KeyEvent event) {
if(!(viewer.getFocusEditPart() instanceof PositionedEditPartBase<?>))
return false;
......@@ -111,12 +99,7 @@ public class DiagramKeyHandler extends KeyHandler {
return true;
}
// TODO: @param is too much here
/**
* @param event
* @return
* Coefficient of 1 if the SHIFT key is not pressed, 50 otherwise.
*/
/** Returns a coefficient of 1 if the SHIFT key is not pressed, 50 otherwise. */
private Point computeScrollCoeff(KeyEvent event) {
int coeff = (event.stateMask & SWT.SHIFT) == 0 ? 1 : 10;
if(event.keyCode == SWT.ARROW_DOWN)
......
......@@ -39,7 +39,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: DC9C2F53C31BA1266F540BA4615E67F1
* @ConQAT.Rating YELLOW Hash: 10B06F6BEB23943035589F0C5B675B24
*/
public abstract class GEFEditorBase<T extends EObject> extends
org.fortiss.tooling.kernel.ui.extension.base.EditorBase<T> {
......
......@@ -71,7 +71,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 33683FAE49F7A27B291767779510466B
* @ConQAT.Rating YELLOW Hash: 4DDBB5752B82805828138AAC988C6FB5
*/
public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase> extends
AbstractConnectionEditPart {
......
......@@ -59,7 +59,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: D48A71D6A7B2EADEAA752C2B08772ADB
* @ConQAT.Rating YELLOW Hash: D12C80B0BAFBFB9A9A76E302A528F5EB
*/
public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INamedCommentedElement>
extends PositionedEditPartBase<T> {
......@@ -81,8 +81,8 @@ public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INam
nameLabel.setFont(DEFAULT_TITLE_FONT);
nameLabel.setTextAlignment(PositionConstants.LEFT | PositionConstants.TOP);
nameLabel.setTextPlacement(PositionConstants.EAST);
nameLabel.setIcon(IModelElementHandlerService.getInstance().getModelElementHandler(getModel())
.getIcon(getModel()));
nameLabel.setIcon(IModelElementHandlerService.getInstance()
.getModelElementHandler(getModel()).getIcon(getModel()));
return nameLabel;
}
......@@ -149,7 +149,6 @@ public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INam
@Override
protected void refreshVisuals() {
super.refreshVisuals();
for(EditPart child : (List<EditPart>)getChildren()) {
child.refresh();
}
......
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 1B0A0DB55C208B24CAAB131BFEA4BDCB
* @ConQAT.Rating YELLOW Hash: 0528B83AC53842521014F7A44293E0B7
*/
public abstract class GraphicalEditPartBase<T extends EObject> extends AbstractGraphicalEditPart {
......@@ -54,13 +54,9 @@ public abstract class GraphicalEditPartBase<T extends EObject> extends AbstractG
// if not removing adapters, just refresh everything
if(notification.getEventType() != Notification.REMOVING_ADAPTER) {
// ensure that refresh is run in the UI thread
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
refresh();
}
Display.getDefault().syncExec(() -> {
refresh();
});
}
}
......
......@@ -75,7 +75,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CAB71AE0F7849C9B28E225D128B37FA4
* @ConQAT.Rating YELLOW Hash: 79D8F8BA81F856A6D6B2CF24FF803483
*/
public abstract class PositionedEditPartBase<T extends ILayoutedModelElement> extends
GraphicalEditPartBase<T> implements NodeEditPart {
......
......@@ -35,7 +35,7 @@ import org.fortiss.tooling.base.ui.layout.IDiagramLayoutConfiguration;
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @param <T>
* @ConQAT.Rating RED Hash: 2658B07745A8C6567BF8554A49171164
* @ConQAT.Rating YELLOW Hash: 1F9B1A2E2A693C00218F66D1F0390BD8
*/
public abstract class AllocationConnectionEditPartBase<T extends ConnectionSegmentBase> extends
ConnectionEditPartBase<T> {
......@@ -53,7 +53,6 @@ public abstract class AllocationConnectionEditPartBase<T extends ConnectionSegme
EditPart target = getTarget();
EditPart source = getSource();
// Prevent connections from being shown in the wrong hierarchical layers
figure.setVisible(target != null && source != null);
}
......
......@@ -58,7 +58,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 85EC44BA4D266213B269443441E4DF7D
* @ConQAT.Rating YELLOW Hash: 1D4E7BC939285B0FE2F81A3D7415D74D
*/
public abstract class AllocationElementEditPartBase<T extends ILayoutedModelElement & INamedCommentedElement>
extends PositionedEditPartBase<T> {
......@@ -113,8 +113,8 @@ public abstract class AllocationElementEditPartBase<T extends ILayoutedModelElem
nameLabel.setFont(DEFAULT_TITLE_FONT);
nameLabel.setTextAlignment(PositionConstants.LEFT | PositionConstants.TOP);
nameLabel.setTextPlacement(PositionConstants.EAST);
nameLabel.setIcon(IModelElementHandlerService.getInstance().getModelElementHandler(getModel())
.getIcon(getModel()));
nameLabel.setIcon(IModelElementHandlerService.getInstance()
.getModelElementHandler(getModel()).getIcon(getModel()));
return nameLabel;
}
......@@ -202,7 +202,6 @@ public abstract class AllocationElementEditPartBase<T extends ILayoutedModelElem
for(int i = 0; i < list.size(); i++) {
((EditPart)list.get(i)).refresh();
}
for(ConnectionEditPart editPart : getSourceConnections()) {
editPart.refresh();
}
......
......@@ -30,9 +30,16 @@ import org.eclipse.gef.RootEditPart;
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 27946C8CFD460886A9A25F8F6DE2CD17
* @ConQAT.Rating YELLOW Hash: 789A62CA87C2F52B82732A2BB0DCE1C2
*/
public class AllocationPositionService implements IAllocationPositionService {
/** Singleton instance. */
private static AllocationPositionService INSTANCE = new AllocationPositionService();
/** Returns the service instance. */
public static AllocationPositionService getInstance() {
return INSTANCE;
}
/** M