Revision: 3921
Author: [email protected]
Date: Wed Aug 25 09:10:43 2010
Log: Fixed PlayPenLabel dragging. It now correctly drags on an initial
mouse pressed event.
http://code.google.com/p/power-architect/source/detail?r=3921
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenLabel.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
Tue Aug 10 14:52:03 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
Wed Aug 25 09:10:43 2010
@@ -139,7 +139,7 @@
@Override
public void handleMouseEvent(MouseEvent evt) {
PlayPen pp = getPlayPen();
-
+
Point p = evt.getPoint();
pp.unzoomPoint(p);
p.translate(-getX(), -getY());
@@ -155,9 +155,9 @@
deselectItem(selectedItemIndex);
fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.DESELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
} else {
- selectNone();
- selectItem(selectedItemIndex);
- fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.SELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
+ selectNone();
+ selectItem(selectedItemIndex);
+ fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.SELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
}
} else if (isSelected() && componentPreviouslySelected) {
setSelected(false, SelectionEvent.SINGLE_SELECT);
@@ -188,7 +188,7 @@
//This is since dragging columns within the same table
does
// not update the previouslySelectedItem
if (isItemSelected(previousSelectedItem)) {
- previousSelectedIndex =
getItems().indexOf(previousSelectedItem);
+ previousSelectedIndex =
getItems().indexOf(previousSelectedItem);
} else {
previousSelectedIndex = getSelectedItemIndex();
}
@@ -200,26 +200,26 @@
}
pp.setMouseMode(MouseModeType.SELECT_ITEM);
} else if (((evt.getModifiersEx() &
InputEvent.SHIFT_DOWN_MASK) != 0) && getSelectedItems().size() > 0 &&
- previousSelectedIndex > ITEM_INDEX_TITLE) {
- int start = Math.min(previousSelectedIndex, clickItem);
- int end = Math.max(previousSelectedIndex, clickItem);
- logger.debug("Start: " +start+ " , End: " +end+ " ,
Total size: " +getItems().size());
- for (int i = 0; i < getItems().size(); i++) {
- if (i > start && i < end ) {
- selectItem(i);
- fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.SELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
+ previousSelectedIndex > ITEM_INDEX_TITLE) {
+ int start = Math.min(previousSelectedIndex,
clickItem);
+ int end = Math.max(previousSelectedIndex,
clickItem);
+ logger.debug("Start: " +start+ " , End: "
+end+ " , Total size: " +getItems().size());
+ for (int i = 0; i < getItems().size(); i++) {
+ if (i > start && i < end ) {
+ selectItem(i);
+ fireSelectionEvent(new
SelectionEvent(this, SelectionEvent.SELECTION_EVENT,
SelectionEvent.SINGLE_SELECT));
+ }
}
}
- }
-
- if (isItemSelected(clickItem)) {
- componentPreviouslySelected = true;
- } else {
- selectItem(clickItem);
- fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.SELECTION_EVENT,SelectionEvent.SINGLE_SELECT));
- repaint();
- previousSelectedItem = getItems().get(clickItem);
- }
+
+ if (isItemSelected(clickItem)) {
+ componentPreviouslySelected = true;
+ } else {
+ selectItem(clickItem);
+ fireSelectionEvent(new SelectionEvent(this,
SelectionEvent.SELECTION_EVENT,SelectionEvent.SINGLE_SELECT));
+ repaint();
+ previousSelectedItem = getItems().get(clickItem);
+ }
}
if (isSelected()&& clickItem == ITEM_INDEX_TITLE){
componentPreviouslySelected = true;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenLabel.java
Tue Aug 10 14:52:03 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenLabel.java
Wed Aug 25 09:10:43 2010
@@ -181,8 +181,17 @@
setSelected(true, SelectionEvent.SINGLE_SELECT);
}
}
- } else if (evt.getID() == MouseEvent.MOUSE_PRESSED
&& !pp.getSession().getArchitectFrame().createRelationshipIsActive()) {
- setupDrag(p);
+ } else if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
+ if (isSelected()){
+ componentPreviouslySelected = true;
+ } else {
+ componentPreviouslySelected = false;
+ setSelected(true, SelectionEvent.SINGLE_SELECT);
+ }
+
+ if
(!pp.getSession().getArchitectFrame().createRelationshipIsActive()) {
+ setupDrag(p);
+ }
} else if (evt.getID() == MouseEvent.MOUSE_MOVED || evt.getID() ==
MouseEvent.MOUSE_DRAGGED) {
setSelected(pp.rubberBand.intersects(getBounds(new
Rectangle())),SelectionEvent.SINGLE_SELECT);
}