Commit d38b9f1a authored by Christoph Döbber's avatar Christoph Döbber
Browse files

added data state variables and icons to field assist

refs 563
parent 20e18151
......@@ -25,5 +25,6 @@ Export-Package: org.fortiss.af3.component.ui,
org.fortiss.af3.component.ui.simulator,
org.fortiss.af3.component.ui.simulator.component,
org.fortiss.af3.component.ui.simulator.menu,
org.fortiss.af3.component.ui.simulator.views
org.fortiss.af3.component.ui.simulator.views,
org.fortiss.af3.component.ui.utils
Import-Package: org.eclipse.ui.texteditor
......@@ -19,7 +19,8 @@ package org.fortiss.af3.component.ui.editor;
import static org.eclipse.swt.SWT.LEFT;
import static org.eclipse.swt.SWT.TOP;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.getPortNames;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getInputPortNames;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getOutputPortNames;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getAllConstructors;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getFunctions;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getPrimitiveValues;
......@@ -78,8 +79,9 @@ public class CodeSpecificationEditorBackend extends
@Override
/** {@inheritDoc} */
public String[] getProposals(String currentWord) {
ArrayList<String> prop = getPortNames(editedObject
ArrayList<String> prop = getInputPortNames(editedObject
.getComponent());
prop.addAll(getOutputPortNames(editedObject.getComponent()));
prop.addAll(getFunctions(editedObject));
prop.addAll(getAllConstructors(editedObject, true));
prop.addAll(getPrimitiveValues());
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 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.component.ui.utils;
import java.util.ArrayList;
import org.eclipse.swt.graphics.Image;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.component.ui.AF3ComponentUIActivator;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.ui.fieldassist.FieldAssistImageRegistry;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* Utils class for assembling component related proposals for FieldAssist.
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class ComponentFieldAssistUtils {
/**
* Returns all input port names of given component.
*
* @param component
* the component to be searched for port names
* @return the list of port names
*/
public static ArrayList<String> getInputPortNames(Component component) {
ArrayList<String> result = new ArrayList<String>();
for (IConnector conn : component.getConnectorsList()) {
if (conn instanceof INamedElement && conn instanceof InputPort) {
result.add(((INamedElement) conn).getName());
FieldAssistImageRegistry.put(((INamedElement) conn).getName(),
INPUT_PORT_ICON);
}
}
return result;
}
/**
* Returns all output port names of given component.
*
* @param component
* the component to be searched for port names
* @return the list of port names
*/
public static ArrayList<String> getOutputPortNames(Component component) {
ArrayList<String> result = new ArrayList<String>();
for (IConnector conn : component.getConnectorsList()) {
if (conn instanceof INamedElement && conn instanceof OutputPort) {
result.add(((INamedElement) conn).getName());
FieldAssistImageRegistry.put(((INamedElement) conn).getName(),
OUTPUT_PORT_ICON);
}
}
return result;
}
/** Icon for input ports. */
static Image INPUT_PORT_ICON = AF3ComponentUIActivator.getImageDescriptor(
"/icons/entry_ipoint.png").createImage();
/** Icon for output ports. */
static Image OUTPUT_PORT_ICON = AF3ComponentUIActivator.getImageDescriptor(
"/icons/exit_ipoint.png").createImage();
}
......@@ -36,7 +36,6 @@ import org.fortiss.af3.component.model.impl.CausalityComponentSpecificationImpl;
import org.fortiss.af3.component.model.impl.ComponentArchitectureImpl;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.model.typesystem.IVariableDefinition;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
......@@ -315,21 +314,4 @@ public class ComponentArchitectureUtils {
}
}
}
/**
* Returns all port names of given component.
*
* @param component
* the component to be searched for port names
* @return the list of port names
*/
public static ArrayList<String> getPortNames(Component component) {
ArrayList<String> result = new ArrayList<String>();
for (IConnector conn : component.getConnectorsList()) {
if (conn instanceof INamedElement) {
result.add(((INamedElement) conn).getName());
}
}
return result;
}
}
......@@ -21,12 +21,14 @@ import static java.util.Arrays.asList;
import static org.fortiss.af3.expression.language.evaluation.NoVal.NOVAL_STRING;
import static org.fortiss.af3.expression.model.terms.impl.BoolConstStaticImpl.FALSE;
import static org.fortiss.af3.expression.model.terms.impl.BoolConstStaticImpl.TRUE;
import static org.fortiss.af3.expression.ui.AF3ExpressionUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.graphics.Image;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.definitions.Enumeration;
import org.fortiss.af3.expression.model.definitions.EnumerationMember;
......@@ -35,6 +37,7 @@ import org.fortiss.af3.expression.model.definitions.TypeDefinition;
import org.fortiss.af3.expression.model.types.impl.TBoolStaticImpl;
import org.fortiss.af3.expression.model.types.impl.TDoubleStaticImpl;
import org.fortiss.af3.expression.model.types.impl.TIntStaticImpl;
import org.fortiss.tooling.base.ui.fieldassist.FieldAssistImageRegistry;
/**
* Utils class for assembling expression related proposals for FieldAssist.
......@@ -86,6 +89,7 @@ public class ExpressionFieldAssistUtils {
DataDictionary dd = getDataDictionary(element);
for (TypeDefinition def : dd.getTypeDefinitionsList()) {
result.add(def.getName());
FieldAssistImageRegistry.put(def.getName(), ENUMERATION_ICON);
}
return result;
}
......@@ -96,6 +100,8 @@ public class ExpressionFieldAssistUtils {
DataDictionary dd = getDataDictionary(element);
for (FunctionDefinition def : dd.getFunctionsList()) {
result.add(def.getFunction().getName());
FieldAssistImageRegistry.put(def.getFunction().getName(),
FUNCTION_ICON);
}
return result;
}
......@@ -113,10 +119,12 @@ public class ExpressionFieldAssistUtils {
for (Enumeration def : dd.getEnumerationsList()) {
for (EnumerationMember mem : def.getMembersList()) {
result.add(mem.getName() + "()");
FieldAssistImageRegistry.put(mem.getName() + "()", MEMBER_ICON);
}
}
if (includeNoVal) {
result.add(NOVAL_STRING);
}
// TODO CD: structures not included in release Feb2012
// https://af3.fortiss.org/issues/367
......@@ -132,7 +140,7 @@ public class ExpressionFieldAssistUtils {
public static ArrayList<String> getConstructorsForType(String type,
boolean includeNoVal, EObject element) {
ArrayList<String> result = new ArrayList<String>();
if (type.equals("boolean")) {
if (type.equals(TBoolStaticImpl.INSTANCE.toString())) {
result.addAll(getPrimitiveValues());
} else {
DataDictionary dd = getDataDictionary(element);
......@@ -142,6 +150,8 @@ public class ExpressionFieldAssistUtils {
}
for (EnumerationMember mem : def.getMembersList()) {
result.add(mem.getName() + "()");
FieldAssistImageRegistry.put(mem.getName() + "()",
MEMBER_ICON);
}
}
}
......@@ -153,4 +163,40 @@ public class ExpressionFieldAssistUtils {
return result;
}
/** Icon for primitive types. */
static Image PRIMITIVE_TYPE_ICON = getImageDescriptor(
"/icons/primitivetype.gif").createImage();
/** Icon for primitive values. */
static Image PRIMITIVE_VALUE_ICON = getImageDescriptor(
"/icons/primitivevalue.gif").createImage();
/** Icon for useful expressions. */
static Image USEFUL_EXPRESSION_ICON = getImageDescriptor(
"/icons/usefulexpression.gif").createImage();
/** Icon for NoVal keyword. */
static Image NOVAL_ICON = getImageDescriptor("/icons/noval.gif")
.createImage();
/** Icon for functions. */
static Image FUNCTION_ICON = getImageDescriptor("/icons/function.png")
.createImage();
/** Icon for types. */
static Image ENUMERATION_ICON = getImageDescriptor("/icons/enumeration.gif")
.createImage();
/** Icon for constructors. */
static Image MEMBER_ICON = getImageDescriptor("/icons/member.png")
.createImage();
static {
FieldAssistImageRegistry.put(NOVAL_STRING, NOVAL_ICON);
for (String type : getPrimitiveTypes()) {
FieldAssistImageRegistry.put(type, PRIMITIVE_TYPE_ICON);
}
for (String value : getPrimitiveValues()) {
FieldAssistImageRegistry.put(value, PRIMITIVE_VALUE_ICON);
}
for (String exp : getUsefulExpressions()) {
FieldAssistImageRegistry.put(exp, USEFUL_EXPRESSION_ICON);
}
}
}
......@@ -17,13 +17,16 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z ratiu $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.state.ui.properties;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getInputPortNames;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getOutputPortNames;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.getEnclosingComponent;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.getPortNames;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getAllConstructors;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getFunctions;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getPrimitiveValues;
import static org.fortiss.af3.state.model.AF3StatePackage.Literals.STATE_SPECIFICATION__INITIAL;
import static org.fortiss.af3.state.model.AF3StatePackage.Literals.TRANSITION_SEGMENT_SPECIFICATION__ACTIONS;
import static org.fortiss.af3.state.ui.utils.StateFieldAssistUtils.getDataStateVariables;
import static org.fortiss.af3.state.ui.utils.StateFieldAssistUtils.getEnclosingAutomaton;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performComplexTextBinding;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
......@@ -92,10 +95,13 @@ public class StateSpecificationPropertySection extends PropertySectionBase {
// Must use inner class here, since state is null during createControls,
// but will be not null when field assist is used
new FieldAssist(idleActionsText, new ProposalProviderBase() {
@Override
/** {@inheritDoc} */
public String[] getProposals(String currentWord) {
ArrayList<String> prop = getPortNames(getEnclosingComponent(state));
ArrayList<String> prop = getDataStateVariables(getEnclosingAutomaton(state));
prop.addAll(getInputPortNames(getEnclosingComponent(state)));
prop.addAll(getOutputPortNames(getEnclosingComponent(state)));
prop.addAll(getFunctions(state));
prop.addAll(getAllConstructors(state, true));
prop.addAll(getPrimitiveValues());
......
......@@ -17,13 +17,16 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z ratiu $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.state.ui.properties;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getInputPortNames;
import static org.fortiss.af3.component.ui.utils.ComponentFieldAssistUtils.getOutputPortNames;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.getEnclosingComponent;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.getPortNames;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getAllConstructors;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getFunctions;
import static org.fortiss.af3.expression.ui.utils.ExpressionFieldAssistUtils.getPrimitiveValues;
import static org.fortiss.af3.state.model.AF3StatePackage.Literals.TRANSITION_SEGMENT_SPECIFICATION__ACTIONS;
import static org.fortiss.af3.state.model.AF3StatePackage.Literals.TRANSITION_SEGMENT_SPECIFICATION__GUARD;
import static org.fortiss.af3.state.ui.utils.StateFieldAssistUtils.getDataStateVariables;
import static org.fortiss.af3.state.ui.utils.StateFieldAssistUtils.getEnclosingAutomaton;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performComplexTextBinding;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
......@@ -86,13 +89,16 @@ public class TransitionSegmentSpecificationPropertySection extends
/** Creates {@link FieldAssist} for text fields. */
private void setupFieldAssist() {
// Must use inner classes here, since specification is null during
// createControls, but will be not null when field assist is used
new FieldAssist(guardText, new ProposalProviderBase() {
@Override
/** {@inheritDoc} */
public String[] getProposals(String currentWord) {
ArrayList<String> prop = getPortNames(getEnclosingComponent(specification));
ArrayList<String> prop = getDataStateVariables(getEnclosingAutomaton(specification));
prop.addAll(getInputPortNames(getEnclosingComponent(specification)));
prop.addAll(getOutputPortNames(getEnclosingComponent(specification)));
prop.addAll(getFunctions(specification));
prop.addAll(getAllConstructors(specification, true));
prop.addAll(getPrimitiveValues());
......@@ -103,7 +109,9 @@ public class TransitionSegmentSpecificationPropertySection extends
@Override
/** {@inheritDoc} */
public String[] getProposals(String currentWord) {
ArrayList<String> prop = getPortNames(getEnclosingComponent(specification));
ArrayList<String> prop = getDataStateVariables(getEnclosingAutomaton(specification));
prop.addAll(getInputPortNames(getEnclosingComponent(specification)));
prop.addAll(getOutputPortNames(getEnclosingComponent(specification)));
prop.addAll(getFunctions(specification));
prop.addAll(getAllConstructors(specification, true));
prop.addAll(getPrimitiveValues());
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 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.state.ui.utils;
import static org.fortiss.af3.state.ui.AF3StateUIActivator.getImageDescriptor;
import java.util.ArrayList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.graphics.Image;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
import org.fortiss.af3.state.model.StateAutomaton;
import org.fortiss.tooling.base.ui.fieldassist.FieldAssistImageRegistry;
/**
* Utils class for assembling state automaton related proposals for FieldAssist.
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class StateFieldAssistUtils {
/**
* Returns this EObject's enclosing state automaton. May return
* <code>null</code> if there is no such element.
*
* @param element
* the element to start the upwards search
* @return the first state automaton in the chain of parent or
* <code>null</code> if no parent is a state automaton
*/
public static StateAutomaton getEnclosingAutomaton(EObject element) {
EObject iterator = element;
while (iterator.eContainer() != null
&& !(iterator.eContainer() instanceof StateAutomaton)) {
iterator = iterator.eContainer();
}
return (StateAutomaton) iterator.eContainer();
}
/** Returns all data state variables. */
public static ArrayList<String> getDataStateVariables(
StateAutomaton automaton) {
ArrayList<String> result = new ArrayList<String>();
for (DataStateVariable dsv : automaton.getDataStateVariablesList()) {
result.add(dsv.getIdentifier());
FieldAssistImageRegistry.put(dsv.getIdentifier(), VARIABLE_ICON);
}
return result;
}
/** Icon for data state variables. */
static Image VARIABLE_ICON = getImageDescriptor(
"/icons/datastatevariable.gif").createImage();
}
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