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/10/01 15:42:22 UTC
svn commit: r1528088 - in /pivot/trunk:
core/src/org/apache/pivot/collections/ core/src/org/apache/pivot/util/
examples/src/org/apache/pivot/examples/scripting/
examples/src/org/apache/pivot/examples/sheets/
tests/src/org/apache/pivot/tests/ tutorials/...
Author: smartini
Date: Tue Oct 1 13:42:21 2013
New Revision: 1528088
URL: http://svn.apache.org/r1528088
Log:
merge from 2.0.x
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/tooltip_test.bxml
Modified:
pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
pivot/trunk/core/src/org/apache/pivot/util/TypeLiteral.java
pivot/trunk/examples/src/org/apache/pivot/examples/scripting/JavaWindow.java
pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetExampleWindow.java
pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java
pivot/trunk/tests/src/org/apache/pivot/tests/ApplicationHandlerTest.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraScrollBarSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Application.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
Modified: pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java Tue Oct 1 13:42:21 2013
@@ -28,8 +28,8 @@ public interface Sequence<T> {
/**
* Collection of static utility methods providing path access to nested
* sequence data.
+ * @param <T> note that in Tree the type parameter currently it's not used
*/
- @SuppressWarnings("unused")
public static class Tree<T> {
/**
* An object representing a path to a nested node in nested sequence
Modified: pivot/trunk/core/src/org/apache/pivot/util/TypeLiteral.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/TypeLiteral.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/TypeLiteral.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/TypeLiteral.java Tue Oct 1 13:42:21 2013
@@ -32,8 +32,8 @@ import java.lang.reflect.Type;
* This class is a drastically reduced derivation from
* <a href="http://code.google.com/p/google-guice/">Google Guice</a>'s
* {@code TypeLiteral} class, written by Bob Lee and Jesse Wilson.
+ * @param <T> note that in Tree the type parameter currently it's not used
*/
-@SuppressWarnings("unused")
public class TypeLiteral<T> {
private final Type type;
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/scripting/JavaWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/scripting/JavaWindow.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/scripting/JavaWindow.java (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/scripting/JavaWindow.java Tue Oct 1 13:42:21 2013
@@ -50,7 +50,7 @@ public class JavaWindow extends Window i
sayHelloButton.requestFocus();
}
- private void sayHello() {
+ void sayHello() {
Prompt.prompt("Hello from Java!", this);
}
}
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetExampleWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetExampleWindow.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetExampleWindow.java (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetExampleWindow.java Tue Oct 1 13:42:21 2013
@@ -34,7 +34,7 @@ import org.apache.pivot.wtk.Window;
* Main window.
*/
public class SheetExampleWindow extends Window implements Bindable {
- @BXML private EditGreetingSheet editGreetingSheet = null;
+ @BXML EditGreetingSheet editGreetingSheet = null;
@BXML private PushButton editGreetingButton = null;
@Override
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java Tue Oct 1 13:42:21 2013
@@ -42,10 +42,10 @@ import org.apache.pivot.wtk.skin.terra.T
public class SheetSlideDirectionWindow extends Window implements Bindable {
- @BXML private Sheet sheet;
- @BXML private TablePane tablePane;
- @BXML private Form form;
- @BXML private ListButton listButton;
+ @BXML Sheet sheet;
+ @BXML TablePane tablePane;
+ @BXML Form form;
+ @BXML ListButton listButton;
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/ApplicationHandlerTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/ApplicationHandlerTest.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/ApplicationHandlerTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/ApplicationHandlerTest.java Tue Oct 1 13:42:21 2013
@@ -25,7 +25,7 @@ import org.apache.pivot.wtk.Keyboard;
import org.apache.pivot.wtk.Window;
public class ApplicationHandlerTest extends Application.Adapter
- implements Application.UnprocessedKeyHandler, Application.UncaughtExceptionHandler {
+ implements Application.UnprocessedKeyHandler {
private Window window = null;
@Override
@@ -64,13 +64,8 @@ public class ApplicationHandlerTest exte
System.out.println("Unprocessed key released: " + keyCode + "; " + keyLocation);
}
- @Override
- public void uncaughtExceptionThrown(Exception exception) {
- System.out.println("Uncaught exception thrown.");
- exception.printStackTrace();
- }
-
public static void main(String[] args) {
DesktopApplicationContext.main(ApplicationHandlerTest.class, args);
}
+
}
Added: pivot/trunk/tests/src/org/apache/pivot/tests/tooltip_test.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/tooltip_test.bxml?rev=1528088&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/tooltip_test.bxml (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/tooltip_test.bxml Tue Oct 1 13:42:21 2013
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Test BXML" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:collections="org.apache.pivot.collections"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk"
+>
+
+ <BoxPane orientation="vertical" styles="{padding:4, verticalAlignment:'center'}">
+ <FlowPane>
+ <Label text="Multi-line Label:"
+ tooltipText="multi-line tooltip for the Label"
+ styles="{wrapText:true}"
+ />
+ <PushButton bxml:id="pushButton" buttonData="Button with multi-line tooltip"
+ tooltipText="multi-line tooltip for the Button"
+ />
+ </FlowPane>
+ <Separator/>
+ <FlowPane>
+ <Label text="Select one element:"/>
+ <ListButton bxml:id="listButton2" buttonData="Number"
+ listData="['One', 'Two', 'Three']"
+ tooltipText="multi-line tooltip for the List"
+ />
+ </FlowPane>
+ <Separator/>
+ <FlowPane>
+ <Label text="TableView:"/>
+ <TableView bxml:id="tableView" styles="{variableRowHeight:true, backgroundColor:'#ffeeee'}"
+ tooltipText="multi-line tooltip for the Table"
+ >
+ <columns>
+ <TableView.Column name="value" width="300">
+ <cellRenderer>
+ <content:TableViewCellRenderer styles="{wrapText:true}"/>
+ </cellRenderer>
+ </TableView.Column>
+
+ <TableView.Column width="1*"/>
+ </columns>
+
+ <collections:HashMap value="Single Line"/>
+ <collections:HashMap value="Double
Line Line Line Line!"/>
+ <collections:HashMap value="Single Line"/>
+ <collections:HashMap value="Double
Line"/>
+ </TableView>
+ </FlowPane>
+ <Separator/>
+ <FlowPane>
+ <Label text="Multi-line Label2:"
+ tooltipText="multi-line tooltip for the Label, but with wrapText false"
+ tooltipWrapText="false"
+ styles="{wrapText:true}"
+ />
+ <PushButton buttonData="Button 2"
+ tooltipText="multi-line tooltip for the Button, but with wrapText false"
+ tooltipWrapText="false"
+ />
+ </FlowPane>
+ <Separator/>
+ </BoxPane>
+
+</Window>
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java Tue Oct 1 13:42:21 2013
@@ -731,20 +731,20 @@ public class KitchenSink implements Appl
this.customTableView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
@Override
public boolean mouseClick(Component comp, Mouse.Button button, int x, int y, int count) {
- if (button == Mouse.Button.LEFT) {
- @SuppressWarnings("unchecked")
- List<CustomTableRow> customTableData =
- (List<CustomTableRow>)TablesRollupStateHandler.this.customTableView.getTableData();
-
- int columnIndex = TablesRollupStateHandler.this.customTableView.getColumnAt(x);
- if (columnIndex == 0) {
- int rowIndex = TablesRollupStateHandler.this.customTableView.getRowAt(y);
- CustomTableRow row = customTableData.get(rowIndex);
-
- row.setA(!row.getA());
- customTableData.update(rowIndex, row);
- }
- }
+ if (button == Mouse.Button.LEFT) {
+ @SuppressWarnings("unchecked")
+ List<CustomTableRow> customTableData =
+ (List<CustomTableRow>)TablesRollupStateHandler.this.customTableView.getTableData();
+
+ int columnIndex = TablesRollupStateHandler.this.customTableView.getColumnAt(x);
+ if (columnIndex == 0) {
+ int rowIndex = TablesRollupStateHandler.this.customTableView.getRowAt(y);
+ CustomTableRow row = customTableData.get(rowIndex);
+
+ row.setA(!row.getA());
+ customTableData.update(rowIndex, row);
+ }
+ }
return false;
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraScrollBarSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraScrollBarSkin.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraScrollBarSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraScrollBarSkin.java Tue Oct 1 13:42:21 2013
@@ -534,9 +534,10 @@ public class TerraScrollBarSkin extends
int realValue = (int)(pixelValue / getValueScale());
// Bound the value
+ int start = scrollBar.getStart();
int end = scrollBar.getEnd();
int extent = scrollBar.getExtent();
- realValue = Math.min(Math.max(realValue, 0), end - extent);
+ realValue = Math.min(Math.max(realValue - start, start), end - extent);
// Update the scroll bar
scrollBar.setValue(realValue);
@@ -718,7 +719,7 @@ public class TerraScrollBarSkin extends
// scale that maps logical value to pixel value
int numLegalPixelValues = availableWidth - handleWidth + 1;
float valueScale = (float)numLegalPixelValues / (float)numLegalRealValues;
- int handleX = (int)(value * valueScale) +
+ int handleX = (int)((value - start) * valueScale) +
scrollUpButton.getWidth() - 1;
if (handleWidth > availableWidth) {
@@ -754,7 +755,7 @@ public class TerraScrollBarSkin extends
// scale maps logical value to pixel value
int numLegalPixelValues = availableHeight - handleHeight + 1;
float valueScale = (float)numLegalPixelValues / (float)numLegalRealValues;
- int handleY = (int)(value * valueScale) +
+ int handleY = (int)((value - start) * valueScale) +
scrollUpButton.getHeight() - 1;
if (handleHeight > availableHeight) {
@@ -1222,15 +1223,16 @@ public class TerraScrollBarSkin extends
// would be overkill. If all that has changed is the value, we can just
// update the handle's location and save the work of full invalidation.
if (handle.isVisible()) {
+ int start = scrollBar.getStart();
int value = scrollBar.getValue();
if (scrollBar.getOrientation() == Orientation.HORIZONTAL) {
- int handleX = (int)(value * getValueScale()) +
+ int handleX = (int)((value - start) * getValueScale()) +
scrollUpButton.getWidth() - 1;
handle.setLocation(handleX, 0);
} else {
- int handleY = (int)(value * getValueScale()) +
+ int handleY = (int)((value - start) * getValueScale()) +
scrollUpButton.getHeight() - 1;
handle.setLocation(0, handleY);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Application.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Application.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Application.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Application.java Tue Oct 1 13:42:21 2013
@@ -30,6 +30,7 @@ public interface Application {
* Application adapter.
*/
public static class Adapter implements Application {
+
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
// empty block
@@ -49,6 +50,7 @@ public interface Application {
public void resume() throws Exception {
// empty block
}
+
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Tue Oct 1 13:42:21 2013
@@ -2006,7 +2006,7 @@ public abstract class ApplicationContext
return cursor;
}
- private static void handleUncaughtException(Exception exception) {
+ protected static void handleUncaughtException(Exception exception) {
int n = 0;
for (Application application : applications) {
if (application instanceof Application.UncaughtExceptionHandler) {
@@ -2019,6 +2019,24 @@ public abstract class ApplicationContext
if (n == 0) {
exception.printStackTrace();
+
+ Display display = (displays.getLength() > 0) ? displays.get(0) : null;
+ if (display == null) {
+ return;
+ }
+
+ String message = exception.getClass().getName();
+
+ TextArea body = null;
+ String bodyText = exception.getMessage();
+ if (bodyText != null && bodyText.length() > 0) {
+ body = new TextArea();
+ body.setText(bodyText);
+ body.setEditable(false);
+ }
+
+ Alert alert = new Alert(MessageType.ERROR, message, null, body, false);
+ alert.open(display);
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java Tue Oct 1 13:42:21 2013
@@ -34,6 +34,7 @@ import org.apache.pivot.collections.immu
/**
* Application context used to execute applications in a web browser.
*/
+@SuppressWarnings("restriction")
public final class BrowserApplicationContext extends ApplicationContext {
/**
* Applet used to host applications in a web browser.
@@ -218,15 +219,15 @@ public final class BrowserApplicationCon
public void run() {
// Start the application
if (HostApplet.this.application != null) {
+ // Add the application to the application list
+ applications.add(HostApplet.this.application);
+
try {
HostApplet.this.application.startup(HostApplet.this.displayHost.getDisplay(),
new ImmutableMap<>(HostApplet.this.startupProperties));
} catch (Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
-
- // Add the application to the application list
- applications.add(HostApplet.this.application);
}
}
}
@@ -241,7 +242,7 @@ public final class BrowserApplicationCon
try {
HostApplet.this.application.shutdown(false);
} catch (Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
// Remove the application from the application list
@@ -330,23 +331,6 @@ public final class BrowserApplicationCon
paint(graphics);
}
- private void displayException(Exception exception) {
- exception.printStackTrace();
-
- String message = exception.getClass().getName();
-
- TextArea body = null;
- String bodyText = exception.getMessage();
- if (bodyText != null
- && bodyText.length() > 0) {
- body = new TextArea();
- body.setText(bodyText);
- body.setEditable(false);
- }
-
- Alert alert = new Alert(MessageType.ERROR, message, null, body, false);
- alert.open(this.displayHost.getDisplay());
- }
}
private static ArrayList<HostApplet> hostApplets = new ArrayList<>();
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Tue Oct 1 13:42:21 2013
@@ -649,10 +649,11 @@ public abstract class Component implemen
// The cursor that is displayed over the component
private Cursor cursor = null;
- // The tooltip text, delay, and trigger callback
+ // The tooltip text, delay, trigger callback, flag for wrapping its text
private String tooltipText = null;
private int tooltipDelay = 1000;
private ApplicationContext.ScheduledCallback triggerTooltipCallback = null;
+ private boolean tooltipWrapText = true;
// The component's drag source
private DragSource dragSource = null;
@@ -2316,6 +2317,31 @@ public abstract class Component implemen
}
/**
+ * Returns the tooltip's mode for wrapping its text.
+ *
+ * @return
+ * <tt>true</tt> if the tooltip text wrap mode is enabled; </tt>false</tt> if not.
+ */
+ public boolean getTooltipWrapText() {
+ return tooltipWrapText;
+ }
+
+ /**
+ * Sets the tooltip's text wrapping mode.
+ *
+ * @param tooltipWrapText
+ * The component's tooltip text wrap mode.
+ */
+ public void setTooltipWrapText(boolean tooltipWrapText) {
+ boolean previousTooltipWrapText = this.tooltipWrapText;
+
+ if (previousTooltipWrapText != tooltipWrapText) {
+ this.tooltipWrapText = tooltipWrapText;
+ // componentListeners.tooltipTextWrapChanged(this, previousTooltipWrapText); // verify if/when to implement it ...
+ }
+ }
+
+ /**
* Tells whether or not this component is fully opaque when painted.
*
* @return
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java Tue Oct 1 13:42:21 2013
@@ -258,7 +258,7 @@ public final class DesktopApplicationCon
try {
application.suspend();
} catch(Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
break;
@@ -267,7 +267,7 @@ public final class DesktopApplicationCon
try {
application.resume();
} catch(Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
break;
@@ -416,7 +416,7 @@ public final class DesktopApplicationCon
try {
cancelShutdown = application.shutdown(optional);
} catch(Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
if (!cancelShutdown) {
@@ -641,7 +641,7 @@ public final class DesktopApplicationCon
application.startup(primaryDisplayHost.getDisplay(),
new ImmutableMap<>(properties));
} catch (Exception exception) {
- displayException(exception);
+ handleUncaughtException(exception);
}
}
});
@@ -706,24 +706,6 @@ public final class DesktopApplicationCon
}
}
- private static void displayException(Exception exception) {
- exception.printStackTrace();
-
- String message = exception.getClass().getName();
-
- TextArea body = null;
- String bodyText = exception.getMessage();
- if (bodyText != null
- && bodyText.length() > 0) {
- body = new TextArea();
- body.setText(bodyText);
- body.setEditable(false);
- }
-
- Alert alert = new Alert(MessageType.ERROR, message, null, body, false);
- alert.open(primaryDisplayHost.getDisplay());
- }
-
/**
* Returns the full-screen mode flag.
*/
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java Tue Oct 1 13:42:21 2013
@@ -723,10 +723,10 @@ public class TextPane extends Container
* @see #setText
*/
public String getText() {
- Document document = getDocument();
- if (document != null && getCharacterCount() != 0) {
+ Document doc = getDocument();
+ if (doc != null && getCharacterCount() != 0) {
StringBuilder text = new StringBuilder(getCharacterCount());
- addToText(text, document);
+ addToText(text, doc);
return text.toString();
}
return null;
@@ -737,13 +737,13 @@ public class TextPane extends Container
* of one paragraph per line of the given text.
*/
public void setText(String text) {
- Document document = new Document();
+ Document doc = new Document();
String[] lines = text.split("\r?\n");
for (int i = 0; i < lines.length; i++) {
Paragraph paragraph = new Paragraph(lines[i]);
- document.add(paragraph);
+ doc.add(paragraph);
}
- setDocument(document);
+ setDocument(doc);
}
/**
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=1528088&r1=1528087&r2=1528088&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Tue Oct 1 13:42:21 2013
@@ -37,6 +37,8 @@ import org.apache.pivot.wtk.DragSource;
import org.apache.pivot.wtk.DropTarget;
import org.apache.pivot.wtk.FocusTraversalDirection;
import org.apache.pivot.wtk.Keyboard;
+import org.apache.pivot.wtk.Keyboard.KeyCode;
+import org.apache.pivot.wtk.Keyboard.Modifier;
import org.apache.pivot.wtk.Label;
import org.apache.pivot.wtk.MenuHandler;
import org.apache.pivot.wtk.Mouse;
@@ -44,8 +46,6 @@ import org.apache.pivot.wtk.Point;
import org.apache.pivot.wtk.Skin;
import org.apache.pivot.wtk.Theme;
import org.apache.pivot.wtk.Tooltip;
-import org.apache.pivot.wtk.Keyboard.KeyCode;
-import org.apache.pivot.wtk.Keyboard.Modifier;
/**
* Abstract base class for component skins.
@@ -295,7 +295,10 @@ public abstract class ComponentSkin impl
String tooltipText = component.getTooltipText();
if (tooltipText != null) {
- Tooltip tooltip = new Tooltip(new Label(tooltipText));
+ Label tooltipLabel = new Label(tooltipText);
+ boolean tooltipWrapText = component.getTooltipWrapText();
+ tooltipLabel.getStyles().put("wrapText", tooltipWrapText);
+ Tooltip tooltip = new Tooltip(tooltipLabel);
Display display = component.getDisplay();
Point location = component.mapPointToAncestor(display, x, y);
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=1528088&r1=1528087&r2=1528088&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 Tue Oct 1 13:42:21 2013
@@ -86,14 +86,24 @@ public class LabelSkin extends Component
Label label = (Label)getComponent();
String text = label.getText();
- int preferredWidth;
- if (text != null
- && text.length() > 0) {
+ int preferredWidth = 0;
+ if (text != null && text.length() > 0) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
- Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
- preferredWidth = (int)Math.ceil(stringBounds.getWidth());
- } else {
- preferredWidth = 0;
+ String str[];
+ if (wrapText) {
+ str = text.split("\n");
+ } else {
+ str = new String[] { text };
+ }
+
+ for (String line : str) {
+ Rectangle2D stringBounds = font.getStringBounds(line, fontRenderContext);
+ int w = (int)Math.ceil(stringBounds.getWidth());
+
+ if (w > preferredWidth) {
+ preferredWidth = w;
+ }
+ }
}
preferredWidth += (padding.left + padding.right);
@@ -172,20 +182,36 @@ public class LabelSkin extends Component
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
- int preferredWidth;
- if (text != null
- && text.length() > 0) {
- Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
- preferredWidth = (int)Math.ceil(stringBounds.getWidth());
+ LineMetrics lm = font.getLineMetrics("", fontRenderContext);
+ int lineHeight = (int)Math.ceil(lm.getHeight());
+
+ int preferredHeight = 0;
+ int preferredWidth = 0;
+
+ if (text != null && text.length() > 0) {
+ String str[];
+ if (wrapText) {
+ str = text.split("\n");
+ } else {
+ str = new String[] { text };
+ }
+
+ for (String line : str) {
+ Rectangle2D stringBounds = font.getStringBounds(line, fontRenderContext);
+ int w = (int)Math.ceil(stringBounds.getWidth());
+
+ if (w > preferredWidth) {
+ preferredWidth = w;
+ }
+ preferredHeight += lineHeight;
+ }
} else {
- preferredWidth = 0;
+ preferredHeight += lineHeight;
}
+ preferredHeight += (padding.top + padding.bottom);
preferredWidth += (padding.left + padding.right);
- LineMetrics lm = font.getLineMetrics("", fontRenderContext);
- int preferredHeight = (int)Math.ceil(lm.getHeight()) + (padding.top + padding.bottom);
-
return new Dimensions(preferredWidth, preferredHeight);
}