This commit is contained in:
Devin148 2012-11-02 07:11:16 -04:00
commit 9dfd0c14e8
3 changed files with 99 additions and 67 deletions

View File

@ -304,10 +304,10 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
}
if(content != null) {
try {
int size = content.getAllArtifacts().size();
long size = content.getAllArtifactsCount();
return size > 0;
} catch (TskException ex) {
logger.log(Level.WARNING, "Couldn't get All Blackboard Artifacts", ex);
logger.log(Level.WARNING, "Couldn't get All Blackboard Artifacts Count", ex);
}
}
return false;

View File

@ -484,9 +484,90 @@ class ExtractedContentPanel extends javax.swing.JPanel {
}
/**
* Swingworker to get makrup source content String from Solr in background thread
* and then set the panel text in the EDT
* Helps not to block the UI while content from Solr is retrieved.
* Update page and search controls for selected source
*
* @param source the selected source
*/
void updateControls(MarkupSource source) {
updatePageControls(source);
updateSearchControls(source);
}
/**
* update page controls given the selected source
*
* @param source selected source
*/
void updatePageControls(MarkupSource source) {
if (source == null) {
enableNextPageControl(false);
enablePrevPageControl(false);
updateCurrentPageDisplay(0);
updateTotalPageslDisplay(0);
return;
}
updateCurrentPageDisplay(source.getCurrentPage());
int totalPages = source.getNumberPages();
updateTotalPageslDisplay(totalPages);
if (totalPages == 1) {
enableNextPageControl(false);
enablePrevPageControl(false);
} else {
if (source.hasNextPage()) {
enableNextPageControl(true);
} else {
enableNextPageControl(false);
}
if (source.hasPreviousPage()) {
enablePrevPageControl(true);
} else {
enablePrevPageControl(false);
}
}
}
/**
* update search controls given the selected source
*
* @param source selected source
*/
void updateSearchControls(MarkupSource source) {
//setup search controls
if (source != null && source.isSearchable()) {
updateCurrentMatchDisplay(source.currentItem());
updateTotaMatcheslDisplay(source.getNumberHits());
if (source.hasNextItem() || source.hasNextPage()) {
enableNextMatchControl(true);
} else {
enableNextMatchControl(false);
}
if (source.hasPreviousItem() || source.hasPreviousPage()) {
enablePrevMatchControl(true);
} else {
enablePrevMatchControl(false);
}
} else {
enableNextMatchControl(false);
enablePrevMatchControl(false);
updateCurrentMatchDisplay(0);
updateTotaMatcheslDisplay(0);
}
}
/**
* Swingworker to get makrup source content String from Solr in background
* thread and then set the panel text in the EDT Helps not to block the UI
* while content from Solr is retrieved.
*/
private final class SetMarkup extends SwingWorker<Object, Void> {
@ -519,6 +600,10 @@ class ExtractedContentPanel extends javax.swing.JPanel {
} else {
setPanelText("");
}
updateControls(source);
}
}
}

View File

@ -222,22 +222,21 @@ public class ExtractedContentViewer implements DataContentViewer {
}
};
//initialize the source
newSource.getNumberPages();
currentSource = newSource;
sources.add(newSource);
//init pages
final int totalPages = currentSource.getNumberPages();
int currentPage = currentSource.getCurrentPage();
if (currentPage == 0 && currentSource.hasNextPage()) {
currentSource.nextPage();
}
updatePageControls();
// first source will be the default displayed
setPanel(sources);
// If node has been selected before, return to the previous position
@ -275,7 +274,7 @@ public class ExtractedContentViewer implements DataContentViewer {
}
@Override
public Component getComponent() {
public synchronized Component getComponent() {
if (panel == null) {
panel = new ExtractedContentPanel();
panel.addPrevMatchControlListener(new PrevFindActionListener());
@ -520,9 +519,6 @@ public class ExtractedContentViewer implements DataContentViewer {
return;
}
final int totalPages = currentSource.getNumberPages();
final int currentPage = currentSource.getCurrentPage();
updatePageControls();
updateSearchControls();
@ -530,60 +526,11 @@ public class ExtractedContentViewer implements DataContentViewer {
}
private void updateSearchControls() {
//setup search controls
if (currentSource != null && currentSource.isSearchable()) {
panel.updateCurrentMatchDisplay(currentSource.currentItem());
panel.updateTotaMatcheslDisplay(currentSource.getNumberHits());
if (currentSource.hasNextItem() || currentSource.hasNextPage()) {
panel.enableNextMatchControl(true);
} else {
panel.enableNextMatchControl(false);
}
if (currentSource.hasPreviousItem() || currentSource.hasPreviousPage()) {
panel.enablePrevMatchControl(true);
} else {
panel.enablePrevMatchControl(false);
}
} else {
panel.enableNextMatchControl(false);
panel.enablePrevMatchControl(false);
panel.updateCurrentMatchDisplay(0);
panel.updateTotaMatcheslDisplay(0);
}
panel.updateSearchControls(currentSource);
}
private void updatePageControls() {
if (currentSource == null) {
return;
}
final int currentPage = currentSource.getCurrentPage();
final int totalPages = currentSource.getNumberPages();
panel.updateTotalPageslDisplay(totalPages);
panel.updateCurrentPageDisplay(currentPage);
if (totalPages == 1) {
panel.enableNextPageControl(false);
panel.enablePrevPageControl(false);
} else {
if (currentSource.hasNextPage()) {
panel.enableNextPageControl(true);
} else {
panel.enableNextPageControl(false);
}
if (currentSource.hasPreviousPage()) {
panel.enablePrevPageControl(true);
} else {
panel.enablePrevPageControl(false);
}
}
panel.updateControls(currentSource);
}
private void nextPage() {