Browse files

Merge pull request #32 from daux2a/src-testing

Src testing
  • Loading branch information...
2 parents 268a801 + b512d40 commit 122652ffc498b98795b8fbcf13bcfd1858f176bd @daux2a daux2a committed Apr 26, 2012
Showing with 408 additions and 140 deletions.
  1. +11 −0 alpha/APIManager.java
  2. +4 −11 alpha/Buddy.java
  3. +7 −6 alpha/Config.java
  4. +2 −4 gui/ChatWindow.java
  5. +28 −18 gui/GUIContactAdd.java
  6. +7 −23 gui/GUISettings.java
  7. +11 −1 gui/Gui.java
  8. +5 −5 gui/Log.java
  9. +175 −0 gui/Profile.java
  10. +64 −0 gui/Profile.jfd
  11. +52 −56 gui/SettingsGUI.java
  12. +12 −16 gui/SettingsGUI.jfd
  13. +2 −0 util/Util.java
  14. +28 −0 util/list.java
View
11 alpha/APIManager.java
@@ -55,6 +55,17 @@ public static void fireAddMe(Buddy buddy) {
e.printStackTrace();
}
}
+
+
+ public static void fireRemove(Buddy buddy) {
+ try {
+ Logger.log(Logger.DEBUG, "API", buddy.getAddress() + " requested us to del them");
+ for (APIListener apil : listeners)
+ apil.onBuddyRemoved(buddy);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
public static void fireMessage(Buddy buddy, String s) {
try {
View
15 alpha/Buddy.java
@@ -417,13 +417,6 @@ public void attatch(Socket s, Scanner sc) throws IOException {
} else if (l.startsWith("ping ")) {
if (ourSock == null)
connect();
- // theirCookie = l.split(" ")[2];
- // try {
- // sendPong(theirCookie);
- // } catch (NullPointerException npe) {
- // Logger.log(Logger.INFO, Buddy.this, "2Caught npe on " +
- // address);
- // }
try {
sendPong(l.split(" ")[2]);
} catch (NullPointerException npe) {
@@ -460,18 +453,17 @@ public void attatch(Socket s, Scanner sc) throws IOException {
APIManager.fireProfileTextChange(this, profile_text, old);
} else if (l.startsWith("add_me")) {
APIManager.fireAddMe(this);
+ } else if (l.startsWith("remove_me")) {
+ APIManager.fireRemove(this);
} else if (l.startsWith("message ")) {
APIManager.fireMessage(this, l.split(" ", 2)[1]);
} else if (l.startsWith("not_implemented")) {
Logger.log(Logger.NOTICE, this, "Recieved " + l.trim() + " from " + address);
} else if (APIManager.cmdListeners.containsKey(l.split(" ")[0])) {
APIManager.cmdListeners.get(l.split(" ")[0]).onCommand(this, l);
} else if (l.startsWith("profile_avatar")) { // will match both profile_avatar_alpha and profile_avatar
- // intentionally placed after the cmdListeners so as to not cause an issue if someone adds a cmdListener for it
-
- // do nothing, only purpose of this is to not flood the log with avatar data
+ Logger.log(Logger.NOTICE, this, "Sorry, we have no avatar support. Coming soon.");
}
-
else {
Logger.log(Logger.WARNING, this, "Recieved unknown from " + address + " " + l);
sendRaw("not_implemented ");
@@ -558,6 +550,7 @@ public void disconnect() throws IOException { // should be used with caution
public void remove() throws IOException {
BuddyList.buds.remove(address);
+ try { sendRaw("remove_me"); } catch (IOException e) {}
disconnect();
APIManager.fireBuddyRemoved(this);
}
View
13 alpha/Config.java
@@ -31,6 +31,7 @@
public static String LANG_DIR = "";
public static String DATA_DIR = "";
public static String ICON_DIR = "";
+ public static String ICON_DIR_MAIN = "";
public static int SOCKS_PORT;
public static int LOCAL_PORT;
public static int alert;
@@ -122,7 +123,8 @@
MESSAGE_DIR = Config.BASE_DIR + Config.DATA_DIR + "offlinemsgs/";
PAGE_DIR = Config.BASE_DIR + Config.DATA_DIR + "page/";
TOR_DIR = Config.BASE_DIR + Config.DATA_DIR + "Tor/";
- LANG_DIR = Config.BASE_DIR + Config.DATA_DIR + "lang/";
+ LANG_DIR = Config.BASE_DIR + Config.DATA_DIR + "lang/";
+ ICON_DIR_MAIN = Config.BASE_DIR + Config.DATA_DIR + "icon/";
//Create all important dir
new File(CONFIG_DIR).mkdirs();
new File(DOWNLOAD_DIR).mkdirs();
@@ -131,7 +133,7 @@
new File(PAGE_DIR).mkdirs();
new File(TOR_DIR).mkdirs();
new File(LANG_DIR).mkdirs();
- new File(ICON_DIR).mkdirs();
+ new File(ICON_DIR_MAIN).mkdirs();
Logger.log(Logger.NOTICE, "Config", "Using " + CONFIG_DIR + " as CONFIG_DIR");
Logger.log(Logger.NOTICE, "Config", "Using " + DOWNLOAD_DIR + " as DOWNLOAD_DIR");
Logger.log(Logger.NOTICE, "Config", "Using " + LOG_DIR + " as LOG_DIR");
@@ -177,13 +179,12 @@
Config.image_size = assignInt("image_size", 16, prop);
Config.icon_size = assignInt("icon_size", 16, prop);
Config.icon_space = assignInt("icon_space", 2, prop);
- Config.icon_folder = assign("ICON", "juan", prop);
+ Config.icon_folder = assign("ICON", "juan.icon", prop);
-
- Config.ICON_DIR = Config.BASE_DIR + Config.DATA_DIR + "icon/" + icon_folder;
+ Config.ICON_DIR = Config.ICON_DIR_MAIN + icon_folder;
if(!new File(ICON_DIR).exists())
{
- Config.ICON_DIR = Config.BASE_DIR + Config.DATA_DIR + "icon/" + "orginal";
+ Config.ICON_DIR = Config.ICON_DIR_MAIN + "juan.icon";
}
Logger.log(Logger.NOTICE, "Config", "Using " + ICON_DIR + " as ICON_DIR");
View
6 gui/ChatWindow.java
@@ -65,9 +65,6 @@ public void addUrlText(String text) {
}
else
{
-
-
-
String[] splittall = text.split(" ");
int x=0;
@@ -96,7 +93,8 @@ else if (splittall[x].startsWith("https://"))
else
{
append("Plain", splittall[x]);
-append("Plain", " ");
+
+if (x < splittall.length-1){append("Plain", " ");}
}
View
46 gui/GUIContactAdd.java
@@ -65,58 +65,68 @@ private void language()
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
+ // Generated using JFormDesigner Evaluation license - dfddfd dfdfdf
label1 = new JLabel();
textField1 = new JTextField();
label2 = new JLabel();
textField2 = new JTextField();
button1 = new JButton();
- // ======== this ========
+ //======== this ========
Container contentPane = getContentPane();
contentPane.setLayout(new GridBagLayout());
- ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] { 0, 0, 0 };
- ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0 };
- ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
- ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
+ ((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {0, 0, 0};
+ ((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0};
+ ((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {0.0, 0.0, 1.0E-4};
+ ((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};
- // ---- label1 ----
+ //---- label1 ----
label1.setText("Address: ");
- contentPane.add(label1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(10, 10, 5, 5), 0, 0));
- contentPane.add(textField1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 0, 5, 10), 0, 0));
-
- // ---- label2 ----
+ contentPane.add(label1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
+ GridBagConstraints.EAST, GridBagConstraints.VERTICAL,
+ new Insets(10, 10, 5, 5), 0, 0));
+ contentPane.add(textField1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(10, 0, 5, 10), 0, 0));
+
+ //---- label2 ----
label2.setText("Display Name: ");
- contentPane.add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 10, 5, 5), 0, 0));
- contentPane.add(textField2, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 10), 0, 0));
-
- // ---- button1 ----
+ contentPane.add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
+ GridBagConstraints.EAST, GridBagConstraints.VERTICAL,
+ new Insets(0, 10, 5, 5), 0, 0));
+ contentPane.add(textField2, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(0, 0, 5, 10), 0, 0));
+
+ //---- button1 ----
button1.setText("Ok");
button1.addActionListener(new ActionListener() {
-
@Override
public void actionPerformed(ActionEvent e) {
ok(e);
}
});
- contentPane.add(button1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 125, 15, 10), 10, 0));
+ contentPane.add(button1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(0, 125, 15, 10), 10, 0));
pack();
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
+ // Generated using JFormDesigner Evaluation license - dfddfd dfdfdf
private JLabel label1;
private JTextField textField1;
private JLabel label2;
private JTextField textField2;
private JButton button1;
-
// JFormDesigner - End of variables declaration //GEN-END:variables
public void setBuddy(Buddy o) {
this.b = o;
textField1.setText(b.getAddress());
- textField1.setEnabled(false);
+ textField1.setEditable(false);
if (b.overrideName)
textField2.setText(b.getName());
}
View
30 gui/GUISettings.java
@@ -2,7 +2,6 @@
import java.awt.*;
import java.awt.event.*;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -30,7 +29,7 @@ public GUISettings() {
setResizable(false);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
initComponents();
- addelements();
+ list1 = util.list.addelements(list1,Config.lang,Config.LANG_DIR,".ini");
language();
textField1.setText(TCPort.profile_name);
textField2.setText(TCPort.profile_text);
@@ -193,27 +192,6 @@ private void sync(ActionEvent e) {
Config.nowstart = textField7.getText();
}
- private void addelements()
- {
- int index=0;
- int now = 0;
- DefaultListModel listModel = new DefaultListModel();
- File dir = new File(Config.LANG_DIR);
- File[] fileList = dir.listFiles();
- for(File f : fileList) {
- if (f.getName().endsWith(".ini"))
- {
- listModel.addElement(f.getName().subSequence(0,f.getName().length()-4));
- if ((f.getName().subSequence(0,f.getName().length()-4)).equals(Config.lang))
- {now=index+1;}
- index++;
- }}
- list1.setModel(listModel);
- if (now != 0)
- {list1.setSelectedIndex(now-1);}
- getlanginfo(Config.lang);
- }
-
private void language()
{
@@ -325,6 +303,12 @@ private void initComponents() {
//======== panel1 ========
{
+ // JFormDesigner evaluation mark
+ panel1.setBorder(new javax.swing.border.CompoundBorder(
+ new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
+ "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
+ javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
+ java.awt.Color.red), panel1.getBorder())); panel1.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
//---- label1 ----
View
12 gui/Gui.java
@@ -379,6 +379,16 @@ public void actionPerformed(ActionEvent e) {
openChatWindow((Buddy) o);
}
}));
+
+
+ popup.add(getMenuItem("Display Profile", new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Profile guis = new Profile((Buddy) o);
+ guis.setVisible(true);
+ }
+ }));
popup.add(new JPopupMenu.Separator());
popup.add(getMenuItem(language.langtext[74], new ActionListener() {
@@ -419,7 +429,7 @@ public void actionPerformed(ActionEvent e) {
BuddyList.addHoly(((Buddy) o));
}
}));
-
+
popup.add(getMenuItem(language.langtext[76], new ActionListener() {
@Override
View
10 gui/Log.java
@@ -55,9 +55,9 @@ public static void append(String text, String style) {
synchronized(LOCK) {
DefaultStyledDocument d = (DefaultStyledDocument) instance.textPane1.getDocument();
try {
-
d.insertString(d.getLength(), text, style == null ? null : d.getStyle(style));
trimText();
+ instance.textPane1.setCaretPosition(d.getLength());
} catch (BadLocationException ble) {
ble.printStackTrace();
}
@@ -70,6 +70,7 @@ public static void updateErr(String s) {
try {
d.insertString(d.getLength(), s, d.getStyle("Err"));
trimText();
+ instance.textPane1.setCaretPosition(d.getLength());
} catch (BadLocationException ble) {
ble.printStackTrace();
}
@@ -82,6 +83,7 @@ public static void updateOut(String s) {
try {
d.insertString(d.getLength(), s, null);
trimText();
+ instance.textPane1.setCaretPosition(d.getLength());
} catch (BadLocationException ble) {
ble.printStackTrace();
}
@@ -91,9 +93,7 @@ public static void updateOut(String s) {
private static void trimText() {
if (Config.fulllog == 0) {
synchronized(LOCK) {
- int count = 0;
- int old = instance.textPane1.getCaretPosition();
- instance.textPane1.setCaretPosition(0);
+ int count = 0; instance.textPane1.setCaretPosition(0);
try {
while (instance.textPane1.getDocument().getLength() > 10000) {
if (count++ > 50) {
@@ -106,7 +106,6 @@ private static void trimText() {
} catch (BadLocationException e) {
// e.printStackTrace();
}
- instance.textPane1.setCaretPosition(Math.min(old, instance.textPane1.getDocument().getLength())); // to try avoid lockup
}
}
}
@@ -116,6 +115,7 @@ private void save(ActionEvent e) {
}
private void clear(ActionEvent e) {
+ instance.textPane1.setCaretPosition(0);
instance.textPane1.setDocument(new DefaultStyledDocument());
initDocument();
System.gc(); // ask the jvm to collect garbage
View
175 gui/Profile.java
@@ -0,0 +1,175 @@
+/*
+ * Created by JFormDesigner on Thu Apr 26 20:42:46 CEST 2012
+ */
+
+package gui;
+
+import java.awt.*;
+import javax.swing.*;
+
+import javax.swing.GroupLayout;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.LayoutStyle;
+
+import alpha.Buddy;
+
+
+@SuppressWarnings("serial")
+public class Profile extends JFrame {
+
+
+
+Buddy b;
+
+ public Profile(Buddy b) {
+ this.b = b;
+ initComponents();
+ textField1.setText(b.getProfile_name());
+ textField4.setText(b.getName());
+ textField2.setText(b.getAddress());
+ textField3.setText(b.getVersion());
+ textArea1.setText(b.getProfile_text());
+ }
+
+
+
+
+
+ private void initComponents() {
+ // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
+ // Generated using JFormDesigner Evaluation license - dfddfd dfdfdf
+ panel1 = new JPanel();
+ scrollPane1 = new JScrollPane();
+ textArea1 = new JTextArea();
+ textField1 = new JTextField();
+ textField2 = new JTextField();
+ textField3 = new JTextField();
+ textField4 = new JTextField();
+ label3 = new JLabel();
+ label4 = new JLabel();
+ label5 = new JLabel();
+ label6 = new JLabel();
+
+ //======== this ========
+ Container contentPane = getContentPane();
+ contentPane.setLayout(new GridBagLayout());
+ ((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {0, 0};
+ ((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {0, 0, 0};
+ ((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {1.0, 1.0E-4};
+ ((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};
+
+ //======== panel1 ========
+ {
+
+ // JFormDesigner evaluation mark
+ panel1.setBorder(new javax.swing.border.CompoundBorder(
+ new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
+ "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
+ javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
+ java.awt.Color.red), panel1.getBorder())); panel1.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
+
+
+ //======== scrollPane1 ========
+ {
+
+ //---- textArea1 ----
+ textArea1.setEditable(false);
+ scrollPane1.setViewportView(textArea1);
+ }
+
+ //---- textField1 ----
+ textField1.setEditable(false);
+
+ //---- textField2 ----
+ textField2.setEditable(false);
+
+ //---- textField3 ----
+ textField3.setEditable(false);
+
+ //---- textField4 ----
+ textField4.setEditable(false);
+
+ //---- label3 ----
+ label3.setText("Name:");
+
+ //---- label4 ----
+ label4.setText("Disp-Name:");
+
+ //---- label5 ----
+ label5.setText("Tor-ID:");
+
+ //---- label6 ----
+ label6.setText("Version:");
+
+ GroupLayout panel1Layout = new GroupLayout(panel1);
+ panel1.setLayout(panel1Layout);
+ panel1Layout.setHorizontalGroup(
+ panel1Layout.createParallelGroup()
+ .addGroup(panel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(panel1Layout.createParallelGroup()
+ .addComponent(scrollPane1)
+ .addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
+ .addComponent(label3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(label4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(label5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(label6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(panel1Layout.createParallelGroup()
+ .addComponent(textField4, GroupLayout.PREFERRED_SIZE, 288, GroupLayout.PREFERRED_SIZE)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
+ .addComponent(textField1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
+ .addComponent(textField2, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
+ .addComponent(textField3, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)))))
+ .addContainerGap())
+ );
+ panel1Layout.setVerticalGroup(
+ panel1Layout.createParallelGroup()
+ .addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label3))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label4))
+ .addGap(4, 4, 4)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label5))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label6))
+ .addGap(12, 12, 12)
+ .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE))
+ );
+ }
+ contentPane.add(panel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 0), 0, 0));
+ pack();
+ setLocationRelativeTo(getOwner());
+ // JFormDesigner - End of component initialization //GEN-END:initComponents
+ }
+
+ // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
+ // Generated using JFormDesigner Evaluation license - dfddfd dfdfdf
+ private JPanel panel1;
+ private JScrollPane scrollPane1;
+ private JTextArea textArea1;
+ private JTextField textField1;
+ private JTextField textField2;
+ private JTextField textField3;
+ private JTextField textField4;
+ private JLabel label3;
+ private JLabel label4;
+ private JLabel label5;
+ private JLabel label6;
+ // JFormDesigner - End of variables declaration //GEN-END:variables
+}
View
64 gui/Profile.jfd
@@ -0,0 +1,64 @@
+JFDML JFormDesigner: "5.1.0.0.47" Java: "1.6.0_24" encoding: "UTF-8"
+
+new FormModel {
+ contentType: "form/swing"
+ root: new FormRoot {
+ add( new FormWindow( "javax.swing.JFrame", new FormLayoutManager( class java.awt.GridBagLayout ) {
+ "$columnSpecs": "0:1.0"
+ "$rowSpecs": "0:1.0, 0"
+ "$alignTop": true
+ "$alignLeft": true
+ } ) {
+ name: "this"
+ "$locationPolicy": 0
+ add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) {
+ "$horizontalGroup": "par l {seq {space :::p, par l {comp scrollPane1:::::x, seq t {par l:::p {comp label3:::::x, comp label4:::::x, comp label5:::::x, comp label6:::::x}, space :::x, par l {comp textField4:::p:288:p, par l:::p {comp textField1::t::288:x, comp textField2::t::288:x, comp textField3::t::288:x}}}}, space :::p}}"
+ "$verticalGroup": "par l {seq t {par b {comp textField1::b:p::p, comp label3::b:p::p}, space :::p, par b {comp textField4::b:p::p, comp label4::b:p::p}, space :p:4:p, par b {comp textField2::b:p::p, comp label5::b:p::p}, space :::p, par b {comp textField3::b:p::p, comp label6::b:p::p}, space :p:12:p, comp scrollPane1::::127:x}}"
+ } ) {
+ name: "panel1"
+ add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
+ name: "scrollPane1"
+ add( new FormComponent( "javax.swing.JTextArea" ) {
+ name: "textArea1"
+ "editable": false
+ } )
+ } )
+ add( new FormComponent( "javax.swing.JTextField" ) {
+ name: "textField1"
+ "editable": false
+ } )
+ add( new FormComponent( "javax.swing.JTextField" ) {
+ name: "textField2"
+ "editable": false
+ } )
+ add( new FormComponent( "javax.swing.JTextField" ) {
+ name: "textField3"
+ "editable": false
+ } )
+ add( new FormComponent( "javax.swing.JTextField" ) {
+ name: "textField4"
+ "editable": false
+ } )
+ add( new FormComponent( "javax.swing.JLabel" ) {
+ name: "label3"
+ "text": "Name:"
+ } )
+ add( new FormComponent( "javax.swing.JLabel" ) {
+ name: "label4"
+ "text": "Disp-Name:"
+ } )
+ add( new FormComponent( "javax.swing.JLabel" ) {
+ name: "label5"
+ "text": "Tor-ID:"
+ } )
+ add( new FormComponent( "javax.swing.JLabel" ) {
+ name: "label6"
+ "text": "Version:"
+ } )
+ }, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) )
+ }, new FormLayoutConstraints( null ) {
+ "size": new java.awt.Dimension( 400, 290 )
+ "location": new java.awt.Point( 0, 0 )
+ } )
+ }
+}
View
108 gui/SettingsGUI.java
@@ -7,6 +7,7 @@
import java.io.IOException;
import javax.swing.*;
+import javax.swing.event.*;
import alpha.Config;
import alpha.TCPort;
@@ -27,11 +28,11 @@ public SettingsGUI() {
setResizable(false);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
initComponents();
+ list1 = util.list.addelements(list1,Config.icon_folder.subSequence(0,Config.icon_folder.length()-5).toString(),Config.ICON_DIR_MAIN,".icon");
language();
textField1.setText(Integer.toString(Config.image_size));
textField2.setText(Integer.toString(Config.icon_size));
textField3.setText(Integer.toString(Config.icon_space));
- textField4.setText(Config.icon_folder);
this.addWindowListener(new WindowListener() {
@@ -118,7 +119,7 @@ private void ok(ActionEvent e) {
}
}
- Config.icon_folder = textField4.getText();
+
Config.prop.put("ICON", Config.icon_folder);
@@ -140,7 +141,7 @@ private void ok(ActionEvent e) {
public JTabbedPane getTabbedPane1() {
return tabbedPane1;
}
-
+
private void language()
{
@@ -149,15 +150,17 @@ private void language()
label2.setText("Buddy icon size: ");
label3.setText("Space between Buddys: ");
label4.setText("You can see the change when you have restart!");
- label5.setText("Icon Set");
- label6.setText("\"orginal\" and \"juan\" are pre installed --> Icon Set");
tabbedPane1.removeAll();
tabbedPane1.addTab("Icons", panel1);
}
+ private void list1ValueChanged(ListSelectionEvent e) {
+ Config.icon_folder = list1.getSelectedValue().toString() + ".icon";
+ }
+
@@ -173,9 +176,8 @@ private void initComponents() {
label3 = new JLabel();
textField3 = new JTextField();
label4 = new JLabel();
- label5 = new JLabel();
- textField4 = new JTextField();
- label6 = new JLabel();
+ scrollPane1 = new JScrollPane();
+ list1 = new JList();
button1 = new JButton();
//======== this ========
@@ -222,67 +224,62 @@ private void initComponents() {
label4.setText("You can see the change when you have restart!");
label4.setHorizontalTextPosition(SwingConstants.CENTER);
- //---- label5 ----
- label5.setText("Icon Set");
- label5.setHorizontalAlignment(SwingConstants.TRAILING);
-
- //---- label6 ----
- label6.setText("\"orginal\", \"juan\" and \"blind\" are pre installed");
+ //======== scrollPane1 ========
+ {
+
+ //---- list1 ----
+ list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ list1.addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ list1ValueChanged(e);
+ }
+ });
+ scrollPane1.setViewportView(list1);
+ }
GroupLayout panel1Layout = new GroupLayout(panel1);
panel1.setLayout(panel1Layout);
panel1Layout.setHorizontalGroup(
panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addContainerGap()
- .addGroup(panel1Layout.createParallelGroup()
- .addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
- .addGroup(panel1Layout.createParallelGroup()
- .addComponent(label1, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE)
- .addComponent(label2, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(label3, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(label5, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
- .addComponent(textField4, GroupLayout.Alignment.LEADING)
- .addComponent(textField1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
- .addComponent(textField2, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
- .addComponent(textField3, GroupLayout.Alignment.LEADING))
- .addContainerGap())
- .addGroup(panel1Layout.createSequentialGroup()
- .addComponent(label4, GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
- .addGap(4, 4, 4))
- .addGroup(panel1Layout.createSequentialGroup()
- .addComponent(label6, GroupLayout.PREFERRED_SIZE, 349, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(23, Short.MAX_VALUE))))
+ .addComponent(label4, GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
+ .addContainerGap())
+ .addGroup(panel1Layout.createSequentialGroup()
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
+ .addComponent(label1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
+ .addComponent(label2, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
+ .addComponent(label3, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
+ .addComponent(textField1, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
+ .addComponent(textField2, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
+ .addComponent(textField3, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE))
);
panel1Layout.setVerticalGroup(
panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGroup(panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
- .addComponent(label1, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
- .addGroup(panel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label2, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
- .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label3, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
- .addComponent(textField3, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label5, GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
- .addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(label1, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
+ .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label2, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(textField3, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
+ .addComponent(label3, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)))
+ .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(label4, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
- .addGap(2, 2, 2)
- .addComponent(label6)
- .addContainerGap())
+ .addContainerGap(21, Short.MAX_VALUE))
);
}
tabbedPane1.addTab("Images", panel1);
@@ -319,9 +316,8 @@ public void actionPerformed(ActionEvent e) {
private JLabel label3;
private JTextField textField3;
private JLabel label4;
- private JLabel label5;
- private JTextField textField4;
- private JLabel label6;
+ private JScrollPane scrollPane1;
+ private JList list1;
private JButton button1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
View
28 gui/SettingsGUI.jfd
@@ -1,4 +1,4 @@
-JFDML JFormDesigner: "5.1.0.0.47" Java: "1.6.0_23" encoding: "UTF-8"
+JFDML JFormDesigner: "5.1.0.0.47" Java: "1.6.0_24" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -13,8 +13,8 @@ new FormModel {
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane1"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) {
- "$horizontalGroup": "par l {seq {space :::p, par l {seq t {par l {comp label1::t:p:158:p, comp label2::t:::x, comp label3::t:::x, comp label5::l:p:158:p}, space u:::p, par t:::p {comp textField4::l:::x, comp textField1::l::192:x:1, comp textField2::l::192:x:1, comp textField3::l:::x:1}, space :::p}, seq l {comp label4::::376:x, space :p:4:p}, seq l {comp label6:::p:349:p, space ::23:x}}}}"
- "$verticalGroup": "par l {seq {par l {seq {space :10:10:10, comp label1:::p:28:p}, seq l {space :::p, comp textField1:::p::p}}, space :::p, par b {comp label2::b:p:28:p, comp textField2::b:p::p}, space :::p, par b {comp label3::b:p:25:p, comp textField3::b:p:28:p}, space :::p, par b {comp label5::b::25:x:1, comp textField4::b:p::p:1}, space s:::p, comp label4:::p:27:p, space :p:2:p, comp label6:::p::p, space :::p}}"
+ "$horizontalGroup": "par l {seq {space :::p, comp label4::::367:x, space :::p}, seq {par t:::p {comp label1::l::132:x, comp label2::t::132:x, comp label3::t::132:x}, space :::p, par t:::p {comp textField1::::132:x:1, comp textField2::t::132:x:1, comp textField3::t::132:x:1}, space :::x, comp scrollPane1:::p:109:p}}"
+ "$verticalGroup": "par l {seq {par l {seq {space :p:10:p, par b {comp label1::b:p:28:p, comp textField1::b:p::p}, space u:::p, par b {comp textField2::b:p::p, comp label2::b:p:28:p}, space u:::p, par b {comp textField3::b:p:28:p, comp label3::b:p:25:p}}, comp scrollPane1:::p::p}, space s:::p, comp label4:::p:27:p, space ::21:x}}"
} ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -48,17 +48,13 @@ new FormModel {
"text": "You can see the change when you have restart!"
"horizontalTextPosition": 0
} )
- add( new FormComponent( "javax.swing.JLabel" ) {
- name: "label5"
- "text": "Icon Set"
- "horizontalAlignment": 11
- } )
- add( new FormComponent( "javax.swing.JTextField" ) {
- name: "textField4"
- } )
- add( new FormComponent( "javax.swing.JLabel" ) {
- name: "label6"
- "text": "\"orginal\", \"juan\" and \"blind\" are pre installed"
+ add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
+ name: "scrollPane1"
+ add( new FormComponent( "javax.swing.JList" ) {
+ name: "list1"
+ "selectionMode": 0
+ addEvent( new FormEvent( "javax.swing.event.ListSelectionListener", "valueChanged", "list1ValueChanged", true ) )
+ } )
} )
}, new FormLayoutConstraints( null ) {
"title": "Images"
@@ -74,8 +70,8 @@ new FormModel {
"hAlign": 4
} )
}, new FormLayoutConstraints( null ) {
- "location": new java.awt.Point( 0, 5 )
- "size": new java.awt.Dimension( 400, 300 )
+ "location": new java.awt.Point( 0, 15 )
+ "size": new java.awt.Dimension( 400, 290 )
} )
}
}
View
2 util/Util.java
@@ -1,5 +1,7 @@
package util;
+
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
View
28 util/list.java
@@ -0,0 +1,28 @@
+package util;
+
+import java.io.File;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+
+public class list {
+ public static JList addelements(JList list,String compare, String Dir,String files)
+ {
+ int index=0;
+ int now = 0;
+ DefaultListModel listModel = new DefaultListModel();
+ File dir = new File(Dir);
+ File[] fileList = dir.listFiles();
+ for(File f : fileList) {
+ if (f.getName().endsWith(files))
+ {
+ listModel.addElement(f.getName().subSequence(0,f.getName().length()-files.length()));
+ if ((f.getName().subSequence(0,f.getName().length()-files.length())).equals(compare))
+ {now=index+1;}
+ index++;
+ }}
+ list.setModel(listModel);
+ if (now != 0){list.setSelectedIndex(now-1);}
+ return list;
+ }
+}

0 comments on commit 122652f

Please sign in to comment.