return;
}
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof Column) {
final Column column = (Column) userObject;
int button = e.getButton();
if (button == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
// double click = toggle column
toggleColumn(column);
} else if (button == MouseEvent.BUTTON2 || button == MouseEvent.BUTTON3) {
// right click = open popup menu
final JMenuItem toggleColumnItem = WidgetFactory.createMenuItem(null,
"images/actions/toggle-source-column.png");
if (_analysisJobBuilder.containsSourceColumn(column)) {
toggleColumnItem.setText("Remove column from source");
} else {
toggleColumnItem.setText("Add column to source");
}
toggleColumnItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
toggleColumn(column);
}
});
final JMenuItem createDictionaryItem = WidgetFactory.createMenuItem("Create dictionary from column",
"images/model/dictionary.png");
createDictionaryItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String datastoreName = _analysisJobBuilder.getDataContextProvider().getDatastore().getName();
DatastoreDictionary dictionary = new DatastoreDictionary(column.getName(), datastoreName, column
.getQualifiedLabel());
Injector injector = _injectorBuilder.with(DatastoreDictionary.class, dictionary).createInjector();
DatastoreDictionaryDialog dialog = injector.getInstance(DatastoreDictionaryDialog.class);
dialog.setVisible(true);
}
});
final JMenuItem quickAnalysisMenuItem = WidgetFactory.createMenuItem("Quick analysis",
"images/component-types/analyzer.png");
Injector injector = _injectorBuilder.with(Column[].class, new Column[] { column }).with(Table.class, null)
.createInjector();
QuickAnalysisActionListener quickAnalysisActionListener = injector
.getInstance(QuickAnalysisActionListener.class);
quickAnalysisMenuItem.addActionListener(quickAnalysisActionListener);
final JMenuItem previewMenuItem = WidgetFactory.createMenuItem("Preview column",
"images/actions/preview_data.png");
previewMenuItem.addActionListener(new PreviewSourceDataActionListener(_schemaTree.getWindowContext(),
_analysisJobBuilder.getDataContextProvider(), column));
final JPopupMenu popup = new JPopupMenu();
popup.setLabel(column.getName());
popup.add(toggleColumnItem);
popup.add(createDictionaryItem);
popup.add(quickAnalysisMenuItem);
popup.add(previewMenuItem);
popup.show((Component) e.getSource(), e.getX(), e.getY());