// JSYnoptic formater
lformatdigits = new JLabel(resources.getString("DecimalDigits:"));
nfformat = new NumberField(0, 3);
nfformat.setColumns(10);
nfformat.setHorizontalAlignment(SwingConstants.RIGHT);
GridBagPanel digitsPanel = new GridBagPanel();
digitsPanel.addOnCurrentRow(lformatdigits);
digitsPanel.addOnCurrentRow(nfformat);
digitsPanel.carriageReturn();
cards.add(digitsPanel, "jsynopticFormat");
// Printf Formater
GridBagPanel printfPanel = new GridBagPanel();
lPrintfFormat = new JLabel(resources.getString("PrintfFormat"));
tfPrintfFormat = new JTextField(10);
printfPanel.addOnCurrentRow(lPrintfFormat);
printfPanel.addOnCurrentRow(tfPrintfFormat);
printfPanel.carriageReturn();
cards.add(printfPanel, "printfFormat");
cards.add(new GridBagPanel(), "noAttributes");
// Mapper
cbxmapper = new JComboBox();
cbxmapper.addItem(resources.getString("=======NONE======="));
int idx = 0;
if (TextMapper.textMappers != null) {
for (int i = 0; i < TextMapper.textMappers.size(); ++i) {
TextMapper tm = (TextMapper) TextMapper.textMappers.get(i);
if (tm.equals(mapper)) {
idx = i + 1;
}
cbxmapper.addItem(tm);
}
}
cbxmapper.setEditable(false);
cbxmapper.setSelectedIndex(idx);
beditmapper = new JButton(resources.getString("Edit"));
bnewmapper = new JButton(resources.getString("New"));
bdelmapper = new JButton(resources.getString("Delete"));
bduplicateMapper = new JButton(resources.getString("Duplicate"));
if (idx == 0) {
beditmapper.setEnabled(false);
bdelmapper.setEnabled(false);
bduplicateMapper.setEnabled(false);
}
cbxmapper.setRenderer(new ListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
String s = value.toString();
if (s.length() > 18) {
s = s.substring(0, 15) + "...";
}
return new JLabel(s);
}
});
beditmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mapper == null) {
return;
}
mapper.editDialog(TextPropertiesPanel.this.getOwner());
cbxmapper.repaint(); // in case of name change
}
});
bnewmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapper = TextMapper.createTextMapperDialog(TextPropertiesPanel.this.getOwner());
if (TextMapper.textMappers == null) {
TextMapper.textMappers = new Vector();
}
TextMapper.textMappers.add(mapper);
cbxmapper.addItem(mapper);
cbxmapper.setSelectedItem(mapper);
cards.revalidate();
}
});
bdelmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mapper == null) {
return;
}
if (TextMapper.textMappers != null) {
TextMapper.textMappers.remove(mapper);
}
cbxmapper.removeItem(mapper);
cbxmapper.setSelectedIndex(0);
mapper = null;
bdelmapper.setEnabled(false);
bduplicateMapper.setEnabled(false);
beditmapper.setEnabled(false);
}
});
bduplicateMapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mapper == null) {
return;
}
try {
TextMapper tm = (TextMapper)((TextMapper)mapper).clone();
if (TextMapper.textMappers != null) {
TextMapper.textMappers.add(tm);
}
mapper = tm;
cbxmapper.addItem(mapper);
cbxmapper.setSelectedItem(mapper);
}catch (CloneNotSupportedException cnse){
}
}
});
cbxmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int idx = cbxmapper.getSelectedIndex();
if (idx == 0) {
beditmapper.setEnabled(false);
bdelmapper.setEnabled(false);
bduplicateMapper.setEnabled(false);
mapper = null;
} else {
mapper = (TextMapper) cbxmapper.getItemAt(idx);
beditmapper.setEnabled(true);
bdelmapper.setEnabled(true);
bduplicateMapper.setEnabled(true);
}
}
});
GridBagPanel mapperPanel = new GridBagPanel();
mapperPanel.addOnCurrentRow(cbxmapper, 2);
mapperPanel.addOnCurrentRow(beditmapper);
mapperPanel.addOnCurrentRow(bnewmapper);
mapperPanel.addOnCurrentRow(bdelmapper);
mapperPanel.addOnCurrentRow(bduplicateMapper);
mapperPanel.carriageReturn();
cards.add(mapperPanel, "mapper");
CardLayout cl = (CardLayout) (cards.getLayout());
if (cbxformat.getSelectedIndex() == TextShape.FORMAT_MAPPER) {
cl.show(cards, "mapper");
} else {