Author: jfuerth
Date: Tue Apr  7 15:02:18 2009
New Revision: 2978

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

Log:
Fixed a test suite failure caused by the red->orange change. The test now no longer uses a hardcoded expected colour for column highlight.

Also changed to the BREWER19 colour scheme for relationship colour suggestion and cleaned up some of the code that sets it up (it was using background colours before, which were too light for the thin relationship lines to be visible especially when zoomed out).

Modified: trunk/regress/ca/sqlpower/architect/swingui/TestRelationship.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestRelationship.java (original) +++ trunk/regress/ca/sqlpower/architect/swingui/TestRelationship.java Tue Apr 7 15:02:18 2009
@@ -18,7 +18,6 @@
  */
 package ca.sqlpower.architect.swingui;

-import java.awt.Color;
 import java.awt.Point;
 import java.sql.Types;

@@ -70,8 +69,8 @@
        
public void testHighlightWithRelationshipTypeChange() throws SQLObjectException {
         rel.setSelected(true,SelectionEvent.SINGLE_SELECT);
-        assertEquals(Color.RED,tp1.getColumnHighlight(0));
-        assertEquals(Color.RED,tp2.getColumnHighlight(1));
+ assertEquals(rel.getColumnHighlightColour(), tp1.getColumnHighlight(0)); + assertEquals(rel.getColumnHighlightColour(), tp2.getColumnHighlight(1));
         assertEquals(tp2.getForegroundColor(), tp2.getColumnHighlight(0));
         rel.setSelected(false,SelectionEvent.SINGLE_SELECT);

@@ -82,10 +81,10 @@
         rel.setSelected(true,SelectionEvent.SINGLE_SELECT);
         rel.getModel().setIdentifying(true);

-        assertEquals(Color.RED,tp1.getColumnHighlight(0));
+ assertEquals(rel.getColumnHighlightColour(), tp1.getColumnHighlight(0));
         SQLColumn fkCol = tp2.getModel().getColumnByName("fkcol");
         assertEquals(0, tp2.getModel().getColumnIndex(fkCol));
-        assertEquals(Color.RED,tp2.getColumnHighlight(0));
+ assertEquals(rel.getColumnHighlightColour(), tp2.getColumnHighlight(0));
         assertEquals(tp2.getForegroundColor(), tp2.getColumnHighlight(1));
     }


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 Tue Apr 7 15:02:18 2009
@@ -28,7 +28,9 @@
 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 javax.swing.AbstractAction;
 import javax.swing.Icon;
@@ -55,10 +57,19 @@
 import ca.sqlpower.sqlobject.SQLRelationship.ColumnMapping;
 import ca.sqlpower.swingui.ColorIcon;
 import ca.sqlpower.swingui.ColourScheme;
+import ca.sqlpower.util.WebColour;

public class Relationship extends PlayPenComponent implements SQLObjectListener, LayoutEdge {
        private static final Logger logger = 
Logger.getLogger(Relationship.class);

+       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()]);
+       }
+       
     private SQLRelationship model;
        private TablePane pkTable;
        private TablePane fkTable;
@@ -154,17 +165,16 @@
         popup.add(setFocusToRelatedTables);

JMenu setRelationshipLineColor = new JMenu(Messages.getString("Relationship.relationshipLineColor")); //$NON-NLS-1$
-        for (final Color color : ColourScheme.RELATIONSHIP_LINE_COLOURS) {
+        for (final Color color : SUGGESTED_COLOURS) {
             Icon icon = new ColorIcon(60, 25, color);
             mi = new JMenuItem(icon);
             mi.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
- getPlayPen().startCompoundEdit("Started setting the relationship line colour"); //$NON-NLS-1$ + getPlayPen().startCompoundEdit("Set relationship line colour"); for (Relationship r : getPlayPen().getSelectedRelationShips()) {
-                        logger.info("relationship line: ");
                         r.setForegroundColor(color);
                     }
- getPlayPen().endCompoundEdit("Finished setting the relationship line colour"); //$NON-NLS-1$ + getPlayPen().endCompoundEdit("Set relationship line colour");
                 }
             });
             setRelationshipLineColor.add(mi);
@@ -435,6 +445,15 @@
                }
        }

+    /**
+ * Returns the colour that will be used to highlight columns participating
+     * in this relationship when this relationship is selected.
+     *
+     * @return
+     */
+       public Color getColumnHighlightColour() {
+        return columnHighlightColour;
+    }

        // ------------------ sqlobject listener ----------------
        public void dbChildrenInserted(SQLObjectEvent e) {

Modified: trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java Tue Apr 7 15:02:18 2009
@@ -42,7 +42,6 @@
 import ca.sqlpower.sqlobject.SQLRelationship.Deferrability;
 import ca.sqlpower.sqlobject.SQLRelationship.UpdateDeleteRule;
 import ca.sqlpower.swingui.ColorCellRenderer;
-import ca.sqlpower.swingui.ColourScheme;
 import ca.sqlpower.swingui.DataEntryPanel;

 import com.jgoodies.forms.builder.DefaultFormBuilder;
@@ -134,7 +133,7 @@
fb.append(Messages.getString("RelationshipEditPanel.name"), relationshipName = new JTextField(), 5); //$NON-NLS-1$

         fb.nextLine();
- fb.append(Messages.getString("RelationshipEditPanel.lineColour"), relationLineColor = new JComboBox(ColourScheme.RELATIONSHIP_LINE_COLOURS)); //$NON-NLS-1$ + fb.append(Messages.getString("RelationshipEditPanel.lineColour"), relationLineColor = new JComboBox(Relationship.SUGGESTED_COLOURS)); //$NON-NLS-1$
         ColorCellRenderer renderer = new ColorCellRenderer(40, 20);
         relationLineColor.setRenderer(renderer);

Reply via email to