Nuiton-widgets-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
March 2010
- 2 participants
- 7 discussions
Author: tchemit
Date: 2010-03-27 21:05:37 +0100 (Sat, 27 Mar 2010)
New Revision: 252
Log:
Utilisation de mavenpom4redmine 2.0.7
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-25 09:51:44 UTC (rev 251)
+++ trunk/pom.xml 2010-03-27 20:05:37 UTC (rev 252)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.6</version>
+ <version>2.0.7</version>
</parent>
<artifactId>nuiton-widgets</artifactId>
1
0
r251 - in trunk/src/main/java/org/nuiton/widget: . datatips
by echatellier@users.nuiton.org 25 Mar '10
by echatellier@users.nuiton.org 25 Mar '10
25 Mar '10
Author: echatellier
Date: 2010-03-25 10:51:44 +0100 (Thu, 25 Mar 2010)
New Revision: 251
Log:
Add datatips code with nimbus fix.
Added:
trunk/src/main/java/org/nuiton/widget/datatips/
trunk/src/main/java/org/nuiton/widget/datatips/DataTipCell.java
trunk/src/main/java/org/nuiton/widget/datatips/DataTipComponent.java
trunk/src/main/java/org/nuiton/widget/datatips/DataTipListener.java
trunk/src/main/java/org/nuiton/widget/datatips/DataTipManager.java
trunk/src/main/java/org/nuiton/widget/datatips/DataTipPopup.java
trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipCell.java
trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipListener.java
trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipCell.java
trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipListener.java
trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipCell.java
trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipListener.java
trunk/src/main/java/org/nuiton/widget/datatips/package-info.java
Added: trunk/src/main/java/org/nuiton/widget/datatips/DataTipCell.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/DataTipCell.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/DataTipCell.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import java.awt.*;
+
+interface DataTipCell {
+
+ boolean isSet();
+
+ Component getRendererComponent();
+
+ Rectangle getCellBounds();
+
+ /**
+ * 'Null' value for cells (location is outside of any cell bounds).
+ */
+ DataTipCell NONE = new DataTipCell() {
+
+ public boolean isSet() {
+ return false;
+ }
+
+ public Component getRendererComponent() {
+ return null;
+ }
+
+ public Rectangle getCellBounds() {
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ return false;
+ }
+
+ public int hashCode() {
+ return 0;
+ }
+ };
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/DataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/DataTipComponent.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/DataTipComponent.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/DataTipComponent.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+
+/**
+ * Note: It's important to inherit from JToolTip: Mouse events get dispatched to the parent.<br/>
+ * I do not really know why this is so. At least PopupFactory creates a different type of popup
+ * if the content is instance of JToolTip.
+ */
+class DataTipComponent extends JToolTip {
+ private DataTipCell cell;
+ private CellRendererPane rendererPane;
+ private Rectangle withoutBorderRectangle;
+ private Color backgroundColor;
+ private boolean isHeavyWeight;
+
+ DataTipComponent(DataTipCell cell, Rectangle withoutBorderRectangle, Color backgroundColor) {
+ this.cell = cell;
+ this.withoutBorderRectangle = withoutBorderRectangle;
+ this.backgroundColor = backgroundColor;
+ rendererPane = new CellRendererPane();
+ add(rendererPane);
+ setFocusable(false);
+ setBorder(null);
+ enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+ }
+
+ /**
+ * Overriden, so that Swing does not create a ToolTipUI.
+ */
+ public void updateUI() {
+ }
+
+ /**
+ * Overriden to always return false, so that no component ever receives mouse events.
+ * Instead a mouse press will be caught on the popup's window ancestor, the popup will be hidden and the mouse press redispatched
+ * to the underlying component.
+ */
+ public boolean contains(int x, int y) {
+ return isHeavyWeight;
+ }
+
+ protected void processMouseEvent(MouseEvent e) {
+ DataTipManager.get().handleEventFromDataTipComponent(e);
+ }
+
+ protected void processMouseMotionEvent(MouseEvent e) {
+ DataTipManager.get().handleEventFromDataTipComponent(e);
+ }
+
+ protected void processMouseWheelEvent(MouseWheelEvent e) {
+ DataTipManager.get().handleEventFromDataTipComponent(e);
+ }
+
+ public void paintComponent(Graphics g) {
+ Component component = cell.getRendererComponent();
+
+ // Leave the component's opacity settings as is, just paint the background myself.
+ // This seems to be the only viable solution: DefaultTableCellRenderer overrides isOpaque() and returns
+ // true only if renderer color does not equal parent color. The problem is that rendererPane.paintComponent()
+ // re-parents the renderer.
+ g.setColor(backgroundColor);
+ int width = getWidth();
+ int height = getHeight();
+ g.fillRect(0, 0, width, height);
+
+ g.setColor(Color.black);
+ g.drawRect(0, 0, width - 1, height - 1);
+
+ if (withoutBorderRectangle != null) {
+ Shape oldClip = g.getClip();
+ g.setClip(withoutBorderRectangle);
+ g.setColor(backgroundColor);
+ g.fillRect(0, 0, width, height);
+ g.setClip(oldClip);
+ }
+
+ g.setClip(1, 1, width - 2, height - 2);
+ rendererPane.paintComponent(g, component, this, 0, 0, width, height);
+ g.setClip(withoutBorderRectangle);
+ rendererPane.paintComponent(g, component, this, 0, 0, width, height);
+ }
+
+ public void setHeavyWeight(boolean isHeavyWeight) {
+ this.isHeavyWeight = isHeavyWeight;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/DataTipComponent.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/DataTipListener.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/DataTipListener.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/DataTipListener.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import javax.swing.*;
+import javax.swing.event.MouseInputAdapter;
+import java.awt.*;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.MouseEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+abstract class DataTipListener extends MouseInputAdapter implements ComponentListener {
+ private DataTipPopup dataTipPopup;
+
+ // When running under JDK 1.5 (or higher) DataTipListener will check if the tip must be updated when the parent
+ // component changes size or moves.
+ // With JDK 1.4 or earlier this does not work, because no mouse event gets posted (even though the relative mouse
+ // position changes) - yet to be able to compile with 1.4 the necessary JDK 1.5 methods are called by reflection.
+ // On JDK 1.4 the popup is just always hidden qwhen the component changes (and reshown when the user first moves
+ // the mouse again).
+ private static final Class[] NO_PARAMETERS = new Class[0];
+ private static final Object[] NO_ARGUMENTS = new Object[0];
+ private static Class mouseInfoClass;
+ private static Method getPointerInfoMethod;
+ private static Class pointerInfoClass;
+ private static Method getLocationMethod;
+
+ static {
+ try {
+ mouseInfoClass = Class.forName("java.awt.MouseInfo");
+ getPointerInfoMethod = mouseInfoClass.getMethod("getPointerInfo", NO_PARAMETERS);
+ pointerInfoClass = Class.forName("java.awt.PointerInfo");
+ getLocationMethod = pointerInfoClass.getMethod("getLocation", NO_PARAMETERS);
+ }
+ catch(NoSuchMethodException e) {
+ // fine probably running on pre-1.5-JDK
+ }
+ catch(ClassNotFoundException e) {
+ // fine probably running on pre-1.5-JDK
+ }
+ }
+
+ DataTipListener() {
+ }
+
+ /**
+ * @return the cell that is at position 'point' in the component or DataTipCell.NONE if there isn't a cell at that
+ * point.
+ */
+ abstract DataTipCell getCell(JComponent component, Point point);
+
+ /**
+ * If the user presses a mouse button on a popup, Swing's behaviour depends on the popup type:
+ * - lightweight popup:
+ * This case is handled here. Because the TipComponent.contains(int x, int y) is overriden to always return false
+ * Swing will dispath the event directly to the parent component.
+ * - heavyweight popup:
+ * Swing will dispatch the event to the popup's window, which is handled in DataTipPopup.
+ */
+ public void mousePressed(MouseEvent e) {
+ //hideTip(); Can't: Double click would not work. Click count of the second click would be '1', because it would
+ // go to a different window (for heavyweight datatips).
+ }
+
+ public void mouseEntered(MouseEvent event) {
+ checkShowOrHide(event);
+ }
+
+ public void mouseExited(MouseEvent event) {
+ checkShowOrHide(event);
+ }
+
+ public void mouseDragged(MouseEvent event) {
+ checkShowOrHide(event);
+ }
+
+ public void mouseMoved(MouseEvent event) {
+ checkShowOrHide(event);
+ }
+
+ private void checkShowOrHide(MouseEvent event) {
+ JComponent component = (JComponent) event.getSource();
+ Point mousePosition = event.getPoint();
+ checkShowOrHide(component, mousePosition);
+ }
+
+ private void checkShowOrHide(JComponent component, Point mousePosition) {
+ Window windowAncestor = SwingUtilities.getWindowAncestor(component);
+ if (windowAncestor == null || !windowAncestor.isActive()) {
+ hideTip();
+ return;
+ }
+
+ DataTipCell dataTipCell = getCell(component, mousePosition);
+ Rectangle visRect = component.getVisibleRect();
+
+ if(!visRect.contains(mousePosition)) {
+ dataTipCell = DataTipCell.NONE;
+ }
+
+ DataTipCell currentPopupCell = getCurrentPopupCell();
+ if(dataTipCell.equals(currentPopupCell)) {
+ return;
+ }
+
+ hideTip();
+ if(!dataTipCell.isSet()) {
+ return;
+ }
+
+ dataTipPopup = createPopup(component, mousePosition, dataTipCell);
+ }
+
+ private DataTipCell getCurrentPopupCell() {
+ if(!isTipShown()) {
+ return DataTipCell.NONE;
+ }
+ return dataTipPopup.getCell();
+ }
+
+ private DataTipPopup createPopup(JComponent component, Point mousePosition, DataTipCell dataTipCell) {
+ Rectangle cellBounds = dataTipCell.getCellBounds();
+
+ Rectangle visRect = component.getVisibleRect();
+ Rectangle visibleCellRectangle = cellBounds.intersection(visRect);
+ if (!visibleCellRectangle.contains(mousePosition)) {
+ return null;
+ }
+
+ Component rendererComponent = dataTipCell.getRendererComponent();
+ Dimension rendCompDim = rendererComponent.getMinimumSize();
+ Rectangle rendCompBounds = new Rectangle(cellBounds.getLocation(), rendCompDim);
+ if(cellBounds.contains(rendCompBounds) && visRect.contains(rendCompBounds)) {
+ return null;
+ }
+
+ Dimension preferredSize = rendererComponent.getPreferredSize();
+ Point tipPosition = cellBounds.getLocation();
+ int width = Math.max(cellBounds.width, preferredSize.width);
+ int height = Math.max(cellBounds.height, preferredSize.height);
+ Dimension tipDimension = new Dimension(width, height);
+ DataTipPopup dataTipPopup = new DataTipPopup(component, dataTipCell, tipPosition, tipDimension);
+
+ return dataTipPopup;
+ }
+
+ private boolean isTipShown() {
+ return dataTipPopup != null && dataTipPopup.isTipShown();
+ }
+
+ private void hideTip() {
+ if (dataTipPopup != null) {
+ dataTipPopup.hideTip();
+ dataTipPopup = null;
+ }
+ }
+
+ public void componentResized(ComponentEvent e) {
+ checkShowOrHide(e);
+ }
+
+ public void componentMoved(ComponentEvent e) {
+ checkShowOrHide(e);
+ }
+
+ public void componentShown(ComponentEvent e) {
+ checkShowOrHide(e);
+ }
+
+ public void componentHidden(ComponentEvent e) {
+ hideTip();
+ }
+
+ private void checkShowOrHide(ComponentEvent e) {
+ JComponent component = (JComponent) e.getSource();
+ Point mousePosition = getCurrentMousePosition();
+ if(mousePosition == null) {
+ hideTip();
+ }
+ else {
+ SwingUtilities.convertPointFromScreen(mousePosition, component);
+ checkShowOrHide(component, mousePosition);
+ }
+ }
+
+ private static Point getCurrentMousePosition() {
+ if(mouseInfoClass == null) {
+ return null;
+ }
+ try {
+ Object pointerInfo = getPointerInfoMethod.invoke(null, NO_ARGUMENTS);
+ Point mousePosition = (Point) getLocationMethod.invoke(pointerInfo, NO_ARGUMENTS);
+ return mousePosition;
+ }
+ catch(IllegalAccessException e) {
+ // strange, but nothing I can do here
+ }
+ catch(InvocationTargetException e) {
+ // strange, but nothing I can do here
+ }
+
+ return null;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/DataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/DataTipManager.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/DataTipManager.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/DataTipManager.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.AWTEventListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.security.AccessControlException;
+
+/**
+ * <code>DataTipManager</code> provides data tips for tree, table and list components. Whenever the mouse cursor is
+ * over a cell whose content is partially hidden a popup with the complete cell content is shown.
+ * The cell content can be hidden because it is clipped at either the parent component bounds (e.g. scrollpane) or at
+ * the cell bounds (e.g. table row height is too small).
+ */
+public class DataTipManager {
+ private static DataTipManager instance;
+
+ private ListDataTipListener listMouseListener = new ListDataTipListener();
+ private TableDataTipListener tableMouseListener = new TableDataTipListener();
+ private TreeDataTipListener treeMouseListener = new TreeDataTipListener();
+ private Component parentComponent;
+ private Window tipComponentWindow;
+ private MouseEvent lastMouseEvent;
+ private static boolean allowUntrustedUsage;
+
+ private DataTipManager() {
+ try {
+ long eventMask = AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK;
+ Toolkit.getDefaultToolkit().addAWTEventListener(new MouseEventModifier(), eventMask);
+ }
+ catch(AccessControlException e) {
+ if(!allowUntrustedUsage) {
+ throw new RuntimeException("DataTipManager needs to run in a trusted application", e);
+ }
+ }
+ }
+
+ static void enableUntrustedUsage(boolean enable) {
+ allowUntrustedUsage = enable;
+ }
+
+ /**
+ * @return the single, shared instance of the DataTipmanager
+ */
+ public static synchronized DataTipManager get() {
+ if(instance == null) {
+ instance = new DataTipManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Enable data tips for a list component.
+ * @param list the list which should be enhanced with data tips.
+ */
+ public synchronized void register(JList list) {
+ list.addMouseListener(listMouseListener);
+ list.addMouseMotionListener(listMouseListener);
+ list.addComponentListener(listMouseListener);
+ }
+
+ /**
+ * Enable data tips for a tree component.
+ * @param tree the tree which should be enhanced with data tips.
+ */
+ public synchronized void register(JTree tree) {
+ tree.addMouseListener(treeMouseListener);
+ tree.addMouseMotionListener(treeMouseListener);
+ tree.addComponentListener(treeMouseListener);
+ }
+
+ /**
+ * Enable data tips for a list component.
+ * @param table the table which should be enhanced with data tips.
+ */
+ public synchronized void register(JTable table) {
+ table.addMouseListener(tableMouseListener);
+ table.addMouseMotionListener(tableMouseListener);
+ table.addComponentListener(tableMouseListener);
+ }
+
+ void setTipWindow(Component parentComponent, Window dataTipComponent) {
+ this.parentComponent = parentComponent;
+ tipComponentWindow = dataTipComponent;
+ }
+
+ public boolean handleEventFromParentComponent(MouseEvent mouseEvent) {
+ // filter out events that come from client explicitly calling this method, but we have already handled in awt event listener
+ if(mouseEvent == lastMouseEvent) {
+ return false;
+ }
+ Object source = mouseEvent.getSource();
+ if(source != parentComponent) {
+ return false;
+ }
+ int id = mouseEvent.getID();
+ int x = mouseEvent.getX();
+ int y = mouseEvent.getY();
+ long when = mouseEvent.getWhen();
+ int modifiers = mouseEvent.getModifiers();
+ int clickCount = mouseEvent.getClickCount();
+ boolean isPopupTrigger = mouseEvent.isPopupTrigger();
+ if(id == MouseEvent.MOUSE_EXITED) {
+ Point point = SwingUtilities.convertPoint(parentComponent, x, y, tipComponentWindow);
+ if(tipComponentWindow.contains(point)) {
+ MouseEvent newEvent = new MouseEvent(parentComponent, MouseEvent.MOUSE_MOVED, when, modifiers,
+ x, y, clickCount, isPopupTrigger);
+ parentComponent.dispatchEvent(newEvent);
+ // If the datatip has been hidden as a result, then process the exit event, too, so that
+ // e.g. tooltips will hide.
+ boolean stillVisible = parentComponent != null;
+ return stillVisible;
+ }
+ }
+ return false;
+ }
+
+ public void handleEventFromDataTipComponent(MouseEvent mouseEvent) {
+ mouseEvent.consume();
+ int id = mouseEvent.getID();
+ if(id != MouseEvent.MOUSE_ENTERED) {
+ int x = mouseEvent.getX();
+ int y = mouseEvent.getY();
+ Point point = SwingUtilities.convertPoint(mouseEvent.getComponent(), x, y, parentComponent);
+
+ if(id == MouseEvent.MOUSE_EXITED && parentComponent.contains(point)) {
+ return;
+ }
+ long when = mouseEvent.getWhen();
+ int modifiers = mouseEvent.getModifiers();
+ int clickCount = mouseEvent.getClickCount();
+ boolean isPopupTrigger = mouseEvent.isPopupTrigger();
+ MouseEvent newEvent;
+ if(id == MouseEvent.MOUSE_WHEEL) {
+ MouseWheelEvent mouseWheelEvent = (MouseWheelEvent) mouseEvent;
+ int scrollType = mouseWheelEvent.getScrollType();
+ int scrollAmount = mouseWheelEvent.getScrollAmount();
+ int wheelRotation = mouseWheelEvent.getWheelRotation();
+ newEvent = new MouseWheelEvent(parentComponent, id, when, modifiers, point.x, point.y,
+ clickCount, isPopupTrigger, scrollType, scrollAmount,
+ wheelRotation);
+ }
+ else {
+ newEvent = new MouseEvent(parentComponent, id, when, modifiers, point.x, point.y,
+ clickCount, isPopupTrigger);
+ }
+ Component parentComponentBackup = parentComponent;
+ parentComponent.dispatchEvent(newEvent);
+ if(parentComponent == null && id != MouseEvent.MOUSE_EXITED) {
+ MouseEvent exitEvent = new MouseEvent(parentComponentBackup, MouseEvent.MOUSE_EXITED, when,
+ modifiers, point.x, point.y, clickCount, isPopupTrigger);
+ parentComponentBackup.dispatchEvent(exitEvent);
+ }
+ if(tipComponentWindow != null && id != MouseEvent.MOUSE_MOVED) {
+ // mouse click might have changed appearance (e.g. selection color)
+ tipComponentWindow.repaint();
+ }
+ }
+ }
+
+ private class MouseEventModifier implements AWTEventListener {
+ private MouseEventModifier() {
+ }
+
+ public void eventDispatched(AWTEvent event) {
+ if(tipComponentWindow == null) {
+ return;
+ }
+ Object source = event.getSource();
+
+ if(source == parentComponent) {
+ MouseEvent mouseEvent = (MouseEvent) event;
+ boolean filter = handleEventFromParentComponent(mouseEvent);
+ if(filter) {
+ mouseEvent.consume();
+ }
+ else {
+ lastMouseEvent = mouseEvent;
+ }
+ }
+ }
+ }
+}
+
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/DataTipManager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/DataTipPopup.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/DataTipPopup.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/DataTipPopup.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import javax.swing.*;
+import java.awt.*;
+
+class DataTipPopup {
+ private Popup popup;
+ private DataTipCell cell;
+
+ DataTipPopup(JComponent parent, DataTipCell cell, Point tipPosition, Dimension tipDimension) {
+ this.cell = cell;
+ Rectangle parentVisibleRect = parent.getVisibleRect();
+ Rectangle withoutBorderRectangle = parentVisibleRect.intersection(new Rectangle(tipPosition, tipDimension));
+ withoutBorderRectangle.translate(-tipPosition.x, -tipPosition.y);
+
+ DataTipComponent dataTipComponent = new DataTipComponent(cell, withoutBorderRectangle, parent.getBackground());
+
+ Dimension tipDimensionClipped = new Dimension(tipDimension.width, tipDimension.height);
+ Window windowAncestor = SwingUtilities.getWindowAncestor(parent);
+ GraphicsConfiguration gc = windowAncestor.getGraphicsConfiguration();
+ Rectangle screenBounds = gc.getBounds();
+ Point tipScreenPosition = new Point(tipPosition.x, tipPosition.y);
+ SwingUtilities.convertPointToScreen(tipScreenPosition, parent);
+ Point tipPositionClipped = new Point();
+ tipPositionClipped.x = Math.max(tipScreenPosition.x, screenBounds.x);
+ tipPositionClipped.y = Math.max(tipScreenPosition.y, screenBounds.y);
+ tipDimensionClipped.width = Math.min(screenBounds.x + screenBounds.width - tipPositionClipped.x, tipDimensionClipped.width);
+ tipDimensionClipped.height = Math.min(screenBounds.y + screenBounds.height - tipPositionClipped.y, tipDimensionClipped.height);
+ SwingUtilities.convertPointFromScreen(tipPositionClipped, parent);
+ dataTipComponent.setPreferredSize(tipDimensionClipped);
+ SwingUtilities.convertPointToScreen(tipPosition, parent);
+
+ PopupFactory popupFactory = PopupFactory.getSharedInstance();
+ popup = popupFactory.getPopup(parent, dataTipComponent, tipPosition.x, tipPosition.y);
+ popup.show();
+ Window componentWindow = SwingUtilities.windowForComponent(parent);
+ Window tipWindow = SwingUtilities.windowForComponent(dataTipComponent);
+ //noinspection ObjectEquality
+ boolean isHeavyWeight = tipWindow != null && tipWindow != componentWindow;
+ dataTipComponent.setHeavyWeight(isHeavyWeight);
+ if (isHeavyWeight) {
+// ToolTipManager.sharedInstance().registerComponent(dataTipComponent);
+ DataTipManager.get().setTipWindow(parent, tipWindow);
+ }
+ }
+
+ DataTipCell getCell() {
+ return cell;
+ }
+
+ void hideTip() {
+ if (popup != null) {
+ popup.hide();
+ popup = null;
+
+ DataTipManager.get().setTipWindow(null, null);
+ }
+ }
+
+ public boolean isTipShown() {
+ return popup != null;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/DataTipPopup.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipCell.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipCell.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipCell.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import org.nuiton.widget.datatips.DataTipCell;
+
+import javax.swing.*;
+import java.awt.*;
+
+class ListDataTipCell implements DataTipCell {
+ private final JList list;
+ private final int rowIndex;
+
+ ListDataTipCell(JList list, int rowIndex) {
+ this.list = list;
+ this.rowIndex = rowIndex;
+ }
+
+ public boolean isSet() {
+ return rowIndex >= 0;
+ }
+
+ public Rectangle getCellBounds() {
+ Rectangle cellRect = list.getCellBounds(rowIndex, rowIndex);
+ return cellRect;
+ }
+
+ public Component getRendererComponent() {
+ Object item = list.getModel().getElementAt(rowIndex);
+ boolean isSelected = list.isSelectedIndex(rowIndex);
+ boolean isFocussed = list.hasFocus() && rowIndex == list.getLeadSelectionIndex();
+ ListCellRenderer renderer = list.getCellRenderer();
+ Component component = renderer.getListCellRendererComponent(list, item, rowIndex, isSelected, isFocussed);
+ return component;
+ }
+
+ public boolean equals(Object o) {
+ if(this == o) {
+ return true;
+ }
+ if(o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ ListDataTipCell listDataTipCell = (ListDataTipCell) o;
+
+ if(rowIndex != listDataTipCell.rowIndex) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return rowIndex;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipListener.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipListener.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipListener.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import org.nuiton.widget.datatips.DataTipCell;
+import org.nuiton.widget.datatips.DataTipListener;
+import org.nuiton.widget.datatips.ListDataTipCell;
+
+import javax.swing.*;
+import java.awt.*;
+
+class ListDataTipListener extends DataTipListener {
+ ListDataTipListener() {
+ }
+
+ DataTipCell getCell(JComponent component, Point point) {
+ JList list = (JList) component;
+ int index = list.locationToIndex(point);
+ if (index < 0) {
+ return DataTipCell.NONE;
+ }
+ return new ListDataTipCell(list, index);
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/ListDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipCell.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipCell.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipCell.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import org.nuiton.widget.datatips.DataTipCell;
+
+import javax.swing.*;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+
+class TableDataTipCell implements DataTipCell {
+ private final JTable table;
+ private final int rowIndex;
+ private final int columnIndex;
+
+ TableDataTipCell(JTable table, int rowIndex, int columnIndex) {
+ this.table = table;
+ this.rowIndex = rowIndex;
+ this.columnIndex = columnIndex;
+ }
+
+ public boolean isSet() {
+ return rowIndex >= 0 && columnIndex >= 0;
+ }
+
+ public Rectangle getCellBounds() {
+ Rectangle cellRect = table.getCellRect(rowIndex, columnIndex, false);
+ return cellRect;
+ }
+
+ public Component getRendererComponent() {
+ TableCellRenderer cellRenderer = table.getCellRenderer(rowIndex, columnIndex);
+ Component component = table.prepareRenderer(cellRenderer, rowIndex, columnIndex);
+ return component;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ TableDataTipCell cellPosition = (TableDataTipCell) o;
+
+ if (columnIndex != cellPosition.columnIndex) {
+ return false;
+ }
+ if (rowIndex != cellPosition.rowIndex) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = rowIndex;
+ result = 29 * result + columnIndex;
+ return result;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipListener.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipListener.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipListener.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import org.nuiton.widget.datatips.DataTipCell;
+import org.nuiton.widget.datatips.DataTipListener;
+import org.nuiton.widget.datatips.TableDataTipCell;
+
+import javax.swing.*;
+import java.awt.*;
+
+class TableDataTipListener extends DataTipListener {
+ TableDataTipListener() {
+ }
+
+ DataTipCell getCell(JComponent component, Point point) {
+ JTable table = (JTable) component;
+ int rowIndex = table.rowAtPoint(point);
+ int columnIndex = table.columnAtPoint(point);
+ if (rowIndex < 0 || columnIndex < 0) {
+ return DataTipCell.NONE;
+ }
+ TableDataTipCell cellPosition = new TableDataTipCell(table, rowIndex, columnIndex);
+ return cellPosition;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/TableDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipCell.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipCell.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipCell.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import java.awt.Component;
+import java.awt.Rectangle;
+
+import javax.swing.JTree;
+import javax.swing.UIManager;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+class TreeDataTipCell implements DataTipCell {
+ private final JTree tree;
+ private final int rowIndex;
+
+ public TreeDataTipCell(JTree tree, int rowIndex) {
+ this.tree = tree;
+ this.rowIndex = rowIndex;
+ }
+
+ public boolean isSet() {
+ return rowIndex >= 0;
+ }
+
+ public Rectangle getCellBounds() {
+ TreePath treePath = tree.getPathForRow(rowIndex);
+ Rectangle cellRect = tree.getPathBounds(treePath);
+ return cellRect;
+ }
+
+ public Component getRendererComponent() {
+ TreeModel treeModel = tree.getModel();
+ TreePath treePath = tree.getPathForRow(rowIndex);
+ TreeCellRenderer renderer = tree.getCellRenderer();
+ boolean isSelected = tree.isPathSelected(treePath);
+ boolean isExpanded = tree.isExpanded(treePath);
+ boolean hasFocus = tree.hasFocus() && rowIndex == tree.getLeadSelectionRow();
+ Object item = treePath.getLastPathComponent();
+ boolean isLeaf = treeModel.isLeaf(item);
+ Component component = renderer.getTreeCellRendererComponent(tree, item, isSelected, isExpanded, isLeaf, rowIndex, hasFocus);
+ component.setFont(tree.getFont());
+
+ // FIX Nimbus white foreground on white background
+ if (isSelected) {
+ component.setForeground(UIManager.getColor("Tree.textForeground"));
+ }
+
+ return component;
+ }
+
+ public boolean equals(Object o) {
+ if(this == o) {
+ return true;
+ }
+ if(o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ TreeDataTipCell treeDataTipCell = (TreeDataTipCell) o;
+
+ if(rowIndex != treeDataTipCell.rowIndex) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return rowIndex;
+ }
+}
+
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipListener.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipListener.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipListener.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002 - 2005, Stephen Kelvin Friedrich. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ * - Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.nuiton.widget.datatips;
+
+import org.nuiton.widget.datatips.DataTipCell;
+import org.nuiton.widget.datatips.DataTipListener;
+import org.nuiton.widget.datatips.TreeDataTipCell;
+
+import javax.swing.*;
+import java.awt.*;
+
+class TreeDataTipListener extends DataTipListener {
+ TreeDataTipListener() {
+ }
+
+ DataTipCell getCell(JComponent component, Point point) {
+ JTree tree = (JTree) component;
+ int rowIndex = tree.getRowForLocation(point.x, point.y);
+ if (rowIndex < 0) {
+ return DataTipCell.NONE;
+ }
+ return new TreeDataTipCell(tree, rowIndex);
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/TreeDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/datatips/package-info.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/datatips/package-info.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/datatips/package-info.java 2010-03-25 09:51:44 UTC (rev 251)
@@ -0,0 +1,8 @@
+/**
+ * Add data tips to your Swing table, tree or list.
+ *
+ * Those classes has been copied from original project :
+ * https://datatips.dev.java.net/ and just contains some bugfixes
+ * for nimbus look'n'feel.
+ */
+package org.nuiton.widget.datatips;
Property changes on: trunk/src/main/java/org/nuiton/widget/datatips/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r250 - in trunk/src/main: java/org/nuiton/widget/tooltip resources/i18n
by echatellier@users.nuiton.org 24 Mar '10
by echatellier@users.nuiton.org 24 Mar '10
24 Mar '10
Author: echatellier
Date: 2010-03-24 14:13:33 +0100 (Wed, 24 Mar 2010)
New Revision: 250
Log:
Replace RessourceBundle by nuiton-i18n
Removed:
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties
Modified:
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java
trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java
trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties
trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties
Modified: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-03-24 13:13:33 UTC (rev 250)
@@ -75,8 +75,8 @@
*/
private static final int MARGIN = 10;
- private static final String MSG = "org.nuiton.widget.tooltip.FocusableTip";
- private static final ResourceBundle msg = ResourceBundle.getBundle(MSG);
+ //private static final String MSG = "org.nuiton.widget.tooltip.FocusableTip";
+ //private static final ResourceBundle msg = ResourceBundle.getBundle(MSG);
public FocusableTip(JComponent attachedComponent, HyperlinkListener listener) {
@@ -169,15 +169,15 @@
}
- /**
+ /*
* Returns localized text for the given key.
*
* @param key The key into the resource bundle.
* @return The localized text.
- */
+ *
static String getString(String key) {
return msg.getString(key);
- }
+ }*/
/**
Deleted: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties 2010-03-24 13:13:33 UTC (rev 250)
@@ -1 +0,0 @@
-FocusHotkey=Press 'F2' for focus
\ No newline at end of file
Deleted: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties 2010-03-24 13:13:33 UTC (rev 250)
@@ -1 +0,0 @@
-FocusHotkey=Appuyez sur 'F2' pour agrandir
\ No newline at end of file
Modified: trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java 2010-03-24 13:13:33 UTC (rev 250)
@@ -22,6 +22,8 @@
*/
package org.nuiton.widget.tooltip;
+import static org.nuiton.i18n.I18n._;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -244,7 +246,7 @@
}
else {
panel.setOpaque(false);
- JLabel label = new JLabel(FocusableTip.getString("FocusHotkey"));
+ JLabel label = new JLabel(_("nuitonwidgets.tootilp.focushotkey")/*FocusableTip.getString("FocusHotkey")*/);
Color fg = UIManager.getColor("Label.disabledForeground");
Font font = textArea.getFont();
font = font.deriveFont(font.getSize2D() - 1.0f);
Modified: trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties 2010-03-24 13:13:33 UTC (rev 250)
@@ -22,3 +22,4 @@
nuitonwidgets.monitor.stream.log=Log stream
nuitonwidgets.monitor.stream.output=Output stream
nuitonwidgets.monitor.title=Application console
+nuitonwidgets.tootilp.focushotkey=Press 'F2' for focus
Modified: trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties 2010-03-15 14:56:12 UTC (rev 249)
+++ trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties 2010-03-24 13:13:33 UTC (rev 250)
@@ -22,3 +22,4 @@
nuitonwidgets.monitor.stream.log=Logs
nuitonwidgets.monitor.stream.output=Sortie standard
nuitonwidgets.monitor.title=Moniteur de l'application
+nuitonwidgets.tootilp.focushotkey=Appuyez sur 'F2' pour agrandir
1
0
r249 - in trunk/src/site: . resources resources/images resources/images/components rst rst/components
by echatellier@users.nuiton.org 15 Mar '10
by echatellier@users.nuiton.org 15 Mar '10
15 Mar '10
Author: echatellier
Date: 2010-03-15 15:56:12 +0100 (Mon, 15 Mar 2010)
New Revision: 249
Log:
Add doc for tree filtering and focusable tooltips
Added:
trunk/src/site/resources/
trunk/src/site/resources/images/
trunk/src/site/resources/images/components/
trunk/src/site/resources/images/components/focusablett1.jpg
trunk/src/site/resources/images/components/focusablett2.jpg
trunk/src/site/rst/components/
trunk/src/site/rst/components/focusabletooltips.rst
trunk/src/site/rst/components/treefilters.rst
trunk/src/site/site_fr.xml
Removed:
trunk/src/site/site_fr.xml
Modified:
trunk/src/site/rst/index.rst
Added: trunk/src/site/resources/images/components/focusablett1.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/components/focusablett1.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/resources/images/components/focusablett2.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/components/focusablett2.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/rst/components/focusabletooltips.rst
===================================================================
--- trunk/src/site/rst/components/focusabletooltips.rst (rev 0)
+++ trunk/src/site/rst/components/focusabletooltips.rst 2010-03-15 14:56:12 UTC (rev 249)
@@ -0,0 +1,50 @@
+Focusables tooltips
+===================
+
+Focusable tooltips are eclipse-like tooltips original taken from `RSyntaxTextArea`_
+project.
+
+The nuiton-widget version also include modification to allow putting focusable
+tooltips on non-``JTextArea`` ``JComponent``s.
+
+Screenshots
+-----------
+
+Default tooltip:
+
+.. image:: ../images/components/focusablett1.jpg
+
+Focused tooltip:
+
+.. image:: ../images/components/focusablett2.jpg
+
+Using
+-----
+
+To use focusable tooltip, you need to redefine the ``getTooltipText()`` method
+on related components ::
+
+ JTable table = new JTable(tableModel) {
+ /** Single tooltip instance. */
+ protected FocusableTip focusableTip;
+
+ @Override
+ public String getToolTipText(MouseEvent e) {
+ String text = super.getToolTipText(e);
+ if (focusableTip == null) {
+ focusableTip = new FocusableTip(this, null);
+ }
+ focusableTip.toolTipRequested(e, text);
+
+ return null;
+ }
+ };
+
+
+Sources
+-------
+
+ * `Fifesoft blog`_.
+
+.. _RSyntaxTextArea: http://fifesoft.com/rsyntaxtextarea/
+.. _Fifesoft blog: http://fifesoft.com/blog/?p=93
\ No newline at end of file
Added: trunk/src/site/rst/components/treefilters.rst
===================================================================
--- trunk/src/site/rst/components/treefilters.rst (rev 0)
+++ trunk/src/site/rst/components/treefilters.rst 2010-03-15 14:56:12 UTC (rev 249)
@@ -0,0 +1,44 @@
+Tree filtering
+==============
+
+Nuiton-widget provide basic model based tree filtering.
+
+API
+---
+
+Only two classes are provided:
+
+ * TreeFilter : Interface for tree filter implementation
+ * TreeFilterModel : Filtered tree model
+
+The TreeFilter currently has only one method ``include`` which must return
+``true`` only if parameter node must be displayed.
+
+Using
+-----
+
+Define your filtered tree::
+
+ public class Test {
+
+ protected FilterTreeModel filterModel;
+
+ [...]
+
+ protected void buildUI() {
+
+ TreeModel realModel = ...
+ filterModel = new FilterTreeModel(realModel);
+
+ JTree tree = new JTree(filterModel);
+
+ [...]
+ }
+
+Then apply filtering (when filter need to be updated)::
+
+ [...]
+ protected void updateFilter(String filterString) {
+ TreeFilter myTreeFilter = new MyTreeFilter(filterString);
+ filterModel.setTreeFilter(myTreeFilter);
+ }
\ No newline at end of file
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2010-03-15 14:08:10 UTC (rev 248)
+++ trunk/src/site/rst/index.rst 2010-03-15 14:56:12 UTC (rev 249)
@@ -1,4 +1,21 @@
Nuiton widgets
==============
-Todo
+Swing components set.
+
+Components
+----------
+
+ * `Tree filters`_.
+ * `Focusable tooltips`_.
+
+Others components
+-----------------
+
+Other usefull components but not included in nuiton-widgets.
+
+ * `Datatips`_.
+
+.. _Tree filters: components/treefilters.html
+.. _Focusable tooltips: components/focusabletooltips.html
+.. _Datatips: https://datatips.dev.java.net/
\ No newline at end of file
Deleted: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2010-03-15 14:08:10 UTC (rev 248)
+++ trunk/src/site/site_fr.xml 2010-03-15 14:56:12 UTC (rev 249)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>index.html</href>
- </bannerLeft>
-
- <poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
- <logo href="http://maven-site.nuiton.org/jrst/" name="JRst" img="images/jrst-logo.png"/>
- <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/>
- </poweredBy>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="index.html" />
- </breadcrumbs>
-
- <menu name="Utilisateur">
- <item href="./index.html" name="Accueil"/>
- <item href="http://www.nuiton.org/projects/list_files/nuiton-widgets" name="Téléchargement"/>
- </menu>
-
- <menu name="Developpeur">
- <item name="Todo" href="Todo.html"/>
- </menu>
-
- <menu ref="reports"/>
-
- </body>
-</project>
Added: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml (rev 0)
+++ trunk/src/site/site_fr.xml 2010-03-15 14:56:12 UTC (rev 249)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
+ <logo href="http://maven-site.nuiton.org/jrst/" name="JRst" img="images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html" />
+ </breadcrumbs>
+
+ <menu name="Utilisateur">
+ <item href="./index.html" name="Accueil"/>
+ <item name="Composants">
+ <item href="components/treefilters.html" name="Tree filters"/>
+ <item href="components/focusabletooltips.html" name="Focusable tooltips"/>
+ </item>
+ </menu>
+
+ <menu name="Developpeur">
+ <item href="http://www.nuiton.org/projects/list_files/nuiton-widgets" name="Téléchargement"/>
+ <item name="Todo" href="Todo.html"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
1
0
r248 - in trunk/src/main/java/org/nuiton/widget: . tooltip
by echatellier@users.nuiton.org 15 Mar '10
by echatellier@users.nuiton.org 15 Mar '10
15 Mar '10
Author: echatellier
Date: 2010-03-15 15:08:10 +0100 (Mon, 15 Mar 2010)
New Revision: 248
Log:
#404 : Add focusable tooltips
Added:
trunk/src/main/java/org/nuiton/widget/tooltip/
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties
trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties
trunk/src/main/java/org/nuiton/widget/tooltip/SizeGrip.java
trunk/src/main/java/org/nuiton/widget/tooltip/TipUtil.java
trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java
trunk/src/main/java/org/nuiton/widget/tooltip/package-info.java
Added: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1,335 @@
+/*
+ * 07/29/2009
+ *
+ * FocusableTip.java - A focusable tool tip, like those in Eclipse.
+ * Copyright (C) 2009 Robert Futrell
+ * robert_futrell at users.sourceforge.net
+ * http://fifesoft.com/rsyntaxtextarea
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.nuiton.widget.tooltip;
+
+import java.awt.Component;
+import java.awt.ComponentOrientation;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.net.URL;
+import java.util.ResourceBundle;
+
+import javax.swing.JComponent;
+//import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
+import javax.swing.event.CaretEvent;
+import javax.swing.event.CaretListener;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.event.MouseInputAdapter;
+
+
+/**
+ * A focusable tool tip, similar to those found in Eclipse. The user
+ * can click in the tip and it becomes a "real," resizable window.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+public class FocusableTip {
+
+ private JComponent attachedComponent;
+ private TipWindow tipWindow;
+ private URL imageBase;
+ private AttachedComponentListener attachedComponentListener;
+ private HyperlinkListener hyperlinkListener;
+ private String lastText;
+
+ /**
+ * The screen bounds in which the mouse has to stay for the currently
+ * displayed tip to stay visible.
+ */
+ private Rectangle tipVisibleBounds;
+
+ /**
+ * Margin from mouse cursor at which to draw focusable tip.
+ */
+ private static final int MARGIN = 10;
+
+ private static final String MSG = "org.nuiton.widget.tooltip.FocusableTip";
+ private static final ResourceBundle msg = ResourceBundle.getBundle(MSG);
+
+
+ public FocusableTip(JComponent attachedComponent, HyperlinkListener listener) {
+ setAttachedComponent(attachedComponent);
+ this.hyperlinkListener = listener;
+ attachedComponentListener = new AttachedComponentListener();
+ tipVisibleBounds = new Rectangle();
+ }
+
+
+ /**
+ * Compute the bounds in which the user can move the mouse without the
+ * tip window disappearing.
+ */
+ private void computeTipVisibleBounds() {
+ // Compute area that the mouse can move in without hiding the
+ // tip window. Note that Java 1.4 can only detect mouse events
+ // in Java windows, not globally.
+ Rectangle r = tipWindow.getBounds();
+ Point p = r.getLocation();
+ SwingUtilities.convertPointFromScreen(p, attachedComponent);
+ r.setLocation(p);
+ tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2);
+ }
+
+
+ private void createAndShowTipWindow(final MouseEvent e, final String text) {
+
+ Window owner = SwingUtilities.getWindowAncestor(attachedComponent);
+ tipWindow = new TipWindow(owner, this, text);
+ tipWindow.setHyperlinkListener(hyperlinkListener);
+
+ // TODO: Position tip window better (handle RTL, edges of screen, etc.).
+ // Wrap in an invokeLater() to work around a JEditorPane issue where it
+ // doesn't return its proper preferred size until after it is displayed.
+ // See http://forums.sun.com/thread.jspa?forumID=57&threadID=574810
+ // for a discussion.
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+
+ // If a new FocusableTip is requested while another one is
+ // *focused* and visible, the focused tip (i.e. "tipWindow")
+ // will be disposed of. If this Runnable is run after the
+ // dispose(), tipWindow will be null. All of this is done on
+ // the EDT so no synchronization should be necessary.
+ if (tipWindow==null) {
+ return;
+ }
+
+ tipWindow.fixSize();
+ ComponentOrientation o = attachedComponent.getComponentOrientation();
+
+ Point p = e.getPoint();
+ SwingUtilities.convertPointToScreen(p, attachedComponent);
+ int x = o.isLeftToRight() ? (p.x-10) :
+ (p.x - tipWindow.getWidth() + MARGIN);
+ int y = p.y + MARGIN;
+
+ // Ensure tooltip is in the window bounds.
+ Dimension ss = tipWindow.getToolkit().getScreenSize();
+ x = Math.max(x, 0);
+ if (x+tipWindow.getWidth()>=ss.width) {
+ x = ss.width - tipWindow.getWidth();
+ }
+ if (y+tipWindow.getHeight()>=ss.height) { // Go above cursor
+ y = p.y - tipWindow.getHeight() - MARGIN;
+ }
+
+ tipWindow.setLocation(x, y);
+ tipWindow.setVisible(true);
+ tipWindow.toFront();
+ computeTipVisibleBounds(); // Do after tip is visible
+ attachedComponentListener.install(attachedComponent);
+ lastText = text;
+
+ }
+ });
+
+ }
+
+
+ /**
+ * Returns the base URL to use when loading images in this focusable tip.
+ *
+ * @return The base URL to use.
+ * @see #setImageBase(URL)
+ */
+ public URL getImageBase() {
+ return imageBase;
+ }
+
+
+ /**
+ * Returns localized text for the given key.
+ *
+ * @param key The key into the resource bundle.
+ * @return The localized text.
+ */
+ static String getString(String key) {
+ return msg.getString(key);
+ }
+
+
+ /**
+ * Disposes of the focusable tip currently displayed, if any.
+ */
+ public void possiblyDisposeOfTipWindow() {
+ if (tipWindow != null) {
+ tipWindow.dispose();
+ tipWindow = null;
+ attachedComponentListener.uninstall();
+ tipVisibleBounds.setBounds(-1, -1, 0, 0);
+ lastText = null;
+ attachedComponent.requestFocus();
+ }
+ }
+
+
+ void removeListeners() {
+ //System.out.println("DEBUG: Removing text area listeners");
+ attachedComponentListener.uninstall();
+ }
+
+
+ /**
+ * Sets the base URL to use when loading images in this focusable tip.
+ *
+ * @param url The base URL to use.
+ * @see #getImageBase()
+ */
+ public void setImageBase(URL url) {
+ imageBase = url;
+ }
+
+
+ private void setAttachedComponent(JComponent attachedComponent) {
+ this.attachedComponent = attachedComponent;
+ // Is okay to do multiple times.
+ ToolTipManager.sharedInstance().registerComponent(attachedComponent);
+ }
+
+
+ public void toolTipRequested(MouseEvent e, String text) {
+
+ if (text==null || text.length()==0) {
+ possiblyDisposeOfTipWindow();
+ lastText = text;
+ return;
+ }
+
+ if (lastText==null || text.length()!=lastText.length()
+ || !text.equals(lastText)) {
+ possiblyDisposeOfTipWindow();
+ createAndShowTipWindow(e, text);
+ }
+
+ }
+
+
+ private class AttachedComponentListener extends MouseInputAdapter implements
+ CaretListener, ComponentListener, FocusListener, KeyListener {
+
+ public void caretUpdate(CaretEvent e) {
+ Object source = e.getSource();
+ if (source == attachedComponent) {
+ possiblyDisposeOfTipWindow();
+ }
+ }
+
+ public void componentHidden(ComponentEvent e) {
+ handleComponentEvent(e);
+ }
+
+ public void componentMoved(ComponentEvent e) {
+ handleComponentEvent(e);
+ }
+
+ public void componentResized(ComponentEvent e) {
+ handleComponentEvent(e);
+ }
+
+ public void componentShown(ComponentEvent e) {
+ handleComponentEvent(e);
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ public void focusLost(FocusEvent e) {
+ // Only dispose of tip if it wasn't the TipWindow that was clicked
+ // "c" can be null, at least on OS X, so we must check that before
+ // calling SwingUtilities.getWindowAncestor() to guard against an
+ // NPE.
+ Component c = e.getOppositeComponent();
+ boolean tipClicked = (c instanceof TipWindow) ||
+ (c!=null &&
+ SwingUtilities.getWindowAncestor(c) instanceof TipWindow);
+ if (!tipClicked) {
+ possiblyDisposeOfTipWindow();
+ }
+ }
+
+ private void handleComponentEvent(ComponentEvent e) {
+ possiblyDisposeOfTipWindow();
+ }
+
+ public void install(JComponent attachedComponent) {
+ //attachedComponent.addCaretListener(this);
+ attachedComponent.addComponentListener(this);
+ attachedComponent.addFocusListener(this);
+ attachedComponent.addKeyListener(this);
+ attachedComponent.addMouseListener(this);
+ attachedComponent.addMouseMotionListener(this);
+ }
+
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode()==KeyEvent.VK_ESCAPE) {
+ possiblyDisposeOfTipWindow();
+ }
+ else if (e.getKeyCode()==KeyEvent.VK_F2) {
+ if (tipWindow!=null && !tipWindow.getFocusableWindowState()) {
+ tipWindow.actionPerformed(null);
+ e.consume(); // Don't do bookmarking stuff
+ }
+ }
+ }
+
+ public void keyReleased(KeyEvent e) {
+ }
+
+ public void keyTyped(KeyEvent e) {
+ }
+
+ public void mouseExited(MouseEvent e) {
+ // possiblyDisposeOfTipWindow();
+ }
+
+ public void mouseMoved(MouseEvent e) {
+ if (tipVisibleBounds==null ||
+ !tipVisibleBounds.contains(e.getPoint())) {
+ possiblyDisposeOfTipWindow();
+ }
+ }
+
+ public void uninstall() {
+ //attachedComponent.removeCaretListener(this);
+ attachedComponent.removeComponentListener(this);
+ attachedComponent.removeFocusListener(this);
+ attachedComponent.removeKeyListener(this);
+ attachedComponent.removeMouseListener(this);
+ attachedComponent.removeMouseMotionListener(this);
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.properties 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1 @@
+FocusHotkey=Press 'F2' for focus
\ No newline at end of file
Added: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip_fr.properties 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1 @@
+FocusHotkey=Appuyez sur 'F2' pour agrandir
\ No newline at end of file
Added: trunk/src/main/java/org/nuiton/widget/tooltip/SizeGrip.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/SizeGrip.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/SizeGrip.java 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1,266 @@
+/*
+ * 12/23/2008
+ *
+ * SizeGrip.java - A size grip component that sits at the bottom of the window,
+ * allowing the user to easily resize that window.
+ * Copyright (C) 2008 Robert Futrell
+ * robert_futrell at users.sourceforge.net
+ * http://fifesoft.com/rsyntaxtextarea
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.nuiton.widget.tooltip;
+
+import java.awt.Color;
+import java.awt.ComponentOrientation;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Window;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.imageio.ImageIO;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.MouseInputAdapter;
+
+
+/**
+ * A component that allows its parent window to be resizable, similar to the
+ * size grip seen on status bars.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+class SizeGrip extends JPanel {
+
+ /**
+ * The size grip to use if we're on OS X.
+ */
+ private Image osxSizeGrip;
+
+
+ public SizeGrip() {
+ MouseHandler adapter = new MouseHandler();
+ addMouseListener(adapter);
+ addMouseMotionListener(adapter);
+ setPreferredSize(new Dimension(16, 16));
+ }
+
+
+ /**
+ * Overridden to ensure that the cursor for this component is appropriate
+ * for the orientation.
+ *
+ * @param o The new orientation.
+ */
+ public void applyComponentOrientation(ComponentOrientation o) {
+ possiblyFixCursor(o.isLeftToRight());
+ super.applyComponentOrientation(o);
+ }
+
+
+ /**
+ * Creates and returns the OS X size grip image.
+ *
+ * @return The OS X size grip.
+ */
+ private Image createOSXSizeGrip() {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = cl.getResource("org/fife/ui/autocomplete/osx_sizegrip.png");
+ if (url==null) {
+ // We're not running in a jar - we may be debugging in Eclipse,
+ // for example
+ File f = new File("../AutoComplete/src/org/fife/ui/autocomplete/osx_sizegrip.png");
+ if (f.isFile()) {
+ try {
+ url = f.toURI().toURL();
+ } catch (MalformedURLException mue) { // Never happens
+ mue.printStackTrace();
+ return null;
+ }
+ }
+ else {
+ return null; // Can't find resource or image file
+ }
+ }
+ Image image = null;
+ try {
+ image = ImageIO.read(url);
+ } catch (IOException ioe) { // Never happens
+ ioe.printStackTrace();
+ }
+ return image;
+ }
+
+
+ /**
+ * Paints this panel.
+ *
+ * @param g The graphics context.
+ */
+ protected void paintComponent(Graphics g) {
+
+ super.paintComponent(g);
+
+ Dimension dim = getSize();
+ Color c1 = UIManager.getColor("Label.disabledShadow");
+ Color c2 = UIManager.getColor("Label.disabledForeground");
+
+ if (osxSizeGrip!=null) {
+ g.drawImage(osxSizeGrip, dim.width-16, dim.height-16, null);
+ return;
+ }
+
+ ComponentOrientation orientation = getComponentOrientation();
+
+ if (orientation.isLeftToRight()) {
+ int width = dim.width -= 3;
+ int height = dim.height -= 3;
+ g.setColor(c1);
+ g.fillRect(width-9,height-1, 3,3);
+ g.fillRect(width-5,height-1, 3,3);
+ g.fillRect(width-1,height-1, 3,3);
+ g.fillRect(width-5,height-5, 3,3);
+ g.fillRect(width-1,height-5, 3,3);
+ g.fillRect(width-1,height-9, 3,3);
+ g.setColor(c2);
+ g.fillRect(width-9,height-1, 2,2);
+ g.fillRect(width-5,height-1, 2,2);
+ g.fillRect(width-1,height-1, 2,2);
+ g.fillRect(width-5,height-5, 2,2);
+ g.fillRect(width-1,height-5, 2,2);
+ g.fillRect(width-1,height-9, 2,2);
+ }
+ else {
+ int height = dim.height -= 3;
+ g.setColor(c1);
+ g.fillRect(10,height-1, 3,3);
+ g.fillRect(6,height-1, 3,3);
+ g.fillRect(2,height-1, 3,3);
+ g.fillRect(6,height-5, 3,3);
+ g.fillRect(2,height-5, 3,3);
+ g.fillRect(2,height-9, 3,3);
+ g.setColor(c2);
+ g.fillRect(10,height-1, 2,2);
+ g.fillRect(6,height-1, 2,2);
+ g.fillRect(2,height-1, 2,2);
+ g.fillRect(6,height-5, 2,2);
+ g.fillRect(2,height-5, 2,2);
+ g.fillRect(2,height-9, 2,2);
+ }
+
+ }
+
+
+ /**
+ * Ensures that the cursor for this component is appropriate for the
+ * orientation.
+ *
+ * @param ltr Whether the current component orientation is LTR.
+ */
+ protected void possiblyFixCursor(boolean ltr) {
+ int cursor = Cursor.NE_RESIZE_CURSOR;
+ if (ltr) {
+ cursor = Cursor.NW_RESIZE_CURSOR;
+ }
+ if (cursor!=getCursor().getType()) {
+ setCursor(Cursor.getPredefinedCursor(cursor));
+ }
+ }
+
+
+ public void updateUI() {
+ super.updateUI();
+ // TODO: Key off of Aqua LaF, not just OS X, as this size grip looks
+ // bad on other LaFs on Mac such as Nimbus.
+ if (System.getProperty("os.name").indexOf("OS X")>-1) {
+ if (osxSizeGrip==null) {
+ osxSizeGrip = createOSXSizeGrip();
+ }
+ }
+ else { // Clear memory in case of runtime LaF change.
+ osxSizeGrip = null;
+ }
+
+ }
+
+
+ /**
+ * Listens for mouse events on this panel and resizes the parent window
+ * appropriately.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+ /*
+ * NOTE: We use SwingUtilities.convertPointToScreen() instead of just using
+ * the locations relative to the corner component because the latter proved
+ * buggy - stretch the window too wide and some kind of arithmetic error
+ * started happening somewhere - our window would grow way too large.
+ */
+ private class MouseHandler extends MouseInputAdapter {
+
+ private Point origPos;
+
+ public void mouseDragged(MouseEvent e) {
+ Point newPos = e.getPoint();
+ SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
+ int xDelta = newPos.x - origPos.x;
+ int yDelta = newPos.y - origPos.y;
+ Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
+ if (wind!=null) { // Should always be true
+ if (getComponentOrientation().isLeftToRight()) {
+ int w = wind.getWidth();
+ if (newPos.x>=wind.getX()) {
+ w += xDelta;
+ }
+ int h = wind.getHeight();
+ if (newPos.y>=wind.getY()) {
+ h += yDelta;
+ }
+ wind.setSize(w,h);
+ }
+ else { // RTL
+ int newW = Math.max(1, wind.getWidth()-xDelta);
+ int newH = Math.max(1, wind.getHeight()+yDelta);
+ wind.setBounds(newPos.x, wind.getY(), newW, newH);
+ }
+ // invalidate()/validate() needed pre-1.6.
+ wind.invalidate();
+ wind.validate();
+ }
+ origPos.setLocation(newPos);
+ }
+
+ public void mousePressed(MouseEvent e) {
+ origPos = e.getPoint();
+ SwingUtilities.convertPointToScreen(origPos, SizeGrip.this);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ origPos = null;
+ }
+
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/java/org/nuiton/widget/tooltip/SizeGrip.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tooltip/TipUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/TipUtil.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/TipUtil.java 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1,117 @@
+/*
+ * 08/13/2009
+ *
+ * TipUtil.java - Utility methods for homemade tool tips.
+ * Copyright (C) 2009 Robert Futrell
+ * robert_futrell at users.sourceforge.net
+ * http://fifesoft.com/rsyntaxtextarea
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.nuiton.widget.tooltip;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.SystemColor;
+import javax.swing.BorderFactory;
+import javax.swing.JEditorPane;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.text.html.HTMLDocument;
+
+
+/**
+ * Static utility methods for focusable tips.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+class TipUtil {
+
+
+ private TipUtil() {
+ }
+
+
+ /**
+ * Returns the default background color to use for tool tip windows.
+ *
+ * @return The default background color.
+ */
+ public static Color getToolTipBackground() {
+
+ Color c = UIManager.getColor("ToolTip.background");
+
+ // Tooltip.background is wrong color on Nimbus (!)
+ if (c==null || UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+ c = UIManager.getColor("info"); // Used by Nimbus (and others)
+ if (c==null) {
+ c = SystemColor.info; // System default
+ }
+ }
+
+ // Workaround for a bug (?) with Nimbus - calling JLabel.setBackground()
+ // with a ColorUIResource does nothing, must be a normal Color
+ if (c instanceof ColorUIResource) {
+ c = new Color(c.getRGB());
+ }
+
+ return c;
+
+ }
+
+
+ /**
+ * Tweaks a <code>JEditorPane</code> so it can be used to render the
+ * content in a focusable pseudo-tool tip. It is assumed that the editor
+ * pane is using an <code>HTMLDocument</code>.
+ *
+ * @param textArea The editor pane to tweak.
+ */
+ public static void tweakTipEditorPane(JEditorPane textArea) {
+
+ // Jump through a few hoops to get things looking nice in Nimbus
+ if (UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+ Color selBG = textArea.getSelectionColor();
+ Color selFG = textArea.getSelectedTextColor();
+ textArea.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
+ textArea.setSelectedTextColor(selFG);
+ textArea.setSelectionColor(selBG);
+ }
+
+ textArea.setEditable(false); // Required for links to work!
+ textArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+
+ // Make selection visible even though we are not (initially) focusable.
+ textArea.getCaret().setSelectionVisible(true);
+
+ // Make it use the "tool tip" background color.
+ textArea.setBackground(TipUtil.getToolTipBackground());
+
+ // Force JEditorPane to use a certain font even in HTML.
+ // All standard LookAndFeels, even Nimbus (!), define Label.font.
+ Font font = UIManager.getFont("Label.font");
+ if (font == null) { // Try to make a sensible default
+ font = new Font("SansSerif", Font.PLAIN, 12);
+ }
+ HTMLDocument doc = (HTMLDocument) textArea.getDocument();
+ doc.getStyleSheet().addRule(
+ "body { font-family: " + font.getFamily() + "; font-size: "
+ + font.getSize() + "pt; }");
+
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/java/org/nuiton/widget/tooltip/TipUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1,328 @@
+/*
+ * 07/29/2009
+ *
+ * TipWindow.java - The actual window component representing the tool tip.
+ * Copyright (C) 2009 Robert Futrell
+ * robert_futrell at users.sourceforge.net
+ * http://fifesoft.com/rsyntaxtextarea
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.nuiton.widget.tooltip;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.BorderFactory;
+import javax.swing.JEditorPane;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.JWindow;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.event.MouseInputAdapter;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.html.HTMLDocument;
+
+
+/**
+ * The actual tool tip component.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+class TipWindow extends JWindow implements ActionListener {
+
+ private FocusableTip ft;
+ private JEditorPane textArea;
+ private String text;
+ private TipListener tipListener;
+ private HyperlinkListener userHyperlinkListener;
+
+ private static TipWindow visibleInstance;
+
+
+ /**
+ * Constructor.
+ *
+ * @param owner The parent window.
+ * @param msg The text of the tool tip. This can be HTML.
+ */
+ public TipWindow(Window owner, FocusableTip ft, String msg) {
+
+ super(owner);
+ this.ft = ft;
+ this.text = msg;
+ tipListener = new TipListener();
+
+ JPanel cp = new JPanel(new BorderLayout());
+ cp.setBorder(BorderFactory.createCompoundBorder(BorderFactory
+ .createLineBorder(Color.BLACK), BorderFactory
+ .createEmptyBorder()));
+ cp.setBackground(TipUtil.getToolTipBackground());
+ textArea = new JEditorPane("text/html", msg);
+ TipUtil.tweakTipEditorPane(textArea);
+ if (ft.getImageBase()!=null) { // Base URL for images
+ ((HTMLDocument)textArea.getDocument()).setBase(ft.getImageBase());
+ }
+ textArea.addMouseListener(tipListener);
+ textArea.addHyperlinkListener(new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) {
+ TipWindow.this.ft.possiblyDisposeOfTipWindow();
+ }
+ }
+ });
+ cp.add(textArea);
+
+ setFocusableWindowState(false);
+ setContentPane(cp);
+ setBottomPanel(); // Must do after setContentPane()
+ pack();
+
+ // InputMap/ActionMap combo doesn't work for JWindows (even when
+ // using the JWindow's JRootPane), so we'll resort to KeyListener
+ KeyAdapter ka = new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode()==KeyEvent.VK_ESCAPE) {
+ TipWindow.this.ft.possiblyDisposeOfTipWindow();
+ }
+ }
+ };
+ addKeyListener(ka);
+ textArea.addKeyListener(ka);
+
+ // Ensure only 1 TipWindow is ever visible. If the caller does what
+ // they're supposed to and only creates these on the EDT, the
+ // synchronization isn't necessary, but we'll be extra safe.
+ synchronized (TipWindow.class) {
+ if (visibleInstance!=null) {
+ visibleInstance.dispose();
+ }
+ visibleInstance = this;
+ }
+
+ }
+
+
+ public void actionPerformed(ActionEvent e) {
+
+ if (!getFocusableWindowState()) {
+ setFocusableWindowState(true);
+ setBottomPanel();
+ textArea.removeMouseListener(tipListener);
+ pack();
+ addWindowFocusListener(new WindowAdapter() {
+ public void windowLostFocus(WindowEvent e) {
+ ft.possiblyDisposeOfTipWindow();
+ }
+ });
+ ft.removeListeners();
+ if (e==null) { // Didn't get here via our mouseover timer
+ requestFocus();
+ }
+ }
+
+ }
+
+
+ /**
+ * Disposes of this window.
+ */
+ public void dispose() {
+ //System.out.println("[DEBUG]: Disposing...");
+ Container cp = getContentPane();
+ for (int i=0; i<cp.getComponentCount(); i++) {
+ // Okay if listener is already removed
+ cp.getComponent(i).removeMouseListener(tipListener);
+ }
+ ft.removeListeners();
+ super.dispose();
+ }
+
+
+ /**
+ * Workaround for JEditorPane not returning its proper preferred size
+ * when rendering HTML until after layout already done. See
+ * http://forums.sun.com/thread.jspa?forumID=57&threadID=574810 for a
+ * discussion.
+ */
+ void fixSize() {
+
+ Dimension d = textArea.getPreferredSize();
+ Rectangle r = null;
+ try {
+
+ r = textArea.modelToView(textArea.getDocument().getLength()-1);
+ d.height = r.y + r.height;
+
+ // Ensure the text area doesn't start out too tall or wide.
+ d = textArea.getPreferredSize();
+ d.width = Math.min(d.width+25, 320);
+ d.height = Math.min(d.height, 150);
+
+ textArea.setPreferredSize(d);
+
+ } catch (BadLocationException ble) { // Never happens
+ ble.printStackTrace();
+ }
+
+ pack(); // Must re-pack to calculate proper size.
+
+ }
+
+
+ public String getText() {
+ return text;
+ }
+
+
+ private void setBottomPanel() {
+
+ final JPanel panel = new JPanel(new BorderLayout());
+ panel.add(new JSeparator(), BorderLayout.NORTH);
+
+ boolean focusable = getFocusableWindowState();
+ if (focusable) {
+ SizeGrip sg = new SizeGrip();
+ sg.applyComponentOrientation(sg.getComponentOrientation()); // Workaround
+ panel.add(sg, BorderLayout.LINE_END);
+ MouseInputAdapter adapter = new MouseInputAdapter() {
+ private Point lastPoint;
+ public void mouseDragged(MouseEvent e) {
+ Point p = e.getPoint();
+ SwingUtilities.convertPointToScreen(p, panel);
+ if (lastPoint==null) {
+ lastPoint = p;
+ }
+ else {
+ int dx = p.x - lastPoint.x;
+ int dy = p.y - lastPoint.y;
+ setLocation(getX()+dx, getY()+dy);
+ lastPoint = p;
+ }
+ }
+ public void mousePressed(MouseEvent e) {
+ lastPoint = e.getPoint();
+ SwingUtilities.convertPointToScreen(lastPoint, panel);
+ }
+ };
+ panel.addMouseListener(adapter);
+ panel.addMouseMotionListener(adapter);
+ // Don't add tipListener to the panel or SizeGrip
+ }
+ else {
+ panel.setOpaque(false);
+ JLabel label = new JLabel(FocusableTip.getString("FocusHotkey"));
+ Color fg = UIManager.getColor("Label.disabledForeground");
+ Font font = textArea.getFont();
+ font = font.deriveFont(font.getSize2D() - 1.0f);
+ label.setFont(font);
+ if (fg==null) { // Non BasicLookAndFeel-derived Looks
+ fg = Color.GRAY;
+ }
+ label.setOpaque(true);
+ Color bg = TipUtil.getToolTipBackground();
+ label.setBackground(bg);
+ label.setForeground(fg);
+ label.setHorizontalAlignment(SwingConstants.TRAILING);
+ label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
+ panel.add(label);
+ panel.addMouseListener(tipListener);
+ }
+
+ // Replace the previous SOUTH Component with the new one.
+ Container cp = getContentPane();
+ if (cp.getComponentCount()==2) { // Skip first time through
+ Component comp = cp.getComponent(0);
+ cp.remove(0);
+ JScrollPane sp = new JScrollPane(comp);
+ sp.setViewportBorder(BorderFactory.createEmptyBorder());
+ sp.setBackground(textArea.getBackground());
+ sp.getViewport().setBackground(textArea.getBackground());
+ cp.add(sp);
+ // What was component 1 is now 0.
+ cp.getComponent(0).removeMouseListener(tipListener);
+ cp.remove(0);
+ }
+
+ cp.add(panel, BorderLayout.SOUTH);
+
+ }
+
+
+ /**
+ * Sets the listener for hyperlink events in this tip window.
+ *
+ * @param listener The new listener. The old listener (if any) is
+ * removed. A value of <code>null</code> means "no listener."
+ */
+ public void setHyperlinkListener(HyperlinkListener listener) {
+ // We've added a separate listener, so remove only the user's.
+ if (userHyperlinkListener!=null) {
+ textArea.removeHyperlinkListener(userHyperlinkListener);
+ }
+ userHyperlinkListener = listener;
+ if (userHyperlinkListener!=null) {
+ textArea.addHyperlinkListener(userHyperlinkListener);
+ }
+ }
+
+
+ /**
+ * Listens for events in this window.
+ */
+ private class TipListener extends MouseAdapter {
+
+ public TipListener() {
+ }
+
+ public void mousePressed(MouseEvent e) {
+ actionPerformed(null); // Manually create "real" window
+ }
+
+ public void mouseExited(MouseEvent e) {
+ // Since we registered this listener on the child components of
+ // the JWindow, not the JWindow iteself, we have to be careful.
+ Component source = (Component)e.getSource();
+ Point p = e.getPoint();
+ SwingUtilities.convertPointToScreen(p, source);
+ if (!TipWindow.this.getBounds().contains(p)) {
+ ft.possiblyDisposeOfTipWindow();
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tooltip/package-info.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tooltip/package-info.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tooltip/package-info.java 2010-03-15 14:08:10 UTC (rev 248)
@@ -0,0 +1,9 @@
+/**
+ * Focusable tooltip.
+ *
+ * Original code from RSyntaxTextArea project with following modifications:
+ * <ul>
+ * <li>allow setting tooltip on all {@link javax.swing.JComponent}</li>
+ * </ul>
+ */
+package org.nuiton.widget.tooltip;
Property changes on: trunk/src/main/java/org/nuiton/widget/tooltip/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
15 Mar '10
Author: echatellier
Date: 2010-03-15 14:59:19 +0100 (Mon, 15 Mar 2010)
New Revision: 247
Log:
#355 : Add tree filtering model
Added:
trunk/src/main/java/org/nuiton/widget/tree/
trunk/src/main/java/org/nuiton/widget/tree/FilterTreeModel.java
trunk/src/main/java/org/nuiton/widget/tree/TreeFilter.java
trunk/src/main/java/org/nuiton/widget/tree/package-info.java
Added: trunk/src/main/java/org/nuiton/widget/tree/FilterTreeModel.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tree/FilterTreeModel.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tree/FilterTreeModel.java 2010-03-15 13:59:19 UTC (rev 247)
@@ -0,0 +1,181 @@
+/* *##% Graphical Widget
+ * Copyright (C) 2010 CodeLutin, Chatellier Eric
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
+
+package org.nuiton.widget.tree;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+/**
+ * Filter tree model.
+ *
+ * Take a delegate {@link TreeModel} filter it with {@link TreeFilter}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ *
+ * Based on : http://forums.sun.com/thread.jspa?forumID=57&threadID=5378510
+ */
+public class FilterTreeModel implements TreeModel {
+
+ /** Listener for data and structure change notification. */
+ protected Collection<TreeModelListener> treeModelListeners;
+
+ /** Real application {@link TreeModel}. */
+ protected TreeModel delegateModel;
+
+ /** Filter to use (can be null : no filtering). */
+ protected TreeFilter treeFilter;
+
+ /**
+ * Constructor with delegate model.
+ *
+ * @param delegateModel delegate data model
+ */
+ public FilterTreeModel(TreeModel delegateModel) {
+ this(delegateModel, null);
+ }
+
+ /**
+ * Constructor with delegate model.
+ *
+ * @param delegateModel
+ * @param filter
+ */
+ public FilterTreeModel(TreeModel delegateModel, TreeFilter filter) {
+ this.delegateModel = delegateModel;
+ this.treeFilter = filter;
+ treeModelListeners = new ArrayList<TreeModelListener>();
+ }
+
+ /**
+ * Change filter.
+ *
+ * Send a {@code treeStructureChanged} event on all registred listeners.
+ *
+ * @param treeFilter new filter
+ */
+ public void setFilter(TreeFilter treeFilter) {
+ this.treeFilter = treeFilter;
+ TreePath path = new TreePath(delegateModel.getRoot());
+ fireTreeStructureChanged(path);
+ }
+
+ /**
+ * Send a {@code treeStructureChanged} event on all registred listeners.
+ *
+ * @param path new path to send in notification
+ */
+ protected void fireTreeStructureChanged(TreePath path) {
+ TreeModelEvent event = new TreeModelEvent(delegateModel, path);
+ Iterator<TreeModelListener> itTreeModelListener = treeModelListeners.iterator();
+ while(itTreeModelListener.hasNext()) {
+ TreeModelListener current = itTreeModelListener.next();
+ current.treeStructureChanged(event);
+ }
+ }
+
+ @Override
+ public int getChildCount(Object parent) {
+ int realCount = delegateModel.getChildCount(parent);
+ int filterCount = 0;
+
+ for (int i = 0; i < realCount; i++) {
+ Object child = delegateModel.getChild(parent, i);
+ // null filter allowed, no filtering
+ if (treeFilter == null || treeFilter.include(delegateModel, child)) {
+ filterCount++;
+ }
+ }
+ return filterCount;
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ int cnt = -1;
+ for (int i = 0; i < delegateModel.getChildCount(parent); i++) {
+ Object child = delegateModel.getChild(parent, i);
+ // null filter allowed, no filtering
+ if (treeFilter == null || treeFilter.include(delegateModel, child)) {
+ cnt++;
+ }
+ if (cnt == index) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#getRoot()
+ */
+ @Override
+ public Object getRoot() {
+ return delegateModel.getRoot();
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
+ */
+ @Override
+ public boolean isLeaf(Object node) {
+ return delegateModel.isLeaf(node);
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
+ */
+ @Override
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ delegateModel.valueForPathChanged(path, newValue);
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ return delegateModel.getIndexOfChild(parent, child);
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void addTreeModelListener(TreeModelListener l) {
+ delegateModel.addTreeModelListener(l);
+ treeModelListeners.add(l);
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void removeTreeModelListener(TreeModelListener l) {
+ delegateModel.removeTreeModelListener(l);
+ treeModelListeners.remove(l);
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/tree/FilterTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tree/TreeFilter.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tree/TreeFilter.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tree/TreeFilter.java 2010-03-15 13:59:19 UTC (rev 247)
@@ -0,0 +1,33 @@
+/* *##% Graphical Widget
+ * Copyright (C) 2010 CodeLutin, Chatellier Eric
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
+
+package org.nuiton.widget.tree;
+
+import javax.swing.tree.TreeModel;
+
+/**
+ * TreeFilter
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public interface TreeFilter {
+
+ boolean include(TreeModel model, Object node);
+}
Property changes on: trunk/src/main/java/org/nuiton/widget/tree/TreeFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/widget/tree/package-info.java
===================================================================
--- trunk/src/main/java/org/nuiton/widget/tree/package-info.java (rev 0)
+++ trunk/src/main/java/org/nuiton/widget/tree/package-info.java 2010-03-15 13:59:19 UTC (rev 247)
@@ -0,0 +1,4 @@
+/**
+ * Tree filtering classes.
+ */
+package org.nuiton.widget.tree;
Property changes on: trunk/src/main/java/org/nuiton/widget/tree/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2010-03-12 21:14:56 +0100 (Fri, 12 Mar 2010)
New Revision: 246
Log:
Utilisation de mavenpom4redmine 2.0.6
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-02-21 10:27:32 UTC (rev 245)
+++ trunk/pom.xml 2010-03-12 20:14:56 UTC (rev 246)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.5</version>
+ <version>2.0.6</version>
</parent>
<artifactId>nuiton-widgets</artifactId>
1
0