Package javax.swing.undo

Examples of javax.swing.undo.CompoundEdit


    // Sort the indices in order to preserve the depth inside of the selection
    Arrays.sort(indices);

    Object tmp;
    int indice;
    CompoundEdit ce = new CompoundEdit();
    for(i=0; i<indices.length; i++) {
      indice=indices[i];
      tmp=this.elementAt(indice);
      this.removeElementAt(indice);
      this.insertElementAt(tmp, i);
      ce.addEdit(new DepthChangedEdit(this, indice, i));
    }
   
    ce.end();
    _comp.fireUndoableEditUpdate(new UndoableEditEvent(this, ce));
    _comp.repaint();
  }
View Full Code Here


    // Sort the indices in order to preserve the depth inside of the selection
    Arrays.sort(indices);
   
    Object tmp;
    int indice;
    CompoundEdit ce = new CompoundEdit();
    for(i=0; i<indices.length; i++) {
      indice=indices[i];
      if(indice > 0) {
        tmp=this.elementAt(indice);
        this.removeElementAt(indice);
        this.insertElementAt(tmp, indice-1);
        ce.addEdit(new DepthChangedEdit(this, indice, indice-1));
      }
    }
   
    ce.end();
    _comp.fireUndoableEditUpdate(new UndoableEditEvent(this, ce));
    _comp.repaint();
  }
View Full Code Here

    if (action==null) return;
   
    Object o = providers.get(jmi);
   
    if (o instanceof ContextualActionProvider) {
        CompoundEdit ce=new CompoundEdit();
       
        ContextualActionProvider provider = (ContextualActionProvider)o;
          provider.doAction(actionX, actionY, actionTarget, action, ce);
         
          ce.end();
          if (ce.isSignificant()) {
                ShapesContainer.ShapesComponent sc=JSynoptic.gui.getActiveComponent();
                sc.fireUndoableEditUpdate(new UndoableEditEvent(sc, ce));
            }

    }
