1 5 6 package org.enhydra.jawe.actions; 7 8 import java.awt.event.ActionEvent ; 9 import java.util.ArrayList ; 10 import java.util.Collections ; 11 import java.util.Comparator ; 12 import org.enhydra.jawe.AbstractEditor; 13 import org.enhydra.jawe.ProcessEditor; 14 import org.enhydra.jawe.WorkflowManager; 15 import org.enhydra.jawe.graph.Participant; 16 17 public class MoveDownParticipant extends ActionBase { 18 19 public MoveDownParticipant (AbstractEditor editor) { 20 super(editor); 21 } 22 23 public void actionPerformed(ActionEvent e) { 24 if (editor instanceof ProcessEditor) { 25 Object [] cells = editor.getGraph().getSelectionCells(); 26 ArrayList gparts=new ArrayList (); 27 for(int i=0;i<cells.length;i++){ 28 gparts.add(cells[i]); 29 } 30 WorkflowManager dm=editor.getGraph().getWorkflowManager(); 31 ParticipantComparator pc=new ParticipantComparator(dm); 32 Collections.sort(gparts,pc); dm.moveParticipants(gparts.toArray(), false); 34 } 35 } 36 37 42 private static class ParticipantComparator implements Comparator { 43 WorkflowManager workflowManager; 44 public ParticipantComparator (WorkflowManager workflowManager) { 45 this.workflowManager=workflowManager; 46 } 47 48 public int compare(Object o1, Object o2) { 49 Participant p1=(Participant)o1; 50 Participant p2=(Participant)o2; 51 int y1=workflowManager.getBounds(p1,null).getBounds().y; int y2=workflowManager.getBounds(p2,null).getBounds().y; 54 return (y1>y2 ? -1 : (y1==y2 ? 0 : 1)); } 56 } 57 } 59 60 | Popular Tags |