You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2013/03/02 02:04:55 UTC
svn commit: r1451799 [3/3] - in /pivot/trunk:
core/src/org/apache/pivot/beans/ core/src/org/apache/pivot/collections/
core/src/org/apache/pivot/io/ core/src/org/apache/pivot/json/
core/src/org/apache/pivot/serialization/ core/src/org/apache/pivot/text/...
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java Sat Mar 2 01:04:53 2013
@@ -46,7 +46,7 @@ public class SpinnerItemRenderer extends
@Override
public void render(Object item, Spinner spinner) {
- setText(item == null ? null : item.toString());
+ setText(item != null ? item.toString() : "");
renderStyles(spinner);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellRenderer.java Sat Mar 2 01:04:53 2013
@@ -57,7 +57,7 @@ public class TableViewCellRenderer exten
text = toString(row, columnName);
}
- setText(text);
+ setText(text != null ? text : "");
}
protected void renderStyles(TableView tableView, boolean rowSelected, boolean rowDisabled) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderData.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderData.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderData.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderData.java Sat Mar 2 01:04:53 2013
@@ -18,8 +18,6 @@ package org.apache.pivot.wtk.content;
import java.net.URL;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.media.Image;
/**
@@ -69,19 +67,7 @@ public class TableViewHeaderData {
throw new IllegalArgumentException("iconURL is null.");
}
- Image iconLocal = (Image)ApplicationContext.getResourceCache().get(iconURL);
-
- if (iconLocal == null) {
- try {
- iconLocal = Image.load(iconURL);
- } catch (TaskExecutionException exception) {
- throw new IllegalArgumentException(exception);
- }
-
- ApplicationContext.getResourceCache().put(iconURL, iconLocal);
- }
-
- setIcon(iconLocal);
+ setIcon(Image.loadFromCache(iconURL));
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderDataRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderDataRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderDataRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewHeaderDataRenderer.java Sat Mar 2 01:04:53 2013
@@ -85,7 +85,7 @@ public class TableViewHeaderDataRenderer
}
// Show/hide the label
- label.setText(text);
+ label.setText(text != null ? text : "");
if (text == null) {
label.setVisible(false);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java Sat Mar 2 01:04:53 2013
@@ -357,7 +357,7 @@ public class TableViewMultiCellRenderer
&& valueClass != Object.class) {
cellRenderer = cellRenderers.get(valueClass);
- if (cellRenderer == null) {
+ if (cellRenderer == null && valueClass != null) {
valueClass = valueClass.getSuperclass();
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewTextAreaCellRenderer.java Sat Mar 2 01:04:53 2013
@@ -55,7 +55,7 @@ public class TableViewTextAreaCellRender
text = toString(row, columnName);
}
- setText(text == null ? "" : text);
+ setText(text != null ? text : "");
}
protected void renderStyles(TableView tableView, boolean rowSelected, boolean rowDisabled) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java Sat Mar 2 01:04:53 2013
@@ -26,8 +26,6 @@ import org.apache.pivot.collections.List
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.util.ImmutableIterator;
import org.apache.pivot.util.ListenerList;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.media.Image;
/**
@@ -76,27 +74,15 @@ public class TreeBranch extends TreeNode
* the cached value will be used. Otherwise, the icon will be loaded
* synchronously and added to the cache.
*
- * @param expandedIconURL
+ * @param iconURL
* The location of the expanded icon to set.
*/
- public void setExpandedIcon(URL expandedIconURL) {
- if (expandedIconURL == null) {
- throw new IllegalArgumentException("expandedIconURL is null.");
+ public void setExpandedIcon(URL iconURL) {
+ if (iconURL == null) {
+ throw new IllegalArgumentException("iconURL is null.");
}
- Image icon = (Image)ApplicationContext.getResourceCache().get(expandedIconURL);
-
- if (icon == null) {
- try {
- icon = Image.load(expandedIconURL);
- } catch (TaskExecutionException exception) {
- throw new IllegalArgumentException(exception);
- }
-
- ApplicationContext.getResourceCache().put(expandedIconURL, icon);
- }
-
- setExpandedIcon(icon);
+ setIcon(Image.loadFromCache(iconURL));
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeNode.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeNode.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeNode.java Sat Mar 2 01:04:53 2013
@@ -18,8 +18,6 @@ package org.apache.pivot.wtk.content;
import java.net.URL;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.media.Image;
/**
@@ -81,19 +79,7 @@ public class TreeNode {
throw new IllegalArgumentException("iconURL is null.");
}
- Image iconLocal = (Image)ApplicationContext.getResourceCache().get(iconURL);
-
- if (iconLocal == null) {
- try {
- iconLocal = Image.load(iconURL);
- } catch (TaskExecutionException exception) {
- throw new IllegalArgumentException(exception);
- }
-
- ApplicationContext.getResourceCache().put(iconURL, iconLocal);
- }
-
- setIcon(iconLocal);
+ setIcon(Image.loadFromCache(iconURL));
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java Sat Mar 2 01:04:53 2013
@@ -88,7 +88,8 @@ public class TreeViewNodeEditor extends
List<?> treeData = treeViewArgument.getTreeData();
TreeNode treeNode = (TreeNode)Sequence.Tree.get(treeData, pathArgument);
- textInput.setText(treeNode.getText());
+ String text = treeNode.getText();
+ textInput.setText(text != null ? text : "");
textInput.selectAll();
// Get the node bounds
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java Sat Mar 2 01:04:53 2013
@@ -100,7 +100,7 @@ public class TreeViewNodeRenderer extend
(treeView.isEnabled() && !disabled) ? 1.0f : 0.5f);
// Update the label
- label.setText(text);
+ label.setText(text != null ? text : "");
if (text == null) {
label.setVisible(false);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java Sat Mar 2 01:04:53 2013
@@ -338,19 +338,19 @@ public class ScaleDecorator implements D
// No-op
}
- public void repaint(Component component, int x, int y, int width, int height) {
+ public void repaint(final Component component, int x, int y, int width, int height) {
Container parent = component.getParent();
if (parent != null) {
int tx = getTranslatedX(component);
int ty = getTranslatedY(component);
- x = (int)((x * scaleX) + component.getX() + tx);
- y = (int)((y * scaleY) + component.getY() + ty);
- width = (int)Math.ceil(width * scaleX);
- height = (int)Math.ceil(height * scaleY);
+ int xUpdated = (int)((x * scaleX) + component.getX() + tx);
+ int yUpdated = (int)((y * scaleY) + component.getY() + ty);
+ int widthUpdated = (int)Math.ceil(width * scaleX);
+ int heightUpdated = (int)Math.ceil(height * scaleY);
- parent.repaint(x, y, width, height);
+ parent.repaint(xUpdated, yUpdated, widthUpdated, heightUpdated);
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java Sat Mar 2 01:04:53 2013
@@ -24,8 +24,6 @@ import java.net.URL;
import org.apache.pivot.json.JSONSerializer;
import org.apache.pivot.serialization.SerializationException;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Bounds;
import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.Component;
@@ -40,7 +38,7 @@ import org.apache.pivot.wtk.media.Image;
* Decorator that paints a watermark effect over a component.
*/
public class WatermarkDecorator implements Decorator {
- private float opacity = 0.075f;
+ private float opacity = 0.1f;
private double theta = Math.PI / 4;
private BoxPane boxPane = new BoxPane(Orientation.HORIZONTAL);
@@ -99,7 +97,7 @@ public class WatermarkDecorator implemen
Font font = (Font)label.getStyles().get("font");
label.getStyles().put("font", font.deriveFont(Font.BOLD, 60));
- label.setText(text);
+ label.setText(text != null ? text : "");
imageView.setImage(image);
validate();
@@ -122,7 +120,7 @@ public class WatermarkDecorator implemen
* This decorator's text
*/
public void setText(String text) {
- label.setText(text);
+ label.setText(text != null ? text : "");
validate();
}
@@ -210,19 +208,7 @@ public class WatermarkDecorator implemen
throw new IllegalArgumentException("imageURL is null.");
}
- Image image = (Image)ApplicationContext.getResourceCache().get(imageURL);
-
- if (image == null) {
- try {
- image = Image.load(imageURL);
- } catch (TaskExecutionException exception) {
- throw new IllegalArgumentException(exception);
- }
-
- ApplicationContext.getResourceCache().put(imageURL, image);
- }
-
- setImage(image);
+ setImage(Image.loadFromCache(imageURL));
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java Sat Mar 2 01:04:53 2013
@@ -28,6 +28,7 @@ import org.apache.pivot.serialization.Se
import org.apache.pivot.util.ListenerList;
import org.apache.pivot.util.concurrent.TaskExecutionException;
import org.apache.pivot.util.concurrent.TaskListener;
+import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.Visual;
@@ -149,4 +150,24 @@ public abstract class Image implements V
loadTask.execute(loadListener);
return loadTask;
}
+
+ public static Image loadFromCache(URL location) {
+ if (location == null) {
+ throw new IllegalArgumentException("location is null.");
+ }
+
+ Image image = (Image)ApplicationContext.getResourceCache().get(location);
+ if (image == null) {
+ try {
+ image = Image.load(location);
+ ApplicationContext.getResourceCache().put(location, image);
+ } catch (TaskExecutionException exception) {
+ throw new IllegalArgumentException(exception);
+ }
+
+ }
+
+ return image;
+ }
+
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java Sat Mar 2 01:04:53 2013
@@ -118,16 +118,17 @@ public class Picture extends Image {
interpolationHint = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
break;
}
-
case BILINEAR: {
interpolationHint = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
break;
}
-
case BICUBIC: {
interpolationHint = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
break;
}
+ default: {
+ break;
+ }
}
bufferedImageGraphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolationHint);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java Sat Mar 2 01:04:53 2013
@@ -93,12 +93,13 @@ public class BorderSkin extends Containe
Component content = border.getContent();
if (content != null) {
- if (height != -1) {
- height = Math.max(height - (topThickness + thickness) -
+ int heightUpdated = height;
+ if (heightUpdated != -1) {
+ heightUpdated = Math.max(heightUpdated - (topThickness + thickness) -
padding.top - padding.bottom, 0);
}
- preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(height));
+ preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(heightUpdated));
}
preferredWidth += (padding.left + padding.right) + (thickness * 2);
@@ -123,12 +124,13 @@ public class BorderSkin extends Containe
Component content = border.getContent();
if (content != null) {
- if (width != -1) {
- width = Math.max(width - (thickness * 2)
+ int widthUpdated = width;
+ if (widthUpdated != -1) {
+ widthUpdated = Math.max(widthUpdated - (thickness * 2)
- padding.left - padding.right, 0);
}
- preferredHeight = content.getPreferredHeight(width);
+ preferredHeight = content.getPreferredHeight(widthUpdated);
}
preferredHeight += (padding.top + padding.bottom) + (topThickness + thickness);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -53,9 +53,10 @@ public class BoxPaneSkin extends Contain
Orientation orientation = boxPane.getOrientation();
if (orientation == Orientation.HORIZONTAL) {
+ int heightUpdated = height;
// Include padding in constraint
- if (height != -1) {
- height = Math.max(height - (padding.top + padding.bottom), 0);
+ if (heightUpdated != -1) {
+ heightUpdated = Math.max(heightUpdated - (padding.top + padding.bottom), 0);
}
// Preferred width is the sum of the preferred widths of all components
@@ -64,7 +65,7 @@ public class BoxPaneSkin extends Contain
Component component = boxPane.get(i);
if (component.isVisible()) {
- preferredWidth += component.getPreferredWidth(fill ? height : -1);
+ preferredWidth += component.getPreferredWidth(fill ? heightUpdated : -1);
j++;
}
}
@@ -109,9 +110,10 @@ public class BoxPaneSkin extends Contain
}
}
} else {
+ int widthUpdated = width;
// Include padding in constraint
- if (width != -1) {
- width = Math.max(width - (padding.left + padding.right), 0);
+ if (widthUpdated != -1) {
+ widthUpdated = Math.max(widthUpdated - (padding.left + padding.right), 0);
}
// Preferred height is the sum of the preferred heights of all components
@@ -120,7 +122,7 @@ public class BoxPaneSkin extends Contain
Component component = boxPane.get(i);
if (component.isVisible()) {
- preferredHeight += component.getPreferredHeight(fill ? width : -1);
+ preferredHeight += component.getPreferredHeight(fill ? widthUpdated : -1);
j++;
}
}
@@ -188,6 +190,10 @@ public class BoxPaneSkin extends Contain
break;
}
+
+ default: {
+ break;
+ }
}
// Include padding
@@ -235,13 +241,16 @@ public class BoxPaneSkin extends Contain
componentBaseline += (contentHeight - size.height) / 2;
break;
}
-
case BOTTOM: {
componentBaseline += contentHeight - size.height;
break;
}
- case TOP:
+ case TOP: {
break;
+ }
+ default: {
+ break;
+ }
}
}
@@ -281,6 +290,10 @@ public class BoxPaneSkin extends Contain
break;
}
+
+ default: {
+ break;
+ }
}
if (baseline != -1) {
@@ -302,6 +315,10 @@ public class BoxPaneSkin extends Contain
baseline += height - (contentHeight + padding.bottom);
break;
}
+
+ default: {
+ break;
+ }
}
}
}
@@ -329,13 +346,16 @@ public class BoxPaneSkin extends Contain
x = (width - preferredWidth) / 2;
break;
}
-
case RIGHT: {
x = width - preferredWidth;
break;
}
- case LEFT:
+ case LEFT: {
break;
+ }
+ default: {
+ break;
+ }
}
x += padding.left;
@@ -375,6 +395,10 @@ public class BoxPaneSkin extends Contain
y = height - padding.bottom - componentHeight;
break;
}
+
+ default: {
+ break;
+ }
}
// Set the component's size and position
@@ -403,6 +427,10 @@ public class BoxPaneSkin extends Contain
}
case TOP:
break;
+
+ default: {
+ break;
+ }
}
y += padding.top;
@@ -432,16 +460,17 @@ public class BoxPaneSkin extends Contain
x = padding.left;
break;
}
-
case CENTER: {
x = (width - componentWidth) / 2;
break;
}
-
case RIGHT: {
x = width - padding.right - componentWidth;
break;
}
+ default: {
+ break;
+ }
}
// Set the component's size and position
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java Sat Mar 2 01:04:53 2013
@@ -97,6 +97,10 @@ public abstract class CalendarButtonSkin
break;
}
+
+ default: {
+ break;
+ }
}
return false;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -727,6 +727,10 @@ public class CardPaneSkin extends Contai
}
break;
}
+
+ default: {
+ break;
+ }
}
if (selectionChangeTransition != null) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java Sat Mar 2 01:04:53 2013
@@ -104,6 +104,10 @@ public abstract class ColorChooserButton
break;
}
+
+ default: {
+ break;
+ }
}
return false;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ContainerSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ContainerSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ContainerSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ContainerSkin.java Sat Mar 2 01:04:53 2013
@@ -113,6 +113,10 @@ public abstract class ContainerSkin exte
break;
}
+
+ default: {
+ break;
+ }
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -48,9 +48,10 @@ public class FillPaneSkin extends Contai
Orientation orientation = fillPane.getOrientation();
if (orientation == Orientation.HORIZONTAL) {
+ int heightUpdated = height;
// Include padding in constraint
- if (height != -1) {
- height = Math.max(height - (padding.top + padding.bottom), 0);
+ if (heightUpdated != -1) {
+ heightUpdated = Math.max(heightUpdated - (padding.top + padding.bottom), 0);
}
// Preferred width is the sum of the preferred widths of all components
@@ -59,7 +60,7 @@ public class FillPaneSkin extends Contai
Component component = fillPane.get(i);
if (component.isVisible()) {
- preferredWidth += component.getPreferredWidth(height);
+ preferredWidth += component.getPreferredWidth(heightUpdated);
j++;
}
}
@@ -104,9 +105,10 @@ public class FillPaneSkin extends Contai
}
}
} else {
+ int widthUpdated = width;
// Include padding in constraint
- if (width != -1) {
- width = Math.max(width - (padding.left + padding.right), 0);
+ if (widthUpdated != -1) {
+ widthUpdated = Math.max(widthUpdated - (padding.left + padding.right), 0);
}
// Preferred height is the sum of the preferred heights of all components
@@ -115,7 +117,7 @@ public class FillPaneSkin extends Contai
Component component = fillPane.get(i);
if (component.isVisible()) {
- preferredHeight += component.getPreferredHeight(width);
+ preferredHeight += component.getPreferredHeight(widthUpdated);
j++;
}
}
@@ -183,6 +185,10 @@ public class FillPaneSkin extends Contai
break;
}
+
+ default: {
+ break;
+ }
}
// Include padding
@@ -235,6 +241,10 @@ public class FillPaneSkin extends Contai
break;
}
+
+ default: {
+ break;
+ }
}
if (baseline != -1) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -305,6 +305,9 @@ public class FlowPaneSkin extends Contai
x = width - rowWidth - padding.right;
break;
}
+ default: {
+ break;
+ }
}
for (Component component : row) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Sat Mar 2 01:04:53 2013
@@ -108,6 +108,7 @@ public class LabelSkin extends Component
float preferredHeight;
if (text != null) {
+ int widthUpdated = width;
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
LineMetrics lm = font.getLineMetrics("", fontRenderContext);
float lineHeight = lm.getHeight();
@@ -117,9 +118,9 @@ public class LabelSkin extends Component
int n = text.length();
if (n > 0
&& wrapText
- && width != -1) {
+ && widthUpdated != -1) {
// Adjust width for padding
- width -= (padding.left + padding.right);
+ widthUpdated -= (padding.left + padding.right);
float lineWidth = 0;
int lastWhitespaceIndex = -1;
@@ -141,7 +142,7 @@ public class LabelSkin extends Component
fontRenderContext);
lineWidth += characterBounds.getWidth();
- if (lineWidth > width
+ if (lineWidth > widthUpdated
&& lastWhitespaceIndex != -1) {
i = lastWhitespaceIndex;
@@ -217,6 +218,10 @@ public class LabelSkin extends Component
baseline = Math.round(height - (textHeightLocal + padding.bottom) + ascent);
break;
}
+
+ default: {
+ break;
+ }
}
return baseline;
@@ -340,6 +345,10 @@ public class LabelSkin extends Component
y = (height - textHeight) / 2;
break;
}
+
+ default: {
+ break;
+ }
}
for (int i = 0, n = glyphVectors.getLength(); i < n; i++) {
@@ -354,16 +363,17 @@ public class LabelSkin extends Component
x = padding.left;
break;
}
-
case RIGHT: {
x = width - (lineWidth + padding.right);
break;
}
-
case CENTER: {
x = (width - lineWidth) / 2;
break;
}
+ default: {
+ break;
+ }
}
if (graphics instanceof PrintGraphics) {
@@ -388,11 +398,13 @@ public class LabelSkin extends Component
offset = y + ascent + 2;
break;
}
-
case STRIKETHROUGH: {
offset = y + lineHeight / 2 + 1;
break;
}
+ default: {
+ break;
+ }
}
Line2D line = new Line2D.Float(x, offset, x + lineWidth, offset);
@@ -675,4 +687,10 @@ public class LabelSkin extends Component
public void textChanged(Label label, String previousText) {
invalidateComponent();
}
+
+ @Override
+ public void maximumLengthChanged(Label label, int previousMaximumLength) {
+ invalidateComponent();
+ }
+
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Sat Mar 2 01:04:53 2013
@@ -107,6 +107,10 @@ public abstract class ListButtonSkin ext
listViewPopup.close();
break;
}
+
+ default: {
+ break;
+ }
}
return false;
@@ -390,7 +394,7 @@ public abstract class ListButtonSkin ext
List<?> listData = listButton.getListData();
ListView.ItemRenderer itemRenderer = listButton.getItemRenderer();
- character = Character.toUpperCase(character);
+ char characterUpper = Character.toUpperCase(character);
for (int i = listButton.getSelectedIndex() + 1, n = listData.getLength(); i < n; i++) {
if (!listButton.isItemDisabled(i)) {
@@ -400,7 +404,7 @@ public abstract class ListButtonSkin ext
&& string.length() > 0) {
char first = Character.toUpperCase(string.charAt(0));
- if (first == character) {
+ if (first == characterUpper) {
listButton.setSelectedIndex(i);
consumed = true;
break;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -167,14 +167,14 @@ public class ScrollPaneSkin extends Cont
// Preferred width is the sum of the constrained preferred
// width of the view and the unconstrained preferred width of
// the row header
-
- if (height >= 0) {
+ int heightUpdated = height;
+ if (heightUpdated >= 0) {
// Subtract the unconstrained preferred height of the
// column header from the height constraint
- height = Math.max(height - preferredColumnHeaderHeight, 0);
+ heightUpdated = Math.max(heightUpdated - preferredColumnHeaderHeight, 0);
}
- preferredWidth = view.getPreferredWidth(height) +
+ preferredWidth = view.getPreferredWidth(heightUpdated) +
preferredRowHeaderWidth;
}
}
@@ -257,14 +257,14 @@ public class ScrollPaneSkin extends Cont
// Preferred height is the sum of the constrained preferred height
// of the view and the unconstrained preferred height of the column
// header
-
- if (width >= 0) {
+ int widthUpdated = width;
+ if (widthUpdated >= 0) {
// Subtract the unconstrained preferred width of the row header
// from the width constraint
- width = Math.max(width - preferredRowHeaderWidth, 0);
+ widthUpdated = Math.max(widthUpdated - preferredRowHeaderWidth, 0);
}
- preferredHeight = view.getPreferredHeight(width) +
+ preferredHeight = view.getPreferredHeight(widthUpdated) +
preferredColumnHeaderHeight;
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java Sat Mar 2 01:04:53 2013
@@ -264,11 +264,12 @@ public class TablePaneSkin extends Conta
int totalRelativeWeight = 0;
- if (width < 0) {
- width = getPreferredWidth(-1);
+ int widthUpdated = width;
+ if (widthUpdated < 0) {
+ widthUpdated = getPreferredWidth(-1);
}
- int[] columnWidthsLocal = getColumnWidths(width);
+ int[] columnWidthsLocal = getColumnWidths(widthUpdated);
// First, we calculate the base heights of the rows, giving relative
// rows their preferred height
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Sat Mar 2 01:04:53 2013
@@ -34,6 +34,7 @@ import org.apache.pivot.collections.Sequ
import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Bounds;
import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Cursor;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.GraphicsUtilities;
import org.apache.pivot.wtk.Insets;
@@ -102,6 +103,10 @@ public class TextAreaSkin extends Compon
break;
}
+
+ default: {
+ break;
+ }
}
}
}
@@ -135,6 +140,7 @@ public class TextAreaSkin extends Compon
private int tabWidth;
private int lineWidth;
private boolean acceptsEnter = true;
+ private boolean acceptsTab = false;
private Dimensions averageCharacterSize;
@@ -165,6 +171,8 @@ public class TextAreaSkin extends Compon
textArea.getTextAreaListeners().add(this);
textArea.getTextAreaContentListeners().add(this);
textArea.getTextAreaSelectionListeners().add(this);
+
+ textArea.setCursor(Cursor.TEXT);
}
@Override
@@ -771,6 +779,34 @@ public class TextAreaSkin extends Compon
this.acceptsEnter = acceptsEnter;
}
+ /**
+ * Gets current value of style that determines the
+ * behavior of <tt>TAB</tt> and <tt>Ctrl-TAB</tt>
+ * characters.
+ * @return <tt>true</tt> if <tt>TAB</tt> inserts an
+ * appropriate number of spaces, while <tt>Ctrl-TAB</tt>
+ * shifts focus to next component. <tt>false</tt> (default)
+ * means <tt>TAB</tt> shifts focus and <tt>Ctrl-TAB</tt>
+ * inserts spaces.
+ */
+ public boolean getAcceptsTab() {
+ return acceptsTab;
+ }
+
+ /**
+ * Sets current value of style that determines the
+ * behavior of <tt>TAB</tt> and <tt>Ctrl-TAB</tt>
+ * characters.
+ * @param acceptsTab <tt>true</tt> if <tt>TAB</tt> inserts an
+ * appropriate number of spaces, while <tt>Ctrl-TAB</tt>
+ * shifts focus to next component. <tt>false</tt> (default)
+ * means <tt>TAB</tt> shifts focus and <tt>Ctrl-TAB</tt>
+ * inserts spaces.
+ */
+ public void setAcceptsTab(boolean acceptsTab) {
+ this.acceptsTab = acceptsTab;
+ }
+
@Override
public int getTabWidth() {
return tabWidth;
@@ -915,13 +951,80 @@ public class TextAreaSkin extends Compon
Mouse.release();
}
- anchor = -1;
scrollDirection = null;
mouseX = -1;
return consumed;
}
+ private void selectSpan(TextArea textArea, int start) {
+ int rowStart = textArea.getRowOffset(start);
+ int rowLength = textArea.getRowLength(start);
+ if (start - rowStart >= rowLength) {
+ start = rowStart + rowLength - 1;
+ char ch = textArea.getCharacterAt(start);
+ if (ch == '\r' || ch == '\n') {
+ start--;
+ }
+ }
+ char ch = textArea.getCharacterAt(start);
+ int selectionStart = start;
+ int selectionLength = 1;
+ if (Character.isWhitespace(ch)) {
+ // Move backward to beginning of whitespace block
+ // but not before the beginning of the line.
+ do {
+ selectionStart--;
+ } while (selectionStart >= rowStart &&
+ Character.isWhitespace(textArea.getCharacterAt(selectionStart)));
+ selectionStart++;
+ selectionLength = start - selectionStart;
+ // Move forward to end of whitespace block
+ // but not past the end of the text or the end of line
+ do {
+ selectionLength++;
+ } while (selectionStart + selectionLength - rowStart < rowLength &&
+ Character.isWhitespace(textArea.getCharacterAt(selectionStart + selectionLength)));
+ } else if (Character.isJavaIdentifierPart(ch)) {
+ // Move backward to beginning of identifier block
+ do {
+ selectionStart--;
+ } while (selectionStart >= rowStart &&
+ Character.isJavaIdentifierPart(textArea.getCharacterAt(selectionStart)));
+ selectionStart++;
+ selectionLength = start - selectionStart;
+ // Move forward to end of identifier block
+ // but not past end of text
+ do {
+ selectionLength++;
+ } while (selectionStart + selectionLength - rowStart < rowLength &&
+ Character.isJavaIdentifierPart(textArea.getCharacterAt(selectionStart + selectionLength)));
+ } else {
+ return;
+ }
+ textArea.setSelection(selectionStart, selectionLength);
+ }
+
+ @Override
+ public boolean mouseClick(Component component, Mouse.Button button,
+ int x, int y, int count) {
+ boolean consumed = super.mouseClick(component, button, x, y, count);
+
+ TextArea textArea = (TextArea)component;
+
+ if (button == Mouse.Button.LEFT) {
+ int index = getInsertionPoint(x, y);
+ if (index != -1) {
+ if (count == 2) {
+ selectSpan(textArea, index);
+ } else if (count == 3) {
+ textArea.setSelection(textArea.getRowOffset(index), textArea.getRowLength(index));
+ }
+ }
+ }
+ return consumed;
+ }
+
@Override
public boolean keyTyped(Component component, char character) {
boolean consumed = super.keyTyped(component, character);
@@ -959,12 +1062,15 @@ public class TextAreaSkin extends Compon
if (paragraphViews.getLength() > 0) {
TextArea textArea = (TextArea)getComponent();
- Keyboard.Modifier commandModifier = Platform.getCommandModifier();
- Keyboard.Modifier wordNavigationModifier = Platform.getWordNavigationModifier();
+ boolean commandPressed = Keyboard.isPressed(Platform.getCommandModifier());
+ boolean wordNavPressed = Keyboard.isPressed(Platform.getWordNavigationModifier());
+ boolean shiftPressed = Keyboard.isPressed(Keyboard.Modifier.SHIFT);
+ boolean ctrlPressed = Keyboard.isPressed(Keyboard.Modifier.CTRL);
+ boolean metaPressed = Keyboard.isPressed(Keyboard.Modifier.META);
+ boolean isEditable = textArea.isEditable();
if (keyCode == Keyboard.KeyCode.ENTER
- && acceptsEnter
- && textArea.isEditable()
+ && acceptsEnter && isEditable
&& Keyboard.getModifiers() == 0) {
int index = textArea.getSelectionStart();
textArea.removeText(index, textArea.getSelectionLength());
@@ -972,7 +1078,7 @@ public class TextAreaSkin extends Compon
consumed = true;
} else if (keyCode == Keyboard.KeyCode.DELETE
- && textArea.isEditable()) {
+ && isEditable) {
int index = textArea.getSelectionStart();
if (index < textArea.getCharacterCount()) {
@@ -982,7 +1088,7 @@ public class TextAreaSkin extends Compon
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.BACKSPACE
- && textArea.isEditable()) {
+ && isEditable) {
int index = textArea.getSelectionStart();
int count = textArea.getSelectionLength();
@@ -995,19 +1101,21 @@ public class TextAreaSkin extends Compon
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.TAB
- && Keyboard.isPressed(Keyboard.Modifier.CTRL)
- && textArea.isEditable()) {
+ && (acceptsTab != ctrlPressed)
+ && isEditable) {
+ int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
+ int rowOffset = textArea.getRowOffset(selectionStart);
+ int linePos = selectionStart - rowOffset;
StringBuilder tabBuilder = new StringBuilder(tabWidth);
- for (int i = 0; i < tabWidth; i++) {
+ for (int i = 0; i < tabWidth - (linePos % tabWidth); i++) {
tabBuilder.append(" ");
}
if (textArea.getCharacterCount() - selectionLength + tabWidth > textArea.getMaximumLength()) {
Toolkit.getDefaultToolkit().beep();
} else {
- int selectionStart = textArea.getSelectionStart();
textArea.removeText(selectionStart, selectionLength);
textArea.insertText(tabBuilder, selectionStart);
}
@@ -1016,40 +1124,53 @@ public class TextAreaSkin extends Compon
consumed = true;
} else if (keyCode == Keyboard.KeyCode.HOME
- || (keyCode == Keyboard.KeyCode.LEFT
- && Keyboard.isPressed(Keyboard.Modifier.META))) {
- // Move the caret to the beginning of the line
+ || (keyCode == Keyboard.KeyCode.LEFT && metaPressed)) {
+ int start;
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
- int rowOffset = getRowOffset(selectionStart);
+ if (ctrlPressed) {
+ // Move the caret to the beginning of the text
+ start = 0;
+ } else {
+ // Move the caret to the beginning of the line
+ start = getRowOffset(selectionStart);
+ }
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
- selectionLength += selectionStart - rowOffset;
+ if (shiftPressed) {
+ selectionLength += selectionStart - start;
+ } else {
+ selectionLength = 0;
}
if (selectionStart >= 0) {
- textArea.setSelection(rowOffset, selectionLength);
- scrollCharacterToVisible(rowOffset);
+ textArea.setSelection(start, selectionLength);
+ scrollCharacterToVisible(start);
caretX = caret.x;
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.END
- || (keyCode == Keyboard.KeyCode.RIGHT
- && Keyboard.isPressed(Keyboard.Modifier.META))) {
- // Move the caret to the end of the line
+ || (keyCode == Keyboard.KeyCode.RIGHT && metaPressed)) {
+ int end;
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
-
int index = selectionStart + selectionLength;
- int rowOffset = getRowOffset(index);
- int rowLength = getRowLength(index);
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
- selectionLength += (rowOffset + rowLength) - index;
+ if (ctrlPressed) {
+ // Move the caret to end of the text
+ end = textArea.getCharacterCount();
} else {
- selectionStart = rowOffset + rowLength;
+ // Move the caret to the end of the line
+ int rowOffset = getRowOffset(index);
+ int rowLength = getRowLength(index);
+ end = rowOffset + rowLength;
+ }
+
+ if (shiftPressed) {
+ selectionLength += end - index;
+ } else {
+ selectionStart = end;
if (selectionStart < textArea.getCharacterCount()
&& textArea.getCharacterAt(selectionStart) != '\n') {
selectionStart--;
@@ -1073,7 +1194,7 @@ public class TextAreaSkin extends Compon
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
- if (Keyboard.isPressed(wordNavigationModifier)) {
+ if (wordNavPressed) {
// Move the caret to the start of the next word to the left
if (selectionStart > 0) {
// Skip over any space immediately to the left
@@ -1089,7 +1210,7 @@ public class TextAreaSkin extends Compon
index--;
}
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ if (shiftPressed) {
selectionLength += selectionStart - index;
} else {
selectionLength = 0;
@@ -1097,11 +1218,28 @@ public class TextAreaSkin extends Compon
selectionStart = index;
}
- } else if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
- // Add the previous character to the selection
- if (selectionStart > 0) {
- selectionStart--;
- selectionLength++;
+ } else if (shiftPressed) {
+ if (anchor != -1) {
+ if (selectionStart < anchor) {
+ if (selectionStart > 0) {
+ selectionStart--;
+ selectionLength++;
+ }
+ } else {
+ if (selectionLength > 0) {
+ selectionLength--;
+ } else {
+ selectionStart--;
+ selectionLength++;
+ }
+ }
+ } else {
+ // Add the previous character to the selection
+ anchor = selectionStart;
+ if (selectionStart > 0) {
+ selectionStart--;
+ selectionLength++;
+ }
}
} else {
// Move the caret back by one character
@@ -1111,6 +1249,7 @@ public class TextAreaSkin extends Compon
}
// Clear the selection
+ anchor = -1;
selectionLength = 0;
}
@@ -1126,7 +1265,7 @@ public class TextAreaSkin extends Compon
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
- if (Keyboard.isPressed(wordNavigationModifier)) {
+ if (wordNavPressed) {
// Move the caret to the start of the next word to the right
if (selectionStart < textArea.getCharacterCount()) {
int index = selectionStart + selectionLength;
@@ -1143,16 +1282,26 @@ public class TextAreaSkin extends Compon
index++;
}
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ if (shiftPressed) {
selectionLength = index - selectionStart;
} else {
selectionStart = index;
selectionLength = 0;
}
}
- } else if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
- // Add the next character to the selection
- selectionLength++;
+ } else if (shiftPressed) {
+ if (anchor != -1) {
+ if (selectionStart < anchor) {
+ selectionStart++;
+ selectionLength--;
+ } else {
+ selectionLength++;
+ }
+ } else {
+ // Add the next character to the selection
+ anchor = selectionStart;
+ selectionLength++;
+ }
} else {
// Move the caret forward by one character
if (selectionLength == 0) {
@@ -1162,6 +1311,7 @@ public class TextAreaSkin extends Compon
}
// Clear the selection
+ anchor = -1;
selectionLength = 0;
}
@@ -1178,14 +1328,13 @@ public class TextAreaSkin extends Compon
}
} else if (keyCode == Keyboard.KeyCode.UP) {
int selectionStart = textArea.getSelectionStart();
+ int selectionLength = textArea.getSelectionLength();
int index = getNextInsertionPoint(caretX, selectionStart, TextArea.ScrollDirection.UP);
if (index != -1) {
- int selectionLength;
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
- int selectionEnd = selectionStart + textArea.getSelectionLength() - 1;
- selectionLength = selectionEnd - index + 1;
+ if (shiftPressed) {
+ selectionLength = selectionStart + selectionLength - index;
} else {
selectionLength = 0;
}
@@ -1199,7 +1348,7 @@ public class TextAreaSkin extends Compon
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ if (shiftPressed) {
int from;
int x;
if (selectionLength == 0) {
@@ -1247,32 +1396,33 @@ public class TextAreaSkin extends Compon
}
consumed = true;
- } else if (Keyboard.isPressed(commandModifier)) {
+ } else if (commandPressed) {
if (keyCode == Keyboard.KeyCode.A) {
textArea.setSelection(0, textArea.getCharacterCount());
consumed = true;
} else if (keyCode == Keyboard.KeyCode.X
- && textArea.isEditable()) {
+ && isEditable) {
textArea.cut();
consumed = true;
} else if (keyCode == Keyboard.KeyCode.C) {
textArea.copy();
consumed = true;
} else if (keyCode == Keyboard.KeyCode.V
- && textArea.isEditable()) {
+ && isEditable) {
textArea.paste();
consumed = true;
} else if (keyCode == Keyboard.KeyCode.Z
- && textArea.isEditable()) {
- if (!Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ && isEditable) {
+ if (!shiftPressed) {
textArea.undo();
}
-
consumed = true;
+ } else if (keyCode == Keyboard.KeyCode.TAB) {
+ // Only here if acceptsTab is false
+ consumed = super.keyPressed(component, keyCode, keyLocation);
}
} else if (keyCode == Keyboard.KeyCode.INSERT) {
- if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
- && textArea.isEditable()) {
+ if (shiftPressed && isEditable) {
textArea.paste();
consumed = true;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java Sat Mar 2 01:04:53 2013
@@ -318,14 +318,14 @@ public class TextPaneSkin extends Contai
if (documentView == null) {
offset = -1;
} else {
- x = Math.min(documentView.getWidth() - 1, Math.max(x - margin.left, 0));
+ int xUpdated = Math.min(documentView.getWidth() - 1, Math.max(x - margin.left, 0));
if (y < margin.top) {
- offset = documentView.getNextInsertionPoint(x, -1, TextPane.ScrollDirection.DOWN);
+ offset = documentView.getNextInsertionPoint(xUpdated, -1, TextPane.ScrollDirection.DOWN);
} else if (y > documentView.getHeight() + margin.top) {
- offset = documentView.getNextInsertionPoint(x, -1, TextPane.ScrollDirection.UP);
+ offset = documentView.getNextInsertionPoint(xUpdated, -1, TextPane.ScrollDirection.UP);
} else {
- offset = documentView.getInsertionPoint(x, y - margin.top);
+ offset = documentView.getInsertionPoint(xUpdated, y - margin.top);
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java Sat Mar 2 01:04:53 2013
@@ -55,6 +55,8 @@ class TextPaneSkinBulletedListView exten
case CIRCLE_OUTLINE:
listItemView.setIndexText("\u25e6 ");
break;
+ default:
+ break;
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java Sat Mar 2 01:04:53 2013
@@ -49,9 +49,10 @@ class TextPaneSkinListItemView extends T
@Override
protected void childLayout(int breakWidth) {
- indexTextNodeView.layout(breakWidth);
+ int bw = breakWidth;
+ indexTextNodeView.layout(bw);
- breakWidth -= indexTextNodeView.getWidth();
+ bw -= indexTextNodeView.getWidth();
int itemsWidth = 0;
int itemsY = 0;
@@ -61,7 +62,7 @@ class TextPaneSkinListItemView extends T
for ( ; iterator.hasNext(); ) {
TextPaneSkinNodeView nodeView = iterator.next();
- nodeView.layout(breakWidth);
+ nodeView.layout(bw);
nodeView.setLocation(indexTextNodeView.getWidth(), itemsY);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java Sat Mar 2 01:04:53 2013
@@ -51,13 +51,14 @@ class TextPaneSkinNumberedListView exten
};
private static String int2roman(int n) {
+ int num = n;
StringBuffer result = new StringBuffer(10);
// ... Start with largest value, and work toward smallest.
for (RomanValue equiv : ROMAN_VALUE_TABLE) {
// ... Remove as many of this value as possible (maybe none).
- while (n >= equiv.integerVal) {
- n -= equiv.integerVal;
+ while (num >= equiv.integerVal) {
+ num -= equiv.integerVal;
result.append(equiv.romanNumeral);
}
}
@@ -112,6 +113,8 @@ class TextPaneSkinNumberedListView exten
case UPPER_ROMAN:
listItemView.setIndexText(int2roman(index) + ". ");
break;
+ default:
+ break;
}
index++;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java Sat Mar 2 01:04:53 2013
@@ -150,7 +150,7 @@ abstract class TextPaneSkinVerticalEleme
}
}
- if (offset != -1) {
+ if (offset != -1 && nodeView != null) {
offset += nodeView.getOffset();
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java Sat Mar 2 01:04:53 2013
@@ -19,8 +19,6 @@ package org.apache.pivot.wtk.text;
import java.net.URL;
import org.apache.pivot.util.ListenerList;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.media.Image;
/**
@@ -88,19 +86,7 @@ public class ImageNode extends Node {
throw new IllegalArgumentException("imageURL is null.");
}
- Image imageLocal = (Image)ApplicationContext.getResourceCache().get(imageURL);
-
- if (imageLocal == null) {
- try {
- imageLocal = Image.load(imageURL);
- } catch (TaskExecutionException exception) {
- throw new IllegalArgumentException(exception);
- }
-
- ApplicationContext.getResourceCache().put(imageURL, imageLocal);
- }
-
- setImage(imageLocal);
+ setImage(Image.loadFromCache(imageURL));
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java Sat Mar 2 01:04:53 2013
@@ -41,7 +41,7 @@ public class Paragraph extends Block {
@Override
public Node removeRange(int offset, int characterCount) {
if (offset + characterCount == getCharacterCount()) {
- characterCount--;
+ return super.removeRange(offset, characterCount - 1);
}
return super.removeRange(offset, characterCount);
@@ -50,7 +50,7 @@ public class Paragraph extends Block {
@Override
public Paragraph getRange(int offset, int characterCount) {
if (offset + characterCount == getCharacterCount()) {
- characterCount--;
+ return (Paragraph) super.getRange(offset, characterCount - 1);
}
return (Paragraph) super.getRange(offset, characterCount);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java Sat Mar 2 01:04:53 2013
@@ -50,7 +50,7 @@ public class ComparableValidator<T exten
}
protected final Comparable<?> textToComparable(String text) {
- return (Comparable<?>) textToBigDecimal(text);
+ return textToBigDecimal(text);
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/DecimalValidator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/DecimalValidator.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/DecimalValidator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/DecimalValidator.java Sat Mar 2 01:04:53 2013
@@ -42,11 +42,12 @@ public class DecimalValidator extends Fo
}
/** helper method that wraps the ParseException in a RuntimeException. */
- protected final Number parseNumber(String text) {
+ protected final Number parseNumber(final String text) {
+ String textToParse;
try {
// We have to upper case because of the exponent symbol
- text = text.toUpperCase(locale);
- return format.parse(text);
+ textToParse = text.toUpperCase(locale);
+ return format.parse(textToParse);
} catch (ParseException ex) {
// this should never happen
throw new RuntimeException(ex);
@@ -56,7 +57,7 @@ public class DecimalValidator extends Fo
/** helper method that returns the widest number real instance,
* and extract later values depending on the precision needed.
*/
- protected final BigDecimal textToBigDecimal(String text) {
+ protected final BigDecimal textToBigDecimal(final String text) {
BigDecimal bd;
try {
if (!autoTrim) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/FormattedValidator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/FormattedValidator.java?rev=1451799&r1=1451798&r2=1451799&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/FormattedValidator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/validation/FormattedValidator.java Sat Mar 2 01:04:53 2013
@@ -49,13 +49,14 @@ public class FormattedValidator<F extend
}
@Override
- public boolean isValid(String text) {
+ public boolean isValid(final String text) {
+ String textToParse = text;
final ParsePosition pos = new ParsePosition(0);
if (format instanceof NumberFormat) {
// We have to upper case because of the exponent symbol
- text = text.toUpperCase(locale);
+ textToParse = textToParse.toUpperCase(locale);
}
- Object obj = format.parseObject(text, pos);
+ Object obj = format.parseObject(textToParse, pos);
// The text is only valid if we successfully parsed ALL of it. Don't want trailing bits of
// not-valid text.