|
@@ -19,17 +19,14 @@ package de.nplusc.izc.tools.baseTools;
|
|
|
|
|
|
import de.nplusc.izc.tools.IOtools.FileTK;
|
|
|
import de.nplusc.izc.tools.IOtools.PrintStreamCapturer;
|
|
|
+
|
|
|
import java.awt.Dimension;
|
|
|
import java.awt.GraphicsEnvironment;
|
|
|
import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.security.MessageDigest;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Scanner;
|
|
|
import java.util.prefs.Preferences;
|
|
|
import javax.swing.*;
|
|
|
//import net.rubygrapefruit.platform.Native;
|
|
@@ -42,120 +39,122 @@ import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author LH
|
|
|
*/
|
|
|
- @SuppressWarnings( "deprecation" )
|
|
|
-public class Tools
|
|
|
-{
|
|
|
+@SuppressWarnings("deprecation")
|
|
|
+public class Tools {
|
|
|
private static final Logger l = LogManager.getLogger();
|
|
|
public static boolean execCrashed = false;
|
|
|
private static boolean ContState;
|
|
|
private static JDialog d;
|
|
|
- private static boolean hl=false;
|
|
|
+ private static boolean hl = false;
|
|
|
//private boolean ProcessReturn;
|
|
|
private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
|
private static int logNumber;
|
|
|
|
|
|
- protected Tools()
|
|
|
- {
|
|
|
+ protected Tools() {
|
|
|
//disabled Constructor
|
|
|
}
|
|
|
- static
|
|
|
- {
|
|
|
- GraphicsEnvironment ge =
|
|
|
- GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
|
+
|
|
|
+ static {
|
|
|
+ GraphicsEnvironment ge =
|
|
|
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
|
boolean hl = ge.isHeadless();
|
|
|
- if(!hl){
|
|
|
- //d = new JDialog();
|
|
|
+ if (!hl) {
|
|
|
+ //d = new JDialog();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Method to pad the left of a Sting with given character
|
|
|
- * @param count Destination amount of data
|
|
|
- * @param base String to pad up
|
|
|
+ *
|
|
|
+ * @param count Destination amount of data
|
|
|
+ * @param base String to pad up
|
|
|
* @param filler Padding data
|
|
|
* @return Padded String
|
|
|
*/
|
|
|
- public static String padLeft(final int count, final String base, final char filler)
|
|
|
- {
|
|
|
- if (base == null)
|
|
|
- {
|
|
|
+ public static String padLeft(final int count, final String base, final char filler) {
|
|
|
+ if (base == null) {
|
|
|
throw new NullPointerException();
|
|
|
}
|
|
|
- if (base.length() >= count)
|
|
|
- {
|
|
|
+ if (base.length() >= count) {
|
|
|
return base;
|
|
|
}
|
|
|
char[] prefix = new char[count - base.length()];
|
|
|
Arrays.fill(prefix, filler);
|
|
|
return new StringBuilder(count).append(prefix).append(base).toString();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Method rename and shorthand for Thread.sleep()
|
|
|
+ *
|
|
|
* @param time Time to wait in ms
|
|
|
*/
|
|
|
- public static void wait(int time)
|
|
|
- {
|
|
|
+ public static void wait(int time) {
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
Thread.sleep(time);
|
|
|
- }
|
|
|
- catch (InterruptedException ex)
|
|
|
- {
|
|
|
+ } catch (InterruptedException ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
|
|
+ public static String bytesToHex(byte[] bytes) {
|
|
|
+ char[] hexChars = new char[bytes.length * 2];
|
|
|
+ for (int j = 0; j < bytes.length; j++) {
|
|
|
+ int v = bytes[j] & 0xFF;
|
|
|
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
|
|
|
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
|
|
|
+ }
|
|
|
+
|
|
|
+ String hexxit = new String(hexChars).toLowerCase(Locale.ROOT);
|
|
|
+ //hexxit = hexxit.replaceAll("^0+", "");
|
|
|
+ return hexxit;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* SHA-Hashes a String
|
|
|
+ *
|
|
|
* @param s String to hash
|
|
|
* @return Hashed String
|
|
|
*/
|
|
|
- public static String getSHAString(String s)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ public static String getSHAString(String s) {
|
|
|
+ try {
|
|
|
MessageDigest sha = MessageDigest.getInstance("SHA");
|
|
|
@SuppressWarnings("StringBufferMayBeStringBuilder")
|
|
|
StringBuffer t = new StringBuffer();
|
|
|
byte[] digest = sha.digest(s.getBytes());
|
|
|
- for (byte b : digest)
|
|
|
- {
|
|
|
+ for (byte b : digest) {
|
|
|
l.trace(String.format("%02x", b));
|
|
|
int val = ((int) b) & 0xff;
|
|
|
- if (val < 16)
|
|
|
- {
|
|
|
+ if (val < 16) {
|
|
|
t.append("0");
|
|
|
}
|
|
|
t.append(Integer.toHexString(val));
|
|
|
}
|
|
|
return t.toString();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
+ } catch (Exception ex) {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Integerizes a String
|
|
|
+ *
|
|
|
* @param ip String to integerize
|
|
|
* @return Array of Integers where each int is a Character of the string
|
|
|
*/
|
|
|
- public static int[] lettersToInt(String ip)
|
|
|
- {
|
|
|
+ public static int[] lettersToInt(String ip) {
|
|
|
ip = ip.toLowerCase();
|
|
|
char[] it = ip.toCharArray();
|
|
|
int[] ri = new int[it.length];
|
|
|
- for (int i = 0; i < ri.length; i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < ri.length; i++) {
|
|
|
ri[i] = (int) it[i];
|
|
|
}
|
|
|
return ri;
|
|
@@ -163,20 +162,19 @@ public class Tools
|
|
|
|
|
|
/**
|
|
|
* Sum of the Elements of the Array
|
|
|
+ *
|
|
|
* @param i Integer-array to sumup
|
|
|
* @return Sum of the elements
|
|
|
*/
|
|
|
- public static int addIntsTogether(int[] i)
|
|
|
- {
|
|
|
+ public static int addIntsTogether(int[] i) {
|
|
|
int t = 1;
|
|
|
- for (int X : i)
|
|
|
- {
|
|
|
+ for (int X : i) {
|
|
|
t *= X;
|
|
|
}
|
|
|
return t;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
@Deprecated
|
|
|
/**
|
|
|
* HACK!!!
|
|
@@ -184,31 +182,24 @@ public class Tools
|
|
|
* @param ints unknown
|
|
|
* @return unknown
|
|
|
*/
|
|
|
- public static int addIntsTogether(HashMap<String, String> m, boolean ints)
|
|
|
- {
|
|
|
+ public static int addIntsTogether(HashMap<String, String> m, boolean ints) {
|
|
|
//boolean ints = !noints;
|
|
|
String[] mk;
|
|
|
Object[] mk2 = m.keySet().toArray();
|
|
|
mk = new String[mk2.length];
|
|
|
- for (int i = 0; i < mk.length; i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < mk.length; i++) {
|
|
|
String s = "";
|
|
|
//s.toString();
|
|
|
mk[i] = mk2[i].toString();
|
|
|
}
|
|
|
int t = 1;
|
|
|
- for (String s : mk)
|
|
|
- {
|
|
|
- if (ints == true)
|
|
|
- {
|
|
|
+ for (String s : mk) {
|
|
|
+ if (ints == true) {
|
|
|
t *= Integer.valueOf(m.get(s));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
int t2 = 0;
|
|
|
int[] itmp = lettersToInt(m.get(s));
|
|
|
- for (int i : itmp)
|
|
|
- {
|
|
|
+ for (int i : itmp) {
|
|
|
t2 += i;
|
|
|
}
|
|
|
t += t2;
|
|
@@ -224,66 +215,48 @@ public class Tools
|
|
|
* @param s2 String 2
|
|
|
* @return the merged Strings
|
|
|
*/
|
|
|
- public static String stringAdd(String s1, String s2)
|
|
|
- {
|
|
|
+ public static String stringAdd(String s1, String s2) {
|
|
|
char[] ca1 = s1.toLowerCase().toCharArray();
|
|
|
char[] ca2 = s2.toLowerCase().toCharArray();
|
|
|
int[] ci1 = new int[ca1.length];
|
|
|
int[] ci2 = new int[ca2.length];
|
|
|
|
|
|
String t;
|
|
|
- for (int i = 0; i < ca1.length; i++)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ for (int i = 0; i < ca1.length; i++) {
|
|
|
+ try {
|
|
|
ci1[i] = Integer.valueOf(Character.toString(ca1[i]));
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
+ } catch (Exception ex) {
|
|
|
t = Character.toString(ca1[i]);
|
|
|
ci1[i] = ALPHABET.indexOf(t) + 1;
|
|
|
}
|
|
|
}
|
|
|
- for (int i = 0; i < ca2.length; i++)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ for (int i = 0; i < ca2.length; i++) {
|
|
|
+ try {
|
|
|
ci2[i] = Integer.valueOf(Character.toString(ca2[i]));
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
+ } catch (Exception ex) {
|
|
|
t = Character.toString(ca2[i]);
|
|
|
ci2[i] = ALPHABET.indexOf(t) + 1;
|
|
|
}
|
|
|
}
|
|
|
int l = ci1.length;
|
|
|
- if (ci1.length < ci2.length)
|
|
|
- {
|
|
|
+ if (ci1.length < ci2.length) {
|
|
|
l = ci2.length;
|
|
|
}
|
|
|
int[] op = new int[l];
|
|
|
int i1, i2, i3;
|
|
|
- for (int i = 0; i < l; i++)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ for (int i = 0; i < l; i++) {
|
|
|
+ try {
|
|
|
i1 = ci1[i];
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
+ } catch (Exception ex) {
|
|
|
i1 = 0;
|
|
|
}
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
i2 = ci2[i];
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
+ } catch (Exception ex) {
|
|
|
i2 = 0;
|
|
|
}
|
|
|
i3 = i1 + i1;
|
|
|
- if (i3 > 26)
|
|
|
- {
|
|
|
+ if (i3 > 26) {
|
|
|
i3 -= 26;
|
|
|
}
|
|
|
op[i] = i3;
|
|
@@ -291,30 +264,27 @@ public class Tools
|
|
|
|
|
|
return backString(op);
|
|
|
}
|
|
|
+
|
|
|
@Deprecated
|
|
|
- public static String backString(int[] ia)
|
|
|
- {
|
|
|
+ public static String backString(int[] ia) {
|
|
|
int l = ia.length, i1;
|
|
|
String[] r1 = new String[l];
|
|
|
String rl = "";
|
|
|
- for (int i = 0; i < l; i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < l; i++) {
|
|
|
i1 = ia[i] - 1;
|
|
|
- if (i1 == -1)
|
|
|
- {
|
|
|
+ if (i1 == -1) {
|
|
|
i1++;
|
|
|
}
|
|
|
r1[i] = Character.toString(ALPHABET.charAt(i1));
|
|
|
}
|
|
|
- for (String s : r1)
|
|
|
- {
|
|
|
+ for (String s : r1) {
|
|
|
rl += s;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return rl;
|
|
|
}
|
|
|
+
|
|
|
@Deprecated
|
|
|
public static String stringFold(String s, int l, int rec)//halbiert Strings und addiert die Hälften
|
|
|
{
|
|
@@ -322,15 +292,13 @@ public class Tools
|
|
|
String sh1, sh2, so1;
|
|
|
//int l2=l1+1-1;//Neuen Wet erzeugen!!
|
|
|
//l2=l1*2
|
|
|
- if ((l1 * 2) == s.length() - 1)
|
|
|
- {
|
|
|
+ if ((l1 * 2) == s.length() - 1) {
|
|
|
l1++;
|
|
|
}
|
|
|
sh1 = s.substring(0, l1++);
|
|
|
sh2 = s.substring(l1++);
|
|
|
so1 = stringAdd(sh1, sh2);
|
|
|
- if (so1.length() > l && rec > 0)
|
|
|
- {
|
|
|
+ if (so1.length() > l && rec > 0) {
|
|
|
so1 = stringFold(so1, l, rec--);
|
|
|
}
|
|
|
|
|
@@ -338,40 +306,38 @@ public class Tools
|
|
|
}
|
|
|
|
|
|
@Deprecated
|
|
|
- public static String stringFold(String s, int l)
|
|
|
- {
|
|
|
+ public static String stringFold(String s, int l) {
|
|
|
return stringFold(s, l, 30);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 2-Elemente-Meckermeldung
|
|
|
- * @param mode ignored
|
|
|
+ *
|
|
|
+ * @param mode ignored
|
|
|
* @param MSGLine1 Zeile 1 der Meldung
|
|
|
* @param MSGLine2 ZEile 2 der Meldung
|
|
|
* @return true if left button got pressed, false on right one
|
|
|
*/
|
|
|
- public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2)
|
|
|
- {
|
|
|
+ public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2) {
|
|
|
return dlg(mode, MSGLine1, MSGLine2, "Fortfahren", "Abbrechen");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 2-Elemente-Meckermeldung
|
|
|
- * @param mode ignored
|
|
|
+ *
|
|
|
+ * @param mode ignored
|
|
|
* @param MSGLine1 Zeile 1 der Meldung
|
|
|
* @param MSGLine2 ZEile 2 der Meldung
|
|
|
- * @param btnLeft MEssage of left button
|
|
|
+ * @param btnLeft MEssage of left button
|
|
|
* @param btnRight MEssage of Right button
|
|
|
* @return true if left button got pressed, false on right one
|
|
|
*/
|
|
|
- public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2, String btnLeft, String btnRight)
|
|
|
- {
|
|
|
- if(hl)
|
|
|
- {
|
|
|
+ public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2, String btnLeft, String btnRight) {
|
|
|
+ if (hl) {
|
|
|
return false;
|
|
|
}
|
|
|
- d=new JDialog();
|
|
|
+ d = new JDialog();
|
|
|
JPanel p = new JPanel();
|
|
|
javax.swing.JButton btnYes = new javax.swing.JButton();
|
|
|
javax.swing.JButton btnNo = new javax.swing.JButton();
|
|
@@ -379,27 +345,21 @@ public class Tools
|
|
|
JLabel lblMSG2 = new JLabel();
|
|
|
|
|
|
|
|
|
-
|
|
|
d.setModal(mode);
|
|
|
mode = true;
|
|
|
- if (mode == true)
|
|
|
- {
|
|
|
+ if (mode == true) {
|
|
|
//Ausgeblendet da nur Fenster-Layout
|
|
|
// <editor-fold defaultstate="collapsed" desc="Layout-Code">
|
|
|
btnNo.setText(btnRight);
|
|
|
- btnNo.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnNo.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
btnNoActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
btnYes.setText(btnLeft);
|
|
|
- btnYes.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnYes.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
btnYesActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
@@ -412,30 +372,30 @@ public class Tools
|
|
|
p.setLayout(layout);
|
|
|
layout.setHorizontalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGap(36, 36, 36)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addComponent(btnYes)
|
|
|
- .addGap(18, 18, 18)
|
|
|
- .addComponent(btnNo))
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGap(40, 40, 40)
|
|
|
- .addComponent(lblMSG2)))
|
|
|
- .addContainerGap(63, Short.MAX_VALUE)));
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(36, 36, 36)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(btnYes)
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addComponent(btnNo))
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(40, 40, 40)
|
|
|
+ .addComponent(lblMSG2)))
|
|
|
+ .addContainerGap(63, Short.MAX_VALUE)));
|
|
|
layout.setVerticalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addContainerGap()
|
|
|
- .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addGap(18, 18, 18)
|
|
|
- .addComponent(lblMSG2)
|
|
|
- .addGap(18, 18, 18)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
- .addComponent(btnYes)
|
|
|
- .addComponent(btnNo))
|
|
|
- .addContainerGap(71, Short.MAX_VALUE)));
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addComponent(lblMSG2)
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(btnYes)
|
|
|
+ .addComponent(btnNo))
|
|
|
+ .addContainerGap(71, Short.MAX_VALUE)));
|
|
|
// </editor-fold>
|
|
|
|
|
|
//p.add(btnYes);
|
|
@@ -447,9 +407,7 @@ public class Tools
|
|
|
|
|
|
//btnNo.setText(btnRight);
|
|
|
//btnYes.setText(btnLeft);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
//TODO working.dialog
|
|
|
return true;
|
|
|
}
|
|
@@ -459,153 +417,126 @@ public class Tools
|
|
|
|
|
|
|
|
|
//</editor-fold>
|
|
|
+
|
|
|
/**
|
|
|
* COmmand run wrapper
|
|
|
+ *
|
|
|
* @param runnable Command elements
|
|
|
*/
|
|
|
- public static void runSingleCmd(String... runnable)
|
|
|
- {
|
|
|
+ public static void runSingleCmd(String... runnable) {
|
|
|
runSingleCmd(true, runnable);
|
|
|
}
|
|
|
|
|
|
- public static void runSingleCmd(boolean logg, String... runnable)
|
|
|
- {
|
|
|
+ public static void runSingleCmd(boolean logg, String... runnable) {
|
|
|
runSingleCmd(true, false, runnable);
|
|
|
}
|
|
|
|
|
|
- public static void runSingleCmd(boolean logg, boolean legacy, String... runnable)
|
|
|
- {
|
|
|
+ public static void runSingleCmd(boolean logg, boolean legacy, String... runnable) {
|
|
|
runSingleCmd(logg, legacy, false, runnable);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, String... runnable)
|
|
|
- {
|
|
|
+ public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, String... runnable) {
|
|
|
return runSingleCmd(logg, legacy, sret, null, runnable);
|
|
|
}
|
|
|
|
|
|
- public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,JTextArea tx, String... runnable)
|
|
|
- {
|
|
|
- return runSingleCmd(logg, legacy, sret, false, tx, runnable);
|
|
|
+ public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, JTextArea tx, String... runnable) {
|
|
|
+ return runSingleCmd(logg, legacy, sret, false, tx, runnable);
|
|
|
}
|
|
|
- public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, String... runnable)
|
|
|
- {
|
|
|
+
|
|
|
+ public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, boolean asArray, JTextArea tx, String... runnable) {
|
|
|
return runSingleCmd(logg, legacy, sret, asArray, tx, null, runnable);
|
|
|
}
|
|
|
- public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, final PrintStream pw,String... runnable)
|
|
|
- {
|
|
|
- return runSingleCmd(logg, legacy, sret, asArray, tx, null, null,false,runnable);
|
|
|
+
|
|
|
+ public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, boolean asArray, JTextArea tx, final PrintStream pw, String... runnable) {
|
|
|
+ return runSingleCmd(logg, legacy, sret, asArray, tx, null, null, false, runnable);
|
|
|
}
|
|
|
+
|
|
|
private static Process p;
|
|
|
- public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,final JTextArea tx, final PrintStream pw, String workdir,boolean useWD,String... runnable)
|
|
|
- {
|
|
|
+
|
|
|
+ public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, boolean asArray, final JTextArea tx, final PrintStream pw, String workdir, boolean useWD, String... runnable) {
|
|
|
execCrashed = false;
|
|
|
- String cret = "";
|
|
|
- File wd=null;
|
|
|
- if(workdir!=null&&useWD)
|
|
|
- {
|
|
|
- wd=new File(workdir);
|
|
|
- if(!wd.isDirectory())
|
|
|
- wd=null;
|
|
|
- }
|
|
|
+ String cret = "";
|
|
|
+ File wd = null;
|
|
|
+ if (workdir != null && useWD) {
|
|
|
+ wd = new File(workdir);
|
|
|
+ if (!wd.isDirectory())
|
|
|
+ wd = null;
|
|
|
+ }
|
|
|
String cmd = "";
|
|
|
- for (String string : runnable)
|
|
|
- {
|
|
|
+ for (String string : runnable) {
|
|
|
cmd += string + " ";
|
|
|
cmd = cmd.trim();
|
|
|
|
|
|
}//wird für ohne array verwended und bei mit array fürs debugging;
|
|
|
l.trace(cmd);
|
|
|
- try
|
|
|
- {
|
|
|
- ProcessBuilder p2=null;
|
|
|
- if(wd!=null)
|
|
|
- {
|
|
|
+ try {
|
|
|
+ ProcessBuilder p2 = null;
|
|
|
+ if (wd != null) {
|
|
|
p2 = new ProcessBuilder(runnable);
|
|
|
p2.directory(wd);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Executor e = null;
|
|
|
CommandLine c = null;
|
|
|
- if (!legacy)
|
|
|
- {
|
|
|
+ if (!legacy) {
|
|
|
c = new CommandLine("cmd.exe");
|
|
|
c.addArgument(cmd);
|
|
|
e = new DefaultExecutor();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(wd==null)
|
|
|
- {
|
|
|
+ } else {
|
|
|
+ if (wd == null) {
|
|
|
p = null;
|
|
|
- if(!asArray)
|
|
|
- p=Runtime.getRuntime().exec(cmd);
|
|
|
+ if (!asArray)
|
|
|
+ p = Runtime.getRuntime().exec(cmd);
|
|
|
else
|
|
|
- p=Runtime.getRuntime().exec(runnable);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- p=p2.start();
|
|
|
+ p = Runtime.getRuntime().exec(runnable);
|
|
|
+ } else {
|
|
|
+ p = p2.start();
|
|
|
}
|
|
|
- if(tx!=null)
|
|
|
- {
|
|
|
+ if (tx != null) {
|
|
|
new Thread(
|
|
|
- new Runnable()
|
|
|
- {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run()
|
|
|
- {
|
|
|
- Scanner scanner = new Scanner(p.getInputStream());
|
|
|
- Scanner scannerE = new Scanner(p.getErrorStream());
|
|
|
- while ((scanner.hasNextLine()||scannerE.hasNextLine()))
|
|
|
- {
|
|
|
- if(scanner.hasNextLine())
|
|
|
- {
|
|
|
- String l = scanner.nextLine();
|
|
|
- tx.append(l+"\n");
|
|
|
- if(pw!=null)
|
|
|
- pw.println(l);
|
|
|
- }
|
|
|
- if(scannerE.hasNextLine())
|
|
|
- {
|
|
|
- String l = scannerE.next();
|
|
|
- tx.append(l+"\n");
|
|
|
- if(pw!=null)
|
|
|
- pw.println(l);
|
|
|
+ new Runnable() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ Scanner scanner = new Scanner(p.getInputStream());
|
|
|
+ Scanner scannerE = new Scanner(p.getErrorStream());
|
|
|
+ while ((scanner.hasNextLine() || scannerE.hasNextLine())) {
|
|
|
+ if (scanner.hasNextLine()) {
|
|
|
+ String l = scanner.nextLine();
|
|
|
+ tx.append(l + "\n");
|
|
|
+ if (pw != null)
|
|
|
+ pw.println(l);
|
|
|
+ }
|
|
|
+ if (scannerE.hasNextLine()) {
|
|
|
+ String l = scannerE.next();
|
|
|
+ tx.append(l + "\n");
|
|
|
+ if (pw != null)
|
|
|
+ pw.println(l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ).start();
|
|
|
+ ).start();
|
|
|
}
|
|
|
- if (sret)
|
|
|
- {
|
|
|
+ if (sret) {
|
|
|
cret = new BufferedReader(new InputStreamReader(p.getInputStream())).readLine();
|
|
|
}
|
|
|
int rv = p.waitFor();
|
|
|
- if(rv>0)
|
|
|
- {
|
|
|
- execCrashed=true;
|
|
|
+ if (rv > 0) {
|
|
|
+ execCrashed = true;
|
|
|
}
|
|
|
}
|
|
|
l.trace(cmd);
|
|
|
- if (logg)
|
|
|
- {
|
|
|
+ if (logg) {
|
|
|
l.trace("Logg");
|
|
|
logNumber++;
|
|
|
}
|
|
|
- if (!legacy)
|
|
|
- {
|
|
|
+ if (!legacy) {
|
|
|
e.execute(c);
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- l.error("Error@"+cmd);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ l.error("Error@" + cmd);
|
|
|
l.error(ex.toString());
|
|
|
l.error(ex.getMessage());
|
|
|
//TODO:SetupError_Here
|
|
@@ -613,43 +544,41 @@ public class Tools
|
|
|
}
|
|
|
return cret;
|
|
|
}
|
|
|
- private static void btnYesActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+
|
|
|
+ private static void btnYesActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
ContState = true;
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
d = new JDialog();
|
|
|
}
|
|
|
|
|
|
- private static void btnNoActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ private static void btnNoActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
ContState = false;
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
d = new JDialog();
|
|
|
}
|
|
|
|
|
|
- public static void hideDialog()
|
|
|
- {
|
|
|
+ public static void hideDialog() {
|
|
|
d.setVisible(false);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static String getRelativePath(String absolutePath, String basePath)//Initializer für Hack!
|
|
|
+
|
|
|
+ public static String getRelativePath(String absolutePath, String basePath)//Initializer für Hack!
|
|
|
{
|
|
|
- return FileTK.getRelativePath(absolutePath, basePath);
|
|
|
+ return FileTK.getRelativePath(absolutePath, basePath);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Array shortening method
|
|
|
- * @param toTrunc SArray to remove
|
|
|
- * @param number Amount to remove
|
|
|
+ *
|
|
|
+ * @param toTrunc SArray to remove
|
|
|
+ * @param number Amount to remove
|
|
|
* @param fromBack True means remove from end, false means remove from start
|
|
|
* @return Shortened array
|
|
|
*/
|
|
|
@SuppressWarnings("ManualArrayToCollectionCopy")//Quick and Dirty Hack
|
|
|
- public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack)
|
|
|
- {
|
|
|
+ public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack) {
|
|
|
//number++;//fucked up error!
|
|
|
if (toTrunc.length - number < 1)//Error bei Zahlen <0
|
|
|
{
|
|
@@ -658,15 +587,11 @@ public class Tools
|
|
|
Object[] out = new Object[toTrunc.length - number];
|
|
|
if (fromBack == true)//Hinten weg
|
|
|
{
|
|
|
- for (int i = 0; i < toTrunc.length - number; i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < toTrunc.length - number; i++) {
|
|
|
out[i] = toTrunc[i];
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- { //Evil loop :P (linenumber)
|
|
|
- for (int i = 0; i > toTrunc.length - number; i++)
|
|
|
- {
|
|
|
+ } else { //Evil loop :P (linenumber)
|
|
|
+ for (int i = 0; i > toTrunc.length - number; i++) {
|
|
|
int j = i + number;
|
|
|
out[i] = toTrunc[j];
|
|
|
}
|
|
@@ -674,32 +599,29 @@ public class Tools
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* OPens a Input window for a line of text
|
|
|
+ *
|
|
|
* @param title Title of the window
|
|
|
- * @return
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public static String getInputString(String title)
|
|
|
- {
|
|
|
+ public static String getInputString(String title) {
|
|
|
return getInputString(title, false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* OPens a Input window for a line of text
|
|
|
- * @param title Title of the window
|
|
|
+ *
|
|
|
+ * @param title Title of the window
|
|
|
* @param txArea WHether to use a MUltiline input or a singleline inout
|
|
|
- * @return
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public static String getInputString(String title, boolean txArea)
|
|
|
- {
|
|
|
+ public static String getInputString(String title, boolean txArea) {
|
|
|
Object txfIP;//Hack!!!!
|
|
|
- if (txArea == true)
|
|
|
- {
|
|
|
+ if (txArea == true) {
|
|
|
txfIP = new JTextArea(20, 40);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
txfIP = new JTextField(30);
|
|
|
}
|
|
|
//passwordField.setEchoChar('#');
|
|
@@ -709,12 +631,9 @@ public class Tools
|
|
|
title,
|
|
|
JOptionPane.PLAIN_MESSAGE);
|
|
|
String ret = "";
|
|
|
- if (txArea == true)
|
|
|
- {
|
|
|
+ if (txArea == true) {
|
|
|
ret = ((JTextArea) txfIP).getText();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
ret = ((JTextField) txfIP).getText();
|
|
|
}
|
|
|
return ret;
|
|
@@ -722,49 +641,43 @@ public class Tools
|
|
|
|
|
|
/**
|
|
|
* Shorthand to write serialized data to a file
|
|
|
+ *
|
|
|
* @param o Object to dump
|
|
|
* @param p Destination file
|
|
|
*/
|
|
|
- public static void saveSerializedObject(Object[] o, String p)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ public static void saveSerializedObject(Object[] o, String p) {
|
|
|
+ try {
|
|
|
FileOutputStream fos = new FileOutputStream(p);
|
|
|
ObjectOutputStream os = new ObjectOutputStream(fos);
|
|
|
os.writeObject(o);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
//NOP
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Shorthand to load serialized data
|
|
|
+ *
|
|
|
* @param p Path to load from
|
|
|
* @return Array with the objects dumped
|
|
|
*/
|
|
|
- public static Object[] loadSerializedObject(String p)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ public static Object[] loadSerializedObject(String p) {
|
|
|
+ try {
|
|
|
FileInputStream fis = new FileInputStream(p);
|
|
|
ObjectInputStream o = new ObjectInputStream(fis);
|
|
|
return (Object[]) o.readObject();
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- l.warn("Loader.failure @{}",p);
|
|
|
+ } catch (Exception e) {
|
|
|
+ l.warn("Loader.failure @{}", p);
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private static JList lstItemz;
|
|
|
private static String retval;
|
|
|
|
|
|
- public static String listSelectorPopup(String[] elemsToChoseFrom, String Question)
|
|
|
- {
|
|
|
- if(hl)return "";
|
|
|
+ public static String listSelectorPopup(String[] elemsToChoseFrom, String Question) {
|
|
|
+ if (hl) return "";
|
|
|
JPanel p = new JPanel();
|
|
|
d.setModal(true);
|
|
|
lstItemz = new javax.swing.JList();
|
|
@@ -788,18 +701,15 @@ public class Tools
|
|
|
((DefaultListModel) (lstItemz.getModel())).clear();
|
|
|
// String[] availUPIDs = dbc.querySIngleColumn("Select UPID20 from upidlst");
|
|
|
|
|
|
- for (String elem : elemsToChoseFrom)
|
|
|
- {
|
|
|
+ for (String elem : elemsToChoseFrom) {
|
|
|
((DefaultListModel) (Tools.lstItemz.getModel())).addElement(elem);
|
|
|
}
|
|
|
|
|
|
|
|
|
retval = "NOP";
|
|
|
|
|
|
- btnCont.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnCont.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
retval = (String) lstItemz.getSelectedValue();
|
|
|
hideDialog();
|
|
|
d = null;
|
|
@@ -807,43 +717,41 @@ public class Tools
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- btnAbort.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnAbort.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
retval = "NOP";
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
- d = new JDialog();;
|
|
|
+ d = new JDialog();
|
|
|
+ ;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
-
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
|
|
|
p.setLayout(layout);
|
|
|
layout.setHorizontalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addComponent(jScrollPane1)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGap(47, 47, 47)
|
|
|
- .addComponent(txtQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addContainerGap(95, Short.MAX_VALUE))
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addComponent(btnCont, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
+ .addComponent(jScrollPane1)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(47, 47, 47)
|
|
|
+ .addComponent(txtQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addContainerGap(95, Short.MAX_VALUE))
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(btnCont, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
layout.setVerticalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGap(26, 26, 26)
|
|
|
- .addComponent(txtQuestion)
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addComponent(btnCont, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
|
|
|
- .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(26, 26, 26)
|
|
|
+ .addComponent(txtQuestion)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(btnCont, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
|
|
|
+ .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));
|
|
|
d.add(p);
|
|
|
Dimension d2 = p.getPreferredSize();
|
|
|
d2 = new Dimension(d2.width, d2.height + 40);
|
|
@@ -851,57 +759,50 @@ public class Tools
|
|
|
d.setVisible(true);
|
|
|
|
|
|
|
|
|
-
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
- public static String FileChooseDlg(javax.swing.JFrame frm)
|
|
|
- {
|
|
|
- return FileChooseDlg(frm,false,false,null);
|
|
|
+ public static String FileChooseDlg(javax.swing.JFrame frm) {
|
|
|
+ return FileChooseDlg(frm, false, false, null);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Opens a FileChooser and returns the path that got chosen
|
|
|
- * @param frm Frame the Dialog links to
|
|
|
+ *
|
|
|
+ * @param frm Frame the Dialog links to
|
|
|
* @param restrict flag to select if a FileLimiter should be used
|
|
|
* @param dirsOnly flag to restrict the CHooser to directories only
|
|
|
- * @param exts Array of FileExtensions
|
|
|
+ * @param exts Array of FileExtensions
|
|
|
* @return Path when file got opened or empty string if none selected
|
|
|
*/
|
|
|
- public static String FileChooseDlg(javax.swing.JFrame frm,boolean restrict,boolean dirsOnly,String[] exts)
|
|
|
- {
|
|
|
+ public static String FileChooseDlg(javax.swing.JFrame frm, boolean restrict, boolean dirsOnly, String[] exts) {
|
|
|
JFileChooser fc = new JFileChooser();
|
|
|
String ret = "";
|
|
|
- if(!dirsOnly)
|
|
|
+ if (!dirsOnly)
|
|
|
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
|
|
else
|
|
|
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
|
- if(restrict)
|
|
|
- {
|
|
|
+ if (restrict) {
|
|
|
FIleLImiter f = new FIleLImiter();
|
|
|
f.setExtensions(exts);
|
|
|
fc.setFileFilter(f);
|
|
|
}
|
|
|
int returnVal = fc.showOpenDialog(frm);
|
|
|
- if (returnVal == JFileChooser.APPROVE_OPTION)
|
|
|
- {
|
|
|
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|
|
File file = fc.getSelectedFile();
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
ret = file.getCanonicalPath();
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
+ } catch (IOException ex) {
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
private static int retnumber = 0;
|
|
|
|
|
|
- public static int numberInputWIndow(int maxNbr, int[] blockednumbrs)
|
|
|
- {
|
|
|
- if(hl) return -1;
|
|
|
+ public static int numberInputWIndow(int maxNbr, int[] blockednumbrs) {
|
|
|
+ if (hl) return -1;
|
|
|
l.info("niw");
|
|
|
k1 = new javax.swing.JButton();
|
|
|
k2 = new javax.swing.JButton();
|
|
@@ -920,7 +821,6 @@ public class Tools
|
|
|
btnClear = new javax.swing.JButton();
|
|
|
|
|
|
|
|
|
-
|
|
|
d = new JDialog();
|
|
|
d.setModal(true);
|
|
|
numEntered = 0;
|
|
@@ -937,46 +837,35 @@ public class Tools
|
|
|
k9.setEnabled(true);
|
|
|
retnumber = 0;
|
|
|
|
|
|
- for (int i : blockednumbrs)
|
|
|
- {
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
+ for (int i : blockednumbrs) {
|
|
|
+ if (i == 0) {
|
|
|
k0.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 1)
|
|
|
- {
|
|
|
+ if (i == 1) {
|
|
|
k1.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 2)
|
|
|
- {
|
|
|
+ if (i == 2) {
|
|
|
k2.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 3)
|
|
|
- {
|
|
|
+ if (i == 3) {
|
|
|
k3.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 4)
|
|
|
- {
|
|
|
+ if (i == 4) {
|
|
|
k4.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 5)
|
|
|
- {
|
|
|
+ if (i == 5) {
|
|
|
k5.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 6)
|
|
|
- {
|
|
|
+ if (i == 6) {
|
|
|
k6.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 7)
|
|
|
- {
|
|
|
+ if (i == 7) {
|
|
|
k7.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 8)
|
|
|
- {
|
|
|
+ if (i == 8) {
|
|
|
k8.setEnabled(false);
|
|
|
}
|
|
|
- if (i == 9)
|
|
|
- {
|
|
|
+ if (i == 9) {
|
|
|
k9.setEnabled(false);
|
|
|
}
|
|
|
|
|
@@ -984,131 +873,100 @@ public class Tools
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
k1.setText("1");
|
|
|
- k1.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k1.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k1ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k2.setText("2");
|
|
|
- k2.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k2.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k2ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k3.setText("3");
|
|
|
- k3.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k3.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k3ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k4.setText("4");
|
|
|
- k4.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k4.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k4ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k5.setText("5");
|
|
|
- k5.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k5.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k5ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k6.setText("6");
|
|
|
- k6.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k6.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k6ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k7.setText("7");
|
|
|
- k7.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k7.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k7ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k8.setText("8");
|
|
|
- k8.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k8.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k8ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k9.setText("9");
|
|
|
- k9.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k9.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k9ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
btnOk.setText("OK");
|
|
|
- btnOk.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnOk.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
btnOkActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
btnAbbr.setText("ABBR");
|
|
|
- btnAbbr.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnAbbr.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
btnAbbrActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
k0.setText("0");
|
|
|
- k0.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ k0.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
k0ActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
kC.setText("<--");
|
|
|
- kC.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ kC.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
kCActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
btnClear.setText("Clr");
|
|
|
- btnClear.addActionListener(new java.awt.event.ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ btnClear.addActionListener(new java.awt.event.ActionListener() {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
btnClearActionPerformed(evt);
|
|
|
}
|
|
|
});
|
|
@@ -1117,69 +975,69 @@ public class Tools
|
|
|
d.getContentPane().setLayout(layout);
|
|
|
layout.setHorizontalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addContainerGap()
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addComponent(btnAbbr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k1, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
|
|
|
- .addComponent(k4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
- .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
- .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
- .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addComponent(k9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
|
|
- .addComponent(entrdNbr))
|
|
|
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(btnAbbr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k1, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
|
|
|
+ .addComponent(k4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
+ .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
+ .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
|
|
|
+ .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(k9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
|
|
+ .addComponent(entrdNbr))
|
|
|
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
layout.setVerticalGroup(
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
- .addGroup(layout.createSequentialGroup()
|
|
|
- .addGap(7, 7, 7)
|
|
|
- .addComponent(entrdNbr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(k9, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
- .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
|
|
|
- .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
- .addComponent(btnAbbr, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
- .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
- .addGap(0, 8, Short.MAX_VALUE)));
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(7, 7, 7)
|
|
|
+ .addComponent(entrdNbr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(k9, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
|
|
|
+ .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(btnAbbr, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addGap(0, 8, Short.MAX_VALUE)));
|
|
|
|
|
|
d.pack();
|
|
|
d.setVisible(true);
|
|
@@ -1187,149 +1045,122 @@ public class Tools
|
|
|
return retnumber;
|
|
|
}// </editor-fold>
|
|
|
|
|
|
- private static void k1ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k1ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "1");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k2ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k2ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "2");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k3ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k3ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "3");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k4ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k4ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "4");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k5ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k5ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "5");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k6ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k6ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "6");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k7ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k7ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "7");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k8ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k8ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "8");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void k9ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k9ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "9");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void btnClearActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ private static void btnClearActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
numEntered = 0;
|
|
|
entrdNbr.setText("");
|
|
|
}
|
|
|
|
|
|
- private static void k0ActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
- if (numEntered >= numMax)
|
|
|
- {
|
|
|
+ private static void k0ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
+ if (numEntered >= numMax) {
|
|
|
return;
|
|
|
}
|
|
|
entrdNbr.setText(entrdNbr.getText() + "0");
|
|
|
numEntered++;
|
|
|
}
|
|
|
|
|
|
- private static void kCActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ private static void kCActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
retnumber = -1;
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
d = new JDialog();
|
|
|
}
|
|
|
|
|
|
- private static void btnOkActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ private static void btnOkActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
retnumber = Integer.valueOf(entrdNbr.getText());
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
d = new JDialog();
|
|
|
}
|
|
|
|
|
|
- private static void btnAbbrActionPerformed(java.awt.event.ActionEvent evt)
|
|
|
- {
|
|
|
+ private static void btnAbbrActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
//retnumber=-1;
|
|
|
hideDialog();
|
|
|
d = null;
|
|
|
d = new JDialog();
|
|
|
}
|
|
|
|
|
|
- public static String processEnvVarsinLine(String line)
|
|
|
- {
|
|
|
+ public static String processEnvVarsinLine(String line) {
|
|
|
Map<String, String> env = System.getenv();
|
|
|
String linemod = line;
|
|
|
int varstart = linemod.indexOf("%");
|
|
|
int varend = linemod.indexOf("%", varstart + 1);
|
|
|
String preVar = "";
|
|
|
- if (varstart == -1)
|
|
|
- {
|
|
|
+ if (varstart == -1) {
|
|
|
return line;
|
|
|
}
|
|
|
- if (varstart > 0)
|
|
|
- {
|
|
|
+ if (varstart > 0) {
|
|
|
preVar = linemod.substring(0, varstart);
|
|
|
}
|
|
|
String postVar = linemod.substring(varend + 1);
|
|
@@ -1338,59 +1169,52 @@ public class Tools
|
|
|
line = preVar + var + postVar;
|
|
|
return line;
|
|
|
}
|
|
|
- public static String replaceHashmarkedVars(String line,String varname,String toReplace)
|
|
|
- {
|
|
|
-
|
|
|
- return line.replaceAll("#"+varname+"#", toReplace.replace("\\", "\\\\")).replace("\\\\", "\\");
|
|
|
-
|
|
|
+
|
|
|
+ public static String replaceHashmarkedVars(String line, String varname, String toReplace) {
|
|
|
+
|
|
|
+ return line.replaceAll("#" + varname + "#", toReplace.replace("\\", "\\\\")).replace("\\\\", "\\");
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- public static void DebugHelperPrint(String msg,boolean dbgonly,String debugEnablePreference)
|
|
|
- {
|
|
|
- if(dbgonly)
|
|
|
- if(!Boolean.valueOf(Preferences.userRoot().get(debugEnablePreference, "false")))
|
|
|
- return;
|
|
|
+
|
|
|
+ public static void DebugHelperPrint(String msg, boolean dbgonly, String debugEnablePreference) {
|
|
|
+ if (dbgonly)
|
|
|
+ if (!Boolean.valueOf(Preferences.userRoot().get(debugEnablePreference, "false")))
|
|
|
+ return;
|
|
|
l.trace(msg);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private static boolean sil = false;
|
|
|
-
|
|
|
- public static boolean runCmdWithOutToTextField(JTextArea txf, String... cmd)
|
|
|
- {
|
|
|
- return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false, cmd);
|
|
|
+
|
|
|
+ public static boolean runCmdWithOutToTextField(JTextArea txf, String... cmd) {
|
|
|
+ return runCmdStreamable(txf, new PrintStream(new NullOutputStream()), false, cmd);
|
|
|
}
|
|
|
-
|
|
|
- public static boolean runCmdWithOutToTextField(JTextArea txf, ProcessWatcher w,String... cmd)
|
|
|
- {
|
|
|
- return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false,w, cmd);
|
|
|
+
|
|
|
+ public static boolean runCmdWithOutToTextField(JTextArea txf, ProcessWatcher w, String... cmd) {
|
|
|
+ return runCmdStreamable(txf, new PrintStream(new NullOutputStream()), false, w, cmd);
|
|
|
}
|
|
|
-
|
|
|
- public static boolean runCmdWithPassthru(PrintStream p,String... cmd)
|
|
|
- {
|
|
|
- return runCmdStreamable(new JTextArea(),p,false, cmd);
|
|
|
+
|
|
|
+ public static boolean runCmdWithPassthru(PrintStream p, String... cmd) {
|
|
|
+ return runCmdStreamable(new JTextArea(), p, false, cmd);
|
|
|
}
|
|
|
-
|
|
|
- public static boolean runCmdWithPassthru(PrintStream p,ProcessWatcher w,String... cmd)
|
|
|
- {
|
|
|
- return runCmdStreamable(new JTextArea(),p,false,w, cmd);
|
|
|
+
|
|
|
+ public static boolean runCmdWithPassthru(PrintStream p, ProcessWatcher w, String... cmd) {
|
|
|
+ return runCmdStreamable(new JTextArea(), p, false, w, cmd);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//private static ExecuteStreamHandler s;
|
|
|
//private static JTextArea txf;
|
|
|
//private static PrintStream otherOut;
|
|
|
- public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException, String... cmd)
|
|
|
- {
|
|
|
+ public static boolean runCmdStreamable(JTextArea txf, PrintStream otherOut, final boolean SpamException, String... cmd) {
|
|
|
return runCmdStreamable(txf, otherOut, SpamException, null, cmd);
|
|
|
}
|
|
|
- public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException,ProcessWatcher w, String... cmd)//synchronized gint nen fetten Bug
|
|
|
+
|
|
|
+ public static boolean runCmdStreamable(JTextArea txf, PrintStream otherOut, final boolean SpamException, ProcessWatcher w, String... cmd)//synchronized gint nen fetten Bug
|
|
|
{
|
|
|
- return runCmdStreamable(txf, otherOut, SpamException, w,null,false ,cmd);
|
|
|
+ return runCmdStreamable(txf, otherOut, SpamException, w, null, false, cmd);
|
|
|
}
|
|
|
-
|
|
|
- public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException,ProcessWatcher w,OutputStreamBridge bridge,boolean async, String... cmd)//synchronized gint nen fetten Bug
|
|
|
+
|
|
|
+ public static boolean runCmdStreamable(JTextArea txf, PrintStream otherOut, final boolean SpamException, ProcessWatcher w, OutputStreamBridge bridge, boolean async, String... cmd)//synchronized gint nen fetten Bug
|
|
|
{
|
|
|
try //synchronized gint nen fetten Bug
|
|
|
{
|
|
@@ -1400,85 +1224,66 @@ public class Tools
|
|
|
// (
|
|
|
// new ByteArrayInputStream(new byte[]{0})
|
|
|
// );//das einzelne Byte ist n(ö|ä)tig um ne NPX zu verhindern
|
|
|
-
|
|
|
- if(txf==null)
|
|
|
- {
|
|
|
- txf=new JTextArea();
|
|
|
+
|
|
|
+ if (txf == null) {
|
|
|
+ txf = new JTextArea();
|
|
|
}
|
|
|
-
|
|
|
- if(otherOut==null)
|
|
|
- {
|
|
|
- otherOut=new PrintStream(new NullOutputStream());
|
|
|
+
|
|
|
+ if (otherOut == null) {
|
|
|
+ otherOut = new PrintStream(new NullOutputStream());
|
|
|
}
|
|
|
- l.trace("OtherOut="+otherOut);
|
|
|
-
|
|
|
+ l.trace("OtherOut=" + otherOut);
|
|
|
+
|
|
|
ProcessBuilder pb = new ProcessBuilder(Arrays.asList(cmd));
|
|
|
pb.redirectErrorStream(true);
|
|
|
//ProcessLauncher l = Native.get(ProcessLauncher.class);
|
|
|
Process process = pb.start();
|
|
|
- if(w!=null)
|
|
|
- {
|
|
|
+ if (w != null) {
|
|
|
w.receiveProcess(process);
|
|
|
}
|
|
|
PrintStream stdout = new PrintStreamCapturer(txf, otherOut);
|
|
|
Thread stdoutThread = new Thread(new TextDumper(process.getInputStream(), stdout));
|
|
|
stdoutThread.start();
|
|
|
- if(async)
|
|
|
- {
|
|
|
- if(bridge!=null)
|
|
|
- {
|
|
|
- bridge.s=process.getOutputStream();
|
|
|
+ if (async) {
|
|
|
+ if (bridge != null) {
|
|
|
+ bridge.s = process.getOutputStream();
|
|
|
}
|
|
|
l.trace("ASYNC background task");
|
|
|
return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int result = process.waitFor();
|
|
|
- stdoutThread.join();
|
|
|
- Tools.l.trace("FIN");
|
|
|
- return result!=0;
|
|
|
+ } else {
|
|
|
+ int result = process.waitFor();
|
|
|
+ stdoutThread.join();
|
|
|
+ Tools.l.trace("FIN");
|
|
|
+ return result != 0;
|
|
|
}
|
|
|
//sil=false;
|
|
|
- }
|
|
|
- catch (InterruptedException|IOException ex)
|
|
|
- {
|
|
|
+ } catch (InterruptedException | IOException ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static String getFormatStrforThisAsMax(int nbr)
|
|
|
- {
|
|
|
- int filesMax=nbr;
|
|
|
+
|
|
|
+ public static String getFormatStrforThisAsMax(int nbr) {
|
|
|
+ int filesMax = nbr;
|
|
|
String nfs = "%1";
|
|
|
- if (filesMax > 9)
|
|
|
- {
|
|
|
+ if (filesMax > 9) {
|
|
|
nfs = "%2";
|
|
|
- if (filesMax > 99)
|
|
|
- {
|
|
|
+ if (filesMax > 99) {
|
|
|
nfs = "%3";
|
|
|
- if (filesMax > 999)
|
|
|
- {
|
|
|
+ if (filesMax > 999) {
|
|
|
nfs = "%4";
|
|
|
- if (filesMax > 9_999)
|
|
|
- {
|
|
|
+ if (filesMax > 9_999) {
|
|
|
nfs = "%5";
|
|
|
- if (filesMax > 99_999)
|
|
|
- {
|
|
|
+ if (filesMax > 99_999) {
|
|
|
nfs = "%6";
|
|
|
- if (filesMax > 999_999)
|
|
|
- {
|
|
|
+ if (filesMax > 999_999) {
|
|
|
nfs = "%7";
|
|
|
- if (filesMax > 9_999_999)
|
|
|
- {
|
|
|
+ if (filesMax > 9_999_999) {
|
|
|
nfs = "%8";
|
|
|
- if (filesMax > 99_999_999)
|
|
|
- {
|
|
|
+ if (filesMax > 99_999_999) {
|
|
|
nfs = "%9";
|
|
|
- if (filesMax > 999_999_999)
|
|
|
- {
|
|
|
+ if (filesMax > 999_999_999) {
|
|
|
nfs = "%10";
|
|
|
}
|
|
|
}
|
|
@@ -1488,32 +1293,28 @@ public class Tools
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- return nfs+"d";
|
|
|
+ }
|
|
|
+ return nfs + "d";
|
|
|
}
|
|
|
- public static void dork()
|
|
|
- {
|
|
|
+
|
|
|
+ public static void dork() {
|
|
|
new Svoujnf().nope();
|
|
|
}
|
|
|
+
|
|
|
public static void ragequit() {
|
|
|
try {
|
|
|
- Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
|
|
|
- f.setAccessible(true);
|
|
|
- sun.misc.Unsafe u= (sun.misc.Unsafe) f.get(null);
|
|
|
- u.setMemory(u, -10L,1024L,(byte)0);
|
|
|
- u.hashCode();
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- /* ... */
|
|
|
+ Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
|
|
|
+ f.setAccessible(true);
|
|
|
+ sun.misc.Unsafe u = (sun.misc.Unsafe) f.get(null);
|
|
|
+ u.setMemory(u, -10L, 1024L, (byte) 0);
|
|
|
+ u.hashCode();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ /* ... */
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private static class TextDumper implements Runnable {
|
|
|
InputStream in;
|
|
|
Appendable app;
|
|
@@ -1539,28 +1340,27 @@ public class Tools
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* http://stackoverflow.com/a/2904266/1405227
|
|
|
+ *
|
|
|
* @param <T>
|
|
|
* @param <E>
|
|
|
* @param map
|
|
|
* @param value
|
|
|
- * @return
|
|
|
+ * @return
|
|
|
*/
|
|
|
public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
|
|
|
- for (Entry<T, E> entry : map.entrySet()) {
|
|
|
- if (Objects.equals(value, entry.getValue())) {
|
|
|
- return entry.getKey();
|
|
|
+ for (Entry<T, E> entry : map.entrySet()) {
|
|
|
+ if (Objects.equals(value, entry.getValue())) {
|
|
|
+ return entry.getKey();
|
|
|
+ }
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
- return null;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private static int numEntered = 0, numMax = 0;
|
|
|
private static javax.swing.JButton btnAbbr;
|
|
|
private static javax.swing.JButton btnClear;
|