View Full Code Here

    public boolean doAction(double x, double y, Object o, String action, CompoundEdit undoableEdit) {
        boolean res;

        if (action.equals(CircuitPlugin.resources.getString("setSource"))) {
            // Save old params
            CompoundEdit ce = new CompoundEdit();
            HashMap oldValues = new HashMap();
            oldValues.put("SWITCH_POSITION_SOURCE", switchPositionDs);

            addDataSource((DataSource)o);

            // Notify changes
            Iterator it = oldValues.keySet().iterator();
            while (it.hasNext()) {
                String n = (String) it.next();
                ce.addEdit(new PropertyChangeEdit(this, n, oldValues.get(n), getPropertyValue(n)));
            }
            ce.end();
            if (undoableEdit != null) {
                undoableEdit.addEdit(ce);
            }

            res =  true;
View Full Code Here

    /**
     * Deletes the selected shapes
     */
    public void deleteSelection(){
        CompoundEdit ce = new CompoundEdit();

        for(int i=0;i<_selectedElements.size();i++){
            ElementSelection ss = (ElementSelection)_selectedElements.get(i);
           
            Element as = ss.element;
            as.processShapeRemoving();
           
            ce.addEdit(new DeleteEdit((getElementContainer()), as));

            if (ss.element instanceof GatedComponent){
                GatedComponent gc = (GatedComponent)ss.element;

                List gates = gc.getGates();
                for(int k=0; k< gates.size(); k++){
                    Gate gate =  ((Gate)gates.get(k));
                    List connections = gate.getConnections();

                    for(int j=0; j< connections.size(); j++){
                        Connection connection = (Connection)connections.get(j);   
                        if (connection.isConnected(gate)){
                            ce.addEdit(new GateDisconnectEdit(connection, gate, connection.getFirstEndGate()!=null && connection.getFirstEndGate().equals(gate)));
                            connection.disconnect(gate);
                        }
                    }
                }
            }


            if (ss.element instanceof Connection){
                Connection gc = (Connection)ss.element;
                if (gc.getFirstEndGate() != null){
                    ce.addEdit(new GateDisconnectEdit(gc, gc.getFirstEndGate(), true));
                    gc.disconnect(gc.getFirstEndGate());
                }
                if (gc.getLastEndGate() != null){
                    ce.addEdit(new GateDisconnectEdit(gc, gc.getLastEndGate(), false));
                    gc.disconnect(gc.getLastEndGate());
                }
            }
            deleteShape(ss.element);
        }

        ce.end();
       
        DiagramComponent dc = getElementContainer().getComponent();
        dc.fireUndoableEditUpdate( new UndoableEditEvent(dc, ce));
       
        unselect();
View Full Code Here

    /* (non-Javadoc)
     * @see simtools.diagram.ShapeSelection#translateShapeEnd()
     */
    public UndoableEdit translateShapeEnd(){
        CompoundEdit ce = new CompoundEdit();

        ce.addEdit(super.translateShapeEnd());

        for(int i=0; i< connectionPathEdits.size(); i++) {
            ConnectionPathEdit cpe = (ConnectionPathEdit)connectionPathEdits.get(i);
            Connection c = cpe.connection;

            if (!ds.isSelected( (Shape)c)){
                // Update the connection pathes
                cpe.connection.getPath().updatePath();

                // Add  connection path edits to the returned coumpound edit
                cpe.pathHasChanged();
                ce.addEdit(cpe);
            }
        }

        ce.end();

        // Create new connection path edits
        createconnectionPathedits();
     
        return ce;
View Full Code Here

     * Aligns the selected shapes
     */
    public void alignSelection(){
        int depx=0;
        int depy=0;
        CompoundEdit ce = new CompoundEdit();

        for(int i=0;i<_selectedElements.size();i++){
            ElementSelection ss = (ElementSelection)_selectedElements.get(i);
            depx = gridPosition(ss.currentPoint.x) - ss.currentPoint.x;
            depy = gridPosition(ss.currentPoint.y) - ss.currentPoint.y;

            ss.translateShape(depx, depy);
            ce.addEdit(ss.translateShapeEnd());
        }

        ce.end();
       
        DiagramComponent dc = getElementContainer().getComponent();
        dc._compoundEdit.addEdit(ce);
    }
View Full Code Here

        if (_selectedElements.size() == 1) {
            ElementSelection selection = (ElementSelection) _selectedElements.get(0);
           
            if (selection.element!=null && selection.element instanceof Resizable) {
                CompoundEdit ce= new CompoundEdit();
          
                switch(way){
                case 1:
                case 5:
                    dx=0;
                    break;
                case 3:
                case 7:
                    dy=0;
                    break;
                }

                Rectangle oldBounds, newBounds;

                oldBounds = selection.element.getBounds();
                switch(way){
                case 1:
                    dtw=0;
                    dth=-depy;
                    break;
                case 2:
                    dtw=depx;
                    dth=-depy;
                    break;
                case 3:
                    dtw=depx;
                    dth=0;
                    break;
                case 4:
                    dtw=depx;
                    dth=depy;
                    break;
                case 5:
                    dtw=0;
                    dth=depy;
                    break;
                case 6:
                    dtw=-depx;
                    dth=depy;
                    break;
                case 7:
                    dtw=-depx;
                    dth=0;
                    break;
                case 8:
                    dtw=-depx;
                    dth=-depy;
                    break;
                }

                // Resize the shape
                resizeShape(selection.element, dtw, dth);

                if(ce!=null){
                    ce.addEdit(new ResizeEdit(dtw, dth, (Resizable)selection.element));
                }  

                newBounds = selection.element.getBounds();
                deltax = newBounds.width - oldBounds.width;
                deltay = newBounds.height - oldBounds.height;
                switch(way){
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    dtx=0;
                    dty=deltay;
                    break;
                case 5:
                    dtx=0;
                    dty=deltay;
                    break;
                case 6:
                    dtx=-deltax;
                    dty=deltay;
                    break;
                case 7:
                    dtx=-deltax;
                    dty=0;
                    break;
                case 8:
                    dtx=-deltax;
                    dty=0;
                    break;
                }

                // Resize the shape
                selection.translateShape(dtx, dty);
             
                ce.end();   
               
                DiagramComponent dc = getElementContainer().getComponent();
                dc._compoundEdit.addEdit(ce);
            }
        }
View Full Code Here

    /**
     * Ends the resize of selected shapes
     */
    public void resizeShapesEnd(){
        CompoundEdit ce = new CompoundEdit();

        for (int i=0;i<_selectedElements.size();i++) {
            ElementSelection ss = (ElementSelection)_selectedElements.get(i);

            UndoableEdit ue = ss.translateShapeEnd();
            if (ue != null && ue.isSignificant()){
                ce.addEdit(ue);
            }
        }

        ce.end();
        if(ce.isSignificant()) { 
            DiagramComponent dc = getElementContainer().getComponent();
            dc._compoundEdit.addEdit(ce);
        }
    }
View Full Code Here

    /**
     * Ends the tranlation of selected shapes
     */
    public void translateShapesEnd(){
        CompoundEdit ce = new CompoundEdit();
       
        for (int i=0;i<_selectedElements.size();i++) {
            ElementSelection ss = (ElementSelection)_selectedElements.get(i);
           
            UndoableEdit ue = ss.translateShapeEnd();
            if (ue != null && ue.isSignificant()){
                ce.addEdit(ue);
            }
        }

        ce.end();
        if(ce.isSignificant()) { 
            DiagramComponent dc = getElementContainer().getComponent();
            dc._compoundEdit.addEdit(ce);
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.undo.CompoundEdit

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.