1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.components;
14
15 import com.eviware.soapui.support.HelpActionMarker;
16 import com.eviware.soapui.support.action.swing.ActionList;
17 import com.eviware.soapui.support.action.swing.ActionSupport;
18 import com.eviware.soapui.support.swing.JXButtonPanel;
19 import com.jgoodies.forms.builder.ButtonBarBuilder;
20
21 import javax.swing.*;
22
23 public class JButtonBar extends JXButtonPanel
24 {
25 private ButtonBarBuilder builder;
26 private JButton defaultButton;
27
28 public JButtonBar()
29 {
30 builder = new ButtonBarBuilder( this );
31 }
32
33 public void addActions( ActionList actions )
34 {
35 for( int c = 0; c < actions.getActionCount(); c++ )
36 {
37 Action action = actions.getActionAt( c );
38
39 if( !( action instanceof HelpActionMarker ) && c == 0 )
40 {
41 if( getComponentCount() == 0 )
42 builder.addGlue();
43 else
44 builder.addUnrelatedGap();
45 }
46
47 if( action == ActionSupport.SEPARATOR_ACTION )
48 {
49 builder.addUnrelatedGap();
50 }
51 else
52 {
53 if( c > 0 )
54 builder.addRelatedGap();
55
56 JButton button = new JButton( action );
57 if( c == 0 || actions.getDefaultAction() == action )
58 defaultButton = button;
59
60 if( action.getValue( Action.SMALL_ICON ) != null )
61 button.setText( null );
62
63 builder.addFixed( button );
64 }
65
66 if( action instanceof HelpActionMarker && c == 0 )
67 builder.addGlue();
68 }
69 }
70
71 public JButton getDefaultButton()
72 {
73 return defaultButton;
74 }
75 }