private void createPopup() {
popupMenu = new JPopupMenu();
/* show columns list */
ArrayList cols = ttModel.getColumns();
ResourceColumn col;
int size = cols.size();
for (int i =0; i < size; i++) {
col = (ResourceColumn)cols.get(i);
JCheckBoxMenuItem item = new JCheckBoxMenuItem(col.getTitle(), col.isVisible());
item.addActionListener(new ColumnHandler(col));
popupMenu.add(item);
}
popupMenu.addSeparator();
/* 'display all columns' button*/
JMenuItem showAllItem = new JMenuItem(language.getText("displayAll"));
showAllItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/* TODO the undo management */
Mediator.getGanttProjectSingleton().getUndoManager()
.undoableEdit("displayAllColumns", new Runnable() {
public void run() {
/* sets all the columns visible */
ArrayList cols = ttModel.getColumns();
for (int i =0; i < cols.size(); i++) {
ResourceColumn col = (ResourceColumn)cols.get(i);
if (!col.isVisible()) {
showColumn(col);
}
}
getProject().setModified(true);
}
});
}
});
popupMenu.add(showAllItem);
popupMenu.addSeparator();
/* 'add new column' button */
JMenuItem addColumnItem = new JMenuItem(language.getText("addCustomColumn"));
addColumnItem.setIcon(new ImageIcon(getClass().getResource("/icons/addCol_16.gif")));
addColumnItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
/* TODO the undo management */
Mediator.getGanttProjectSingleton().getUndoManager()
.undoableEdit("addCustomColumn", new Runnable() {
public void run() {
ResourceColumn column = null;
addCustomColumn(column);
getProject().setModified();
}
});
}