Is there ever a time when you're not viewing who's online?
private UndoManagerTeam undoManageTeam = new UndoManagerTeam();
private UndoAction undoActionObj = new UndoAction();
private RedoAction redoActionObj = new RedoAction();
private JMenuItem undoItem;
private JMenuItem redoItem;
private class UndoManagerTeam {
private ArrayList<UndoManager> undoManageTeam =
new ArrayList<UndoManager>();
private void addManager() {
undoManageTeam.add(new UndoManager());
}
private void removeManager(int index) {
undoManageTeam.remove(index);
}
private UndoManager getCurrentManager() {
int currentIndex = tabManageObj.getCurrentTabIndex();
return undoManageTeam.get(currentIndex);
}
}
private class CustomUndoableEditListener implements UndoableEditListener {
@Override
public void undoableEditHappened(UndoableEditEvent event) {
undoManageTeam.getCurrentManager().addEdit(event.getEdit());
}
}
private class UndoAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent event) {
try {
UndoManager currentManager = undoManageTeam.getCurrentManager();
if (currentManager.canUndo())
currentManager.undo();
} catch (CannotUndoException exceptionInfo) {
//Ignore the exception.
}
}
}
private class RedoAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent event) {
try {
UndoManager currentManager = undoManageTeam.getCurrentManager();
if (currentManager.canRedo())
currentManager.redo();
} catch (CannotRedoException exceptionInfo) {
//Ignore the exception.
}
}
}
private ArrayList<CustomUndoableEditListener> editListeners =
new ArrayList<CustomUndoableEditListener>();
private void addTab() {
JScrollPane newScrollPane = new JScrollPane();
JTextPane newTextPane = new JTextPane();
newScrollPane.setViewportView(newTextPane);
textPaneList.add(newTextPane);
tabList.add(newScrollPane);
mainTabbedPane.addTab("New File",newScrollPane);
filesBeingEdited.add("");
undoManageTeam.addManager();
editListeners.add(new [COLOR="Red"][B]CustomUndoableEditListener[/B][/COLOR]());
addPropertiesToTextPane(newTextPane);
switchToLastTab();
}