Changeset 2146 for trunk/autoquest-ui-swt/src/main/java
- Timestamp:
- 05/19/17 11:31:29 (7 years ago)
- Location:
- trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/AbstractInsertEventComposite.java
r927 r2146 18 18 19 19 import de.ugoe.cs.autoquest.eventcore.Event; 20 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;20 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 21 21 22 22 abstract public class AbstractInsertEventComposite extends Composite { 23 23 24 protected GUIModel guiModel;24 protected IHierarchicalEventTargetModel<?> eventTargetModel; 25 25 26 public AbstractInsertEventComposite(Composite parent, int style, GUIModel guiModel) {26 public AbstractInsertEventComposite(Composite parent, int style, IHierarchicalEventTargetModel<?> eventTargetModel) { 27 27 super(parent, style); 28 this. guiModel = guiModel;28 this.eventTargetModel = eventTargetModel; 29 29 } 30 30 -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/EditSequenceDialog.java
r927 r2146 32 32 33 33 import de.ugoe.cs.autoquest.eventcore.Event; 34 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;34 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 35 35 36 36 public class EditSequenceDialog extends Dialog { … … 43 43 44 44 private java.util.List<Event> sequence; 45 private GUIModel guiModel;45 private IHierarchicalEventTargetModel<?> eventTargetModel; 46 46 47 47 /** … … 51 51 * @param style 52 52 */ 53 public EditSequenceDialog(Shell parent, int style, GUIModel guiModel) {53 public EditSequenceDialog(Shell parent, int style, IHierarchicalEventTargetModel<?> eventTargetModel) { 54 54 super(parent, style); 55 55 setText("SWT Dialog"); 56 this. guiModel = guiModel;56 this.eventTargetModel = eventTargetModel; 57 57 } 58 58 … … 206 206 207 207 private void openInsertDialog(int position) { 208 if ( guiModel == null) {208 if (eventTargetModel == null) { 209 209 MessageBox messageBox = new MessageBox(shell, SWT.ERROR); 210 210 messageBox.setMessage("Operation not supported!\nOnly works for GUI sequences."); … … 212 212 messageBox.open(); 213 213 } else { 214 InsertAssertionDialog insertDialog = new InsertAssertionDialog(shell, SWT.NONE, guiModel); 214 InsertAssertionDialog insertDialog = 215 new InsertAssertionDialog(shell, SWT.NONE, eventTargetModel); 216 215 217 Event event = insertDialog.open(); 216 218 if (event != null) { -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/GuiModelTabComposite.java
r1275 r2146 25 25 import org.eclipse.swt.widgets.List; 26 26 27 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget; 28 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 27 29 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel; 28 30 import de.ugoe.cs.util.console.GlobalDataContainer; … … 52 54 * </p> 53 55 */ 54 private void createContents() {56 private <T extends IHierarchicalEventTarget> void createContents() { 55 57 setLayout(new GridLayout(5, false)); 56 58 … … 68 70 } 69 71 String modelName = selectedStrings[0]; 70 GUIModel model = (GUIModel) GlobalDataContainer.getInstance().getData(modelName); 72 73 @SuppressWarnings("unchecked") 74 IHierarchicalEventTargetModel<T> model = 75 (IHierarchicalEventTargetModel<T>) GlobalDataContainer.getInstance().getData(modelName); 71 76 72 ShowGuiModelDialog showGuiModelDialog = 73 new ShowGuiModelDialog(getShell(), SWT.NONE, model, modelName); 77 ShowGuiModelDialog<T> showGuiModelDialog = 78 new ShowGuiModelDialog<T>(getShell(), SWT.NONE, model, modelName); 79 74 80 showGuiModelDialog.open(); 75 81 } -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/InsertAssertionDialog.java
r927 r2146 31 31 32 32 import de.ugoe.cs.autoquest.eventcore.Event; 33 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;33 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 34 34 35 35 public class InsertAssertionDialog extends Dialog { … … 41 41 42 42 List<AbstractInsertEventComposite> insertEventComposites; 43 GUIModel guiModel;43 IHierarchicalEventTargetModel<?> eventTargetModel; 44 44 45 45 /** … … 49 49 * @param style 50 50 */ 51 public InsertAssertionDialog(Shell parent, int style, GUIModel guiModel) {51 public InsertAssertionDialog(Shell parent, int style, IHierarchicalEventTargetModel<?> eventTargetModel) { 52 52 super(parent, style); 53 53 setText("SWT Dialog"); 54 this. guiModel = guiModel;54 this.eventTargetModel = eventTargetModel; 55 55 } 56 56 … … 90 90 tbtmTextEquals.setText("TextEquals"); 91 91 AbstractInsertEventComposite compTextEquals = 92 new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, guiModel);92 new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, eventTargetModel); 93 93 tbtmTextEquals.setControl(compTextEquals); 94 94 insertEventComposites.add(compTextEquals); … … 97 97 tbtmFileEquals.setText("FileEquals"); 98 98 AbstractInsertEventComposite compFileEquals = 99 new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, guiModel);99 new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, eventTargetModel); 100 100 tbtmFileEquals.setControl(compFileEquals); 101 101 insertEventComposites.add(compFileEquals); -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/InsertFileEquals.java
r927 r2146 27 27 import de.ugoe.cs.autoquest.assertions.FileEqualsReplay; 28 28 import de.ugoe.cs.autoquest.eventcore.Event; 29 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;29 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 30 30 31 31 import org.eclipse.swt.events.SelectionAdapter; … … 46 46 * @param style 47 47 */ 48 public InsertFileEquals(Composite parent, int style, GUIModel guiModel) {49 super(parent, style, guiModel);48 public InsertFileEquals(Composite parent, int style, IHierarchicalEventTargetModel<?> eventTargetModel) { 49 super(parent, style, eventTargetModel); 50 50 setLayout(new GridLayout(3, false)); 51 51 -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/InsertTextEquals.java
r927 r2146 31 31 import de.ugoe.cs.autoquest.eventcore.Event; 32 32 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 33 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;34 import de.ugoe.cs.autoquest.eventcore. guimodel.IGUIElement;33 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget; 34 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 35 35 36 36 import org.eclipse.swt.events.SelectionAdapter; … … 47 47 * @param style 48 48 */ 49 public InsertTextEquals(Composite parent, int style, GUIModel guiModel) {50 super(parent, style, guiModel);49 public InsertTextEquals(Composite parent, int style, IHierarchicalEventTargetModel<?> eventTargetModel) { 50 super(parent, style, eventTargetModel); 51 51 setLayout(new GridLayout(3, false)); 52 52 … … 60 60 guiTree = new Tree(this, SWT.BORDER); 61 61 guiTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); 62 buildGuiTree( );62 buildGuiTree(eventTargetModel); 63 63 new Label(this, SWT.NONE); 64 64 … … 109 109 } 110 110 111 private void buildGuiTree() {112 for ( IGUIElement element : guiModel.getRootElements()) {111 private <T extends IHierarchicalEventTarget> void buildGuiTree(IHierarchicalEventTargetModel<T> eventTargetModel) { 112 for (T element : eventTargetModel.getRootElements()) { 113 113 TreeItem child = new TreeItem(guiTree, SWT.NULL); 114 114 child.setText(element.toString()); 115 115 child.setData(element); 116 buildGuiTree(child, guiModel.getChildren(element));116 buildGuiTree(child, eventTargetModel.getChildren(element), eventTargetModel); 117 117 } 118 118 } 119 119 120 private void buildGuiTree(TreeItem currentParent, List<IGUIElement> elements) { 121 for (IGUIElement element : elements) { 120 private <T extends IHierarchicalEventTarget> void buildGuiTree(TreeItem currentParent, 121 List<T> list, 122 IHierarchicalEventTargetModel<T> eventTargetModel) 123 { 124 for (T element : list) { 122 125 TreeItem child = new TreeItem(currentParent, SWT.NULL); 123 126 child.setText(element.toString()); 124 127 child.setData(element); 125 buildGuiTree(child, guiModel.getChildren(element));128 buildGuiTree(child, eventTargetModel.getChildren(element), eventTargetModel); 126 129 } 127 130 } -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/SequencesDialog.java
r927 r2146 29 29 import de.ugoe.cs.autoquest.SequenceInstanceOf; 30 30 import de.ugoe.cs.autoquest.eventcore.Event; 31 import de.ugoe.cs.autoquest.eventcore. guimodel.GUIModel;31 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 32 32 import de.ugoe.cs.util.console.GlobalDataContainer; 33 33 … … 41 41 private List sequenceList; 42 42 private Collection<java.util.List<Event>> sequences; 43 private GUIModel guiModel;43 private IHierarchicalEventTargetModel<?> eventTargetModel; 44 44 45 45 protected Shell shell; … … 99 99 else { 100 100 EditSequenceDialog editSequenceDialog = 101 new EditSequenceDialog(shell, SWT.NONE, guiModel);101 new EditSequenceDialog(shell, SWT.NONE, eventTargetModel); 102 102 int counter = 0; 103 103 java.util.List<Event> selectedSequence = null; … … 143 143 Object targetObject = 144 144 GlobalDataContainer.getInstance().getData(sequencesName + "_targets"); 145 guiModel = null;146 if (targetObject instanceof GUIModel) {147 guiModel = (GUIModel) targetObject;145 eventTargetModel = null; 146 if (targetObject instanceof IHierarchicalEventTargetModel) { 147 eventTargetModel = (IHierarchicalEventTargetModel<?>) targetObject; 148 148 } 149 149 } -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowGuiModelDialog.java
r1261 r2146 28 28 import org.eclipse.swt.widgets.TreeItem; 29 29 30 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget; 31 import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel; 30 32 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel; 31 33 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; … … 34 36 import org.eclipse.swt.widgets.Label; 35 37 36 public class ShowGuiModelDialog extends Dialog {38 public class ShowGuiModelDialog<T extends IHierarchicalEventTarget> extends Dialog { 37 39 38 40 protected Shell shell; 39 private Tree guiTree;40 41 protected GUIModelmodel;42 43 public ShowGuiModelDialog(Shell parent, int style, GUIModelmodel, String modelName) {41 private Tree targetTree; 42 43 protected IHierarchicalEventTargetModel<T> model; 44 45 public ShowGuiModelDialog(Shell parent, int style, IHierarchicalEventTargetModel<T> model, String modelName) { 44 46 super(parent, style); 45 47 setText("GUI Model " + modelName); … … 66 68 shell.setLayout(new GridLayout(4, false)); 67 69 68 guiTree = new Tree(shell, SWT.BORDER | SWT.MULTI);69 guiTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));70 71 build GuiTree();70 targetTree = new Tree(shell, SWT.BORDER | SWT.MULTI); 71 targetTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); 72 73 buildTargetTree(); 72 74 73 75 Button btnExpandAll = new Button(shell, SWT.NONE); … … 75 77 @Override 76 78 public void widgetSelected(SelectionEvent e) { 77 expandAll( guiTree, true);79 expandAll(targetTree, true); 78 80 } 79 81 }); … … 84 86 @Override 85 87 public void widgetSelected(SelectionEvent e) { 86 expandAll( guiTree, false);88 expandAll(targetTree, false); 87 89 } 88 90 }); 89 91 btnCollapseAll.setText("Collapse all"); 90 92 91 Button btnCondense = new Button(shell, SWT.NONE); 92 btnCondense.addSelectionListener(new SelectionAdapter() { 93 @Override 94 public void widgetSelected(SelectionEvent e) { 95 model.condenseModel(); 96 guiTree.removeAll(); 97 buildGuiTree(); 98 } 99 }); 100 btnCondense.setText("Condense"); 101 102 Button btnMerge = new Button(shell, SWT.NONE); 103 btnMerge.addSelectionListener(new SelectionAdapter() { 104 @Override 105 public void widgetSelected(SelectionEvent e) { 106 mergeSelectedNode(guiTree); 107 } 108 }); 109 btnMerge.setText("Merge nodes"); 93 if (model instanceof GUIModel) { 94 Button btnCondense = new Button(shell, SWT.NONE); 95 btnCondense.addSelectionListener(new SelectionAdapter() { 96 @Override 97 public void widgetSelected(SelectionEvent e) { 98 ((GUIModel) model).condenseModel(); 99 targetTree.removeAll(); 100 buildTargetTree(); 101 } 102 }); 103 btnCondense.setText("Condense"); 104 105 Button btnMerge = new Button(shell, SWT.NONE); 106 btnMerge.addSelectionListener(new SelectionAdapter() { 107 @Override 108 public void widgetSelected(SelectionEvent e) { 109 mergeSelectedNode(targetTree); 110 } 111 }); 112 btnMerge.setText("Merge nodes"); 113 } 110 114 111 115 //new Label(shell, SWT.NONE); … … 116 120 } 117 121 118 private void build GuiTree() {119 GUIModel.Traverser traverser =model.getTraverser();120 121 I GUIElement root = traverser.firstChild();122 private void buildTargetTree() { 123 IHierarchicalEventTargetModel.Traverser<T> traverser = model.getTraverser(); 124 125 IHierarchicalEventTarget root = traverser.firstChild(); 122 126 123 127 while (root != null) { 124 TreeItem child = new TreeItem( guiTree, SWT.NULL);128 TreeItem child = new TreeItem(targetTree, SWT.NULL); 125 129 child.setText(root.toString()); 126 130 child.setData(root); 127 build GuiTree(child, traverser);131 buildTargetTree(child, traverser); 128 132 root = traverser.nextSibling(); 129 133 } 130 134 } 131 135 132 private void buildGuiTree(TreeItem currentParent, GUIModel.Traverser traverser) { 136 private void buildTargetTree(TreeItem currentParent, 137 IHierarchicalEventTargetModel.Traverser<T> traverser) 138 { 133 139 if (traverser.hasFirstChild()) { 134 IGUIElementchildElement = traverser.firstChild();140 T childElement = traverser.firstChild(); 135 141 136 142 while (childElement != null) { … … 138 144 child.setText(childElement.toString()); 139 145 child.setData(childElement); 140 build GuiTree(child, traverser);146 buildTargetTree(child, traverser); 141 147 childElement = traverser.nextSibling(); 142 148 } … … 159 165 } 160 166 167 @SuppressWarnings("unchecked") 161 168 private void mergeSelectedNode(Tree tree) { 162 169 TreeItem[] selectedNodes = tree.getSelection(); … … 184 191 IGUIElement firstElement = (IGUIElement) selectedNodes[0].getData(); 185 192 for( int i=1 ; i<selectedNodes.length ; i++ ) { 186 model.mergeGUIElements(firstElement, (IGUIElement) selectedNodes[i].getData()); 187 } 188 } catch( IllegalArgumentException e) { 193 ((GUIModel) model).mergeEventTargets 194 (firstElement, (IGUIElement) selectedNodes[i].getData()); 195 } 196 } 197 catch( IllegalArgumentException e) { 189 198 Console.logException(e); 190 199 } … … 193 202 if (firstParent != null) { 194 203 firstParent.removeAll(); 195 build GuiTree(firstParent, model.getTraverser((IGUIElement) firstParent.getData()));204 buildTargetTree(firstParent, model.getTraverser((T) firstParent.getData())); 196 205 firstParent.setExpanded(true); 197 206 } 198 207 else { 199 guiTree.removeAll();200 build GuiTree();208 targetTree.removeAll(); 209 buildTargetTree(); 201 210 } 202 211 }
Note: See TracChangeset
for help on using the changeset viewer.