Commit 8b82552a authored by Dongyue Mou's avatar Dongyue Mou
Browse files

apply the new code format rules on all source code

parent 34d7096e
......@@ -33,8 +33,7 @@ import org.osgi.framework.BundleContext;
public class AF3ComponentUIActivator extends AbstractUIPlugin {
/** The plug-in ID. */
public static final String PLUGIN_ID = AF3ComponentUIActivator.class
.getPackage().getName(); //$NON-NLS-1$
public static final String PLUGIN_ID = AF3ComponentUIActivator.class.getPackage().getName(); //$NON-NLS-1$
/** The shared instance. */
private static AF3ComponentUIActivator plugin;
......
......@@ -33,14 +33,11 @@ import org.fortiss.af3.component.model.Component;
public final class DefaultStyle {
/** {@link Component} background color for strong causality. */
public static Color STRONGLY_CAUSAL_COMPONENT_BACKGROUND = createColor(159,
186, 221);
public static Color STRONGLY_CAUSAL_COMPONENT_BACKGROUND = createColor(159, 186, 221);
/** {@link Component} background color for strong causality. */
public static Color WEAKLY_CAUSAL_COMPONENT_BACKGROUND = createColor(250,
232, 131);
public static Color WEAKLY_CAUSAL_COMPONENT_BACKGROUND = createColor(250, 232, 131);
/** {@link Component} background color for component sub-structure.. */
public static Color SUBSTRUCTURE_COMPONENT_BACKGROUND = createColor(224,
192, 192);
public static Color SUBSTRUCTURE_COMPONENT_BACKGROUND = createColor(224, 192, 192);
/** {@link Component} foreground color. */
public static Color COMPONENT_FOREGROUND = createColor(14, 46, 88);
......
......@@ -46,15 +46,14 @@ public class ActionsToStringConverter extends Converter {
public Object convert(Object fromObject) {
StringBuffer buffer = new StringBuffer();
// build a sequence of semi-colon separated actions
for (Action action : (List<Action>) fromObject) {
if (buffer.length() > 0) {
for(Action action : (List<Action>)fromObject) {
if(buffer.length() > 0) {
buffer.append("; ");
}
Var variable = action.getVariable();
ITerm value = action.getValue();
buffer.append(variable.getIdentifier()).append("=")
.append(value.toString());
buffer.append(variable.getIdentifier()).append("=").append(value.toString());
}
return buffer.toString();
}
}
\ No newline at end of file
}
......@@ -39,8 +39,8 @@ public class GuardToStringConverter extends Converter {
/** {@inheritDoc} */
@Override
public String convert(Object fromObject) {
Guard condition = (Guard) fromObject;
if (condition == null) {
Guard condition = (Guard)fromObject;
if(condition == null) {
return "";
}
ITerm expression = condition.getExpression();
......
......@@ -54,19 +54,18 @@ public class StringToActionsConverter extends Converter {
public Object convert(Object fromObject) {
// split semi-colon separated list
EList<EObject> actions = new BasicEList<EObject>();
for (String str : splitString((String) fromObject, ";")) {
for(String str : splitString((String)fromObject, ";")) {
Action action = CommonFactory.eINSTANCE.createAction();
try {
// split action parts: variable and value
String[] strs = splitString(str, "=");
action.setVariable((Var) singleStringConverter.convert(strs[0]));
action.setVariable((Var)singleStringConverter.convert(strs[0]));
action.setValue(singleStringConverter.convert(strs[1]));
actions.add(action);
} catch (Exception e) {
error(getDefault(),
"Conversion problems not caught by the validator!", e);
} catch(Exception e) {
error(getDefault(), "Conversion problems not caught by the validator!", e);
}
}
return actions;
}
}
\ No newline at end of file
}
......@@ -50,18 +50,18 @@ public class StringToActionsValidator implements IValidator {
@Override
public IStatus validate(Object value) {
// split semi-colon separated list
for (String str : splitString(((String) value), ";")) {
ITypeSystemCompiler compiler = ITypeSystemService.INSTANCE
.getHandler(editedObject).getTypeSystemCompiler();
for(String str : splitString(((String)value), ";")) {
ITypeSystemCompiler compiler =
ITypeSystemService.INSTANCE.getHandler(editedObject).getTypeSystemCompiler();
try {
// split action parts: variable and value
String[] strs = splitString(str, "=");
compiler.compileTerm(strs[0]);
compiler.compileTerm(strs[1]);
} catch (ParseException e) {
} catch(ParseException e) {
return cancel(e.getMessage());
}
}
return ok();
}
}
\ No newline at end of file
}
......@@ -47,14 +47,13 @@ public class StringToGuardConverter extends Converter {
/** {@inheritDoc} */
@Override
public Object convert(Object fromObject) {
if (((String) fromObject).trim().length() == 0) {
if(((String)fromObject).trim().length() == 0) {
return null;
}
try {
return createGuard(singleStringConverter.convert(fromObject));
} catch (Exception e) {
error(getDefault(),
"Conversion problems not caught by the validator!", e);
} catch(Exception e) {
error(getDefault(), "Conversion problems not caught by the validator!", e);
}
return null;
}
......
......@@ -41,10 +41,10 @@ public class StringToGuardValidator extends StringToIExpressionTermValidator {
/** {@inheritDoc} */
@Override
public IStatus validate(Object value) {
String term = ((String) value).trim();
if (term.length() == 0) {
String term = ((String)value).trim();
if(term.length() == 0) {
return ok();
}
return super.validate(value);
}
}
\ No newline at end of file
}
......@@ -42,8 +42,8 @@ public class ComponentArchitectureCompositor extends
/** {@inheritDoc} */
@Override
public boolean canCompose(ComponentArchitecture container,
EObject contained, IElementCompositionContext context) {
public boolean canCompose(ComponentArchitecture container, EObject contained,
IElementCompositionContext context) {
return isCorrectElementClass(contained);
}
......@@ -51,10 +51,9 @@ public class ComponentArchitectureCompositor extends
@Override
public boolean compose(ComponentArchitecture container, EObject contained,
IElementCompositionContext context) {
if (contained instanceof Component) {
if(contained instanceof Component) {
// bridge hidden root component
container.getContainedElements(0).getContainedElementsList()
.add((Component) contained);
container.getContainedElements(0).getContainedElementsList().add((Component)contained);
return true;
}
return false;
......@@ -68,8 +67,7 @@ public class ComponentArchitectureCompositor extends
/** Returns whether the given element is of an acceptable class. */
private boolean isCorrectElementClass(EObject element) {
return isInstanceOfAny(element, Component.class, InputPort.class,
OutputPort.class);
return isInstanceOfAny(element, Component.class, InputPort.class, OutputPort.class);
}
/** {@inheritDoc} */
......
......@@ -46,8 +46,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: A06AB2959A66B984B6A4647E3654E36E
*/
public class ComponentCompositor extends
HierarchicElementCompositorBase<Component> {
public class ComponentCompositor extends HierarchicElementCompositorBase<Component> {
/** {@inheritDoc} */
@Override
......@@ -57,12 +56,11 @@ public class ComponentCompositor extends
// contains already a behavior specification of arbitrary kind,
// it should be an atomic component. Hence, it is not allowed to add
// sub-components into that component (see ticket #458).
if (context instanceof ElementDropContext
&& contained instanceof Component
&& ((ElementDropContext) context).getDropTarget() instanceof ComponentEditPart) {
if(context instanceof ElementDropContext && contained instanceof Component &&
((ElementDropContext)context).getDropTarget() instanceof ComponentEditPart) {
return container.getSpecificationsLength() == 0;
}
if (context == null && contained instanceof Component) {
if(context == null && contained instanceof Component) {
return !hasBehaviorDefinitionSpecification(container);
}
return isCorrectElementClass(contained);
......@@ -72,27 +70,24 @@ public class ComponentCompositor extends
@Override
public boolean compose(Component container, EObject contained,
IElementCompositionContext context) {
if (contained instanceof Component) {
Component component = (Component) contained;
if (context instanceof ElementDropContext) {
layoutNodeInRoot(component, (ElementDropContext) context,
DEFAULT_GRID_SIZE, true);
if(contained instanceof Component) {
Component component = (Component)contained;
if(context instanceof ElementDropContext) {
layoutNodeInRoot(component, (ElementDropContext)context, DEFAULT_GRID_SIZE, true);
}
container.getContainedElementsList().add(component);
return true;
}
if (contained instanceof Port) {
Port port = (Port) contained;
if(contained instanceof Port) {
Port port = (Port)contained;
avoidDuplicatePortName(port, container);
if (context instanceof ElementDropContext) {
final ElementDropContext ctx = (ElementDropContext) context;
if (ctx.isRoot()) {
layoutNodeInRoot(port, ctx, DEFAULT_CONNECTOR_SIZE / 2,
true);
if(context instanceof ElementDropContext) {
final ElementDropContext ctx = (ElementDropContext)context;
if(ctx.isRoot()) {
layoutNodeInRoot(port, ctx, DEFAULT_CONNECTOR_SIZE / 2, true);
} else {
layoutConnectorInRectangle(port, container,
ctx.getPosition());
layoutConnectorInRectangle(port, container, ctx.getPosition());
}
}
container.getConnectorsList().add(port);
......@@ -102,15 +97,14 @@ public class ComponentCompositor extends
}
/** Alters port name if duplicate name already exists. */
/* package */static void avoidDuplicatePortName(Port port,
Component container) {
if (port.getComponent() == container) {
/* package */static void avoidDuplicatePortName(Port port, Component container) {
if(port.getComponent() == container) {
return;
}
int num = 1;
String orig = port.getName();
while (findInputPort(container, port.getName()) != null
|| findOutputPort(container, port.getName()) != null) {
while(findInputPort(container, port.getName()) != null ||
findOutputPort(container, port.getName()) != null) {
port.setName(orig + num);
num++;
}
......@@ -124,8 +118,7 @@ public class ComponentCompositor extends
/** Returns whether the given element is of an acceptable class. */
private boolean isCorrectElementClass(EObject element) {
return isInstanceOfAny(element, Component.class, InputPort.class,
OutputPort.class);
return isInstanceOfAny(element, Component.class, InputPort.class, OutputPort.class);
}
/** {@inheritDoc} */
......
......@@ -39,15 +39,14 @@ import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: ED6D082F9E38342AEE3DF1F25F0744B9
*/
public class ComponentConnectionCompositor
extends
public class ComponentConnectionCompositor extends
HierarchicElementConnectionCompositorBase<Component, Component, Component> {
/** {@inheritDoc} */
@Override
public boolean canConnect(Component source, Component target,
Component parent, IConnectionCompositionContext context) {
if (source.eContainer() != target.eContainer()) {
public boolean canConnect(Component source, Component target, Component parent,
IConnectionCompositionContext context) {
if(source.eContainer() != target.eContainer()) {
return false;
}
return super.canConnect(source, target, parent, context);
......@@ -62,8 +61,8 @@ public class ComponentConnectionCompositor
/** {@inheritDoc} */
@Override
protected IConnector createSourceConnector(Component source,
Component target, IConnectionCompositionContext context) {
protected IConnector createSourceConnector(Component source, Component target,
IConnectionCompositionContext context) {
OutputPort op = createOutputPort("Output", "");
avoidDuplicatePortName(op, source);
return op;
......@@ -71,8 +70,8 @@ public class ComponentConnectionCompositor
/** {@inheritDoc} */
@Override
protected IConnector createTargetConnector(Component source,
Component target, IConnectionCompositionContext context) {
protected IConnector createTargetConnector(Component source, Component target,
IConnectionCompositionContext context) {
InputPort ip = createInputPort("Input", "");
avoidDuplicatePortName(ip, source);
return ip;
......
......@@ -29,8 +29,7 @@ import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: B6999890427222F1F8DC5083D96A5B5E
*/
public class CodeSpecificationEditorBinding implements
IModelEditorBinding<CodeSpecification> {
public class CodeSpecificationEditorBinding implements IModelEditorBinding<CodeSpecification> {
/** {@inheritDoc} */
@Override
......
......@@ -27,16 +27,15 @@ import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
* {@link IModelEditorBinding} implementation for the component structure editor
* opened by {@link ComponentArchitecture} model element.
*
* This editor binding is needed to open the component editor from
* {@link ComponentArchitecture} elements, which are the top-level wrappers of a
* hidden {@link Component} instance. See also the {@link PrototypeProvider}
* implementation.
* This editor binding is needed to open the component editor from {@link ComponentArchitecture}
* elements, which are the top-level wrappers of a
* hidden {@link Component} instance. See also the {@link PrototypeProvider} implementation.
*
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 24F4023424C8C51347EE819DEB3C554A
* @ConQAT.Rating GREEN Hash: 6045AE891DB43BCD330485A62DAFD574
*/
public final class ComponentArchitectureEditorBinding implements
IModelEditorBinding<ComponentArchitecture> {
......
......@@ -32,15 +32,13 @@ import org.fortiss.tooling.base.ui.editor.DiagramEditorBase;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: F88E4385307A4891B4F6C1440E16E4BE
*/
public class ComponentStructureEditor extends
DiagramEditorBase<Component> {
public class ComponentStructureEditor extends DiagramEditorBase<Component> {
/** {@inheritDoc} */
@Override
protected Object getViewerContentObject() {
if (getEditedObject() instanceof ComponentArchitecture) {
return ((ComponentArchitecture) getEditedObject())
.getContainedElements(0);
if(getEditedObject() instanceof ComponentArchitecture) {
return ((ComponentArchitecture)getEditedObject()).getContainedElements(0);
}
return getEditedObject();
}
......@@ -49,6 +47,6 @@ public class ComponentStructureEditor extends
@SuppressWarnings("unchecked")
@Override
public Class<? extends EObject>[] getVisibleEObjectTypes() {
return new Class[] { Component.class, InputPort.class, OutputPort.class };
return new Class[] {Component.class, InputPort.class, OutputPort.class};
}
}
......@@ -30,8 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 8F1A84725DD462CF5A7651FEDF9D9227
*/
public final class ComponentStructureEditorBinding implements
IModelEditorBinding<Component> {
public final class ComponentStructureEditorBinding implements IModelEditorBinding<Component> {
/** {@inheritDoc} */
@Override
......
......@@ -39,15 +39,13 @@ import org.fortiss.tooling.kernel.ui.util.ObservableUtils;
* @version $Rev: 5261 $
* @ConQAT.Rating GREEN Hash: 190C2DC7ABBAAFAC0D466AAA1AD46DD5
*/
class DataStateTypeEditingSupport extends
AbstractDecoratedTextCellDatabindingEditingSupport {
class DataStateTypeEditingSupport extends AbstractDecoratedTextCellDatabindingEditingSupport {
/** Edited object. */
private EObject model;
/** Constructor */
public DataStateTypeEditingSupport(ColumnViewer viewer,
DataBindingContext dbc, EObject model) {
public DataStateTypeEditingSupport(ColumnViewer viewer, DataBindingContext dbc, EObject model) {
super(viewer, dbc);
this.model = model;
}
......@@ -55,7 +53,7 @@ class DataStateTypeEditingSupport extends
/** {@inheritDoc} */
@Override
protected IObservableValue getModelObservableValue(Object model) {
return ObservableUtils.observeValue((DataStateVariable) model,
return ObservableUtils.observeValue((DataStateVariable)model,
CommonPackage.Literals.DATA_STATE_VARIABLE__TYPE);
}
......
......@@ -40,15 +40,13 @@ import org.fortiss.tooling.kernel.ui.util.ObservableUtils;
* @version $Rev: 5261 $
* @ConQAT.Rating GREEN Hash: E3DAC99515B1B25D0652AB731CB1EA03
*/
class DataStateValueEditingSupport extends
AbstractDecoratedTextCellDatabindingEditingSupport {
class DataStateValueEditingSupport extends AbstractDecoratedTextCellDatabindingEditingSupport {
/** Edited object. */
private EObject model;
/** Constructor */
public DataStateValueEditingSupport(ColumnViewer viewer,
DataBindingContext dbc, EObject model) {
public DataStateValueEditingSupport(ColumnViewer viewer, DataBindingContext dbc, EObject model) {
super(viewer, dbc);
this.model = model;
}
......@@ -56,7 +54,7 @@ class DataStateValueEditingSupport extends
/** {@inheritDoc} */
@Override
protected IObservableValue getModelObservableValue(Object model) {
return ObservableUtils.observeValue((DataStateVariable) model,
return ObservableUtils.observeValue((DataStateVariable)model,
CommonPackage.Literals.DATA_STATE_VARIABLE__INITIAL_VALUE);
}
......@@ -90,8 +88,8 @@ class DataStateValueEditingSupport extends
@Override
protected IType getType() {
return ((DataStateVariable) element).getType();
return ((DataStateVariable)element).getType();
}
};
}
}
\ No newline at end of file
}
......@@ -46,8 +46,8 @@ class DataStateVariableNameEditingSupport extends
private EObject model;
/** Constructor */
public DataStateVariableNameEditingSupport(ColumnViewer viewer,
DataBindingContext dbc, EObject model) {
public DataStateVariableNameEditingSupport(ColumnViewer viewer, DataBindingContext dbc,
EObject model) {
super(viewer, dbc);
this.model = model;
}
......@@ -55,7 +55,7 @@ class DataStateVariableNameEditingSupport extends
/** {@inheritDoc} */
@Override
protected IObservableValue getModelObservableValue(Object model) {
return ObservableUtils.observeValue((DataStateVariable) model,
return ObservableUtils.observeValue((DataStateVariable)model,
CommonPackage.Literals.DATA_STATE_VARIABLE__VARIABLE);
}
......@@ -76,4 +76,4 @@ class DataStateVariableNameEditingSupport extends
protected IValidator getTextValidator(Object element) {
return new StringToITermValidator(model);
}
}
\ No newline at end of file
}
......@@ -49,10 +49,10 @@ public class ComponentEditPart extends ElementEditPartBase<Component> {
/** {@inheritDoc} */
@Override
protected Color getBackgroundColor() {
if (!getModel().getContainedElementsList().isEmpty()) {
if(!getModel().getContainedElementsList().isEmpty()) {
return DefaultStyle.SUBSTRUCTURE_COMPONENT_BACKGROUND;
}
if (getModel().isStronglyCausal()) {
if(getModel().isStronglyCausal()) {
return DefaultStyle.STRONGLY_CAUSAL_COMPONENT_BACKGROUND;
}
return DefaultStyle.WEAKLY_CAUSAL_COMPONENT_BACKGROUND;
......
......@@ -36,24 +36,24 @@ public final class EditPartFactory implements IEditPartFactory {
/** {@inheritDoc} */
@Override
public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof Component) {
Component cmp = (Component) model;
if(model instanceof Component) {
Component cmp = (Component)model;
if (context instanceof ComponentDiagramEditPart) {
if(context instanceof ComponentDiagramEditPart) {
return new ComponentEditPart(cmp);
}
return new ComponentDiagramEditPart(cmp);
} else if (model instanceof Port) {
Port p = (Port) model;
} else if(model instanceof Port) {
Port p = (Port)model;
if (context instanceof ComponentDiagramEditPart) {
if(context instanceof ComponentDiagramEditPart) {
return new FreePortEditPart(p);
} else if (context instanceof ComponentEditPart) {
} else if(context instanceof ComponentEditPart) {
return new StickyPortEditPart(p);
}
} else if (model instanceof Channel) {
return new ChannelEditPart((Channel) model);
} else if(model instanceof Channel) {
return new ChannelEditPart((Channel)model);
}
return null;
}
......
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