001 /* 002 Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public 015 License along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 */ 018 019 package org.objectweb.jac.ide.diagrams; 020 021 import CH.ifa.draw.framework.Tool; 022 import CH.ifa.draw.util.PaletteListener; 023 import org.objectweb.jac.aspects.gui.ResourceManager; 024 import java.awt.Point; 025 import javax.swing.JPanel; 026 027 028 public class ToolPalette extends JPanel { 029 030 public ToolPalette() { 031 setLayout(new PaletteLayout(2,new Point(2,2))); 032 } 033 034 035 /** 036 * Add a tool button with the given image, tool, and text 037 * 038 * @param iconName name of the icon of the tool 039 * @param toolName name of the tool 040 * @param tool the tool 041 */ 042 public ToolButton addToolButton(PaletteListener paletteListener, 043 String iconName, String toolName, 044 Tool tool) { 045 ToolButton button = 046 new ToolButton(paletteListener, 047 ResourceManager.getIconResource(iconName), 048 toolName, 049 tool); 050 add(button); 051 return button; 052 } 053 054 ToolButton defaultToolButton; 055 public void setDefaultToolButton(ToolButton defaultToolButton) { 056 this.defaultToolButton = defaultToolButton; 057 } 058 public ToolButton getDefaultToolButton() { 059 return defaultToolButton; 060 } 061 }