Examples of UndoManager


Examples of javax.swing.undo.UndoManager

   
    doc=new PlainDocument();
    createTextArea();
    port.add(ui);
   
    undoHandler = new UndoHandler(new UndoManager());
    doc.addUndoableEditListener(undoHandler);
    ui.addCaretListener(this);
    setupActions();

    JMenuBar mb = new JMenuBar();
View Full Code Here

Examples of javax.swing.undo.UndoManager

        _popup=null;
        _action=null;

        _listenerList = new EventListenerList();
        _undoManager = new UndoManager();
        _undoHandler = new UndoHandler(_undoManager);
        _compoundEdit = new CompoundEdit();

        setDiagramSize(_param.width, _param.height);
View Full Code Here

Examples of javax.swing.undo.UndoManager

    public Tree(UniversePool pool,Java3dPlugin plugin) {
        _pool = pool;
        _plugin=plugin;
        _clipBoard=new ClipBoard();
        _undoManager = new UndoManager();
        _undoHandler = new UndoHandler(_undoManager);

        _rootNode = new RootNode(this, null, false);
        _treeModel = new DefaultTreeModel(_rootNode);
        setModel(_treeModel);
View Full Code Here

Examples of javax.swing.undo.UndoManager

    public UndoManagerImpl(IGanttProject project, ParserFactory parserFactory,
            DocumentManager documentManager) {
        myProject = project;
        myParserFactory = parserFactory;
        myDocumentManager = documentManager;
        mySwingUndoManager = new UndoManager();
        myUndoEventDispatcher = new UndoableEditSupport();

    }
View Full Code Here

Examples of javax.swing.undo.UndoManager

      this.home.getCompass().setVisible(false);
      Locale.setDefault(Locale.FRANCE);
      this.preferences = new DefaultUserPreferences();
      ViewFactory viewFactory = new SwingViewFactory();
      UndoableEditSupport undoSupport = new UndoableEditSupport();
      final UndoManager undoManager = new UndoManager();
      undoSupport.addUndoableEditListener(undoManager);
      this.planController = new PlanController(this.home, this.preferences, viewFactory, null, undoSupport);
      // Add plan component to frame at its preferred size
      add(new JScrollPane((JComponent)this.planController.getView()));
      // Create a toggle button for plan component mode
      this.modeButton = new JToggleButton(new ImageIcon(
          getClass().getResource("resources/Add16.gif")));
      // Add listeners to modeButton that manages plan planController mode
      this.modeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
          if (modeButton.isSelected()) {
            planController.setMode(PlanController.Mode.WALL_CREATION);
          } else {
            planController.setMode(PlanController.Mode.SELECTION);
          }
        }
      });
      // Create an undo button
      this.undoButton = new JButton(new ImageIcon(
          getClass().getResource("resources/Undo16.gif")));
      this.undoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
          undoManager.undo();
        }
      });
      // Create a redo button
      this.redoButton = new JButton(new ImageIcon(
          getClass().getResource("resources/Redo16.gif")));
      this.redoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
          undoManager.redo();
        }
      });
      this.reverseDirectionButton = new JButton("Reverse");
      this.reverseDirectionButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
View Full Code Here

