You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by km...@apache.org on 2008/06/10 03:02:50 UTC
svn commit: r665943 - in /cayenne/main/trunk: docs/doc/src/main/resources/
framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/
framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/
Author: kmenard
Date: Mon Jun 9 18:02:50 2008
New Revision: 665943
URL: http://svn.apache.org/viewvc?rev=665943&view=rev
Log:
Fixed CAY-888: CM Usability: Object Select Query Improvements.
Modified:
cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java
Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=665943&r1=665942&r2=665943&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Mon Jun 9 18:02:50 2008
@@ -15,6 +15,7 @@
Changes/New Features Since M4:
+CAY-888 CM Usability: Object Select Query Improvements
CAY-911 CM Usability: JComboBox Autocompletion
CAY-1056 Detection of the project file changes on disk.
CAY-1055 Right-click contextual menu for entities/attributes/relationships that would include common operations, like "delete".
@@ -28,7 +29,7 @@
----------------------------------
Release: 3.0M4
-Date:
+Date: 05/29/2008
----------------------------------
Changes/New Features Since M3:
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java?rev=665943&r1=665942&r2=665943&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java Mon Jun 9 18:02:50 2008
@@ -24,6 +24,8 @@
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Iterator;
import javax.swing.JButton;
@@ -49,6 +51,8 @@
import org.apache.cayenne.modeler.util.ModelerUtil;
import org.apache.cayenne.modeler.util.MultiColumnBrowser;
import org.apache.cayenne.modeler.util.UIUtil;
+import org.apache.cayenne.pref.Domain;
+import org.apache.cayenne.pref.PreferenceDetail;
import org.apache.cayenne.query.Ordering;
import org.apache.cayenne.query.Query;
import org.apache.cayenne.query.SelectQuery;
@@ -59,8 +63,11 @@
*
* @author Andrus Adamchik
*/
-public class SelectQueryOrderingTab extends JPanel {
+public class SelectQueryOrderingTab extends JPanel implements PropertyChangeListener {
+ //property for split pane divider size
+ private static final String SPLIT_DIVIDER_LOCATION_PROPERTY = "query.orderings.divider.location";
+
static final Dimension BROWSER_CELL_DIM = new Dimension(150, 100);
static final Dimension TABLE_DIM = new Dimension(460, 60);
@@ -91,13 +98,21 @@
messagePanel = new JPanel(new BorderLayout());
cardLayout = new CardLayout();
+
+ PreferenceDetail detail = getDomain().
+ getDetail(getDividerLocationProperty(), false);
+
+ int defLocation = Application.getFrame().getHeight() / 2;
+ int location = detail != null ?
+ detail.getIntProperty(getDividerLocationProperty(), defLocation) : defLocation;
/**
* As of CAY-888 #3 main pane is now a JSplitPane.
* Top component is a bit larger.
*/
JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- mainPanel.setDividerLocation(Application.getFrame().getHeight() / 2);
+ mainPanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
+ mainPanel.setDividerLocation(location);
mainPanel.setTopComponent(createEditorPanel());
mainPanel.setBottomComponent(createSelectorPanel());
@@ -368,4 +383,29 @@
}
}
+
+ /**
+ * Updates split pane divider location in properties
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) {
+ int value = (Integer) evt.getNewValue();
+
+ PreferenceDetail detail = getDomain().
+ getDetail(getDividerLocationProperty(), true);
+ detail.setIntProperty(getDividerLocationProperty(), value);
+ }
+ }
+
+ /**
+ * Returns name of a property for divider location.
+ */
+ protected String getDividerLocationProperty() {
+ return SPLIT_DIVIDER_LOCATION_PROPERTY;
+ }
+
+ protected Domain getDomain() {
+ //note: getClass() returns different values for Orderings and Prefetches tabs
+ return Application.getInstance().getPreferenceDomain().getSubdomain(getClass());
+ }
}
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java?rev=665943&r1=665942&r2=665943&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java Mon Jun 9 18:02:50 2008
@@ -111,11 +111,65 @@
}
catch (ValidationException vex) {
textComponent.setBackground(errorColor);
- textComponent.setToolTipText(vex.getUnlabeledMessage());
+ textComponent.setToolTipText(wrapTooltip(vex.getUnlabeledMessage()));
}
}
/**
+ * Wraps the tooltip, making it multi-lined if needed.
+ * Current implementation uses HTML markup to break the lines
+ * @param tooltip single-line tooltip
+ * @return multi-line tooltip.
+ */
+ protected String wrapTooltip(String tooltip) {
+ tooltip = encodeHTMLAttribute(tooltip);
+ tooltip = tooltip.replaceAll(System.getProperty("line.separator"), "<br>");
+
+ return "<html>" + tooltip + "</html>";
+ }
+
+ /**
+ * Encodes a string so that it can be used as an attribute value in an HMTL document.
+ * Will do conversion of the greater/less signs and ampersands.
+ *
+ * ***
+ * This method is almost a copy of Util.encodeXmlAttribute(), but it does not replace
+ * single quotes. So only '<', '>', '&', '"' chars will be replaced.
+ */
+ public static String encodeHTMLAttribute(String str) {
+ if (str == null) {
+ return null;
+ }
+
+ int len = str.length();
+ if (len == 0) {
+ return str;
+ }
+
+ StringBuilder encoded = new StringBuilder();
+ for (int i = 0; i < len; i++) {
+ char c = str.charAt(i);
+ if (c == '<') {
+ encoded.append("<");
+ }
+ else if (c == '\"') {
+ encoded.append(""");
+ }
+ else if (c == '>') {
+ encoded.append(">");
+ }
+ else if (c == '&') {
+ encoded.append("&");
+ }
+ else {
+ encoded.append(c);
+ }
+ }
+
+ return encoded.toString();
+ }
+
+ /**
* Listener to user input, which fires validation timer
*/
class TimerScheduler implements DocumentListener, FocusListener {