10 |
|
|
11 |
import net.miginfocom.swing.MigLayout; |
import net.miginfocom.swing.MigLayout; |
12 |
import schmitzm.swing.JPanel; |
import schmitzm.swing.JPanel; |
|
import schmitzm.swing.SwingUtil; |
|
13 |
|
|
14 |
public abstract class CancellableTabbedDialogAdapter extends |
public abstract class CancellableTabbedDialogAdapter extends |
15 |
CancellableDialogAdapter { |
CancellableDialogAdapter { |
16 |
|
|
17 |
private final JTabbedPane tabbedPane; |
private final JTabbedPane tabbedPane; |
18 |
|
|
19 |
public CancellableTabbedDialogAdapter(Component owner) { |
public CancellableTabbedDialogAdapter(Component owner, String title) { |
20 |
super(owner); |
super(owner, title); |
21 |
|
|
22 |
/** |
/** |
23 |
* Prepare buttons |
* Prepare buttons |
25 |
final JPanel buttons = createButtons(); |
final JPanel buttons = createButtons(); |
26 |
|
|
27 |
/*** Build GUI ***/ |
/*** Build GUI ***/ |
28 |
tabbedPane = new JTabbedPane(){ |
tabbedPane = new JTabbedPane() { |
29 |
@Override |
@Override |
30 |
public void insertTab(String title, Icon icon, Component component, |
public void insertTab(String title, Icon icon, Component component, |
31 |
String tip, int index) { |
String tip, int index) { |
45 |
|
|
46 |
} |
} |
47 |
|
|
48 |
|
public CancellableTabbedDialogAdapter(Component parentWindow) { |
49 |
|
this(parentWindow, null); |
50 |
|
} |
51 |
|
|
52 |
/** |
/** |
53 |
* Is only called once! Doesn't use lazy initialization. Use |
* Is only called once! Doesn't use lazy initialization. Use |
54 |
* <code>super.createButtons.add( newButton )</code> to add buttons. |
* <code>super.createButtons.add( newButton )</code> to add buttons. |
70 |
|
|
71 |
// Set tool tip text |
// Set tool tip text |
72 |
putValue(Action.SHORT_DESCRIPTION, |
putValue(Action.SHORT_DESCRIPTION, |
73 |
"Accept the changes made in this dialog."); // i8n |
"Accept the changes made in this dialog."); // i8n i8n |
74 |
|
// i8n |
75 |
} |
} |
76 |
|
|
77 |
// |
// |
81 |
|
|
82 |
}); |
}); |
83 |
|
|
84 |
buttonsJPanel.add(okButton); |
buttonsJPanel.add(okButton, "tag ok"); |
85 |
|
|
86 |
final CancelButton cancelButton = new CancelButton(new AbstractAction( |
final CancelButton cancelButton = new CancelButton(new AbstractAction( |
87 |
"") { |
"") { |
89 |
cancelClose(); |
cancelClose(); |
90 |
} |
} |
91 |
}); |
}); |
92 |
buttonsJPanel.add(cancelButton); |
buttonsJPanel.add(cancelButton, "tag cancel"); |
93 |
|
|
94 |
return buttonsJPanel; |
return buttonsJPanel; |
95 |
} |
} |
97 |
public JTabbedPane getTabbedPane() { |
public JTabbedPane getTabbedPane() { |
98 |
return tabbedPane; |
return tabbedPane; |
99 |
} |
} |
100 |
|
|
101 |
/** |
/** |
102 |
* Calling cancel() will call cancel to all {@link Cancellable} children in the tabbedPane. |
* Calling cancel() will call cancel to all {@link Cancellable} children in |
103 |
|
* the tabbedPane. |
104 |
*/ |
*/ |
105 |
@Override |
@Override |
106 |
public void cancel() { |
public void cancel() { |
114 |
} |
} |
115 |
} |
} |
116 |
|
|
|
|
|
117 |
@Override |
@Override |
118 |
public boolean okClose() { |
public boolean okClose() { |
119 |
// TranslationAskJDialog.this.firePropertyChange( |
// TranslationAskJDialog.this.firePropertyChange( |