Skip to content

Commit

Permalink
Split up cell services into subpackages, create adapter system for co…
Browse files Browse the repository at this point in the history
…ntext menus
  • Loading branch information
Col-E committed Feb 24, 2024
1 parent db4d546 commit 45a626c
Show file tree
Hide file tree
Showing 95 changed files with 1,371 additions and 785 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import software.coley.recaf.info.member.MethodMember;
import software.coley.recaf.path.*;
import software.coley.recaf.services.Service;
import software.coley.recaf.services.cell.context.ContextMenuProviderService;
import software.coley.recaf.services.cell.context.ContextSource;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.services.navigation.ClassNavigable;
import software.coley.recaf.services.navigation.Navigable;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import software.coley.recaf.services.cell.ContextMenuProviderFactory;
import software.coley.recaf.services.cell.IconProviderService;
import software.coley.recaf.services.cell.TextProviderService;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import javafx.scene.control.ContextMenu;
import software.coley.recaf.info.ClassInfo;
import software.coley.recaf.info.annotation.Annotated;
import software.coley.recaf.info.annotation.AnnotationInfo;
import software.coley.recaf.workspace.model.Workspace;
import software.coley.recaf.workspace.model.bundle.ClassBundle;
import software.coley.recaf.workspace.model.resource.WorkspaceResource;

/**
* Context menu adapter for {@link AnnotationInfo} types.
*
* @author Matt Coley
*/
public interface AnnotationContextMenuAdapter extends ContextMenuAdapter {
/**
* @param menu
* The menu to adapt.
* @param source
* Context request origin.
* @param workspace
* Containing workspace.
* @param resource
* Containing resource.
* @param bundle
* Containing bundle.
* @param annotated
* The annotated item.
* @param annotation
* The annotation the menu is for.
*/
default void adaptAnnotationContextMenu(@Nonnull ContextMenu menu,
@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull Annotated annotated,
@Nonnull AnnotationInfo annotation) {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import software.coley.recaf.info.ClassInfo;
Expand All @@ -9,8 +9,7 @@
import software.coley.recaf.workspace.model.resource.WorkspaceResource;

/**
* Context menu provider for {@link AnnotationInfo types}, to be plugged into {@link ContextMenuProviderService}
* to allow for third party menu customization.
* Context menu provider for {@link AnnotationInfo} types.
*
* @author Matt Coley
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import javafx.scene.control.ContextMenu;
import software.coley.recaf.info.ClassInfo;
import software.coley.recaf.path.AssemblerPathData;
import software.coley.recaf.ui.pane.editing.assembler.AssemblerPane;
import software.coley.recaf.workspace.model.Workspace;
import software.coley.recaf.workspace.model.bundle.ClassBundle;
import software.coley.recaf.workspace.model.resource.WorkspaceResource;

/**
* Context menu adapter for contents within an {@link AssemblerPane}.
*
* @author Matt Coley
*/
public interface AssemblerContextMenuAdapter extends ContextMenuAdapter {
/**
* @param menu
* The menu to adapt.
* @param source
* Context request origin.
* @param workspace
* Containing workspace.
* @param resource
* Containing resource.
* @param bundle
* Containing bundle.
* @param declaringClass
* Containing class.
* @param assemblerData
* The assembler data the menu is for.
*/
default void adaptAssemblerMenu(@Nonnull ContextMenu menu,
@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull ClassInfo declaringClass,
@Nonnull AssemblerPathData assemblerData) {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import software.coley.recaf.info.ClassInfo;
Expand All @@ -9,8 +9,7 @@
import software.coley.recaf.workspace.model.resource.WorkspaceResource;

/**
* Context menu provider for contents within an {@link AssemblerPane}, to be plugged into {@link ContextMenuProviderService}
* to allow for third party menu customization.
* Context menu provider for contents within an {@link AssemblerPane}.
*
* @author Matt Coley
*/
Expand All @@ -32,12 +31,12 @@ public interface AssemblerContextMenuProviderFactory extends ContextMenuProvider
* @return Menu provider for the selected contents in the assembler.
*/
@Nonnull
default ContextMenuProvider getProvider(@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull ClassInfo declaringClass,
@Nonnull AssemblerPathData assemblerData) {
default ContextMenuProvider getAssemblerMenuProvider(@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull ClassInfo declaringClass,
@Nonnull AssemblerPathData assemblerData) {
return emptyProvider();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -17,7 +17,10 @@
import software.coley.recaf.info.member.FieldMember;
import software.coley.recaf.info.member.MethodMember;
import software.coley.recaf.path.ClassPathNode;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.util.visitors.ClassAnnotationRemovingVisitor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -15,11 +15,8 @@
import software.coley.recaf.path.AssemblerPathData;
import software.coley.recaf.path.ClassPathNode;
import software.coley.recaf.path.IncompletePathException;
import software.coley.recaf.services.cell.AssemblerContextMenuProviderFactory;
import software.coley.recaf.services.cell.ContextMenuProvider;
import software.coley.recaf.services.cell.ContextSource;
import software.coley.recaf.services.cell.IconProviderService;
import software.coley.recaf.services.cell.TextProviderService;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.control.ActionMenuItem;
import software.coley.recaf.ui.control.richtext.Editor;
Expand Down Expand Up @@ -56,12 +53,12 @@ public BasicAssemblerContextMenuProviderFactory(@Nonnull TextProviderService tex

@Nonnull
@Override
public ContextMenuProvider getProvider(@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull ClassInfo declaringClass,
@Nonnull AssemblerPathData assemblerData) {
public ContextMenuProvider getAssemblerMenuProvider(@Nonnull ContextSource source,
@Nonnull Workspace workspace,
@Nonnull WorkspaceResource resource,
@Nonnull ClassBundle<? extends ClassInfo> bundle,
@Nonnull ClassInfo declaringClass,
@Nonnull AssemblerPathData assemblerData) {
return () -> {
ContextMenu menu = new ContextMenu();
AssemblyResolution resolution = assemblerData.resolution();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import javafx.scene.control.ContextMenu;
import software.coley.recaf.info.Info;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.ui.control.popup.ChangeClassVersionForAllPopup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -13,7 +13,10 @@
import software.coley.recaf.info.ClassInfo;
import software.coley.recaf.info.JvmClassInfo;
import software.coley.recaf.path.PathNodes;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.ui.contextmenu.MenuHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package software.coley.recaf.services.cell;
package software.coley.recaf.services.cell.context;

/**
* Basic context source. Either a declaration or a reference.
*
* @see BasicBlacklistingContextSource Simple blacklist filtering source.
* @see BasicWhitelistingContextSource Simple whitelist filtering source.
*
* @author Matt Coley
*/
public class BasicContextSource implements ContextSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javafx.scene.control.ContextMenu;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.util.ClipboardUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -12,7 +12,10 @@
import software.coley.recaf.path.ClassPathNode;
import software.coley.recaf.path.IncompletePathException;
import software.coley.recaf.path.PathNodes;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.util.ClipboardUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -7,7 +7,10 @@
import software.coley.recaf.info.FileInfo;
import software.coley.recaf.path.FilePathNode;
import software.coley.recaf.path.PathNodes;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.util.ClipboardUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javafx.scene.control.ContextMenu;
import software.coley.recaf.info.ClassInfo;
import software.coley.recaf.info.InnerClassInfo;
import software.coley.recaf.services.cell.ClassContextMenuProviderFactory;
import software.coley.recaf.services.cell.ContextMenuProvider;
import software.coley.recaf.services.cell.ContextSource;
import software.coley.recaf.services.cell.InnerClassContextMenuProviderFactory;
import software.coley.recaf.services.cell.context.ClassContextMenuProviderFactory;
import software.coley.recaf.services.cell.context.ContextMenuProvider;
import software.coley.recaf.services.cell.context.ContextSource;
import software.coley.recaf.services.cell.context.InnerClassContextMenuProviderFactory;
import software.coley.recaf.workspace.model.Workspace;
import software.coley.recaf.workspace.model.bundle.AndroidClassBundle;
import software.coley.recaf.workspace.model.bundle.ClassBundle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -15,7 +15,10 @@
import software.coley.recaf.path.ClassPathNode;
import software.coley.recaf.path.IncompletePathException;
import software.coley.recaf.path.PathNodes;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.util.ClipboardUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package software.coley.recaf.services.cell.builtin;
package software.coley.recaf.services.cell.context;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javafx.collections.ObservableList;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import org.kordamp.ikonli.carbonicons.CarbonIcons;
import software.coley.recaf.info.ClassInfo;
import software.coley.recaf.services.cell.*;
import software.coley.recaf.services.cell.icon.IconProvider;
import software.coley.recaf.services.cell.icon.IconProviderService;
import software.coley.recaf.services.cell.text.TextProvider;
import software.coley.recaf.services.cell.text.TextProviderService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.ui.contextmenu.ContextMenuBuilder;
import software.coley.recaf.ui.contextmenu.DirectoryMenuBuilder;
import software.coley.recaf.util.ClipboardUtil;
import software.coley.recaf.util.Lang;
import software.coley.recaf.workspace.model.Workspace;
import software.coley.recaf.workspace.model.bundle.ClassBundle;
import software.coley.recaf.workspace.model.bundle.JvmClassBundle;
Expand Down
Loading

0 comments on commit 45a626c

Please sign in to comment.