return;
handlePositionsUpdate();
}
});
final ActionManager actionManager = r.getContext().getActionManager();
tablePositions.setModel(getPositionsModel());
PositionsTableColumnModel tableColumnModel = new PositionsTableColumnModel();
tablePositions.setColumnModel(tableColumnModel);
tablePositions.registerKeyboardAction(new FrameAction() {
public void run() {
actionManager.run("delete");
}
}, getKeyStroke(VK_DELETE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tablePositions.registerKeyboardAction(new FrameAction() {
public void run() {
selectAndScrollToPosition(tablePositions, 0, 0);
}
}, getKeyStroke(VK_HOME, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tablePositions.registerKeyboardAction(new FrameAction() {
public void run() {
selectAndScrollToPosition(tablePositions, 0, tablePositions.getSelectedRow());
}
}, getKeyStroke(VK_HOME, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tablePositions.registerKeyboardAction(new FrameAction() {
public void run() {
int lastRow = tablePositions.getRowCount() - 1;
selectAndScrollToPosition(tablePositions, lastRow, lastRow);
}
}, getKeyStroke(VK_END, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tablePositions.registerKeyboardAction(new FrameAction() {
public void run() {
selectAndScrollToPosition(tablePositions, tablePositions.getRowCount() - 1, tablePositions.getSelectedRow());
}
}, getKeyStroke(VK_END, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tablePositions.setDragEnabled(true);
tablePositions.setDropMode(ON);
TableDragAndDropHandler dropHandler = new TableDragAndDropHandler(new PanelDropHandler());
tablePositions.setTransferHandler(dropHandler);
getPositionsModel().addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if (!isFirstToLastRow(e))
return;
if (getPositionsModel().isContinousRange())
return;
handlePositionsUpdate();
}
});
JMenuBar menuBar = Application.getInstance().getContext().getMenuBar();
tableHeaderMenu = new TableHeaderMenu(tablePositions.getTableHeader(), menuBar, getPositionsModel(),
tableColumnModel, actionManager);
JPopupMenu menu = new TablePopupMenu(tablePositions).createPopupMenu();
JMenu mergeMenu = (JMenu) findMenuComponent(menu, "merge-positionlist");
new MergePositionListMenu(mergeMenu, getPositionsView(), getFormatAndRoutesModel());
ClipboardInteractor clipboardInteractor = new ClipboardInteractor();
clipboardInteractor.watchClipboard();
actionManager.register("undo", new UndoAction());
actionManager.register("redo", new RedoAction());
actionManager.register("copy", new CopyAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
actionManager.register("cut", new CutAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
actionManager.register("delete", new DeleteAction(getPositionsView(), getPositionsModel()));
actionManager.register("new-position", new AddPositionAction(getPositionsView(), getPositionsModel(), getPositionsSelectionModel()));
actionManager.register("new-file", new NewFileAction(this));
actionManager.register("open", new OpenAction(this));
actionManager.register("paste", new PasteAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
actionManager.register("save", new SaveAction(this));
actionManager.register("save-as", new SaveAsAction(this));
actionManager.register("select-all", new SelectAllAction(getPositionsView()));
actionManager.register("new-positionlist", new AddPositionListAction(getFormatAndRoutesModel()));
actionManager.register("rename-positionlist", new RenamePositionListAction(getFormatAndRoutesModel()));
actionManager.register("delete-positionlist", new RemovePositionListAction(getFormatAndRoutesModel()));
actionManager.register("add-coordinates", new AddCoordinatesToPositionsAction());
actionManager.register("add-elevation", new AddElevationToPositionsAction());
actionManager.register("add-postal-address", new AddPostalAddressToPositionsAction());
actionManager.register("add-populated-place", new AddPopulatedPlaceToPositionsAction());
actionManager.register("add-speed", new AddSpeedToPositionsAction());
actionManager.register("add-time", new AddTimeToPositionsAction());
actionManager.register("add-number", new AddNumberToPositionsAction());
actionManager.register("split-positionlist", new SplitPositionListAction(tablePositions, getPositionsModel(), formatAndRoutesModel));
actionManager.register("import-positionlist", new ImportPositionListAction(this));
actionManager.register("export-positionlist", new ExportPositionListAction(this));
registerKeyStroke(tablePositions, "copy");
registerKeyStroke(tablePositions, "cut");
registerKeyStroke(tablePositions, "paste");
formatAndRoutesModel.addModifiedListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
actionManager.enable("save", formatAndRoutesModel.isModified() &&
formatAndRoutesModel.getFormat() != null &&
formatAndRoutesModel.getFormat().isSupportsWriting());
}
});