|
@@ -1,33 +1,30 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.aokeyhole.swing; |
3 |
3 |
|
|
4 |
|
- |
import java.awt.*; |
5 |
|
- |
import java.util.*; |
6 |
|
- |
import java.util.List; |
7 |
|
- |
import javax.swing.*; |
8 |
|
- |
|
9 |
4 |
|
import org.litesoft.aokeyhole.objects.*; |
10 |
5 |
|
import org.litesoft.aokeyhole.swing.simplecomponents.*; |
11 |
6 |
|
import org.litesoft.aokeyhole.toolkit.*; |
12 |
7 |
|
import org.litesoft.aokeyhole.toolkit.editorviewer.*; |
13 |
8 |
|
|
14 |
|
- |
public class AddNewObjectTypeSelectorJPanel extends JPanelPlus implements ActionsListener |
15 |
|
- |
{ |
|
9 |
+ |
import javax.swing.*; |
|
10 |
+ |
import java.awt.*; |
|
11 |
+ |
import java.util.*; |
|
12 |
+ |
import java.util.List; |
|
13 |
+ |
|
|
14 |
+ |
public class AddNewObjectTypeSelectorJPanel extends JPanelPlus implements ActionsListener { |
16 |
15 |
|
private ActionsListener mActionsListener; |
17 |
16 |
|
private NewObjectTypeSelectionListener mNewObjectTypeSelectionListener; |
18 |
17 |
|
private ArrayList<OurRadioButton> mTypeOptions = new ArrayList<OurRadioButton>(); |
19 |
18 |
|
|
20 |
19 |
|
public AddNewObjectTypeSelectorJPanel( List<ObjectSet> pObjectSets, ActionsListener pActionsListener, |
21 |
|
- |
NewObjectTypeSelectionListener pNewObjectTypeSelectionListener ) |
22 |
|
- |
{ |
|
20 |
+ |
NewObjectTypeSelectionListener pNewObjectTypeSelectionListener ) { |
23 |
21 |
|
super( new BorderLayout() ); |
24 |
22 |
|
|
25 |
23 |
|
mActionsListener = pActionsListener; |
26 |
24 |
|
mNewObjectTypeSelectionListener = pNewObjectTypeSelectionListener; |
27 |
25 |
|
|
28 |
26 |
|
boolean zSelected = true; |
29 |
|
- |
for ( ObjectSet zSet : pObjectSets ) |
30 |
|
- |
{ |
|
27 |
+ |
for ( ObjectSet zSet : pObjectSets ) { |
31 |
28 |
|
mTypeOptions.add( new OurRadioButton( zSet, zSelected ) ); |
32 |
29 |
|
zSelected = false; |
33 |
30 |
|
} |
|
@@ -38,10 +35,8 @@ |
38 |
35 |
|
} |
39 |
36 |
|
|
40 |
37 |
|
@Override |
41 |
|
- |
public void actionRequested( String pAction ) |
42 |
|
- |
{ |
43 |
|
- |
if ( ActionsListener.ACTION_CANCEL.equals( pAction ) ) |
44 |
|
- |
{ |
|
38 |
+ |
public void actionRequested( String pAction ) { |
|
39 |
+ |
if ( ActionsListener.ACTION_CANCEL.equals( pAction ) ) { |
45 |
40 |
|
mActionsListener.actionRequested( pAction ); |
46 |
41 |
|
return; |
47 |
42 |
|
} |
|
@@ -49,28 +44,23 @@ |
49 |
44 |
|
mNewObjectTypeSelectionListener.newObjectTypeSelected( zSet ); |
50 |
45 |
|
} |
51 |
46 |
|
|
52 |
|
- |
private ObjectSet determineSelectedObjectSet() |
53 |
|
- |
{ |
54 |
|
- |
for ( int i = mTypeOptions.size(); --i > 0; ) |
55 |
|
- |
{ |
|
47 |
+ |
private ObjectSet determineSelectedObjectSet() { |
|
48 |
+ |
for ( int i = mTypeOptions.size(); --i > 0; ) { |
56 |
49 |
|
OurRadioButton zButton = mTypeOptions.get( i ); |
57 |
|
- |
if ( zButton.isSelected() ) |
58 |
|
- |
{ |
|
50 |
+ |
if ( zButton.isSelected() ) { |
59 |
51 |
|
return zButton.getObjectSet(); |
60 |
52 |
|
} |
61 |
53 |
|
} |
62 |
54 |
|
return mTypeOptions.get( 0 ).getObjectSet(); |
63 |
55 |
|
} |
64 |
56 |
|
|
65 |
|
- |
private JPanel createOptionPanel() |
66 |
|
- |
{ |
|
57 |
+ |
private JPanel createOptionPanel() { |
67 |
58 |
|
ButtonGroup group = new ButtonGroup(); |
68 |
59 |
|
JPanel options = new JPanel( new GridLayout( mTypeOptions.size() + 1, 1 ) ); |
69 |
60 |
|
|
70 |
61 |
|
options.add( new JLabel( " " ) ); |
71 |
62 |
|
|
72 |
|
- |
for ( OurRadioButton zOption : mTypeOptions ) |
73 |
|
- |
{ |
|
63 |
+ |
for ( OurRadioButton zOption : mTypeOptions ) { |
74 |
64 |
|
group.add( zOption ); |
75 |
65 |
|
options.add( zOption ); |
76 |
66 |
|
} |
|
@@ -78,18 +68,15 @@ |
78 |
68 |
|
return options; |
79 |
69 |
|
} |
80 |
70 |
|
|
81 |
|
- |
private class OurRadioButton extends JRadioButton |
82 |
|
- |
{ |
|
71 |
+ |
private class OurRadioButton extends JRadioButton { |
83 |
72 |
|
private ObjectSet mObjectSet; |
84 |
73 |
|
|
85 |
|
- |
public OurRadioButton( ObjectSet pObjectSet, boolean selected ) |
86 |
|
- |
{ |
|
74 |
+ |
public OurRadioButton( ObjectSet pObjectSet, boolean selected ) { |
87 |
75 |
|
super( pObjectSet.getType(), selected ); |
88 |
76 |
|
mObjectSet = pObjectSet; |
89 |
77 |
|
} |
90 |
78 |
|
|
91 |
|
- |
public ObjectSet getObjectSet() |
92 |
|
- |
{ |
|
79 |
+ |
public ObjectSet getObjectSet() { |
93 |
80 |
|
return mObjectSet; |
94 |
81 |
|
} |
95 |
82 |
|
} |