Commit f22acc6c authored by Florian Hölzl's avatar Florian Hölzl

AF3: data state editor now showing error one type input validation.

Issue-Ref: 3961
Issue-Url: https://af3-developer.fortiss.org/issues/3961Signed-off-by: Florian Hölzl's avatarFlorian Hoelzl <hoelzl@fortiss.org>
parent 00da95aa
DataStateFXEditor.java e64fcec84ea83e5ba99e48a6825063471e9ea70d GREEN
DataStateFXEditorBase.java 0bec3533962ebcd7326f6597d598a5ff7c8ba8e6 GREEN
DataStateFXEditorBase.java 9e9ad35d14ab1d7ca82be8685dab56a4248105cd YELLOW
DataStateFXEditorBinding.java 46ab36b197a6fca102a5e2d75aa24b1fbba26b89 GREEN
DataStateFXEditorContentProvider.java 324cd24e2219ba2cf360b0f82e3628ca1b5dabba GREEN
DataStateFXEditorUIProvider.java 4993d4a6685b7738dd28a7a55177ab43fe81fc53 GREEN
......
......@@ -19,17 +19,21 @@ import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.af3.component.utils.BehaviorModelElementFactory.createDataStateVariable;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intConst;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intType;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
import org.fortiss.af3.component.model.behavior.common.IDataStateVariableProvider;
import org.fortiss.af3.expression.ui.databinding.validate.StringToTypeValidator;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
import org.fortiss.tooling.kernel.utils.KernelServiceBasedModelListenerBase;
......@@ -37,6 +41,9 @@ import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
......@@ -47,18 +54,18 @@ import javafx.scene.layout.VBox;
*/
public abstract class DataStateFXEditorBase<T extends IDataStateVariableProvider>
extends FXEditorBase<T> {
/** The description. */
private static final String DESCRIPTION = "Define data state variables with the table below:";
/** The tree-table viewer. */
private DynamicTreeTableViewer<EObject> viewer;
/** The remove button. */
private Button removeButton;
/** The add button. */
private Button addButton;
/** The model listener. */
private KernelServiceBasedModelListenerBase<IDataStateVariableProvider> modelListener;
/** The description / error label. */
private Label descriptionError;
/** {@inheritDoc} */
@Override
......@@ -76,10 +83,31 @@ public abstract class DataStateFXEditorBase<T extends IDataStateVariableProvider
DynamicTreeContentProviderBase<EObject> contentProvider =
new DataStateFXEditorContentProvider();
DataStateFXEditorUIProvider uiProvider = new DataStateFXEditorUIProvider();
DataStateFXEditorUIProvider uiProvider = new DataStateFXEditorUIProvider() {
@Override
public void validateOnKeyReleased(KeyEvent event, int colIndex, EObject item,
String text) {
String message = DataStateFXEditorBase.DESCRIPTION;
ImageView icon = null;
if(colIndex == 1) {
StringToTypeValidator validator = new StringToTypeValidator(item);
IStatus status = validator.validate(text);
if(!status.isOK()) {
message = status.getMessage();
icon = new ImageView(
getFXImage(ToolingKernelUIActivator.PLUGIN_ID, "/icons/error.png"));
}
}
descriptionError.setText(message);
descriptionError.setGraphic(icon);
}
};
// Add main pane with the table.
BorderPane mainPane = new BorderPane();
descriptionError = new Label(DESCRIPTION);
mainPane.setTop(descriptionError);
viewer = new DynamicTreeTableViewer<>(provider, false, 2, contentProvider, uiProvider);
viewer.addColumn("Variable", 160);
viewer.addColumn("Type", 160);
......
Markdown is supported
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