Skip to content
Permalink
Browse files

Continue work on localization UI

  • Loading branch information...
LadyCailin committed Aug 6, 2019
1 parent 44351ec commit 7010d0123f6a3ebf93f6cd9b8d4e085d60cf5a2c
@@ -17,6 +17,8 @@

<!-- It's too difficult to manage checkstyle for half generated files, so just exclude them. -->
<suppress checks=".*" files="com[\\/]laytonsmith[\\/]tools[\\/]docgen[\\/]localization[\\/]LocalizationUI.java$"/>
<suppress checks=".*" files="com[\\/]laytonsmith[\\/]tools[\\/]docgen[\\/]localization[\\/]FindDialog.java$"/>
<suppress checks=".*" files="com[\\/]laytonsmith[\\/]tools[\\/]docgen[\\/]localization[\\/]AzureKeyInputDialog.java$"/>


</suppressions>
@@ -781,7 +781,7 @@
<processor>com.laytonsmith.core.extensions.ExtensionAnnotationProcessor</processor>
<processor>com.laytonsmith.core.MObjectAnnotationProcessor</processor>
</processors>
<outputDiagnostics>false</outputDiagnostics>
<outputDiagnostics>true</outputDiagnostics>
</configuration>
</plugin>

@@ -19,8 +19,6 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
@@ -60,12 +58,13 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
try {
c = getClassFromName(className);
} catch (ClassNotFoundException ex) {
Logger.getLogger(CheckOverrides.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace(System.err);
}
if(c != null) {
if(!c.isInterface()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
"Only interfaces may be annotated with " + MustUseOverride.class.getName());
String msg = "Only interfaces may be annotated with " + MustUseOverride.class.getName();
System.err.println(msg);
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
}
INTERFACES_WITH_MUST_USE_OVERRIDE.add(c);
}
@@ -76,7 +75,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
try {
c = getClassFromName(className);
} catch (ClassNotFoundException ex) {
Logger.getLogger(CheckOverrides.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace(System.err);
}

if(c != null && !c.isInterface()) {
@@ -126,7 +125,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
if(!isTemplate || !found) {
//Oh, there aren't any. Well, I don't know why this would happen.
Logger.getLogger(CheckOverrides.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace(System.err);
}
try {
argTypes[i] = Class.forName(args[i]);
@@ -169,7 +168,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
}
} catch (NoSuchMethodException | SecurityException ex) {
Logger.getLogger(CheckOverrides.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace(System.err);
}
}
if(methods.get(c).isEmpty()) {
@@ -240,6 +239,7 @@ public String toString(Class<?> item) {
.append(" with @Override to continue the build process.")
.append(StringUtils.NL)
.append(StringUtils.Join(stringMethodsInError, StringUtils.NL));
System.err.println(b.toString());
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, b.toString());
} else {
StreamUtils.GetSystemOut().println("No @Override annotations were found to be missing.");
@@ -90,7 +90,7 @@
private static final ArgumentParser DOC_EXPORT_MODE;
private static final ArgumentParser PROFILER_SUMMARY_MODE;
private static final ArgumentParser RSA_KEY_GEN_MODE;
private static final ArgumentParser PM_VIEWER_MODE;
private static final ArgumentParser PN_VIEWER_MODE;
private static final ArgumentParser CORE_FUNCTIONS_MODE;
private static final ArgumentParser UI_MODE;
private static final ArgumentParser EXTENSION_BUILDER_MODE;
@@ -268,7 +268,7 @@
.setName('l', "label")
.setArgType(ArgumentBuilder.BuilderTypeNonFlag.STRING));
suite.addMode("key-gen", RSA_KEY_GEN_MODE);
PM_VIEWER_MODE = ArgumentParser.GetParser()
PN_VIEWER_MODE = ArgumentParser.GetParser()
.addDescription("Launches the Persistence Network viewer. This is a GUI tool that can help you"
+ " visualize your databases.")
.addArgument(new ArgumentBuilder()
@@ -290,7 +290,7 @@
.setOptional()
.setName("password")
.setArgType(ArgumentBuilder.BuilderTypeNonFlag.STRING));
suite.addMode("pn-viewer", PM_VIEWER_MODE);
suite.addMode("pn-viewer", PN_VIEWER_MODE);
CORE_FUNCTIONS_MODE = ArgumentParser.GetParser()
.addDescription("Prints a list of functions tagged with the @core annotation, then exits.");
suite.addMode("core-functions", CORE_FUNCTIONS_MODE);
@@ -648,7 +648,7 @@ public static void main(String[] args) throws Exception {
FileUtil.write(enc.getPrivateKey(), privOutputFile);
FileUtil.write(enc.getPublicKey(), pubOutputFile);
System.exit(0);
} else if(mode == PM_VIEWER_MODE) {
} else if(mode == PN_VIEWER_MODE) {
if(parsedArgs.isFlagSet("server")) {
if(parsedArgs.getNumberArgument("port") == null) {
StreamUtils.GetSystemErr().println("When running as a server, port is required.");
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="endpointField" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="storeKeyCheckbox" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="250" max="32767" attributes="0"/>
</Group>
<Component id="keyField" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="endpointField" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="keyField" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Component id="storeKeyCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Input Azure Cognitive Services Key"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="storeKeyCheckbox">
<Properties>
<Property name="text" type="java.lang.String" value="Store Key (key is stored locally in plain text!)"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Input Azure Cognitive Services Endpoint"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="endpointField">
</Component>
<Component class="javax.swing.JPasswordField" name="keyField">
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,155 @@
package com.laytonsmith.tools.docgen.localization;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
*
*/
public class AzureKeyInputDialog extends javax.swing.JDialog {


public static interface AzureKeyInputDialogCallback {
void getResults(String endpoint, String key, boolean storeValue);
}

/**
* Creates new form AzureKeyInputDialog
* @param parent The parent frame
* @param endpoint The existing endpoint, if any
* @param callback The callback is called with the key and store value setting if the user clicks ok
*/
public AzureKeyInputDialog(java.awt.Frame parent, String endpoint, AzureKeyInputDialogCallback callback) {
super(parent, true);
if(endpoint == null) {
endpoint = "";
}
initComponents();
endpointField.setText(endpoint);
keyField.setText("");
okButton.setEnabled(false);
storeKeyCheckbox.setSelected(false);
cancelButton.addActionListener((ae) -> {
AzureKeyInputDialog.this.setVisible(false);
this.dispose();
});
okButton.addActionListener((ae) -> {
callback.getResults(endpointField.getText(), new String(keyField.getPassword()),
storeKeyCheckbox.isSelected());
setVisible(false);
this.dispose();
});
endpointField.addKeyListener(validationListener);
keyField.addKeyListener(validationListener);
}

KeyListener validationListener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
validateInput();
}

@Override
public void keyPressed(KeyEvent e) {
validateInput();
}

@Override
public void keyReleased(KeyEvent e) {
validateInput();
}
};

private void validateInput() {
if(endpointField.getText().trim().isEmpty() || keyField.getPassword().length == 0) {
okButton.setEnabled(false);
} else {
okButton.setEnabled(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 regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
storeKeyCheckbox = new javax.swing.JCheckBox();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
endpointField = new javax.swing.JTextField();
keyField = new javax.swing.JPasswordField();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setText("Input Azure Cognitive Services Key");

storeKeyCheckbox.setText("Store Key (key is stored locally in plain text!)");

okButton.setText("Ok");

cancelButton.setText("Cancel");

jLabel2.setText("Input Azure Cognitive Services Endpoint");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(endpointField)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(storeKeyCheckbox)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addComponent(jLabel2))
.addGap(0, 250, Short.MAX_VALUE))
.addComponent(keyField))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(endpointField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(keyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(8, 8, 8)
.addComponent(storeKeyCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(okButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JTextField endpointField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPasswordField keyField;
private javax.swing.JButton okButton;
private javax.swing.JCheckBox storeKeyCheckbox;
// End of variables declaration//GEN-END:variables
}

0 comments on commit 7010d01

Please sign in to comment.
You can’t perform that action at this time.