javax.swing.undo.UndoableEditSupport Java Examples
The following examples show how to use
javax.swing.undo.UndoableEditSupport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XDMModel.java From netbeans with Apache License 2.0 | 5 votes |
/** * @param ms requires an instance of org.netbeans.editor.BaseDocument to be * available in the lookup; */ public XDMModel(ModelSource ms) { source = ms; // assert getSwingDocument() != null; // It can be null, for example if the file is deleted. ues = new UndoableEditSupport(this); pcs = new PropertyChangeSupport(this); parser = new XMLSyntaxParser(); setStatus(Status.UNPARSED); //establish a default element identification mechanism //domain models should override this by invoking "setElementIdentity" ElementIdentity eID = createElementIdentity(); setElementIdentity(eID); }
Example #2
Source File: UndoManagerImpl.java From ganttproject with GNU General Public License v3.0 | 5 votes |
public UndoManagerImpl(IGanttProject project, ParserFactory parserFactory, DocumentManager documentManager) { myProject = project; myParserFactory = parserFactory; myDocumentManager = documentManager; mySwingUndoManager = new UndoManager(); myUndoEventDispatcher = new UndoableEditSupport(); GanttLanguage.getInstance().addListener(new GanttLanguage.Listener() { public void languageChanged(Event event) { UIManager.getDefaults().put("AbstractUndoableEdit.undoText", GanttLanguage.getInstance().getText("undo")); UIManager.getDefaults().put("AbstractUndoableEdit.redoText", GanttLanguage.getInstance().getText("redo")); } }); }
Example #3
Source File: JarTreeDialog.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Constructor. * * @param owner the owner frame * @param root the root directory */ public JarTreeDialog(Frame owner, File root) { super(owner, true); rootFile = root; createGUI(); // set up the undo system undoManager = new UndoManager(); undoSupport = new UndoableEditSupport(); undoSupport.addUndoableEditListener(undoManager); CheckTreeSelectionModel checkModel = checkManager.getSelectionModel(); checkModel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if(ignoreEvents) { return; } TreePath[] prev = (TreePath[]) e.getOldValue(); TreePath[] curr = (TreePath[]) e.getNewValue(); TreePath path = jarTree.getSelectionPath(); int row = jarTree.getRowForPath(path); SelectionEdit edit = new SelectionEdit(prev, prevRow, curr, row); undoSupport.postEdit(edit); prevRow = row; refresh(); } }); refresh(); // center on screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (dim.width-getBounds().width)/2; int y = (dim.height-getBounds().height)/2; setLocation(x, y); }
Example #4
Source File: PencilControl.java From tracker with GNU General Public License v3.0 | 4 votes |
/** * Constructs a PencilControl for a specified PencilDrawer. * * @param pencilDrawer the PencilDrawer */ protected PencilControl(PencilDrawer pencilDrawer) { super(JOptionPane.getFrameForComponent(pencilDrawer.trackerPanel), false); drawer = pencilDrawer; trackerPanel = drawer.trackerPanel; // set up the undo system undoManager = new UndoManager(); undoSupport = new UndoableEditSupport(); undoSupport.addUndoableEditListener(undoManager); createGUI(); refreshGUI(); pack(); // center on screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (dim.width - getBounds().width) / 2; int y = (dim.height - getBounds().height) / 2; setLocation(x, y); // create PropertyChangeListeners stepListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { // if selected scene is visible at current frame, do nothing if (selectedScene!=null && selectedScene.includesFrame(trackerPanel.getFrameNumber())) return; if (isVisible()) { setSelectedScene(drawer.getSceneAtFrame(trackerPanel.getFrameNumber())); refreshGUI(); } } }; trackerPanel.addPropertyChangeListener("stepnumber", stepListener); //$NON-NLS-1$ tabListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { if (e.getNewValue() == trackerPanel) { setVisible(isVisible); } else { boolean vis = isVisible; setVisible(false); isVisible = vis; } } }; TFrame frame = trackerPanel.getTFrame(); if (frame != null) { frame.addPropertyChangeListener("tab", tabListener); //$NON-NLS-1$ } clipListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { // stepcount has changed refreshGUI(); } }; trackerPanel.addPropertyChangeListener("stepcount", clipListener); //$NON-NLS-1$ }
Example #5
Source File: Launcher.java From osp with GNU General Public License v3.0 | 4 votes |
/** * Sets the look and feel. * * @param lf OSPRuntime name of look and feel * @param always true to set LnF even if already set * @return a new Launcher */ protected Launcher setLookAndFeel(final String lf, final boolean always) { if(lf==null) { return null; } lookAndFeel = lf; boolean newDecorations = true; boolean currentDecorations = JFrame.isDefaultLookAndFeelDecorated(); if(lf.equals(OSPRuntime.SYSTEM_LF)) { systemLFItem.setSelected(true); } else if(lf.equals(OSPRuntime.CROSS_PLATFORM_LF)) { javaLFItem.setSelected(true); } else if(lf.equals(OSPRuntime.DEFAULT_LF)) { newDecorations = OSPRuntime.DEFAULT_LOOK_AND_FEEL_DECORATIONS; defaultLFItem.setSelected(true); } else if(genericLFGroup.getSelection()!=null) { genericLFGroup.remove(systemLFItem); genericLFGroup.remove(javaLFItem); genericLFGroup.remove(defaultLFItem); systemLFItem.setSelected(false); javaLFItem.setSelected(false); defaultLFItem.setSelected(false); genericLFGroup.add(systemLFItem); genericLFGroup.add(javaLFItem); genericLFGroup.add(defaultLFItem); } Object lfType = OSPRuntime.LOOK_AND_FEEL_TYPES.get(lf); LookAndFeel currentLF = UIManager.getLookAndFeel(); if(!always&&(newDecorations==currentDecorations)&¤tLF.getClass().getName().equals(lfType)) { return null; } if(!isVisible()) { frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { setLookAndFeel(lf, always); frame.removeWindowListener(this); } }); return null; } OSPRuntime.setLookAndFeel(newDecorations, lf); if(spawner!=null) { spawner = spawner.setLookAndFeel(lf, true); } exitCurrentApps(); LauncherUndo undoManager = Launcher.this.undoManager; UndoableEditSupport undoSupport = Launcher.this.undoSupport; LaunchNode node = Launcher.this.getSelectedNode(); Point loc = Launcher.this.frame.getLocation(); Launcher.this.frame.dispose(); Launcher launcher; LaunchSet tabset = new LaunchSet(Launcher.this, tabSetName); XMLControlElement control = new XMLControlElement(tabset); // set null password so LaunchBuilder opens without verification control.setPassword(null); if(Launcher.this instanceof LaunchBuilder) { launcher = new LaunchBuilder(control.toXML()); } else { launcher = new Launcher(control.toXML()); } launcher.setSelectedNode(node.getPathString()); undoManager.setLauncher(launcher); launcher.undoManager = undoManager; launcher.undoSupport = undoSupport; launcher.tabSetName = tabSetName; launcher.password = password; launcher.spawner = spawner; launcher.jarBasePath = jarBasePath; launcher.frame.setDefaultCloseOperation(Launcher.this.frame.getDefaultCloseOperation()); launcher.refreshGUI(); launcher.frame.setLocation(loc); launcher.setVisible(true); launcher.frame.pack(); SwingUtilities.updateComponentTreeUI(OSPLog.getOSPLog()); return launcher; }