01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.support.components;
14:
15: import javax.swing.Action;
16: import javax.swing.JButton;
17: import javax.swing.JPanel;
18:
19: import com.eviware.soapui.support.HelpActionMarker;
20: import com.eviware.soapui.support.action.swing.ActionList;
21: import com.eviware.soapui.support.action.swing.ActionSupport;
22: import com.jgoodies.forms.builder.ButtonBarBuilder;
23:
24: public class JButtonBar extends JPanel {
25: private ButtonBarBuilder builder;
26: private JButton defaultButton;
27:
28: public JButtonBar() {
29: builder = new ButtonBarBuilder(this );
30: }
31:
32: public void addActions(ActionList actions) {
33: for (int c = 0; c < actions.getActionCount(); c++) {
34: Action action = actions.getActionAt(c);
35:
36: if (!(action instanceof HelpActionMarker) && c == 0)
37: builder.addGlue();
38:
39: if (action == ActionSupport.SEPARATOR_ACTION) {
40: builder.addUnrelatedGap();
41: } else {
42: if (c > 0)
43: builder.addRelatedGap();
44:
45: JButton button = new JButton(action);
46: if (c == 0 || actions.getDefaultAction() == action)
47: defaultButton = button;
48:
49: if (action.getValue(Action.SMALL_ICON) != null)
50: button.setText(null);
51:
52: builder.addFixed(button);
53: }
54:
55: if (action instanceof HelpActionMarker && c == 0)
56: builder.addGlue();
57: }
58: }
59:
60: public JButton getDefaultButton() {
61: return defaultButton;
62: }
63: }
|