Commit 0dcbf834 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3961' into 'master'

3961

See merge request af3/af3!310
parents 5e8c466a 86827aa7
DataStateFXEditor.java e64fcec84ea83e5ba99e48a6825063471e9ea70d GREEN
DataStateFXEditorBase.java 0bec3533962ebcd7326f6597d598a5ff7c8ba8e6 GREEN
DataStateFXEditorBase.java 83655742fdcfdade31eabd7deafa88862f28ba22 GREEN
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,10 @@ 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.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
......@@ -47,18 +55,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 +84,39 @@ 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(event.getCode() != KeyCode.ESCAPE && 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);
event.consume();
}
/** {@inheritDoc} */
@Override
public void validateOnCancelEdit(int colIndex, EObject item) {
descriptionError.setText(DataStateFXEditorBase.DESCRIPTION);
descriptionError.setGraphic(null);
}
};
// 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