Commit f0d887a8 authored by Alexander Diewald's avatar Alexander Diewald

Merge branch '4004' into 'master'

[4004] context menu entry for delete action in data dictionary

See merge request !114
parents 03c59007 c6db24d4
ContextMenuUtil.java 6d270ba4c239c35ee487192427d02797e73ee109 GREEN
CurvedLinkLayoutedContentAnchorangeController.java e22faedbe98c3dab660b5d2df8ebd004e116c5ba GREEN
CurvedLinkLayoutedDiagramAnchorangeController.java f2e5e2a7cc9b6a070871e200e57371286bb15222 GREEN
EObjectDiagramController.java 18cbb2f092409adeb728233dae6e084faf357d6d GREEN
EObjectEllipticResizableContentControllerBase.java 958d3856daf5337cd75d0a6f163a27dcc8717160 GREEN
EObjectDiagramController.java 27b008c02e174d66184ba8ad76ae81b082f1069f GREEN
EObjectEllipticResizableContentControllerBase.java f12e8f5a646a23fe428ed4768bf041c8b885ec81 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java 7cbc3e89b7b74106d56b8b4f845087e96e13d109 GREEN
EObjectRectangularResizableContentControllerBase.java cde6c13659611d927691c03ecd2621cff2414b03 GREEN
KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN
LayoutedContentAnchorageController.java 83f066a151dd2984c4bef64daf8165a0cd53b00f GREEN
LayoutedCurveLinkBendPointController.java d963a5e227de7bd8ba910c733df2ac7acf4fa1fa GREEN
......@@ -13,5 +12,5 @@ LayoutedEllipticResizableContentController.java 1c50e80121512de7ae1f2ba09e0e1f4d
LayoutedLineLinkBendPointController.java f49c994a0c90612c44ec83d42cf858e476662e1f GREEN
LayoutedLinkBendPointController.java d06736b49b6ac9a073237b989895469891500e7f GREEN
LayoutedRectangularResizableContentController.java 341f4a7da0d69360d7026af6d9b3d44dfd7d9bb1 GREEN
ModelElementFXEditorUIProviderBase.java b81bf7fc945d40f1f842876f07ba70799ab65f6d GREEN
ModelElementFXEditorUIProviderBase.java 6bdd31d033228315e99c973b4986cdabc135ec9f GREEN
NamedCommentedLayoutModelChangeProvider.java 223e82c1b1cba842f6fae115182f5d0c6acb44b0 GREEN
......@@ -15,10 +15,10 @@ package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createAutoLayoutMenu;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createDisplayMenu;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createAutoLayoutMenu;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createDisplayMenu;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
......
......@@ -15,8 +15,8 @@ package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
......
......@@ -17,9 +17,9 @@ import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.RECTANGLE_INSETS;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
......
......@@ -15,7 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.utils.ContextMenuUtils.createPrototypeMenu;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
......
AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN
ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN
ContextMenuUtils.java 434d6b7aad095ce726caa4de42913391ed6e6832 GREEN
DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN
EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
......
......@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.controller;
package org.fortiss.tooling.base.ui.utils;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
......@@ -42,7 +42,7 @@ import javafx.scene.control.MenuItem;
*
* @author hoelzl
*/
public final class ContextMenuUtil {
public final class ContextMenuUtils {
/** Creates the menu populated with composable prototypes. */
public static List<MenuItem> createPrototypeMenu(EObject target,
IElementCompositionContext context) {
......@@ -70,6 +70,21 @@ public final class ContextMenuUtil {
return result;
}
/** Creates a delete menu entry */
public static MenuItem createDeleteMenu(EObject target) {
IElementCompositorService ecs = IElementCompositorService.getInstance();
ICommandStackService css = ICommandStackService.getInstance();
MenuItem deleteMenuItem = new MenuItem("Delete");
deleteMenuItem.setOnAction(evt -> {
css.runAsCommand(target, () -> {
ecs.decompose(target);
});
});
return deleteMenuItem;
}
/** Creates an auto-layout menu entry for {@link IHierarchicElement}s. */
public static MenuItem createAutoLayoutMenu(IHierarchicElement target) {
final String MENU_NAME = "Automatic layout";
......
DynamicTreeContentProviderBase.java 6760a6dc5721175b1dada8f30fd9da05f7bcc4b3 GREEN
DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN
DynamicTreeTableUIProviderBase.java f4fd20e3d267bc39a33a3bbb18416312779ea886 GREEN
DynamicTreeTableUIProviderBase.java ea7de1e0fd824b61b46010d2317f93422bab6144 GREEN
DynamicTreeTableViewer.java 431ac62cbd6ad7df25852fce1b5a62a05ba510e3 GREEN
DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece GREEN
DynamicTreeViewer.java e9f19d16a2a7e5a1b03b8a8b543453ac7eb6a051 GREEN
DynamicTreeViewer.java 725f41f4fb4b6bfa813f010fb9083ab02eea164a GREEN
DynamicTreeViewerBase.java a2013538b62d86f6a09efdf2cd78babac2072484 GREEN
IDoubleClickHandler.java 447f7769dead9a106b3ea3139ef0da51eb0b9a89 GREEN
......@@ -13,15 +13,20 @@
*******************************************************************************/
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableCell;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.cell.TextFieldTreeTableCell;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.util.Callback;
import javafx.util.converter.DefaultStringConverter;
......@@ -233,15 +238,44 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
ContextMenu menu = null;
Node icon = null;
if(!empty && item != null) {
T data = this.getTreeTableRow().getItem();
menu = createContextMenu(data, colIndex);
icon = getIconNode(data, colIndex);
menu = createContextMenu(data, colIndex);
if(IS_OS_LINUX && menu != null) {
// JFX-builtin handling is non-operation in Linux.
addContextMenuHandler(menu, data);
}
}
this.setContextMenu(menu);
this.setGraphic(icon);
this.setContextMenu(menu);
}
/**
* Adds a handler for showing the context menu. Duplicate of the same method in
* {@link DynamicTreeViewer} due to the absence of proper selection interfaces in
* JFX.
*/
private void addContextMenuHandler(ContextMenu menu, T element) {
getTreeTableView().addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
if(e.getButton() == MouseButton.SECONDARY) {
TreeItem<T> selected =
getTreeTableView().getSelectionModel().getSelectedItem();
// We must check the element since all rows are evaluated.
if(selected != null && selected.getValue() == element) {
menu.show(this, e.getScreenX(), e.getScreenY());
e.consume();
}
} else {
// any other click cause hiding menu
menu.hide();
}
});
}
};
cell.textProperty().bind(cell.itemProperty());
......
......@@ -15,6 +15,8 @@
*******************************************************************************/
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
import javafx.beans.value.ChangeListener;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TreeCell;
......@@ -23,6 +25,7 @@ import javafx.scene.control.TreeView;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
......@@ -127,6 +130,11 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
ContextMenu menu = null;
if(!empty && item != null) {
menu = uiProvider.createContextMenu(item);
if(IS_OS_LINUX && menu != null) {
// JFX-builtin handling is non-operation in Linux.
addContextMenuHandler(menu, item);
}
this.setText(uiProvider.getLabel(item));
this.setGraphic(uiProvider.getIconNode(item));
this.setOnDragDetected(evt -> {
......@@ -149,6 +157,28 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
});
}
/**
* Adds a handler for showing the context menu. Duplicate of the same method in
* {@link DynamicTreeTableUIProviderBase} due to the absence of proper selection interfaces in
* JFX.
*/
private void addContextMenuHandler(ContextMenu menu, T element) {
view.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
if(e.getButton() == MouseButton.SECONDARY) {
TreeItem<T> selected = view.getSelectionModel().getSelectedItem();
// We must check the element since all rows are evaluated.
if(selected != null && selected.getValue() == element) {
menu.show(view, e.getScreenX(), e.getScreenY());
e.consume();
}
} else {
// any other click cause hiding menu
menu.hide();
}
});
}
/** Called when an item in the tree is dragged. */
private void dragDetected(MouseEvent evt, TreeCell<T> cell, T item) {
ClipboardContent cbContent = uiProvider.getDragClipboardContent(item);
......
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