Author: daceywang
Date: Mon Apr 27 15:07:57 2009
New Revision: 3019

Modified:
   trunk/src/ca/sqlpower/architect/swingui/Relationship.java

Log:
This is a fix to the forum bug post about relationship line color on Windows machine. The problem was our Color Set doesn't include the default foreground color on Windows, so the color selector in RelationshipEditPanel picks up its first item, which is Red. Now add the color to our Color Set if it's not included.

The problem I haven't solved yet is this won't help if the file is created and saved on Windows and then use it on Mac.(the reason is we add color to our Color Set in the constructor, so getForegroundColor() method returns the general foreground instead of saved Windows Relationship foreground color) We can solve this problem by doing the same thing(add the color to our Color Set if it's not included) in the constructor of RelationshipEditPanel and createPop() of Relationship, but I don't think it's ideal. Any ideas?

Modified: trunk/src/ca/sqlpower/architect/swingui/Relationship.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/Relationship.java   (original)
+++ trunk/src/ca/sqlpower/architect/swingui/Relationship.java Mon Apr 27 15:07:57 2009
@@ -28,9 +28,8 @@
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
+import java.util.Vector;

 import javax.swing.AbstractAction;
 import javax.swing.Icon;
@@ -65,13 +64,12 @@
        public static final String PAREENT_TO_CHILD = "receives";
        public static final String CHILD_TO_PARENT = "is received by";

-       public static final WebColour[] SUGGESTED_COLOURS;
-       static {
-           List<WebColour> l = new ArrayList<WebColour>();
-           l.addAll(ColourScheme.BREWER_SET19);
-           l.add(new WebColour(0, 0, 0));
-           SUGGESTED_COLOURS = l.toArray(new WebColour[l.size()]);
-       }
+    public static final Vector<Color> SUGGESTED_COLOURS;
+    static {
+        SUGGESTED_COLOURS = new Vector<Color>();
+        SUGGESTED_COLOURS.addAll(ColourScheme.BREWER_SET19);
+        SUGGESTED_COLOURS.add(new WebColour(0, 0, 0));
+    }
        
     private SQLRelationship model;
        private TablePane pkTable;
@@ -146,8 +144,21 @@
                model.addSQLObjectListener(this);
                setToolTipText(model.getName());
                
-               // requires pkTable and fkTable to be initialized
-               //ui.bestConnectionPoints(); // breaks when loading a new 
project?
+               // Check whether the foreground color of this machine is in the
+        // set of our color set. Add the color if it is not included,
+        // do nothing otherwise.
+        boolean containForegroundColor = false;
+        for (final Color color : SUGGESTED_COLOURS) {
+            if (color.equals(this.getForegroundColor())) {
+                containForegroundColor = true;
+        }
+        }
+        if (!containForegroundColor) {
+            SUGGESTED_COLOURS.add(this.getForegroundColor());
+        }
+
+        // requires pkTable and fkTable to be initialized
+        //ui.bestConnectionPoints(); // breaks when loading a new project?
        }

        protected void createPopup() {

Reply via email to