Sandbox-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
- 17 discussions
Author: tchemit
Date: 2010-03-08 19:41:50 +0100 (Mon, 08 Mar 2010)
New Revision: 392
Log:
update pom
Modified:
javabeans/trunk/pom.xml
Modified: javabeans/trunk/pom.xml
===================================================================
--- javabeans/trunk/pom.xml 2010-03-08 10:16:08 UTC (rev 391)
+++ javabeans/trunk/pom.xml 2010-03-08 18:41:50 UTC (rev 392)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.0-rc-2</version>
+ <version>2.0.5</version>
</parent>
<artifactId>javabeans</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.6</version>
+ <version>4.7</version>
<scope>test</scope>
</dependency>
1
0
r391 - in testTreeTooltipSession/trunk/src/main/java/org/nuiton/test: . tooltip
by echatellier@users.nuiton.org 08 Mar '10
by echatellier@users.nuiton.org 08 Mar '10
08 Mar '10
Author: echatellier
Date: 2010-03-08 11:16:08 +0100 (Mon, 08 Mar 2010)
New Revision: 391
Log:
Test another implementation (not fully implemented)
Added:
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/ViewTooltips.java
Modified:
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java
Modified: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java 2010-03-05 14:08:58 UTC (rev 390)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java 2010-03-08 10:16:08 UTC (rev 391)
@@ -44,6 +44,7 @@
import org.nuiton.test.table.BasicTableModel;
import org.nuiton.test.table.BasicTableRenderer;
+import org.nuiton.test.tooltip.ViewTooltips;
import org.nuiton.test.tree.BasicTreeModel;
import org.nuiton.test.tree.FilterTreeModel;
import org.nuiton.test.tree.MyFilter;
@@ -100,6 +101,7 @@
1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(2, 2, 2, 2), 0, 0));
DataTipManager.get().register(tree);
+ //ViewTooltips.register(tree);
} catch (IOException e1) {
e1.printStackTrace();
}
@@ -166,6 +168,7 @@
new Insets(2, 2, 2, 2), 0, 0));
DataTipManager.get().register(table);
+ //ViewTooltips.register(table);
} catch (IOException e1) {
e1.printStackTrace();
}
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/ViewTooltips.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/ViewTooltips.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/ViewTooltips.java 2010-03-08 10:16:08 UTC (rev 391)
@@ -0,0 +1,746 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.nuiton.test.tooltip;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.ListCellRenderer;
+import javax.swing.Popup;
+import javax.swing.PopupFactory;
+import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreePath;
+
+/**
+ * Displays pseudo-tooltips for tree and list views which don't have enough
+ * space. This class is not NB specific, and can be used with any
+ * JTree or JList.
+ *
+ * @author Tim Boudreau
+ */
+public class ViewTooltips extends MouseAdapter implements MouseMotionListener {
+ /** The default instance, reference counted */
+ private static ViewTooltips INSTANCE = null;
+ /** A reference count for number of comps listened to */
+ private int refcount = 0;
+ /** The last known component we were invoked against, nulled on hide() */
+ private JComponent inner = null;
+ /** The last row we were invoked against */
+ private int row = -1;
+ /** An array of currently visible popups */
+ private Popup[] popups = new Popup[2];
+ /** A component we'll reuse to paint into the popups */
+ private ImgComp painter = new ImgComp();
+
+ /** Nobody should instantiate this */
+ private ViewTooltips() {
+ }
+
+ /**
+ * Register a child of a JScrollPane (only JList or JTree supported
+ * for now) which should show helper tooltips. Should be called
+ * from the component's addNotify() method.
+ */
+ public static void register(JComponent comp) {
+ if (INSTANCE == null) {
+ INSTANCE = new ViewTooltips();
+ }
+ INSTANCE.attachTo(comp);
+ }
+
+ /**
+ * Unregister a child of a JScrollPane (only JList or JTree supported
+ * for now) which should show helper tooltips. Should be called
+ * from the component's removeNotify() method.
+ */
+ public static void unregister(JComponent comp) {
+ assert INSTANCE != null : "Unregister asymmetrically called";
+ if (INSTANCE.detachFrom(comp) == 0) {
+ INSTANCE.hide();
+ INSTANCE = null;
+ }
+ }
+
+ /** Start listening to mouse motion on the passed component */
+ private void attachTo(JComponent comp) {
+ assert comp instanceof JTree || comp instanceof JList;
+ comp.addMouseListener(this);
+ comp.addMouseMotionListener(this);
+ refcount++;
+ }
+
+ /** Stop listening to mouse motion on the passed component */
+ private int detachFrom(JComponent comp) {
+ assert comp instanceof JTree || comp instanceof JList;
+ comp.removeMouseMotionListener(this);
+ comp.removeMouseListener(this);
+ return refcount--;
+ }
+
+ public void mouseMoved(MouseEvent e) {
+ Point p = e.getPoint();
+ JComponent comp = (JComponent) e.getSource();
+ JScrollPane jsp = (JScrollPane) SwingUtilities.getAncestorOfClass(
+ JScrollPane.class, comp);
+ if (jsp != null) {
+ p = SwingUtilities.convertPoint(comp, p, jsp);
+ show(jsp, p);
+ }
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ hide();
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ hide();
+ }
+
+ public void mouseExited(MouseEvent e) {
+ hide();
+ }
+
+ /** Shows the appropriate popups given the state of the scroll pane and
+ * its view.
+ * @param view The scroll pane owning the component the event happened on
+ * @param pt The point at which the mouse event happened, in the coordinate
+ * space of the scroll pane.
+ */
+ void show(JScrollPane view, Point pt) {
+ if (view.getViewport().getView() instanceof JTree) {
+ showJTree(view, pt);
+ } else if (view.getViewport().getView() instanceof JList) {
+ showJList(view, pt);
+ } else {
+ assert false : "Bad component type registered: "
+ + view.getViewport().getView();
+ }
+ }
+
+ private void showJList(JScrollPane view, Point pt) {
+ JList list = (JList) view.getViewport().getView();
+ Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, list);
+ int row = list.locationToIndex(p);
+ if (row == -1) {
+ hide();
+ return;
+ }
+ Rectangle bds = list.getCellBounds(row, row);
+ //GetCellBounds returns a width that is the
+ //full component width; we want only what
+ //the renderer really needs.
+ ListCellRenderer ren = list.getCellRenderer();
+ Dimension rendererSize = ren.getListCellRendererComponent(list,
+ list.getModel().getElementAt(row), row, false, false)
+ .getPreferredSize();
+
+ bds.width = rendererSize.width;
+ if (bds == null || !bds.contains(p)) {
+ hide();
+ return;
+ }
+ if (setCompAndRow(list, row)) {
+ Rectangle visible = getShowingRect(view);
+ Rectangle[] rects = getRects(bds, visible);
+ if (rects.length > 0) {
+ ensureOldPopupsHidden();
+ painter.configure(list.getModel().getElementAt(row), view,
+ list, row);
+ showPopups(rects, bds, visible, list, view);
+ } else {
+ hide();
+ }
+ }
+ }
+
+ private void showJTree(JScrollPane view, Point pt) {
+ JTree tree = (JTree) view.getViewport().getView();
+ Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, tree);
+
+ int row = tree.getClosestRowForLocation(p.x, p.y);
+
+ TreePath path = tree.getClosestPathForLocation(p.x, p.y);
+
+ Rectangle bds = tree.getPathBounds(path);
+ if (bds == null || !bds.contains(p)) {
+ hide();
+ return;
+ }
+ if (setCompAndRow(tree, row)) {
+ Rectangle visible = getShowingRect(view);
+ Rectangle[] rects = getRects(bds, visible);
+ if (rects.length > 0) {
+ ensureOldPopupsHidden();
+ painter.configure(path.getLastPathComponent(), view, tree,
+ path, row);
+ showPopups(rects, bds, visible, tree, view);
+ } else {
+ hide();
+ }
+ }
+ }
+
+ /**
+ * Set the currently shown component and row, returning true if they are
+ * not the same as the last known values.
+ */
+ private boolean setCompAndRow(JComponent inner, int row) {
+ boolean rowChanged = row != this.row;
+ boolean compChanged = inner != this.inner;
+ this.inner = inner;
+ this.row = row;
+ return (rowChanged || compChanged);
+ }
+
+ /**
+ * Hide all popups and discard any references to the components the
+ * popups were showing for.
+ */
+ void hide() {
+ ensureOldPopupsHidden();
+ if (painter != null) {
+ painter.clear();
+ }
+ setHideComponent(null, null);
+ inner = null;
+ row = -1;
+ }
+
+ private void ensureOldPopupsHidden() {
+ for (int i = 0; i < popups.length; i++) {
+ if (popups[i] != null) {
+ popups[i].hide();
+ popups[i] = null;
+ }
+ }
+ }
+
+ /**
+ * Gets the sub-rectangle of a JScrollPane's area that
+ * is actually showing the view
+ */
+ private Rectangle getShowingRect(JScrollPane pane) {
+ Insets ins1 = pane.getViewport().getInsets();
+ Border inner = pane.getViewportBorder();
+ Insets ins2;
+ if (inner != null) {
+ ins2 = inner.getBorderInsets(pane);
+ } else {
+ ins2 = new Insets(0, 0, 0, 0);
+ }
+ Insets ins3 = new Insets(0, 0, 0, 0);
+ if (pane.getBorder() != null) {
+ ins3 = pane.getBorder().getBorderInsets(pane);
+ }
+
+ Rectangle r = pane.getViewportBorderBounds();
+ r.translate(-r.x, -r.y);
+ r.width -= ins1.left + ins1.right;
+ r.width -= ins2.left + ins2.right;
+ r.height -= ins1.top + ins1.bottom;
+ r.height -= ins2.top + ins2.bottom;
+ r.x -= ins2.left;
+ r.x -= ins3.left;
+ Point p = pane.getViewport().getViewPosition();
+ r.translate(p.x, p.y);
+ r = SwingUtilities.convertRectangle(pane.getViewport(), r, pane);
+ return r;
+ }
+
+ /**
+ * Fetches an array or rectangles representing the non-overlapping
+ * portions of a cell rect against the visible portion of the component.
+ * @bds The cell's bounds, in the coordinate space of the tree or list
+ * @vis The visible area of the tree or list, in the tree or list's coordinate space
+ */
+ private static final Rectangle[] getRects(final Rectangle bds,
+ final Rectangle vis) {
+ Rectangle[] result;
+ if (vis.contains(bds)) {
+ result = new Rectangle[0];
+ } else {
+ if (bds.x < vis.x && bds.x + bds.width > vis.x + vis.width) {
+ Rectangle a = new Rectangle(bds.x, bds.y, vis.x - bds.x,
+ bds.height);
+ Rectangle b = new Rectangle(vis.x + vis.width, bds.y,
+ (bds.x + bds.width) - (vis.x + vis.width), bds.height);
+ result = new Rectangle[] { a, b };
+ } else if (bds.x < vis.x) {
+ result = new Rectangle[] { new Rectangle(bds.x, bds.y, vis.x
+ - bds.x, bds.height) };
+ } else if (bds.x + bds.width > vis.x + vis.width) {
+ result = new Rectangle[] { new Rectangle(vis.x + vis.width,
+ bds.y, (bds.x + bds.width) - (vis.x + vis.width),
+ bds.height) };
+ } else {
+ result = new Rectangle[0];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Show popups for each rectangle, using the now configured painter.
+ */
+ private void showPopups(Rectangle[] rects, Rectangle bds,
+ Rectangle visible, JComponent comp, JScrollPane view) {
+ boolean shown = false;
+ for (int i = 0; i < rects.length; i++) {
+ Rectangle sect = rects[i];
+ sect.translate(-bds.x, -bds.y);
+ ImgComp part = painter.getPartial(sect,
+ bds.x + rects[i].x < visible.x);
+ Point pos = new Point(bds.x + rects[i].x, bds.y + rects[i].y);
+ SwingUtilities.convertPointToScreen(pos, comp);
+ if (comp instanceof JList) {
+ //XXX off by one somewhere, only with JLists - where?
+ pos.y--;
+ }
+ if (pos.x > 0) { //Mac OS will reposition off-screen popups to x=0,
+ //so don't try to show them
+ popups[i] = getPopupFactory()
+ .getPopup(view, part, pos.x, pos.y);
+ popups[i].show();
+ shown = true;
+ }
+ }
+ if (shown) {
+ setHideComponent(comp, view);
+ } else {
+ setHideComponent(null, null); //clear references
+ }
+ }
+
+ private static PopupFactory getPopupFactory() {
+ //if (Utilities.isMac()) {
+
+ // See ide/applemenu/src/org/netbeans/modules/applemenu/ApplePopupFactory
+ // We have a custom PopupFactory that will consistently use
+ // lightweight popups on Mac OS, since HW popups get a drop
+ // shadow. By default, popups returned when a heavyweight popup
+ // is needed (SDI mode) are no-op popups, since some hacks
+ // are necessary to make it really work.
+
+ // To enable heavyweight popups which have no drop shadow
+ // *most* of the time on mac os, run with
+ // -J-Dnb.explorer.hw.completions=true
+
+ // To enable heavyweight popups which have no drop shadow
+ // *ever* on mac os, you need to put the cocoa classes on the
+ // classpath - modify netbeans.conf to add
+ // System/Library/Java on the bootclasspath. *Then*
+ // run with the above line switch and
+ // -J-Dnb.explorer.hw.cocoahack=true
+
+ /*PopupFactory result = (PopupFactory) Lookup.getDefault().lookup (
+ PopupFactory.class);
+ return result == null ? PopupFactory.getSharedInstance() : result;
+ } else {*/
+ return PopupFactory.getSharedInstance();
+ //}
+ }
+
+ private Hider hider = null;
+
+ /**
+ * Set a component (JList or JTree) which should be listened to, such that if
+ * a model, selection or scroll event occurs, all currently open popups
+ * should be hidden.
+ */
+ private void setHideComponent(JComponent comp, JScrollPane parent) {
+ if (hider != null) {
+ if (hider.isListeningTo(comp)) {
+ return;
+ }
+ }
+ if (hider != null) {
+ hider.detach();
+ }
+ if (comp != null) {
+ hider = new Hider(comp, parent);
+ } else {
+ hider = null;
+ }
+ }
+
+ /**
+ * A JComponent which creates a BufferedImage of a cell renderer and can
+ * produce clones of itself that display subrectangles of that cell
+ * renderer.
+ */
+ private static final class ImgComp extends JComponent {
+ private BufferedImage img;
+ private Dimension d = null;
+
+ private Color bg = Color.WHITE;
+ private JScrollPane comp = null;
+
+ private Object node = null;
+
+ private AffineTransform at = AffineTransform.getTranslateInstance(0d,
+ 0d);
+ boolean isRight = false;
+
+ ImgComp() {
+ }
+
+ /**
+ * Create a clone with a specified backing image
+ */
+ ImgComp(BufferedImage img, Rectangle off, boolean right) {
+ this.img = img;
+ at = AffineTransform.getTranslateInstance(-off.x, 0);
+ d = new Dimension(off.width, off.height);
+ isRight = right;
+ }
+
+ public ImgComp getPartial(Rectangle bds, boolean right) {
+ assert img != null;
+ return new ImgComp(img, bds, right);
+ }
+
+ /** Configures a tree cell renderer and sets up sizing and the
+ * backing image from it */
+ public boolean configure(Object nd, JScrollPane tv, JTree tree,
+ TreePath path, int row) {
+ boolean sameVn = setLastRendereredObject(nd);
+ boolean sameComp = setLastRenderedScrollPane(tv);
+ Component renderer = null;
+ bg = tree.getBackground();
+ boolean sel = tree.isSelectionEmpty() ? false : tree
+ .getSelectionModel().isPathSelected(path);
+ boolean exp = tree.isExpanded(path);
+ boolean leaf = !exp && tree.getModel().isLeaf(nd);
+ boolean lead = path.equals(tree.getSelectionModel()
+ .getLeadSelectionPath());
+ renderer = tree.getCellRenderer().getTreeCellRendererComponent(
+ tree, nd, sel, exp, leaf, row, lead);
+ if (renderer != null) {
+ setComponent(renderer);
+ }
+ return true;
+ }
+
+ /** Configures a list cell renderer and sets up sizing and the
+ * backing image from it */
+ public boolean configure(Object nd, JScrollPane tv, JList list, int row) {
+ boolean sameVn = setLastRendereredObject(nd);
+ boolean sameComp = setLastRenderedScrollPane(tv);
+ Component renderer = null;
+ bg = list.getBackground();
+ boolean sel = list.isSelectionEmpty() ? false : list
+ .getSelectionModel().isSelectedIndex(row);
+ renderer = list.getCellRenderer().getListCellRendererComponent(
+ list, nd, row, sel, false);
+ if (renderer != null) {
+ setComponent(renderer);
+ }
+ return true;
+ }
+
+ private boolean setLastRenderedScrollPane(JScrollPane comp) {
+ boolean result = comp != this.comp;
+ this.comp = comp;
+ return result;
+ }
+
+ private boolean setLastRendereredObject(Object nd) {
+ boolean result = node != nd;
+ if (result) {
+ node = nd;
+ }
+ return result;
+ }
+
+ void clear() {
+ comp = null;
+ node = null;
+ }
+
+ /**
+ * Set the cell renderer we will proxy.
+ */
+ public void setComponent(Component jc) {
+ Dimension d = jc.getPreferredSize();
+ BufferedImage nue = new BufferedImage(d.width, d.height + 2,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ SwingUtilities.paintComponent(nue.getGraphics(), jc, this, 0, 0,
+ d.width, d.height + 2);
+ setImage(nue);
+ }
+
+ public Rectangle getBounds() {
+ Dimension dd = getPreferredSize();
+ return new Rectangle(0, 0, dd.width, dd.height);
+ }
+
+ private void setImage(BufferedImage img) {
+ this.img = img;
+ d = null;
+ }
+
+ public Dimension getPreferredSize() {
+ if (d == null) {
+ d = new Dimension(img.getWidth(), img.getHeight());
+ }
+ return d;
+ }
+
+ public Dimension getSize() {
+ return getPreferredSize();
+ }
+
+ public void paint(Graphics g) {
+ g.setColor(bg);
+ g.fillRect(0, 0, d.width, d.height);
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.drawRenderedImage(img, at);
+ g.setColor(Color.GRAY);
+ g.drawLine(0, 0, d.width, 0);
+ g.drawLine(0, d.height - 1, d.width, d.height - 1);
+ if (isRight) {
+ g.drawLine(0, 0, 0, d.height - 1);
+ } else {
+ g.drawLine(d.width - 1, 0, d.width - 1, d.height - 1);
+ }
+ }
+
+ public void firePropertyChange(String s, Object a, Object b) {
+ }
+
+ public void invalidate() {
+ }
+
+ public void validate() {
+ }
+
+ public void revalidate() {
+ }
+ }
+
+ /**
+ * A listener that listens to just about everything in the known universe
+ * and hides all currently displayed popups if anything happens.
+ */
+ private static final class Hider implements ChangeListener,
+ PropertyChangeListener, TreeModelListener, TreeSelectionListener,
+ HierarchyListener, HierarchyBoundsListener, ListSelectionListener,
+ ListDataListener, ComponentListener {
+ private final JTree tree;
+
+ private JScrollPane pane;
+ private final JList list;
+
+ public Hider(JComponent comp, JScrollPane pane) {
+ if (comp instanceof JTree) {
+ this.tree = (JTree) comp;
+ this.list = null;
+ } else {
+ this.list = (JList) comp;
+ this.tree = null;
+ }
+ assert tree != null || list != null;
+ this.pane = pane;
+ attach();
+ }
+
+ private boolean isListeningTo(JComponent comp) {
+ return !detached && (comp == list || comp == tree);
+ }
+
+ private void attach() {
+ if (tree != null) {
+ tree.getModel().addTreeModelListener(this);
+ tree.getSelectionModel().addTreeSelectionListener(this);
+ tree.addHierarchyBoundsListener(this);
+ tree.addHierarchyListener(this);
+ tree.addComponentListener(this);
+ } else {
+ list.getSelectionModel().addListSelectionListener(this);
+ list.getModel().addListDataListener(this);
+ list.addHierarchyBoundsListener(this);
+ list.addHierarchyListener(this);
+ list.addComponentListener(this);
+ }
+ pane.getHorizontalScrollBar().getModel().addChangeListener(this);
+ pane.getVerticalScrollBar().getModel().addChangeListener(this);
+ KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .addPropertyChangeListener(this);
+ }
+
+ private boolean detached = false;
+
+ private void detach() {
+ KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .removePropertyChangeListener(this);
+ if (tree != null) {
+ tree.getSelectionModel().removeTreeSelectionListener(this);
+ tree.getModel().removeTreeModelListener(this);
+ tree.removeHierarchyBoundsListener(this);
+ tree.removeHierarchyListener(this);
+ tree.removeComponentListener(this);
+ } else {
+ list.getSelectionModel().removeListSelectionListener(this);
+ list.getModel().removeListDataListener(this);
+ list.removeHierarchyBoundsListener(this);
+ list.removeHierarchyListener(this);
+ list.removeComponentListener(this);
+ }
+ pane.getHorizontalScrollBar().getModel().removeChangeListener(this);
+ pane.getVerticalScrollBar().getModel().removeChangeListener(this);
+ detached = true;
+ }
+
+ private void change() {
+ if (ViewTooltips.INSTANCE != null) {
+ ViewTooltips.INSTANCE.hide();
+ }
+ detach();
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ change();
+ }
+
+ public void treeNodesChanged(TreeModelEvent e) {
+ change();
+ }
+
+ public void treeNodesInserted(TreeModelEvent e) {
+ change();
+ }
+
+ public void treeNodesRemoved(TreeModelEvent e) {
+ change();
+ }
+
+ public void treeStructureChanged(TreeModelEvent e) {
+ change();
+ }
+
+ public void hierarchyChanged(HierarchyEvent e) {
+ change();
+ }
+
+ public void valueChanged(TreeSelectionEvent e) {
+ change();
+ }
+
+ public void ancestorMoved(HierarchyEvent e) {
+ change();
+ }
+
+ public void ancestorResized(HierarchyEvent e) {
+ change();
+ }
+
+ public void stateChanged(ChangeEvent e) {
+ change();
+ }
+
+ public void valueChanged(ListSelectionEvent e) {
+ change();
+ }
+
+ public void intervalAdded(ListDataEvent e) {
+ change();
+ }
+
+ public void intervalRemoved(ListDataEvent e) {
+ change();
+ }
+
+ public void contentsChanged(ListDataEvent e) {
+ change();
+ }
+
+ public void componentResized(ComponentEvent e) {
+ change();
+ }
+
+ public void componentMoved(ComponentEvent e) {
+ change();
+ }
+
+ public void componentShown(ComponentEvent e) {
+ change();
+ }
+
+ public void componentHidden(ComponentEvent e) {
+ change();
+ }
+ }
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tooltip/ViewTooltips.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r390 - in eugenehelloworld/trunk: . lib src/main/java/org/nuiton src/main/java/org/nuiton/helloworld
by echatellier@users.nuiton.org 05 Mar '10
by echatellier@users.nuiton.org 05 Mar '10
05 Mar '10
Author: echatellier
Date: 2010-03-05 15:08:58 +0100 (Fri, 05 Mar 2010)
New Revision: 390
Log:
Update hello world ant application on eugene 2
Added:
eugenehelloworld/trunk/lib/
eugenehelloworld/trunk/lib/README.txt
Removed:
eugenehelloworld/trunk/src/main/java/org/nuiton/util/
Modified:
eugenehelloworld/trunk/build.xml
eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/ClassInfoGenerator.java
eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/JavaBeanGenerator.java
Modified: eugenehelloworld/trunk/build.xml
===================================================================
--- eugenehelloworld/trunk/build.xml 2010-03-05 10:56:46 UTC (rev 389)
+++ eugenehelloworld/trunk/build.xml 2010-03-05 14:08:58 UTC (rev 390)
@@ -1,6 +1,6 @@
<project name="EugeneHelloWorld" default="compile" basedir=".">
<description>
- simple example build file
+ Simple example build file
</description>
<!-- set global properties for this build -->
@@ -8,9 +8,9 @@
<property name="resources" location="src/main/resources" />
<property name="modelDir" location="src/main/xmi" />
<property name="lib" location="lib" />
- <property name="target" location="target" />
- <property name="targetgen" location="${target}/gen/java" />
- <property name="targetbuild" location="${target}/classes" />
+ <property name="builddir" location="build" />
+ <property name="buildgen" location="${builddir}/gen/java" />
+ <property name="buildclasses" location="${builddir}/classes" />
<path id="project.classpath">
<fileset dir="${lib}">
@@ -23,7 +23,7 @@
</pathconvert>
<taskdef name="eugene" classname="org.nuiton.eugene.GeneratorTask"
- classpath="${compile.classpath}:${targetbuild}:${resources}" />
+ classpath="${compile.classpath}:${buildclasses}:${resources}" />
<target name="warning">
<echo>********************************************************</echo>
@@ -34,31 +34,30 @@
<target name="init" depends="warning">
<!-- Create the build directory structure used by compile -->
- <mkdir dir="${target}" />
- <mkdir dir="${targetgen}" />
- <mkdir dir="${targetbuild}" />
+ <mkdir dir="${builddir}" />
+ <mkdir dir="${buildgen}" />
+ <mkdir dir="${buildclasses}" />
</target>
<target name="pre-compile" depends="init">
<echo>Using classpath ${compile.classpath}</echo>
- <javac srcdir="${src}" destdir="${targetbuild}" classpath="${compile.classpath}" />
+ <javac srcdir="${src}" destdir="${buildclasses}" classpath="${compile.classpath}" />
</target>
<target name="generate" depends="pre-compile" description="generate">
- <eugene srcdir="${modelDir}" destdir="${targetgen}"
+ <eugene srcdir="${modelDir}" destdir="${buildgen}"
resolver="org.nuiton.util.ResourceResolver"
templates="org.nuiton.helloworld.ClassInfoGenerator,org.nuiton.helloworld.JavaBeanGenerator"
- properties="defaultPackage=org.nuiton,fullPackagePath=org.nuiton,extraPackages=org.nuiton"
- classpath="${compile.classpath}:${targetbuild}:${resources}" />
+ properties="defaultPackage=org.nuiton,fullPackagePath=org,extraPackages=org" />
</target>
<target name="compile" depends="generate" description="compile the source ">
<!-- Compile the java code from ${src} into ${build} -->
- <javac srcdir="${targetgen}" destdir="${targetbuild}" />
+ <javac srcdir="${buildgen}" destdir="${buildclasses}" />
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
- <delete dir="${target}" />
+ <delete dir="${builddir}" />
</target>
</project>
Added: eugenehelloworld/trunk/lib/README.txt
===================================================================
--- eugenehelloworld/trunk/lib/README.txt (rev 0)
+++ eugenehelloworld/trunk/lib/README.txt 2010-03-05 14:08:58 UTC (rev 390)
@@ -0,0 +1,22 @@
+All eugene ant task dependency must be located into
+this directory.
+
+Tested with:
+------------
+ant-eugene-task-2.0.0.jar
+commons-beanutils-1.8.0.jar
+commons-collections-3.2.1.jar
+commons-digester-2.0.jar
+commons-lang-2.4.jar
+commons-logging-1.1.1.jar
+commons-primitives-1.0.jar
+dom4j-1.6.1.jar
+eugene-2.0.0.jar
+jaxen-1.1.1.jar
+jdom-1.0.jar
+nuiton-i18n-api-1.0.1.jar
+nuiton-utils-1.1.1.jar
+saxon-9.1.0.8.jar
+xercesImpl-2.9.1.jar
+xml-apis-1.3.04.jar
+xom-1.0.jar
Modified: eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/ClassInfoGenerator.java
===================================================================
--- eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/ClassInfoGenerator.java 2010-03-05 10:56:46 UTC (rev 389)
+++ eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/ClassInfoGenerator.java 2010-03-05 14:08:58 UTC (rev 390)
@@ -21,9 +21,9 @@
import java.io.IOException;
import java.io.Writer;
-import org.nuiton.eugene.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
/**
* HelloWorld.
Modified: eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/JavaBeanGenerator.java
===================================================================
--- eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/JavaBeanGenerator.java 2010-03-05 10:56:46 UTC (rev 389)
+++ eugenehelloworld/trunk/src/main/java/org/nuiton/helloworld/JavaBeanGenerator.java 2010-03-05 14:08:58 UTC (rev 390)
@@ -22,9 +22,9 @@
import java.io.Writer;
import org.apache.commons.lang.StringUtils;
-import org.nuiton.eugene.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
/**
* HelloWorld.
1
0
r389 - in testTreeTooltipSession/trunk: . src/main/java/org/nuiton/test src/main/java/org/nuiton/test/tree
by echatellier@users.nuiton.org 05 Mar '10
by echatellier@users.nuiton.org 05 Mar '10
05 Mar '10
Author: echatellier
Date: 2010-03-05 11:56:46 +0100 (Fri, 05 Mar 2010)
New Revision: 389
Log:
Ajout du filtrage des arbres (filtrage par modele)
Added:
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/FilterTreeModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/MyFilter.java
Modified:
testTreeTooltipSession/trunk/pom.xml
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java
Modified: testTreeTooltipSession/trunk/pom.xml
===================================================================
--- testTreeTooltipSession/trunk/pom.xml 2010-03-05 09:09:13 UTC (rev 388)
+++ testTreeTooltipSession/trunk/pom.xml 2010-03-05 10:56:46 UTC (rev 389)
@@ -99,6 +99,13 @@
<version>1.0.3</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.5</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<repositories>
Modified: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java 2010-03-05 09:09:13 UTC (rev 388)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java 2010-03-05 10:56:46 UTC (rev 389)
@@ -17,6 +17,7 @@
**/
package org.nuiton.test;
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -34,6 +35,8 @@
import javax.swing.JTextField;
import javax.swing.JToolTip;
import javax.swing.JTree;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
import net.java.balloontip.BalloonTip;
import net.java.balloontip.styles.RoundedBalloonStyle;
@@ -42,6 +45,8 @@
import org.nuiton.test.table.BasicTableModel;
import org.nuiton.test.table.BasicTableRenderer;
import org.nuiton.test.tree.BasicTreeModel;
+import org.nuiton.test.tree.FilterTreeModel;
+import org.nuiton.test.tree.MyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +58,7 @@
* @author ceric35
* Date : 4 mars 2010
*/
-public class MainPanel extends JPanel {
+public class MainPanel extends JPanel implements DocumentListener {
/** serialVersionUID. */
private static final long serialVersionUID = -4867848058485235754L;
@@ -61,8 +66,14 @@
/** Logger */
private static Logger logger = LoggerFactory.getLogger(MainPanel.class);
+ protected FilterTreeModel filterModel;
+
+ protected JTextField filterField;
+
public MainPanel() {
+ super(new BorderLayout());
+
// label filter
JPanel leftPanel = new JPanel(new GridBagLayout());
JLabel filterLabel = new JLabel("Filtre : ");
@@ -71,7 +82,8 @@
new Insets(2, 2, 2, 2), 0, 0));
// field filter
- JTextField filterField = new JTextField();
+ filterField = new JTextField();
+ filterField.getDocument().addDocumentListener(this);
leftPanel.add(filterField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(2, 2, 2, 2), 0, 0));
@@ -80,8 +92,9 @@
try {
BasicTreeModel treeModel = new BasicTreeModel(new File(".")
.getCanonicalFile());
+ filterModel = new FilterTreeModel(treeModel, new MyFilter(""));
- JTree tree = new JTree(treeModel);
+ JTree tree = new JTree(filterModel);
tree.setName("tree");
leftPanel.add(new JScrollPane(tree), new GridBagConstraints(0, 1, 2, 1,
1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
@@ -162,50 +175,35 @@
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rigthPanel);
pane.setName("mainViewPane");
- add(pane);
+ add(pane, BorderLayout.CENTER);
}
- /*public static void main(String[] args) {
- final MainFrame m = new MainFrame();
- m.setName("mainFrame");
+ protected void updateFilter() {
+ String filterString = filterField.getText().trim();
+ filterModel.setFilter(new MyFilter(filterString));
+ }
- // centering
- centerWindow(m);
+ /*
+ * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
+ */
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ updateFilter();
+ }
- SafApplicationContext context = new SafApplicationContext();
- final SessionStorage sessionStorage = context.getSessionStorage();
- sessionStorage.restore(m, m.getName() + ".session.xml");
-
- m.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- try {
- sessionStorage.save(m, m.getName() + ".session.xml");
- System.exit(0);
- } catch (IOException ex) {
- logger.error("Can't save frame session", ex);
- }
- }
- });
- m.setVisible(true);
+ /*
+ * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
+ */
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ updateFilter();
}
- protected static void centerWindow(Window root) {
- // If the window's bounds don't appear to have been set, do it
- if (root instanceof Window) {
- Window window = (Window) root;
- if (!root.isValid() || (root.getWidth() == 0)
- || (root.getHeight() == 0)) {
- window.pack();
- }
- if (!window.isLocationByPlatform() && (root.getX() == 0)
- && (root.getY() == 0)) {
- Component owner = window.getOwner();
- //if (owner == null) {
- // owner = (window != mainFrame) ? mainFrame : null;
- //}
- window.setLocationRelativeTo(owner); // center the window
- }
- }
- }*/
+ /*
+ * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
+ */
+ @Override
+ public void changedUpdate(DocumentEvent e) {
+ updateFilter();
+ }
}
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/FilterTreeModel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/FilterTreeModel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/FilterTreeModel.java 2010-03-05 10:56:46 UTC (rev 389)
@@ -0,0 +1,139 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.nuiton.test.tree;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.jdesktop.swingx.tree.TreeModelSupport;
+
+/**
+ * TODO add comment here.
+ *
+ * @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 {
+
+ protected TreeModelSupport support;
+
+ protected TreeModel delegateModel;
+
+ protected TreeFilter treeFilter;
+
+ public FilterTreeModel(TreeModel delegateModel, TreeFilter filter) {
+ this.delegateModel = delegateModel;
+ this.treeFilter = filter;
+ this.support = new TreeModelSupport(delegateModel);
+ }
+
+ public void setFilter(TreeFilter treeFilter) {
+ this.treeFilter = treeFilter;
+ TreePath path = new TreePath(delegateModel.getRoot());
+ support.fireTreeStructureChanged(path);
+ }
+
+ @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);
+ if (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);
+ if (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);
+ support.addTreeModelListener(l);
+ }
+
+ /*
+ * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void removeTreeModelListener(TreeModelListener l) {
+ delegateModel.removeTreeModelListener(l);
+ support.addTreeModelListener(l);
+ }
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/FilterTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/MyFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/MyFilter.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/MyFilter.java 2010-03-05 10:56:46 UTC (rev 389)
@@ -0,0 +1,61 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.nuiton.test.tree;
+
+import javax.swing.tree.TreeModel;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MyFilter implements TreeFilter {
+
+ protected String filterString;
+
+ public MyFilter(String filterString) {
+ this.filterString = filterString;
+ }
+
+ /*
+ * @see org.nuiton.test.tree.TreeFilter#pass(javax.swing.tree.TreeModel, java.lang.Object)
+ */
+ @Override
+ public boolean include(TreeModel model, Object node) {
+
+ boolean result = true;
+
+ if (StringUtils.isNotEmpty(filterString)) {
+ if (node.toString().contains(filterString)) {
+ result = true;
+ }
+ else {
+ result = false;
+ }
+ }
+
+ return result;
+ }
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/MyFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java 2010-03-05 09:09:13 UTC (rev 388)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java 2010-03-05 10:56:46 UTC (rev 389)
@@ -17,6 +17,8 @@
**/
package org.nuiton.test.tree;
+import javax.swing.tree.TreeModel;
+
/**
* TreeFilter
*
@@ -26,6 +28,6 @@
* Date : 4 mars 2010
*/
public interface TreeFilter {
-
- public boolean include(Object o);
+
+ boolean include(TreeModel model, Object node);
}
1
0
r388 - in testTreeTooltipSession/trunk/src/main/java/org/nuiton/test: . resources table tree
by echatellier@users.nuiton.org 05 Mar '10
by echatellier@users.nuiton.org 05 Mar '10
05 Mar '10
Author: echatellier
Date: 2010-03-05 10:09:13 +0100 (Fri, 05 Mar 2010)
New Revision: 388
Log:
Use SAF framework without modification.
Added:
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MyApplication.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MyApplication.properties
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableRenderer.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/BasicTreeModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/CustomTreeFilter.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java
Removed:
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -1,128 +0,0 @@
-/* *
- * Copyright (C) 2010 ceric35
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **/
-package org.nuiton.test;
-
-import java.io.File;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.views.AbstractView;
-
-/**
- * BasicTableModel
- *
- * TODO ADD COMMENT HERE !
- *
- * @author ceric35
- * Date : 4 mars 2010
- */
-public class BasicTableModel extends AbstractTableModel {
-
- /** Logger */
- private static Logger logger = LoggerFactory.getLogger(BasicTableModel.class);
-
- protected File root;
-
- protected File[] children;
-
- public BasicTableModel(File rootFile) {
- this.root = rootFile;
- children = root.listFiles();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
- */
- public Object getChild(Object parent, int index) {
-
- File parentFile = (File)parent;
- File[] children = parentFile.listFiles();
- return children[index];
- }
-
- /*
- * @see javax.swing.table.TableModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- return children.length;
- }
-
- /*
- * @see javax.swing.table.TableModel#getColumnCount()
- */
- @Override
- public int getColumnCount() {
- return 2;
- }
-
-
- /*
- * @see javax.swing.table.AbstractTableModel#getColumnName(int)
- */
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0: result = "File"; break;
- case 1: result = "Size"; break;
- }
-
- return result;
- }
-
- /*
- * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
- */
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- Class<?> result = null;
-
- switch (columnIndex) {
- case 0: result = String.class; break;
- case 1: result = Long.class; break;
- }
-
- return result;
- }
-
- /*
- * @see javax.swing.table.TableModel#getValueAt(int, int)
- */
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
-
- Object result = null;
- File f = children[rowIndex];
- switch (columnIndex) {
- case 0: result = f.getAbsolutePath(); break;
- case 1: result = f.length(); break;
- }
-
- return result;
- }
-
-
-
-}
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -1,119 +0,0 @@
-/* *
- * Copyright (C) 2010 ceric35
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **/
-package org.nuiton.test;
-
-import java.io.File;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BasicTreeModel
- *
- * TODO ADD COMMENT HERE !
- *
- * @author ceric35
- * Date : 4 mars 2010
- */
-public class BasicTreeModel implements TreeModel {
-
- /** Logger */
- private static Logger logger = LoggerFactory.getLogger(BasicTreeModel.class);
-
- protected File root;
-
- public BasicTreeModel(File rootFile) {
- this.root = rootFile;
- }
-
- /* @see javax.swing.tree.TreeModel#getRoot()
- */
- @Override
- public Object getRoot() {
- return root;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
- */
- @Override
- public Object getChild(Object parent, int index) {
-
- File parentFile = (File)parent;
- File[] children = parentFile.listFiles();
- return children[index];
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
- */
- @Override
- public int getChildCount(Object parent) {
- File parentFile = (File)parent;
- File[] children = parentFile.listFiles();
- return children == null ? 0 : children.length;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
- */
- @Override
- public boolean isLeaf(Object node) {
- return getChildCount(node) == 0;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
- */
- @Override
- public void valueForPathChanged(TreePath path, Object newValue) {
-
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
- */
- @Override
- public int getIndexOfChild(Object parent, Object child) {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
- */
- @Override
- public void addTreeModelListener(TreeModelListener l) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
- */
- @Override
- public void removeTreeModelListener(TreeModelListener l) {
- // TODO Auto-generated method stub
-
- }
-
-
-}
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -1,36 +0,0 @@
-/* *
- * Copyright (C) 2010 ceric35
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **/
-package org.nuiton.test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * CustomTreeFilter
- *
- * TODO ADD COMMENT HERE !
- *
- * @author ceric35
- * Date : 4 mars 2010
- */
-public class CustomTreeFilter {
-
- /** Logger */
- private static Logger logger = LoggerFactory.getLogger(Main.class);
-
-}
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -1,200 +0,0 @@
-/* *
- * Copyright (C) 2010 ceric35
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **/
-package org.nuiton.test;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Window;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.io.IOException;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.JToolTip;
-import javax.swing.JTree;
-
-import net.java.balloontip.BalloonTip;
-import net.java.balloontip.styles.RoundedBalloonStyle;
-import net.java.balloontip.utils.ToolTipUtils;
-
-import org.jdesktop.application.SessionStorage;
-import org.nuiton.test.saf.SafApplicationContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.xduke.xswing.DataTipManager;
-
-/**
- * Main
- *
- * @author ceric35
- * Date : 4 mars 2010
- */
-public class Main extends JFrame {
-
- /** Logger */
- private static Logger logger = LoggerFactory.getLogger(Main.class);
-
- public Main() throws IOException {
-
- // label filter
- JPanel leftPanel = new JPanel(new GridBagLayout());
- JLabel filterLabel = new JLabel("Filtre : ");
- leftPanel.add(filterLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(2, 2, 2, 2), 0, 0));
-
- // field filter
- JTextField filterField = new JTextField();
- leftPanel.add(filterField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(2, 2, 2, 2), 0, 0));
-
- // tree
- BasicTreeModel treeModel = new BasicTreeModel(new File(".")
- .getCanonicalFile());
- JTree tree = new JTree(treeModel);
- tree.setName("tree");
- leftPanel.add(new JScrollPane(tree), new GridBagConstraints(0, 1, 2, 1,
- 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(2, 2, 2, 2), 0, 0));
- DataTipManager.get().register(tree);
-
- JPanel rigthPanel = new JPanel(new GridBagLayout());
- // label tootip
- JLabel testToottip = new JLabel("Over me !!!!!") {
- @Override
- public JToolTip createToolTip() {
- JToolTip tt = new JToolTip();
- /*BalloonTip bt = new BalloonTip(this, this.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), false);
- bt.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
-
- BalloonTip source = (BalloonTip)e.getSource();
- source.closeBalloon();
-
- BalloonTip bt = new BalloonTip(source, source.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), true);
- bt.setVisible(true);
- }
-
- });
- //ToolTipUtils.balloonToToolTip(bt, 500, 3000);
- tt.setComponent(this);*/
- return tt;
- }
- };
- testToottip.setToolTipText("Alors ?");
-
- BalloonTip bt = new BalloonTip(testToottip, testToottip
- .getToolTipText(), new RoundedBalloonStyle(5, 5, Color.WHITE,
- Color.BLACK), false);
- bt.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- logger.debug("Called");
- BalloonTip source = (BalloonTip) e.getSource();
- source.setVisible(false);
- source.setEnabled(false);
- BalloonTip bt = new BalloonTip(
- source.getAttachedComponent(),
- source.getAttachedComponent().getToolTipText(),
- new RoundedBalloonStyle(5, 5, Color.WHITE, Color.BLACK),
- true);
- bt.setVisible(true);
- }
- });
- ToolTipUtils.balloonToToolTip(bt, 500, 3000);
- rigthPanel.add(testToottip, new GridBagConstraints(0, 0, 1, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
- 2, 2, 2, 2), 0, 0));
-
- // table
- BasicTableModel tableModel = new BasicTableModel(new File(".")
- .getCanonicalFile());
- JTable table = new JTable(tableModel);
- table.setName("table");
- rigthPanel.add(new JScrollPane(table), new GridBagConstraints(0, 1, 1,
- 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(2, 2, 2, 2), 0, 0));
- DataTipManager.get().register(table);
-
- // end UI
-
- JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rigthPanel);
- pane.setName("mainViewPane");
-
- add(pane);
- }
-
- public static void main(String[] args) throws IOException {
- final Main m = new Main();
- m.setName("mainFrame");
-
- // centering
- centerWindow(m);
-
- SafApplicationContext context = new SafApplicationContext();
- final SessionStorage sessionStorage = context.getSessionStorage();
- sessionStorage.restore(m, m.getName() + "-session.xml");
-
- m.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- try {
- sessionStorage.save(m, m.getName() + "-session.xml");
- System.exit(0);
- } catch (IOException ex) {
- logger.error("Can't save frame session", ex);
- }
- }
- });
- m.setVisible(true);
- }
-
- protected static void centerWindow(Window root) {
- // If the window's bounds don't appear to have been set, do it
- if (root instanceof Window) {
- Window window = (Window) root;
- if (!root.isValid() || (root.getWidth() == 0)
- || (root.getHeight() == 0)) {
- window.pack();
- }
- if (!window.isLocationByPlatform() && (root.getX() == 0)
- && (root.getY() == 0)) {
- Component owner = window.getOwner();
- //if (owner == null) {
- // owner = (window != mainFrame) ? mainFrame : null;
- //}
- window.setLocationRelativeTo(owner); // center the window
- }
- }
- }
-}
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MainPanel.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,211 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.IOException;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.JToolTip;
+import javax.swing.JTree;
+
+import net.java.balloontip.BalloonTip;
+import net.java.balloontip.styles.RoundedBalloonStyle;
+import net.java.balloontip.utils.ToolTipUtils;
+
+import org.nuiton.test.table.BasicTableModel;
+import org.nuiton.test.table.BasicTableRenderer;
+import org.nuiton.test.tree.BasicTreeModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.xduke.xswing.DataTipManager;
+
+/**
+ * Main
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class MainPanel extends JPanel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -4867848058485235754L;
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(MainPanel.class);
+
+ public MainPanel() {
+
+ // label filter
+ JPanel leftPanel = new JPanel(new GridBagLayout());
+ JLabel filterLabel = new JLabel("Filtre : ");
+ leftPanel.add(filterLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(2, 2, 2, 2), 0, 0));
+
+ // field filter
+ JTextField filterField = new JTextField();
+ leftPanel.add(filterField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(2, 2, 2, 2), 0, 0));
+
+ // tree
+ try {
+ BasicTreeModel treeModel = new BasicTreeModel(new File(".")
+ .getCanonicalFile());
+
+ JTree tree = new JTree(treeModel);
+ tree.setName("tree");
+ leftPanel.add(new JScrollPane(tree), new GridBagConstraints(0, 1, 2, 1,
+ 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(2, 2, 2, 2), 0, 0));
+ DataTipManager.get().register(tree);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ JPanel rigthPanel = new JPanel(new GridBagLayout());
+ // label tootip
+ JLabel testToottip = new JLabel("Over me !!!!!") {
+ @Override
+ public JToolTip createToolTip() {
+ JToolTip tt = new JToolTip();
+ /*BalloonTip bt = new BalloonTip(this, this.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), false);
+ bt.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ BalloonTip source = (BalloonTip)e.getSource();
+ source.closeBalloon();
+
+ BalloonTip bt = new BalloonTip(source, source.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), true);
+ bt.setVisible(true);
+ }
+
+ });
+ //ToolTipUtils.balloonToToolTip(bt, 500, 3000);
+ tt.setComponent(this);*/
+ return tt;
+ }
+ };
+ testToottip.setToolTipText("Alors ?");
+
+ BalloonTip bt = new BalloonTip(testToottip, testToottip
+ .getToolTipText(), new RoundedBalloonStyle(5, 5, Color.WHITE,
+ Color.BLACK), false);
+ bt.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ logger.debug("Called");
+ BalloonTip source = (BalloonTip) e.getSource();
+ source.setVisible(false);
+ source.setEnabled(false);
+ BalloonTip bt = new BalloonTip(
+ source.getAttachedComponent(),
+ source.getAttachedComponent().getToolTipText(),
+ new RoundedBalloonStyle(5, 5, Color.WHITE, Color.BLACK),
+ true);
+ bt.setVisible(true);
+ }
+ });
+ ToolTipUtils.balloonToToolTip(bt, 500, 3000);
+ rigthPanel.add(testToottip, new GridBagConstraints(0, 0, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
+ 2, 2, 2, 2), 0, 0));
+
+ // table
+ try {
+ BasicTableModel tableModel = new BasicTableModel(new File(".")
+ .getCanonicalFile());
+
+ JTable table = new JTable(tableModel);
+ table.setDefaultRenderer(String.class, new BasicTableRenderer());
+ table.setName("table");
+ rigthPanel.add(new JScrollPane(table), new GridBagConstraints(0, 1, 1,
+ 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(2, 2, 2, 2), 0, 0));
+
+ DataTipManager.get().register(table);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ // end UI
+
+ JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rigthPanel);
+ pane.setName("mainViewPane");
+
+ add(pane);
+ }
+
+ /*public static void main(String[] args) {
+ final MainFrame m = new MainFrame();
+ m.setName("mainFrame");
+
+ // centering
+ centerWindow(m);
+
+ SafApplicationContext context = new SafApplicationContext();
+ final SessionStorage sessionStorage = context.getSessionStorage();
+ sessionStorage.restore(m, m.getName() + ".session.xml");
+
+ m.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ try {
+ sessionStorage.save(m, m.getName() + ".session.xml");
+ System.exit(0);
+ } catch (IOException ex) {
+ logger.error("Can't save frame session", ex);
+ }
+ }
+ });
+ m.setVisible(true);
+ }
+
+ protected static void centerWindow(Window root) {
+ // If the window's bounds don't appear to have been set, do it
+ if (root instanceof Window) {
+ Window window = (Window) root;
+ if (!root.isValid() || (root.getWidth() == 0)
+ || (root.getHeight() == 0)) {
+ window.pack();
+ }
+ if (!window.isLocationByPlatform() && (root.getX() == 0)
+ && (root.getY() == 0)) {
+ Component owner = window.getOwner();
+ //if (owner == null) {
+ // owner = (window != mainFrame) ? mainFrame : null;
+ //}
+ window.setLocationRelativeTo(owner); // center the window
+ }
+ }
+ }*/
+}
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MyApplication.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MyApplication.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MyApplication.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,47 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.nuiton.test;
+
+import org.jdesktop.application.SingleFrameApplication;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MyApplication extends SingleFrameApplication {
+
+ public static void main(String args[]) {
+ launch(MyApplication.class, args);
+ }
+
+ /*
+ * @see org.jdesktop.application.Application#startup()
+ */
+ @Override
+ protected void startup() {
+ super.getMainFrame().setName("mainFrame");
+ show(new MainPanel());
+ }
+
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/MyApplication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -1,31 +0,0 @@
-/* *
- * Copyright (C) 2010 ceric35
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **/
-package org.nuiton.test;
-
-/**
- * TreeFilter
- *
- * TODO ADD COMMENT HERE !
- *
- * @author ceric35
- * Date : 4 mars 2010
- */
-public interface TreeFilter {
-
- public boolean include(Object o);
-}
Deleted: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties 2010-03-04 16:06:40 UTC (rev 387)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties 2010-03-05 09:09:13 UTC (rev 388)
@@ -1 +0,0 @@
-Application.id=testtesttest
\ No newline at end of file
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MyApplication.properties (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MyApplication.properties (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MyApplication.properties 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,4 @@
+Application.id = myapplication
+Application.title = My frame title
+Application.vendor = CodeLutin
+Application.vendorId = codelutin
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableModel.java (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableModel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableModel.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,128 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test.table;
+
+import java.io.File;
+
+import javax.swing.event.TreeModelListener;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.views.AbstractView;
+
+/**
+ * BasicTableModel
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class BasicTableModel extends AbstractTableModel {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(BasicTableModel.class);
+
+ protected File root;
+
+ protected File[] children;
+
+ public BasicTableModel(File rootFile) {
+ this.root = rootFile;
+ children = root.listFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
+ */
+ public Object getChild(Object parent, int index) {
+
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children[index];
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ return children.length;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+
+ /*
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0: result = "File"; break;
+ case 1: result = "Size"; break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
+ */
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ Class<?> result = null;
+
+ switch (columnIndex) {
+ case 0: result = String.class; break;
+ case 1: result = Long.class; break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ Object result = null;
+ File f = children[rowIndex];
+ switch (columnIndex) {
+ case 0: result = f.getAbsolutePath(); break;
+ case 1: result = f.length(); break;
+ }
+
+ return result;
+ }
+
+
+
+}
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableRenderer.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableRenderer.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableRenderer.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,122 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.nuiton.test.table;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class BasicTableRenderer extends DefaultTableCellRenderer implements MouseListener {
+
+ /*
+ * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
+ */
+ @Override
+ public Component getTableCellRendererComponent(final JTable table, Object value,
+ boolean isSelected, boolean hasFocus, final int row, final int column) {
+
+ JComponent c = (JComponent)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ /*JLabel b = new JLabel(value.toString()) {
+ @Override
+ public JToolTip createToolTip() {
+ JToolTip tt = super.createToolTip();
+
+ //TablecellBalloonTip tip = new TablecellBalloonTip(table, "etst", row, column, new RoundedBalloonStyle(5,5
+ // , Color.WHITE, Color.BLACK), Orientation.RIGHT_ABOVE, AttachLocation.ALIGNED, 5, 5, true);
+ BalloonTip bt = new BalloonTip(this, this.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), false);
+ /*bt.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ BalloonTip source = (BalloonTip)e.getSource();
+ source.closeBalloon();
+
+ BalloonTip bt = new BalloonTip(source, source.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), true);
+ bt.setVisible(true);
+ }
+
+ });
+ ToolTipUtils.balloonToToolTip(bt, 500, 3000);
+ tt.setComponent(bt);
+
+ return tt;
+ }
+ };
+ b.setToolTipText("Tooltip = " + value.toString());*/
+
+ this.addMouseListener(new BasicTableRenderer());
+
+ return this;
+ }
+
+ /*
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ System.out.println("mouseClicked");
+ }
+
+ /*
+ * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mousePressed(MouseEvent e) {
+ System.out.println("mousePressed");
+ }
+
+ /*
+ * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ System.out.println("mouseReleased");
+ }
+
+ /*
+ * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ System.out.println("mouseEntered");
+ }
+
+ /*
+ * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseExited(MouseEvent e) {
+ System.out.println("mouseExited");
+ }
+
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/table/BasicTableRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/BasicTreeModel.java (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/BasicTreeModel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/BasicTreeModel.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,119 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test.tree;
+
+import java.io.File;
+
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BasicTreeModel
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class BasicTreeModel implements TreeModel {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(BasicTreeModel.class);
+
+ protected File root;
+
+ public BasicTreeModel(File rootFile) {
+ this.root = rootFile;
+ }
+
+ /* @see javax.swing.tree.TreeModel#getRoot()
+ */
+ @Override
+ public Object getRoot() {
+ return root;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
+ */
+ @Override
+ public Object getChild(Object parent, int index) {
+
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children[index];
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
+ */
+ @Override
+ public int getChildCount(Object parent) {
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children == null ? 0 : children.length;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
+ */
+ @Override
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
+ */
+ @Override
+ public void valueForPathChanged(TreePath path, Object newValue) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void addTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void removeTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/CustomTreeFilter.java (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/CustomTreeFilter.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/CustomTreeFilter.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,37 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test.tree;
+
+import org.nuiton.test.MainPanel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * CustomTreeFilter
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class CustomTreeFilter {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(MainPanel.class);
+
+}
Copied: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java (from rev 387, testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java)
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/tree/TreeFilter.java 2010-03-05 09:09:13 UTC (rev 388)
@@ -0,0 +1,31 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test.tree;
+
+/**
+ * TreeFilter
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public interface TreeFilter {
+
+ public boolean include(Object o);
+}
1
0
r387 - in testTreeTooltipSession/trunk: . src src/main src/main/java src/main/java/com src/main/java/com/xduke src/main/java/com/xduke/xswing src/main/java/org src/main/java/org/nuiton src/main/java/org/nuiton/test src/main/java/org/nuiton/test/resources src/main/java/org/nuiton/test/saf
by echatellier@users.nuiton.org 04 Mar '10
by echatellier@users.nuiton.org 04 Mar '10
04 Mar '10
Author: echatellier
Date: 2010-03-04 17:06:40 +0100 (Thu, 04 Mar 2010)
New Revision: 387
Log:
Init commit.
Added:
testTreeTooltipSession/trunk/pom.xml
testTreeTooltipSession/trunk/src/
testTreeTooltipSession/trunk/src/main/
testTreeTooltipSession/trunk/src/main/java/
testTreeTooltipSession/trunk/src/main/java/com/
testTreeTooltipSession/trunk/src/main/java/com/xduke/
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipCell.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipComponent.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipListener.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipManager.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipPopup.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipCell.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipListener.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipCell.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipListener.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipCell.java
testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipListener.java
testTreeTooltipSession/trunk/src/main/java/org/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/
testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/SafApplicationContext.java
testTreeTooltipSession/trunk/src/main/resources/
Modified:
testTreeTooltipSession/trunk/
Property changes on: testTreeTooltipSession/trunk
___________________________________________________________________
Added: svn:ignore
+ .settings
target
.classpath
.project
Added: testTreeTooltipSession/trunk/pom.xml
===================================================================
--- testTreeTooltipSession/trunk/pom.xml (rev 0)
+++ testTreeTooltipSession/trunk/pom.xml 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.ceric35</groupId>
+ <artifactId>testtrees</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>TestTrees</name>
+ <description>TestTrees</description>
+ <inceptionYear>2010</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>GPL</name>
+ <url>http://www.gnu.org/licenses/gpl.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <developers>
+ <developer>
+ <id>ceric35</id>
+ <name>Eric Chatellier</name>
+ <email>chatellier(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputDirectory>UTF-8</project.reporting.outputDirectory>
+ <maven.compiler.source>1.6</maven.compiler.source>
+ <maven.compiler.target>1.6</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.nuiton.test.Main</mainClass>
+ <classpathScope>runtime</classpathScope>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.11</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>0.9.18</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <classifier>jdk15</classifier>
+ <version>5.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swingx</artifactId>
+ <version>1.6</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.java.balloontip</groupId>
+ <artifactId>balloontip</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jdesktop</groupId>
+ <artifactId>appframework</artifactId>
+ <version>1.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>nuiton.repository</id>
+ <url>http://maven.nuiton.org/release</url>
+ </repository>
+ <repository>
+ <id>jboss.repository</id>
+ <url>http://repository.jboss.com/maven2</url>
+ </repository>
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <url>http://download.java.net/maven/2/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>nuiton.repository</id>
+ <url>http://maven.nuiton.org/release</url>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipCell.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipCell.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipCell.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipComponent.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipComponent.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipComponent.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipComponent.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipListener.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipListener.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipListener.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipManager.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipManager.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipManager.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipManager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipPopup.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipPopup.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipPopup.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/DataTipPopup.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipCell.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipCell.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipCell.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+import com.xduke.xswing.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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipListener.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipListener.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipListener.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+import com.xduke.xswing.DataTipCell;
+import com.xduke.xswing.DataTipListener;
+import com.xduke.xswing.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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/ListDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipCell.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipCell.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipCell.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+import com.xduke.xswing.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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipListener.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipListener.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipListener.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+import com.xduke.xswing.DataTipCell;
+import com.xduke.xswing.DataTipListener;
+import com.xduke.xswing.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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TableDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipCell.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipCell.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipCell.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,91 @@
+/*
+ * 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 com.xduke.xswing;
+
+import com.xduke.xswing.DataTipCell;
+
+import javax.swing.*;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeCellRenderer;
+import java.awt.*;
+
+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());
+ 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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipListener.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipListener.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipListener.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -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 com.xduke.xswing;
+
+import com.xduke.xswing.DataTipCell;
+import com.xduke.xswing.DataTipListener;
+import com.xduke.xswing.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: testTreeTooltipSession/trunk/src/main/java/com/xduke/xswing/TreeDataTipListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,128 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+import java.io.File;
+
+import javax.swing.event.TreeModelListener;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.views.AbstractView;
+
+/**
+ * BasicTableModel
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class BasicTableModel extends AbstractTableModel {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(BasicTableModel.class);
+
+ protected File root;
+
+ protected File[] children;
+
+ public BasicTableModel(File rootFile) {
+ this.root = rootFile;
+ children = root.listFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
+ */
+ public Object getChild(Object parent, int index) {
+
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children[index];
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ return children.length;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+
+ /*
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0: result = "File"; break;
+ case 1: result = "Size"; break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
+ */
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ Class<?> result = null;
+
+ switch (columnIndex) {
+ case 0: result = String.class; break;
+ case 1: result = Long.class; break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ Object result = null;
+ File f = children[rowIndex];
+ switch (columnIndex) {
+ case 0: result = f.getAbsolutePath(); break;
+ case 1: result = f.length(); break;
+ }
+
+ return result;
+ }
+
+
+
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,119 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+import java.io.File;
+
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BasicTreeModel
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class BasicTreeModel implements TreeModel {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(BasicTreeModel.class);
+
+ protected File root;
+
+ public BasicTreeModel(File rootFile) {
+ this.root = rootFile;
+ }
+
+ /* @see javax.swing.tree.TreeModel#getRoot()
+ */
+ @Override
+ public Object getRoot() {
+ return root;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
+ */
+ @Override
+ public Object getChild(Object parent, int index) {
+
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children[index];
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
+ */
+ @Override
+ public int getChildCount(Object parent) {
+ File parentFile = (File)parent;
+ File[] children = parentFile.listFiles();
+ return children == null ? 0 : children.length;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
+ */
+ @Override
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
+ */
+ @Override
+ public void valueForPathChanged(TreePath path, Object newValue) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void addTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
+ */
+ @Override
+ public void removeTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/BasicTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,36 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * CustomTreeFilter
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class CustomTreeFilter {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(Main.class);
+
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/CustomTreeFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,200 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Window;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.io.IOException;
+
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.JToolTip;
+import javax.swing.JTree;
+
+import net.java.balloontip.BalloonTip;
+import net.java.balloontip.styles.RoundedBalloonStyle;
+import net.java.balloontip.utils.ToolTipUtils;
+
+import org.jdesktop.application.SessionStorage;
+import org.nuiton.test.saf.SafApplicationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.xduke.xswing.DataTipManager;
+
+/**
+ * Main
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public class Main extends JFrame {
+
+ /** Logger */
+ private static Logger logger = LoggerFactory.getLogger(Main.class);
+
+ public Main() throws IOException {
+
+ // label filter
+ JPanel leftPanel = new JPanel(new GridBagLayout());
+ JLabel filterLabel = new JLabel("Filtre : ");
+ leftPanel.add(filterLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(2, 2, 2, 2), 0, 0));
+
+ // field filter
+ JTextField filterField = new JTextField();
+ leftPanel.add(filterField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(2, 2, 2, 2), 0, 0));
+
+ // tree
+ BasicTreeModel treeModel = new BasicTreeModel(new File(".")
+ .getCanonicalFile());
+ JTree tree = new JTree(treeModel);
+ tree.setName("tree");
+ leftPanel.add(new JScrollPane(tree), new GridBagConstraints(0, 1, 2, 1,
+ 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(2, 2, 2, 2), 0, 0));
+ DataTipManager.get().register(tree);
+
+ JPanel rigthPanel = new JPanel(new GridBagLayout());
+ // label tootip
+ JLabel testToottip = new JLabel("Over me !!!!!") {
+ @Override
+ public JToolTip createToolTip() {
+ JToolTip tt = new JToolTip();
+ /*BalloonTip bt = new BalloonTip(this, this.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), false);
+ bt.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ BalloonTip source = (BalloonTip)e.getSource();
+ source.closeBalloon();
+
+ BalloonTip bt = new BalloonTip(source, source.getToolTipText(), new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), true);
+ bt.setVisible(true);
+ }
+
+ });
+ //ToolTipUtils.balloonToToolTip(bt, 500, 3000);
+ tt.setComponent(this);*/
+ return tt;
+ }
+ };
+ testToottip.setToolTipText("Alors ?");
+
+ BalloonTip bt = new BalloonTip(testToottip, testToottip
+ .getToolTipText(), new RoundedBalloonStyle(5, 5, Color.WHITE,
+ Color.BLACK), false);
+ bt.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ logger.debug("Called");
+ BalloonTip source = (BalloonTip) e.getSource();
+ source.setVisible(false);
+ source.setEnabled(false);
+ BalloonTip bt = new BalloonTip(
+ source.getAttachedComponent(),
+ source.getAttachedComponent().getToolTipText(),
+ new RoundedBalloonStyle(5, 5, Color.WHITE, Color.BLACK),
+ true);
+ bt.setVisible(true);
+ }
+ });
+ ToolTipUtils.balloonToToolTip(bt, 500, 3000);
+ rigthPanel.add(testToottip, new GridBagConstraints(0, 0, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
+ 2, 2, 2, 2), 0, 0));
+
+ // table
+ BasicTableModel tableModel = new BasicTableModel(new File(".")
+ .getCanonicalFile());
+ JTable table = new JTable(tableModel);
+ table.setName("table");
+ rigthPanel.add(new JScrollPane(table), new GridBagConstraints(0, 1, 1,
+ 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(2, 2, 2, 2), 0, 0));
+ DataTipManager.get().register(table);
+
+ // end UI
+
+ JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rigthPanel);
+ pane.setName("mainViewPane");
+
+ add(pane);
+ }
+
+ public static void main(String[] args) throws IOException {
+ final Main m = new Main();
+ m.setName("mainFrame");
+
+ // centering
+ centerWindow(m);
+
+ SafApplicationContext context = new SafApplicationContext();
+ final SessionStorage sessionStorage = context.getSessionStorage();
+ sessionStorage.restore(m, m.getName() + "-session.xml");
+
+ m.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ try {
+ sessionStorage.save(m, m.getName() + "-session.xml");
+ System.exit(0);
+ } catch (IOException ex) {
+ logger.error("Can't save frame session", ex);
+ }
+ }
+ });
+ m.setVisible(true);
+ }
+
+ protected static void centerWindow(Window root) {
+ // If the window's bounds don't appear to have been set, do it
+ if (root instanceof Window) {
+ Window window = (Window) root;
+ if (!root.isValid() || (root.getWidth() == 0)
+ || (root.getHeight() == 0)) {
+ window.pack();
+ }
+ if (!window.isLocationByPlatform() && (root.getX() == 0)
+ && (root.getY() == 0)) {
+ Component owner = window.getOwner();
+ //if (owner == null) {
+ // owner = (window != mainFrame) ? mainFrame : null;
+ //}
+ window.setLocationRelativeTo(owner); // center the window
+ }
+ }
+ }
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/Main.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,31 @@
+/* *
+ * Copyright (C) 2010 ceric35
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ **/
+package org.nuiton.test;
+
+/**
+ * TreeFilter
+ *
+ * TODO ADD COMMENT HERE !
+ *
+ * @author ceric35
+ * Date : 4 mars 2010
+ */
+public interface TreeFilter {
+
+ public boolean include(Object o);
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/TreeFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/resources/MainApplication.properties 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1 @@
+Application.id=testtesttest
\ No newline at end of file
Added: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/SafApplicationContext.java
===================================================================
--- testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/SafApplicationContext.java (rev 0)
+++ testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/SafApplicationContext.java 2010-03-04 16:06:40 UTC (rev 387)
@@ -0,0 +1,39 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.nuiton.test.saf;
+
+import org.jdesktop.application.Application;
+import org.jdesktop.application.ApplicationContext;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SafApplicationContext extends ApplicationContext {
+
+ public SafApplicationContext() {
+ super();
+ setApplicationClass(Application.class);
+ }
+}
Property changes on: testTreeTooltipSession/trunk/src/main/java/org/nuiton/test/saf/SafApplicationContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: echatellier
Date: 2010-03-04 17:06:00 +0100 (Thu, 04 Mar 2010)
New Revision: 386
Log:
Initial import.
Added:
testTreeTooltipSession/
testTreeTooltipSession/trunk/
1
0