mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/GP-5830_ghidra1_ProjectDataTableUpdates--SQUASHED'
This commit is contained in:
commit
1a1cdefc14
8 changed files with 362 additions and 27 deletions
|
@ -71,6 +71,7 @@ class ProjectDataPanel extends JSplitPane implements ProjectViewListener {
|
|||
readOnlyViews = new HashMap<>(TYPICAL_NUM_VIEWS);
|
||||
|
||||
projectTab = new JTabbedPane(SwingConstants.BOTTOM);
|
||||
projectTab.setName("PROJECT_TABBED_PANE");
|
||||
projectTab.setBorder(BorderFactory.createTitledBorder(BORDER_PREFIX));
|
||||
projectTab.addChangeListener(e -> frontEndPlugin.getTool().contextChanged(null));
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ import ghidra.framework.model.DomainFile;
|
|||
public class DomainFileInfo {
|
||||
|
||||
private DomainFile domainFile;
|
||||
private ProjectDataTableModel model;
|
||||
private int modCount;
|
||||
private String name;
|
||||
private String path;
|
||||
private Map<String, String> metadata;
|
||||
|
@ -36,9 +38,9 @@ public class DomainFileInfo {
|
|||
private Boolean isBrokenLink;
|
||||
private String toolTipText;
|
||||
|
||||
public DomainFileInfo(DomainFile domainFile) {
|
||||
DomainFileInfo(DomainFile domainFile, ProjectDataTableModel model) {
|
||||
this.domainFile = domainFile;
|
||||
this.path = domainFile.getParent().getPathname();
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
private String computeName() {
|
||||
|
@ -74,6 +76,7 @@ public class DomainFileInfo {
|
|||
}
|
||||
|
||||
public synchronized String getDisplayName() {
|
||||
checkModelModCount();
|
||||
if (name == null) {
|
||||
name = computeName();
|
||||
}
|
||||
|
@ -81,6 +84,7 @@ public class DomainFileInfo {
|
|||
}
|
||||
|
||||
public synchronized String getPath() {
|
||||
checkModelModCount();
|
||||
if (path == null) {
|
||||
path = domainFile.getParent().getPathname();
|
||||
}
|
||||
|
@ -88,6 +92,7 @@ public class DomainFileInfo {
|
|||
}
|
||||
|
||||
public synchronized DomainFileType getDomainFileType() {
|
||||
checkModelModCount();
|
||||
if (domainFileType == null) {
|
||||
checkStatus();
|
||||
String contentType = domainFile.getContentType();
|
||||
|
@ -102,7 +107,7 @@ public class DomainFileInfo {
|
|||
}
|
||||
|
||||
public synchronized Date getModificationDate() {
|
||||
|
||||
checkModelModCount();
|
||||
if (modificationDate == null) {
|
||||
modificationDate = getLastModifiedTime();
|
||||
}
|
||||
|
@ -118,6 +123,7 @@ public class DomainFileInfo {
|
|||
}
|
||||
|
||||
private synchronized Map<String, String> getMetadata() {
|
||||
checkModelModCount();
|
||||
if (metadata == null) {
|
||||
metadata = domainFile.getMetadata();
|
||||
if (metadata == null) {
|
||||
|
@ -154,7 +160,16 @@ public class DomainFileInfo {
|
|||
return domainFile.getName();
|
||||
}
|
||||
|
||||
private void checkStatus() {
|
||||
private void checkModelModCount() {
|
||||
int modelModCount = model.getModCount();
|
||||
if (modelModCount != modCount) {
|
||||
refresh();
|
||||
modCount = modelModCount;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void checkStatus() {
|
||||
checkModelModCount();
|
||||
if (isBrokenLink == null) {
|
||||
isBrokenLink = false;
|
||||
List<String> linkErrors = null;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -40,10 +39,6 @@ public class DomainFileType implements Comparable<DomainFileType>, DisplayString
|
|||
return result;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -34,6 +34,7 @@ import ghidra.util.task.TaskMonitor;
|
|||
public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, ProjectData> {
|
||||
|
||||
private ProjectData projectData;
|
||||
private volatile int modCount;
|
||||
private boolean editingOn;
|
||||
|
||||
private boolean loadWasCancelled;
|
||||
|
@ -50,6 +51,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
protected void doLoad(Accumulator<DomainFileInfo> accumulator, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
loadWasCancelled = false;
|
||||
++modCount;
|
||||
if (projectData != null) {
|
||||
loadWasCancelled = true;
|
||||
DomainFolder rootFolder = projectData.getRootFolder();
|
||||
|
@ -63,7 +65,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
DomainFile[] files = folder.getFiles();
|
||||
for (DomainFile domainFile : files) {
|
||||
monitor.checkCancelled();
|
||||
accumulator.add(new DomainFileInfo(domainFile));
|
||||
accumulator.add(new DomainFileInfo(domainFile, this));
|
||||
}
|
||||
DomainFolder[] folders = folder.getFolders();
|
||||
for (DomainFolder domainFolder : folders) {
|
||||
|
@ -113,13 +115,16 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
|
||||
@Override
|
||||
public void refresh() {
|
||||
List<DomainFileInfo> modelData = getModelData();
|
||||
for (DomainFileInfo domainFileInfo : modelData) {
|
||||
domainFileInfo.refresh();
|
||||
}
|
||||
// The modCount allows DomainFileInfo to determine if its cached data is stale relative
|
||||
// to this model
|
||||
++modCount;
|
||||
super.refresh();
|
||||
}
|
||||
|
||||
int getModCount() {
|
||||
return modCount;
|
||||
}
|
||||
|
||||
public void setProjectData(ProjectData projectData) {
|
||||
this.projectData = projectData;
|
||||
reload();
|
||||
|
@ -162,7 +167,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
//==================================================================================================
|
||||
|
||||
private class DomainFileTypeColumn
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, DomainFileType, ProjectData> {
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, DomainFileType, ProjectData> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
@ -182,7 +187,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
}
|
||||
|
||||
private class DomainFileNameColumn
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, String, ProjectData> {
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, String, ProjectData> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
@ -203,7 +208,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
}
|
||||
|
||||
private class ModificationDateColumn
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, Date, ProjectData> {
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, Date, ProjectData> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
@ -224,7 +229,7 @@ public class ProjectDataTableModel extends ThreadedTableModel<DomainFileInfo, Pr
|
|||
}
|
||||
|
||||
private class DomainFilePathColumn
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, String, ProjectData> {
|
||||
extends AbstractDynamicTableColumn<DomainFileInfo, String, ProjectData> {
|
||||
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
|
|
|
@ -373,7 +373,8 @@ public class ProjectDataTablePanel extends JPanel {
|
|||
}
|
||||
checkCapacity();
|
||||
if (!capacityExceeded) {
|
||||
model.addObject(new DomainFileInfo(file));
|
||||
model.addObject(new DomainFileInfo(file, model));
|
||||
model.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +383,7 @@ public class ProjectDataTablePanel extends JPanel {
|
|||
if (ignoreChanges()) {
|
||||
return;
|
||||
}
|
||||
model.refresh();
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -399,6 +400,7 @@ public class ProjectDataTablePanel extends JPanel {
|
|||
break;
|
||||
}
|
||||
}
|
||||
model.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue