Package javax.swing.undo

Examples of javax.swing.undo.CompoundEdit


   
    /**
     * If a connection end is selected, disconnect it from its gate
     */
    protected void disconnectConnectionEnd(){
        CompoundEdit ce = new CompoundEdit();

        if (_elementContainer.getSelection().getShapeCount()==1 &&  _elementContainer.getSelection().getSelectedShape(0) instanceof ConnectionPathSelection){
            ConnectionPathSelection cs = (ConnectionPathSelection)_elementContainer.getSelection().getSelectedShape(0);
            Connection connection = cs.getConnection();

            if( cs.isFirstEndSelected() && connection.getFirstEndGate()!=null ){
                Gate firstGate = connection.getFirstEndGate()
                connection.disconnect(firstGate);
                ce.addEdit(new GateDisconnectEdit(connection, firstGate,true));  

            } else if( cs.isLastEndSelected() && connection.getLastEndGate()!=null  ){
                Gate lastGate = connection.getLastEndGate()
                connection.disconnect(lastGate);
                ce.addEdit(new GateDisconnectEdit(connection, lastGate,false));  
            }
        }

        ce.end();
        if (ce.isSignificant()){
            _compoundEdit.addEdit(ce);
        }  
    }
View Full Code Here


     * This method is called at the end of a translation of points
     * of the selection i.e when the mouse is released
     */
    protected void pointTranslationEnd(){
        // Reset _compoundEdit
        _compoundEdit = new CompoundEdit();
    }
View Full Code Here

     * This method is called at the end of the transaltion
     * of the selection i.e when the mouse is released
     */
    protected void translationEnd(){
        // Reset _compoundEdit
        _compoundEdit = new CompoundEdit();
    }
View Full Code Here

     * This method is called at the end of the resize
     * of the selection i.e when the mouse is released
     */
    protected void resizeEnd(){
        // Reset _compoundEdit
        _compoundEdit = new CompoundEdit();
    }
View Full Code Here

    }

   
    // Implementation of the abstract methods
    protected void translate(int x, int y){
      CompoundEdit ce = new CompoundEdit();
      for(int i=0;i<ShapesContainer.this.size();i++){
        AbstractShape s=(AbstractShape)elementAt(i);
        s.translate(x,y);
        ce.addEdit(new TranslateEdit(x, y, s));
      }
      ce.end();
      fireUndoableEditUpdate(new UndoableEditEvent(this, ce));
    }
View Full Code Here

    /* (non-Javadoc)
     * @see simtools.diagram.DiagramComponent#copyAt(java.util.Vector, int, int)
     */
    protected void copyAt(Vector v, int x, int y){
        CompoundEdit compoundEdit = new CompoundEdit();

        List selectedConnectors = new ArrayList();
        List selectedGatedComponent = new ArrayList();
       
        Hashtable clonedGates = new Hashtable();

        for(int i=0;i<v.size();i++){
            Object o=v.elementAt(i);

        if (o instanceof Connection){
            selectedConnectors.add(o);
           
        } else if (o instanceof AbstractShape){
            AbstractShape as=((AbstractShape)o).cloneShape();

            if (o instanceof GatedComponent){
                selectedGatedComponent.add(o);
               
             // Kept the relation between the existing and the new gate
                List oldGates = new ArrayList(((GatedComponent)o).getGates());
                    List newGates = new ArrayList(((GatedComponent)as).getGates());
                   
                    for(int j=0;j<oldGates.size(); j++){
                        clonedGates.put(oldGates.get(j), newGates.get(j));
                    }
                  }
           
          as.translate(x,y);
          ShapesContainer.this.add(as);
          compoundEdit.addEdit(new CreateEdit(ShapesContainer.this,as));
        }
        }

        // Now Copy the connectors
        for (int i = 0; i < selectedConnectors.size(); i++) {
            Connection connection = (Connection) selectedConnectors.get(i);

            if (connection instanceof AbstractShape){
                Gate fisrtGate = (Gate) connection.getFirstEndGate();
                Gate lastGate = (Gate) connection.getLastEndGate();
               
                Gate newFg = null;
                Gate newLg = null;

                if ((fisrtGate!=null) && selectedGatedComponent.contains(fisrtGate.getOwner())){
                    newFg = (Gate) clonedGates.get(fisrtGate);
                }
                if ((lastGate!=null) && selectedGatedComponent.contains(lastGate.getOwner())){
                    newLg = (Gate) clonedGates.get(lastGate);
                }

                AbstractShape newConnector = ((AbstractShape)connection).cloneShape();
                newConnector.translate(x,y);
               
                if (newFg != null){
                    ((Connection)newConnector).connect(newFg, true);
                    compoundEdit.addEdit(new GateConnectEdit( (Connection)newConnector, newFg, true));
                }

                if (newLg != null){
                    ((Connection)newConnector).connect(newLg, false);
                    compoundEdit.addEdit(new GateConnectEdit( (Connection)newConnector, newLg, false));
                }

                // Add it ton container
                ShapesContainer.this.add(newConnector);
               
                compoundEdit.addEdit(new CreateEdit(ShapesContainer.this,newConnector));
            }
        }

        compoundEdit.end();
        fireUndoableEditUpdate(new UndoableEditEvent(this, compoundEdit));
    }
