Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
TagNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020-2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import org.openide.nodes.Children;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.Lookup;
26 import org.openide.util.NbBundle;
30 import org.sleuthkit.datamodel.Content;
31 
45 @NbBundle.Messages({
46  "TagNode.propertySheet.origName=Original Name",
47  "TagNode.propertySheet.origNameDisplayName=Original Name"
48 })
49 abstract class TagNode extends DisplayableItemNode {
50 
51  private final static String ORIG_NAME_PROP_NAME = Bundle.TagNode_propertySheet_origName();
52  private final static String ORIG_NAME_PROP_DISPLAY_NAME = Bundle.TagNode_propertySheet_origNameDisplayName();
53 
54  private final String originalName;
55  private volatile String translatedName;
56 
65  TagNode(Lookup lookup, Content content) {
66  super(Children.LEAF, lookup);
67  originalName = content.getName();
68  }
69 
70  @Override
71  public boolean isLeafTypeNode() {
72  return true;
73  }
74 
75  @Override
76  abstract public String getItemType();
77 
78  @Override
79  abstract public <T> T accept(DisplayableItemNodeVisitor<T> visitor);
80 
92  protected void addOriginalNameProp(Sheet.Set properties) {
93  if (TextTranslationService.getInstance().hasProvider() && UserPreferences.displayTranslatedFileNames()) {
94  properties.put(new NodeProperty<>(
95  ORIG_NAME_PROP_NAME,
96  ORIG_NAME_PROP_DISPLAY_NAME,
97  "",
98  translatedName != null ? originalName : ""));
99  if (translatedName == null) {
100  new FileNameTransTask(originalName, this, new NameTranslationListener()).submit();
101  }
102  }
103  }
104 
109  private class NameTranslationListener implements PropertyChangeListener {
110 
111  @Override
112  public void propertyChange(PropertyChangeEvent evt) {
113  String eventType = evt.getPropertyName();
114  if (eventType.equals(FileNameTransTask.getPropertyName())) {
115  translatedName = evt.getNewValue().toString();
116  String originalName = evt.getOldValue().toString();
117  setDisplayName(translatedName);
118  setShortDescription(originalName);
119  updatePropertySheet(new NodeProperty<>(
120  ORIG_NAME_PROP_NAME,
121  ORIG_NAME_PROP_DISPLAY_NAME,
122  "",
123  originalName));
124  }
125  }
126  }
127 
128 }

Copyright © 2012-2022 Basis Technology. Generated on: Wed Feb 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.