/**********************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
import java.util.ArrayList;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent;
import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent;
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+
/**
* Returns the current time if available else null.
*
* @return the current time if available else null
+ * @since 2.0
*/
public ITmfTimestamp getCurrentTime() {
fLock.lock();
@TmfSignalHandler
public void traceSelected(TmfTraceSelectedSignal signal) {
+ ITmfEventRequest indexRequest = null;
fLock.lock();
try {
// Update the trace reference
job.setUser(false);
job.schedule();
- if (fIndexRequest != null && !fIndexRequest.isCompleted()) {
- fIndexRequest.cancel();
- }
+ indexRequest = fIndexRequest;
cancelOngoingRequests();
- resetLoader();
TmfTimeRange window = TmfTimeRange.ETERNITY;
public void handleData(ITmfEvent event) {
super.handleData(event);
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
++fNbSeqEvents;
}
};
- fTrace.sendRequest(fIndexRequest);
} finally {
fLock.unlock();
}
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
+ resetLoader();
+ fTrace.sendRequest(fIndexRequest);
}
if (signal.getTrace() != fTrace) {
return;
}
+ ITmfEventRequest indexRequest = null;
fLock.lock();
try {
- if (fIndexRequest != null) {
- if (!fIndexRequest.isCompleted()) {
- fIndexRequest.cancel();
- }
- fIndexRequest = null;
- }
+ indexRequest = fIndexRequest;
+ fIndexRequest = null;
cancelOngoingRequests();
}
FilterListDialog.deactivateSavedGlobalFilters();
-
- resetLoader();
} finally {
fTrace = null;
fLock.unlock();
}
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
+
+ resetLoader();
}
/**
@Override
public void dispose() {
super.dispose();
+ ITmfEventRequest indexRequest = null;
fLock.lock();
try {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
window.getSelectionService().removePostSelectionListener(this);
}
- if (fIndexRequest != null) {
- if (!fIndexRequest.isCompleted()) {
- fIndexRequest.cancel();
- }
- fIndexRequest = null;
- }
+ indexRequest = fIndexRequest;
+ fIndexRequest = null;
cancelOngoingRequests();
fView.setSDFindProvider(null);
} finally {
fLock.unlock();
}
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
}
/*
*/
protected void cancelOngoingRequests() {
fLock.lock();
+ ITmfEventRequest pageRequest = null;
try {
// Cancel the search thread
if (fFindJob != null) {
fFindCriteria = null;
fCurrentFindIndex = 0;
- if (fPageRequest != null) {
- if (!fPageRequest.isCompleted()) {
- fPageRequest.cancel();
- }
- fPageRequest = null;
- }
+ pageRequest = fPageRequest;
+ fPageRequest = null;
} finally {
fLock.unlock();
}
+ if (pageRequest != null && !pageRequest.isCompleted()) {
+ pageRequest.cancel();
+ }
}
/**
public void handleData(ITmfEvent event) {
super.handleData(event);
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
fSdEvent.add(sdEvent);
*
* @param time The timestamp
* @return page that contains the time
+ * @since 2.0
*/
protected int getPage(ITmfTimestamp time) {
int page;
*
* @param startTime The start time of time range.
* @return the time range
+ * @since 2.0
*/
protected TmfTimeRange getSignalTimeRange(ITmfTimestamp startTime) {
fLock.lock();
*
* @param findCriteria The search criteria
* @param window Time range to search in
+ * @since 2.0
*/
public SearchJob(Criteria findCriteria, TmfTimeRange window) {
super(Messages.TmfUml2SDSyncLoader_SearchJobDescrition);
return;
}
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
* Returns timestamp of found time.
*
* @return timestamp of found time.
+ * @since 2.0
*/
public ITmfTimestamp getFoundTime() {
return fFoundTime;
*
* @param tmfEvent Event to parse for sequence diagram event details
* @return sequence diagram event if details are available else null
+ * @since 2.0
*/
- protected ITmfSyncSequenceDiagramEvent getSequnceDiagramEvent(ITmfEvent tmfEvent){
+ protected ITmfSyncSequenceDiagramEvent getSequenceDiagramEvent(ITmfEvent tmfEvent){
//type = .*RECEIVE.* or .*SEND.*
//content = sender:<sender name>:receiver:<receiver name>,signal:<signal name>
String eventType = tmfEvent.getType().toString();
- if (eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeReceive)) {
- Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSender);
- Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldReceiver);
- Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSignal);
+ if (eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeReceive)) {
+ Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSender);
+ Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldReceiver);
+ Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSignal);
if ((sender instanceof ITmfEventField) && (receiver instanceof ITmfEventField) && (name instanceof ITmfEventField)) {
ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent,
((ITmfEventField) sender).getValue().toString(),