Merge pull request #4712 from kellykelly3/1226-add-messageContentViewer

1226 added message content viewer
This commit is contained in:
Richard Cordovano 2019-04-17 18:37:02 -04:00 committed by GitHub
commit 2b32ce7fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 147 additions and 131 deletions

View File

@ -39,4 +39,3 @@ VisualizationPanel.fastOrganicLayoutButton.text=Fast Organic
VisualizationPanel.hierarchyLayoutButton.text=Hierarchical VisualizationPanel.hierarchyLayoutButton.text=Hierarchical
VisualizationPanel.clearVizButton.text_1=Clear Viz. VisualizationPanel.clearVizButton.text_1=Clear Viz.
VisualizationPanel.snapshotButton.text_1=Snapshot Report VisualizationPanel.snapshotButton.text_1=Snapshot Report
ContactsViewer.testLabel.text=No Value Set

View File

@ -89,7 +89,6 @@ VisualizationPanel.fastOrganicLayoutButton.text=Fast Organic
VisualizationPanel.hierarchyLayoutButton.text=Hierarchical VisualizationPanel.hierarchyLayoutButton.text=Hierarchical
VisualizationPanel.clearVizButton.text_1=Clear Viz. VisualizationPanel.clearVizButton.text_1=Clear Viz.
VisualizationPanel.snapshotButton.text_1=Snapshot Report VisualizationPanel.snapshotButton.text_1=Snapshot Report
ContactsViewer.testLabel.text=No Value Set
VisualizationPanel_action_dialogs_title=Communications VisualizationPanel_action_dialogs_title=Communications
VisualizationPanel_action_name_text=Snapshot Report VisualizationPanel_action_name_text=Snapshot Report
VisualizationPanel_module_name=Communications VisualizationPanel_module_name=Communications

View File

@ -16,30 +16,13 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <EmptySpace min="0" pref="692" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="testLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="294" max="32767" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <EmptySpace min="0" pref="573" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="testLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="264" max="32767" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="testLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/communications/Bundle.properties" key="ContactsViewer.testLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form> </Form>

View File

