}
// If there are conflicts, solve them...
if (!clm.resolved()) {
if (JSynoptic.gui != null) {
conflictsOK = false;
final JList list = new JList(clm);
list.setCellRenderer(new ConflictListCellRenderer());
JButton changeSourceAlias;
JPanel treePane = new JPanel(new BorderLayout());
final SourceTree st = SourceTree.getFromPool("PropertiesPanel0");
treePane.add(new JScrollPane(st), BorderLayout.CENTER);
JPanel bpanel = new JPanel(new GridLayout(1, 1));
bpanel.add(changeSourceAlias = new JButton(resources.getString("changeSourceAlias")));
treePane.add(bpanel, BorderLayout.SOUTH);
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(list), treePane);
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