Search in sources :

Example 1 with Frame

use of org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame in project tracecompass by tracecompass.

the class SDViewTest method testSDView.

/**
 * Test Sequence diagram view, counting the columns
 */
@Test
public void testSDView() {
    SWTBotView viewBot = fBot.viewById(UML2DVIEW_ID);
    SWTBotCanvas timeCompressionBar = viewBot.bot().canvas(0);
    SWTBotCanvas sdWidget = viewBot.bot().canvas(1);
    assertNotNull(viewBot);
    viewBot.setFocus();
    WaitUtils.waitForJobs();
    List<SWTBotToolbarButton> viewButtons = viewBot.getToolbarButtons();
    List<String> titles = new ArrayList<>();
    for (SWTBotToolbarButton buttonBot : viewButtons) {
        titles.add(buttonBot.getToolTipText());
    }
    final char commandKeyChar = (char) 0x2318;
    final String findShortcut = (Platform.getOS().equals(Platform.OS_MACOSX) ? commandKeyChar : "Ctrl+") + "F";
    String[] expected = { "Reset zoom factor", "Select", "Zoom in the diagram", "Zoom out the diagram", "Go to next page", "Go to previous page", "Go to first page", "Go to last page", "Find... (" + findShortcut + ")" };
    assertArrayEquals("Buttons", expected, titles.toArray(new String[0]));
    SDView view = (SDView) viewBot.getViewReference().getPart(false);
    ISDAdvancedPagingProvider pagingProvider = (ISDAdvancedPagingProvider) view.getSDPagingProvider();
    Frame frame = view.getFrame();
    assertEquals(2, frame.lifeLinesCount());
    timeCompressionBar.click();
    // Zoom in page using toolbar buttons
    viewBot.toolbarButton("Select").click();
    sdWidget.click(0, 0);
    viewBot.toolbarButton("Zoom in the diagram").click();
    sdWidget.click();
    sdWidget.click();
    viewBot.toolbarButton("Zoom out the diagram").click();
    sdWidget.click();
    viewBot.toolbarButton("Reset zoom factor").click();
    sdWidget.click();
    // Zoom in page using view menu
    viewBot.viewMenu("Select").click();
    sdWidget.click(0, 0);
    viewBot.viewMenu("Zoom in").click();
    sdWidget.click();
    sdWidget.click();
    viewBot.viewMenu("Zoom out").click();
    sdWidget.click();
    viewBot.viewMenu("Reset zoom factor").click();
    sdWidget.click();
    assertEquals(0, pagingProvider.currentPage());
    viewBot.toolbarButton("Find... (" + findShortcut + ")").click();
    SWTBot findDialogBot = fBot.shell("Sequence Diagram Find").bot();
    findDialogBot.comboBox().setText("peer2");
    findDialogBot.checkBox("Lifeline").select();
    findDialogBot.checkBox("Interaction").deselect();
    findDialogBot.button("Find").click();
    findDialogBot.button("Close").click();
    SWTBotUtils.waitUntil(f -> f.getLifeline(1).isSelected(), frame, "Did not find lifeline");
    assertEquals(0, pagingProvider.currentPage());
    // Shell focus required to enable tool item shortcut
    viewBot.setFocus();
    viewBot.toolbarButton("Find... (" + findShortcut + ")").click();
    findDialogBot = fBot.shell("Sequence Diagram Find").bot();
    findDialogBot.comboBox().setText("1001");
    findDialogBot.checkBox("Lifeline").deselect();
    findDialogBot.checkBox("Interaction").select();
    findDialogBot.button("Find").click();
    findDialogBot.button("Close").click();
    SWTBotUtils.waitUntil(f -> f.getSyncMessage(1).isSelected(), frame, "Did not find interaction");
    viewBot.viewMenu("Hide Patterns...").click();
    SWTBot hideDialogBot = fBot.shell("Sequence Diagram Hide Patterns").bot();
    hideDialogBot.button("Add...").click();
    SWTBot definitionBot = fBot.shell("Definition of Hide Pattern").bot();
    definitionBot.comboBox().setText("peer2");
    definitionBot.checkBox("Lifeline").select();
    definitionBot.checkBox("Interaction").deselect();
    definitionBot.button("Create").click();
    hideDialogBot.button("OK").click();
    SWTBotUtils.waitUntil(v -> v.getFrame().lifeLinesCount() == 1, view, "Did not hide lifeline");
    viewBot.viewMenu("Hide Patterns...").click();
    hideDialogBot = fBot.shell("Sequence Diagram Hide Patterns").bot();
    hideDialogBot.table().select("hide peer2 [Lifeline]");
    hideDialogBot.button("Remove").click();
    hideDialogBot.button("OK").click();
    SWTBotUtils.waitUntil(v -> v.getFrame().lifeLinesCount() == 2, view, "Did not show lifeline");
    viewBot.viewMenu("Configure Min Max...").click();
    SWTBot configurationBot = fBot.shell("TimeCompression bar configuration").bot();
    configurationBot.textWithLabel("Max time").setText("200");
    configurationBot.button("OK").click();
    viewBot.viewMenu("Configure Min Max...").click();
    configurationBot = fBot.shell("TimeCompression bar configuration").bot();
    configurationBot.button("Default").click();
    configurationBot.button("OK").click();
    // Navigate pages using toolbar buttons
    assertEquals(0, pagingProvider.currentPage());
    viewBot.toolbarButton("Go to next page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to previous page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to last page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to first page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    // Navigate pages using view menu
    assertEquals(0, pagingProvider.currentPage());
    viewBot.viewMenu("Next page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.viewMenu("Previous page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.viewMenu("Last page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.viewMenu("First page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.viewMenu("Pages...").click();
    SWTBot pagesBot = fBot.shell("Sequence Diagram Pages").bot();
    pagesBot.text().setText("2");
    pagesBot.button("OK").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) ArrayList(java.util.ArrayList) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) ISDAdvancedPagingProvider(org.eclipse.tracecompass.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) SDView(org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView) Test(org.junit.Test)

Example 2 with Frame

use of org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame in project tracecompass by tracecompass.

the class TestLoaders method find.

@Override
public boolean find(Criteria toSearch) {
    Frame frame = v.getFrame();
    if (frame == null) {
        return false;
    }
    if (findResults == null || findCriteria == null || !findCriteria.compareTo(toSearch)) {
        findResults = new ArrayList<>();
        findCriteria = toSearch;
        if (findCriteria.isLifeLineSelected()) {
            for (int i = 0; i < frame.lifeLinesCount(); i++) {
                if (findCriteria.matches(frame.getLifeline(i).getName())) {
                    findResults.add(frame.getLifeline(i));
                }
            }
        }
        ArrayList<GraphNode> msgs = new ArrayList<>();
        if (findCriteria.isSyncMessageSelected()) {
            for (int i = 0; i < frame.syncMessageCount(); i++) {
                if (findCriteria.matches(frame.getSyncMessage(i).getName())) {
                    msgs.add(frame.getSyncMessage(i));
                }
            }
            for (int i = 0; i < frame.syncMessageReturnCount(); i++) {
                if (findCriteria.matches(frame.getSyncMessageReturn(i).getName())) {
                    msgs.add(frame.getSyncMessageReturn(i));
                }
            }
        }
        // if(msgs.size() > 0) {
        // GraphNode temp[] = msgs.toArray(new GraphNode[0]);
        // Arrays.sort(temp, new DateComparator());
        // findResults.addAll(Arrays.asList(temp));
        // }
        msgs = new ArrayList<>();
        if (findCriteria.isAsyncMessageSelected()) {
            for (int i = 0; i < frame.asyncMessageCount(); i++) {
                if (findCriteria.matches(frame.getAsyncMessage(i).getName())) {
                    msgs.add(frame.getAsyncMessage(i));
                }
            }
            for (int i = 0; i < frame.asyncMessageReturnCount(); i++) {
                if (findCriteria.matches(frame.getAsyncMessageReturn(i).getName())) {
                    msgs.add(frame.getAsyncMessageReturn(i));
                }
            }
        }
        // if(msgs.size() > 0) {
        // GraphNode temp[] = msgs.toArray(new GraphNode[0]);
        // Arrays.sort(temp, new DateComparator());
        // findResults.addAll(Arrays.asList(temp));
        // }
        List<GraphNode> selection = v.getSDWidget().getSelection();
        if (selection != null && selection.size() == 1) {
            currentFindIndex = findResults.indexOf(selection.get(0)) + 1;
        } else {
            currentFindIndex = 0;
        }
    } else {
        currentFindIndex++;
    }
    if (findResults.size() > currentFindIndex) {
        GraphNode current = findResults.get(currentFindIndex);
        v.getSDWidget().moveTo(current);
        return true;
    }
    // return notFoundYet(findCriteria); // search in other page
    return false;
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) ArrayList(java.util.ArrayList) GraphNode(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode)

Example 3 with Frame

use of org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame in project tracecompass by tracecompass.

the class TestLoaders method filter.

@Override
public boolean filter(List<FilterCriteria> filters) {
    if (savedFrame != null) {
        savedFrame = v.getFrame();
    }
    Frame frame = v.getFrame();
    if (frame == null) {
        return false;
    }
    if (filters.size() != 1) {
        return false;
    }
    FilterCriteria filterCriteria = filters.get(0);
    // One way is to set visiblity of the item, but this only works for messages and not
    // for lifelines! It's better to create a new frame without the filtered messages.
    boolean found = false;
    if (filterCriteria.getCriteria().isSyncMessageSelected()) {
        for (int i = 0; i < frame.syncMessageCount(); i++) {
            if (filterCriteria.getCriteria().matches(frame.getSyncMessage(i).getName())) {
                frame.getSyncMessage(i).setVisible(false);
                found = true;
            }
        }
        for (int i = 0; i < frame.syncMessageReturnCount(); i++) {
            if (filterCriteria.getCriteria().matches(frame.getSyncMessageReturn(i).getName())) {
                frame.getSyncMessageReturn(i).setVisible(false);
                found = true;
            }
        }
    }
    v.getSDWidget().redraw();
    return found;
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) FilterCriteria(org.eclipse.tracecompass.tmf.ui.views.uml2sd.dialogs.FilterCriteria)

Example 4 with Frame

use of org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame in project tracecompass by tracecompass.

the class TmfUml2SDSyncLoader method resetLoader.

/**
 * Resets loader attributes
 */
protected void resetLoader() {
    fLock.lock();
    try {
        fCurrentTime = null;
        fEvents.clear();
        fCheckPoints.clear();
        fCurrentPage = 0;
        fCurrentFindIndex = 0;
        fFindCriteria = null;
        fFindResults = null;
        fView.setFrameSync(new Frame());
        fFrame = null;
    } finally {
        fLock.unlock();
    }
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame)

Example 5 with Frame

use of org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame in project tracecompass by tracecompass.

the class TmfUml2SDSyncLoader method loadTrace.

/**
 * Method for loading the current selected trace into the view. Sub-class
 * need to override this method to add the view specific implementation.
 */
protected void loadTrace() {
    ITmfEventRequest indexRequest = null;
    fLock.lock();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        final Job job = new IndexingJob("Indexing " + getName() + "...");
        job.setUser(false);
        job.schedule();
        indexRequest = fIndexRequest;
        cancelOngoingRequests();
        TmfTimeRange window = TmfTimeRange.ETERNITY;
        fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, 0, ITmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.BACKGROUND) {

            private ITmfTimestamp fFirstTime = null;

            private ITmfTimestamp fLastTime = null;

            private int fNbSeqEvents = 0;

            private final List<ITmfSyncSequenceDiagramEvent> fSdEvents = new ArrayList<>(MAX_NUM_OF_MSG);

            @Override
            public void handleData(ITmfEvent event) {
                super.handleData(event);
                ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
                ITmfTimestamp firstTime = fFirstTime;
                ITmfTimestamp lastTime = fLastTime;
                if (sdEvent != null) {
                    ++fNbSeqEvents;
                    if (firstTime == null) {
                        firstTime = event.getTimestamp();
                        fFirstTime = firstTime;
                    }
                    lastTime = event.getTimestamp();
                    fLastTime = lastTime;
                    if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
                        fLock.lock();
                        try {
                            fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                            if (fView != null) {
                                fView.updateCoolBar();
                            }
                        } finally {
                            fLock.unlock();
                        }
                        fFirstTime = null;
                    }
                    if (fNbSeqEvents > MAX_NUM_OF_MSG) {
                        // page is full
                        return;
                    }
                    fSdEvents.add(sdEvent);
                    if (fNbSeqEvents == MAX_NUM_OF_MSG) {
                        fillCurrentPage(fSdEvents);
                    }
                }
            }

            @Override
            public void handleSuccess() {
                final ITmfTimestamp firstTime = fFirstTime;
                final ITmfTimestamp lastTime = fLastTime;
                if ((firstTime != null) && (lastTime != null)) {
                    fLock.lock();
                    try {
                        fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                        if (fView != null) {
                            fView.updateCoolBar();
                        }
                    } finally {
                        fLock.unlock();
                    }
                }
                if (fNbSeqEvents <= MAX_NUM_OF_MSG) {
                    fillCurrentPage(fSdEvents);
                }
                super.handleSuccess();
            }

            @Override
            public void handleCompleted() {
                if (fEvents.isEmpty()) {
                    fFrame = new Frame();
                    // make sure that view is not null when setting frame
                    SDView sdView;
                    fLock.lock();
                    try {
                        sdView = fView;
                    } finally {
                        fLock.unlock();
                    }
                    if (sdView != null) {
                        sdView.setFrameSync(fFrame);
                    }
                }
                super.handleCompleted();
                job.cancel();
            }
        };
    } finally {
        fLock.unlock();
    }
    if (indexRequest != null && !indexRequest.isCompleted()) {
        indexRequest.cancel();
    }
    resetLoader();
    fTrace.sendRequest(fIndexRequest);
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfSyncSequenceDiagramEvent(org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Job(org.eclipse.core.runtime.jobs.Job) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) SDView(org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView)

Aggregations

Frame (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame)7 ArrayList (java.util.ArrayList)3 ITmfSyncSequenceDiagramEvent (org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent)2 SDView (org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView)2 Lifeline (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Lifeline)2 HashMap (java.util.HashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Job (org.eclipse.core.runtime.jobs.Job)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)1 SWTBotCanvas (org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas)1 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)1 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)1 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)1 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)1 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)1 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)1 AsyncMessageReturn (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.AsyncMessageReturn)1 BasicExecutionOccurrence (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence)1 EllipsisMessage (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.EllipsisMessage)1