Examples of javax.swing.undo.UndoManager

              || edit.isSignificant()) {
            super._postEdit(edit);
          }
        }
      };
    this.undoManager = new UndoManager();
    this.undoSupport.addUndoableEditListener(this.undoManager);
   
    // Update recent homes list
    if (home.getName() != null) {
      List<String> recentHomes = new ArrayList<String>(this.preferences.getRecentHomes());
View Full Code Here

Examples of javax.swing.undo.UndoManager

    Home home = new Home();
    Locale.setDefault(Locale.FRANCE);
    UserPreferences preferences = new DefaultUserPreferences();
    ViewFactory viewFactory = new SwingViewFactory();
    UndoableEditSupport undoSupport = new UndoableEditSupport();
    UndoManager undoManager = new UndoManager();
    undoSupport.addUndoableEditListener(undoManager);
    PlanController planController =
        new PlanController(home, preferences, viewFactory, null, undoSupport);
   
    // Build an ordered list of walls added to home
    final ArrayList<Wall> orderedWalls = new ArrayList<Wall>();
    home.addWallsListener(new CollectionListener<Wall> () {
      public void collectionChanged(CollectionEvent<Wall> ev) {
        if (ev.getType() == CollectionEvent.Type.ADD) {
          orderedWalls.add(ev.getItem());
        }
      }
    });
   
    // 2. Use WALL_CREATION mode
    planController.setMode(PlanController.Mode.WALL_CREATION);
    // Click at (20, 20), (500, 22), (498, 300), then double click at (20, 302) in home coordinates space
    planController.moveMouse(20, 20);
    planController.pressMouse(20, 20, 1, false, false);
    planController.toggleMagnetism(false);
    planController.releaseMouse(20, 20);
    planController.moveMouse(500, 22);
    planController.pressMouse(500, 22, 1, false, false);
    planController.releaseMouse(500, 22);
    planController.moveMouse(498, 300);
    planController.pressMouse(498, 300, 1, false, false);
    planController.releaseMouse(498, 300);
    planController.moveMouse(20, 302);
    planController.pressMouse(20, 302, 1, false, false);
    planController.releaseMouse(20, 302);
    planController.pressMouse(20, 302, 2, false, false);
    planController.releaseMouse(20, 302);
    // Check 3 walls were created at (20, 20), (500, 20), (500, 300) and (20, 300) coordinates
    Wall wall1 = orderedWalls.get(0);
    assertCoordinatesEqualWallPoints(20, 20, 500, 20, wall1);
    Wall wall2 = orderedWalls.get(1);
    assertCoordinatesEqualWallPoints(500, 20, 500, 300, wall2);
    Wall wall3 = orderedWalls.get(2);
    assertCoordinatesEqualWallPoints(500, 300, 20, 300, wall3);
    // Check they are joined to each other end point
    assertWallsAreJoined(null, wall1, wall2);
    assertWallsAreJoined(wall1, wall2, wall3);
    assertWallsAreJoined(wall2, wall3, null);
    // Check they are selected
    assertSelectionContains(home, wall1, wall2, wall3);

    // 3. Click at (20, 300), then double click at (60, 60) with Alt key depressed
    planController.moveMouse(20, 300);
    planController.pressMouse(20, 300, 1, false, false);
    planController.releaseMouse(20, 300);
    planController.toggleMagnetism(true);
    planController.moveMouse(60, 60);
    planController.pressMouse(60, 60, 1, false, false);
    planController.releaseMouse(60, 60);
    planController.pressMouse(60, 60, 2, false, false);
    planController.releaseMouse(60, 60);
    planController.toggleMagnetism(false);
    // Check a forth wall was created at (20, 300), (60, 60) coordinates
    Wall wall4 = orderedWalls.get(orderedWalls.size() - 1);
    assertCoordinatesEqualWallPoints(20, 300, 60, 60, wall4);
    assertSelectionContains(home, wall4);
    assertWallsAreJoined(wall3, wall4, null);

    // 4. Use SELECTION mode
    planController.setMode(PlanController.Mode.SELECTION);
    // Check current mode is SELECTION
    assertEquals("Current mode isn't " + PlanController.Mode.SELECTION,
        PlanController.Mode.SELECTION, planController.getMode());
    // Press the delete key
    planController.deleteSelection();
    // Check plan contains only the first three walls
    assertHomeContains(home, wall1, wall2, wall3);
   
    // 5. Use WALL_CREATION mode
    planController.setMode(PlanController.Mode.WALL_CREATION);
    //  Click at (22, 18), then double click at (20, 300)
    planController.moveMouse(22, 18);
    planController.pressMouse(22, 18, 1, false, false);
    planController.releaseMouse(22, 18);
    planController.moveMouse(20, 300);
    planController.pressMouse(20, 300, 1, false, false);
    planController.releaseMouse(20, 300);
    planController.pressMouse(20, 300, 2, false, false);
    planController.releaseMouse(20, 300);
    // Check a new forth wall was created at (20, 20), (20, 300) coordinates
    wall4 = orderedWalls.get(orderedWalls.size() - 1);
    assertCoordinatesEqualWallPoints(20, 20, 20, 300, wall4);
    // Check its end points are joined to the first and third wall
    assertWallsAreJoined(wall1, wall4, wall3);
   
    // 6. Use SELECTION mode
    planController.setMode(PlanController.Mode.SELECTION);
    // Drag and drop cursor from (360, 160) to (560, 320)
    planController.moveMouse(360, 160);
    planController.pressMouse(360, 160, 1, false, false);
    planController.moveMouse(560, 320);
    planController.releaseMouse(560, 320);
    // Check the selected walls are the second and third ones
    assertSelectionContains(home, wall2, wall3);

    // 7. Press twice right arrow key    
    planController.moveSelection(2, 0);
    planController.moveSelection(2, 0);
    // Check the 4 walls coordinates are (20, 20), (504, 20), (504, 300), (24, 300)
    assertCoordinatesEqualWallPoints(20, 20, 504, 20, wall1);
    assertCoordinatesEqualWallPoints(504, 20, 504, 300, wall2);
    assertCoordinatesEqualWallPoints(504, 300, 24, 300, wall3);
    assertCoordinatesEqualWallPoints(20, 20, 24, 300, wall4);

    // 8. Click at (504, 40) with Shift key depressed
    planController.moveMouse(504, 40);
    planController.pressMouse(504, 40, 1, true, false);
    planController.releaseMouse(504, 40);
    // Check the second wall was removed from selection
    assertSelectionContains(home, wall3);

     // 9. Drag cursor from (60, 20) to (60, 60)
    planController.moveMouse(60, 20);
    planController.pressMouse(60, 20, 1, false, false);
    planController.moveMouse(60, 60);
    // Check first wall is selected and that it moved
    assertSelectionContains(home, wall1);
    assertCoordinatesEqualWallPoints(20, 60, 504, 60, wall1);
    // Lose focus
    planController.escape();
    // Check the wall didn't move at end
    assertCoordinatesEqualWallPoints(20, 20, 504, 20, wall1);

    // 10. Undo 8 times
    for (int i = 0; i < 6; i++) {
      undoManager.undo();
    }
    // Check home doesn't contain any wall
    assertHomeContains(home);
   
    // 11. Redo 8 times
    for (int i = 0; i < 6; i++) {
      undoManager.redo();
    }
    // Check plan contains the four wall
    assertHomeContains(home, wall1, wall2, wall3, wall4);
    // Check the second and the third wall are selected
    assertSelectionContains(home, wall2, wall3);
View Full Code Here

Examples of javax.swing.undo.UndoManager

            overlay.setPreferredSize(size);

//            // Useful for making icons out of screenshots:
//            overlay.setTransform(AffineTransform.getScaleInstance(4, 4));

            undo = new UndoManager() {
                public boolean addEdit(UndoableEdit edit) {
                    boolean result = super.addEdit(edit);
                    updateButtons();
                    return result;
                }
View Full Code Here

Examples of javax.swing.undo.UndoManager

    private UndoSupport undoSupport;

    public void guiSetUp() {
        source = new BasicEventList<String>();
        txSource = new TransactionList<String>(source);
        undoManager = new UndoManager();
        undoManager.setLimit(NUMBER_OF_UNDOS);
        undoSupport = UndoSupport.install(undoManager, txSource);
        System.out.println("UndoSupportTest.guiSetUp");
    }
View Full Code Here

Examples of javax.swing.undo.UndoManager

public class getLimit
  implements Testlet
{
  public void test(TestHarness harness)
  {
    UndoManager mgr = new UndoManager();

    // Check #1.
    harness.check(mgr.getLimit(), 100);

    // Check #2.
    mgr.setLimit(20);
    harness.check(mgr.getLimit(), 20);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.