/*******************************************************************************
* Copyright (c) 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Mathieu Denis (mathieu.denis@polymtl.ca) - Initial API and Implementation
* Bernd Hufmann - Fixed header and warnings
// ------------------------------------------------------------------------
private final static String LEVEL_COLUMN = org.eclipse.linuxtools.tmf.ui.views.statistics.Messages.TmfStatisticsView_LevelColumn;
private final static String EVENTS_COUNT_COLUMN = org.eclipse.linuxtools.tmf.ui.views.statistics.Messages.TmfStatisticsView_NbEventsColumn;
-
+
private TmfBaseColumnDataProvider provider;
private String fTestName;
private final String fContext = "UnitTest";
-
+
private final String fTypeId1 = "Some type1";
private final String fTypeId2 = "Some type2";
assertNotNull("getColumnData", columnData);
assertNotNull("getColumnData", columnData.getHeader());
assertNotNull("getColumnData", columnData.getTooltip());
-
+
// Testing labelProvider
ColumnLabelProvider labelProvider = columnData.getLabelProvider();
if (columnData.getHeader().compareTo(LEVEL_COLUMN) == 0) {
assertNull("getColumnData", percentProvider);
} else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
double percentage = (double) treeNode1.getValue().nbEvents / parentNode.getValue().nbEvents;
- assertEquals("getColumnData", (double) percentage, (double) percentProvider.getPercentage(treeNode1));
+ assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1));
}
}
}
/*******************************************************************************
* Copyright (c) 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Mathieu Denis (mathieu.denis@polymtl.ca) - Initial design and implementation
*******************************************************************************/
if (parent == null) {
return 0;
- } else {
- return (double) node.getValue().nbEvents / parent.getValue().nbEvents;
}
+ return (double) node.getValue().nbEvents / parent.getValue().nbEvents;
}
};
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load;
private final static String SDVIEW_WITH_MULTIPLE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView2Loaders"; //$NON-NLS-1$
private final static String TEST_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.tests.uml2sd.load.TestLoaders"; //$NON-NLS-1$
private final static String TMF_UML2SD_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader"; //$NON-NLS-1$
-
+
private static final String LOADER_TAG = "uml2SDLoader"; //$NON-NLS-1$
private static final String LOADER_PREFIX = LOADER_TAG + "."; //$NON-NLS-1$
try {
/*
- * Test creation of a loader (one per SD view)
+ * Test creation of a loader (one per SD view)
*/
-
+
// Open view
// Note this will create the default loader!
view = (SDView)PlatformUI.getWorkbench()
IUml2SDLoader defaultLoader = LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_ONE_LOADER, view);
assertNotNull("testLoaderManager", defaultLoader);
-
+
// Test createLoader where loader doesn't exist
assertNull("testLoaderManager", LoadersManager.getInstance().createLoader("blabla", view));
- // Test createLoader
+ // Test createLoader
IUml2SDLoader loader = LoadersManager.getInstance().createLoader(TEST_LOADER_CLASS_NAME, view);
assertNotNull("testLoaderManager", loader);
- assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
+ assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
assertEquals("testLoaderManager", loader, LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_ONE_LOADER));
-
- // compare loader and default loader. Even if they are the same class, they are different instances
+
+ // compare loader and default loader. Even if they are the same class, they are different instances
assertFalse("testLoaderManager", loader==defaultLoader);
// test getCurrentLoader(viewId, view)
// Well, this is the only way test which loader is set
assertEquals("testLoaderManager", "Sequence Diagram - First Page", view.getFrame().getName());
-
+
// Test view == null
assertNull("testLoaderManager", LoadersManager.getInstance().createLoader(TEST_LOADER_CLASS_NAME, null));
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(view);
/*
- * Test creation of loaders with re-uses the same SD view
+ * Test creation of loaders with re-uses the same SD view
*/
// test that view restores the previous associated loader
loader = LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_MULTIPLE_LOADER, view);
assertNotNull("testLoaderManager", loader);
- assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
+ assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
assertEquals("testLoaderManager", loader, LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_MULTIPLE_LOADER));
- // Test createLoader for loader with class name TMF_UML2SD_LOADER_CLASS_NAME
+ // Test createLoader for loader with class name TMF_UML2SD_LOADER_CLASS_NAME
loader = LoadersManager.getInstance().createLoader(TMF_UML2SD_LOADER_CLASS_NAME, view);
assertNotNull("testLoaderManager", loader);
- assertEquals("testLoaderManager", "Component Interactions", loader.getTitleString());
+ assertEquals("testLoaderManager", "Component Interactions", loader.getTitleString());
assertEquals("testLoaderManager", loader, LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_MULTIPLE_LOADER));
// Verify if the correct loader is stored in the preferences as the current loader for this view
assertEquals("testLoaderManager", TMF_UML2SD_LOADER_CLASS_NAME, getSavedLoader(SDVIEW_WITH_MULTIPLE_LOADER));
- // Test createLoader for loader with class name TEST_LOADER_CLASS_NAME
+ // Test createLoader for loader with class name TEST_LOADER_CLASS_NAME
loader = LoadersManager.getInstance().createLoader(TEST_LOADER_CLASS_NAME, view);
assertNotNull("testLoaderManager", loader);
- assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
+ assertEquals("testLoaderManager", "Test Loader", loader.getTitleString());
assertEquals("testLoaderManager", loader, LoadersManager.getInstance().getCurrentLoader(SDVIEW_WITH_MULTIPLE_LOADER));
// Verify if the correct loader is stored in the preferences as the current loader for this view
}
@SuppressWarnings("unused")
- private void delay(long waitTimeMillis) {
+ private static void delay(long waitTimeMillis) {
Display display = Display.getCurrent();
if (display != null) {
long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
}
}
- private String getSavedLoader(String viewId) {
+ private static String getSavedLoader(String viewId) {
IPreferenceStore p = Activator.getDefault().getPreferenceStore();
return p.getString(LOADER_PREFIX + viewId);
}
/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Bernd Hufmann - Initial API and implementation
*******************************************************************************/
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
/**
- * Class to implement that certain signals are sent as well as are sent with correct content.
+ * Class to implement that certain signals are sent as well as are sent with correct content.
*/
public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignalValidator {
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public Uml2SDSignalValidator() {
}
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@TmfSignalHandler
public void synchToTime(TmfTimeSynchSignal signal) {
- // Set results so that it can be validated in the test case
+ // Set results so that it can be validated in the test case
setSignalReceived(true);
setSourceError(getSource() != signal.getSource());
setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
@TmfSignalHandler
public void synchToTimeRange(TmfRangeSynchSignal signal) {
- // Set results so that it can be validated in the test case
+ // Set results so that it can be validated in the test case
setSignalReceived(true);
setSourceError(getSource() != signal.getSource());
setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
}
-
+
@TmfSignalHandler
public void startSynch(TmfStartSynchSignal signal) {
fSignalDepth++;
- // make sure that the signal which is send by the loader class is not handled by the loader class
+ // make sure that the signal which is send by the loader class is not handled by the loader class
// after receiving it. i.e. it must not trigger a another signal
-
+
// Set results so that it can be validated in the test case
setSignalError(fSignalDepth > 1);
}
public void endSynch(TmfEndSynchSignal signal) {
fSignalDepth = fSignalDepth > 0 ? fSignalDepth - 1 : 0;
}
-
+
@Override
public boolean isSignalReceived() {
return fIsSignalReceived;
@Override
public boolean isSignalError() {
return fIsSignalError;
- }
-
+ }
+
@Override
public void setSignalError(boolean fIsSignalError) {
this.fIsSignalError = fIsSignalError;
public void setSource(Object source) {
fSource = source;
}
-
+
@Override
public TmfTimestamp getCurrentTime() {
return fCurrentTimestamp;
public void setCurrentRange(TmfTimeRange currentRange) {
fCurrentTimeRange = currentRange == null ? null : new TmfTimeRange(currentRange);
}
-};
+}
* @param page number to set
*/
public void setPage(final int page) {
- fLoader.pageNumberChanged(page);;
+ fLoader.pageNumberChanged(page);
fLoader.waitForCompletion();
delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
}
}
}
- for (int i = 0; i < testFrame.lifeLinesCount(); i++)
+ for (int i = 0; i < testFrame.lifeLinesCount(); i++) {
if (i > 0) {
ExecutionOccurrence occ = new ExecutionOccurrence();
occ.setStartOccurrence(testFrame.getSyncMessage(i).getEventOccurrence() + 1);
testFrame.getLifeline(i).addExecution(occ);
occ.setName("******************* Execution Occurance TEST ****************");
}
+ }
Stop s = new Stop();
s.setLifeline(testFrame.getLifeline(1));
occ.setEndOccurrence(testFrame.getSyncMessageReturn(i - 1).getEventOccurrence());
testFrame.getLifeline(0).addExecution(occ);
}
- }
+ }
v.setFrame(testFrame);
}
public boolean find(Criteria toSearch) {
Frame frame = v.getFrame();
- if (frame == null)
+ if (frame == null) {
return false;
+ }
if (findResults == null || findCriteria == null || !findCriteria.compareTo(toSearch)) {
findResults = new ArrayList<GraphNode>();
findCriteria = toSearch;
if (findCriteria.isLifeLineSelected()) {
for (int i = 0; i < frame.lifeLinesCount(); i++) {
- if (findCriteria.matches(frame.getLifeline(i).getName()))
+ if (findCriteria.matches(frame.getLifeline(i).getName())) {
findResults.add(frame.getLifeline(i));
+ }
}
}
ArrayList<GraphNode> msgs = new ArrayList<GraphNode>();
if (findCriteria.isSyncMessageSelected()) {
for (int i = 0; i < frame.syncMessageCount(); i++) {
- if (findCriteria.matches(frame.getSyncMessage(i).getName()))
+ 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()))
+ for (int i = 0; i < frame.syncMessageReturnCount(); i++) {
+ if (findCriteria.matches(frame.getSyncMessageReturn(i).getName())) {
msgs.add(frame.getSyncMessageReturn(i));
+ }
+ }
}
// if(msgs.size() > 0) {
msgs = new ArrayList<GraphNode>();
if (findCriteria.isAsyncMessageSelected()) {
- for (int i = 0; i < frame.asyncMessageCount(); i++)
- if (findCriteria.matches(frame.getAsyncMessage(i).getName()))
+ 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()))
+ for (int i = 0; i < frame.asyncMessageReturnCount(); i++) {
+ if (findCriteria.matches(frame.getAsyncMessageReturn(i).getName())) {
msgs.add(frame.getAsyncMessageReturn(i));
+ }
+ }
}
// if(msgs.size() > 0) {
@SuppressWarnings("rawtypes")
List selection = v.getSDWidget().getSelection();
- if (selection != null && selection.size() == 1)
+ if (selection != null && selection.size() == 1) {
currentFindIndex = findResults.indexOf(selection.get(0)) + 1;
- else
+ } else {
currentFindIndex = 0;
+ }
} else {
currentFindIndex++;
}
if (findResults.size() > currentFindIndex) {
- GraphNode current = (GraphNode) findResults.get(currentFindIndex);
+ GraphNode current = findResults.get(currentFindIndex);
v.getSDWidget().moveTo(current);
return true;
- } else {
- // return notFoundYet(findCriteria); // search in other page
- return false;
}
- // return false;
+ // return notFoundYet(findCriteria); // search in other page
+ return false;
}
@Override
}
}
- for (int i = 0; i < frame.syncMessageReturnCount(); i++)
+ 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();
@Override
public void dispose() {
- if (img != null)
+ if (img != null) {
img.dispose();
+ }
}
}
public void firstPage() {
page = 0;
createFrame();
-
+
}
@Override
/*******************************************************************************\r
* Copyright (c) 2009, 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
*******************************************************************************/\r
// Data\r
// ========================================================================\r
private int count = 0;\r
- private TraceStrings[] traceNames;\r
+ private final TraceStrings[] traceNames;\r
private static final long msTons = 1000000;\r
- private Long timeRef = new Date().getTime() * msTons;\r
+ private final Long timeRef = new Date().getTime() * msTons;\r
\r
// ========================================================================\r
// Constructor\r
}\r
return traceArr;\r
}\r
- \r
+\r
/**\r
* 5000 Events per Trace.\r
* @param number\r
return traceArr;\r
}\r
\r
- private void create5000Events(TraceImpl trace) {\r
+ private static void create5000Events(TraceImpl trace) {\r
EventImpl event;\r
Long eventTime;\r
int numEvents = 5000;\r
long sTime = trace.getStartTime();\r
long eTime = trace.getEndTime();\r
- long duration = (long) ((eTime - sTime)/numEvents);\r
+ long duration = (eTime - sTime)/numEvents;\r
for (int i = 0; i < numEvents; i++) {\r
eventTime = sTime + (i * duration);\r
// eventTime = timeRef + (5 * (count % 4) + (5 * (int) (i/2) ));\r
long duration = 0;\r
for (int i = 0; i < numEvents; i++) {\r
eventTime = timeRef + msTons * i + (5 * msTons * count) + (5 * i);\r
- duration = msTons + i * msTons + (long) ((i % 4));\r
+ duration = msTons + i * msTons + ((i % 4));\r
// duration = i + (long) ((i % 4));\r
event = new EventImpl(eventTime, trace, getEventType(i));\r
event.setDuration(duration);\r
}\r
}\r
\r
- private EventImpl.Type getEventType(int val) {\r
- if (EventImpl.Type.ALARM.ordinal() == val)\r
- return EventImpl.Type.ALARM;\r
- if (EventImpl.Type.ERROR.ordinal() == val)\r
- return EventImpl.Type.ERROR;\r
- if (EventImpl.Type.EVENT.ordinal() == val)\r
- return EventImpl.Type.EVENT;\r
- if (EventImpl.Type.INFORMATION.ordinal() == val)\r
- return EventImpl.Type.INFORMATION;\r
- if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val)\r
- return EventImpl.Type.TIMEADJUSTMENT;\r
- if (EventImpl.Type.WARNING.ordinal() == val)\r
- return EventImpl.Type.WARNING;\r
- if (EventImpl.Type.INFO1.ordinal() == val)\r
- return EventImpl.Type.INFO1;\r
- if (EventImpl.Type.INFO2.ordinal() == val)\r
- return EventImpl.Type.INFO2;\r
- if (EventImpl.Type.INFO3.ordinal() == val)\r
- return EventImpl.Type.INFO3;\r
- if (EventImpl.Type.INFO4.ordinal() == val)\r
- return EventImpl.Type.INFO4;\r
- if (EventImpl.Type.INFO5.ordinal() == val)\r
- return EventImpl.Type.INFO5;\r
- if (EventImpl.Type.INFO6.ordinal() == val)\r
- return EventImpl.Type.INFO6;\r
- if (EventImpl.Type.INFO7.ordinal() == val)\r
- return EventImpl.Type.INFO7;\r
- if (EventImpl.Type.INFO8.ordinal() == val)\r
- return EventImpl.Type.INFO8;\r
- if (EventImpl.Type.INFO9.ordinal() == val)\r
- return EventImpl.Type.INFO9;\r
- return EventImpl.Type.UNKNOWN;\r
- }\r
+ private static EventImpl.Type getEventType(int val) {\r
+ if (EventImpl.Type.ALARM.ordinal() == val) {\r
+ return EventImpl.Type.ALARM;\r
+ }\r
+ if (EventImpl.Type.ERROR.ordinal() == val) {\r
+ return EventImpl.Type.ERROR;\r
+ }\r
+ if (EventImpl.Type.EVENT.ordinal() == val) {\r
+ return EventImpl.Type.EVENT;\r
+ }\r
+ if (EventImpl.Type.INFORMATION.ordinal() == val) {\r
+ return EventImpl.Type.INFORMATION;\r
+ }\r
+ if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) {\r
+ return EventImpl.Type.TIMEADJUSTMENT;\r
+ }\r
+ if (EventImpl.Type.WARNING.ordinal() == val) {\r
+ return EventImpl.Type.WARNING;\r
+ }\r
+ if (EventImpl.Type.INFO1.ordinal() == val) {\r
+ return EventImpl.Type.INFO1;\r
+ }\r
+ if (EventImpl.Type.INFO2.ordinal() == val) {\r
+ return EventImpl.Type.INFO2;\r
+ }\r
+ if (EventImpl.Type.INFO3.ordinal() == val) {\r
+ return EventImpl.Type.INFO3;\r
+ }\r
+ if (EventImpl.Type.INFO4.ordinal() == val) {\r
+ return EventImpl.Type.INFO4;\r
+ }\r
+ if (EventImpl.Type.INFO5.ordinal() == val) {\r
+ return EventImpl.Type.INFO5;\r
+ }\r
+ if (EventImpl.Type.INFO6.ordinal() == val) {\r
+ return EventImpl.Type.INFO6;\r
+ }\r
+ if (EventImpl.Type.INFO7.ordinal() == val) {\r
+ return EventImpl.Type.INFO7;\r
+ }\r
+ if (EventImpl.Type.INFO8.ordinal() == val) {\r
+ return EventImpl.Type.INFO8;\r
+ }\r
+ if (EventImpl.Type.INFO9.ordinal() == val) {\r
+ return EventImpl.Type.INFO9;\r
+ }\r
+ return EventImpl.Type.UNKNOWN;\r
+ }\r
\r
private void loadTraceNameStrings() {\r
traceNames[0] = new TraceStrings();\r
traceNames[9] = new TraceStrings();\r
traceNames[9].name = "TE Log - TATA BSC14";\r
traceNames[9].classNmme = "Board 14, SPO";\r
- \r
+\r
traceNames[10] = new TraceStrings();\r
traceNames[10].name = "INFO 1";\r
traceNames[10].classNmme = "All Boards";\r
traceNames[14] = new TraceStrings();\r
traceNames[14].name = "MISC2";\r
traceNames[14].classNmme = "Board 11";\r
- \r
+\r
traceNames[15] = new TraceStrings();\r
traceNames[15].name = "MISC3";\r
traceNames[15].classNmme = "Board 23";\r
/*******************************************************************************
* Copyright (c) 2009, 2010 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
*******************************************************************************/
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
*/
class TreeObject implements IAdaptable {
- private String name;
+ private final String name;
private TreeParent parent;
public TreeObject(String name) {
}
class TreeParent extends TreeObject {
- private ArrayList<TreeObject> children;
+ private final ArrayList<TreeObject> children;
public TreeParent(String name) {
super(name);
}
}
- class ViewContentProvider implements IStructuredContentProvider,
- ITreeContentProvider {
+ class ViewContentProvider implements ITreeContentProvider {
private TreeParent invisibleRoot;
@Override
@Override
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- if (invisibleRoot == null)
- initialize();
+ if (invisibleRoot == null) {
+ initialize();
+ }
return getChildren(invisibleRoot);
}
return getChildren(parent);
@Override
public boolean hasChildren(Object parent) {
- if (parent instanceof TreeParent)
- return ((TreeParent) parent).hasChildren();
+ if (parent instanceof TreeParent) {
+ return ((TreeParent) parent).hasChildren();
+ }
return false;
}
@Override
public Image getImage(Object obj) {
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
- if (obj instanceof TreeParent)
- imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ if (obj instanceof TreeParent) {
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ }
return PlatformUI.getWorkbench().getSharedImages().getImage(
imageKey);
}
private TimeGraphViewer getActiveTsfCtrl() {
TimeGraphViewer inFocusViewer = null;
- if (tsfviewer.isInFocus())
- inFocusViewer = tsfviewer;
- else if (tsfviewer2.isInFocus())
- inFocusViewer = tsfviewer2;
+ if (tsfviewer.isInFocus()) {
+ inFocusViewer = tsfviewer;
+ } else if (tsfviewer2.isInFocus()) {
+ inFocusViewer = tsfviewer2;
+ }
return inFocusViewer;
}
@Override
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
- if (event == null)
- return;
- Object source = event.getSource();
- if (source == null || !(source instanceof TimeGraphViewer)) {
- return;
- }
-
- if (event instanceof TimeGraphRangeUpdateEvent) {
- TimeGraphRangeUpdateEvent rEvent = (TimeGraphRangeUpdateEvent) event;
- TimeGraphViewer rViewer = (TimeGraphViewer) event
- .getSource();
- TimeGraphViewer synchViewer = null;
- // Synchronize viewer selections if Enabled,
- // make sure the selection does not go in loops
- if (tsfviewer == rViewer) {
- synchViewer = tsfviewer2;
- } else {
- synchViewer = tsfviewer;
- }
+ if (event == null) {
+ return;
+ }
+ Object source = event.getSource();
+ if (source == null || !(source instanceof TimeGraphViewer)) {
+ return;
+ }
+ TimeGraphRangeUpdateEvent rEvent = event;
+ TimeGraphViewer rViewer = (TimeGraphViewer) event
+ .getSource();
+ TimeGraphViewer synchViewer = null;
+ // Synchronize viewer selections if Enabled,
+ // make sure the selection does not go in loops
+ if (tsfviewer == rViewer) {
+ synchViewer = tsfviewer2;
+ } else {
+ synchViewer = tsfviewer;
+ }
- synchViewer.setSelectVisTimeWindow(rEvent.getStartTime(), rEvent
- .getEndTime(), source);
- }
- }
+ synchViewer.setSelectVisTimeWindow(rEvent.getStartTime(), rEvent
+ .getEndTime(), source);
+ }
/**
* Obtains the remainder fraction on unit Seconds of the entered value in
* nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds can
* be obtain by removing the last 9 digits: 1241207054 the fractional
* portion of seconds, expressed in ns is: 171080214
- *
+ *
* @param v
* @return
*/
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
import org.eclipse.jface.dialogs.Dialog;\r
import org.eclipse.jface.dialogs.IDialogConstants;\r
import org.eclipse.jface.dialogs.MessageDialog;\r
+import org.eclipse.jface.window.Window;\r
import org.eclipse.jface.wizard.WizardDialog;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
Button deleteButton;\r
Button importButton;\r
Button exportButton;\r
- \r
+\r
public ManageCustomParsersDialog(Shell parent) {\r
super(parent);\r
setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());\r
protected Control createDialogArea(Composite parent) {\r
getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader);\r
getShell().setImage(image);\r
- \r
+\r
Composite composite = (Composite) super.createDialogArea(parent);\r
composite.setLayout(new GridLayout(2, false));\r
\r
lcgl.marginHeight = 0;\r
lcgl.marginWidth = 0;\r
listContainer.setLayout(lcgl);\r
- \r
+\r
Composite radioContainer = new Composite(listContainer, SWT.NONE);\r
GridLayout rcgl = new GridLayout(2, true);\r
rcgl.marginHeight = 0;\r
rcgl.marginWidth = 0;\r
radioContainer.setLayout(rcgl);\r
- \r
+\r
txtButton = new Button(radioContainer, SWT.RADIO);\r
txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);\r
txtButton.setSelection(true);\r
public void widgetSelected(SelectionEvent e) {\r
fillParserList();\r
}});\r
- \r
+\r
xmlButton = new Button(radioContainer, SWT.RADIO);\r
xmlButton.setText("XML"); //$NON-NLS-1$\r
xmlButton.addSelectionListener(new SelectionListener(){\r
public void widgetSelected(SelectionEvent e) {\r
fillParserList();\r
}});\r
- \r
+\r
parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);\r
parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
parserList.addSelectionListener(new SelectionListener(){\r
exportButton.setEnabled(true);\r
}\r
}});\r
- \r
+\r
Composite buttonContainer = new Composite(composite, SWT.NULL);\r
buttonContainer.setLayout(new GridLayout());\r
buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));\r
}\r
if (dialog != null) {\r
dialog.open();\r
- if (dialog.getReturnCode() == Dialog.OK) {\r
+ if (dialog.getReturnCode() == Window.OK) {\r
fillParserList();\r
}\r
}\r
}});\r
- \r
+\r
editButton = new Button(buttonContainer, SWT.PUSH);\r
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);\r
}\r
if (dialog != null) {\r
dialog.open();\r
- if (dialog.getReturnCode() == Dialog.OK) {\r
+ if (dialog.getReturnCode() == Window.OK) {\r
fillParserList();\r
}\r
}\r
}});\r
\r
new Label(buttonContainer, SWT.NONE); // filler\r
- \r
+\r
importButton = new Button(buttonContainer, SWT.PUSH);\r
importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag;\r
public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag;\r
public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;\r
- \r
+\r
public String definitionName;\r
public List<OutputColumn> outputs;\r
public String timeStampOutputFormat;\r
- \r
+\r
public static class OutputColumn {\r
public String name;\r
\r
- public OutputColumn() {};\r
+ public OutputColumn() {}\r
\r
public OutputColumn(String name) {\r
this.name = name;\r
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat);\r
return simpleDateFormat.format(timestamp.getValue());\r
}\r
- \r
+\r
public abstract void save();\r
public abstract void save(String path);\r
}\r
continue;\r
}\r
String name = column.name;\r
- if (column.action == CustomTxtTraceDefinition.ACTION_SET) {\r
+ if (column.action == CustomTraceDefinition.ACTION_SET) {\r
fData.put(name, value);\r
- if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
}\r
- } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {\r
+ } else if (column.action == CustomTraceDefinition.ACTION_APPEND) {\r
String s = fData.get(name);\r
if (s != null) {\r
fData.put(name, s + value);\r
} else {\r
fData.put(name, value);\r
}\r
- if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
if (timeStampInputFormat != null) {\r
fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);\r
fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
}\r
}\r
- } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
+ } else if (column.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
String s = fData.get(name);\r
if (s != null) {\r
fData.put(name, s + " | " + value); //$NON-NLS-1$\r
} else {\r
fData.put(name, value);\r
}\r
- if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
if (timeStampInputFormat != null) {\r
fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
import javax.xml.transform.dom.DOMSource;\r
import javax.xml.transform.stream.StreamResult;\r
\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
import org.w3c.dom.Node;\r
private static final String ACTION_ATTRIBUTE = Messages.CustomTxtTraceDefinition_action;\r
private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;\r
private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn;\r
- \r
+\r
public List<InputLine> inputs;\r
\r
public CustomTxtTraceDefinition() {\r
this("", new ArrayList<InputLine>(0), new ArrayList<OutputColumn>(0), ""); //$NON-NLS-1$ //$NON-NLS-2$\r
- };\r
- \r
+ }\r
+\r
public CustomTxtTraceDefinition(String logtype, List<InputLine> inputs, List<OutputColumn> outputs, String timeStampOutputFormat) {\r
this.definitionName = logtype;\r
this.inputs = inputs;\r
this.outputs = outputs;\r
this.timeStampOutputFormat = timeStampOutputFormat;\r
}\r
- \r
+\r
public static class InputLine {\r
public List<InputData> columns;\r
public Cardinality cardinality;\r
public int level;\r
public InputLine nextInput;\r
public List<InputLine> childrenInputs;\r
- \r
- public InputLine() {};\r
- \r
+\r
+ public InputLine() {}\r
+\r
public InputLine(Cardinality cardinality, String regex, List<InputData> columns) {\r
this.cardinality = cardinality;\r
this.regex = regex;\r
this.columns = columns;\r
}\r
- \r
+\r
public void setRegex(String regex) {\r
this.regex = regex;\r
this.pattern = null;\r
}\r
- \r
+\r
public String getRegex() {\r
return regex;\r
}\r
- \r
+\r
public Pattern getPattern() throws PatternSyntaxException {\r
if (pattern == null) {\r
pattern = Pattern.compile(regex);\r
}\r
return pattern;\r
}\r
- \r
+\r
public void addChild(InputLine input) {\r
if (childrenInputs == null) {\r
childrenInputs = new ArrayList<InputLine>(1);\r
}\r
columns.add(column);\r
}\r
- \r
+\r
public List<InputLine> getNextInputs(Map<InputLine, Integer> countMap) {\r
List<InputLine> nextInputs = new ArrayList<InputLine>();\r
InputLine next = nextInput;\r
}\r
return nextInputs;\r
}\r
- \r
+\r
public int getMinCount() {\r
return cardinality.min;\r
}\r
- \r
+\r
public int getMaxCount() {\r
return cardinality.max;\r
}\r
public String toString() {\r
return regex + " " + cardinality; //$NON-NLS-1$\r
}\r
- \r
+\r
}\r
\r
public static class InputData {\r
public String name;\r
public int action;\r
public String format;\r
- \r
- public InputData() {};\r
- \r
+\r
+ public InputData() {}\r
+\r
public InputData(String name, int action, String format) {\r
this.name = name;\r
this.action = action;\r
this.format = format;\r
}\r
- \r
+\r
public InputData(String name, int action) {\r
this.name = name;\r
this.action = action;\r
public final static Cardinality ONE = new Cardinality(1, 1);\r
public final static Cardinality ONE_OR_MORE = new Cardinality(1, INF);\r
public final static Cardinality ZERO_OR_ONE = new Cardinality(0, 1);\r
- public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF); \r
- \r
- private int min;\r
- private int max;\r
- \r
+ public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF);\r
+\r
+ private final int min;\r
+ private final int max;\r
+\r
public Cardinality(int min, int max) {\r
this.min = min;\r
this.max = max;\r
if (obj == null) {\r
return false;\r
}\r
- if (!(obj instanceof Cardinality)) return false;\r
+ if (!(obj instanceof Cardinality)) {\r
+ return false;\r
+ }\r
Cardinality other = (Cardinality) obj;\r
return (this.min == other.min && this.max == other.max);\r
}\r
}\r
- \r
+\r
@Override\r
public void save() {\r
save(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
}\r
- \r
+\r
@Override\r
public void save(String path) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
DocumentBuilder db = dbf.newDocumentBuilder();\r
- \r
+\r
// The following allows xml parsing without access to the dtd\r
EntityResolver resolver = new EntityResolver () {\r
@Override\r
public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
throw saxparseexception;\r
}});\r
- \r
+\r
Document doc = null;\r
File file = new File(path);\r
if (file.canRead()) {\r
}\r
\r
Element root = doc.getDocumentElement();\r
- \r
+\r
NodeList nodeList = root.getChildNodes();\r
for (int i = 0; i < nodeList.getLength(); i++) {\r
Node node = nodeList.item(i);\r
Element definitionElement = doc.createElement(DEFINITION_ELEMENT);\r
root.appendChild(definitionElement);\r
definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);\r
- \r
+\r
Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);\r
definitionElement.appendChild(formatElement);\r
formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));\r
outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);\r
}\r
}\r
- \r
+\r
Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
\r
DOMSource source = new DOMSource(doc);\r
transformer.transform(source, result);\r
String xmlString = result.getWriter().toString();\r
- \r
+\r
FileWriter writer = new FileWriter(file);\r
writer.write(xmlString);\r
writer.close();\r
\r
private Element createInputLineElement(InputLine inputLine, Document doc) {\r
Element inputLineElement = doc.createElement(INPUT_LINE_ELEMENT);\r
- \r
+\r
Element cardinalityElement = doc.createElement(CARDINALITY_ELEMENT);\r
inputLineElement.appendChild(cardinalityElement);\r
cardinalityElement.setAttribute(MIN_ATTRIBUTE, Integer.toString(inputLine.cardinality.min));\r
cardinalityElement.setAttribute(MAX_ATTRIBUTE, Integer.toString(inputLine.cardinality.max));\r
- \r
+\r
Element regexElement = doc.createElement(REGEX_ELEMENT);\r
inputLineElement.appendChild(regexElement);\r
regexElement.appendChild(doc.createTextNode(inputLine.regex));\r
}\r
}\r
}\r
- \r
+\r
if (inputLine.childrenInputs != null) {\r
for (InputLine childInputLine : inputLine.childrenInputs) {\r
inputLineElement.appendChild(createInputLineElement(childInputLine, doc));\r
}\r
}\r
- \r
+\r
return inputLineElement;\r
}\r
- \r
+\r
public static CustomTxtTraceDefinition[] loadAll() {\r
return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
}\r
- \r
+\r
public static CustomTxtTraceDefinition[] loadAll(String path) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
}\r
return null;\r
}\r
- \r
+\r
public static CustomTxtTraceDefinition extractDefinition(Element definitionElement) {\r
CustomTxtTraceDefinition def = new CustomTxtTraceDefinition();\r
- \r
+\r
def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);\r
- if (def.definitionName == null) return null;\r
- \r
+ if (def.definitionName == null) {\r
+ return null;\r
+ }\r
+\r
NodeList nodeList = definitionElement.getChildNodes();\r
for (int i = 0; i < nodeList.getLength(); i++) {\r
Node node = nodeList.item(i);\r
}\r
return inputLine;\r
}\r
- \r
+\r
public static void delete(String definitionName) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
root.removeChild(node);\r
}\r
}\r
- \r
+\r
Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
\r
DOMSource source = new DOMSource(doc);\r
transformer.transform(source, result);\r
String xmlString = result.getWriter().toString();\r
- \r
+\r
FileWriter writer = new FileWriter(file);\r
writer.write(xmlString);\r
writer.close();\r
}\r
} catch (final IOException e) {\r
Activator.getDefault().logError("Error parsing event. File: " + getPath(), e); //$NON-NLS-1$\r
- \r
+\r
}\r
context.setLocation(NULL_LOCATION);\r
return event;\r
}\r
}\r
\r
- private void readQuote(final StringBuffer buffer, final RandomAccessFile raFile, final char eq) {\r
+ private static void readQuote(final StringBuffer buffer,\r
+ final RandomAccessFile raFile, final char eq) {\r
try {\r
int i;\r
while ((i = raFile.read()) != -1) {\r
}\r
}\r
\r
- private void readComment(final StringBuffer buffer, final RandomAccessFile raFile) {\r
+ private static void readComment(final StringBuffer buffer,\r
+ final RandomAccessFile raFile) {\r
try {\r
int numRead = 0;\r
int i;\r
/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
import javax.xml.transform.dom.DOMSource;\r
import javax.xml.transform.stream.StreamResult;\r
\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
import org.w3c.dom.Node;\r
private static final String ACTION_ATTRIBUTE = Messages.CustomXmlTraceDefinition_action;\r
private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format;\r
private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;\r
- \r
+\r
public InputElement rootInputElement;\r
\r
public CustomXmlTraceDefinition() {\r
this("", null, new ArrayList<OutputColumn>(), ""); //$NON-NLS-1$ //$NON-NLS-2$\r
- };\r
+ }\r
\r
public CustomXmlTraceDefinition(String logtype, InputElement rootElement, List<OutputColumn> outputs, String timeStampOutputFormat) {\r
this.definitionName = logtype;\r
public InputElement parentElement;\r
public InputElement nextElement;\r
public List<InputElement> childElements;\r
- \r
- public InputElement() {};\r
- \r
+\r
+ public InputElement() {}\r
+\r
public InputElement(String elementName, boolean logEntry, String inputName, int inputAction, String inputFormat, List<InputAttribute> attributes) {\r
this.elementName = elementName;\r
this.logEntry = logEntry;\r
this.inputFormat = inputFormat;\r
this.attributes = attributes;\r
}\r
- \r
+\r
public void addAttribute(InputAttribute attribute) {\r
if (attributes == null) {\r
attributes = new ArrayList<InputAttribute>(1);\r
public String inputName;\r
public int inputAction;\r
public String inputFormat;\r
- \r
- public InputAttribute() {};\r
- \r
+\r
+ public InputAttribute() {}\r
+\r
public InputAttribute(String attributeName, String inputName, int inputAction, String inputFormat) {\r
this.attributeName = attributeName;\r
this.inputName = inputName;\r
public void save() {\r
save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
}\r
- \r
+\r
@Override\r
public void save(String path) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
DocumentBuilder db = dbf.newDocumentBuilder();\r
- \r
+\r
// The following allows xml parsing without access to the dtd\r
EntityResolver resolver = new EntityResolver () {\r
@Override\r
public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
throw saxparseexception;\r
}});\r
- \r
+\r
Document doc = null;\r
File file = new File(path);\r
if (file.canRead()) {\r
}\r
\r
Element root = doc.getDocumentElement();\r
- \r
+\r
NodeList nodeList = root.getChildNodes();\r
for (int i = 0; i < nodeList.getLength(); i++) {\r
Node node = nodeList.item(i);\r
Element definitionElement = doc.createElement(DEFINITION_ELEMENT);\r
root.appendChild(definitionElement);\r
definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);\r
- \r
+\r
Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);\r
definitionElement.appendChild(formatElement);\r
formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));\r
outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);\r
}\r
}\r
- \r
+\r
Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
\r
DOMSource source = new DOMSource(doc);\r
transformer.transform(source, result);\r
String xmlString = result.getWriter().toString();\r
- \r
+\r
FileWriter writer = new FileWriter(file);\r
writer.write(xmlString);\r
writer.close();\r
Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
}\r
}\r
- \r
+\r
private Element createInputElementElement(InputElement inputElement, Document doc) {\r
Element inputElementElement = doc.createElement(INPUT_ELEMENT_ELEMENT);\r
inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.elementName);\r
- \r
+\r
if (inputElement.logEntry) {\r
inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.logEntry));\r
}\r
}\r
}\r
}\r
- \r
+\r
if (inputElement.childElements != null) {\r
for (InputElement childInputElement : inputElement.childElements) {\r
inputElementElement.appendChild(createInputElementElement(childInputElement, doc));\r
}\r
}\r
- \r
+\r
return inputElementElement;\r
}\r
- \r
+\r
public static CustomXmlTraceDefinition[] loadAll() {\r
return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
}\r
- \r
+\r
public static CustomXmlTraceDefinition[] loadAll(String path) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
}\r
return null;\r
}\r
- \r
+\r
public static CustomXmlTraceDefinition extractDefinition(Element definitionElement) {\r
CustomXmlTraceDefinition def = new CustomXmlTraceDefinition();\r
- \r
+\r
def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);\r
- if (def.definitionName == null) return null;\r
- \r
+ if (def.definitionName == null) {\r
+ return null;\r
+ }\r
+\r
NodeList nodeList = definitionElement.getChildNodes();\r
for (int i = 0; i < nodeList.getLength(); i++) {\r
Node node = nodeList.item(i);\r
}\r
return inputElement;\r
}\r
- \r
+\r
public static void delete(String definitionName) {\r
try {\r
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
root.removeChild(node);\r
}\r
}\r
- \r
+\r
Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
\r
DOMSource source = new DOMSource(doc);\r
transformer.transform(source, result);\r
String xmlString = result.getWriter().toString();\r
- \r
+\r
FileWriter writer = new FileWriter(file);\r
writer.write(xmlString);\r
writer.close();\r
import org.eclipse.jface.viewers.TreeViewer;\r
import org.eclipse.jface.viewers.Viewer;\r
import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.Cardinality;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;\r
private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);\r
private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);\r
\r
- private ISelection selection;\r
+ private final ISelection selection;\r
private CustomTxtTraceDefinition definition;\r
private String editDefinitionName;\r
private String defaultDescription;\r
// variables used recursively through line traversal\r
private String timeStampFormat;\r
private boolean timestampFound;\r
- \r
+\r
protected CustomTxtParserInputWizardPage(ISelection selection, CustomTxtTraceDefinition definition) {\r
super("CustomParserWizardPage"); //$NON-NLS-1$\r
if (definition == null) {\r
container.setLayout(new GridLayout());\r
\r
updateListener = new UpdateListener();\r
- \r
+\r
Composite headerComposite = new Composite(container, SWT.FILL);\r
GridLayout headerLayout = new GridLayout(5, false);\r
headerLayout.marginHeight = 0;\r
headerLayout.marginWidth = 0;\r
headerComposite.setLayout(headerLayout);\r
headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
- \r
+\r
Label logtypeLabel = new Label(headerComposite, SWT.NULL);\r
logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType);\r
- \r
+\r
logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
- \r
+\r
Label timestampFormatLabel = new Label(headerComposite, SWT.NULL);\r
timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat);\r
- \r
+\r
timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);\r
openHelpShell(SIMPLE_DATE_FORMAT_URL);\r
}\r
});\r
- \r
+\r
Label timestampPreviewLabel = new Label(headerComposite, SWT.NULL);\r
timestampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));\r
timestampPreviewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);\r
- \r
+\r
timestampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
timestampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));\r
timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);\r
buttonBarLayout.marginHeight = 0;\r
buttonBarLayout.marginWidth = 0;\r
buttonBar.setLayout(buttonBarLayout);\r
- \r
+\r
Button removeButton = new Button(buttonBar, SWT.PUSH);\r
removeButton.setImage(deleteImage);\r
removeButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeLine);\r
removeButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty() || selectedLine == null) return;\r
+ if (treeViewer.getSelection().isEmpty() || selectedLine == null) {\r
+ return;\r
+ }\r
removeLine();\r
InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputLine.parentInput == null) {\r
moveUpButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty()) return;\r
+ if (treeViewer.getSelection().isEmpty()) {\r
+ return;\r
+ }\r
InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputLine.parentInput == null) {\r
for (int i = 1; i < definition.inputs.size(); i++) {\r
moveDownButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty()) return;\r
+ if (treeViewer.getSelection().isEmpty()) {\r
+ return;\r
+ }\r
InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputLine.parentInput == null) {\r
for (int i = 0; i < definition.inputs.size() - 1; i++) {\r
updatePreviews();\r
}\r
});\r
- \r
+\r
SashForm vSash = new SashForm(container, SWT.VERTICAL);\r
vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
treeScrolledComposite.setContent(treeContainer);\r
treeScrolledComposite.setExpandHorizontal(true);\r
treeScrolledComposite.setExpandVertical(true);\r
- \r
+\r
treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);\r
treeViewer.setContentProvider(new InputLineTreeNodeContentProvider());\r
treeViewer.setLabelProvider(new InputLineTreeLabelProvider());\r
treeViewer.addSelectionChangedListener(new InputLineTreeSelectionChangedListener());\r
treeContainer.layout();\r
- \r
+\r
treeScrolledComposite.setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);\r
- \r
+\r
lineScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);\r
lineScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
lineContainer = new Composite(lineScrolledComposite, SWT.NONE);\r
if (definition == null) {\r
definition = new CustomTxtTraceDefinition();\r
definition.inputs.add(new InputLine(Cardinality.ZERO_OR_MORE, DEFAULT_REGEX,\r
- Arrays.asList(new InputData(CustomTxtTraceDefinition.TAG_MESSAGE, CustomTxtTraceDefinition.ACTION_SET))));\r
+ Arrays.asList(new InputData(CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.ACTION_SET))));\r
}\r
loadDefinition(definition);\r
treeViewer.expandAll();\r
lineContainer.layout();\r
- \r
+\r
logtypeText.addModifyListener(updateListener);\r
timestampOutputFormatText.addModifyListener(updateListener);\r
- \r
+\r
lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
\r
hSash.setWeights(new int[] {1, 2});\r
- \r
+\r
Composite sashBottom = new Composite(vSash, SWT.NONE);\r
GridLayout sashBottomLayout = new GridLayout(3, false);\r
sashBottomLayout.marginHeight = 0;\r
updatePreviews(true);\r
}\r
});\r
- \r
+\r
Button legendButton = new Button(sashBottom, SWT.PUSH);\r
legendButton.setImage(helpImage);\r
legendButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_previewLegend);\r
openLegend();\r
}\r
});\r
- \r
+\r
inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\r
if (fixedFont == null) {\r
if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$\r
inputText.addModifyListener(updateListener);\r
\r
vSash.setWeights(new int[] {hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});\r
- \r
+\r
setControl(container);\r
- \r
+\r
validate();\r
updatePreviews();\r
}\r
@Override\r
public Object[] getChildren(Object parentElement) {\r
InputLine inputLine = (InputLine) parentElement;\r
- if (inputLine.childrenInputs == null) return new InputLine[0];\r
+ if (inputLine.childrenInputs == null) {\r
+ return new InputLine[0];\r
+ }\r
return inputLine.childrenInputs.toArray();\r
}\r
\r
return inputLine.parentInput;\r
}\r
}\r
- \r
+\r
private class InputLineTreeLabelProvider extends ColumnLabelProvider {\r
\r
@Override\r
InputLine inputLine = (InputLine) element;\r
if (inputLine.parentInput == null) {\r
return "Root Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- } else {\r
- return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
}\r
+ return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
}\r
}\r
\r
}\r
}\r
}\r
- \r
+\r
/* (non-Javadoc)\r
* @see org.eclipse.jface.dialogs.DialogPage#dispose()\r
*/\r
}\r
return inputs;\r
}\r
- \r
+\r
public List<String> getInputNames(InputLine inputLine) {\r
List<String> inputs = new ArrayList<String>();\r
if (inputLine.columns != null) {\r
}\r
return inputs;\r
}\r
- \r
+\r
private void removeLine() {\r
selectedLine.dispose();\r
selectedLine = null;\r
}\r
return ""; //$NON-NLS-1$\r
}\r
- \r
+\r
private void updatePreviews() {\r
updatePreviews(false);\r
}\r
return;\r
}\r
inputText.setStyleRanges(new StyleRange[] {});\r
- \r
+\r
Scanner scanner = new Scanner(inputText.getText());\r
scanner.useDelimiter("\n"); //$NON-NLS-1$\r
int rawPos = 0;\r
if ((skip = scanner.findWithinHorizon("\\A\n+", 0)) != null) { //$NON-NLS-1$\r
rawPos += skip.length();\r
}\r
- \r
+\r
timeStampFormat = null;\r
if (selectedLine != null) {\r
for (InputGroup input : selectedLine.inputs) {\r
input.previewText.setText(Messages.CustomTxtParserInputWizardPage_noMathcingLine);\r
}\r
}\r
- \r
+\r
Map<String, String> data = new HashMap<String, String>();\r
int rootLineMatches = 0;\r
String firstEntryTimeStamp = null;\r
String firstEntryTimeStampInputFormat = null;\r
String log = null;\r
- event: \r
- while (log != null || scanner.hasNext()) {\r
+ event:\r
+ while (scanner.hasNext()) {\r
if (rootLineMatches > 0 && !updateAll) {\r
break;\r
}\r
timeStampFormat = null;\r
updatePreviewLine(rootInputLine, matcher, data, rawPos, rootLineMatches);\r
if (rootLineMatches == 1) {\r
- firstEntryTimeStamp = data.get(CustomTxtTraceDefinition.TAG_TIMESTAMP);\r
+ firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
firstEntryTimeStampInputFormat = timeStampFormat;\r
}\r
HashMap<InputLine, Integer> countMap = new HashMap<InputLine, Integer>();\r
}\r
scanner.close();\r
if (rootLineMatches == 1) {\r
- firstEntryTimeStamp = data.get(CustomTxtTraceDefinition.TAG_TIMESTAMP);\r
+ firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
firstEntryTimeStampInputFormat = timeStampFormat;\r
}\r
if (firstEntryTimeStamp == null) {\r
timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noTimestampGroup);\r
if (selectedLine != null) {\r
for (InputGroup group : selectedLine.inputs) {\r
- if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);\r
break;\r
}\r
if (value.length() == 0) {\r
continue;\r
}\r
- if (input.action == CustomTxtTraceDefinition.ACTION_SET) {\r
+ if (input.action == CustomTraceDefinition.ACTION_SET) {\r
data.put(input.name, value);\r
- if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
timeStampFormat = input.format;\r
}\r
- } else if (input.action == CustomTxtTraceDefinition.ACTION_APPEND) {\r
+ } else if (input.action == CustomTraceDefinition.ACTION_APPEND) {\r
String s = data.get(input.name);\r
if (s != null) {\r
data.put(input.name, s + value);\r
} else {\r
data.put(input.name, value);\r
}\r
- if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
if (timeStampFormat != null) {\r
timeStampFormat += input.format;\r
} else {\r
timeStampFormat = input.format;\r
}\r
}\r
- } else if (input.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
+ } else if (input.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
String s = data.get(input.name);\r
if (s != null) {\r
data.put(input.name, s + " | " + value); //$NON-NLS-1$\r
} else {\r
data.put(input.name, value);\r
}\r
- if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
if (timeStampFormat != null) {\r
timeStampFormat += " | " + input.format; //$NON-NLS-1$\r
} else {\r
}\r
}\r
}\r
- \r
+\r
private void openHelpShell(String url) {\r
if (helpBrowser != null && !helpBrowser.isDisposed()) {\r
helpBrowser.getShell().setActive();\r
int line5start = line4start + line4.length();\r
String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;\r
int line6start = line5start + line5.length();\r
- String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ \r
- \r
+ String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
+\r
final Shell legendShell = new Shell(getShell(), SWT.DIALOG_TRIM);\r
legendShell.setLayout(new FillLayout());\r
StyledText legendText = new StyledText(legendShell, SWT.MULTI);\r
}\r
\r
}\r
- \r
+\r
private class Line {\r
private static final String INFINITY_STRING = "\u221E"; //$NON-NLS-1$\r
InputLine inputLine;\r
List<InputGroup> inputs = new ArrayList<InputGroup>();\r
Button addGroupButton;\r
Label addGroupLabel;\r
- \r
+\r
public Line(Composite parent, String name, InputLine inputLine) {\r
this.inputLine = inputLine;\r
- \r
+\r
group = new Group(parent, SWT.NONE);\r
group.setText(name);\r
group.setLayout(new GridLayout(2, false));\r
group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
- \r
+\r
labelComposite = new Composite(group, SWT.FILL);\r
GridLayout labelLayout = new GridLayout(1, false);\r
labelLayout.marginWidth = 0;\r
labelLayout.marginHeight = 0;\r
labelComposite.setLayout(labelLayout);\r
labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
- \r
+\r
Label label = new Label(labelComposite, SWT.NULL);\r
label.setText(Messages.CustomTxtParserInputWizardPage_regularExpression);\r
- \r
+\r
Composite regexContainer = new Composite(group, SWT.NONE);\r
GridLayout regexLayout = new GridLayout(2, false);\r
regexLayout.marginHeight = 0;\r
regexLayout.marginWidth = 0;\r
regexContainer.setLayout(regexLayout);\r
regexContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
- \r
+\r
regexText = new Text(regexContainer, SWT.BORDER | SWT.SINGLE);\r
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
gd.widthHint = 0;\r
regexText.setLayoutData(gd);\r
regexText.setText(inputLine.getRegex());\r
regexText.addModifyListener(updateListener);\r
- \r
+\r
Button regexHelpButton = new Button(regexContainer, SWT.PUSH);\r
regexHelpButton.setImage(helpImage);\r
regexHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_regularExpressionHelp);\r
openHelpShell(PATTERN_URL);\r
}\r
});\r
- \r
+\r
label = new Label(group, SWT.NONE);\r
label.setText(Messages.CustomTxtParserInputWizardPage_cardinality);\r
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
- \r
+\r
cardinalityContainer = new Composite(group, SWT.NONE);\r
GridLayout cardinalityLayout = new GridLayout(6, false);\r
cardinalityLayout.marginHeight = 0;\r
validate();\r
updatePreviews();\r
}});\r
- \r
+\r
cardinalityMinLabel = new Label(cardinalityContainer, SWT.NONE);\r
cardinalityMinLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
cardinalityMinLabel.setText(Messages.CustomTxtParserInputWizardPage_min);\r
cardinalityMinLabel.setVisible(false);\r
- \r
+\r
cardinalityMinText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);\r
gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);\r
gd.widthHint = 20;\r
cardinalityMinText.setLayoutData(gd);\r
cardinalityMinText.setVisible(false);\r
- \r
+\r
cardinalityMaxLabel = new Label(cardinalityContainer, SWT.NONE);\r
cardinalityMaxLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
cardinalityMaxLabel.setText(Messages.CustomTxtParserInputWizardPage_max);\r
cardinalityMaxLabel.setVisible(false);\r
- \r
+\r
cardinalityMaxText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);\r
gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);\r
gd.widthHint = 20;\r
}\r
infiniteButton.setVisible(true);\r
}\r
- \r
+\r
VerifyListener digitsListener = new VerifyListener() {\r
@Override\r
public void verifyText(VerifyEvent e) {\r
}\r
}\r
}};\r
- \r
+\r
cardinalityMinText.addModifyListener(updateListener);\r
cardinalityMaxText.addModifyListener(updateListener);\r
cardinalityMinText.addVerifyListener(digitsListener);\r
if (inputLine.columns != null) {\r
for (InputData inputData : inputLine.columns) {\r
InputGroup inputGroup = new InputGroup(group, this, inputs.size()+1);\r
- if (inputData.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
inputGroup.tagCombo.select(0);\r
inputGroup.tagText.setText(inputData.format);\r
inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);\r
inputGroup.tagLabel.setVisible(true);\r
inputGroup.tagText.setVisible(true);\r
inputGroup.tagText.addModifyListener(updateListener);\r
- } else if (inputData.name.equals(CustomTxtTraceDefinition.TAG_MESSAGE)) {\r
+ } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
inputGroup.tagCombo.select(1);\r
} else {\r
inputGroup.tagCombo.select(2);\r
inputs.add(inputGroup);\r
}\r
}\r
- \r
+\r
createAddGroupButton();\r
}\r
\r
updatePreviews();\r
}\r
});\r
- \r
+\r
addGroupLabel = new Label(group, SWT.NULL);\r
addGroupLabel.setText(Messages.CustomTxtParserInputWizardPage_newGroup);\r
}\r
addGroupButton.dispose();\r
addGroupLabel.dispose();\r
}\r
- \r
+\r
private void removeInput(int inputNumber) {\r
if (--inputNumber < inputs.size()) {\r
inputs.remove(inputNumber).dispose();\r
group.getParent().layout();\r
}\r
}\r
- \r
+\r
// private void setName(String name) {\r
// this.name = name;\r
// group.setText("Line " + name);\r
// }\r
- \r
+\r
private void dispose() {\r
group.dispose();\r
}\r
- \r
+\r
private void extractInputs() {\r
inputLine.setRegex(selectedLine.regexText.getText());\r
switch (cardinalityCombo.getSelectionIndex()) {\r
for (int i = 0; i < inputs.size(); i++) {\r
InputGroup group = inputs.get(i);\r
InputData inputData = new InputData();\r
- if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_OTHER)) {\r
+ if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
inputData.name = group.tagText.getText().trim();\r
} else {\r
inputData.name = group.tagCombo.getText();\r
- if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
inputData.format = group.tagText.getText().trim();\r
}\r
}\r
private class InputGroup {\r
Line line;\r
int inputNumber;\r
- \r
+\r
// children of parent (must be disposed)\r
Composite labelComposite;\r
Composite tagComposite;\r
\r
// children of labelComposite\r
Label inputLabel;\r
- \r
+\r
// children of tagComposite\r
Combo tagCombo;\r
Label tagLabel;\r
Text tagText;\r
Combo actionCombo;\r
- \r
+\r
public InputGroup(Composite parent, Line line, int inputNumber) {\r
this.line = line;\r
this.inputNumber = inputNumber;\r
- \r
+\r
labelComposite = new Composite(parent, SWT.FILL);\r
GridLayout labelLayout = new GridLayout(2, false);\r
labelLayout.marginWidth = 0;\r
labelLayout.marginHeight = 0;\r
labelComposite.setLayout(labelLayout);\r
labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
- \r
+\r
Button deleteButton = new Button(labelComposite, SWT.PUSH);\r
deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
deleteButton.setImage(deleteImage);\r
updatePreviews();\r
}\r
});\r
- \r
+\r
inputLabel = new Label(labelComposite, SWT.NULL);\r
inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$\r
tagLayout.marginHeight = 0;\r
tagComposite.setLayout(tagLayout);\r
tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
- \r
+\r
tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
- tagCombo.setItems(new String[] {CustomTxtTraceDefinition.TAG_TIMESTAMP,\r
- CustomTxtTraceDefinition.TAG_MESSAGE,\r
- CustomTxtTraceDefinition.TAG_OTHER});\r
+ tagCombo.setItems(new String[] {CustomTraceDefinition.TAG_TIMESTAMP,\r
+ CustomTraceDefinition.TAG_MESSAGE,\r
+ CustomTraceDefinition.TAG_OTHER});\r
tagCombo.select(1);\r
tagCombo.addSelectionListener(new SelectionListener(){\r
@Override\r
tagLabel.setVisible(false);\r
tagText.setVisible(false);\r
break;\r
+ default:\r
+ break;\r
}\r
tagComposite.layout();\r
validate();\r
updatePreviews();\r
}});\r
- \r
+\r
tagLabel = new Label(tagComposite, SWT.NULL);\r
tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
tagLabel.setVisible(false);\r
- \r
+\r
tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
gd.widthHint = 0;\r
tagText.setLayoutData(gd);\r
tagText.setVisible(false);\r
- \r
+\r
actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
actionCombo.setItems(new String[] {Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith});\r
actionCombo.select(0);\r
actionCombo.addSelectionListener(updateListener);\r
- \r
+\r
previewLabel = new Label(parent, SWT.NULL);\r
previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
previewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);\r
- \r
+\r
previewText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
gd.widthHint = 0;\r
previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatch);\r
previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
}\r
- \r
+\r
private void dispose() {\r
labelComposite.dispose();\r
tagComposite.dispose();\r
previewLabel.dispose();\r
previewText.dispose();\r
}\r
- \r
+\r
private void setInputNumber(int inputNumber) {\r
this.inputNumber = inputNumber;\r
inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$\r
\r
definition.definitionName = logtypeText.getText().trim();\r
definition.timeStampOutputFormat = timestampOutputFormatText.getText().trim();\r
- \r
+\r
if (selectedLine != null) {\r
selectedLine.extractInputs();\r
treeViewer.refresh();\r
}\r
- \r
+\r
StringBuffer errors = new StringBuffer();\r
- \r
+\r
if (definition.definitionName.length() == 0) {\r
errors.append("Enter a name for the new log type. "); //$NON-NLS-1$\r
logtypeText.setBackground(COLOR_LIGHT_RED);\r
}\r
}\r
}\r
- \r
+\r
timestampFound = false;\r
for (int i = 0; i < definition.inputs.size(); i++) {\r
- \r
+\r
InputLine inputLine = definition.inputs.get(i);\r
String name = Integer.toString(i+1);\r
errors.append(validateLine(inputLine, name));\r
timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
}\r
}\r
- \r
+\r
} else {\r
timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);\r
// timestampPreviewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
public StringBuffer validateLine(InputLine inputLine, String name) {\r
StringBuffer errors = new StringBuffer();\r
Line line = null;\r
- if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) line = selectedLine;\r
+ if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) {\r
+ line = selectedLine;\r
+ }\r
try {\r
Pattern.compile(inputLine.getRegex());\r
- if (line != null) line.regexText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ if (line != null) {\r
+ line.regexText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
} catch (PatternSyntaxException e) {\r
errors.append("Enter a valid regular expression (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
- if (line != null) line.regexText.setBackground(COLOR_LIGHT_RED);\r
+ if (line != null) {\r
+ line.regexText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
if (inputLine.getMinCount() == -1) {\r
errors.append("Enter a minimum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
- if (line != null) line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
+ if (line != null) {\r
+ line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (line != null) line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ if (line != null) {\r
+ line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
if (inputLine.getMaxCount() == -1) {\r
errors.append("Enter a maximum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
- if (line != null) line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
+ if (line != null) {\r
+ line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else if (inputLine.getMinCount() > inputLine.getMaxCount()) {\r
errors.append("Enter correct (min <= max) values for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
- if (line != null) line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
- if (line != null) line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
+ if (line != null) {\r
+ line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
+ if (line != null) {\r
+ line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (line != null) line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ if (line != null) {\r
+ line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
for (int i = 0; inputLine.columns != null && i < inputLine.columns.size(); i++) {\r
InputData inputData = inputLine.columns.get(i);\r
InputGroup group = null;\r
- if (line != null) group = line.inputs.get(i);\r
- if (inputData.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (line != null) {\r
+ group = line.inputs.get(i);\r
+ }\r
+ if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
timestampFound = true;\r
if (inputData.format.length() == 0) {\r
errors.append("Enter the input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ if (group != null) {\r
+ group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
try {\r
new SimpleDateFormat(inputData.format);\r
- if (group != null) group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ if (group != null) {\r
+ group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
} catch (IllegalArgumentException e) {\r
errors.append("Enter a valid input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ if (group != null) {\r
+ group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
}\r
} else if (inputData.name.length() == 0) {\r
errors.append("Enter a name for the data group (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ if (group != null) {\r
+ group.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (group != null) group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ if (group != null) {\r
+ group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
}\r
for (int i = 0; inputLine.childrenInputs != null && i < inputLine.childrenInputs.size(); i++) {\r
}\r
return errors;\r
}\r
- \r
+\r
public CustomTxtTraceDefinition getDefinition() {\r
return definition;\r
}\r
\r
import org.eclipse.core.resources.IFile;\r
import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.jface.viewers.AbstractTreeViewer;\r
import org.eclipse.jface.viewers.ColumnLabelProvider;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.jface.viewers.ISelectionChangedListener;\r
import org.eclipse.jface.viewers.TreeViewer;\r
import org.eclipse.jface.viewers.Viewer;\r
import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;\r
removeButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty() || selectedElement == null)\r
+ if (treeViewer.getSelection().isEmpty() || selectedElement == null) {\r
return;\r
+ }\r
removeElement();\r
InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputElement == definition.rootInputElement) {\r
InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (previousInputElement == definition.rootInputElement) {\r
return;\r
- } else {\r
- previousInputElement.addNext(inputElement);\r
- inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);\r
}\r
+ previousInputElement.addNext(inputElement);\r
+ inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);\r
}\r
treeViewer.refresh();\r
treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
}\r
treeViewer.refresh();\r
treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
- treeViewer.expandToLevel(inputElement, TreeViewer.ALL_LEVELS);\r
+ treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS);\r
}\r
});\r
\r
moveUpButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty())\r
+ if (treeViewer.getSelection().isEmpty()) {\r
return;\r
+ }\r
InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputElement == definition.rootInputElement) {\r
return;\r
- } else {\r
- inputElement.moveUp();\r
}\r
+ inputElement.moveUp();\r
treeViewer.refresh();\r
validate();\r
updatePreviews();\r
moveDownButton.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- if (treeViewer.getSelection().isEmpty())\r
+ if (treeViewer.getSelection().isEmpty()) {\r
return;\r
+ }\r
InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
if (inputElement == definition.rootInputElement) {\r
return;\r
- } else {\r
- inputElement.moveDown();\r
}\r
+ inputElement.moveDown();\r
treeViewer.refresh();\r
validate();\r
updatePreviews();\r
String attributeName = getAttributeNameSuggestion(inputElement);\r
if (attributeName.length() == 0) {\r
break;\r
- } else {\r
- InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
- inputElement.addAttribute(attribute);\r
}\r
+ InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
+ inputElement.addAttribute(attribute);\r
}\r
while (true) {\r
String childName = getChildNameSuggestion(inputElement);\r
if (childName.length() == 0) {\r
break;\r
- } else {\r
- InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
- inputElement.addChild(childElement);\r
- feelingLucky(childElement);\r
}\r
+ InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
+ inputElement.addChild(childElement);\r
+ feelingLucky(childElement);\r
}\r
}\r
\r
CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;\r
if (def.rootInputElement != null) {\r
return new Object[] { def.rootInputElement };\r
- } else {\r
- return new Object[0];\r
}\r
+ return new Object[0];\r
}\r
\r
@Override\r
public Object[] getChildren(Object parentElement) {\r
InputElement inputElement = (InputElement) parentElement;\r
- if (inputElement.childElements == null)\r
+ if (inputElement.childElements == null) {\r
return new InputElement[0];\r
+ }\r
return inputElement.childElements.toArray();\r
}\r
\r
\r
/*\r
* (non-Javadoc)\r
- * \r
+ *\r
* @see org.eclipse.jface.dialogs.DialogPage#dispose()\r
*/\r
@Override\r
\r
/*\r
* (non-Javadoc)\r
- * \r
+ *\r
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
*/\r
@Override\r
tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
\r
tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
- tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomXmlTraceDefinition.TAG_TIMESTAMP,\r
- CustomXmlTraceDefinition.TAG_MESSAGE, CustomXmlTraceDefinition.TAG_OTHER });\r
+ tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP,\r
+ CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });\r
tagCombo.setVisibleItemCount(tagCombo.getItemCount());\r
tagCombo.addSelectionListener(new SelectionListener() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
tagText.removeModifyListener(updateListener);\r
switch (tagCombo.getSelectionIndex()) {\r
- case 0: // Ignore\r
- tagLabel.setVisible(false);\r
- tagText.setVisible(false);\r
- actionCombo.setVisible(false);\r
- break;\r
- case 1: // Time Stamp\r
- tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
- tagLabel.setVisible(true);\r
- tagText.setVisible(true);\r
- tagText.addModifyListener(updateListener);\r
- actionCombo.setVisible(true);\r
- break;\r
- case 2: // Message\r
- tagLabel.setVisible(false);\r
- tagText.setVisible(false);\r
- actionCombo.setVisible(true);\r
- break;\r
- case 3: // Other\r
- tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
- tagLabel.setVisible(true);\r
- if (tagText.getText().trim().length() == 0) {\r
- tagText.setText(elementNameText.getText().trim());\r
- }\r
- tagText.setVisible(true);\r
- tagText.addModifyListener(updateListener);\r
- actionCombo.setVisible(true);\r
- break;\r
+ case 0: // Ignore\r
+ tagLabel.setVisible(false);\r
+ tagText.setVisible(false);\r
+ actionCombo.setVisible(false);\r
+ break;\r
+ case 1: // Time Stamp\r
+ tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
+ tagLabel.setVisible(true);\r
+ tagText.setVisible(true);\r
+ tagText.addModifyListener(updateListener);\r
+ actionCombo.setVisible(true);\r
+ break;\r
+ case 2: // Message\r
+ tagLabel.setVisible(false);\r
+ tagText.setVisible(false);\r
+ actionCombo.setVisible(true);\r
+ break;\r
+ case 3: // Other\r
+ tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
+ tagLabel.setVisible(true);\r
+ if (tagText.getText().trim().length() == 0) {\r
+ tagText.setText(elementNameText.getText().trim());\r
+ }\r
+ tagText.setVisible(true);\r
+ tagText.addModifyListener(updateListener);\r
+ actionCombo.setVisible(true);\r
+ break;\r
+ default:\r
+ break;\r
}\r
tagComposite.layout();\r
validate();\r
tagLabel.setVisible(false);\r
tagText.setVisible(false);\r
actionCombo.setVisible(false);\r
- } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
tagCombo.select(1);\r
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
tagText.setText(inputElement.inputFormat);\r
tagText.addModifyListener(updateListener);\r
- } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) {\r
+ } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
tagCombo.select(2);\r
tagLabel.setVisible(false);\r
tagText.setVisible(false);\r
// log entry\r
}\r
}\r
- if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
+ if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
String value = previewText.getText().trim();\r
if (value.length() != 0) {\r
- if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) {\r
+ if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
timeStampValue = value;\r
timeStampFormat = tagText.getText().trim();\r
- } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) {\r
+ } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
if (timeStampValue != null) {\r
timeStampValue += value;\r
timeStampFormat += tagText.getText().trim();\r
timeStampValue = value;\r
timeStampFormat = tagText.getText().trim();\r
}\r
- } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
+ } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
if (timeStampValue != null) {\r
timeStampValue += " | " + value; //$NON-NLS-1$\r
timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$\r
String value = element.getAttribute(attribute.attributeNameText.getText().trim());\r
if (value.length() != 0) {\r
attribute.previewText.setText(value);\r
- if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
- if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) {\r
+ if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
+ if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
timeStampValue = value;\r
timeStampFormat = attribute.tagText.getText().trim();\r
- } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) {\r
+ } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
if (timeStampValue != null) {\r
timeStampValue += value;\r
timeStampFormat += attribute.tagText.getText().trim();\r
timeStampValue = value;\r
timeStampFormat = attribute.tagText.getText().trim();\r
}\r
- } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
+ } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
if (timeStampValue != null) {\r
timeStampValue += " | " + value; //$NON-NLS-1$\r
timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$\r
inputElement.elementName = elementNameText.getText().trim();\r
if (inputElement.parentElement != null) {\r
inputElement.logEntry = logEntryButton.getSelection();\r
- if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) {\r
+ if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
inputElement.inputName = tagText.getText().trim();\r
} else {\r
inputElement.inputName = tagCombo.getText();\r
- if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
inputElement.inputFormat = tagText.getText().trim();\r
}\r
}\r
Attribute attribute = attributes.get(i);\r
InputAttribute inputAttribute = new InputAttribute();\r
inputAttribute.attributeName = attribute.attributeNameText.getText().trim();\r
- if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) {\r
+ if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
inputAttribute.inputName = attribute.tagText.getText().trim();\r
} else {\r
inputAttribute.inputName = attribute.tagCombo.getText();\r
- if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
inputAttribute.inputFormat = attribute.tagText.getText().trim();\r
}\r
}\r
tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
\r
tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
- tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_TIMESTAMP, CustomXmlTraceDefinition.TAG_MESSAGE,\r
- CustomXmlTraceDefinition.TAG_OTHER });\r
+ tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE,\r
+ CustomTraceDefinition.TAG_OTHER });\r
tagCombo.select(2); // Other\r
tagCombo.addSelectionListener(new SelectionListener() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
tagText.removeModifyListener(updateListener);\r
switch (tagCombo.getSelectionIndex()) {\r
- case 0: // Time Stamp\r
- tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
- tagLabel.setVisible(true);\r
- tagText.setVisible(true);\r
- tagText.addModifyListener(updateListener);\r
- break;\r
- case 1: // Message\r
- tagLabel.setVisible(false);\r
- tagText.setVisible(false);\r
- break;\r
- case 2: // Other\r
- tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
- tagLabel.setVisible(true);\r
- if (tagText.getText().trim().length() == 0) {\r
- tagText.setText(attributeNameText.getText().trim());\r
- }\r
- tagText.setVisible(true);\r
- tagText.addModifyListener(updateListener);\r
- break;\r
+ case 0: // Time Stamp\r
+ tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
+ tagLabel.setVisible(true);\r
+ tagText.setVisible(true);\r
+ tagText.addModifyListener(updateListener);\r
+ break;\r
+ case 1: // Message\r
+ tagLabel.setVisible(false);\r
+ tagText.setVisible(false);\r
+ break;\r
+ case 2: // Other\r
+ tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
+ tagLabel.setVisible(true);\r
+ if (tagText.getText().trim().length() == 0) {\r
+ tagText.setText(attributeNameText.getText().trim());\r
+ }\r
+ tagText.setVisible(true);\r
+ tagText.addModifyListener(updateListener);\r
+ break;\r
+ default:\r
+ break;\r
}\r
tagComposite.layout();\r
validate();\r
actionCombo.select(inputAttribute.inputAction);\r
actionCombo.addSelectionListener(updateListener);\r
\r
- if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
tagCombo.select(0);\r
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
tagText.setText(inputAttribute.inputFormat);\r
tagText.addModifyListener(updateListener);\r
- } else if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) {\r
+ } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
tagCombo.select(1);\r
tagLabel.setVisible(false);\r
tagText.setVisible(false);\r
public StringBuffer validateElement(InputElement inputElement) {\r
StringBuffer errors = new StringBuffer();\r
ElementNode elementNode = null;\r
- if (selectedElement != null && selectedElement.inputElement.equals(inputElement))\r
+ if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {\r
elementNode = selectedElement;\r
+ }\r
if (inputElement == definition.rootInputElement) {\r
if (inputElement.elementName.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
}\r
if (inputElement != definition.rootInputElement) {\r
if (inputElement.logEntry) {\r
logEntryFound = true;\r
}\r
- if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
timeStampFound = true;\r
if (inputElement.inputFormat.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt\r
+ " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
try {\r
new SimpleDateFormat(inputElement.inputFormat);\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
} catch (IllegalArgumentException e) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
}\r
} else if (inputElement.inputName.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
}\r
if (inputElement.attributes != null) {\r
if (attribute.attributeName.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else if (duplicate) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
- if (attribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {\r
+ if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
timeStampFound = true;\r
if (attribute.inputFormat.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
try {\r
new SimpleDateFormat(attribute.inputFormat);\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
} catch (IllegalArgumentException e) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
}\r
} else if (attribute.inputName.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
- if (elementNode != null)\r
+ if (elementNode != null) {\r
elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
}\r
}\r
if (inputElement.childElements != null) {\r
for (InputElement child : inputElement.childElements) {\r
ElementNode childElementNode = null;\r
- if (selectedElement != null && selectedElement.inputElement.equals(child))\r
+ if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
childElementNode = selectedElement;\r
- if (childElementNode != null)\r
+ }\r
+ if (childElementNode != null) {\r
childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
+ }\r
}\r
for (int i = 0; i < inputElement.childElements.size(); i++) {\r
InputElement child = inputElement.childElements.get(i);\r
ElementNode childElementNode = null;\r
- if (selectedElement != null && selectedElement.inputElement.equals(child))\r
+ if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
childElementNode = selectedElement;\r
+ }\r
if (child.elementName.length() == 0) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (childElementNode != null)\r
+ if (childElementNode != null) {\r
childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
} else {\r
boolean duplicate = false;\r
for (int j = i + 1; j < inputElement.childElements.size(); j++) {\r
if (otherChild.elementName.equals(child.elementName)) {\r
duplicate = true;\r
ElementNode otherChildElementNode = null;\r
- if (selectedElement != null && selectedElement.inputElement.equals(otherChild))\r
+ if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {\r
otherChildElementNode = selectedElement;\r
- if (otherChildElementNode != null)\r
+ }\r
+ if (otherChildElementNode != null) {\r
otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
}\r
if (duplicate) {\r
errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError\r
+ " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
- if (childElementNode != null)\r
+ if (childElementNode != null) {\r
childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
+ }\r
}\r
}\r
\r
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
// There should be only one item selected as per the plugin.xml
Object element = sel.getFirstElement();
List<IResource> resourcesList = new ArrayList<IResource>();
-
+
if (element instanceof TmfExperimentElement) {
TmfExperimentElement trace = (TmfExperimentElement) element;
}
SelectSupplementaryResourcesDialog dialog = new SelectSupplementaryResourcesDialog(window.getShell(), resourcesList.toArray(new IResource[resourcesList.size()]));
-
+
if (dialog.open() != Window.OK) {
return null;
}
IResource resource = trace.getProject().getResource();
if (resource != null) {
try {
- if (resource != null) {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
+ resource.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
Activator.getDefault().logError("Error refreshing resource " + resource, e); //$NON-NLS-1$
}
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return null;
+ }
// Get the selection
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
// Delete the selected resources
IResource[] resources = trace.getSupplementaryResources();
-
+
SelectSupplementaryResourcesDialog dialog = new SelectSupplementaryResourcesDialog(window.getShell(), resources);
if (dialog.open() != Window.OK) {
return null;
if (resource != null) {
try {
- if (resource != null) {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
+ resource.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
Activator.getDefault().logError("Error refreshing resource " + resource, e); //$NON-NLS-1$
}
/*******************************************************************************
* Copyright (c) 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Patrick Tasse - Initial API and implementation
*******************************************************************************/
return (ok ? Status.OK_STATUS : Status.CANCEL_STATUS);
}
-
+
/**
* Drop a trace by copying a resource in a target experiment
- *
+ *
* @param sourceTrace the source trace element to copy
* @param targetExperiment the target experiment
* @return true if successful
*/
- private boolean drop(TmfTraceElement sourceTrace, TmfExperimentElement targetExperiment) {
-
+ private static boolean drop(TmfTraceElement sourceTrace,
+ TmfExperimentElement targetExperiment) {
+
IResource sourceResource = sourceTrace.getResource();
-
+
if (drop(sourceResource, targetExperiment)) {
IFolder destinationSupplementaryFolder = targetExperiment.getTraceSupplementaryFolder(sourceResource.getName());
if (!destinationSupplementaryFolder.exists()) {
}
return false;
}
-
+
/**
* Drop a trace by copying a resource in a target experiment
- *
+ *
* @param sourceResource the source resource
* @param targetExperiment the target experiment
* @return true if successful
*/
- private boolean drop(IResource sourceResource, TmfExperimentElement targetExperiment) {
+ private static boolean drop(IResource sourceResource,
+ TmfExperimentElement targetExperiment) {
boolean doit = true;
//Use local variable to avoid parameter assignment
/**
* Drop a trace by copying it's a trace element in a trace folder
- *
+ *
* @param sourceTrace the source trace
* @param traceFolder the target trace folder
* @return true if successful
*/
- private boolean drop(TmfTraceElement sourceTrace, TmfTraceFolder traceFolder) {
+ private static boolean drop(TmfTraceElement sourceTrace, TmfTraceFolder traceFolder) {
IResource sourceResource = sourceTrace.getResource();
if (drop(sourceResource, traceFolder)) {
IFolder destinationSupplementaryFolder = traceFolder.getTraceSupplementaryFolder(sourceResource.getName());
/**
* Drop a trace by copying a resource in a trace folder
- *
+ *
* @param sourceResource the source resource
* @param traceFolder the target trace folder
* @return true if successful
*/
- private boolean drop(IResource sourceResource, TmfTraceFolder traceFolder) {
+ private static boolean drop(IResource sourceResource, TmfTraceFolder traceFolder) {
boolean doit = true;
for (TmfTraceElement trace : traceFolder.getTraces()) {
}
return false;
}
-
+
/**
* Drop a trace by importing a path in a target experiment
- *
+ *
* @param path the source path
* @param targetExperiment the target experiment
* @return true if successful
*/
- private boolean drop(Path path, TmfExperimentElement targetExperiment) {
+ private static boolean drop(Path path, TmfExperimentElement targetExperiment) {
boolean doit = true;
-
+
// Use local variable to avoid parameter assignment
Path pathToUse = path;
/**
* Drop a trace by importing a path in a trace folder
- *
+ *
* @param path the source path
* @param traceFolder the target trace folder
* @return true if successful
*/
- private boolean drop(Path path, TmfTraceFolder traceFolder) {
+ private static boolean drop(Path path, TmfTraceFolder traceFolder) {
boolean doit = true;
for (TmfTraceElement trace : traceFolder.getTraces()) {
if (trace.getName().equals(path.lastSegment())) {
/**
* Import a trace to the trace folder
- *
+ *
* @param resource the trace folder resource
* @param path the path to the trace to import
*/
- private void importTrace(IFolder resource, Path path) {
+ private static void importTrace(IFolder resource, Path path) {
IPath containerPath = resource.getFullPath();
File file = new File(path.toString());
File source = file.getParentFile();
} catch (InterruptedException e) {
displayException(e);
}
- }
+ }
/**
* Create a link to the actual trace and set the trace type
- *
+ *
* @param parentFolder the parent folder
* @param resource the resource
*/
- private void createLink(IFolder parentFolder, IResource resource) {
+ private static void createLink(IFolder parentFolder, IResource resource) {
IPath location = resource.getLocation();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
}
} else {
IFile file = parentFolder.getFile(resource.getName());
-
+
if (workspace.validateLinkLocation(file, location).isOK()) {
file.createLink(location, IResource.REPLACE, null);
setProperties(file, bundleName, traceType, iconUrl, supplFolder);
/**
* Cleanup bookmarks file in copied trace
*/
- private void cleanupBookmarks(IPath path) {
+ private static void cleanupBookmarks(IPath path) {
IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
if (folder.exists()) {
try {
/**
* Set the trace persistent properties
- *
+ *
* @param resource the trace resource
* @param bundleName the bundle name
* @param traceType the trace type
* @param iconUrl the icon URL
- * @param supplFolder the directory of the directory for supplementary information or null to ignore the property
+ * @param supplFolder the directory of the directory for supplementary information or null to ignore the property
* @throws CoreException
*/
- private void setProperties(IResource resource, String bundleName, String traceType, String iconUrl, String supplFolder) throws CoreException {
+ private static void setProperties(IResource resource, String bundleName,
+ String traceType, String iconUrl, String supplFolder)
+ throws CoreException {
resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, bundleName);
resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceType);
resource.setPersistentProperty(TmfCommonConstants.TRACEICON, iconUrl);
/**
* Display an exception in a message box
- *
+ *
* @param e the exception
*/
- private void displayException(Exception e) {
+ private static void displayException(Exception e) {
MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
mb.setText(e.getClass().getName());
mb.setMessage(e.getMessage());
return null;
}
- private void displayErrorMsg(final String errorMsg) {
+ private static void displayErrorMsg(final String errorMsg) {
final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
mb.setText(Messages.OpenExperimentHandler_Title);
mb.setMessage(errorMsg);
// Check if we are closing down
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return false;
+ }
// Get the selection
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final IWorkbenchPart part = page.getActivePart();
final ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
- if (selectionProvider == null)
+ if (selectionProvider == null) {
return false;
+ }
final ISelection selection = selectionProvider.getSelection();
// Make sure there is only one selection and that it is a trace
final TreeSelection sel = (TreeSelection) selection;
// There should be only one item selected as per the plugin.xml
final Object element = sel.getFirstElement();
- if (element instanceof TmfTraceElement)
+ if (element instanceof TmfTraceElement) {
fTrace = (TmfTraceElement) element;
+ }
}
// We only enable opening from the Traces folder for now
// Check if we are closing down
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return null;
+ }
// Check that the trace is valid
- if (fTrace == null)
+ if (fTrace == null) {
return null;
+ }
// If trace is under an experiment, use the original trace from the traces folder
fTrace = fTrace.getElementUnderTraceFolder();
final IResource resource = fTrace.getResource();
IFile file = null;
- if (resource instanceof IFile)
+ if (resource instanceof IFile) {
file = (IFile) resource;
- else if (resource instanceof IFolder)
+ } else if (resource instanceof IFolder) {
try {
final IFile bookmarksFile = fTrace.getProject().getTracesFolder().getResource().getFile(BOOKMARKS_HIDDEN_FILE);
if (!bookmarksFile.exists()) {
final IFolder folder = (IFolder) resource;
file = folder.getFile(fTrace.getName() + '_');
- if (!file.exists())
+ if (!file.exists()) {
file.createLink(bookmarksFile.getLocation(), IResource.REPLACE, null);
+ }
file.setHidden(true);
- if (usesEditor)
+ if (usesEditor) {
file.setPersistentProperty(TmfCommonConstants.TRACETYPE, fTrace.getTraceType());
- else
+ } else {
file.setPersistentProperty(TmfCommonConstants.TRACETYPE, TmfTrace.class.getCanonicalName());
+ }
} catch (final CoreException e) {
Activator.getDefault().logError("Error opening trace " + fTrace.getName(), e); //$NON-NLS-1$
}
+ }
- if (usesEditor)
+ if (usesEditor) {
try {
final IEditorInput editorInput = new TmfEditorInput(file, trace);
final IWorkbench wb = PlatformUI.getWorkbench();
activePage.activate(editor);
} else {
activePage.openEditor(editorInput, editorId);
- if (resource instanceof IFile)
+ if (resource instanceof IFile) {
IDE.setDefaultEditor((IFile) resource, editorId);
+ }
}
} catch (final PartInitException e) {
Activator.getDefault().logError("Error opening trace " + fTrace.getName(), e); //$NON-NLS-1$
}
- else {
+ } else {
// Create the experiment
final ITmfTrace[] traces = new ITmfTrace[] { trace };
final TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), fTrace.getName(), traces, trace.getCacheSize());
return null;
}
- private void displayErrorMsg(final String errorMsg) {
+ private static void displayErrorMsg(final String errorMsg) {
final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
mb.setText(Messages.OpenTraceHandler_Title);
mb.setMessage(errorMsg);
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
public class RenameTraceHandler extends AbstractHandler {
private TmfTraceElement fTrace = null;
-
+
// ------------------------------------------------------------------------
// isEnabled
// ------------------------------------------------------------------------
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return false;
+ }
// Get the selection
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPart part = page.getActivePart();
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
- if (selectionProvider == null)
+ if (selectionProvider == null) {
return false;
+ }
ISelection selection = selectionProvider.getSelection();
// Make sure there is only selection and that it is an experiment
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return null;
+ }
// If trace is under an experiment, use the original trace from the traces folder
fTrace = fTrace.getElementUnderTraceFolder();
TmfTraceFolder traceFolder = (TmfTraceFolder) fTrace.getParent();
TmfTraceElement oldTrace = fTrace;
RenameTraceDialog dialog = new RenameTraceDialog(shell, fTrace);
- if (dialog.open() != Window.OK)
+ if (dialog.open() != Window.OK) {
return null;
+ }
// Locate the new trace object
TmfTraceElement newTrace = null;
}
}
}
- if (newTrace == null)
+ if (newTrace == null) {
return null;
+ }
List<WorkspaceModifyOperation> removeOps = new ArrayList<WorkspaceModifyOperation>();
TmfExperimentFolder experimentFolder = newTrace.getProject().getExperimentsFolder();
if (trace.equals(oldTrace)) {
// Create a link to the renamed trace
createTraceLink(newTrace, experiment);
-
+
// Queue the removal of the old trace link
removeOps.add(new WorkspaceModifyOperation() {
@Override
} catch (RuntimeException exception) {
}
}
-
+
return null;
}
- private void createTraceLink(TmfTraceElement trace, final ITmfProjectModelElement experiment) {
+ private static void createTraceLink(TmfTraceElement trace,
+ final ITmfProjectModelElement experiment) {
try {
IResource resource = trace.getResource();
IPath location = resource.getLocation();
/*******************************************************************************
* Copyright (c) 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Patrick Tasse - Initial API and implementation
*******************************************************************************/
return list.toArray(new IContributionItem[list.size()]);
}
- private void addContributionItem(List<IContributionItem> list,
- String traceBundle, String traceTypeId, String traceIcon, String label, boolean selected,
+ private static void addContributionItem(List<IContributionItem> list,
+ String traceBundle, String traceTypeId, String traceIcon,
+ String label, boolean selected,
MenuManager subMenu) {
Map<String, String> params;
-
+
params = new HashMap<String, String>();
params.put(BUNDLE_PARAMETER, traceBundle);
params.put(TYPE_PARAMETER, traceTypeId);
return null;
}
- private boolean propagateProperties(TmfTraceElement trace, String bundleName, String traceType, String iconUrl) throws CoreException {
+ private static boolean propagateProperties(TmfTraceElement trace,
+ String bundleName, String traceType, String iconUrl)
+ throws CoreException {
IResource svResource = trace.getResource();
String svBundleName = svResource.getPersistentProperty(TmfCommonConstants.TRACEBUNDLE);
return true;
}
- private void setProperties(IResource resource, String bundleName, String traceType, String iconUrl) throws CoreException {
+ private static void setProperties(IResource resource, String bundleName,
+ String traceType, String iconUrl) throws CoreException {
resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, bundleName);
resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceType);
resource.setPersistentProperty(TmfCommonConstants.TRACEICON, iconUrl);
}
- private boolean validateTraceType(TmfTraceElement trace) {
+ private static boolean validateTraceType(TmfTraceElement trace) {
IProject project = trace.getProject().getResource();
ITmfTrace<?> tmfTrace = null;
try {
fTrace = ((TmfEditorInput) input).getTrace();
} else if (input instanceof IFileEditorInput) {
fFile = ((IFileEditorInput) input).getFile();
- if (fFile == null)
+ if (fFile == null) {
throw new PartInitException("Invalid IFileEditorInput: " + input); //$NON-NLS-1$
+ }
final TmfExperiment currentExperiment = TmfExperiment.getCurrentExperiment();
if ((currentExperiment != null) && fFile.equals(currentExperiment.getBookmarksFile())) {
fTrace = currentExperiment;
}
try {
final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);
- if (traceTypeId == null)
+ if (traceTypeId == null) {
throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+ }
if (traceTypeId.equals(TmfExperiment.class.getCanonicalName())) {
// Special case: experiment bookmark resource
final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();
ncp.getChildren(fFile.getProject()); // force the model to be populated
final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());
- if (project == null)
+ if (project == null) {
throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);
+ }
for (final ITmfProjectModelElement projectElement : project.getExperimentsFolder().getChildren()) {
final String traceName = fFile.getParent().getName();
if (projectElement.getName().equals(traceName)) {
final ITmfTrace trace = traceElement.instantiateTrace();
final ITmfEvent traceEvent = traceElement.instantiateEvent();
if ((trace == null) || (traceEvent == null)) {
- for (int j = 0; j < i; j++)
+ for (int j = 0; j < i; j++) {
traces[j].dispose();
+ }
throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);
}
try {
// Instantiate the experiment trace
final ITmfTrace trace = traceElement.instantiateTrace();
final ITmfEvent traceEvent = traceElement.instantiateEvent();
- if ((trace == null) || (traceEvent == null))
+ if ((trace == null) || (traceEvent == null)) {
throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+ }
try {
trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());
} catch (final TmfTraceException e) {
final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();
ncp.getChildren(fFile.getProject()); // force the model to be populated
final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());
- for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren())
+ for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren()) {
if (projectElement.getResource().equals(fFile)) {
final TmfTraceElement traceElement = (TmfTraceElement) projectElement;
// Instantiate the experiment trace
final ITmfTrace trace = traceElement.instantiateTrace();
final ITmfEvent traceEvent = traceElement.instantiateEvent();
- if ((trace == null) || (traceEvent == null))
+ if ((trace == null) || (traceEvent == null)) {
throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+ }
try {
trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());
} catch (final TmfTraceException e) {
TmfSignalManager.dispatchSignal(new TmfExperimentSelectedSignal(this, experiment));
break;
}
+ }
}
} catch (final InvalidRegistryObjectException e) {
Activator.getDefault().logError("Error initializing EventsViewEditor", e); //$NON-NLS-1$
Activator.getDefault().logError("Error initializing EventsViewEditor", e); //$NON-NLS-1$
}
input = new TmfEditorInput(fFile, fTrace);
- } else
+ } else {
throw new PartInitException("Invalid IEditorInput: " + input.getClass()); //$NON-NLS-1$
+ }
if (fTrace == null)
+ {
throw new PartInitException("Invalid IEditorInput: " + fFile.getName()); //$NON-NLS-1$
+ }
super.setSite(site);
super.setInput(input);
}
final EditorPart editorPart = EventsViewEditor.this;
final IWorkbenchPage page = editorPart.getEditorSite().getPage();
page.closeEditor(editorPart, false);
- if (page.getEditorReferences().length == 0)
+ if (page.getEditorReferences().length == 0) {
page.setEditorAreaVisible(fEditorAreaVisible);
+ }
try {
final IViewPart viewPart = page.showView(TmfEventsView.ID);
if (fGotoMarker != null) {
final IGotoMarker adapter = (IGotoMarker) viewPart.getAdapter(IGotoMarker.class);
- if (adapter != null)
+ if (adapter != null) {
adapter.gotoMarker(fGotoMarker);
+ }
}
} catch (final PartInitException e) {
Activator.getDefault().logError("Error setting focus", e); //$NON-NLS-1$
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(final Class adapter) {
- if (IGotoMarker.class.equals(adapter))
+ if (IGotoMarker.class.equals(adapter)) {
return new IGotoMarker() {
@Override
public void gotoMarker(final IMarker marker) {
fGotoMarker = marker;
}
};
+ }
return super.getAdapter(adapter);
}
}\r
\r
/**\r
- * Get the events table for an experiment.\r
- * If all traces in the experiment are of the same type,\r
- * use the extension point specified event table\r
- * @param experiment the experiment\r
- * @param parent the parent Composite\r
- * @param cacheSize the event table cache size\r
+ * Get the events table for an experiment. If all traces in the experiment\r
+ * are of the same type, use the extension point specified event table\r
+ *\r
+ * @param experiment\r
+ * the experiment\r
+ * @param parent\r
+ * the parent Composite\r
+ * @param cacheSize\r
+ * the event table cache size\r
* @return an events table of the appropriate type\r
*/\r
- private TmfEventsTable getExperimentEventsTable(final TmfExperiment<?> experiment, final Composite parent, final int cacheSize) {\r
+ private static TmfEventsTable getExperimentEventsTable(\r
+ final TmfExperiment<?> experiment, final Composite parent,\r
+ final int cacheSize) {\r
TmfEventsTable eventsTable = null;\r
String commonTraceType = null;\r
try {\r
* @param children
* the current children
*/
- private void customizeTmfElements(Object[] elements, Set<Object> children) {
+ private static void customizeTmfElements(Object[] elements,
+ Set<Object> children) {
if (elements != null && children != null) {
for (Object element : elements) {
if (element instanceof ITmfProjectModelElement) {
fExperimentIcon = loadIcon(bundle, fExperimentIconFile);
}
- private Image loadIcon(Bundle bundle, String url) {
+ private static Image loadIcon(Bundle bundle, String url) {
Activator plugin = Activator.getDefault();
String key = bundle.getSymbolicName() + "/" + url; //$NON-NLS-1$
Image icon = plugin.getImageRegistry().get(key);
* Implementation of trace model element representing a trace. It provides methods to instantiate
* <code>ITmfTrace</code> and <code>ITmfEvent</code> as well as editor ID from the trace type
* extension definition.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
// Constructors
// ------------------------------------------------------------------------
/**
- * Constructor.
+ * Constructor.
* Creates trace model element under the trace folder.
* @param name The name of trace
* @param trace The trace resource.
this(name, trace, (TmfProjectModelElement) parent);
}
/**
- * Constructor.
+ * Constructor.
* Creates trace model element under the experiment folder.
* @param name The name of trace
* @param trace The trace resource.
}
/**
- * Refreshes the trace type filed by reading the trace type persistent property of the resource
+ * Refreshes the trace type filed by reading the trace type persistent property of the resource
* referenece.
*/
public void refreshTraceType() {
}
/**
- * Instantiate a <code>ITmfTrace</code> object based on the trace type and the corresponding extension.
- *
+ * Instantiate a <code>ITmfTrace</code> object based on the trace type and the corresponding extension.
+ *
* @return the <code>ITmfTrace</code> or <code>null</code> for an error
*/
public ITmfTrace<?> instantiateTrace() {
}
/**
- * Instantiate a <code>ITmfEvent</code> object based on the trace type and the corresponding extension.
- *
+ * Instantiate a <code>ITmfEvent</code> object based on the trace type and the corresponding extension.
+ *
* @return the <code>ITmfEvent</code> or <code>null</code> for an error
*/
public ITmfEvent instantiateEvent() {
return null;
}
- private String getCategory(IConfigurationElement ce) {
+ private static String getCategory(IConfigurationElement ce) {
String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR);
if (categoryId != null) {
IConfigurationElement category = sfTraceCategories.get(categoryId);
/*******************************************************************************
* Copyright (c) 2010, 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The import trace wizard implementation.
}
setWindowTitle(Messages.ImportTraceWizard_DialogTitle);
- setDefaultPageImageDescriptor(Activator.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
+ setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
setNeedsProgressMonitor(true);
}
fTraceImportWizardPage = new ImportTraceWizardPage(fWorkbench, fSelection);
addPage(fTraceImportWizardPage);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
};
}
- private void populateChildren(FileSystemElement parent) {
+ private static void populateChildren(FileSystemElement parent) {
// Do not re-populate if the job was done already...
FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
if (parent.getFolders().size() == 0 && parent.getFiles().size() == 0) {
return getSourceDirectory(directoryNameField.getText());
}
- private File getSourceDirectory(String path) {
+ private static File getSourceDirectory(String path) {
File sourceDirectory = new File(getSourceDirectoryName(path));
if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
return null;
return sourceDirectory;
}
- private String getSourceDirectoryName(String sourceName) {
+ private static String getSourceDirectoryName(String sourceName) {
IPath result = new Path(sourceName.trim());
if (result.getDevice() != null && result.segmentCount() == 0) {
result = result.addTrailingSeparator();
return results[0];
}
- private FileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
+ private static FileSystemElement createRootElement(Object fileSystemObject,
+ IImportStructureProvider provider) {
boolean isContainer = provider.isFolder(fileSystemObject);
String elementLabel = provider.getLabel(fileSystemObject);
/*******************************************************************************
* Copyright (c) 2009, 2011 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.wizard.Wizard#performCancel()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
return true;
}
- private IProject createProject(String projectName, URI projectLocation, IProgressMonitor monitor) {
+ private static IProject createProject(String projectName,
+ URI projectLocation, IProgressMonitor monitor) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
try {
if (!project.exists()) {
IProjectDescription description = workspace.newProjectDescription(project.getName());
- if (projectLocation != null)
+ if (projectLocation != null) {
description.setLocationURI(projectLocation);
+ }
project.create(description, monitor);
}
- if (!project.isOpen())
+ if (!project.isOpen()) {
project.open(monitor);
+ }
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { TmfProjectNature.ID });
project.setDescription(description, null);
IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
- if (!folder.exists())
+ if (!folder.exists()) {
folder.create(true, true, null);
+ }
folder = project.getFolder(TmfExperimentFolder.EXPER_FOLDER_NAME);
- if (!folder.exists())
+ if (!folder.exists()) {
folder.create(true, true, null);
+ }
// create folder for supplementary tracing files
folder = project.getFolder(TmfCommonConstants.TRACE_SUPPLEMENATARY_FOLDER_NAME);
- if (!folder.exists())
+ if (!folder.exists()) {
folder.create(true, true, null);
+ }
return project;
} catch (CoreException e) {
- Activator.getDefault().logError("Error creating TMF project " + project.getName(), e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error creating TMF project " + project.getName(), e); //$NON-NLS-1$
}
return null;
}
/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Copied and adapted from NewFolderDialog
*******************************************************************************/
/**
* Implementation of a dialog box to rename an experiment.
- * <p>
+ * <p>
* @version 1.0
* @author Francois Chouinard
*/
private final TmfExperimentElement fExperiment;
private Text fNewExperimentName;
- private IContainer fExperimentFolder;
- private TmfProjectElement fProject;
+ private final IContainer fExperimentFolder;
+ private final TmfProjectElement fProject;
// ------------------------------------------------------------------------
// Constructor
}
private void validateNewExperimentName() {
-
+
String name = fNewExperimentName.getText();
IWorkspace workspace = fExperimentFolder.getWorkspace();
IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null));
return;
}
-
+
if (!nameStatus.isOK()) {
updateStatus(nameStatus);
return;
}
-
+
IPath path = new Path(name);
if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) {
updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null));
super.create();
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed()
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
- IFolder folder = (IFolder) fExperiment.getResource();
+ IFolder folder = fExperiment.getResource();
IFile bookmarksFile = folder.getFile(fExperiment.getName() + '_');
IFile newBookmarksFile = folder.getFile(newName + '_');
if (bookmarksFile.exists()) {
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* Implementation of a wizard page for selecting trace for an experiment.
* <p>
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
/**
* Create a link to the actual trace and set the trace type
*/
- private void createLink(IFolder experiment, TmfTraceElement trace, IResource resource, IPath location) {
+ private static void createLink(IFolder experiment, TmfTraceElement trace,
+ IResource resource, IPath location) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
Map<QualifiedName, String> properties = trace.getResource().getPersistentProperties();
String bundleName = properties.get(TmfCommonConstants.TRACEBUNDLE);
String traceType = properties.get(TmfCommonConstants.TRACETYPE);
String iconUrl = properties.get(TmfCommonConstants.TRACEICON);
-
+
if (resource instanceof IFolder) {
IFolder folder = experiment.getFolder(trace.getName());
if (workspace.validateLinkLocation(folder, location).isOK()) {
}
}
- private void setProperties(IResource resource, String bundleName, String traceType, String iconUrl) throws CoreException {
+ private static void setProperties(IResource resource, String bundleName,
+ String traceType, String iconUrl) throws CoreException {
resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, bundleName);
resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceType);
resource.setPersistentProperty(TmfCommonConstants.TRACEICON, iconUrl);
Vector<TmfTraceElement> traces = new Vector<TmfTraceElement>();
Object[] selection = fCheckboxTableViewer.getCheckedElements();
for (Object sel : selection) {
- if (sel instanceof TmfTraceElement)
+ if (sel instanceof TmfTraceElement) {
traces.add((TmfTraceElement) sel);
+ }
}
TmfTraceElement[] result = new TmfTraceElement[traces.size()];
traces.toArray(result);
import org.eclipse.jface.action.IMenuManager;\r
import org.eclipse.jface.action.MenuManager;\r
import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.dialogs.Dialog;\r
import org.eclipse.jface.dialogs.InputDialog;\r
import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.jface.resource.FontDescriptor;\r
import org.eclipse.jface.resource.JFaceResources;\r
import org.eclipse.jface.resource.LocalResourceManager;\r
+import org.eclipse.jface.window.Window;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;\r
final InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),\r
Messages.TmfEventsTable_AddBookmarkDialogTitle, Messages.TmfEventsTable_AddBookmarkDialogText,\r
defaultMessage.toString(), null);\r
- if (dialog.open() == Dialog.OK) {\r
+ if (dialog.open() == Window.OK) {\r
final String message = dialog.getValue();\r
try {\r
final IMarker bookmark = bookmarksFile.createMarker(IMarker.BOOKMARK);\r
*\r
* @param e the exception\r
*/\r
- private void displayException(final Exception e) {\r
+ private static void displayException(final Exception e) {\r
final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());\r
mb.setText(e.getClass().getName());\r
mb.setMessage(e.getMessage());\r
import org.eclipse.jface.action.Action;\r
import org.eclipse.jface.action.IToolBarManager;\r
import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.dialogs.Dialog;\r
import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.window.Window;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
FilterDialog dialog = new FilterDialog(fShell);\r
dialog.setFilter(colorSetting.getFilter());\r
dialog.open();\r
- if (dialog.getReturnCode() == Dialog.OK) {\r
+ if (dialog.getReturnCode() == Window.OK) {\r
if (dialog.getFilter() != null) {\r
colorSetting.setFilter(dialog.getFilter());\r
filterText.setText(dialog.getFilter().toString());\r
fTimeRangeEndText.setLayoutData(gridData);
}
- private Font adjustFont(final Composite composite) {
+ private static Font adjustFont(final Composite composite) {
// Reduce font size for a more pleasing rendering
final int fontSizeAdjustment = -2;
final Font font = composite.getFont();
}
}
- private void drawDelimiter(final GC imageGC, final Color color, final int height, final int index) {
+ private static void drawDelimiter(final GC imageGC, final Color color,
+ final int height, final int index) {
imageGC.setBackground(color);
final int dash = height / 4;
imageGC.fillRectangle(index, 0 * dash, 1, dash - 1);
* <li>the window span (size of the time window of the smaller histogram).
* </ul>
* The histograms x-axis show their respective time range.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
/**
* Returns the time range of the current selected window (base on default time scale).
- *
+ *
* @return the time range of current selected window.
*/
public TmfTimeRange getTimeRange() {
}
/**
- * Handles experiment range updated signal. Extends histogram according to the new time range. If a
+ * Handles experiment range updated signal. Extends histogram according to the new time range. If a
* HistogramRequest is already ongoing, it will be cancelled and a new request with the new range
* will be issued.
- *
+ *
* @param signal the experiment range updated signal
*/
@TmfSignalHandler
/**
* Handles the current time updated signal. Sets the current time in the time range
* histogram as well as the full histogram.
- *
+ *
* @param signal the signal to process
*/
@TmfSignalHandler
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
modelIncomplete(experiment.getName());
}
};
- ((TmfExperiment<ITmfEvent>) experiment).sendRequest((ITmfDataRequest<ITmfEvent>) fRequest);
+ ((TmfExperiment<ITmfEvent>) experiment).sendRequest(fRequest);
waitCursor(true);
}
}
if (path.size() == 1) {
if (path.equals(ROOT)) {
return null;
- } else {
- return get(ROOT);
}
+ return get(ROOT);
}
return get(path.subArray(0, path.size() - 1));
}
TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) element;
if (fFolderLevels.contains(node.getKey())) {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- } else {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
}, new ViewerComparator() {
@Override
TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) element;
if (!fFolderLevels.contains(node.getKey())) {
return Long.toString(node.getValue().nbEvents);
- } else {
- return ""; //$NON-NLS-1$
}
+ return ""; //$NON-NLS-1$
}
}, new ViewerComparator() {
@Override
if (parent == null) {
return 0;
- } else {
- return (double) node.getValue().nbEvents / parent.getValue().nbEvents;
}
+ return (double) node.getValue().nbEvents / parent.getValue().nbEvents;
}
}));
}
if (nestedIterator != null) {\r
if (nestedIterator.hasNext()) {\r
return true;\r
- } else {\r
- nestedIterator = null;\r
}\r
+ nestedIterator = null;\r
}\r
long time = (lastTime == -1) ? fStartTime : lastTime;\r
int index = (fReferenceTime == -1) ? 0 : (int) ((time - fReferenceTime) >> fPower);\r
lastTime = event.getTime() + event.getDuration();\r
next = event;\r
return true;\r
- } else {\r
- nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration);\r
- return nestedIterator.hasNext();\r
}\r
+ nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration);\r
+ return nestedIterator.hasNext();\r
}\r
}\r
}\r
index = (int) ((time - fReferenceTime) >> fPower);\r
fTraceEvents.setSize((int) index + 1);\r
}\r
- TimeChartEvent event = (TimeChartEvent) fTraceEvents.get((int) index);\r
+ TimeChartEvent event = fTraceEvents.get((int) index);\r
if (event == null) {\r
fTraceEvents.set((int) index, (TimeChartEvent) timeEvent);\r
} else {\r
TimeChartEvent event = fTraceEvents.get(i);\r
if (event != null) {\r
index = (int) ((event.getTime() - fReferenceTime) >> fPower);\r
- TimeChartEvent mergedEvent = (TimeChartEvent) fTraceEvents.get(index);\r
+ TimeChartEvent mergedEvent = fTraceEvents.get(index);\r
if (mergedEvent == null) {\r
fTraceEvents.set(index, event);\r
} else {\r
}\r
}\r
\r
- private void drawBookmark(Rectangle r, GC gc) {\r
+ private static void drawBookmark(Rectangle r, GC gc) {\r
gc.setForeground(BOOKMARK_OUTER_COLOR);\r
gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);\r
gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);\r
gc.drawPoint(r.x + 1, r.y + 3);\r
}\r
\r
- private void drawSearchMatch(Rectangle r, GC gc) {\r
+ private static void drawSearchMatch(Rectangle r, GC gc) {\r
gc.setForeground(SEARCH_MATCH_COLOR);\r
gc.drawPoint(r.x, r.y + r.height);\r
gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);\r
if (fRefreshBusy) {\r
fRefreshPending = true;\r
return;\r
- } else {\r
- fRefreshBusy = true;\r
}\r
+ fRefreshBusy = true;\r
}\r
// Perform the refresh on the UI thread\r
Display.getDefault().asyncExec(new Runnable() {\r
if (fRedrawBusy) {\r
fRedrawPending = true;\r
return;\r
- } else {\r
- fRedrawBusy = true;\r
}\r
+ fRedrawBusy = true;\r
}\r
final boolean reset = resetTimeIntervals;\r
// Perform the refresh on the UI thread\r
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
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.ui.views.uml2sd.util.SDMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
* below, a scale to visually locate the value in a time range (usually the minimum an maximum elapsed time in the whole
* diagram)
* </p>
- *
+ *
* @version 1.0
* @author sveyrier
*/
*/
private static int fScaleLength = 100;
/**
- * The text to display
+ * The text to display
*/
protected String fMessage;
/**
/**
* Creates a drawable tool tip instance.
- *
+ *
* @param parent The parent composite.
*/
public DrawableToolTip(Composite parent) {
// ------------------------------------------------------------------------
/**
* Returns the message to display.
- *
+ *
* @return the message to display.
*/
public String getText() {
/**
* Returns teh current time to display.
- *
+ *
* @return the current time to display
*/
public String getAccessibleText() {
/**
* Returns the horizontal margin.
- *
+ *
* @return the horizontal margin.
*/
protected static int getHorizontalMargin() {
/**
* Sets the horizontal margin.
- *
+ *
* @param margin The margin to set.
*/
protected static void setHorizontalMargin(int margin) {
/**
* Returns the vertical margin.
- *
+ *
* @return the vertical margin.
*/
protected static int getVerticalMargin() {
/**
* Sets the vertical margin.
- *
+ *
* @param margin The margin to set.
*/
protected static void setVerticalMargin(int margin) {
/**
* Returns the text scale margin.
- *
+ *
* @return the text scale margin.
*/
protected static int getTextScaleMargin() {
/**
* Returns the scale length.
- *
+ *
* @return the scale length.
*/
protected static int getScaleLength() {
/**
* Sets the scale length.
- *
+ *
* @param scaleLength The scale length to set.
*/
protected static void setScaleLength(int scaleLength) {
fScaleLength = scaleLength;
}
-
+
/**
* Display the tooltip using the given time range(min,max) the current value and the time unit The tooltip will stay
* on screen until it is told otherwise
- *
+ *
* @param value the current in the scale
* @param min the scale min
* @param max the scale max
* Disposes the system resource used by this kind of toolTips (a colors array essentially)
*/
public void dispose() {
- for (int i = 0; i < fColors.length; i++)
+ for (int i = 0; i < fColors.length; i++) {
fColors[i].dispose();
+ }
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
int step = fScaleLength / 10;
// double gr = (max - min) / 10;
- ITmfTimestamp minMaxdelta = (TmfTimestamp) fMinMaxRange.getEndTime().getDelta(fMinMaxRange.getStartTime());
+ ITmfTimestamp minMaxdelta = fMinMaxRange.getEndTime().getDelta(fMinMaxRange.getStartTime());
double gr = (minMaxdelta.getValue()) / (double) 10;
// double delta = currentValue-min;
- ITmfTimestamp delta = (TmfTimestamp) fCurrentValue.getDelta(fMinMaxRange.getStartTime());
+ ITmfTimestamp delta = fCurrentValue.getDelta(fMinMaxRange.getStartTime());
long absDelta = Math.abs(delta.getValue());
-
+
int colIndex = 0;
if (gr != 0) {
// colIndex = Math.round((float)(Math.log(1+delta)/gr));
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
* <p>
* This class implements the graphical context for the sequence diagram widgets.
* </p>
- *
- * @version 1.0
+ *
+ * @version 1.0
* @author sveyrier
*/
public class NGC implements IGC {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+
/**
* The graphical context.
*/
*/
protected int fVisibleX;
/**
- * The current yx value (view visible height - visible screen bounds)
+ * The current yx value (view visible height - visible screen bounds)
*/
protected int yx;
/**
- * The current xx value (view visible width - visible screen bounds)
+ * The current xx value (view visible width - visible screen bounds)
*/
protected int xx;
/**
- * <code>true</code> to draw with focus else <code>false</code>.
+ * <code>true</code> to draw with focus else <code>false</code>.
*/
protected boolean fDrawWithFocus = false;
* The static visible screen bounds.
*/
private static int fVisibleScreenBounds = 0;
-
-
+
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
* Default constructor.
- *
+ *
* @param scrollView A sequence diagram view reference.
* @param gc A graphical context.
*/
/**
* Get code for drawings at given x and y position.
- *
+ *
* @param x The x position
* @param y The y position.
* @return A code for top, bottom, right and left
} else if (y < fVisibleY) {
c |= 0x02; // bottom
}
-
+
if (x > xx) {
c |= 0x04; // right
} else if (x < fVisibleX) {
*/
@Override
public void drawLine(int x1, int y1, int x2, int y2) {
- int localX1 = x1;
- int localY1 = y1;
+ int localX1 = x1;
+ int localY1 = y1;
int localX2 = x2;
int localY2 = y2;
-
+
localX1 = Math.round(localX1 * fView.fZoomValue);
localY1 = Math.round(localY1 * fView.fZoomValue);
localX2 = Math.round(localX2 * fView.fZoomValue);
int localY = y;
int localWidth = width;
int localHeight = height;
-
+
localX = Math.round(localX * fView.fZoomValue);
// Workaround to avoid problems for some special cases (not very nice)
if (localY != getContentsY()) {
}
fContext.drawRectangle(localX, localY, localWidth, localHeight);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawFocus(int, int, int, int)
i++;
localPoint[i] = fView.contentsToViewY(Math.round(points[i] * fView.fZoomValue));
}
-
- if (validatePolygonHeight(localPoint) <= 0)
+
+ if (validatePolygonHeight(localPoint) <= 0) {
return;
-
+ }
+
fContext.fillPolygon(localPoint);
}
i++;
localPoint[i] = fView.contentsToViewY(Math.round(points[i] * fView.fZoomValue));
}
-
+
if (validatePolygonHeight(localPoint) <= 0) {
return;
}
int localY = y;
int localWidth = width;
int localHeight = height;
-
+
localX = Math.round(localX * fView.fZoomValue);
localY = Math.round(localY * fView.fZoomValue);
localWidth = Math.round(localWidth * fView.fZoomValue);
setForeground(tempColor);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#textExtent(java.lang.String)
*/
@Override
public int textExtent(String name) {
- return ((Point) (fContext.textExtent(name))).x;
+ return fContext.textExtent(name).x;
}
/*
public void drawText(String string, int x, int y, boolean isTrans) {
int localX = x;
int localY = y;
-
+
localX = Math.round(localX * fView.fZoomValue);
localY = Math.round(localY * fView.fZoomValue);
fContext.drawText(string, fView.contentsToViewX(localX), fView.contentsToViewY(localY), isTrans);
int localY = y;
int localWidth = width;
int localHeight = height;
-
+
localX = Math.round(localX * fView.fZoomValue);
localY = Math.round(localY * fView.fZoomValue);
localWidth = Math.round(localWidth * fView.fZoomValue);
/**
* Method to draw a text in rectangle. (Linux GTK Workaround)
- *
+ *
* @param string The text to draw.
* @param x The x position.
* @param y The y position.
if (tx.y > localHeight) {
return;
}
-
+
// Adjust height and y
if (y < -fVisibleScreenBounds) {
localHeight = localHeight + y + fVisibleScreenBounds;
} else if (localHeight + y > fView.getVisibleHeight() + fVisibleScreenBounds) {
localHeight = fView.getVisibleHeight() + fVisibleScreenBounds - y;
}
-
+
if (tx.x <= localWidth) {
localDrawText(name, x + 1 + (localWidth - tx.x) / 2, y + 1 + (localHeight - tx.y) / 2, trans);
} else {
int localY = yValue;
int localWidth = width;
int localHeight = height;
-
+
localX = Math.round(localX * fView.fZoomValue);
localY = Math.round(localY * fView.fZoomValue);
localWidth = Math.round(localWidth * fView.fZoomValue);
public void drawImage(IImage image, int xValue, int yValue, int maxWith, int maxHeight) {
int localX = xValue;
int localY = yValue;
-
+
Image img = null;
if (image != null && image.getImage() instanceof Image) {
img = (Image) image.getImage();
/**
* Returns the current font height.
- *
+ *
* @return the current font height.
*/
protected int getCurrentFontHeight() {
public float getZoom() {
if (fView != null) {
return fView.fZoomValue;
- }
+ }
return 1;
}
public void setDrawTextWithFocusStyle(boolean focus) {
fDrawWithFocus = focus;
}
-
+
/**
* Returns the screen bounds.
- *
+ *
* @return the screen bounds.
*/
protected static int getVscreenBounds() {
/**
* Sets the visible screen bounds.
- *
+ *
* @param vBounds the screen bounds.
*/
protected static void setVscreenBounds(int vBounds) {
fVisibleScreenBounds = vBounds;
}
-
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
-
+
/**
* Validates the polygon height
- *
+ *
* @param localPoint array of points
* @return height
*/
int max = 0;
int min = Integer.MAX_VALUE;
while (i < localPoint.length) {
- max = Math.abs(localPoint[i]) > Math.abs(max) ? localPoint[i] : max;
+ max = Math.abs(localPoint[i]) > Math.abs(max) ? localPoint[i] : max;
min = Math.abs(localPoint[i]) < Math.abs(min) ? localPoint[i] : min;
i+=2;
}
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDExtendedActionBarProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPropertiesProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
if (getSDWidget() != null) {
return getSDWidget().getFrame();
}
- else {
- return null;
- }
+ return null;
}
/**
if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
loader.setViewer(this);
return false;
- } else {
- loadBlank();
- return true;
}
+ loadBlank();
+ return true;
}
/**
for (int i = 0; i < list.size(); i++) {
if (!fSelectedNodeList.contains(list.get(i))) {
fSelectedNodeList.add(list.get(i));
- ((GraphNode) list.get(i)).setSelected(true);
+ list.get(i).setSelected(true);
}
}
StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
public void removeSelection(List<GraphNode> list) {
fSelectedNodeList.removeAll(list);
for (int i = 0; i < list.size(); i++) {
- ((GraphNode) list.get(i)).setSelected(false);
- ((GraphNode) list.get(i)).setFocused(false);
+ list.get(i).setSelected(false);
+ list.get(i).setFocused(false);
}
StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
fSelProvider.setSelection(selection);
*/
public void clearSelection() {
for (int i = 0; i < fSelectedNodeList.size(); i++) {
- ((GraphNode) fSelectedNodeList.get(i)).setSelected(false);
- ((GraphNode) fSelectedNodeList.get(i)).setFocused(false);
+ fSelectedNodeList.get(i).setSelected(false);
+ fSelectedNodeList.get(i).setFocused(false);
}
fCurrentGraphNode = null;
fSelectedNodeList.clear();
fOverView = new Image(getDisplay(), rect.width, rect.height);
GC gcim = new GC(fOverView);
NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
fFrame.draw(context);
setContentsPos(backX, backY);
gcim.dispose();
// Set the metrics to use for lifeline text and message text
// using the Graphical Context
- Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+ Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
- int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
- int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
- int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
- int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
+ int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+ int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+ int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+ int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
int messageFontHeight = 0;
if (syncMessFontH > syncMessRetFontH) {
messageFontHeight = asyncMessRetFontH;
}
Metrics.setMessageFontHeight(messageFontHeight);
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
int width = Math.round((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
int height = Math.round((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
fFrame.draw(context);
fZoomValue = pageNumFontZoom;
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
String currentPageNum = String.valueOf(pageNum);
int ii = context.textExtent(currentPageNum);
int jj = context.getCurrentFontHeight();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
}
return false;
// Set the metrics to use for lifeline text and message text
// using the Graphical Context
- Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+ Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
- int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
- int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
- int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
- int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
+ int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+ int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+ int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+ int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
int messageFontHeight = 0;
if (syncMessFontH > syncMessRetFontH) {
messageFontHeight = asyncMessRetFontH;
}
Metrics.setMessageFontHeight(messageFontHeight);
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
int width = (int) ((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
int height = (int) ((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
fFrame.draw(context);
if (fDragAndDrop != null) {
- Lifeline node = (Lifeline) fDragAndDrop;
+ Lifeline node = fDragAndDrop;
boolean isSelected = fDragAndDrop.isSelected();
boolean hasFocus = fDragAndDrop.hasFocus();
node.setSelected(false);
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
return false;
}
int rx = Math.round(node.getX() * fZoomValue);
if (rx <= event.x && Math.round(rx + (node.getWidth() * fZoomValue)) >= event.x) {
if ((fCollapseProvider != null) && (fDragAndDrop != node)) {
- fCollapseProvider.collapseTwoLifelines((Lifeline) fDragAndDrop, node);
+ fCollapseProvider.collapseTwoLifelines(fDragAndDrop, node);
}
} else if (rx < event.x) {
- fFrame.insertLifelineAfter((Lifeline) fDragAndDrop, node);
+ fFrame.insertLifelineAfter(fDragAndDrop, node);
if (node.getIndex() < fFrame.lifeLinesCount()) {
- Lifeline temp[] = { (Lifeline) fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
+ Lifeline temp[] = { fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
fReorderList.add(temp);
} else {
- Lifeline temp[] = { (Lifeline) fDragAndDrop, null };
+ Lifeline temp[] = { fDragAndDrop, null };
fReorderList.add(temp);
}
} else {
- fFrame.insertLifelineBefore((Lifeline) fDragAndDrop, node);
- Lifeline temp[] = { (Lifeline) fDragAndDrop, node };
+ fFrame.insertLifelineBefore(fDragAndDrop, node);
+ Lifeline temp[] = { fDragAndDrop, node };
fReorderList.add(temp);
}
}
gc.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
gc.dispose();
return;
- } else {
-// Frame.setUserPref(SDViewPref.getInstance());
- SDViewPref.getInstance();
}
+ // Frame.setUserPref(SDViewPref.getInstance());
+ SDViewPref.getInstance();
Rectangle area = getClientArea();
Image dbuffer = getDrawBuffer();
fOverView = new Image(getDisplay(), r.width, r.height);
GC gcim = new GC(fOverView);
NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
fFrame.draw(context);
setContentsPos(backX, backY);
gcim.dispose();
public void setSelection(ISelection selection) {
fCurrentSelection = selection;
for (int i = 0; i < fListenerList.size(); i++) {
- ISelectionChangedListener list = (ISelectionChangedListener) fListenerList.get(i);
+ ISelectionChangedListener list = fListenerList.get(i);
list.selectionChanged(new SelectionChangedEvent(this, fCurrentSelection));
}
}
for (int i = firstVisible; i < fFrame.syncMessageCount(); i = i + messageArraysStep) {
SyncMessage m = fFrame.getSyncMessage(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.syncMessageReturnCount(); i = i + messageArraysStep) {
SyncMessage m = fFrame.getSyncMessageReturn(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.asyncMessageCount(); i = i + messageArraysStep) {
AsyncMessage m = fFrame.getAsyncMessage(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m);
fNodeList.add(t);
- t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
+ t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.asyncMessageReturnCount(); i = i + messageArraysStep) {
AsyncMessageReturn m = fFrame.getAsyncMessageReturn(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m);
fNodeList.add(t);
- t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
+ t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
}
gcim = new GC(dbuffer);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
}
return false;
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
return false;
}
if (fFrame != null) {
setFocus(0);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
colIndex = 0;
}
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
if (localMes1.getEndLifeline() != null) {
list.deltaSelected(localMes1.getEndLifeline(), event1, event2 - event1, fColors[colIndex]);
} else if (localMes2.getStartLifeline() != null) {
}
if ((fFrame != null) && (fNextNodeY == 0)) {
for (int i = 0; i < fNodeList.size() - 1 && i < 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
if (fLifeline != null) {
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
}
}
boolean done = false;
if (fFrame != null) {
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
}
}
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
}
break;
- } else {
- lastM1 = m1;
- lastM2 = m2;
- lastY1 = m1Y;
- lastY2 = m2Y;
}
+ lastM1 = m1;
+ lastM2 = m2;
+ lastY1 = m1Y;
+ lastY2 = m2Y;
}
}
}
if (fFrame != null) {
setFocus(0);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
int messageMaxWidth = Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH;
int nameWidth = getName().length() * Metrics.getAverageCharWidth();
if (getName().length() * Metrics.getAverageCharWidth() > messageMaxWidth) {
- if (Frame.contains(getX(), getY() - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), messageMaxWidth, Metrics.getMessageFontHeigth(), x, y)) {
+ if (GraphNode.contains(getX(), getY() - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), messageMaxWidth, Metrics.getMessageFontHeigth(), x, y)) {
return true;
}
} else {
- if (Frame.contains(getX() + (messageMaxWidth - nameWidth) / 2, getY() + getHeight() / 2 - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), nameWidth, Metrics.getMessageFontHeigth(), x, y)) {
+ if (GraphNode.contains(getX() + (messageMaxWidth - nameWidth) / 2, getY() + getHeight() / 2 - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), nameWidth, Metrics.getMessageFontHeigth(), x, y)) {
return true;
}
}
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
* representations (like asynchronous syncMessages) will be responsible to define the missing second eventOccurrence
* property.<br>
* <br>
- *
+ *
* @see Lifeline Lifeline for more event occurence details
* @version 1.0
* @author sveyrier
*/
public abstract class BaseMessage extends GraphNode {
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
*/
protected Lifeline fEndLifeline = null;
/**
- * The visiblitiy flag.
+ * The visiblitiy flag.
*/
protected boolean fVisible = true;
*/
return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
- } else {
- /*
- * UML2 lost message kind
- */
- if (fStartLifeline != null) {
- return fStartLifeline.getY() + fStartLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
- }
+ }
+ /*
+ * UML2 lost message kind
+ */
+ if (fStartLifeline != null) {
+ return fStartLifeline.getY() + fStartLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
+ }
- /*
- * UML2 found message kind
- */
- if (fEndLifeline != null) {
- return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
- }
+ /*
+ * UML2 found message kind
+ */
+ if (fEndLifeline != null) {
+ return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
}
// return 0 by default
return 0;
* <br>
* This method is typically used to faster execute none graphical operation like tooltip lookup.<br>
* <br>
- *
+ *
* @param quick true to get an approximative value<br>
* false to get the exact x value<br>
* @return the graph node x coordinate
* <br>
* This method is typically used to faster execute none graphical operation like tooltip lookup.<br>
* <br>
- *
+ *
* @param quick true to get an approximative value<br>
* false to get the exact x value
* @return the graph node width
/**
* Sets the visibility value.
- *
+ *
* @param value The visibility to set.
*/
public void setVisible(boolean value) {
}
/**
- * @return the visibility value.
+ * @return the visibility value.
*/
public boolean isVisible() {
return fVisible;
/**
* Set the lifeline from which this message has been sent.
- *
+ *
* @param lifeline - the message sender
*/
public void setStartLifeline(Lifeline lifeline) {
/**
* Returns the lifeline from which this message has been sent.
- *
+ *
* @return the message sender
*/
public Lifeline getStartLifeline() {
/**
* Returns the lifeline which has received this message.
- *
+ *
* @return the message receiver
*/
public Lifeline getEndLifeline() {
/**
* Set the lifeline which has receive this message.
- *
+ *
* @param lifeline the message receiver
*/
public void setEndLifeline(Lifeline lifeline) {
/**
* Set the event occurrence when this message occurs.<br>
- *
+ *
* @param occurrence the event occurrence to assign to this message.<br>
* @see Lifeline Lifeline for more event occurence details
*/
/**
* Returns the event occurence when is message occurs.<br>
- *
+ *
* @return the event occurrence assigned to this message.<br>
* @see Lifeline Lifeline for more event occurence details
*/
* WARNING: this method will return a valid result only for execution occurrences which are visible in the View.<br>
* As consequence this method is only used for drawing purpose, especially to determine the exact message x
* coordinate and width.<br>
- *
+ *
* @see BaseMessage#getX(boolean)
* @param event the event occurrence to test
* @return true if occurs on a execution occurrence owned by the sending lifeine, false otherwise
* WARNING: this method will return a valid result only for execution occurrences which are visible in the View.<br>
* As consequence this method is only used for drawing purpose, especially to determine the exact message x
* coordinate and width.<br>
- *
+ *
* @see BaseMessage#getX(boolean)
* @param event the event occurrence to test
* @return true if occurs on a execution occurrence owned by the receiving lifeline, false otherwise
* rectangle width is negative.
*/
if (getName().length() * Metrics.getAverageCharWidth() > Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH) {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), xValue, yValue)) {
+ if (GraphNode.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), xValue, yValue)) {
return true;
}
} else {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), xValue, yValue)) {
+ if (GraphNode.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), xValue, yValue)) {
return true;
}
}
// Test if the point is in part 1 of the self message
// see: "private void drawMessage (NGC context)" method for self message drawing schema
- if (Frame.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
+ if (GraphNode.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
return true;
}
// Test if the point is in part 3 of the self message
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, xValue, yValue)) {
+ if (GraphNode.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, xValue, yValue)) {
return true;
}
// Test if the point is in part 5 of the self message
- if (Frame.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
+ if (GraphNode.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
return true;
}
// false otherwise
return false;
}
- if (Frame.contains(x, y - tempHeight, width, tempHeight, xValue, yValue)) {
+ if (GraphNode.contains(x, y - tempHeight, width, tempHeight, xValue, yValue)) {
return true;
}
// false otherwise
/**
* Method to draw the message using the graphical context.
- *
+ *
* @param context A graphical context to draw in.
*/
protected void drawMessage(IGC context) {
}
}
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNodee#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
if (!isVisible()) {
return;
}
-
+
// Draw it selected?*/
if (isSelected()) {
ISDPreferences pref = SDViewPref.getInstance();
/**
* Determine if two messages are identical. This default implementation considers that overlapping messages with
* same coordinates are identical.
- *
+ *
* @param message - the message to compare with
* @return true if identical false otherwise
- *
+ *
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isSameAs(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode)
*/
@Override
/**
* Method drawRot.
- *
+ *
* @param x A x coordinate
* @param y A y coordinate
* @param w A width
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* BasicExecutionOccurrence is the UML2 execution occurrence graphical representation. It is attached to one Lifeline,
* the event occurrence "duration" along the lifeline is defined by two event occurrences
- *
+ *
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
- * @version 1.0
+ * @version 1.0
* @author sveyrier
- *
+ *
*/
public class BasicExecutionOccurrence extends GraphNode {
// ------------------------------------------------------------------------
/**
- * The corresponding lifeline.
+ * The corresponding lifeline.
*/
protected Lifeline fLifeline = null;
int width = getWidth();
int height = getHeight();
- if (Frame.contains(x, y, width, height, xValue, yValue)) {
+ if (GraphNode.contains(x, y, width, height, xValue, yValue)) {
return true;
}
public String getName() {
if (super.getName() == null || super.getName().equals("")) { //$NON-NLS-1$
return fLifeline.getToolTipText();
- } else {
- return super.getName();
}
+ return super.getName();
}
/**
* Set the lifeline on which the execution occurrence appears.
- *
+ *
* @param theLifeline - the parent lifeline
*/
public void setLifeline(Lifeline theLifeline) {
/**
* Get the lifeline on which the execution occurrence appears.
- *
+ *
* @return - the parent lifeline
*/
public Lifeline getLifeline() {
/**
* Get the execution start event occurrence
- *
+ *
* @return the start event occurrence to set
*/
@Override
/**
* Set the execution end event occurrence
- *
+ *
* @return the end event occurrence to set
*/
@Override
/**
* Set the execution start event occurrence
- *
+ *
* @param occurrence the start event occurrence to set
*/
public void setStartOccurrence(int occurrence) {
/**
* Set the execution end event occurrence
- *
+ *
* @param occurrence the end event occurrence to set
*/
public void setEndOccurrence(int occurrence) {
IColor tempStrokeColor = null;
ISDPreferences pref = SDViewPref.getInstance();
-
+
// The execution occurrence is selected
// if the owning lifeline is selected
if (fLifeline.isSelected() || isSelected()) {
/**
* Rewrite this method in your extension in order to support customized fill colors
- *
+ *
* @param context
* @return IColor
*/
/**
* Rewrite this method in your extension in order to support customized stroke colors
- *
+ *
* @param context
* @return IColor
*/
public int getWidth() {
if (fHorizontalIndex == 0) {
return 3 * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 - Metrics.FRAME_H_MARGIN - Metrics.LIFELINE_SPACING / 2;
- } else {
- return fHorizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
}
+ return fHorizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
}
/*
return null;
}
for (int i = fromIndex; i < list.size(); i++) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
// only lifeline list is x ordered
// Stop browsing the list if the node is outside the visible area
// all others nodes will be not visible
return;
}
for (int i = 0; i < timeArray.size(); i++) {
- SDTimeEvent m = (SDTimeEvent) timeArray.get(i);
+ SDTimeEvent m = timeArray.get(i);
if (m.getTime().compareTo(fMaxSDTime, true) > 0) {
fMaxSDTime = m.getTime();
return;
}
for (int i = 0; i < timeArray.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) timeArray.get(i);
- SDTimeEvent m2 = (SDTimeEvent) timeArray.get(i + 1);
+ SDTimeEvent m1 = timeArray.get(i);
+ SDTimeEvent m2 = timeArray.get(i + 1);
updateMinMax(m1, m2);
}
List<SDTimeEvent> timeArray = new ArrayList<SDTimeEvent>();
while (it.hasNext()) {
String nodeType = it.next();
- List<GraphNode> list = (List<GraphNode>) fNodes.get(nodeType);
+ List<GraphNode> list = fNodes.get(nodeType);
for (int i = 0; i < list.size(); i++) {
Object timedNode = list.get(i);
if ((timedNode instanceof ITimeRange) && ((ITimeRange) timedNode).hasTimeInfo()) {
- int event = ((GraphNode) list.get(i)).getStartOccurrence();
+ int event = list.get(i).getStartOccurrence();
ITmfTimestamp time = ((ITimeRange) list.get(i)).getStartTime();
SDTimeEvent f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
timeArray.add(f);
- if (event != ((GraphNode) list.get(i)).getEndOccurrence()) {
+ if (event != list.get(i).getEndOccurrence()) {
event = ((AsyncMessage) list.get(i)).getEndOccurrence();
time = ((ITimeRange) list.get(i)).getEndTime();
f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
* which you can customize fill and/or.
- *
+ *
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
- * @version 1.0
+ * @version 1.0
* @author sveyrier
- *
+ *
*/
public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange {
// Attributes
// ------------------------------------------------------------------------
/**
- * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
+ * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
*/
protected int[] fFillRGB;
/**
*/
protected IImage fEllipsesImage;
/**
- * The start time stamp.
+ * The start time stamp.
*/
protected ITmfTimestamp fStartTime;
/**
*/
protected ITmfTimestamp fEndTime;
/**
- * Flag to indicate whether time information is available or not.
+ * Flag to indicate whether time information is available or not.
*/
protected boolean fHasTimeInfo;
/**
* Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
- *
+ *
* @param red A value for red.
* @param green A green value for green.
* @param blue A value blue.
/**
* Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
- *
+ *
* @param red A value for red.
* @param green A green value for green.
* @param blue A value blue.
/**
* Set the corresponding image.
- *
+ *
* @param image A image to set.
*/
public void setImage(IImage image) {
/**
* Set the top ellipses image.
- *
+ *
* @param image A image to set.
*/
public void setTopEllipsesImage(IImage image) {
/**
* Set the time when the execution occurrence starts.
- *
+ *
* @param time the time when the execution occurrence starts
*/
public void setStartTime(ITmfTimestamp time) {
/**
* Set the time when the execution occurrence ends.
- *
+ *
* @param time the time when the execution occurrence ends
*/
public void setEndTime(ITmfTimestamp time) {
context.setBackground(tempFillColor);
}
return tempFillColor;
- } else {
- return super.setUnselectedFillColor(context);
}
+ return super.setUnselectedFillColor(context);
}
/*
IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]);
context.setForeground(tempStrokeColor);
return tempStrokeColor;
- } else {
- return super.setUnselectedStrokeColor(context);
}
+ return super.setUnselectedStrokeColor(context);
}
}
if (!fHasChilden) {
return null;
}
- return (List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG);
+ return fNodes.get(Lifeline.LIFELINE_TAG);
}
/**
if (!fHasChilden) {
return null;
}
- return (List<GraphNode>) fNodes.get(SyncMessage.SYNC_MESS_TAG);
+ return fNodes.get(SyncMessage.SYNC_MESS_TAG);
}
/**
if (!fHasChilden) {
return null;
}
- return (List<GraphNode>) fNodes.get(AsyncMessage.ASYNC_MESS_TAG);
+ return fNodes.get(AsyncMessage.ASYNC_MESS_TAG);
}
/**
if (!fHasChilden) {
return null;
}
- return (List<GraphNode>) fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
+ return fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
}
/**
if (!fHasChilden) {
return null;
}
- return (List<GraphNode>) fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
+ return fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
}
/**
if (!fHasChilden) {
return 0;
} else if (fIndexes.get(Lifeline.LIFELINE_TAG) != null) {
- return ((Integer) fIndexes.get(Lifeline.LIFELINE_TAG)).intValue();
+ return fIndexes.get(Lifeline.LIFELINE_TAG).intValue();
}
return 0;
}
if (!fHasChilden) {
return 0;
} else if (fIndexes.get(SyncMessage.SYNC_MESS_TAG) != null) {
- return ((Integer) fIndexes.get(SyncMessage.SYNC_MESS_TAG)).intValue();
+ return fIndexes.get(SyncMessage.SYNC_MESS_TAG).intValue();
}
return 0;
}
if (!fHasChilden) {
return 0;
} else if (fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG) != null) {
- return ((Integer) fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG)).intValue();
+ return fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG).intValue();
}
return 0;
}
if (!fHasChilden) {
return 0;
} else if (fIndexes.get(AsyncMessage.ASYNC_MESS_TAG) != null) {
- return ((Integer) fIndexes.get(AsyncMessage.ASYNC_MESS_TAG)).intValue();
+ return fIndexes.get(AsyncMessage.ASYNC_MESS_TAG).intValue();
}
return 0;
}
if (!fHasChilden) {
return 0;
} else if (fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG) != null) {
- return ((Integer) fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG)).intValue();
+ return fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG).intValue();
}
return 0;
}
return;
}
for (int i = 0; i < timeArray.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) timeArray.get(i);
- SDTimeEvent m2 = (SDTimeEvent) timeArray.get(i + 1);
+ SDTimeEvent m1 = timeArray.get(i);
+ SDTimeEvent m2 = timeArray.get(i + 1);
if (SDViewPref.getInstance().excludeExternalTime() && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
bounds[0] = null;
bounds[1] = null;
for (int i = 0; i < timeArray.size(); i++) {
- SDTimeEvent m = (SDTimeEvent) timeArray.get(i);
+ SDTimeEvent m = timeArray.get(i);
if (m.getTime().compareTo(dateToFind, true) > 0) {
bounds[1] = m.getGraphNode();
if (i > 0) {
- bounds[0] = ((SDTimeEvent) timeArray.get(i - 1)).getGraphNode();
+ bounds[0] = timeArray.get(i - 1).getGraphNode();
return true;
}
return false;
}
}
- bounds[0] = ((SDTimeEvent) timeArray.get(timeArray.size() - 1)).getGraphNode();
+ bounds[0] = timeArray.get(timeArray.size() - 1).getGraphNode();
}
return false;
}
if (fIndexes.size() == 0) {
return;
}
- int lifeLineDrawIndex = ((Integer) fIndexes.get(Lifeline.LIFELINE_TAG)).intValue();
- for (int i = lifeLineDrawIndex; i < ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i = i + lifelineArryStep) {
- Lifeline toDraw = (Lifeline) ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).get(i);
+ int lifeLineDrawIndex = fIndexes.get(Lifeline.LIFELINE_TAG).intValue();
+ for (int i = lifeLineDrawIndex; i < fNodes.get(Lifeline.LIFELINE_TAG).size(); i = i + lifelineArryStep) {
+ Lifeline toDraw = (Lifeline) fNodes.get(Lifeline.LIFELINE_TAG).get(i);
if (toDraw.getX() - Metrics.LIFELINE_SPACING / 2 > context.getContentsX() + context.getVisibleWidth()) {
break;
}
List<SDTimeEvent> timeArray = super.buildTimeArray();
fExecutionOccurrencesWithTime = null;
if (getLifelines() != null) {
- for (int i = 0; i < ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i++) {
- Lifeline lifeline = (Lifeline) ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).get(i);
+ for (int i = 0; i < fNodes.get(Lifeline.LIFELINE_TAG).size(); i++) {
+ Lifeline lifeline = (Lifeline) fNodes.get(Lifeline.LIFELINE_TAG).get(i);
if (lifeline.hasTimeInfo() && lifeline.getExecutions() != null) {
for (Iterator<GraphNode> j = lifeline.getExecutions().iterator(); j.hasNext();) {
GraphNode o = j.next();
event = message.getEventOccurrence();
}
for (int i = 0; i < list.size(); i++) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
if ((syncNode.getEventOccurrence() > event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
}
}
for (int i = list.size() - 1; i >= 0; i--) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
if ((syncNode.getEventOccurrence() < event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
event = message.getEventOccurrence();
}
for (int i = 0; i < list.size(); i++) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
if ((syncNode.getEventOccurrence() > event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
}
}
for (int i = list.size() - 1; i >= 0; i--) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
if ((syncNode.getEventOccurrence() < event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
if ((node1 != null) && (node2 != null)) {
if (distanceFromEvent(node1, event) < distanceFromEvent(node2, event)) {
return node1;
- } else {
- return node2;
}
+ return node2;
} else if (node1 != null) {
return node1;
} else if (node2 != null) {
GraphNode result = null;
Lifeline lifeline = null;
if (startMessage != null) {
- event = ((BaseMessage) startMessage).getEventOccurrence();
- lifeline = ((BaseMessage) startMessage).getEndLifeline();
+ event = startMessage.getEventOccurrence();
+ lifeline = startMessage.getEndLifeline();
if (lifeline == null) {
- lifeline = ((BaseMessage) startMessage).getStartLifeline();
+ lifeline = startMessage.getStartLifeline();
}
}
if (lifeline == null) {
GraphNode result = null;
Lifeline lifeline = null;
if (startMessage != null) {
- event = ((BaseMessage) startMessage).getEventOccurrence();
- lifeline = ((BaseMessage) startMessage).getStartLifeline();
+ event = startMessage.getEventOccurrence();
+ lifeline = startMessage.getStartLifeline();
if (lifeline == null) {
- lifeline = ((BaseMessage) startMessage).getEndLifeline();
+ lifeline = startMessage.getEndLifeline();
}
}
if (lifeline == null) {
public GraphNode getNextLifelineMessage(Lifeline lifeline, BaseMessage startMessage) {
int event = 0;
if (startMessage != null) {
- event = ((BaseMessage) startMessage).getEventOccurrence();
+ event = startMessage.getEventOccurrence();
}
if (lifeline == null) {
return null;
}
}
- List<GraphNode> fNodeList = (List<GraphNode>) fForwardNodes.get(nodeToAdd.getArrayId());
+ List<GraphNode> fNodeList = fForwardNodes.get(nodeToAdd.getArrayId());
List<GraphNode> bNodeList = null;
if (fBackwardNodes != null) {
- bNodeList = (List<GraphNode>) fBackwardNodes.get(nodeToAdd.getArrayId());
+ bNodeList = fBackwardNodes.get(nodeToAdd.getArrayId());
}
if (fNodeList != null && fNodeList.size() > 0) {
// check if the nodes are added y ordered
// if not, tag the list to sort it later (during draw)
- GraphNode node = (GraphNode) fNodeList.get(fNodeList.size() - 1);
+ GraphNode node = fNodeList.get(fNodeList.size() - 1);
Comparator<GraphNode> fcomp = nodeToAdd.getComparator();
Comparator<GraphNode> bcomp = nodeToAdd.getBackComparator();
if ((fcomp != null) && (fcomp.compare(node, nodeToAdd) > 0)) {
GraphNode node = null;
while (it.hasNext()) {
Object nodeType = it.next();
- List<GraphNode> list = (List<GraphNode>) fNodes.get(nodeType);
- int index = ((Integer) fIndexes.get(nodeType)).intValue();
+ List<GraphNode> list = fNodes.get(nodeType);
+ int index = fIndexes.get(nodeType).intValue();
node = getNodeFromListAt(x, y, list, index);
if (toReturn == null) {
toReturn = node;
Iterator<String> it = fNodes.keySet().iterator();
while (it.hasNext()) {
Object nodeType = it.next();
- List<GraphNode> nodesList = (List<GraphNode>) fNodes.get(nodeType);
+ List<GraphNode> nodesList = fNodes.get(nodeType);
if (nodesList == null || nodesList.isEmpty()) {
return null;
}
for (int i = 0; i < nodesList.size(); i++) {
- GraphNode node = (GraphNode) nodesList.get(i);
+ GraphNode node = nodesList.get(i);
int nw = node.getWidth();
int nh = node.getHeight();
int nx = node.getX();
return null;
}
for (int i = fromIndex; i < list.size(); i++) {
- GraphNode node = (GraphNode) list.get(i);
+ GraphNode node = list.get(i);
if (node.contains(x, y)) {
return node;
}
while (it.hasNext()) {
String nodeType = it.next();
int direction = 1;
- int drawIndex = ((Integer) fIndexes.get(nodeType)).intValue();
+ int drawIndex = fIndexes.get(nodeType).intValue();
/*
* if (x==0) { drawIndex = 0; indexes.put(nodeType,new Integer(drawIndex)); }
*/
- if ((fNodes.get(nodeType) != null) && (((List<GraphNode>) fNodes.get(nodeType)).size() > 1)) {
- if (((GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(drawIndex)).positiveDistanceToPoint(x, y)) {
+ if ((fNodes.get(nodeType) != null) && (fNodes.get(nodeType).size() > 1)) {
+ if (fNodes.get(nodeType).get(drawIndex).positiveDistanceToPoint(x, y)) {
direction = -1;
}
}
if ((direction == -1) && (fBackwardNodes.get(nodeType) != null)) {
- GraphNode currentNode = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(drawIndex);
- drawIndex = Arrays.binarySearch(((List<GraphNode>) fBackwardNodes.get(nodeType)).toArray(new GraphNode[((List<GraphNode>) fBackwardNodes.get(nodeType)).size()]),
- ((List<GraphNode>) fNodes.get(nodeType)).get(drawIndex), currentNode.getBackComparator());
- fNodes.put(nodeType, (List<GraphNode>) fBackwardNodes.get(nodeType));
+ GraphNode currentNode = fNodes.get(nodeType).get(drawIndex);
+ drawIndex = Arrays.binarySearch(fBackwardNodes.get(nodeType).toArray(new GraphNode[fBackwardNodes.get(nodeType).size()]),
+ fNodes.get(nodeType).get(drawIndex), currentNode.getBackComparator());
+ fNodes.put(nodeType, fBackwardNodes.get(nodeType));
if (drawIndex < 0) {
drawIndex = 0;
direction = 1;
} else {
- fNodes.put(nodeType, (List<GraphNode>) fBackwardNodes.get(nodeType));
+ fNodes.put(nodeType, fBackwardNodes.get(nodeType));
}
}
GraphNode prev = null;
- for (int i = drawIndex; i < ((List<GraphNode>) fNodes.get(nodeType)).size() && i >= 0; i = i + direction) {
+ for (int i = drawIndex; i < fNodes.get(nodeType).size() && i >= 0; i = i + direction) {
drawIndex = i;
fIndexes.put(nodeType, Integer.valueOf(i));
- GraphNode currentNode = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(i);
+ GraphNode currentNode = fNodes.get(nodeType).get(i);
if (prev == null) {
prev = currentNode;
sort = fBackwardSort;
}
- if (i < ((List<GraphNode>) fNodes.get(nodeType)).size() - 1) {
- GraphNode next = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(i + 1);
+ if (i < fNodes.get(nodeType).size() - 1) {
+ GraphNode next = fNodes.get(nodeType).get(i + 1);
if ((comp != null) && (comp.compare(currentNode, next) > 0)) {
sort.put(nodeType, Boolean.TRUE);
}
}
if (direction == 1) {
- if (((GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(i)).positiveDistanceToPoint(x, y)) {
+ if (fNodes.get(nodeType).get(i).positiveDistanceToPoint(x, y)) {
break;
}
} else {
fNodes.put(nodeType, fForwardNodes.get(nodeType));
if ((fBackwardNodes.get(nodeType) != null) && (direction == -1)) {
// nodes.put(nodeType,fnodes.get(nodeType));
- int index = ((Integer) fIndexes.get(nodeType)).intValue();
- List<GraphNode> list = (List<GraphNode>) fNodes.get(nodeType);
- List<GraphNode> backList = (List<GraphNode>) fBackwardNodes.get(nodeType);
- GraphNode currentNode = (GraphNode) (backList.get(index));
+ int index = fIndexes.get(nodeType).intValue();
+ List<GraphNode> list = fNodes.get(nodeType);
+ List<GraphNode> backList = fBackwardNodes.get(nodeType);
+ GraphNode currentNode = (backList.get(index));
if (index > 0) {
index = Arrays.binarySearch(list.toArray(new GraphNode[list.size()]), backList.get(index), currentNode.getComparator());
if (index < 0) {
}
}
- for (int i = drawIndex; i < ((List<GraphNode>) fNodes.get(nodeType)).size() && i >= 0; i++) {
- GraphNode toDraw = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(i);
+ for (int i = drawIndex; i < fNodes.get(nodeType).size() && i >= 0; i++) {
+ GraphNode toDraw = fNodes.get(nodeType).get(i);
toDraw.updateIndex(x, y, width, height);
if (!toDraw.isVisible(x, y, width, height)) {
break;
Iterator<String> it = fForwardSort.keySet().iterator();
while (it.hasNext()) {
String nodeType = it.next();
- boolean sort = ((Boolean) fForwardSort.get(nodeType)).booleanValue();
+ boolean sort = fForwardSort.get(nodeType).booleanValue();
if (sort) {
- GraphNode[] temp = ((List<GraphNode>) fForwardNodes.get(nodeType)).toArray(new GraphNode[((List<GraphNode>)fForwardNodes.get(nodeType)).size()]);
- GraphNode node = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(0);
+ GraphNode[] temp = fForwardNodes.get(nodeType).toArray(new GraphNode[fForwardNodes.get(nodeType).size()]);
+ GraphNode node = fNodes.get(nodeType).get(0);
Arrays.sort(temp, node.getComparator());
fForwardSort.put(nodeType, Boolean.FALSE);
fNodes.put(nodeType, Arrays.asList(temp));
Iterator<String> it2 = fBackwardSort.keySet().iterator();
while (it2.hasNext()) {
String nodeType = it2.next();
- boolean sort = ((Boolean) fBackwardSort.get(nodeType)).booleanValue();
+ boolean sort = fBackwardSort.get(nodeType).booleanValue();
if (sort) {
- GraphNode[] temp = ((List<GraphNode>) fBackwardNodes.get(nodeType)).toArray(new GraphNode[((List<GraphNode>) fBackwardNodes.get(nodeType)).size()]);
- GraphNode node = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(0);
+ GraphNode[] temp = fBackwardNodes.get(nodeType).toArray(new GraphNode[fBackwardNodes.get(nodeType).size()]);
+ GraphNode node = fNodes.get(nodeType).get(0);
Arrays.sort(temp, node.getBackComparator());
fBackwardSort.put(nodeType, Boolean.FALSE);
fBackwardNodes.put(nodeType, Arrays.asList(temp));
while (it3.hasNext()) {
count = 0;
Object nodeType = it3.next();
- GraphNode node = (GraphNode) ((List<GraphNode>) fNodes.get(nodeType)).get(0);
+ GraphNode node = fNodes.get(nodeType).get(0);
context.setFont(SDViewPref.getInstance().getFont(node.fPrefId));
- int index = ((Integer) fIndexes.get(nodeType)).intValue();
- count = drawNodes(context, (List<GraphNode>) fNodes.get(nodeType), index, arrayStep);
+ int index = fIndexes.get(nodeType).intValue();
+ count = drawNodes(context, fNodes.get(nodeType), index, arrayStep);
if (TmfUiTracer.isDisplayTraced()) {
TmfUiTracer.traceDisplay(count + " " + nodeType + " drawn, starting from index " + index + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return 0;
}
- GraphNode node = (GraphNode) list.get(0);
+ GraphNode node = list.get(0);
context.setFont(SDViewPref.getInstance().getFont(node.fPrefId));
Comparator<GraphNode> comparator = node.getComparator();
for (int i = startIndex; i < list.size(); i = i + step) {
- GraphNode toDraw = (GraphNode) list.get(i);
+ GraphNode toDraw = list.get(i);
if (i < list.size() - 1) {
- GraphNode next = (GraphNode) list.get(i + 1);
+ GraphNode next = list.get(i + 1);
if ((comparator != null) && (comparator.compare(toDraw, next) > 0)) {
fForwardSort.put(next.getArrayId(), Boolean.TRUE);
}
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* Class to add a hot spot marker.
- *
+ *
* @version 1.0
* @author sveyrier
*/
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+
/**
* Default constructor
*/
/**
* Set the marker image.
- *
+ *
* @param img A image to set
*/
public void setImage(IImage img) {
/**
* Set the lifeline on which the execution occurrence appears.
- *
+ *
* @param occ the parent lifeline
*/
public void setExecution(BasicExecutionOccurrence occ) {
/**
* Get the lifeline on which the execution occurrence appears.
- *
+ *
* @return - the parent lifeline
*/
public BasicExecutionOccurrence getExecOcc() {
}
/**
- * Returns the occurrence number.
- *
+ * Returns the occurrence number.
+ *
* @return the occurrence number.
*/
public int getOccurrence() {
/**
* Set the occurrence number.
- *
+ *
* @param occ A number to set.
*/
public void setOccurrence(int occ) {
int width = getWidth();
int height = getHeight();
- if (Frame.contains(x, y, width, height, xValue, yValue)) {
+ if (GraphNode.contains(x, y, width, height, xValue, yValue)) {
return true;
}
return false;
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
* Event occurrence define the drawing order of graph node along a lifeline. In this lifeline implementation, event
* occurrences are just integer index. The event occurrences with the same value on different lifelines will correspond
* the same y coordinate value.
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class Lifeline extends GraphNode {
// ------------------------------------------------------------------------
/**
* Set the lifeline category for this lifeline.
- *
+ *
* @param arrayIndex the index of the category to use
* @see Frame#setLifelineCategories(LifelineCategories[])
*/
/**
* Returns the tooltip text for the lifeline. It is the combination between the category name(if any) and the
* lifeline name
- *
+ *
* @return the tooltip text
*/
public String getToolTipText() {
LifelineCategories[] categories = fFrame.getLifelineCategories();
if (fCategory < categories.length) {
return categories[fCategory].getName() + " " + getName(); //$NON-NLS-1$
- } else {
- return ""; //$NON-NLS-1$
}
- } else {
- return ""; //$NON-NLS-1$
}
+ return ""; //$NON-NLS-1$
}
/**
* Returns the index of the first visible Execution Occurrence in the execution occurrence array.<br>
* Execution Occurrences are Y ordered in this array
- *
+ *
* @return the first visible Execution Occurrence
*/
public int getExecOccurrenceDrawIndex() {
return 0;
}
if (fIndexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG) != null) {
- return ((Integer) fIndexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG)).intValue();
+ return fIndexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG).intValue();
}
return 0;
}
/**
* Set the frame on which this lifeline must be drawn
- *
+ *
* @param parentFrame
*/
protected void setFrame(Frame parentFrame) {
/**
* Returns the frame which this lifeline is drawn
- *
+ *
* @return the Frame
*/
protected Frame getFrame() {
/**
* Set the lifeline position index in the containing frame
- *
+ *
* @param index the lifeline X position
*/
protected void setIndex(int index) {
/**
* Returns the lifeline position in de the containing frame
- *
+ *
* @return the X position
*/
public int getIndex() {
* greater event created on this lifeline are still valid and usable. This also need to inform the frame of the
* operation mostly to store in the frame the greater event found in the diagram (used to determine the frame
* height)
- *
+ *
* @param eventOcc the new current event occurrence
*/
public void setCurrentEventOccurrence(int eventOcc) {
/**
* Returns the last created event occurrence along the lifeline.
- *
+ *
* @return the current event occurrence
*/
public int getEventOccurrence() {
/**
* Creates a new event occurrence along the lifeline.
- *
+ *
* @return the new created event occurrence
*/
public int getNewEventOccurrence() {
/**
* Adds the execution occurrence given in parameter to the lifeline.<br>
* A Execution occurrence is never drawn in the frame instead it is added to a lifeline
- *
+ *
* @param exec the execution occurrence to add
*/
public void addExecution(BasicExecutionOccurrence exec) {
/**
* Returns true if at least one execution occurrence has time info.
- *
+ *
* @return true if at least one execution occurrence has time info
*/
public boolean hasTimeInfo() {
/**
* Returns the list of execution occurrence on this lifeline.
- *
+ *
* @return the execution occurrence list
*/
public List<GraphNode> getExecutions() {
if (fHasChilden) {
- return (List<GraphNode>) fNodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG);
+ return fNodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG);
}
return new ArrayList<GraphNode>();
}
if (fFrame == null) {
return false;
}
- if (Frame.contains(x, y, width, height, xValue, yValue)) {
+ if (GraphNode.contains(x, y, width, height, xValue, yValue)) {
return true;
}
- if (Frame.contains(x + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2, y + height, Metrics.EXECUTION_OCCURRENCE_WIDTH, (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fFrame.getMaxEventOccurrence()
+ if (GraphNode.contains(x + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2, y + height, Metrics.EXECUTION_OCCURRENCE_WIDTH, (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fFrame.getMaxEventOccurrence()
+ Metrics.LIFELINE_VB_MAGIN - 4, xValue, yValue)) {
return true;
}
if (hMargin >= 2) {
if (fFrame.getVisibleAreaY() < y - height - hMargin) {
- if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height + 1, xValue, yValue)) {
+ if (GraphNode.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height + 1, xValue, yValue)) {
return true;
}
} else {
- if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height, xValue, yValue)) {
+ if (GraphNode.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height, xValue, yValue)) {
return true;
}
}
/**
* Returns the lifeline visibility for the given visible area
- *
+ *
* @param vx The x coordinate of the visible area
* @param vy The y coordinate of the visible area
* @param vwidth The width of the visible area
}
/**
- * Draws the name within the graphical context.
- *
+ * Draws the name within the graphical context.
+ *
* @param context The graphical context.
*/
protected void drawName(IGC context) {
/**
* Force the lifeline to be drawn at the given coordinate
- *
+ *
* @param context - the context to draw into
* @param x - the x coordinate
* @param y - the y coordinate
*/
public void draw(IGC context, int x, int y) {
-
+
ISDPreferences pref = SDViewPref.getInstance();
-
+
// Set the draw color depending if the lifeline must be selected or not
context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
if (isSelected()) {
/**
* Draws the select execution occurrence region using the given color
- *
+ *
* @param context the graphical context
* @param startEvent the region start
* @param nbEvent the region height
*/
@Override
public boolean positiveDistanceToPoint(int x, int y) {
- if (getX() > x - Metrics.swimmingLaneWidth())
+ if (getX() > x - Metrics.swimmingLaneWidth()) {
return true;
+ }
return false;
}
return null;
}
for (int i = getExecOccurrenceDrawIndex(); i < getExecutions().size(); i++) {
- GraphNode node = (GraphNode) getExecutions().get(i);
+ GraphNode node = getExecutions().get(i);
if (node.getHeight() < 0) {
if (node.getY() + node.getHeight() > vy + vh) {
break;
StringBuffer ret = new StringBuffer();
String prefix = "["; //$NON-NLS-1$
for (Iterator<String> i = list.iterator(); i.hasNext();) {
- String s = (String) i.next();
+ String s = i.next();
ret.append(prefix);
ret.append(s);
prefix = " " + SDMessages._34 + " "; //$NON-NLS-1$ //$NON-NLS-2$
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* A filter criteria is a criteria that can be activated or not, positive or not.
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class FilterCriteria {
*/
protected static final String ACTIVE = "active"; //$NON-NLS-1$
/**
- * The property value for positive filter.
+ * The property value for positive filter.
*/
protected static final String POSITIVE = "positive"; //$NON-NLS-1$
/**
- * The filter loader class name property.
+ * The filter loader class name property.
*/
protected static final String LOADERCLASSNAME = "loaderClassName"; //$NON-NLS-1$
// Attributes
// ------------------------------------------------------------------------
/**
- * The criteria reference.
+ * The criteria reference.
*/
protected Criteria fCriteria;
/**
// ------------------------------------------------------------------------
/**
* Standard constructor
- *
+ *
* @param criteria A criteria reference
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
*/
public FilterCriteria(Criteria criteria, boolean isActive, boolean isPositive) {
/**
* Constructor
- *
+ *
* @param criteria A criteria reference
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
* @param loaderClassName A loader class name
*/
/**
* Returns the criteria reference.
- *
+ *
* @return the criteria reference
*/
public Criteria getCriteria() {
/**
* Sets the active flag.
- *
+ *
* @param isActive A active value.
*/
public void setActive(boolean isActive) {
/**
* Returns whether filter criteria is active or not.
- *
+ *
* @return whether filter criteria is active or not.
*/
public boolean isActive() {
/**
* Sets filter is for positive filtering or not.
- *
+ *
* @param isPositive The value to set.
*/
public void setPositive(boolean isPositive) {
/**
* Returns whether the filter si for positive filtering or not.
- *
+ *
* @return Returns the positive.
*/
public boolean isPositive() {
/**
* Sets the loader class name for this filter.
- *
+ *
* @param loaderClassName The loader class name to set
*/
public void setLoaderClassName(String loaderClassName) {
/**
* Returns the class loader name.
- *
+ *
* @return the class loader name.
*/
public String getLoaderClassName() {
/**
* Finds a filter criteria within a list of criteria.
- *
+ *
* @param what The filter to find
* @param list A list of filter criteria
* @return The found filter criteria or null
if (what != null && list != null) {
try {
for (Iterator<FilterCriteria> i = list.iterator(); i.hasNext();) {
- FilterCriteria fc = (FilterCriteria) i.next();
+ FilterCriteria fc = i.next();
if (what.compareTo(fc)) {
return fc;
}
/**
* Compares this filter criteria with a given criteria.
- *
+ *
* @param to The filter criteria to compare.
* @return usual comparison result (< 0, 0, > 0)
*/
/**
* Saves current criteria attributes in the dialog settings.
- *
+ *
* @param settings The dialog settings
*/
public void save(DialogSettings settings) {
/**
* Loads the criteria with values of the dialog settings.
- *
+ *
* @param settings The dialog settings
*/
public void load(DialogSettings settings) {
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* This is the filters list dialog.<br>
* It is associated to an SDView and to a ISDFilterProvider.<br>
- *
+ *
* @version 1.0
* @author sveyrier
*/
/**
* Standard constructor
- *
+ *
* @param view The view reference
* @param loader The filter provider implementation
*/
// ------------------------------------------------------------------------
/**
* Adds a criteria to the table
- *
+ *
* @param criteria A criteria to add
- * @param checked A flag whether criteria is checked (selected) or not
+ * @param checked A flag whether criteria is checked (selected) or not
* @param positive A flag whether criteria is for positive filter or not
* @param loaderClassName A loader class name for the filters
*/
/**
* Replaces a selected criteria with a new criteria.
- *
+ *
* @param newCriteria A new criteria.
*/
protected void replaceSelectedCriteria(Criteria newCriteria) {
});
if (fFilters != null) {
for (Iterator<FilterCriteria> i = fFilters.iterator(); i.hasNext();) {
- FilterCriteria filterCriteria = (FilterCriteria) i.next();
+ FilterCriteria filterCriteria = i.next();
addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName());
}
}
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing to do
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
/**
* Opens the filter dialog box with given parameter.
- *
+ *
* @param criteria The criteria reference to pass
* @param action to distinguish between "Update" and "Create"
* @return the criteria that has been updated or created
/**
* Sets the list of filters.
- *
+ *
* @param filters The list of filters to set.
*/
public void setFilters(List<FilterCriteria> filters) {
/**
* Returns the filters list after editing.
- *
+ *
* @return the filters list after editing
*/
public List<FilterCriteria> getFilters() {
protected void loadFiltersCriteria() {
List<FilterCriteria> globalFilters = getGlobalFilters();
for (Iterator<FilterCriteria> i = globalFilters.iterator(); i.hasNext();) {
- FilterCriteria filterCriteria = (FilterCriteria) i.next();
+ FilterCriteria filterCriteria = i.next();
addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName());
}
}
/**
* Returns the global filters which are saved in the dialog settings..
- *
+ *
* @return the saved global filters
*/
public static List<FilterCriteria> getGlobalFilters() {
/**
* Saves the filter criteria in the dialog settings.
- *
+ *
* @param globalFilters A list of filters to save.
*/
public static void saveFiltersCriteria(List<FilterCriteria> globalFilters) {
FilterCriteria criteria;
for (int j = 0; j < globalFilters.size(); j++) {
- if (!(globalFilters.get(j) instanceof FilterCriteria)) {
+ if (globalFilters.get(j) == null) {
return;
}
- criteria = (FilterCriteria) globalFilters.get(j);
+ criteria = globalFilters.get(j);
DialogSettings subSection = (DialogSettings) section.getSection(FILTERS_LIST_CRITERIA + j);
if (subSection == null) {
criteria.save(subSection);
}
}
-
+
/**
* Deactivates the saved global filters.
*/
/**
* Constructor
- *
+ *
* @param parent The parent table
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
* @param loaderClassName The loader class name
*/
/**
* Constructor
- *
+ *
* @param parent The parent table
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
* @param loaderClassName The loader class name
* @param index The table item index
/**
* Sets the criteria.
- *
+ *
* @param criteria The criteria to set
*/
public void setCriteria(Criteria criteria) {
/**
* Returns whether positive filtering is active or not.
- *
+ *
* @return <code>true</code> for positive filter else <code>false</code>
*/
public boolean isPositive() {
/**
* Returns the loader class name.
- *
+ *
* @return the loader class name
*/
public String getLoaderClassName() {
if (fSdView.getContentsHeight() > fSdView.getContentsHeight()) {
return (int) (fSdView.getVisibleHeight() / (float) fTest / fSdView.fZoomValue);
}
- return (int) (super.getContentsHeight());
+ return super.getContentsHeight();
}
/*
if (fSdView.getVisibleWidth() > fSdView.getContentsWidth()) {
return (int) (fSdView.getVisibleWidth() / (float) fTest / fSdView.fZoomValue);
}
- return (int) (super.getContentsWidth());
+ return super.getContentsWidth();
}
/*
Printer printer = new Printer(fPrinterData);
if (fSetHPagesNumber.getSelection()) {
fNbPages = Integer.valueOf(fHorPagesNum.getText()).intValue();
- float z1 = (float) fSdView.getContentsWidth() / (cw);
+ float z1 = fSdView.getContentsWidth() / cw;
float z2 = printer.getClientArea().width / ((float) fSdView.getContentsWidth() / fNbPages);
fStepY = printer.getClientArea().height / z1 / z2;
fStepX = cw / fNbPages;
} else if (fSetVPagesNumber.getSelection()) {
fNbPages = Integer.valueOf(fVertPagesNum.getText()).intValue();
- float z1 = (float) fSdView.getContentsHeight() / (ch);
+ float z1 = fSdView.getContentsHeight() / ch;
float z2 = printer.getClientArea().height / ((float) fSdView.getContentsHeight() / fNbPages);
fStepX = printer.getClientArea().width / z1 / z2;
fStepY = ch / fNbPages;
} else {
float z1 = fSdView.getContentsWidth() / (cw);
- fStepX = ((float) fSdView.getVisibleWidth() / z1);
+ fStepX = fSdView.getVisibleWidth() / z1;
fNbPages = Math.round(cw / fStepX);
if (fNbPages == 0) {
fNbPages = 1;
int pw = printer.getClientArea().width;
int ph = printer.getClientArea().height;
float z2 = pw / ((float) fSdView.getContentsWidth() / fNbPages);
- fStepY = ((float) ph / z1 / z2);
+ fStepY = ph / z1 / z2;
}
}
} catch (NumberFormatException e) {
if (fStepX != 0) {
row = (int) (cw / fStepX);
if (fSetHPagesNumber.getSelection()) {
- row = Math.round((float) cw / fStepX);
+ row = Math.round(cw / fStepX);
} else if ((cw % fStepX != 0)) {
row++;
}
if (fStepY != 0) {
line = (int) (ch / fStepY);
if (fSetVPagesNumber.getSelection()) {
- line = Math.round((float) ch / fStepY);
+ line = Math.round(ch / fStepY);
} else if (ch % fStepY != 0) {
line++;
}
int size = Math.min(list.size(), MAX_EXPRESSION_LIST);
String[] temp = new String[size];
for (int i = 0; i < size; i++) {
- temp[i] = (String) list.get(i);
+ temp[i] = list.get(i);
}
fExpressionList = temp;
settings.put(EXPRESSION_LIST, fExpressionList);
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* Default implementation of the IImage interface.
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class ImageImpl implements IImage {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+
/**
* The image reference
*/
// ------------------------------------------------------------------------
/**
* Default constructor.
- *
+ *
* @param file A file name of image file.
*/
public ImageImpl(String file) {
/**
* Copy constructor
- *
+ *
* @param image THe image to copy
*/
public ImageImpl(Image image) {
// ------------------------------------------------------------------------
/**
* Returns Image object from file name.
- *
+ *
* @param name File name of image file
* @return image object or <code>null</code>
*/
/**
* Returns Image object from file name.
- *
+ *
* @param name File name of image file
* @return image object or <code>null</code>
*/
- private Image createResourceImage(String name) {
+ private static Image createResourceImage(String name) {
try {
URL BASIC_URL = new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
URL url = new URL(BASIC_URL, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + name);//$NON-NLS-1$
super();
setId(ID);
setActionDefinitionId(ID);
- fView = ((SDView) view);
+ fView = view;
}
// ------------------------------------------------------------------------
if (fView == null) {
return;
}
- SDWidget viewer = ((SDView) fView).getSDWidget();
+ SDWidget viewer = fView.getSDWidget();
if (viewer != null) {
viewer.scrollBy(0, -viewer.getVisibleHeight());
* @param viewId the id of the view
*/
public void resetLoader(String viewId) {
- IUml2SDLoader loader = (IUml2SDLoader) fViewLoaderMap.get(viewId);
+ IUml2SDLoader loader = fViewLoaderMap.get(viewId);
if (loader != null) {
loader.dispose();
}
try {
// Search the view corresponding to the viewId
if (sdView == null) {
- IViewReference viewref = (IViewReference) persp.findViewReference(viewId);
+ IViewReference viewref = persp.findViewReference(viewId);
if (viewref != null) {
sdView = (SDView) viewref.getView(false);
}
try {
// Search view corresponding to the viewId
SDView sdview = null;
- IViewReference viewref = (IViewReference) persp.findViewReference(id);
+ IViewReference viewref = persp.findViewReference(id);
if (viewref != null) {
sdview = (SDView) viewref.getView(false);
}
* @return List of extension point configuration elements.
*/
private List<IConfigurationElement> getLoaderConfigurationElements(String viewId) {
- List<IConfigurationElement> list = (List<IConfigurationElement>) fViewLoadersList.get(viewId);
+ List<IConfigurationElement> list = fViewLoadersList.get(viewId);
if (list != null) {
return list;
}
* @param loaderElements The list of loader configuration elements
* @return Extension point configuration element
*/
- private IConfigurationElement getLoaderConfigurationElement(String loaderClassName, List<IConfigurationElement> loaderElements) {
+ private static IConfigurationElement getLoaderConfigurationElement(
+ String loaderClassName, List<IConfigurationElement> loaderElements) {
if (loaderClassName != null && loaderClassName.length() > 0) {
// Find configuration element corresponding to the saved loader
for (Iterator<IConfigurationElement> i = loaderElements.iterator(); i.hasNext();) {
- IConfigurationElement ce = (IConfigurationElement) i.next();
+ IConfigurationElement ce = i.next();
if (ce.getAttribute("class").equals(loaderClassName)) { //$NON-NLS-1$
return ce;
}
* @param loaderElements The list of loader configuration elements
* @return The default extension point configuration element.
*/
- private IConfigurationElement getDefaultLoader(List<IConfigurationElement> loaderElements) {
+ private static IConfigurationElement getDefaultLoader(
+ List<IConfigurationElement> loaderElements) {
// Look for a default loader
for (Iterator<IConfigurationElement> i = loaderElements.iterator(); i.hasNext();) {
- IConfigurationElement ce = (IConfigurationElement) i.next();
+ IConfigurationElement ce = i.next();
if (Boolean.valueOf(ce.getAttribute("default")).booleanValue()) { //$NON-NLS-1$
return ce;
}
return Messages.TmfUml2SDSyncLoader_CategoryLifeline;
case ISDGraphNodeSupporter.SYNCMESSAGE:
return Messages.TmfUml2SDSyncLoader_CategoryMessage;
+ default:
+ break;
}
return ""; //$NON-NLS-1$
}
GraphNode current = fFindResults.get(fCurrentFindIndex);
fView.getSDWidget().moveTo(current);
return true;
- } else {
- fFindResults = null;
- fCurrentFindIndex =0;
- return findInNextPages(fFindCriteria); // search in other page
}
+ fFindResults = null;
+ fCurrentFindIndex =0;
+ return findInNextPages(fFindCriteria); // search in other page
} finally {
fLock.unlock();
}
}
else {
// String was not found
- status = new Status(Status.WARNING, Activator.PLUGIN_ID, Messages.TmfUml2SDSyncLoader_SearchNotFound);
+ status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, Messages.TmfUml2SDSyncLoader_SearchNotFound);
}
setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
}
@Override
public IColor getForeGroundColor(String prefName) {
if ((fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fForeColorPref.get(prefName + FORE_COLOR_POSTFIX);
+ return fForeColorPref.get(prefName + FORE_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
@Override
public IColor getBackGroundColor(String prefName) {
if ((fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fBackColorPref.get(prefName + BACK_COLOR_POSTFIX);
+ return fBackColorPref.get(prefName + BACK_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
}
@Override
public IColor getFontColor(String prefName) {
if ((fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX);
+ return fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
*/
@Override
public IFont getFont(String prefName) {
- if ((fFontPref.get(prefName) != null) && (fFontPref.get(prefName) instanceof IFont)) {
- return (IFont) fFontPref.get(prefName);
+ if (fFontPref.get(prefName) != null) {
+ return fFontPref.get(prefName);
}
return FontImpl.getSystemFont();
}
for (int i = 0; i < FONT_LIST.length; i++) {
FontData fontData = PreferenceConverter.getFontData(fPrefStore, FONT_LIST[i]);
- if ((fFontPref.get(FONT_LIST[i]) != null) && (fFontPref.get(FONT_LIST[i]) instanceof IFont)) {
- ((IFont) fFontPref.get(FONT_LIST[i])).dispose();
+ if (fFontPref.get(FONT_LIST[i]) != null) {
+ fFontPref.get(FONT_LIST[i]).dispose();
}
fFontPref.put(FONT_LIST[i], new FontImpl(display, fontData));
}
for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX);
- if ((fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX)).dispose();
+ if (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) {
+ fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX).dispose();
}
fBackColorPref.put(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX);
- if ((fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX)).dispose();
+ if (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) {
+ fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX).dispose();
}
fForeColorPref.put(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX);
- if ((fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX)).dispose();
+ if (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) {
+ fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX).dispose();
}
fTextColorPref.put(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* The Sequence Diagram preferences page implementation.
- *
+ *
* @version 1.0
* @author sveyrier
*/
* Temporary preferences tag
*/
protected static final String TEMP_TAG = SDViewPref.TEMP_TAG;
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
page.setLayoutData(pageLayoutdata);
page.setLayout(pageLayout);
- fTooltip = new BooleanFieldEditor(SDViewPref.PREF_TOOLTIP, SDMessages._97, page);
+ fTooltip = new BooleanFieldEditor(ISDPreferences.PREF_TOOLTIP, SDMessages._97, page);
fTooltip.setPreferenceStore(fPreferences.getPreferenceStore());
fTooltip.load();
// link font with zoom pref
- fLink = new BooleanFieldEditor(SDViewPref.PREF_LINK_FONT, SDMessages._82, page);
+ fLink = new BooleanFieldEditor(ISDPreferences.PREF_LINK_FONT, SDMessages._82, page);
fLink.setPreferenceStore(fPreferences.getPreferenceStore());
fLink.load();
- fNoExternalTime = new BooleanFieldEditor(SDViewPref.PREF_EXCLUDE_EXTERNAL_TIME, SDMessages._83, page);
+ fNoExternalTime = new BooleanFieldEditor(ISDPreferences.PREF_EXCLUDE_EXTERNAL_TIME, SDMessages._83, page);
fNoExternalTime.setPreferenceStore(fPreferences.getPreferenceStore());
fNoExternalTime.load();
// use gradient color pref
- fUseGrad = new BooleanFieldEditor(SDViewPref.PREF_USE_GRADIENT, SDMessages._84, page);
+ fUseGrad = new BooleanFieldEditor(ISDPreferences.PREF_USE_GRADIENT, SDMessages._84, page);
fUseGrad.setPreferenceStore(fPreferences.getPreferenceStore());
fUseGrad.load();
prefPage.setLayout(prefPageLayout);
// swimLane width pref
- fLifelineWidth = new IntegerFieldEditor(SDViewPref.PREF_LIFELINE_WIDTH, SDMessages._80, prefPage);
+ fLifelineWidth = new IntegerFieldEditor(ISDPreferences.PREF_LIFELINE_WIDTH, SDMessages._80, prefPage);
fLifelineWidth.setPreferenceStore(fPreferences.getPreferenceStore());
fLifelineWidth.setValidRange(119, 500);
fLifelineWidth.load();
performApply();
return true;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
fTextColor.store();
String[] fontList = SDViewPref.getFontList();
-
+
// set the FontFieldEditor for the new selected graphNode font
fFont.setPreferenceName(fontList[fClassItemList.getSelectionIndex()] + TEMP_TAG);
fFont.load();
fTextColor.load();
// No Background for message graphNodes
- if ((fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_SYNC_MESS)) || (fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_SYNC_MESS_RET))
- || (fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS)) || (fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS_RET))) {
+ if ((fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_SYNC_MESS)) || (fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_SYNC_MESS_RET))
+ || (fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_ASYNC_MESS)) || (fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_ASYNC_MESS_RET))) {
fBackGroundColor.setEnabled(false, fButtonArea);
} else {
fBackGroundColor.setEnabled(true, fButtonArea);
}
// No font used for execution occurrence and global frame
- if ((fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_EXEC)) || (fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME))) {
+ if ((fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_EXEC)) || (fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_FRAME))) {
fTextColor.setEnabled(false, fButtonArea);
} else {
fTextColor.setEnabled(true, fButtonArea);
}
- if (fontList[fClassItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME)) {
+ if (fontList[fClassItemList.getSelectionIndex()].equals(ISDPreferences.PREF_FRAME)) {
fFont.setEnabled(false, fButtonArea);
} else {
fFont.setEnabled(true, fButtonArea);
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
/**
- * Asynchronous message comparator.
- *
+ * Asynchronous message comparator.
+ *
* Compares two asyncMessages only taking into account the event occurrence when their
* appear.<br>
- *
+ *
* Used to order the AsyncMessage list insuring that the previous node has both of his ends smaller than the current node
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class SortAsyncForBackward implements Comparator<GraphNode>, Serializable {
-
+
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
} else {
return -1;
}
- } else {
- return 0;
}
+ return 0;
}
}
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2011, 2012 Ericsson.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* Asynchronous message comparator Compare two AsyncMessages only taking into account the event occurrence when their
* appear.<br>
- *
+ *
* Used to order the AsyncMessage list insuring that next node has one of his ends greater than the current node
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class SortAsyncMessageComparator implements Comparator<GraphNode>, Serializable {
} else {
return -1;
}
- } else {
- return 0;
}
+ return 0;
}
}
} else {
return -1;
}
- } else {
- return 0;
}
+ return 0;
}
}
*/
@Override
public int compare(SDTimeEvent arg0, SDTimeEvent arg1) {
- SDTimeEvent t1 = (SDTimeEvent) arg0;
- SDTimeEvent t2 = (SDTimeEvent) arg1;
+ SDTimeEvent t1 = arg0;
+ SDTimeEvent t2 = arg1;
if (t1.getEvent() > t2.getEvent()) {
return 1;
}
* of visible lines in the StyledText control is set to fill the viewer display area.\r
* An underlying data model is used to store a cache of event raw text line data.\r
* The slider is ratio-based.\r
- * \r
+ *\r
* @version 1.0\r
* @author Patrick Tasse\r
*/\r
private int getPreviousCaretOffset(int time) {\r
if (fStoredCaretPosition[0].time == time) {\r
return fStoredCaretPosition[1].caretOffset;\r
- } else {\r
- return fStoredCaretPosition[0].caretOffset;\r
}\r
+ return fStoredCaretPosition[0].caretOffset;\r
}\r
\r
private void updateHighlightedRank() {\r
}\r
break;\r
}\r
+ default:\r
+ break;\r
}\r
//fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
if (e.detail != SWT.NONE) {\r
}\r
break;\r
}\r
+ default:\r
+ break;\r
}\r
//fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
updateHighlightedRank();\r
public Object[] getChildren(Object parentElement) {\r
if (parentElement instanceof ITimeGraphEntry) {\r
return contentProvider.getChildren(parentElement);\r
- } else {\r
- return new Object[0];\r
}\r
+ return new Object[0];\r
}\r
\r
@Override\r
public Object getParent(Object element) {\r
if (element instanceof ITimeGraphEntry) {\r
return contentProvider.getParent(element);\r
- } else {\r
- return null;\r
}\r
+ return null;\r
}\r
\r
@Override\r
public boolean hasChildren(Object element) {\r
if (element instanceof ITimeGraphEntry) {\r
return contentProvider.hasChildren(element);\r
- } else {\r
- return false;\r
}\r
+ return false;\r
}\r
}\r
\r
public boolean isLabelProperty(Object element, String property) {\r
if (element instanceof ITimeGraphEntry) {\r
return labelProvider.isLabelProperty(element, property);\r
- } else {\r
- return false;\r
}\r
+ return false;\r
}\r
\r
@Override\r
public Image getColumnImage(Object element, int columnIndex) {\r
if (element instanceof ITimeGraphEntry) {\r
return labelProvider.getColumnImage(element, columnIndex);\r
- } else {\r
- return null;\r
}\r
+ return null;\r
}\r
\r
@Override\r
public String getColumnText(Object element, int columnIndex) {\r
if (element instanceof ITimeGraphEntry) {\r
return labelProvider.getColumnText(element, columnIndex);\r
- } else {\r
- return null;\r
}\r
+ return null;\r
}\r
\r
}\r
return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
}\r
return getColor(BACKGROUND_NAME);\r
- } else {\r
- if (selected && focused) {\r
- return getColor(BACKGROUND_SEL);\r
- }\r
- if (selected) {\r
- return getColor(BACKGROUND_SEL_NOFOCUS);\r
- }\r
- return getColor(BACKGROUND);\r
}\r
+ if (selected && focused) {\r
+ return getColor(BACKGROUND_SEL);\r
+ }\r
+ if (selected) {\r
+ return getColor(BACKGROUND_SEL_NOFOCUS);\r
+ }\r
+ return getColor(BACKGROUND);\r
}\r
\r
/**\r
boolean changed = false;\r
if (idx < 0) {\r
for (idx = 0; idx < _data._expandedItems.length; idx++) {\r
- if (((Item) _data._expandedItems[idx])._selected) {\r
+ if (_data._expandedItems[idx]._selected) {\r
break;\r
}\r
}\r
boolean changed = false;\r
int lastSelection = -1;\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- Item item = (Item) _data._expandedItems[i];\r
+ Item item = _data._expandedItems[i];\r
if (item._selected) {\r
lastSelection = i;\r
if ((1 == n) && (i < _data._expandedItems.length - 1)) {\r
item._selected = false;\r
- item = (Item) _data._expandedItems[i + 1];\r
+ item = _data._expandedItems[i + 1];\r
item._selected = true;\r
changed = true;\r
} else if ((-1 == n) && (i > 0)) {\r
item._selected = false;\r
- item = (Item) _data._expandedItems[i - 1];\r
+ item = _data._expandedItems[i - 1];\r
item._selected = true;\r
changed = true;\r
}\r
}\r
\r
if (lastSelection < 0 && _data._expandedItems.length > 0) {\r
- Item item = (Item) _data._expandedItems[0];\r
+ Item item = _data._expandedItems[0];\r
item._selected = true;\r
changed = true;\r
}\r
} // to allow getting out of single point interval\r
long newInterval;\r
if (zoomIn) {\r
- newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());\r
+ newInterval = Math.max(Math.round(interval * 0.8), _timeProvider.getMinTimeInterval());\r
} else {\r
- newInterval = (long) Math.ceil((double) interval * 1.25);\r
+ newInterval = (long) Math.ceil(interval * 1.25);\r
}\r
long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));\r
long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
\r
long m = _timeProvider.getMinTimeInterval();\r
if ((time1 - time0) < m) {\r
- time0 = selTime - (long) ((selTime - _time0) * m / _range);\r
+ time0 = selTime - (selTime - _time0) * m / _range;\r
time1 = time0 + m;\r
}\r
\r
public int getSelectedIndex() {\r
int idx = -1;\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- Item item = (Item) _data._expandedItems[i];\r
+ Item item = _data._expandedItems[i];\r
if (item._selected) {\r
idx = i;\r
break;\r
boolean toggle(int idx) {\r
boolean toggled = false;\r
if (idx >= 0 && idx < _data._expandedItems.length) {\r
- Item item = (Item) _data._expandedItems[idx];\r
+ Item item = _data._expandedItems[idx];\r
if (item._hasChildren) {\r
item._expanded = !item._expanded;\r
_data.updateExpandedItems();\r
int nameWidth = _timeProvider.getNameSpace();\r
if (x > nameWidth - w && x < nameWidth + w) {\r
return true;\r
- } else {\r
- return false;\r
}\r
+ return false;\r
}\r
\r
ITimeGraphEntry getEntry(Point pt) {\r
boolean changed = false;\r
if (addSelection) {\r
if (idx >= 0 && idx < _data._expandedItems.length) {\r
- Item item = (Item) _data._expandedItems[idx];\r
+ Item item = _data._expandedItems[idx];\r
changed = (item._selected == false);\r
item._selected = true;\r
}\r
} else {\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- Item item = (Item) _data._expandedItems[i];\r
+ Item item = _data._expandedItems[i];\r
if ((i == idx && !item._selected) || (idx == -1 && item._selected)) {\r
changed = true;\r
}\r
long time1 = _timeProvider.getTime1();\r
long selectedTime = _timeProvider.getSelectedTime();\r
double pixelsPerNanoSec = (bounds.width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (bounds.width - nameSpace - RIGHT_MARGIN) / (time1 - time0);\r
- int x = bounds.x + nameSpace + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec);\r
+ int x = bounds.x + nameSpace + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= nameSpace && x < bounds.x + bounds.width) {\r
gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME));\r
gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);\r
public void drawItems(Rectangle bounds, ITimeDataProvider timeProvider,\r
Item[] items, int topIndex, int nameSpace, GC gc) {\r
for (int i = topIndex; i < items.length; i++) {\r
- Item item = (Item) items[i];\r
+ Item item = items[i];\r
drawItem(item, bounds, timeProvider, i, nameSpace, gc);\r
}\r
fTimeGraphProvider.postDrawControl(bounds, gc);\r
if (idx < 0 || idx >= _expandedItems.length) {\r
return;\r
}\r
- Item item = (Item) _expandedItems[idx];\r
+ Item item = _expandedItems[idx];\r
if (item._hasChildren && !item._expanded) {\r
item._expanded = true;\r
updateExpandedItems();\r
import java.text.SimpleDateFormat;\r
import java.util.Calendar;\r
import java.util.Date;\r
-import java.util.GregorianCalendar;\r
\r
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;\r
import org.eclipse.swt.SWT;\r
private static final double LOG10_3 = Math.log10(3);\r
private static final double LOG10_5 = Math.log10(5);\r
\r
- private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance();\r
+ private static final Calendar GREGORIAN_CALENDAR = Calendar.getInstance();\r
\r
private ITimeDataProvider _timeProvider;\r
private int _dragState = 0;\r
}\r
\r
private void calcTimeDelta(int width, double pixelsPerNanoSec) {\r
- double minDelta = (double) ((pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec);\r
+ double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;\r
long unit = 1;\r
if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
if (minDelta > 6 * MONTH_IN_NS) {\r
return;\r
}\r
}\r
- double log = Math.log10((double) minDelta / unit);\r
+ double log = Math.log10(minDelta / unit);\r
long pow10 = (long) log;\r
double remainder = log - pow10;\r
if (remainder < LOG10_1) {\r
}\r
\r
// draw selected time\r
- int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec);\r
+ int x = _rect0.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= _rect0.x && x < _rect0.x + _rect0.width) {\r
gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME));\r
gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = syearformat.format(new Date((long) (time / 1000000)));\r
+ String stime = syearformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = smonthformat.format(new Date((long) (time / 1000000)));\r
+ String stime = smonthformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = sdayformat.format(new Date((long) (time / 1000000)));\r
+ String stime = sdayformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = sdayformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = sdayformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = shrsformat.format(new Date((long) (time / 1000000)));\r
+ String stime = shrsformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = shrsformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = shrsformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = sminformat.format(new Date((long) (time / 1000000)));\r
+ String stime = sminformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = sminformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = sminformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+ String stime = stimeformat.format(new Date(time / 1000000));\r
Utils.drawText(gc, stime, rect, true);\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = stimeformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+ String stime = stimeformat.format(new Date(time / 1000000));\r
String ns = Utils.formatNs(time, Resolution.MILLISEC);\r
\r
Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = stimeformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+ String stime = stimeformat.format(new Date(time / 1000000));\r
String micr = Utils.formatNs(time, Resolution.MICROSEC);\r
Utils.drawText(gc, stime + "." + micr, rect, true); //$NON-NLS-1$\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = stimeformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+ String stime = stimeformat.format(new Date(time / 1000000));\r
String ns = Utils.formatNs(time, Resolution.NANOSEC);\r
Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$\r
}\r
\r
@Override\r
public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
- String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ String header = stimeformatheader.format(new Date(time / 1000000));\r
int headerwidth = gc.stringExtent(header).x + 4;\r
if (headerwidth <= rect.width) {\r
rect.x += (rect.width - headerwidth);\r
Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent);\r
if (eventAddOns != null) {\r
for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) {\r
- String message = (String) iter.next();\r
+ String message = iter.next();\r
addItem(message, eventAddOns.get(message));\r
}\r
}\r
long eventDuration = -1;\r
long eventEndTime = -1;\r
\r
- if (threadEvent != null) {\r
- eventStartTime = threadEvent.getTime();\r
- eventDuration = threadEvent.getDuration();\r
- if (eventDuration < 0 && nextEvent != null) {\r
- eventEndTime = nextEvent.getTime();\r
- eventDuration = eventEndTime - eventStartTime;\r
- } else {\r
- eventEndTime = eventStartTime + eventDuration;\r
- }\r
+ eventStartTime = threadEvent.getTime();\r
+ eventDuration = threadEvent.getDuration();\r
+ if (eventDuration < 0 && nextEvent != null) {\r
+ eventEndTime = nextEvent.getTime();\r
+ eventDuration = eventEndTime - eventStartTime;\r
+ } else {\r
+ eventEndTime = eventStartTime + eventDuration;\r
}\r
\r
// TODO: Check if we need "format"\r
});\r
}\r
\r
- private void setHoverLocation(Shell shell, Point position) {\r
+ private static void setHoverLocation(Shell shell, Point position) {\r
Rectangle displayBounds = shell.getDisplay().getBounds();\r
Rectangle shellBounds = shell.getBounds();\r
shellBounds.x = Math.max(Math.min(position.x, displayBounds.width\r
Iterator<ITimeEvent> iterator = entry.getTimeEventsIterator();\r
if (iterator != null && iterator.hasNext()) {\r
return iterator.next();\r
- } else {\r
- return null;\r
}\r
+ return null;\r
}\r
\r
/**\r
ITimeEvent prevEvent = null;\r
\r
while (iterator.hasNext()) {\r
- nextEvent = (ITimeEvent) iterator.next();\r
+ nextEvent = iterator.next();\r
long nextStartTime = nextEvent.getTime();\r
\r
if (nextStartTime > time) {\r
if (n == -1) { //previous\r
if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
return prevEvent;\r
- } else {\r
- return currEvent;\r
}\r
+ return currEvent;\r
} else if (n == 0) { //current\r
if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
return currEvent;\r
- } else {\r
- return null;\r
}\r
+ return null;\r
} else if (n == 1) { //next\r
return nextEvent;\r
} else if (n == 2) { //current or previous when in empty space\r
* expects.\r
* @return The mangled string of types\r
*/\r
- @SuppressWarnings("nls")\r
static public String getTypeSignature(String type) {\r
int dim = 0;\r
for (int j = 0; j < type.length(); j++) {\r
{\r
sig.append("["); //$NON-NLS-1$\r
}\r
- if (type.equals("boolean")) {\r
- sig.append("Z"); //$NON-NLS-1$\r
- } else if (type.equals("byte")) {\r
- sig.append("B"); //$NON-NLS-1$\r
- } else if (type.equals("char")) {\r
- sig.append("C"); //$NON-NLS-1$\r
- } else if (type.equals("short")) {\r
- sig.append("S"); //$NON-NLS-1$\r
- } else if (type.equals("int")) {\r
- sig.append("I"); //$NON-NLS-1$\r
- } else if (type.equals("long")) {\r
- sig.append("J"); //$NON-NLS-1$\r
- } else if (type.equals("float")) {\r
- sig.append("F"); //$NON-NLS-1$\r
- } else if (type.equals("double")) {\r
- sig.append("D"); //$NON-NLS-1$\r
- } else if (type.equals("void")) {\r
- sig.append("V"); //$NON-NLS-1$\r
+ if (type.equals("boolean")) { //$NON-NLS-1$\r
+ sig.append('Z');\r
+ } else if (type.equals("byte")) { //$NON-NLS-1$\r
+ sig.append('B');\r
+ } else if (type.equals("char")) { //$NON-NLS-1$\r
+ sig.append('C');\r
+ } else if (type.equals("short")) { //$NON-NLS-1$\r
+ sig.append('S');\r
+ } else if (type.equals("int")) { //$NON-NLS-1$\r
+ sig.append('I');\r
+ } else if (type.equals("long")) { //$NON-NLS-1$\r
+ sig.append('J');\r
+ } else if (type.equals("float")) { //$NON-NLS-1$\r
+ sig.append('F');\r
+ } else if (type.equals("double")) { //$NON-NLS-1$\r
+ sig.append('D');\r
+ } else if (type.equals("void")) { //$NON-NLS-1$\r
+ sig.append('V');\r
}\r
else {\r
- sig.append("L").append(type.replace('.', '/')).append(";"); //$NON-NLS-1$ //$NON-NLS-2$\r
+ sig.append('L').append(type.replace('.', '/')).append(';');\r
}\r
return sig.toString();\r
}\r
case SWT.MouseWheel:
shell.dispose ();
break;
+ default:
+ break;
}
}
};
}
if (tooltipProvider == null) {
return;
- } else {
- String tooltipText = tooltipProvider.getTooltip(i, item.getData());
- if (tooltipText == null) {
- return;
- }
- tip = new Shell(fTable.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
- tip.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- FillLayout layout = new FillLayout();
- layout.marginWidth = 2;
- tip.setLayout(layout);
- label = new Label(tip, SWT.WRAP);
- label.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setData(TOOLTIP_DATA_KEY, item);
- label.setText(tooltipText);
-
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- label.addListener(SWT.MouseWheel, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point pt = fTable.toDisplay(bounds.x, bounds.y);
- tip.setBounds(pt.x, pt.y, size.x, size.y);
- tip.setVisible(true);
}
- break;
+ String tooltipText = tooltipProvider.getTooltip(i, item.getData());
+ if (tooltipText == null) {
+ return;
+ }
+ tip = new Shell(fTable.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
+ tip.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ FillLayout layout = new FillLayout();
+ layout.marginWidth = 2;
+ tip.setLayout(layout);
+ label = new Label(tip, SWT.WRAP);
+ label.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ label.setData(TOOLTIP_DATA_KEY, item);
+ label.setText(tooltipText);
+
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ label.addListener(SWT.MouseWheel, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Point pt = fTable.toDisplay(bounds.x, bounds.y);
+ tip.setBounds(pt.x, pt.y, size.x, size.y);
+ tip.setVisible(true);
}
}
}
+ break;
}
+ default:
+ break;
}
}
};
refreshTable();
break;
}
+ default:
+ break;
}
}
});
int index = fTable.indexOf(ti);
if (index < fFrozenRowCount) {
return index;
- } else {
- return (index - fFrozenRowCount) + getTopIndex();
}
+ return (index - fFrozenRowCount) + getTopIndex();
}
/**
}
if (index < fFrozenRowCount) {
return index;
- } else {
- return (index - fFrozenRowCount) + getTopIndex();
}
+ return (index - fFrozenRowCount) + getTopIndex();
}
/**