Mercurial > hg > ltpda
view src/MPipeline2/src/mpipeline/pipelinelist/PipelineListTreeRenderer.java @ 52:daf4eab1a51e database-connection-manager tip
Fix. Default password should be [] not an empty string
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:29:47 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
/* * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de> * * 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ package mpipeline.pipelinelist; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.FontMetrics; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.tree.DefaultTreeCellRenderer; import mpipeline.canvas.BlockDiagram; import mpipeline.canvas.MCanvas; /** * A subclass of DefaultTreeCellRenderer that allows us to set the tooltip for * the tree given the element we are over. * * @author hewitson */ public class PipelineListTreeRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { final Component rc = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); String tooltip = ""; if (value instanceof PipelineList) { PipelineList pl = (PipelineList) value; if (pl.isSelected()) { rc.setForeground(Color.red); } else { rc.setForeground(Color.black); } BlockDiagram diag = pl.getDiagram(); if (diag != null) { MCanvas c = diag.getCanvas(); if (c != null) { tooltip = c.getMyInfo().toHTMLString(); } } } String txt = ((JLabel) rc).getText(); FontMetrics fm = rc.getFontMetrics(rc.getFont()); int w = SwingUtilities.computeStringWidth(fm, txt); w = w + getIcon().getIconWidth() + Math.max(0, getIconTextGap() - 1); Dimension d = new Dimension(w, 20); rc.setPreferredSize(d); rc.setMinimumSize(d); rc.setMaximumSize(d); rc.setSize(d); this.setToolTipText(tooltip); return rc; } }