a status is not a path

This commit is contained in:
Jason P. Leasure 2020-04-02 17:54:03 -04:00
parent 431d7ac752
commit 15f46b7fae
4 changed files with 40 additions and 16 deletions

View file

@ -77,7 +77,6 @@ public class BundleCompiler {
options.add(System.getProperty("java.class.path") + File.pathSeparator + bindir.toString());
options.add("-proc:none");
// final JavaFileManager rfm = new ResourceFileJavaFileManager(Collections.singletonList(bi.getSourceDir()));
final JavaFileManager rfm =
new ResourceFileJavaFileManager(Collections.singletonList(sb.getSourceDir()));

View file

@ -19,13 +19,29 @@ import generic.jar.ResourceFile;
import generic.util.Path;
/**
* The BundleStatus class represents the runtime state and user preferences for OSGi bundles in Ghidra.
* The BundleStatus class represents the runtime state and user preferences for OSGi bundles in Ghidra.
*
* XXX: this class relies on generic.util.Path solely for the parsing and formatting of USER_HOME and GHIDRA_HOME
*/
public class BundleStatus extends Path {
public class BundleStatus implements Comparable<BundleStatus> {
final Path path;
final GhidraBundle.Type type;
boolean active = false;
boolean busy = false;
public boolean isEnabled() {
return path.isEnabled();
}
public void setEnabled(boolean isEnabled) {
path.setEnabled(isEnabled);
}
public boolean isReadOnly() {
return path.isReadOnly();
}
String summary;
public GhidraBundle.Type getType() {
@ -33,12 +49,12 @@ public class BundleStatus extends Path {
}
BundleStatus(String path, boolean enabled, boolean readonly) {
super(path, enabled, false /*editable */, readonly);
this.path = new Path(path, enabled, false, readonly);
type = GhidraBundle.getType(getPath());
}
BundleStatus(ResourceFile path, boolean enabled, boolean readonly) {
super(path, enabled, false /* editable */, readonly);
this.path = new Path(path, enabled, false, readonly);
type = GhidraBundle.getType(getPath());
}
@ -50,11 +66,6 @@ public class BundleStatus extends Path {
return active;
}
@Override
public boolean isEditable() {
return false;
}
public void setActive(boolean b) {
active = b;
}
@ -75,8 +86,21 @@ public class BundleStatus extends Path {
return summary;
}
public ResourceFile getPath() {
return path.getPath();
}
public boolean pathExists() {
return exists();
return path.exists();
}
@Override
public int compareTo(BundleStatus o) {
return path.compareTo(o != null ? o.path : null);
}
public String getPathAsString() {
return path.getPathAsString();
}
}

View file

@ -99,10 +99,10 @@ public class BundleStatusModel extends AbstractSortedTableModel<BundleStatus> {
}
};
Column pathColumn = new Column("Path", String.class) {
Column pathColumn = new Column("Path", ResourceFile.class) {
@Override
Object getValue(BundleStatus status) {
return status.getPath().toString();
return status.getPath();
}
};
Column summaryColumn = new Column("Summary", String.class) {
@ -164,7 +164,7 @@ public class BundleStatusModel extends AbstractSortedTableModel<BundleStatus> {
// add user path
this.statuses.add(0,
new BundleStatus(GhidraScriptUtil.getUserScriptDirectory(), true, false));
computeCache();
bundleHost.addListener(bundleListener = new OSGiListener() {

View file

@ -27,6 +27,7 @@ import javax.swing.table.TableColumn;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.table.*;
import generic.jar.ResourceFile;
import ghidra.app.services.ConsoleService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.PluginTool;
@ -182,8 +183,8 @@ public class BundleStatusProvider extends ComponentProviderAdapter {
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
JLabel c = (JLabel) super.getTableCellRendererComponent(data);
BundleStatus status = (BundleStatus) data.getValue();
if (!status.pathExists()) {
ResourceFile path = (ResourceFile) data.getValue();
if (!path.exists()) {
c.setForeground(Color.RED);
}
return c;