@ -59,30 +59,19 @@ public class ContactsViewer extends JPanel implements RelationshipsViewer{
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
testLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(testLabel, org.openide.util.NbBundle.getMessage(ContactsViewer.class, "ContactsViewer.testLabel.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGap(0, 692, Short.MAX_VALUE)
.addContainerGap()
.addComponent(testLabel)
.addContainerGap(294, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGap(0, 573, Short.MAX_VALUE)
.addContainerGap()
.addComponent(testLabel)
.addContainerGap(264, Short.MAX_VALUE))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel testLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -18,15 +18,16 @@
*/ */
package org.sleuthkit.autopsy.communications; package org.sleuthkit.autopsy.communications;
import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
import org.sleuthkit.autopsy.datamodel.NodeProperty; import org.sleuthkit.autopsy.datamodel.NodeProperty;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
@ -39,37 +40,22 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHO
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO; import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT; import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME; import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
import org.sleuthkit.datamodel.Tag;
import org.sleuthkit.datamodel.TimeUtilities; import org.sleuthkit.datamodel.TimeUtilities;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Wraps a BlackboardArtifact as an AbstractNode for use in an OutlookView * Wraps a BlackboardArtifact as an AbstractNode for use in an OutlookView
*/ */
final class MessageNode extends AbstractNode { final class MessageNode extends BlackboardArtifactNode {
private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName()); private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
private final BlackboardArtifact artifact;
MessageNode(BlackboardArtifact artifact) { MessageNode(BlackboardArtifact artifact) {
super(Children.LEAF, Lookups.fixed(artifact)); super(artifact);
this.artifact = artifact;
final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(), "s"); // NON-NLS final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(), "s"); // NON-NLS
String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd, "message"); // NON-NLS String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd, "message"); // NON-NLS
setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase); setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
int typeID = artifact.getArtifactTypeID();
String filePath = "org/sleuthkit/autopsy/images/"; //NON-NLS
if( typeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) {
filePath = filePath + "mail-icon-16.png"; //NON-NLS
} else if (typeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
filePath = filePath + "message.png"; //NON-NLS
} else if (typeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG.getTypeID()) {
filePath = filePath + "calllog.png"; //NON-NLS
}
setIconBaseWithExtension(filePath);
} }
@Messages({ @Messages({
@ -84,6 +70,7 @@ final class MessageNode extends AbstractNode {
@Override @Override
protected Sheet createSheet() { protected Sheet createSheet() {
Sheet sheet = new Sheet(); Sheet sheet = new Sheet();
List<Tag> tags = getAllTagsFromDatabase();
Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES); Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
if (sheetSet == null) { if (sheetSet == null) {
sheetSet = Sheet.createPropertiesSet(); sheetSet = Sheet.createPropertiesSet();
@ -92,6 +79,19 @@ final class MessageNode extends AbstractNode {
sheetSet.put(new NodeProperty<>("Type", Bundle.MessageNode_Node_Property_Type(), "", getDisplayName())); //NON-NLS sheetSet.put(new NodeProperty<>("Type", Bundle.MessageNode_Node_Property_Type(), "", getDisplayName())); //NON-NLS
addScoreProperty(sheetSet, tags);
CorrelationAttributeInstance correlationAttribute = null;
if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
correlationAttribute = getCorrelationAttributeInstance();
}
addCommentProperty(sheetSet, tags, correlationAttribute);
if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
addCountProperty(sheetSet, correlationAttribute);
}
final BlackboardArtifact artifact = getArtifact();
BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID()); BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
if (null != fromID) { if (null != fromID) {
//Consider refactoring this to reduce boilerplate //Consider refactoring this to reduce boilerplate
@ -170,4 +170,15 @@ final class MessageNode extends AbstractNode {
return ""; return "";
} }
} }
/**
* Circumvent DataResultFilterNode's slightly odd delegation to
* BlackboardArtifactNode.getSourceName().
*
* @return the displayName of this Node, which is the type.
*/
@Override
public String getSourceName() {
return getDisplayName();
}
} }

View File

@ -16,14 +16,16 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="outlineView" alignment="0" pref="480" max="32767" attributes="0"/> <Component id="outlineView" alignment="0" max="32767" attributes="0"/>
<Component id="contentViewer" alignment="1" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="outlineView" min="-2" pref="475" max="-2" attributes="0"/> <Component id="outlineView" min="-2" pref="190" max="-2" attributes="0"/>
<EmptySpace min="0" pref="16" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="contentViewer" pref="778" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -31,5 +33,10 @@
<SubComponents> <SubComponents>
<Component class="org.openide.explorer.view.OutlineView" name="outlineView"> <Component class="org.openide.explorer.view.OutlineView" name="outlineView">
</Component> </Component>
<Component class="org.sleuthkit.autopsy.contentviewers.MessageContentViewer" name="contentViewer">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MessageDataContent()"/>
</AuxValues>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -18,17 +18,24 @@
*/ */
package org.sleuthkit.autopsy.communications; package org.sleuthkit.autopsy.communications;
import java.awt.Component;
import java.awt.KeyboardFocusManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import static javax.swing.SwingUtilities.isDescendingFrom;
import org.netbeans.swing.outline.DefaultOutlineModel; import org.netbeans.swing.outline.DefaultOutlineModel;
import org.netbeans.swing.outline.Outline; import org.netbeans.swing.outline.Outline;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils; import static org.openide.explorer.ExplorerUtils.createLookup;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
/** /**
* Visualation for the messages of the currently selected accounts. * Visualation for the messages of the currently selected accounts.
@ -36,9 +43,10 @@ import org.openide.util.lookup.ServiceProvider;
@ServiceProvider(service = RelationshipsViewer.class) @ServiceProvider(service = RelationshipsViewer.class)
public class MessagesViewer extends JPanel implements RelationshipsViewer, ExplorerManager.Provider, Lookup.Provider{ public class MessagesViewer extends JPanel implements RelationshipsViewer, ExplorerManager.Provider, Lookup.Provider{
private final ExplorerManager tableEM = new ExplorerManager(); private final ExplorerManager tableEM;
private final Lookup lookup;
private final Outline outline; private final Outline outline;
private final ModifiableProxyLookup proxyLookup;
private final PropertyChangeListener focusPropertyListener;
@Messages({ @Messages({
"MessageViewer_tabTitle=Messages", "MessageViewer_tabTitle=Messages",
@ -53,6 +61,29 @@ public class MessagesViewer extends JPanel implements RelationshipsViewer, Explo
* Creates new form MessagesViewer * Creates new form MessagesViewer
*/ */
public MessagesViewer() { public MessagesViewer() {
tableEM = new ExplorerManager();
proxyLookup = new ModifiableProxyLookup(createLookup(tableEM, getActionMap()));
// See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed
// explaination of focusPropertyListener
focusPropertyListener = (final PropertyChangeEvent focusEvent) -> {
if (focusEvent.getPropertyName().equalsIgnoreCase("focusOwner")) {
final Component newFocusOwner = (Component) focusEvent.getNewValue();
if (newFocusOwner == null) {
return;
}
if (isDescendingFrom(newFocusOwner, contentViewer)) {
//if the focus owner is within the MessageContentViewer (the attachments table)
proxyLookup.setNewLookups(createLookup(((MessageDataContent) contentViewer).getExplorerManager(), getActionMap()));
} else if (isDescendingFrom(newFocusOwner, MessagesViewer.this)) {
//... or if it is within the Results table.
proxyLookup.setNewLookups(createLookup(tableEM, getActionMap()));
}
}
} ;
initComponents(); initComponents();
outline = outlineView.getOutline(); outline = outlineView.getOutline();
@ -62,13 +93,20 @@ public class MessagesViewer extends JPanel implements RelationshipsViewer, Explo
"Date", Bundle.MessageViewer_columnHeader_Date(), "Date", Bundle.MessageViewer_columnHeader_Date(),
"Subject", Bundle.MessageViewer_columnHeader_Subject(), "Subject", Bundle.MessageViewer_columnHeader_Subject(),
"Attms", Bundle.MessageViewer_columnHeader_Attms() "Attms", Bundle.MessageViewer_columnHeader_Attms()
); );
outline.setRootVisible(false); outline.setRootVisible(false);
outline.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); outline.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.AccountNode_accountName()); ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.AccountNode_accountName());
lookup = ExplorerUtils.createLookup(tableEM, getActionMap()); tableEM.addPropertyChangeListener((PropertyChangeEvent evt) -> {
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
final Node[] nodes = tableEM.getSelectedNodes();
if (nodes != null && nodes.length > 0) {
contentViewer.setNode(nodes[0]);
}
}
});
} }
@Override @Override
@ -83,7 +121,7 @@ public class MessagesViewer extends JPanel implements RelationshipsViewer, Explo
@Override @Override
public void setSelectionInfo(SelectionInfo info) { public void setSelectionInfo(SelectionInfo info) {
tableEM.setRootContext(new AbstractNode(Children.create(new MessagesChildNodeFactory(info), true))); tableEM.setRootContext(new DataResultFilterNode(new AbstractNode(Children.create(new MessagesChildNodeFactory(info), true)), getExplorerManager()));
} }
@Override @Override
@ -93,7 +131,22 @@ public class MessagesViewer extends JPanel implements RelationshipsViewer, Explo
@Override @Override
public Lookup getLookup() { public Lookup getLookup() {
return lookup; return proxyLookup;
}
@Override
public void addNotify() {
super.addNotify();
//add listener that maintains correct selection in the Global Actions Context
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("focusOwner", focusPropertyListener);
}
@Override
public void removeNotify() {
super.removeNotify();
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removePropertyChangeListener("focusOwner", focusPropertyListener);
} }
/** /**
@ -106,23 +159,27 @@ public class MessagesViewer extends JPanel implements RelationshipsViewer, Explo
private void initComponents() { private void initComponents() {
outlineView = new org.openide.explorer.view.OutlineView(); outlineView = new org.openide.explorer.view.OutlineView();
contentViewer = new MessageDataContent();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(outlineView, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE) .addComponent(outlineView, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(contentViewer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(outlineView, javax.swing.GroupLayout.PREFERRED_SIZE, 475, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(outlineView, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 16, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(contentViewer, javax.swing.GroupLayout.DEFAULT_SIZE, 778, Short.MAX_VALUE))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private org.sleuthkit.autopsy.contentviewers.MessageContentViewer contentViewer;
private org.openide.explorer.view.OutlineView outlineView; private org.openide.explorer.view.OutlineView outlineView;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -1,48 +0,0 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2017-2019 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.communications;
import java.util.Collection;
import java.util.List;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Node;
import org.sleuthkit.datamodel.BlackboardArtifact;
/**
*
*/
public class RelaionshipSetNodeFactory extends ChildFactory<BlackboardArtifact> {
private final Collection<BlackboardArtifact> artifacts;
public RelaionshipSetNodeFactory(Collection<BlackboardArtifact> artifacts) {
this.artifacts = artifacts;
}
@Override
protected boolean createKeys(List<BlackboardArtifact> list) {
list.addAll(artifacts);
return true;
}
@Override
protected Node createNodeForKey(BlackboardArtifact key) {
return new RelationshipNode(key);
}
}

