Changeset 659 for trunk/quest-ui-swt
- Timestamp:
- 08/28/12 10:42:56 (12 years ago)
- Location:
- trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/AbstractInsertEventComposite.java
r655 r659 1 1 package de.ugoe.cs.quest.ui.swt; 2 3 import java.util.SortedSet;4 2 5 3 import org.eclipse.swt.widgets.Composite; 6 4 7 5 import de.ugoe.cs.quest.eventcore.Event; 6 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 8 7 9 8 abstract public class AbstractInsertEventComposite extends Composite { 10 9 11 protected SortedSet<String> targets;10 protected GUIModel guiModel; 12 11 13 public AbstractInsertEventComposite(Composite parent, int style, SortedSet<String> targets) {12 public AbstractInsertEventComposite(Composite parent, int style, GUIModel guiModel) { 14 13 super(parent, style); 15 this. targets = targets;14 this.guiModel = guiModel; 16 15 } 17 16 -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/EditSequenceDialog.java
r655 r659 1 1 package de.ugoe.cs.quest.ui.swt; 2 3 import java.util.SortedSet;4 2 5 3 import org.eclipse.swt.widgets.Dialog; … … 20 18 21 19 import de.ugoe.cs.quest.eventcore.Event; 20 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 22 21 23 22 public class EditSequenceDialog extends Dialog { … … 29 28 30 29 private java.util.List<Event> sequence; 31 private SortedSet<String> targets;30 private GUIModel guiModel; 32 31 33 32 /** … … 37 36 * @param style 38 37 */ 39 public EditSequenceDialog(Shell parent, int style, SortedSet<String> targets) {38 public EditSequenceDialog(Shell parent, int style, GUIModel guiModel) { 40 39 super(parent, style); 41 40 setText("SWT Dialog"); 42 this. targets = targets;41 this.guiModel = guiModel; 43 42 } 44 43 … … 169 168 for (Event event : sequence) { 170 169 TableItem tableItem = new TableItem(table, SWT.NONE); 171 // TODO check if toString is sufficient 172 String target = event.getTarget().toString(); 170 String target = null; 171 if( event.getTarget()!=null ) { 172 target = event.getTarget().toString(); 173 } 173 174 if (target != null) { 174 175 // the target is split into multiple lines, as one line may … … 185 186 186 187 private void openInsertDialog(int position) { 187 InsertAssertionDialog insertDialog = new InsertAssertionDialog(shell, SWT.NONE, targets);188 InsertAssertionDialog insertDialog = new InsertAssertionDialog(shell, SWT.NONE, guiModel); 188 189 Event event = insertDialog.open(); 189 190 if (event != null) { -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/InsertAssertionDialog.java
r655 r659 3 3 import java.util.ArrayList; 4 4 import java.util.List; 5 import java.util.SortedSet;6 5 7 6 import org.eclipse.swt.widgets.Dialog; … … 18 17 19 18 import de.ugoe.cs.quest.eventcore.Event; 19 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 20 20 21 21 public class InsertAssertionDialog extends Dialog { … … 27 27 28 28 List<AbstractInsertEventComposite> insertEventComposites; 29 SortedSet<String> targets;29 GUIModel guiModel; 30 30 31 31 /** … … 35 35 * @param style 36 36 */ 37 public InsertAssertionDialog(Shell parent, int style, SortedSet<String> targets) {37 public InsertAssertionDialog(Shell parent, int style, GUIModel guiModel) { 38 38 super(parent, style); 39 39 setText("SWT Dialog"); 40 this. targets = targets;40 this.guiModel = guiModel; 41 41 } 42 42 … … 76 76 tbtmTextEquals.setText("TextEquals"); 77 77 AbstractInsertEventComposite compTextEquals = 78 new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, targets);78 new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, guiModel); 79 79 tbtmTextEquals.setControl(compTextEquals); 80 80 insertEventComposites.add(compTextEquals); … … 83 83 tbtmFileEquals.setText("FileEquals"); 84 84 AbstractInsertEventComposite compFileEquals = 85 new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, targets);85 new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, guiModel); 86 86 tbtmFileEquals.setControl(compFileEquals); 87 87 insertEventComposites.add(compFileEquals); -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/InsertFileEquals.java
r657 r659 1 1 package de.ugoe.cs.quest.ui.swt; 2 3 import java.util.SortedSet;4 2 5 3 import org.eclipse.swt.widgets.Composite; … … 15 13 import de.ugoe.cs.quest.assertions.FileEqualsReplay; 16 14 import de.ugoe.cs.quest.eventcore.Event; 15 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 17 16 18 17 import org.eclipse.swt.events.SelectionAdapter; … … 33 32 * @param style 34 33 */ 35 public InsertFileEquals(Composite parent, int style, SortedSet<String> targets) {36 super(parent, style, targets);34 public InsertFileEquals(Composite parent, int style, GUIModel guiModel) { 35 super(parent, style, guiModel); 37 36 setLayout(new GridLayout(3, false)); 38 37 -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/InsertTextEquals.java
r655 r659 1 1 2 package de.ugoe.cs.quest.ui.swt; 2 3 3 import java.util. SortedSet;4 import java.util.List; 4 5 5 6 import org.eclipse.swt.widgets.Composite; … … 14 15 15 16 import de.ugoe.cs.quest.assertions.TextEqualsAssertEventType; 17 import de.ugoe.cs.quest.assertions.TextEqualsReplay; 16 18 import de.ugoe.cs.quest.eventcore.Event; 17 import de.ugoe.cs.util.ArrayTools; 19 import de.ugoe.cs.quest.eventcore.IEventTarget; 20 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 21 import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 18 22 19 23 import org.eclipse.swt.events.SelectionAdapter; … … 22 26 public class InsertTextEquals extends AbstractInsertEventComposite { 23 27 private Text expectedText; 24 private Tree targetTree; 25 private Text targetText; 28 private Tree guiTree; 26 29 27 30 /** … … 31 34 * @param style 32 35 */ 33 public InsertTextEquals(Composite parent, int style, SortedSet<String> targets) {34 super(parent, style, targets);36 public InsertTextEquals(Composite parent, int style, GUIModel guiModel) { 37 super(parent, style, guiModel); 35 38 setLayout(new GridLayout(3, false)); 36 39 … … 42 45 expectedText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); 43 46 44 Label lblTargetWidget = new Label(this, SWT.NONE); 45 lblTargetWidget.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); 46 lblTargetWidget.setText("Target Widget:"); 47 48 targetText = new Text(this, SWT.BORDER); 49 targetText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); 50 new Label(this, SWT.NONE); 51 52 targetTree = new Tree(this, SWT.BORDER); 53 targetTree.addSelectionListener(new SelectionAdapter() { 54 @Override 55 public void widgetSelected(SelectionEvent e) { 56 TreeItem[] selection = targetTree.getSelection(); 57 if (selection.length == 1) { 58 TreeItem item = selection[0]; 59 String targetString = item.getText(); 60 item = item.getParentItem(); 61 while (item != null) { 62 // TODO the "." is hard coded for the JFCMonitor. should be flexible 63 targetString = item.getText() + "." + targetString; 64 item = item.getParentItem(); 65 } 66 targetText.setText(targetString); 67 } 68 } 69 }); 70 targetTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); 71 buildTargetTree(); 47 guiTree = new Tree(this, SWT.BORDER); 48 guiTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); 49 buildGuiTree(); 72 50 new Label(this, SWT.NONE); 73 51 … … 76 54 @Override 77 55 public void widgetSelected(SelectionEvent e) { 78 expandAll( targetTree, true);56 expandAll(guiTree, true); 79 57 } 80 58 }); … … 85 63 @Override 86 64 public void widgetSelected(SelectionEvent e) { 87 expandAll( targetTree, false);65 expandAll(guiTree, false); 88 66 } 89 67 }); … … 99 77 @Override 100 78 public Event getEvent() { 101 // TODO make compatible to new event core 102 /* 103 * IEventTarget target = targetText.getText(); TextEqualsReplay replay = new 104 * TextEqualsReplay(expectedText.getText(), target); 105 */ 106 Event event = new Event(new TextEqualsAssertEventType()); 107 /* 108 * event.setTarget(target); event.addReplayable(replay); 109 */ 79 // TODO possibly display error if no target is selected 80 TreeItem[] selection = guiTree.getSelection(); 81 IEventTarget target = null; 82 TextEqualsReplay replay = null; 83 if (selection.length == 1) { 84 target = (IEventTarget) selection[0].getData(); 85 replay = new TextEqualsReplay(expectedText.getText(), target.toString()); 86 } 87 88 Event event = new Event(new TextEqualsAssertEventType(), target); 89 90 event.setTarget(target); 91 if (replay != null) { 92 event.addReplayable(replay); 93 } 94 110 95 return event; 111 96 } 112 97 113 private void buildTargetTree() { 114 for (String target : targets) { 115 TreeItem currentParent = null; 116 TreeItem[] currentItems = targetTree.getItems(); 98 private void buildGuiTree() { 99 for (IGUIElement element : guiModel.getRootElements()) { 100 TreeItem child = new TreeItem(guiTree, SWT.NULL); 101 child.setText(element.toString()); 102 child.setData(element); 103 buildGuiTree(child, guiModel.getChildren(element)); 104 } 105 } 117 106 118 // TODO needs rule for target splitting. currently its hard coded for JFCEvent targets. 119 String[] targetParts = target.split("\\.\\["); 120 for (String targetPart : targetParts) { 121 String[] currentTexts = new String[currentItems.length]; 122 for (int i = 0; i < currentItems.length; i++) { 123 currentTexts[i] = currentItems[i].getText(); 124 } 125 if (currentParent != null) { 126 targetPart = "[" + targetPart; 127 } 128 int index = ArrayTools.findIndex(currentTexts, targetPart); 129 if (index >= 0) { 130 currentParent = currentItems[index]; 131 } 132 else { 133 if (currentParent == null) { 134 currentParent = new TreeItem(targetTree, SWT.NULL); 135 currentParent.setText(targetPart); 136 } 137 else { 138 currentParent = new TreeItem(currentParent, SWT.NULL); 139 currentParent.setText(targetPart); 140 } 141 } 142 currentItems = currentParent.getItems(); 143 } 107 private void buildGuiTree(TreeItem currentParent, List<IGUIElement> elements) { 108 for (IGUIElement element : elements) { 109 TreeItem child = new TreeItem(currentParent, SWT.NULL); 110 child.setText(element.toString()); 111 child.setData(element); 112 buildGuiTree(child, guiModel.getChildren(element)); 144 113 } 145 146 114 } 147 115 -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SequencesDialog.java
r655 r659 2 2 3 3 import java.util.Collection; 4 import java.util.SortedSet;5 import java.util.TreeSet;6 4 7 5 import org.eclipse.swt.widgets.Dialog; … … 17 15 import de.ugoe.cs.quest.SequenceInstanceOf; 18 16 import de.ugoe.cs.quest.eventcore.Event; 17 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 19 18 import de.ugoe.cs.quest.ui.GlobalDataContainer; 20 19 … … 28 27 private List sequenceList; 29 28 private Collection<java.util.List<Event>> sequences; 30 private SortedSet<String> targets;29 private GUIModel guiModel; 31 30 32 31 protected Shell shell; … … 86 85 else { 87 86 EditSequenceDialog editSequenceDialog = 88 new EditSequenceDialog(shell, SWT.NONE, targets);87 new EditSequenceDialog(shell, SWT.NONE, guiModel); 89 88 int counter = 0; 90 89 java.util.List<Event> selectedSequence = null; … … 130 129 Object targetObject = 131 130 GlobalDataContainer.getInstance().getData(sequencesName + "_targets"); 132 targets = null; 133 if (targetObject instanceof SortedSet) { 134 if (!((SortedSet<?>) targetObject).isEmpty()) { 135 if (((SortedSet<?>) targetObject).first() instanceof String) { 136 targets = (SortedSet<String>) targetObject; 137 } 138 } 131 guiModel = null; 132 if (targetObject instanceof GUIModel) { 133 guiModel = (GUIModel) targetObject; 139 134 } 140 if (targets == null) { 141 targets = new TreeSet<String>(); 142 for (java.util.List<Event> sequence : sequences) { 143 for (Event event : sequence) { 144 // TODO check if toString() is sufficient 145 String target = event.getTarget().toString(); 146 if (target != null) { 147 targets.add(target); 148 } 149 } 150 } 135 if (guiModel == null) { 136 MessageBox messageBox = new MessageBox(shell, SWT.ERROR); 137 messageBox.setMessage("Operation not supported!\nOnly works for GUI sequences."); 138 messageBox.setText("Error"); 139 messageBox.open(); 151 140 } 152 141 }
Note: See TracChangeset
for help on using the changeset viewer.