~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/load/TestLoaders.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import org.eclipse.ui.IWorkbenchPart;
36
36
import org.eclipse.ui.PlatformUI;
37
37
 
38
 
// Referenced classes of package org.eclipse.hyades.uml2sd.ztest:
39
 
//            OpenToolBox
40
 
 
 
38
/**
 
39
 * Test loader class.
 
40
 */
 
41
@SuppressWarnings("javadoc")
41
42
public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterProvider, ISDPagingProvider, ISelectionListener {
42
43
 
43
44
    public SDView v;
52
53
        this(""); //$NON-NLS-1$
53
54
    }
54
55
 
 
56
    @SuppressWarnings("unused")
55
57
    public TestLoaders(String name) {
56
58
        page = 1;
57
59
    }
151
153
                }
152
154
            }
153
155
 
154
 
            for (int i = 0; i < testFrame.lifeLinesCount(); i++)
 
156
            for (int i = 0; i < testFrame.lifeLinesCount(); i++) {
155
157
                if (i > 0) {
156
158
                    ExecutionOccurrence occ = new ExecutionOccurrence();
157
159
                    occ.setStartOccurrence(testFrame.getSyncMessage(i).getEventOccurrence() + 1);
159
161
                    testFrame.getLifeline(i).addExecution(occ);
160
162
                    occ.setName("******************* Execution Occurance TEST ****************");
161
163
                }
 
164
            }
162
165
 
163
166
            Stop s = new Stop();
164
167
            s.setLifeline(testFrame.getLifeline(1));
204
207
                occ.setEndOccurrence(testFrame.getSyncMessageReturn(i - 1).getEventOccurrence());
205
208
                testFrame.getLifeline(0).addExecution(occ);
206
209
            }
207
 
        } 
 
210
        }
208
211
        v.setFrame(testFrame);
209
212
    }
210
213
 
