PageRenderTime 83ms CodeModel.GetById 78ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/Ancestor/src/gatchan/jedit/ancestor/AncestorButton.java

#
Java | 65 lines | 32 code | 4 blank | 29 comment | 4 complexity | 79dca28acb35f9cff1bea9947b9c2e51 MD5 | raw file
 1/*
 2 * AncestorButton.java - The button representation for an Ancestor
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2007, 201 Matthieu Casanova
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21package gatchan.jedit.ancestor;
22
23import javax.swing.*;
24import java.awt.event.ActionListener;
25import java.awt.event.ActionEvent;
26import java.awt.*;
27
28/**
29 * @author Matthieu Casanova
30 * @version $Id: Server.java,v 1.33 2007/01/05 15:15:17 matthieu Exp $
31 */
32public class AncestorButton extends JButton
33{
34	private Ancestor ancestor;
35
36	//{{{ AncestorButton constructor
37	/**
38	 * Creates a button with no set text or icon.
39	 */
40	public AncestorButton()
41	{
42		addActionListener(new ActionListener()
43		{
44			@Override
45			public void actionPerformed(ActionEvent e)
46			{
47				if (ancestor != null)
48				{
49					if((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
50						ancestor.closeContainedFiles();
51					else
52						ancestor.doAction();
53				}
54			}
55		});
56		setMargin(new Insets(0,0,0,0));
57	} //}}}
58
59	//{{{ setAncestor() method
60	public void setAncestor(Ancestor ancestor)
61	{
62		this.ancestor = ancestor;
63		setText(ancestor.getName());
64	} //}}}
65}