Package javax.swing.event

Examples of javax.swing.event.UndoableEditEvent


        UEListener listener3 = new UEListener("3");
        ues1.addUndoableEditListener(listener1);
        ues1.addUndoableEditListener(listener2);
        ues1.addUndoableEditListener(listener3);
        UndoableEdit ue = new CompoundEdit();
        UndoableEditEvent uee = new UndoableEditEvent(ues1.realSource, ue);
        ues1._postEdit(ue);
        assertEquals("123", fireOrder);
        checkEvent(uee, listener1.event);
        checkEvent(uee, listener2.event);
        checkEvent(uee, listener3.event);
View Full Code Here


            assertEquals(0, ues1.compoundEdit.edits.size());
        }
        ues1.compoundEdit = ce;
        for (int i = 0; i < 10; i++) {
            CompoundEdit ce1 = ues1.compoundEdit;
            UndoableEditEvent uee = new UndoableEditEvent(ues1.realSource, ce1);
            resetDbgInfo(ce, ues1);
            ues1.endUpdate();
            assertEquals(4 - i, ues1.updateLevel);
            if (ues1.updateLevel == 0) {
                assertTrue(ues1.wasCallPostEdit);
View Full Code Here

            return null;
        }
    };

    public void testFireUndoableEditUpdate() {
        UndoableEditEvent undoEvent = new UndoableEditEvent(doc, new AbstractUndoableEdit());
        doc.addUndoableEditListener(this);
        doc.fireUndoableEditUpdate(undoEvent);
        checkCalledEvents(false, false, false, true);
        assertSame(undoEvent, undo);
    }
View Full Code Here

        newTriangle.addToObjects(objects);
        clearAndHide();
        step.setOutputs(new Object[]
             {newTriangle.getSides()[0], newTriangle.getSides()[1],
              newTriangle.getSides()[2], newTriangle});
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Please select three distinct"+
              " non-collinear points", "Try Again", JOptionPane.ERROR_MESSAGE);
        initDialog();
      }
    }
    else if (step.getConstructionType() == POINT_LINE) {
      Point P1 = (Point)step.getInputs()[0];
      Line L1 = (Line)step.getInputs()[1];
      if (!(P1.canIntersect(L1))) {
        Triangle newTriangle = new Triangle(P1, L1);
        newTriangle.addToObjects(objects);
        clearAndHide();
        step.setOutputs(new Object[]
          {newTriangle.getSides()[1], newTriangle.getSides()[2], newTriangle});
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Please select a point that does "+
              "not lie on the line", "Try Again", JOptionPane.ERROR_MESSAGE);
        initDialog();
View Full Code Here

  }

  public abstract void initDialog();
 
  protected void constructionCancelled() {
    fireUndoableEditUpdate(new UndoableEditEvent(this, null));
  }
View Full Code Here

      Point newPoint = new Point(((Double)step.getInputs()[0]).doubleValue(),
                        ((Double)step.getInputs()[1]).doubleValue());
      newPoint.addToObjects(objects);
      clearAndHide();
      step.setOutputs(new Object[]{newPoint});
      fireUndoableEditUpdate(new UndoableEditEvent(this, step));
    }
    else {
      System.err.println("Bad construction type");
    }
  }
View Full Code Here

            Triangle newTriangle = new Triangle(ptOppSelSide, newSide);
            newTriangle.addToObjects(objects);
            clearAndHide();
            step.setOutputs(new Object[]{ptOppSelSide, newTriangle.getSides()[1],
                        newTriangle.getSides()[2], newTriangle});
            fireUndoableEditUpdate(new UndoableEditEvent(this, step));
            return;
          }
        }
        ptOppSelSide.move(new Point(), angleOfRotation, centreOfRotation);
        Triangle newTriangle = new Triangle(ptOppSelSide, newSide);
        newTriangle.addToObjects(objects);
        clearAndHide();
        step.setOutputs(new Object[]{ptOppSelSide, newTriangle.getSides()[1],
                    newTriangle.getSides()[2], newTriangle});
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Lengths of old & new sides must be equal",
                        "Try Again", JOptionPane.ERROR_MESSAGE);
        initDialog();
View Full Code Here

        ((Line)obj2).addPropertyChangeListener(Line.PROP_ANGLE, newLine);
        newLine.addPropertyChangeListener(Line.PROP_ANGLE, (Line)obj2);
      }       
      clearAndHide();
      step.setOutputs(new Object[]{newLine.getEnd(), newLine});
      fireUndoableEditUpdate(new UndoableEditEvent(this, step));
    }
    else if (step.getConstructionType() == TWO_POINTS) {
      Point p1 = (Point)step.getInputs()[0];
      Point p2 = (Point)step.getInputs()[1];
      if (!p1.equalTo(p2)) {
        Line newLine = new Line(p1, p2);
        newLine.addToObjects(objects);
        clearAndHide();
        step.setOutputs(new Object[]{newLine});
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Please select two different points",
                                  "Try Again", JOptionPane.ERROR_MESSAGE);
        initDialog();
View Full Code Here

        step.getInputs()[4] = fixedPoint;
      }
      o.move(translation, rotation, fixedPoint);
      clearAndHide();
      step.setOutputs(new Object[]{o});
      fireUndoableEditUpdate(new UndoableEditEvent(this, step));
    }
    else
      System.err.println("Bad construction type");
  }
View Full Code Here

      }
    }
    double[] b = fractal.getCoordinates();
    if (ke.getKeyCode() == KeyEvent.VK_DOWN) {
      fractal.translate(0.0, fractal.getCoordinateHeight()/10);
      undoManager.undoableEditHappened(new UndoableEditEvent(fractal, new UndoablePan(fractal, b, fractal.getCoordinates())));
    } else if (ke.getKeyCode() == KeyEvent.VK_UP) {
      fractal.translate(0.0, -fractal.getCoordinateHeight()/10);
      undoManager.undoableEditHappened(new UndoableEditEvent(fractal, new UndoablePan(fractal, b, fractal.getCoordinates())));
    } if (ke.getKeyCode() == KeyEvent.VK_LEFT) {
      fractal.translate(-fractal.getCoordinateWidth()/10, 0.0);
      undoManager.undoableEditHappened(new UndoableEditEvent(fractal, new UndoablePan(fractal, b, fractal.getCoordinates())));
    } if (ke.getKeyCode() == KeyEvent.VK_RIGHT) {
      fractal.translate(fractal.getCoordinateWidth()/10, 0.0);
      undoManager.undoableEditHappened(new UndoableEditEvent(fractal, new UndoablePan(fractal, b, fractal.getCoordinates())));
    }
    updateUndo();
  }
View Full Code Here

TOP

Related Classes of javax.swing.event.UndoableEditEvent

Copyright © 2018 www.massapicom. 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.