list.setVisibleRowCount(10);
JPanel bbox = new JPanel(new FlowLayout());
final JButton bok;
bbox.add(bok = new JButton("OK"));
// bbox.add(bcancel = new JButton("Cancel"));
final JDialog dialog = new JDialog(JSynoptic.gui.getOwner(), resources
.getString("conflictResolutionDialog"), true);
dialog.getContentPane().add(pane, BorderLayout.CENTER);
dialog.getContentPane().add(bbox, BorderLayout.SOUTH);
bok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
conflictsOK = true;
dialog.setVisible(false);
}
});
/*
* bcancel.addActionListener(new ActionListener() { public void
* actionPerformed(ActionEvent e) { conflictsOK = false;
* dialog.hide(); } });
*/
changeSourceAlias.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object o = st.getSelectedSourceOrCollection();
if (!(o instanceof DataSource)) {
return;
}
VariableConflict vc = (VariableConflict) list.getSelectedValue();
((DataSource) o).getInformation().alias = vc.var;
list.repaint();
if (clm.resolved()) {
bok.setEnabled(true);
}
TreeNode tn = (TreeNode) (st.getSelectionPath().getLastPathComponent());
((DefaultTreeModel) (st.getModel())).nodeChanged(tn);
}
});
st.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object o = st.getSelectedSourceOrCollection();
if ((o instanceof DataSource) && e.isAddedPath()) {
VariableConflict vc = (VariableConflict) list.getSelectedValue();
vc.ds = (DataSource) o;
list.repaint();
if (clm.resolved()) {
bok.setEnabled(true);
}
TreeNode tn = (TreeNode) (st.getSelectionPath().getLastPathComponent());
((DefaultTreeModel) (st.getModel())).nodeChanged(tn);
}
}
});
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Object sel = list.getSelectedValue();
if (sel == null) {
return;
}
st.setSelectedValue(((VariableConflict) sel).ds); // call
// the
// tree
// selection
// listener
// in
// turn
}
});
list.setSelectedIndex(0);
bok.setEnabled(false);
dialog.pack();
dialog.setVisible(true);
if (!conflictsOK) {
return null; // cancel => do not create the source
}
}
}