Initial commit for new warning label

This commit is contained in:
U-BASIS\dsmyda 2019-06-07 14:39:35 -04:00
parent 944208ae7f
commit 70f0cfa42b
6 changed files with 73 additions and 20 deletions

View File

@ -120,4 +120,12 @@ public final class TextTranslationService {
public boolean hasProvider() { public boolean hasProvider() {
return selectedTranslator.isPresent(); return selectedTranslator.isPresent();
} }
/**
*
* @return
*/
public int getMaxPayloadSize() {
return selectedTranslator.get().getMaxPayloadSize();
}
} }

View File

@ -5,3 +5,4 @@ TranslationContentPanel.ocrLabel.text=OCR:
TranslationOptionsPanel.translationServiceLabel.text=Text translator: TranslationOptionsPanel.translationServiceLabel.text=Text translator:
TranslationOptionsPanelController.moduleErr=Module Error TranslationOptionsPanelController.moduleErr=Module Error
TranslationOptionsPanelController.moduleErr.msg=A module caused an error listening to TranslationSettingsPanelController updates. See log to determine which module. Some data could be incomplete. TranslationOptionsPanelController.moduleErr.msg=A module caused an error listening to TranslationSettingsPanelController updates. See log to determine which module. Some data could be incomplete.
TranslationContentPanel.warningLabel.text=

View File

@ -12,6 +12,7 @@ TranslatedContentViewer.noServiceProvider=Machine Translation software was not f
TranslatedContentViewer.textAlreadyIndexed=Please view the original text in the Indexed Text viewer. TranslatedContentViewer.textAlreadyIndexed=Please view the original text in the Indexed Text viewer.
TranslatedContentViewer.translatingText=Translating text, please wait... TranslatedContentViewer.translatingText=Translating text, please wait...
TranslatedContentViewer.translationException=Error encountered while attempting translation. TranslatedContentViewer.translationException=Error encountered while attempting translation.
TranslatedTextViewer.maxPayloadSize=Up to the first %dKB of text will be translated
TranslatedTextViewer.title=Translation TranslatedTextViewer.title=Translation
TranslatedTextViewer.toolTip=Displays translated file text. TranslatedTextViewer.toolTip=Displays translated file text.
TranslationContentPanel.autoDetectOCR=Autodetect language TranslationContentPanel.autoDetectOCR=Autodetect language
@ -24,3 +25,4 @@ TranslationOptionsPanel.translationDisabled.text=Translation disabled
TranslationOptionsPanel.translationServiceLabel.text=Text translator: TranslationOptionsPanel.translationServiceLabel.text=Text translator:
TranslationOptionsPanelController.moduleErr=Module Error TranslationOptionsPanelController.moduleErr=Module Error
TranslationOptionsPanelController.moduleErr.msg=A module caused an error listening to TranslationSettingsPanelController updates. See log to determine which module. Some data could be incomplete. TranslationOptionsPanelController.moduleErr.msg=A module caused an error listening to TranslationSettingsPanelController updates. See log to determine which module. Some data could be incomplete.
TranslationContentPanel.warningLabel.text=

View File

@ -77,6 +77,9 @@ public final class TranslatedTextViewer implements TextViewer {
= new ThreadFactoryBuilder().setNameFormat("translation-content-viewer-%d").build(); = new ThreadFactoryBuilder().setNameFormat("translation-content-viewer-%d").build();
private final ExecutorService executorService = Executors.newSingleThreadExecutor(translationThreadFactory); private final ExecutorService executorService = Executors.newSingleThreadExecutor(translationThreadFactory);
@NbBundle.Messages({
"TranslatedTextViewer.maxPayloadSize=Up to the first %dKB of text will be translated"
})
@Override @Override
public void setNode(final Node node) { public void setNode(final Node node) {
this.node = node; this.node = node;
@ -92,6 +95,9 @@ public final class TranslatedTextViewer implements TextViewer {
panel.addLanguagePackNames(INSTALLED_LANGUAGE_PACKS); panel.addLanguagePackNames(INSTALLED_LANGUAGE_PACKS);
} }
} }
int payloadMaxInKB = TextTranslationService.getInstance().getMaxPayloadSize() / 1000;
panel.setWarningLabelMsg(String.format(Bundle.TranslatedTextViewer_maxPayloadSize(), payloadMaxInKB));
//Force a background task. //Force a background task.
displayDropDownListener.actionPerformed(null); displayDropDownListener.actionPerformed(null);

View File

