r388 - in testTreeTooltipSession/trunk/src/main/java/org/nuiton/test: . resources table tree
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); +}
participants (1)
-
echatellier@users.nuiton.org