Skip to content

Commit

Permalink
Core Editor: Copy class/attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Aug 14, 2024
1 parent 9b9cb58 commit 98f11f9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.shade.decima.ui.editor.core.menu;

import com.shade.decima.model.rtti.RTTIClass;
import com.shade.decima.ui.editor.core.CoreNodeEntry;
import com.shade.decima.ui.editor.core.CoreNodeObject;
import com.shade.platform.ui.PlatformDataKeys;
import com.shade.platform.ui.menus.MenuItem;
Expand All @@ -14,7 +15,7 @@

import static com.shade.decima.ui.menu.MenuConstants.*;

@MenuItemRegistration(parent = CTX_MENU_CORE_EDITOR_ID, name = "Copy Attribute Name", keystroke = "ctrl shift C", group = CTX_MENU_CORE_EDITOR_GROUP_GENERAL, order = 4000)
@MenuItemRegistration(parent = CTX_MENU_CORE_EDITOR_ID, name = "Copy Name", keystroke = "ctrl shift C", group = CTX_MENU_CORE_EDITOR_GROUP_GENERAL, order = 4000)
public class CopyNameItem extends MenuItem {
@Override
public void perform(@NotNull MenuItemContext ctx) {
Expand All @@ -28,7 +29,10 @@ public void perform(@NotNull MenuItemContext ctx) {

@Override
public boolean isVisible(@NotNull MenuItemContext ctx) {
return ctx.getData(PlatformDataKeys.SELECTION_KEY) instanceof CoreNodeObject node
&& node.getParent() instanceof CoreNodeObject parent && parent.getType() instanceof RTTIClass;
if (!(ctx.getData(PlatformDataKeys.SELECTION_KEY) instanceof CoreNodeObject node)) {
return false;
}
return node instanceof CoreNodeEntry
|| node.getParent() instanceof CoreNodeObject parent && parent.getType() instanceof RTTIClass;
}
}

0 comments on commit 98f11f9

Please sign in to comment.