move properties to NbBundle.messages annotation and out of Bundle.properties

This commit is contained in:
jmillman 2015-08-11 15:24:58 -04:00
parent b7ca50385d
commit 572fc50b6b
5 changed files with 31 additions and 63 deletions

View File

@ -29,3 +29,4 @@ TimeLineTopComponent.filterTab.name=Filters
OpenTimelineAction.title=Timeline
OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources.
TimeLineTopComponent.timeZonePanel.text=Display Times In\:
ProgressWindow.progressHeader.text=\

View File

@ -53,8 +53,11 @@
</Component>
<Component class="javax.swing.JLabel" name="progressHeader">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 14]"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/timeline/Bundle.properties" key="ProgressWindow.progressHeader.text" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[10, 14]"/>
</Property>
</Properties>
</Component>

View File

@ -33,8 +33,7 @@ import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;
import static org.sleuthkit.autopsy.timeline.Bundle.Timeline_progressWindow_name;
import static org.sleuthkit.autopsy.timeline.Bundle.Timeline_progressWindow_title;
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
/**
* Dialog with progress bar that pops up when timeline is being generated
@ -61,8 +60,8 @@ public class ProgressWindow extends JFrame {
setIconImage(WindowManager.getDefault().getMainWindow().getIconImage());
});
setName(Timeline_progressWindow_name());
setTitle(Timeline_progressWindow_title());
setName(Bundle.Timeline_progressWindow_name());
setTitle(Bundle.Timeline_progressWindow_title());
// Close the dialog when Esc is pressed
String cancelName = "cancel"; // NON-NLS
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
@ -79,46 +78,6 @@ public class ProgressWindow extends JFrame {
this.worker = worker;
}
public void updateProgress(final int progress) {
SwingUtilities.invokeLater(() -> {
progressBar.setValue(progress);
});
}
public void updateProgress(final int progress, final String message) {
SwingUtilities.invokeLater(() -> {
progressBar.setValue(progress);
progressBar.setString(message);
});
}
public void updateProgress(final String message) {
SwingUtilities.invokeLater(() -> {
progressBar.setString(message);
});
}
public void setProgressTotal(final int total) {
SwingUtilities.invokeLater(() -> {
progressBar.setIndeterminate(false);
progressBar.setMaximum(total);
progressBar.setStringPainted(true);
});
}
public void updateHeaderMessage(final String headerMessage) {
SwingUtilities.invokeLater(() -> {
progressHeader.setText(headerMessage);
});
}
public void setIndeterminate() {
SwingUtilities.invokeLater(() -> {
progressBar.setIndeterminate(true);
progressBar.setStringPainted(true);
});
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@ -137,7 +96,8 @@ public class ProgressWindow extends JFrame {
}
});
progressHeader.setPreferredSize(new java.awt.Dimension(0, 14));
org.openide.awt.Mnemonics.setLocalizedText(progressHeader, NbBundle.getMessage(ProgressWindow.class, "ProgressWindow.progressHeader.text")); // NOI18N
progressHeader.setMinimumSize(new java.awt.Dimension(10, 14));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -200,14 +160,19 @@ public class ProgressWindow extends JFrame {
private javax.swing.JLabel progressHeader;
// End of variables declaration//GEN-END:variables
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
public void update(ProgressUpdate chunk) {
updateHeaderMessage(chunk.getHeaderMessage());
progressHeader.setText(chunk.getHeaderMessage());
if (chunk.getTotal() >= 0) {
setProgressTotal(chunk.getTotal());
updateProgress(chunk.getProgress(), chunk.getDetailMessage());
progressBar.setIndeterminate(false);
progressBar.setMaximum(chunk.getTotal());
progressBar.setStringPainted(true);
progressBar.setValue(chunk.getProgress());
progressBar.setString(chunk.getDetailMessage());
} else {
setIndeterminate();
updateProgress(chunk.getDetailMessage());
progressBar.setIndeterminate(true);
progressBar.setStringPainted(true);
progressBar.setString(chunk.getDetailMessage());
}
}

View File

@ -1,6 +1,5 @@
EventsRepository.progressWindow.msg.reinit_db=(re)initializing events database
EventsRepository.progressWindow.msg.populateMacEventsFiles=populating mac events for files\:
EventsRepository.progressWindow.msg.populateMacEventsFiles2=populating mac events for files\:
EventsRepository.progressWindow.msg.commitingDb=committing events db
EventsRepository.msgdlg.problem.text=There was a problem populating the timeline. Not all events may be present or accurate. See the log for details.
EventsRepository.progressWindow.populatingXevents=populating {0} events

View File

@ -244,7 +244,7 @@ public class EventsRepository {
@Override
protected Void doInBackground() throws Exception {
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, -1, NbBundle.getMessage(this.getClass(),
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, -1, NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.msg.reinit_db"), "")));
//reset database
//TODO: can we do more incremental updates? -jm
@ -256,8 +256,8 @@ public class EventsRepository {
List<Long> files = skCase.findAllFileIdsWhere("name != '.' AND name != '..'");
final int numFiles = files.size();
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, numFiles, NbBundle.getMessage(this.getClass(),
"EventsRepository.progressWindow.msg.populateMacEventsFiles"), "")));
publish(new ProgressWindow.ProgressUpdate(0, numFiles, NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.msg.populateMacEventsFiles"), ""));
//insert file events into db
int i = 1;
@ -298,8 +298,8 @@ public class EventsRepository {
}
process(Arrays.asList(new ProgressWindow.ProgressUpdate(i, numFiles,
NbBundle.getMessage(this.getClass(),
"EventsRepository.progressWindow.msg.populateMacEventsFiles2"), f.getName())));
NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.msg.populateMacEventsFiles"), f.getName())));
} else {
LOGGER.log(Level.WARNING, "failed to look up data for file : {0}", fID); // NON-NLS
}
@ -322,7 +322,7 @@ public class EventsRepository {
}
}
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, -1, NbBundle.getMessage(this.getClass(),
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, -1, NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.msg.commitingDb"), "")));
if (isCancelled()) {
eventDB.rollBackTransaction(trans);
@ -359,11 +359,11 @@ public class EventsRepository {
LOGGER.log(Level.INFO, "Database population was cancelled by the user. Not all events may be present or accurate. See the log for details.", ex); // NON-NLS
} catch (InterruptedException | ExecutionException ex) {
LOGGER.log(Level.WARNING, "Exception while populating database.", ex); // NON-NLS
JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(),
JOptionPane.showMessageDialog(null, NbBundle.getMessage(EventsRepository.class,
"EventsRepository.msgdlg.problem.text"));
} catch (Exception ex) {
LOGGER.log(Level.WARNING, "Unexpected exception while populating database.", ex); // NON-NLS
JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(),
JOptionPane.showMessageDialog(null, NbBundle.getMessage(EventsRepository.class,
"EventsRepository.msgdlg.problem.text"));
}
r.run(); //execute post db population operation
@ -383,7 +383,7 @@ public class EventsRepository {
final int numArtifacts = blackboardArtifacts.size();
process(Arrays.asList(new ProgressWindow.ProgressUpdate(0, numArtifacts,
NbBundle.getMessage(this.getClass(),
NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.populatingXevents",
type.toString()), "")));
@ -403,7 +403,7 @@ public class EventsRepository {
i++;
process(Arrays.asList(new ProgressWindow.ProgressUpdate(i, numArtifacts,
NbBundle.getMessage(this.getClass(),
NbBundle.getMessage(EventsRepository.class,
"EventsRepository.progressWindow.populatingXevents",
type.toString()), "")));
}