@ -16,7 +16,7 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="1" pref="628" max="32767" attributes="0"/> <Component id="jPanel1" alignment="1" pref="872" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -47,7 +47,9 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace pref="204" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="warningLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="422" max="32767" attributes="0"/>
<Component id="ShowLabel" min="-2" max="-2" attributes="0"/> <Component id="ShowLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="displayTextComboBox" min="-2" pref="150" max="-2" attributes="0"/> <Component id="displayTextComboBox" min="-2" pref="150" max="-2" attributes="0"/>
@ -70,17 +72,25 @@
</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="1" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/> <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="1" groupAlignment="3" attributes="0"> <Group type="102" attributes="0">
<Component id="displayTextComboBox" alignment="3" pref="26" max="32767" attributes="0"/> <Component id="warningLabel" max="32767" attributes="0"/>
<Component id="ShowLabel" alignment="3" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="ocrLabel" alignment="3" max="32767" attributes="0"/> </Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="displayTextComboBox" alignment="3" pref="26" max="32767" attributes="0"/>
<Component id="ShowLabel" alignment="3" max="32767" attributes="0"/>
<Component id="ocrLabel" alignment="3" max="32767" attributes="0"/>
</Group>
<Component id="ocrDropdown" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
</Group> </Group>
<Component id="ocrDropdown" alignment="1" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
@ -150,6 +160,16 @@
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="warningLabel">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/sleuthkit/autopsy/images/warning16.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/texttranslation/ui/Bundle.properties" key="TranslationContentPanel.warningLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> <Container class="javax.swing.JScrollPane" name="jScrollPane1">

View File

@ -87,6 +87,10 @@ public class TranslationContentPanel extends javax.swing.JPanel {
dropDown.removeActionListener(listener); dropDown.removeActionListener(listener);
} }
} }
void setWarningLabelMsg(String msg) {
warningLabel.setText(msg);
}
@NbBundle.Messages({"TranslationContentPanel.autoDetectOCR=Autodetect language"}) @NbBundle.Messages({"TranslationContentPanel.autoDetectOCR=Autodetect language"})
final void reset() { final void reset() {
@ -280,6 +284,7 @@ public class TranslationContentPanel extends javax.swing.JPanel {
displayTextComboBox = new javax.swing.JComboBox<>(); displayTextComboBox = new javax.swing.JComboBox<>();
ocrDropdown = new javax.swing.JComboBox<>(); ocrDropdown = new javax.swing.JComboBox<>();
ocrLabel = new javax.swing.JLabel(); ocrLabel = new javax.swing.JLabel();
warningLabel = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
displayTextArea = new javax.swing.JTextArea(); displayTextArea = new javax.swing.JTextArea();
@ -301,12 +306,17 @@ public class TranslationContentPanel extends javax.swing.JPanel {
org.openide.awt.Mnemonics.setLocalizedText(ocrLabel, org.openide.util.NbBundle.getMessage(TranslationContentPanel.class, "TranslationContentPanel.ocrLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(ocrLabel, org.openide.util.NbBundle.getMessage(TranslationContentPanel.class, "TranslationContentPanel.ocrLabel.text")); // NOI18N
ocrLabel.setEnabled(false); ocrLabel.setEnabled(false);
warningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/warning16.png"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(TranslationContentPanel.class, "TranslationContentPanel.warningLabel.text")); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(204, Short.MAX_VALUE) .addContainerGap()
.addComponent(warningLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 422, Short.MAX_VALUE)
.addComponent(ShowLabel) .addComponent(ShowLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(displayTextComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(displayTextComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -325,15 +335,20 @@ public class TranslationContentPanel extends javax.swing.JPanel {
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addGap(9, 9, 9) .addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(displayTextComboBox, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) .addComponent(warningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ShowLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())
.addComponent(ocrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(ocrDropdown)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGap(7, 7, 7)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(displayTextComboBox, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
.addComponent(ShowLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ocrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(ocrDropdown))
.addGap(7, 7, 7))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
@ -355,7 +370,7 @@ public class TranslationContentPanel extends javax.swing.JPanel {
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(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 872, Short.MAX_VALUE)
.addComponent(jScrollPane1) .addComponent(jScrollPane1)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -377,5 +392,6 @@ public class TranslationContentPanel extends javax.swing.JPanel {
private javax.swing.JSeparator jSeparator2; private javax.swing.JSeparator jSeparator2;
private javax.swing.JComboBox<String> ocrDropdown; private javax.swing.JComboBox<String> ocrDropdown;
private javax.swing.JLabel ocrLabel; private javax.swing.JLabel ocrLabel;
private javax.swing.JLabel warningLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }