Skip to content

Ghidra is a software reverse engineering (SRE) framework

bundle status gui updates

Jason P. Leasured8ec1784ecfe
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
index 7598f68f30..6bdf8a0668 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
@@ -147,6 +147,11 @@ public class BundleHost {
private static GhidraBundle createGhidraBundle(BundleHost bundleHost, ResourceFile bundleFile,
boolean enabled, boolean systemBundle) {
+ if (!bundleFile.exists()) {
+ return new GhidraPlaceholderBundle(bundleHost, bundleFile, enabled, systemBundle,
+ "file not found: " + generic.util.Path.toPathString(bundleFile));
+ }
+
switch (GhidraBundle.getType(bundleFile)) {
case SOURCE_DIR:
return new GhidraSourceBundle(bundleHost, bundleFile, enabled, systemBundle);
@@ -156,7 +161,8 @@ public class BundleHost {
default:
break;
}
- return new GhidraPlaceholderBundle(bundleHost, bundleFile, enabled, systemBundle);
+ return new GhidraPlaceholderBundle(bundleHost, bundleFile, enabled, systemBundle,
+ "no bundle type for " + generic.util.Path.toPathString(bundleFile));
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
index c6432276f7..6e1120825b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
@@ -43,7 +43,7 @@ public class BundleStatus implements Comparable<BundleStatus> {
@Override
public int compareTo(BundleStatus o) {
- return Path.toPathString(file).compareTo(o != null ? Path.toPathString(o.file) : null);
+ return file.compareTo(o.file);
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
index 3a58ff89f0..488ba8f4ca 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
@@ -29,11 +29,10 @@ import docking.action.builder.ActionBuilder;
import docking.util.AnimationUtils;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
-import docking.widgets.table.*;
+import docking.widgets.table.GTableFilterPanel;
import generic.jar.ResourceFile;
import generic.util.Path;
import ghidra.app.services.ConsoleService;
-import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.preferences.Preferences;
@@ -42,8 +41,6 @@ import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
import ghidra.util.filechooser.GhidraFileChooserModel;
import ghidra.util.filechooser.GhidraFileFilter;
-import ghidra.util.table.column.AbstractGColumnRenderer;
-import ghidra.util.table.column.AbstractWrapperTypeColumnRenderer;
import ghidra.util.task.*;
import resources.Icons;
import resources.ResourceManager;
@@ -58,9 +55,6 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
static final String PREFENCE_LAST_SELECTED_BUNDLE = "LastGhidraBundle";
- private static final Color DARK_GREEN = new Color(0.0f, .6f, 0.0f);
- private static final Color DARK_RED = new Color(0.6f, .1f, 0.0f);
-
private JPanel panel;
private LessFreneticGTable bundleStatusTable;
private final BundleStatusTableModel bundleStatusTableModel;
@@ -126,7 +120,6 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
// to allow custom cell renderers
bundleStatusTable.setAutoCreateColumnsFromModel(false);
- configureTableColumns();
filterPanel = new GTableFilterPanel<>(bundleStatusTable, bundleStatusTableModel);
JScrollPane scrollPane = new JScrollPane(bundleStatusTable);
@@ -137,23 +130,12 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
panel.setPreferredSize(new Dimension(800, 400));
}
- private void configureTableColumns() {
- int skinnyWidth = 60;
- bundleStatusTableModel.activeColumn.setColumnRenderer(new BusyBooleanRenderer());
- bundleStatusTableModel.activeColumn.setColumnPreferredWidth(skinnyWidth);
- bundleStatusTableModel.enabledColumn.setColumnPreferredWidth(skinnyWidth);
- bundleStatusTableModel.typeColumn.setColumnPreferredWidth(90);
- bundleStatusTableModel.pathColumn.setColumnRenderer(new BundleFileRenderer());
- }
-
private void addBundlesAction(String actionName, String description, Icon icon,
Runnable runnable) {
new ActionBuilder(actionName, this.getName()).popupMenuPath(description)
.popupMenuIcon(icon)
.popupMenuGroup(BUNDLE_GROUP)
- .toolBarIcon(icon)
- .toolBarGroup(BUNDLE_GROUP)
.description(description)
.enabled(false)
.enabledWhen(context -> bundleStatusTable.getSelectedRows().length > 0)
@@ -168,21 +150,21 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
.popupMenuGroup(BUNDLE_LIST_GROUP)
.toolBarIcon(icon)
.toolBarGroup(BUNDLE_LIST_GROUP)
- .description("Refresh bundles by cleaning and reactivating all enabled bundles")
+ .description("Refresh state by cleaning and reactivating all enabled bundles")
.onAction(c -> doRefresh())
.buildAndInstallLocal(this);
- addBundlesAction("ActivateBundles", "Activate bundle(s)",
- ResourceManager.loadImage("images/media-playback-start.png"), this::doActivateBundles);
+ addBundlesAction("ActivateBundles", "Enable selected bundle(s)",
+ ResourceManager.loadImage("images/media-playback-start.png"), this::doEnableBundles);
- addBundlesAction("DeactivateBundles", "Deactivate bundle(s)",
- ResourceManager.loadImage("images/media-playback-stop.png"), this::doDeactivateBundles);
+ addBundlesAction("DeactivateBundles", "Disable selected bundle(s)",
+ ResourceManager.loadImage("images/media-playback-stop.png"), this::doDisableBundles);
- addBundlesAction("CleanBundles", "Clean bundle(s)",
- ResourceManager.loadImage("images/erase16.png"), this::doClean);
+ addBundlesAction("CleanBundles", "Clean selected bundle build cache(s)",
+ ResourceManager.loadImage("images/erase16.png"), this::doCleanBundleBuildCaches);
icon = ResourceManager.loadImage("images/Plus.png");
- new ActionBuilder("AddBundles", this.getName()).popupMenuPath("Add Bundle(s)")
+ new ActionBuilder("AddBundles", this.getName()).popupMenuPath("Add bundle(s)")
.popupMenuIcon(icon)
.popupMenuGroup(BUNDLE_LIST_GROUP)
.toolBarIcon(icon)
@@ -192,7 +174,8 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
.buildAndInstallLocal(this);
icon = ResourceManager.loadImage("images/edit-delete.png");
- new ActionBuilder("RemoveBundles", this.getName()).popupMenuPath("Remove bundle(s)")
+ new ActionBuilder("RemoveBundles", this.getName())
+ .popupMenuPath("Remove selected bundle(s)")
.popupMenuIcon(icon)
.popupMenuGroup(BUNDLE_LIST_GROUP)
.toolBarIcon(icon)
@@ -238,11 +221,12 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
}
// then activate them all
- new TaskLauncher(new ActivateBundlesTask("activating", true, true, false, statuses),
+ new TaskLauncher(
+ new EnableAndActivateBundlesTask("activating", true, true, false, statuses),
getComponent(), 1000);
}
- private void doClean() {
+ private void doCleanBundleBuildCaches() {
int[] selectedModelRows = getSelectedModelRows();
boolean anythingCleaned = false;
for (BundleStatus status : bundleStatusTableModel.getRowObjects(selectedModelRows)) {
@@ -323,16 +307,14 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
return bundleStatusTableModel.getRowObjects(getSelectedModelRows());
}
- protected void doActivateBundles() {
- new TaskLauncher(
- new ActivateBundlesTask("activating", true, true, false, getSelectedStatuses()),
- getComponent(), 1000);
+ protected void doEnableBundles() {
+ new TaskLauncher(new EnableAndActivateBundlesTask("activating", true, true, false,
+ getSelectedStatuses()), getComponent(), 1000);
}
- protected void doDeactivateBundles() {
- new TaskLauncher(
- new DeactivateBundlesTask("deactivating", true, true, false, getSelectedStatuses()),
- getComponent(), 1000);
+ protected void doDisableBundles() {
+ new TaskLauncher(new DeactivateAndDisableBundlesTask("deactivating", true, true, false,
+ getSelectedStatuses()), getComponent(), 1000);
}
protected void doActivateDeactivateBundle(BundleStatus status, boolean activate) {
@@ -385,13 +367,13 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
}
private final class RemoveBundlesTask extends Task {
- private final DeactivateBundlesTask deactivateBundlesTask;
+ private final DeactivateAndDisableBundlesTask deactivateBundlesTask;
private final List<BundleStatus> statuses;
private RemoveBundlesTask(String title, List<BundleStatus> statuses) {
super(title);
this.deactivateBundlesTask =
- new DeactivateBundlesTask("deactivating", true, true, false, statuses);
+ new DeactivateAndDisableBundlesTask("deactivating", true, true, false, statuses);
this.statuses = statuses;
}
@@ -408,8 +390,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
if (!systemBundles.isEmpty()) {
StringBuilder stringBuilder = new StringBuilder();
for (GhidraBundle bundle : systemBundles) {
- bundleHost.disable(bundle);
- stringBuilder.append(bundle.getFile() + "\n");
+ stringBuilder.append(Path.toPathString(bundle.getFile()) + "\n");
}
Msg.showWarn(this, BundleStatusComponentProvider.this.getComponent(),
"Unabled to remove",
@@ -420,10 +401,10 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
}
}
- private class ActivateBundlesTask extends Task {
+ private class EnableAndActivateBundlesTask extends Task {
private final List<BundleStatus> statuses;
- private ActivateBundlesTask(String title, boolean canCancel, boolean hasProgress,
+ private EnableAndActivateBundlesTask(String title, boolean canCancel, boolean hasProgress,
boolean isModal, List<BundleStatus> statuses) {
super(title, canCancel, hasProgress, isModal);
this.statuses = statuses;
@@ -463,11 +444,11 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
}
}
- private class DeactivateBundlesTask extends Task {
+ private class DeactivateAndDisableBundlesTask extends Task {
final List<BundleStatus> statuses;
- private DeactivateBundlesTask(String title, boolean canCancel, boolean hasProgress,
- boolean isModal, List<BundleStatus> statuses) {
+ private DeactivateAndDisableBundlesTask(String title, boolean canCancel,
+ boolean hasProgress, boolean isModal, List<BundleStatus> statuses) {
super(title, canCancel, hasProgress, isModal);
this.statuses = statuses;
}
@@ -483,6 +464,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
for (GhidraBundle bundle : bundles) {
try {
bundleHost.deactivateSynchronously(bundle.getLocationIdentifier());
+ bundleHost.disable(bundle);
}
catch (GhidraBundleException | InterruptedException e) {
ConsoleService console = getTool().getService(ConsoleService.class);
@@ -559,64 +541,4 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
}
}
}
-
- private class BusyBooleanRenderer extends GBooleanCellRenderer
- implements AbstractWrapperTypeColumnRenderer<Boolean> {
- @Override
- public Component getTableCellRendererComponent(GTableCellRenderingData data) {
- BundleStatus status = (BundleStatus) data.getRowObject();
- Component component = super.getTableCellRendererComponent(data);
- if (status.isBusy()) {
- cb.setVisible(false);
- cb.setEnabled(false);
- setHorizontalAlignment(SwingConstants.CENTER);
- setText("...");
- }
- else {
- cb.setVisible(true);
- cb.setEnabled(true);
- setText("");
- }
- return component;
- }
-
- }
-
- private class BundleFileRenderer extends AbstractGColumnRenderer<ResourceFile> {
-
- @Override
- public Component getTableCellRendererComponent(GTableCellRenderingData data) {
- BundleStatus status = (BundleStatus) data.getRowObject();
- ResourceFile file = (ResourceFile) data.getValue();
- JLabel label = (JLabel) super.getTableCellRendererComponent(data);
- label.setFont(defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD));
- label.setText(Path.toPathString(file));
- GhidraBundle bundle = bundleHost.getExistingGhidraBundle(file);
- if (bundle == null || bundle instanceof GhidraPlaceholderBundle || !file.exists()) {
- label.setBackground(Color.RED);
- label.setForeground(Color.BLACK);
- }
- else {
- if (status.isBusy()) {
- label.setForeground(Color.GRAY);
- }
- else if (!status.isEnabled()) {
- label.setForeground(Color.BLACK);
- }
- else if (status.isActive()) {
- label.setForeground(DARK_GREEN);
- }
- else {
- label.setForeground(DARK_RED);
- }
- }
- return label;
- }
-
- @Override
- public String getFilterString(ResourceFile file, Settings settings) {
- return Path.toPathString(file);
- }
-
- }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
index 064d3a44c4..aecd6f17f2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
@@ -15,32 +15,35 @@
*/
package ghidra.app.plugin.core.osgi;
+import java.awt.*;
import java.util.*;
+import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
import javax.swing.event.TableModelEvent;
import docking.widgets.table.*;
import generic.jar.ResourceFile;
+import generic.util.Path;
import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;
-import ghidra.util.table.column.GColumnRenderer;
+import ghidra.util.table.column.*;
/**
* Model for {@link BundleStatus} objects.
*/
public class BundleStatusTableModel
extends GDynamicColumnTableModel<BundleStatus, List<BundleStatus>> {
- Column<Boolean> enabledColumn;
- Column<Boolean> activeColumn;
- Column<String> typeColumn;
- Column<ResourceFile> pathColumn;
- Column<String> summaryColumn;
+ private static final Color COLOR_BUNDLE_ERROR = Color.RED;
+ private static final Color COLOR_BUNDLE_DISABLED = Color.DARK_GRAY;
+ private static final Color COLOR_BUNDLE_BUSY = Color.GRAY;
+ private static final Color COLOR_BUNDLE_INACTIVE = Color.BLACK;
+ private static final Color COLOR_BUNDLE_ACTIVE = new Color(0.0f, .6f, 0.0f); // a dark green
private BundleHost bundleHost;
private BundleStatusComponentProvider provider;
@@ -150,7 +153,7 @@ public class BundleStatusTableModel
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
BundleStatus status = statuses.get(rowIndex);
- return ((Column<?>) getColumn(columnIndex)).editable(status);
+ return ((Column<?>) getColumn(columnIndex)).isEditable(status);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -362,131 +365,212 @@ public class BundleStatusTableModel
@Override
protected TableColumnDescriptor<BundleStatus> createTableColumnDescriptor() {
-
TableColumnDescriptor<BundleStatus> columnDescriptor = new TableColumnDescriptor<>();
- enabledColumn = new Column<>("Enabled") {
- @Override
- boolean editable(BundleStatus status) {
- return status.fileExists();
- }
- @Override
- Boolean getValue(BundleStatus status) {
- return status.isEnabled();
- }
+ columnDescriptor.addVisibleColumn(new EnabledColumn());
+ columnDescriptor.addVisibleColumn(new BundleFileColumn());
+ columnDescriptor.addVisibleColumn(new BuildSummaryColumn());
+ columnDescriptor.addHiddenColumn(new OSGiStatusColumn());
+ columnDescriptor.addHiddenColumn(new BundleTypeColumn());
- @Override
- void setValue(BundleStatus status, Boolean newValue) {
- fireBundleEnablementChangeRequested(status, newValue);
- }
- };
- columnDescriptor.addVisibleColumn(enabledColumn);
+ return columnDescriptor;
+ }
- activeColumn = new Column<>("Active") {
- @Override
- boolean editable(BundleStatus status) {
- return status.fileExists() && status.isEnabled();
- }
+ private abstract class Column<COLUMN_TYPE>
+ extends AbstractDynamicTableColumn<BundleStatus, COLUMN_TYPE, List<BundleStatus>> {
+ final String columnName;
- @Override
- public Boolean getValue(BundleStatus status) {
- return status.isActive();
- }
+ Column(String columnName) {
+ this.columnName = columnName;
+ }
- @Override
- void setValue(BundleStatus status, Boolean newValue) {
- fireBundleActivationChangeRequested(status, newValue);
- }
- };
- columnDescriptor.addHiddenColumn(activeColumn);
+ void setValue(BundleStatus status, COLUMN_TYPE aValue) {
+ throw new RuntimeException(columnName + " is not editable!");
- typeColumn = new Column<>("Type") {
- @Override
- public String getValue(BundleStatus status) {
- return status.getType().toString();
- }
+ }
- @Override
- public int getColumnPreferredWidth() {
- return 90;
- }
+ boolean isEditable(BundleStatus status) {
+ return false;
+ }
- };
- columnDescriptor.addVisibleColumn(typeColumn);
+ @Override
+ public String getColumnName() {
+ return columnName;
+ }
- pathColumn = new Column<>("Path") {
- @Override
- public ResourceFile getValue(BundleStatus status) {
- return status.getFile();
- }
+ }
- };
- columnDescriptor.addVisibleColumn(pathColumn);
+ private class OSGiStatusColumn extends Column<String> {
+ OSGiStatusColumn() {
+ super("OSGi Status");
+ }
- summaryColumn = new Column<>("Summary") {
- @Override
- public String getValue(BundleStatus status) {
- return status.getSummary();
+ @Override
+ public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
+ ServiceProvider serviceProvider0) throws IllegalArgumentException {
+ if (!status.isEnabled()) {
+ return "";
}
- };
- columnDescriptor.addVisibleColumn(summaryColumn);
+ if (status.isBusy()) {
+ return "...";
+ }
+ if (status.isActive()) {
+ return "Active";
+ }
+ return "Inactive";
+ }
- return columnDescriptor;
+ @Override
+ public int getColumnPreferredWidth() {
+ return 100;
+ }
}
- abstract class Column<COLUMN_TYPE>
- extends AbstractDynamicTableColumn<BundleStatus, COLUMN_TYPE, List<BundleStatus>> {
- final String columnName;
- GColumnRenderer<COLUMN_TYPE> renderer;
- int width = -1;
+ private class BundleTypeColumn extends Column<String> {
+ BundleTypeColumn() {
+ super("Bundle Type");
+ }
+
+ @Override
+ public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
+ ServiceProvider serviceProvider0) throws IllegalArgumentException {
+ return status.getType().toString();
+ }
- Column(String name) {
- super();
- this.columnName = name;
+ @Override
+ public int getColumnPreferredWidth() {
+ return 90;
}
- boolean editable(BundleStatus status) {
- return false;
+ }
+
+ private class EnabledColumn extends Column<Boolean> {
+ EnabledColumn() {
+ super("Enabled");
}
- abstract COLUMN_TYPE getValue(BundleStatus status);
+ @Override
+ public Boolean getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
+ ServiceProvider serviceProvider0) throws IllegalArgumentException {
+ return status.isEnabled();
+ }
@Override
- public COLUMN_TYPE getValue(BundleStatus rowObject, Settings settings,
- List<BundleStatus> data, ServiceProvider serviceProvider0)
- throws IllegalArgumentException {
- return getValue(rowObject);
+ public int getColumnPreferredWidth() {
+ return 60;
}
- void setValue(BundleStatus status, COLUMN_TYPE aValue) {
- throw new RuntimeException(columnName + " is not editable!");
+ @Override
+ boolean isEditable(BundleStatus status) {
+ return status.fileExists();
}
@Override
- public String getColumnName() {
- return columnName;
+ void setValue(BundleStatus status, Boolean newValue) {
+ fireBundleEnablementChangeRequested(status, newValue);
}
- int getModelIndex() {
- return getColumnIndex(this);
+ }
+
+ private class BundleFileColumn extends Column<ResourceFile> {
+ final BundleFileRenderer renderer = new BundleFileRenderer();
+
+ BundleFileColumn() {
+ super("Path");
}
- public void setColumnRenderer(GColumnRenderer<COLUMN_TYPE> renderer) {
- this.renderer = renderer;
+ @Override
+ public ResourceFile getValue(BundleStatus status, Settings settings,
+ List<BundleStatus> data, ServiceProvider serviceProvider0)
+ throws IllegalArgumentException {
+ return status.getFile();
}
@Override
- public GColumnRenderer<COLUMN_TYPE> getColumnRenderer() {
+ public GColumnRenderer<ResourceFile> getColumnRenderer() {
return renderer;
}
+ }
+
+ private class BuildSummaryColumn extends Column<String> {
+
+ BuildSummaryColumn() {
+ super("Build Summary");
+ }
+
@Override
- public int getColumnPreferredWidth() {
- return width;
+ public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
+ ServiceProvider serviceProvider0) throws IllegalArgumentException {
+ GhidraBundle bundle = bundleHost.getExistingGhidraBundle(status.getFile());
+ if (bundle == null) {
+ return "bundle cache error";
+ }
+ else if (bundle instanceof GhidraPlaceholderBundle) {
+ // placeholders will have a summary assigned on construction
+ return ((GhidraPlaceholderBundle) bundle).getSummary();
+ }
+ // other bundles will update their summary on build
+ return status.getSummary();
+ }
+
+ }
+
+ private class BundleFileRenderer extends AbstractGColumnRenderer<ResourceFile> {
+
+ @Override
+ public Component getTableCellRendererComponent(GTableCellRenderingData data) {
+ BundleStatus status = (BundleStatus) data.getRowObject();
+ ResourceFile file = (ResourceFile) data.getValue();
+ JLabel label = (JLabel) super.getTableCellRendererComponent(data);
+ label.setFont(defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD));
+ label.setText(Path.toPathString(file));
+ GhidraBundle bundle = bundleHost.getExistingGhidraBundle(file);
+ if (bundle == null || bundle instanceof GhidraPlaceholderBundle || !file.exists()) {
+ label.setForeground(COLOR_BUNDLE_ERROR);
+ }
+ else {
+ if (status.isBusy()) {
+ label.setForeground(COLOR_BUNDLE_BUSY);
+ }
+ else if (!status.isEnabled()) {
+ label.setForeground(COLOR_BUNDLE_DISABLED);
+ }
+ else if (status.isActive()) {
+ label.setForeground(COLOR_BUNDLE_ACTIVE);
+ }
+ else {
+ label.setForeground(COLOR_BUNDLE_INACTIVE);
+ }
+ }
+ return label;
+ }
+
+ @Override
+ public String getFilterString(ResourceFile file, Settings settings) {
+ return Path.toPathString(file);
}
- public void setColumnPreferredWidth(int width) {
- this.width = width;
+ }
+
+ private class BusyBooleanRenderer extends GBooleanCellRenderer
+ implements AbstractWrapperTypeColumnRenderer<Boolean> {
+ @Override
+ public Component getTableCellRendererComponent(GTableCellRenderingData data) {
+ BundleStatus status = (BundleStatus) data.getRowObject();
+ Component component = super.getTableCellRendererComponent(data);
+ if (status.isBusy()) {
+ cb.setVisible(false);
+ cb.setEnabled(false);
+ setHorizontalAlignment(SwingConstants.CENTER);
+ setText("...");
+ }
+ else {
+ cb.setVisible(true);
+ cb.setEnabled(true);
+ setText("");
+ }
+ return component;
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraPlaceholderBundle.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraPlaceholderBundle.java
index 0f9d6aad02..9b66c9fa04 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraPlaceholderBundle.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraPlaceholderBundle.java
@@ -27,10 +27,19 @@ import generic.jar.ResourceFile;
* {@link GhidraPlaceholderBundle} represents invalid bundle paths in the GUI.
*/
public class GhidraPlaceholderBundle extends GhidraBundle {
+ final String summary;
GhidraPlaceholderBundle(BundleHost bundleHost, ResourceFile bundleFile, boolean isEnabled,
- boolean isSystemBundle) {
+ boolean isSystemBundle, String summary) {
super(bundleHost, bundleFile, isEnabled, isSystemBundle);
+ this.summary = summary;
+ }
+
+ /**
+ * @return a summary of the reason for this placeholder
+ */
+ String getSummary() {
+ return summary;
}
@Override