View File

@ -27,6 +27,9 @@
</Layout> </Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JTabbedPane" name="tabPane"> <Container class="javax.swing.JTabbedPane" name="tabPane">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="tabPaneStateChanged"/>
</Events>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container> </Container>

View File

@ -27,6 +27,8 @@ import org.openide.util.Lookup;
*/ */
public class RelationshipBrowser extends JPanel { public class RelationshipBrowser extends JPanel {
private SelectionInfo currentSelection;
/** /**
* Creates new form RelationshipBrowser * Creates new form RelationshipBrowser
*/ */
@ -38,11 +40,15 @@ public class RelationshipBrowser extends JPanel {
}); });
} }
/**
* Sets the value of currentSelection and passes the SelectionInfo onto
* the currently selected\visible tab.
*
* @param info Currently selected account nodes
*/
public void setSelectionInfo(SelectionInfo info) { public void setSelectionInfo(SelectionInfo info) {
currentSelection = info;
((RelationshipsViewer)tabPane.getSelectedComponent()).setSelectionInfo(info); ((RelationshipsViewer)tabPane.getSelectedComponent()).setSelectionInfo(info);
// TODO If we only pass the info to the currently selected tab, we
// need to do something when the tab changes
} }
/** /**
@ -56,6 +62,12 @@ public class RelationshipBrowser extends JPanel {
tabPane = new javax.swing.JTabbedPane(); tabPane = new javax.swing.JTabbedPane();
tabPane.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
tabPaneStateChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -68,6 +80,10 @@ public class RelationshipBrowser extends JPanel {
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void tabPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabPaneStateChanged
((RelationshipsViewer)tabPane.getSelectedComponent()).setSelectionInfo(currentSelection);
}//GEN-LAST:event_tabPaneStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane tabPane; private javax.swing.JTabbedPane tabPane;