use of org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent in project tracecompass by tracecompass.
the class TmfUml2SDSyncLoader method moveToPage.
/**
* Moves to a certain page.
*
* @param notifyAll
* true to broadcast time range signal to other signal handlers
* else false
*/
protected void moveToPage(boolean notifyAll) {
TmfTimeRange window = null;
fLock.lock();
try {
// Safety check
if (fCurrentPage > fCheckPoints.size()) {
return;
}
window = fCheckPoints.get(fCurrentPage);
} finally {
fLock.unlock();
}
if (window == null) {
window = TmfTimeRange.ETERNITY;
}
fPageRequest = new TmfEventRequest(ITmfEvent.class, window, 0, ITmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.FOREGROUND) {
private final List<ITmfSyncSequenceDiagramEvent> fSdEvent = new ArrayList<>();
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
fSdEvent.add(sdEvent);
}
}
@Override
public void handleSuccess() {
fillCurrentPage(fSdEvent);
super.handleSuccess();
}
};
fTrace.sendRequest(fPageRequest);
if (notifyAll) {
TmfTimeRange timeRange = getSignalTimeRange(window.getStartTime());
broadcast(new TmfWindowRangeUpdatedSignal(this, timeRange, fTrace));
}
}
use of org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent 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);
}
use of org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent in project tracecompass by tracecompass.
the class TmfUml2SDSyncLoader method fillCurrentPage.
/**
* Fills current page with sequence diagram content.
*
* @param events
* sequence diagram events
*/
protected void fillCurrentPage(List<ITmfSyncSequenceDiagramEvent> events) {
fLock.lock();
try {
fEvents = new ArrayList<>(events);
if (fView != null && !events.isEmpty()) {
fView.toggleWaitCursorAsync(true);
}
} finally {
fLock.unlock();
}
final Frame frame = new Frame();
if (!events.isEmpty()) {
Map<String, Lifeline> nodeToLifelineMap = new HashMap<>();
frame.setName(Messages.TmfUml2SDSyncLoader_FrameName);
for (int i = 0; i < events.size(); i++) {
ITmfSyncSequenceDiagramEvent sdEvent = events.get(i);
if ((nodeToLifelineMap.get(sdEvent.getSender()) == null) && (!filterLifeLine(sdEvent.getSender()))) {
Lifeline lifeline = new Lifeline();
lifeline.setName(sdEvent.getSender());
nodeToLifelineMap.put(sdEvent.getSender(), lifeline);
frame.addLifeLine(lifeline);
}
if ((nodeToLifelineMap.get(sdEvent.getReceiver()) == null) && (!filterLifeLine(sdEvent.getReceiver()))) {
Lifeline lifeline = new Lifeline();
lifeline.setName(sdEvent.getReceiver());
nodeToLifelineMap.put(sdEvent.getReceiver(), lifeline);
frame.addLifeLine(lifeline);
}
}
int eventOccurence = 1;
for (int i = 0; i < events.size(); i++) {
ITmfSyncSequenceDiagramEvent sdEvent = events.get(i);
// Check message filter
if (filterMessage(sdEvent)) {
continue;
}
// Set the message sender and receiver
Lifeline startLifeline = nodeToLifelineMap.get(sdEvent.getSender());
Lifeline endLifeline = nodeToLifelineMap.get(sdEvent.getReceiver());
// Check if any of the lifelines were filtered
if ((startLifeline == null) || (endLifeline == null)) {
continue;
}
int tmp = Math.max(startLifeline.getEventOccurrence(), endLifeline.getEventOccurrence());
eventOccurence = Math.max(eventOccurence, tmp);
startLifeline.setCurrentEventOccurrence(eventOccurence);
endLifeline.setCurrentEventOccurrence(eventOccurence);
TmfSyncMessage message = new TmfSyncMessage(sdEvent, eventOccurence++);
message.setStartLifeline(startLifeline);
message.setEndLifeline(endLifeline);
message.setTime(sdEvent.getStartTime());
// add the message to the frame
frame.addMessage(message);
}
fLock.lock();
try {
if (!fView.getSDWidget().isDisposed()) {
fView.getSDWidget().getDisplay().asyncExec(() -> {
fLock.lock();
try {
// check if view was disposed in the meanwhile
if ((fView != null) && (!fView.getSDWidget().isDisposed())) {
fFrame = frame;
fView.setFrame(fFrame);
if (fCurrentTime != null) {
moveToMessageInPage();
}
if (fFindCriteria != null) {
find(fFindCriteria);
}
fView.toggleWaitCursorAsync(false);
}
} finally {
fLock.unlock();
}
});
}
} finally {
fLock.unlock();
}
}
}
use of org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent in project tracecompass by tracecompass.
the class TmfUml2SDSyncLoader method getSequenceDiagramEvent.
/**
* Returns sequence diagram event if details in given event are available
* else null.
*
* @param tmfEvent
* Event to parse for sequence diagram event details
* @return sequence diagram event if details are available else null
*/
protected ITmfSyncSequenceDiagramEvent getSequenceDiagramEvent(ITmfEvent tmfEvent) {
// type = .*RECEIVE.* or .*SEND.*
// content = sender:<sender name>:receiver:<receiver
// name>,signal:<signal name>
String eventName = tmfEvent.getName();
if (eventName.contains(Messages.TmfUml2SDSyncLoader_EventTypeSend) || eventName.contains(Messages.TmfUml2SDSyncLoader_EventTypeReceive)) {
Object sender = tmfEvent.getContent().getFieldValue(Object.class, NonNullUtils.checkNotNull(Messages.TmfUml2SDSyncLoader_FieldSender));
Object receiver = tmfEvent.getContent().getFieldValue(Object.class, NonNullUtils.checkNotNull(Messages.TmfUml2SDSyncLoader_FieldReceiver));
ITmfEventField content = tmfEvent.getContent();
Object name = content.getFieldValue(Object.class, NonNullUtils.checkNotNull(Messages.TmfUml2SDSyncLoader_FieldSignal));
if ((sender != null) && (receiver != null) && (name != null)) {
ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent, sender.toString(), receiver.toString(), name.toString());
return sdEvent;
}
}
return null;
}
Aggregations