import javax.swing.JPanel;
import javax.swing.JTabbedPane;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.simantics.utils.strings.format.MetricsFormat;
public class AWTStyleDialog extends JDialog {
private boolean useFormat = true;
public AWTStyleDialog(Frame owner,boolean useFont, boolean useColor, boolean useFormat) {
- super(owner,"Style",true);
+ super(owner,Messages.AWTStyleDialog_Style,true);
this.useFont = useFont;
this.useColor = useColor;
this.useFormat = useFormat;
public AWTStyleDialog(boolean useFont, boolean useColor, boolean useFormat) {
super();
- setTitle("Style");
+ setTitle(Messages.AWTStyleDialog_Style);
setModal(true);
this.useFont = useFont;
this.useColor = useColor;
public void setStartFont(Font font) {
if (!useFont)
- throw new RuntimeException("Dialog is not configured with font support");
+ throw new RuntimeException("Dialog is not configured with font support"); //$NON-NLS-1$
fontChooser.setCurrentFont(font);
}
public void setStartColor(Color color) {
if (!useColor)
- throw new RuntimeException("Dialog is not configured with color support");
+ throw new RuntimeException("Dialog is not configured with color support"); //$NON-NLS-1$
colorChooser.setColor(color);
}
public void setStartFormat(MetricsFormat format) {
if (!useFormat)
- throw new RuntimeException("Dialog is not configured with format support");
+ throw new RuntimeException("Dialog is not configured with format support"); //$NON-NLS-1$
metricsEditor.setMetricsFormat(format);
}
private void createContents() {
-
+
JTabbedPane tabbedPane = new JTabbedPane();
- getContentPane().add(tabbedPane,BorderLayout.CENTER);
+ getContentPane().add(tabbedPane, BorderLayout.CENTER);
if (useFont)
- tabbedPane.addTab("Font", fontChooser = new FontChooser("Sample text"));
+ tabbedPane.addTab(Messages.AWTStyleDialog_Font,
+ fontChooser = new FontChooser(Messages.AWTStyleDialog_SampleText));
if (useColor)
- tabbedPane.addTab("Color",colorChooser = new JColorChooser(new Color(0, 0, 0)));
+ tabbedPane.addTab(Messages.AWTStyleDialog_Color, colorChooser = new JColorChooser(new Color(0, 0, 0)));
if (useFormat)
- tabbedPane.addTab("Metrics",metricsEditor = new MetricsEditor());
-
+ tabbedPane.addTab(Messages.AWTStyleDialog_Metrics, metricsEditor = new MetricsEditor());
+
JPanel controlPanel = new JPanel();
- getContentPane().add(controlPanel,BorderLayout.SOUTH);
+ getContentPane().add(controlPanel, BorderLayout.SOUTH);
controlPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
-
- JButton okButton = new JButton("OK");
+
+ JButton okButton = new JButton(IDialogConstants.OK_LABEL);
controlPanel.add(okButton);
okButton.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
cancelled = false;
AWTStyleDialog.this.dispose();
}
});
-
- JButton cancelButton = new JButton("Cancel");
+
+ JButton cancelButton = new JButton(IDialogConstants.CANCEL_LABEL);
controlPanel.add(cancelButton);
cancelButton.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
AWTStyleDialog.this.setVisible(false);
AWTStyleDialog.this.dispose();
}
});
-
-
+
this.addWindowListener(new WindowListener() {
-
+
@Override
public void windowOpened(WindowEvent arg0) {}
-
+
@Override
public void windowIconified(WindowEvent arg0) {}
-
+
@Override
public void windowDeiconified(WindowEvent arg0) {}
-
+
@Override
public void windowDeactivated(WindowEvent arg0) {}
-
+
@Override
public void windowClosing(WindowEvent arg0) {
if (metricsEditor != null)
metricsEditor.dispose();
}
-
+
@Override
public void windowClosed(WindowEvent arg0) {}
-
+
@Override
public void windowActivated(WindowEvent arg0) {}
});