diff --git a/src/org/idp/laf/Color.java b/src/org/idp/laf/Color.java index 656c867..c5083e8 100644 --- a/src/org/idp/laf/Color.java +++ b/src/org/idp/laf/Color.java @@ -42,6 +42,7 @@ public class Color implements Serializable{ int A; String pname; ColorClass cls; + String description; public Color(javax.swing.plaf.ColorUIResource color) { @@ -51,24 +52,26 @@ public class Color implements Serializable{ this.R = color.getRed(); this.pname = "_"; this.cls = SF; + this.description = ""; } - public Color(String pname, ColorClass cls, int red, int green, int blue, int alpha) { + public Color(String pname, ColorClass cls, int red, int green, int blue, int alpha, String desc) { this.A = alpha; this.B = blue; this.G = green; this.R = red; this.pname = pname; this.cls = cls; + this.description = desc; } @Override public String toString() { - return "C[" + this.pname + ":" + this.cls + ":" + R + "," + G + "," + B + "," + A + "]"; + return this.pname; } public String toStringC() { - return "[" + this.pname + ":" + this.cls + ":" + R + "," + G + "," + B + "," + A + "]"; + return "C[" + this.pname + ":" + this.cls + ":" + R + "," + G + "," + B + "," + A + ":" + description + "]"; } public Color (String str) @@ -99,6 +102,8 @@ public class Color implements Serializable{ this.G = Integer.parseInt(vals[1]); this.B = Integer.parseInt(vals[2]); this.A = Integer.parseInt(vals[3]); + + this.description = vals[3]; } else @@ -134,5 +139,45 @@ public class Color implements Serializable{ public Object getName() { return this.pname; } + + public String getDescription() { + return description; + } + + public void setA(int A) { + this.A = A; + } + + public void setB(int B) { + this.B = B; + } + + public void setG(int G) { + this.G = G; + } + + public void setR(int R) { + this.R = R; + } + + public void setDescription(String description) { + this.description = description; + } + + public Color() { + } + + public String getPname() { + return pname; + } + public void setObject ( java.awt.Color obj) + { + this.A = obj.getAlpha(); + this.B = obj.getBlue(); + this.G = obj.getGreen(); + this.R = obj.getRed(); + } + } + diff --git a/src/org/idp/laf/Kernel.java b/src/org/idp/laf/Kernel.java index 1842cd9..2ac0967 100644 --- a/src/org/idp/laf/Kernel.java +++ b/src/org/idp/laf/Kernel.java @@ -20,6 +20,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Random; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -34,6 +35,8 @@ import org.openide.windows.WindowManager; */ public class Kernel { + private static final String scheme_file_name = "netbeans.idp_scheme"; + public static void load_kernel () { if (prepare_metal_laf ()) @@ -127,7 +130,7 @@ public class Kernel { private static boolean load_setup (String nb_etc) { - File scheme_file = new File(nb_etc + File.separator + ".idp_scheme"); + File scheme_file = new File(nb_etc + File.separator + scheme_file_name); String path = scheme_file.getAbsolutePath(); if (!scheme_file.exists()) @@ -150,6 +153,29 @@ public class Kernel { } + private static Random rand = new Random(System.currentTimeMillis()); + + public static void save () + { + String nb_etc = retrieve_netbeans_etc_dir(); + File scheme_file = new File(nb_etc + File.separator + scheme_file_name); + String path = scheme_file.getAbsolutePath(); + save_scheme (path); + } + + public static void reload () + { + String nb_etc = retrieve_netbeans_etc_dir(); + File scheme_file = new File(nb_etc + File.separator + scheme_file_name); + String path = scheme_file.getAbsolutePath(); + read_scheme (path); + } + + public static void load (String path) + { + read_scheme (path); + } + private static boolean save_scheme(String scheme_file) { ArrayList color_map = new ArrayList(); @@ -162,22 +188,25 @@ public class Kernel { if (o.getClass().equals(javax.swing.plaf.ColorUIResource.class)) { ColorUIResource oo = (ColorUIResource) o; - Color c = new Color(Keys.color_keys[i], Color.ColorClass.SF, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha()); + Color c = new Color(Keys.color_keys[i], Color.ColorClass.SF, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha(),"..."); color_map.add(c); //System.out.println( "\"" + Keys.color_keys[i] + "\","); } else if (o.getClass().equals(java.awt.Color.class)) { java.awt.Color oo = (java.awt.Color) o; - Color c = new Color(Keys.color_keys[i], Color.ColorClass.AT, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha()); + Color c = new Color(Keys.color_keys[i], Color.ColorClass.AT, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha(),"..."); color_map.add(c); //System.out.println( "\"" + Keys.color_keys[i] + "\","); } } -// else -// { -// System.out.println( " \"" + Keys.color_keys[i] + "\","); -// } + else + { + ColorUIResource oo = new ColorUIResource(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); + Color c = new Color(Keys.color_keys[i], Color.ColorClass.SF, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha(),"..."); + color_map.add(c); + //System.out.println( " \"" + Keys.color_keys[i] + "\","); + } } try @@ -185,7 +214,7 @@ public class Kernel { PrintWriter writer = new PrintWriter(scheme_file , "UTF-8"); for (int i = 0; i < color_map.size(); i ++) { - writer.println(color_map.get(i)); + writer.println(color_map.get(i).toStringC()); } writer.close(); return true; @@ -203,6 +232,8 @@ public class Kernel { } + public static Color[] color_scheme_loaded; + private static boolean read_scheme(String scheme_file) { try @@ -215,12 +246,12 @@ public class Kernel { color_map.add(new Color (s)); } - for (int i = 0; i < color_map.size(); i ++) - { - UIManager.put(color_map.get(i).getName(), color_map.get(i).getObject()); - } + - repaintUI(); + color_scheme_loaded = new Color[color_map.size()]; + color_map.toArray(color_scheme_loaded); + + reloadUI(); return true; } @@ -231,8 +262,16 @@ public class Kernel { } } + public static void reloadUI() + { + for (int i = 0; i < color_scheme_loaded.length; i ++) + { + UIManager.put(color_scheme_loaded[i].getName(), color_scheme_loaded[i].getObject()); + } + repaintUI(); + } - public static void repaintUI() + private static void repaintUI() { SwingUtilities.updateComponentTreeUI(WindowManager.getDefault().getMainWindow()); WindowManager.getDefault().getMainWindow().pack(); @@ -255,5 +294,9 @@ public class Kernel { bw.close(); } + + public static Color[] getColors() { + return color_scheme_loaded; + } } diff --git a/src/org/idp/laf/Keys.java b/src/org/idp/laf/Keys.java index fb9a852..5e7adf3 100644 --- a/src/org/idp/laf/Keys.java +++ b/src/org/idp/laf/Keys.java @@ -10,7 +10,7 @@ package org.idp.laf; */ public class Keys { - public static String [] color_keys = + public static final String [] color_keys = { "Button.background", "Button.darkShadow", @@ -296,7 +296,7 @@ public class Keys { }; - private static String [] keys = { "AbstractButton.clickText", + private static final String [] keys = { "AbstractButton.clickText", "AbstractDocument.additionText", "AbstractDocument.deletionText", "AbstractDocument.redoText", diff --git a/src/org/idp/laf/gui/Bundle.properties b/src/org/idp/laf/gui/Bundle.properties index 03671be..7c1c4e2 100644 --- a/src/org/idp/laf/gui/Bundle.properties +++ b/src/org/idp/laf/gui/Bundle.properties @@ -3,3 +3,18 @@ # and open the template in the editor. Editor.title=[idp!] Color Editor +ColorEditorTopComponent.jTextField1.text=jTextField1 +ColorEditorTopComponent.jPanel2.border.title=Color List +ColorEditorTopComponent.jPanel4.border.title=Color Settings +ColorEditorTopComponent.jLabel1.text=HEX: +ColorEditorTopComponent.jLabel2.text=RED: +ColorEditorTopComponent.jLabel3.text=GREEN: +ColorEditorTopComponent.jLabel4.text=BLUE: +ColorEditorTopComponent.color_hex.text_1=jTextField1 +ColorEditorTopComponent.color_R.text=jTextField2 +ColorEditorTopComponent.color_G.text=jTextField3 +ColorEditorTopComponent.color_B.text=jTextField4 +ColorEditorTopComponent.test_mode.text=Pink Daemon Mode +ColorEditorTopComponent.save_btn.text=Write Scheme +ColorEditorTopComponent.reload_btn.text=Reload Scheme +ColorEditorTopComponent.load_btn.text=Load Scheme from File diff --git a/src/org/idp/laf/gui/ColorEditorTopComponent.form b/src/org/idp/laf/gui/ColorEditorTopComponent.form index 5f3eab1..452f37b 100644 --- a/src/org/idp/laf/gui/ColorEditorTopComponent.form +++ b/src/org/idp/laf/gui/ColorEditorTopComponent.form @@ -16,13 +16,277 @@ - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/idp/laf/gui/ColorEditorTopComponent.java b/src/org/idp/laf/gui/ColorEditorTopComponent.java index 4ad1b49..95c0f70 100644 --- a/src/org/idp/laf/gui/ColorEditorTopComponent.java +++ b/src/org/idp/laf/gui/ColorEditorTopComponent.java @@ -5,11 +5,18 @@ */ package org.idp.laf.gui; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; +import javax.swing.plaf.ColorUIResource; +import org.idp.laf.Color; +import org.idp.laf.Kernel; import org.netbeans.api.settings.ConvertAsProperties; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.windows.TopComponent; import org.openide.util.NbBundle.Messages; +import sun.swing.PrintColorUIResource; /** * @author Edward M. Kagan @@ -59,25 +66,486 @@ public final class ColorEditorTopComponent extends TopComponent { // //GEN-BEGIN:initComponents private void initComponents() { + jPanel2 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + color_list = new javax.swing.JList(); + jPanel4 = new javax.swing.JPanel(); + color_preview_panel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + color_hex = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + color_R = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + color_G = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + color_B = new javax.swing.JTextField(); + reload_btn = new javax.swing.JButton(); + save_btn = new javax.swing.JButton(); + load_btn = new javax.swing.JButton(); + test_mode = new javax.swing.JToggleButton(); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jPanel2.border.title"))); // NOI18N + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS)); + + color_list.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public Object getElementAt(int i) { return strings[i]; } + }); + color_list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + color_list.setName("color_list"); // NOI18N + color_list.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + color_listValueChanged(evt); + } + }); + jScrollPane1.setViewportView(color_list); + + jPanel2.add(jScrollPane1); + + jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jPanel4.border.title"))); // NOI18N + jPanel4.setMaximumSize(new java.awt.Dimension(270, 32767)); + jPanel4.setMinimumSize(new java.awt.Dimension(270, 100)); + jPanel4.setPreferredSize(new java.awt.Dimension(270, 253)); + + color_preview_panel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true)); + + javax.swing.GroupLayout color_preview_panelLayout = new javax.swing.GroupLayout(color_preview_panel); + color_preview_panel.setLayout(color_preview_panelLayout); + color_preview_panelLayout.setHorizontalGroup( + color_preview_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 234, Short.MAX_VALUE) + ); + color_preview_panelLayout.setVerticalGroup( + color_preview_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 159, Short.MAX_VALUE) + ); + + jPanel1.setLayout(new java.awt.GridLayout(4, 2, 5, 5)); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jLabel1.text")); // NOI18N + jPanel1.add(jLabel1); + + color_hex.setText(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.color_hex.text_1")); // NOI18N + color_hex.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + color_hexFocusLost(evt); + } + }); + color_hex.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + color_hexActionPerformed(evt); + } + }); + jPanel1.add(color_hex); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jLabel2.text")); // NOI18N + jPanel1.add(jLabel2); + + color_R.setText(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.color_R.text")); // NOI18N + color_R.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + color_RFocusLost(evt); + } + }); + color_R.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + color_RActionPerformed(evt); + } + }); + jPanel1.add(color_R); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jLabel3.text")); // NOI18N + jPanel1.add(jLabel3); + + color_G.setText(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.color_G.text")); // NOI18N + color_G.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + color_GFocusLost(evt); + } + }); + color_G.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + color_GActionPerformed(evt); + } + }); + jPanel1.add(color_G); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.jLabel4.text")); // NOI18N + jPanel1.add(jLabel4); + + color_B.setText(org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.color_B.text")); // NOI18N + color_B.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + color_BFocusLost(evt); + } + }); + color_B.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + color_BActionPerformed(evt); + } + }); + jPanel1.add(color_B); + + org.openide.awt.Mnemonics.setLocalizedText(reload_btn, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.reload_btn.text")); // NOI18N + reload_btn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + reload_btnActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(save_btn, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.save_btn.text")); // NOI18N + save_btn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + save_btnActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(load_btn, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.load_btn.text")); // NOI18N + load_btn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + load_btnActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(test_mode, org.openide.util.NbBundle.getMessage(ColorEditorTopComponent.class, "ColorEditorTopComponent.test_mode.text")); // NOI18N + test_mode.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + test_modeStateChanged(evt); + } + }); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) + .addComponent(color_preview_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(save_btn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(reload_btn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(load_btn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(test_mode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(color_preview_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(test_mode, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(save_btn) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(reload_btn) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(load_btn) + .addContainerGap()) + ); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)) + .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE)) + .addContainerGap()) ); }// //GEN-END:initComponents + private void color_listValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_color_listValueChanged + + Color sel_col = (Color) this.color_list.getSelectedValue(); + if (sel_col != null) + { + if (sel_col.getObject().getClass() == ColorUIResource.class) + { + ColorUIResource col = (ColorUIResource) sel_col.getObject(); + update_preview (col); + this.color_R.setText(String.valueOf (col.getRed())); + this.color_G.setText(String.valueOf (col.getGreen())); + this.color_B.setText(String.valueOf (col.getBlue())); + this.color_hex.setText(String.format("#%06X", (0xFFFFFF & col.getRGB()))); + } + else + { + java.awt.Color col = (java.awt.Color) sel_col.getObject(); + update_preview (col); + this.color_R.setText(String.valueOf (col.getRed())); + this.color_G.setText(String.valueOf (col.getGreen())); + this.color_B.setText(String.valueOf (col.getBlue())); + this.color_hex.setText(String.format("#%06X", (0xFFFFFF & col.getRGB()))); + } + } + + }//GEN-LAST:event_color_listValueChanged + + private void update_preview (java.awt.Color col) + { + this.color_preview_panel.setBackground(col); + this.color_preview_panel.repaint(); + } + + private void color_hexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_color_hexActionPerformed + + try + { + Color sel_col = (Color) this.color_list.getSelectedValue(); + java.awt.Color tmp = java.awt.Color.decode(this.color_hex.getText()); + sel_col.setR(tmp.getRed()); + sel_col.setG(tmp.getGreen()); + sel_col.setB(tmp.getBlue()); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) sel_col.getObject()); + } + catch (NumberFormatException ex) + { + + } + }//GEN-LAST:event_color_hexActionPerformed + + private void color_RActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_color_RActionPerformed + try + { + int newP = Integer.parseInt(this.color_R.getText()); + Color sel_col = (Color) this.color_list.getSelectedValue(); + if (newP > 255) + { + this.color_R.setText("255"); + newP = 255; + } + if (newP < 0) + { + this.color_R.setText("0"); + newP = 0; + } + + sel_col.setR(newP); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) sel_col.getObject()); + } + catch (NumberFormatException ex) + { + + } + }//GEN-LAST:event_color_RActionPerformed + + private void color_GActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_color_GActionPerformed + try + { + int newP = Integer.parseInt(this.color_G.getText()); + if (newP > 255) + { + this.color_G.setText("255"); + newP = 255; + } + if (newP < 0) + { + this.color_G.setText("0"); + newP = 0; + } + Color sel_col = (Color) this.color_list.getSelectedValue(); + sel_col.setG(newP); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) sel_col.getObject()); + } + catch (NumberFormatException ex) + { + + } + }//GEN-LAST:event_color_GActionPerformed + + private void color_BActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_color_BActionPerformed + try + { + int newP = Integer.parseInt(this.color_B.getText()); + if (newP > 255) + { + this.color_B.setText("255"); + newP = 255; + } + if (newP < 0) + { + this.color_B.setText("0"); + newP = 0; + } + Color sel_col = (Color) this.color_list.getSelectedValue(); + sel_col.setB(newP); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) sel_col.getObject()); + } + catch (NumberFormatException ex) + { + + } + }//GEN-LAST:event_color_BActionPerformed + + private final Color test_color = new Color(new ColorUIResource(java.awt.Color.PINK)); + + private void test_modeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_test_modeStateChanged + if (this.test_mode.isSelected()) + { + this.color_list.setEnabled(false); + + this.color_hex.setEnabled(false); + this.color_R.setEnabled(false); + this.color_G.setEnabled(false); + this.color_B.setEnabled(false); + + this.save_btn.setEnabled(false); + this.load_btn.setEnabled(false); + this.reload_btn.setEnabled(false); + + + Color real = (Color) this.color_list.getSelectedValue(); + java.awt.Color cc = (java.awt.Color) real.getObject(); + java.awt.Color test = (java.awt.Color) test_color.getObject(); + + real.setObject(test); + test_color.setObject(cc); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) real.getObject()); + } + else + { + this.color_list.setEnabled(true); + + this.color_hex.setEnabled(true); + this.color_R.setEnabled(true); + this.color_G.setEnabled(true); + this.color_B.setEnabled(true); + + this.save_btn.setEnabled(true); + this.load_btn.setEnabled(true); + this.reload_btn.setEnabled(true); + + Color real = (Color) this.color_list.getSelectedValue(); + java.awt.Color cc = (java.awt.Color) real.getObject(); + java.awt.Color test = (java.awt.Color) test_color.getObject(); + + real.setObject(test); + test_color.setObject(cc); + color_listValueChanged (null); + Kernel.reloadUI(); + update_preview ((java.awt.Color) real.getObject()); + + } + }//GEN-LAST:event_test_modeStateChanged + + private void color_hexFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_color_hexFocusLost + color_hexActionPerformed (null); + }//GEN-LAST:event_color_hexFocusLost + + private void color_RFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_color_RFocusLost + color_RActionPerformed (null); + }//GEN-LAST:event_color_RFocusLost + + private void color_GFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_color_GFocusLost + color_GActionPerformed (null); + }//GEN-LAST:event_color_GFocusLost + + private void color_BFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_color_BFocusLost + color_BActionPerformed (null); + }//GEN-LAST:event_color_BFocusLost + + private void save_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_btnActionPerformed + Kernel.save(); + }//GEN-LAST:event_save_btnActionPerformed + + private void reload_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reload_btnActionPerformed + Kernel.reload(); + reload_list(); + }//GEN-LAST:event_reload_btnActionPerformed + + private void load_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_load_btnActionPerformed + + JFileChooser loadFile = new JFileChooser();//new dialog + loadFile.setFileSelectionMode(JFileChooser.FILES_ONLY); + loadFile.setFileFilter(new FileFilter() { + + @Override + public boolean accept(File file) { + return file.getName().toLowerCase().endsWith("idp_scheme"); + } + + @Override + public String getDescription() { + return ("[idP!] Crew Netbeans Color Scheme File"); + } + }); + + + if (loadFile.showOpenDialog(this)==JFileChooser.APPROVE_OPTION) + { + if (loadFile.getSelectedFile() != null) + { + File scheme_file = loadFile.getSelectedFile(); + Kernel.load(scheme_file.getAbsolutePath()); + reload_list(); + } + } + + +// TODO add your handling code here: + }//GEN-LAST:event_load_btnActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField color_B; + private javax.swing.JTextField color_G; + private javax.swing.JTextField color_R; + private javax.swing.JTextField color_hex; + private javax.swing.JList color_list; + private javax.swing.JPanel color_preview_panel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton load_btn; + private javax.swing.JButton reload_btn; + private javax.swing.JButton save_btn; + private javax.swing.JToggleButton test_mode; // End of variables declaration//GEN-END:variables @Override public void componentOpened() { - // TODO add custom code on component opening + reload_list(); } + private void reload_list () + { + Color[] colors = Kernel.getColors (); + + this.color_list.setListData(colors); + this.color_list.setSelectedIndex(0); + } + @Override public void componentClosed() { // TODO add custom code on component closing