View Full Code Here

        /* (non-Javadoc)
         * @see simtools.diagram.DiagramComponent#copyAt(java.util.Vector, int, int)
         */
        protected void copyAt(Vector v, int x, int y) {
            CompoundEdit compoundEdit = new CompoundEdit();

            List selectedConnectors = new ArrayList();
            List selectedGatedComponent = new ArrayList();

            Hashtable clonedGates = new Hashtable();

            for(int i=0;i<v.size();i++){
                Object o=v.elementAt(i);

                if (o instanceof Connection){
                    selectedConnectors.add(o);

                } else {
                    Element as= null;
                    if (o instanceof TestGatedRectangle){
                        as = ((TestGatedRectangle)o).cloneTestGatedRectangle();
                   
                    } else if (o instanceof TestConnection){
                        as = ((TestConnection)o).cloneTestConnection();
                    }

                    if (o instanceof GatedComponent){
                        selectedGatedComponent.add(o);

                        // Kept the relation between the existing and the new gate
                        List oldGates = new ArrayList(((GatedComponent)o).getGates());
                        List newGates = new ArrayList(((GatedComponent)as).getGates());

                        for(int j=0;j<oldGates.size(); j++){
                            clonedGates.put(oldGates.get(j), newGates.get(j));
                        }
                    }

                    as.translate(x,y);
                    TestShapesContainer.this.add(as);
                }
            }

            // Now Copy the connectors
            for (int i = 0; i < selectedConnectors.size(); i++) {
                Connection connection = (Connection) selectedConnectors.get(i);

                if (connection instanceof TestConnection){
                    Gate fisrtGate = (Gate) connection.getFirstEndGate();
                    Gate lastGate = (Gate) connection.getLastEndGate();

                    Gate newFg = null;
                    Gate newLg = null;

                    if ((fisrtGate!=null) && selectedGatedComponent.contains(fisrtGate.getOwner())){
                        newFg = (Gate) clonedGates.get(fisrtGate);
                    }
                    if ((lastGate!=null) && selectedGatedComponent.contains(lastGate.getOwner())){
                        newLg = (Gate) clonedGates.get(lastGate);
                    }

                    TestConnection newConnector = (TestConnection)((TestConnection)connection).cloneTestConnection();
                    newConnector.translate(x,y);

                    if (newFg != null){
                        ((Connection)newConnector).connect(newFg, true);
                        compoundEdit.addEdit(new GateConnectEdit( (Connection)newConnector, newFg, true));
                    }

                    if (newLg != null){
                        ((Connection)newConnector).connect(newLg, false);
                        compoundEdit.addEdit(new GateConnectEdit( (Connection)newConnector, newLg, false));
                    }

                    // Add it ton container
                    TestShapesContainer.this.add(newConnector);  
                }
            }

            compoundEdit.end();
            fireUndoableEditUpdate(new UndoableEditEvent(this, compoundEdit));
        }
View Full Code Here

        if (result == JOptionPane.OK_OPTION) {
          // update the button
          update();
         
          // update the selection
          CompoundEdit ce=new CompoundEdit();
          boolean ok=false;
          for(int i=0;i<v.size();i++){
            Object o=v.get(i);
            if(o instanceof AbstractShape){
              AbstractShape as=(AbstractShape)o;
              if(as.setProperties(DiagramSelectionPropertiesPanel.this, ce)){
                ok=true;
              }
            }
          }
          if(ok){
            ce.end();
            sc.fireUndoableEditUpdate(new UndoableEditEvent(sc, ce));
            sc.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]-i;
      tmp=this.elementAt(indice);
      this.removeElementAt(indice);
      this.add(tmp);
      ce.addEdit(new DepthChangedEdit(this, indice, size()-1));
    }
   
    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=indices.length; i>0; i--) {
      indice=indices[i-1];
      if(indice < size()-1) {
        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

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.