1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.action.swing;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import javax.swing.Action;
19 import javax.swing.BorderFactory;
20 import javax.swing.JComponent;
21
22 import com.eviware.soapui.model.ModelItem;
23 import com.eviware.soapui.support.action.SoapUIAction;
24 import com.eviware.soapui.support.actions.MarkerAction;
25 import com.eviware.soapui.support.components.JXToolBar;
26 import com.jgoodies.looks.HeaderStyle;
27 import com.jgoodies.looks.Options;
28
29 public class JXSoapUIActionListToolBar extends JXToolBar
30 {
31 private Map<String, Action> actionMap = new HashMap<String, Action>();
32
33 @SuppressWarnings( "unchecked" )
34 public JXSoapUIActionListToolBar( ActionList actions, ModelItem modelItem )
35 {
36 addSpace( 1 );
37 setRollover( true );
38 putClientProperty( Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE );
39 setBorder( BorderFactory.createEmptyBorder( 3, 0, 3, 0 ) );
40
41 for( int i = 0; i < actions.getActionCount(); i++ )
42 {
43 Action action = actions.getActionAt( i );
44
45 if( action instanceof MarkerAction )
46 continue;
47
48 if( action == ActionSupport.SEPARATOR_ACTION )
49 {
50 addSeparator();
51 }
52 else if( action instanceof ActionSupport.ActionListAction )
53 {
54
55
56
57
58
59
60 }
61 else if( action != null )
62 {
63 JComponent component = null;
64
65 if( action instanceof SoapUIActionMarker )
66 {
67 SoapUIAction soapUIAction = ( ( SoapUIActionMarker )action ).getSoapUIAction();
68 component = ActionComponentRegistry.buildActionComponent( soapUIAction, modelItem );
69 actionMap.put( soapUIAction.getId(), action );
70 }
71
72 if( component != null )
73 add( component );
74 else
75 add( action );
76 }
77 }
78 }
79
80 public JXSoapUIActionListToolBar( ModelItem modelItem )
81 {
82 this( ActionListBuilder.buildActions( modelItem, "EditorToolbar" ), modelItem );
83 }
84
85 public void setEnabled( String actionId, boolean enabled )
86 {
87 if( actionMap.containsKey( actionId ) )
88 actionMap.get( actionId ).setEnabled( enabled );
89 }
90
91 }