216
219
    public boolean find(Criteria toSearch) {
217
220
        Frame frame = v.getFrame();
218
221
 
219
 
        if (frame == null)
 
222
        if (frame == null) {
220
223
            return false;
 
224
        }
221
225
        if (findResults == null || findCriteria == null || !findCriteria.compareTo(toSearch)) {
222
226
            findResults = new ArrayList<GraphNode>();
223
227
            findCriteria = toSearch;
224
228
            if (findCriteria.isLifeLineSelected()) {
225
229
                for (int i = 0; i < frame.lifeLinesCount(); i++) {
226
 
                    if (findCriteria.matches(frame.getLifeline(i).getName()))
 
230
                    if (findCriteria.matches(frame.getLifeline(i).getName())) {
227
231
                        findResults.add(frame.getLifeline(i));
 
232
                    }
228
233
                }
229
234
 
230
235
            }
231
236
            ArrayList<GraphNode> msgs = new ArrayList<GraphNode>();
232
237
            if (findCriteria.isSyncMessageSelected()) {
233
238
                for (int i = 0; i < frame.syncMessageCount(); i++) {
234
 
                    if (findCriteria.matches(frame.getSyncMessage(i).getName()))
 
239
                    if (findCriteria.matches(frame.getSyncMessage(i).getName())) {
235
240
                        msgs.add(frame.getSyncMessage(i));
 
241
                    }
236
242
                }
237
243
 
238
 
                for (int i = 0; i < frame.syncMessageReturnCount(); i++)
239
 
                    if (findCriteria.matches(frame.getSyncMessageReturn(i).getName()))
 
244
                for (int i = 0; i < frame.syncMessageReturnCount(); i++) {
 
245
                    if (findCriteria.matches(frame.getSyncMessageReturn(i).getName())) {
240
246
                        msgs.add(frame.getSyncMessageReturn(i));
 
247
                    }
 
248
                }
241
249
 
242
250
            }
243
251
            // if(msgs.size() > 0) {
248
256
 
249
257
            msgs = new ArrayList<GraphNode>();
250
258
            if (findCriteria.isAsyncMessageSelected()) {
251
 
                for (int i = 0; i < frame.asyncMessageCount(); i++)
252
 
                    if (findCriteria.matches(frame.getAsyncMessage(i).getName()))
 
259
                for (int i = 0; i < frame.asyncMessageCount(); i++) {
 
260
                    if (findCriteria.matches(frame.getAsyncMessage(i).getName())) {
253
261
                        msgs.add(frame.getAsyncMessage(i));
 
262
                    }
 
263
                }
254
264
 
255
 
                for (int i = 0; i < frame.asyncMessageReturnCount(); i++)
256
 
                    if (findCriteria.matches(frame.getAsyncMessageReturn(i).getName()))
 
265
                for (int i = 0; i < frame.asyncMessageReturnCount(); i++) {
 
266
                    if (findCriteria.matches(frame.getAsyncMessageReturn(i).getName())) {
257
267
                        msgs.add(frame.getAsyncMessageReturn(i));
 
268
                    }
 
269
                }
258
270
 
259
271
            }
260
272
            // if(msgs.size() > 0) {
265
277
 
266
278
            @SuppressWarnings("rawtypes")
267
279
            List selection = v.getSDWidget().getSelection();
268
 
            if (selection != null && selection.size() == 1)
 
280
            if (selection != null && selection.size() == 1) {
269
281
                currentFindIndex = findResults.indexOf(selection.get(0)) + 1;
270
 
            else
 
282
            } else {
271
283
                currentFindIndex = 0;
 
284
            }
272
285
        } else {
273
286
            currentFindIndex++;
274
287
        }
275
288
        if (findResults.size() > currentFindIndex) {
276
 
            GraphNode current = (GraphNode) findResults.get(currentFindIndex);
 
289
            GraphNode current = findResults.get(currentFindIndex);
277
290
            v.getSDWidget().moveTo(current);
278
291
            return true;
279
 
        } else {
280
 
            // return notFoundYet(findCriteria); // search in other page
281
 
            return false;
282
292
        }
283
 
        // return false;
 
293
        // return notFoundYet(findCriteria); // search in other page
 
294
        return false;
284
295
    }
285
296
 
286
297
    @Override
348
359
                }
349
360
            }
350
361
 
351
 
            for (int i = 0; i < frame.syncMessageReturnCount(); i++)
 
362
            for (int i = 0; i < frame.syncMessageReturnCount(); i++) {
352
363
                if (filterCriteria.getCriteria().matches(frame.getSyncMessageReturn(i).getName())) {
353
364
                    frame.getSyncMessageReturn(i).setVisible(false);
354
365
                    found = true;
355
366
                }
 
367
            }
356
368
        }
357
369
 
358
370
        v.getSDWidget().redraw();
427
439
 
428
440
        @SuppressWarnings("nls")
429
441
        public Image getResourceImage(String _name) {
430
 
            ImageDescriptor img;
 
442
            ImageDescriptor imgage;
431
443
            try {
432
444
                URL BASIC_URL = new URL("platform", "localhost", "plugin");
433
445
                URL url = new URL(BASIC_URL, (new StringBuilder("plugin/org.eclipse.linuxtools.tmf.ui/icons/")).append(_name).toString());
434
 
                img = ImageDescriptor.createFromURL(url);
435
 
                return img.createImage();
 
446
                imgage = ImageDescriptor.createFromURL(url);
 
447
                return imgage.createImage();
436
448
            } catch (Exception e) {
437
449
                System.err.println(e);
438
450
            }
446
458
 
447
459
        @Override
448
460
        public void dispose() {
449
 
            if (img != null)
 
461
            if (img != null) {
450
462
                img.dispose();
 
463
            }
451
464
        }
452
465
 
453
466
    }
456
469
    public void firstPage() {
457
470
        page = 0;
458
471
        createFrame();
459
 
        
 
472
 
460
473
    }
461
474
 
462
475
    @Override