From abbdd66ae5cfcdcb2b8af78a8f4b2dad410974ab Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 14 Jun 2012 18:49:55 -0400 Subject: [PATCH] tmf: Simple warning fixes in tmf.ui and tests Remove unecessary casts: makes the code more readable Mark methods static wherever possible: potential memory savings Remove unecessary else clauses: Makes it easier for the compiler to optimize branching. and other small things. Signed-off-by: Alexandre Montplaisir --- .../TmfBaseColumnDataProviderTest.java | 12 +- .../statistics/TmfBaseColumnDataTest.java | 7 +- .../views/uml2sd/load/LoadersManagerTest.java | 38 +-- .../uml2sd/loader/Uml2SDSignalValidator.java | 30 +- .../uml2sd/loader/Uml2SDTestFacility.java | 2 +- .../tmf/ui/tests/uml2sd/load/TestLoaders.java | 53 ++-- .../stub/model/TraceModelImplFactory.java | 101 ++++--- .../test/stub/views/TsfTraceAnalysisView.java | 82 +++--- .../ui/dialogs/ManageCustomParsersDialog.java | 29 +- .../parsers/custom/CustomTraceDefinition.java | 12 +- .../tmf/ui/parsers/custom/CustomTxtEvent.java | 12 +- .../custom/CustomTxtTraceDefinition.java | 102 +++---- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 8 +- .../custom/CustomXmlTraceDefinition.java | 66 +++-- .../CustomTxtParserInputWizardPage.java | 274 ++++++++++-------- .../CustomXmlParserInputWizardPage.java | 254 ++++++++-------- ...teExperimentSupplementaryFilesHandler.java | 12 +- .../DeleteTraceSupplementaryFilesHandler.java | 13 +- .../handlers/DropAdapterAssistant.java | 68 +++-- .../handlers/OpenExperimentHandler.java | 2 +- .../ui/project/handlers/OpenTraceHandler.java | 37 ++- .../project/handlers/RenameTraceHandler.java | 28 +- .../SelectTraceTypeContributionItem.java | 11 +- .../handlers/SelectTraceTypeHandler.java | 9 +- .../tmf/ui/editors/EventsViewEditor.java | 35 ++- .../tmf/ui/editors/TmfEventsEditor.java | 19 +- .../model/TmfNavigatorContentProvider.java | 3 +- .../model/TmfNavigatorLabelProvider.java | 2 +- .../tmf/ui/project/model/TmfTraceElement.java | 18 +- .../ui/project/wizards/ImportTraceWizard.java | 9 +- .../wizards/ImportTraceWizardPage.java | 9 +- .../project/wizards/NewTmfProjectWizard.java | 30 +- .../wizards/RenameExperimentDialog.java | 20 +- .../wizards/SelectTracesWizardPage.java | 17 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 6 +- .../tmf/ui/views/colors/ColorsView.java | 4 +- .../tmf/ui/views/histogram/Histogram.java | 5 +- .../tmf/ui/views/histogram/HistogramView.java | 10 +- .../views/statistics/TmfStatisticsView.java | 3 +- .../model/AbsTmfStatisticsTree.java | 3 +- .../model/TmfBaseColumnDataProvider.java | 9 +- .../timechart/TimeChartAnalysisEntry.java | 12 +- .../timechart/TimeChartAnalysisProvider.java | 4 +- .../tmf/ui/views/timechart/TimeChartView.java | 6 +- .../tmf/ui/views/uml2sd/DrawableToolTip.java | 46 +-- .../linuxtools/tmf/ui/views/uml2sd/NGC.java | 85 +++--- .../tmf/ui/views/uml2sd/SDView.java | 10 +- .../tmf/ui/views/uml2sd/SDWidget.java | 69 +++-- .../uml2sd/SDWidgetSelectionProvider.java | 2 +- .../ui/views/uml2sd/TimeCompressionBar.java | 53 ++-- .../ui/views/uml2sd/core/AsyncMessage.java | 4 +- .../tmf/ui/views/uml2sd/core/BaseMessage.java | 85 +++--- .../uml2sd/core/BasicExecutionOccurrence.java | 37 ++- .../tmf/ui/views/uml2sd/core/BasicFrame.java | 17 +- .../uml2sd/core/ExecutionOccurrence.java | 36 ++- .../tmf/ui/views/uml2sd/core/Frame.java | 65 ++--- .../tmf/ui/views/uml2sd/core/GraphNode.java | 78 ++--- .../tmf/ui/views/uml2sd/core/HotSpot.java | 24 +- .../tmf/ui/views/uml2sd/core/Lifeline.java | 72 +++-- .../tmf/ui/views/uml2sd/dialogs/Criteria.java | 2 +- .../views/uml2sd/dialogs/FilterCriteria.java | 48 +-- .../uml2sd/dialogs/FilterListDialog.java | 52 ++-- .../views/uml2sd/dialogs/SDPrintDialogUI.java | 16 +- .../uml2sd/dialogs/SearchFilterDialog.java | 2 +- .../views/uml2sd/drawings/impl/ImageImpl.java | 22 +- .../ui/views/uml2sd/handlers/MoveSDUp.java | 4 +- .../ui/views/uml2sd/load/LoadersManager.java | 18 +- .../uml2sd/loader/TmfUml2SDSyncLoader.java | 11 +- .../views/uml2sd/preferences/SDViewPref.java | 26 +- .../uml2sd/preferences/SDViewerPage.java | 32 +- .../uml2sd/util/SortAsyncForBackward.java | 21 +- .../util/SortAsyncMessageComparator.java | 15 +- .../util/SortSyncMessageComparator.java | 3 +- .../uml2sd/util/TimeEventComparator.java | 4 +- .../widgets/rawviewer/TmfRawEventViewer.java | 9 +- .../ui/widgets/timegraph/TimeGraphCombo.java | 18 +- .../widgets/TimeGraphColorScheme.java | 15 +- .../timegraph/widgets/TimeGraphControl.java | 33 +-- .../timegraph/widgets/TimeGraphScale.java | 41 ++- .../widgets/TimeGraphTooltipHandler.java | 20 +- .../ui/widgets/timegraph/widgets/Utils.java | 50 ++-- .../widgets/virtualtable/TmfVirtualTable.java | 59 ++-- 82 files changed, 1403 insertions(+), 1287 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index e3508f00a8..0b7ea29965 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 @@ -39,13 +39,13 @@ public class TmfBaseColumnDataProviderTest extends TestCase { // ------------------------------------------------------------------------ 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"; @@ -128,7 +128,7 @@ public class TmfBaseColumnDataProviderTest extends TestCase { assertNotNull("getColumnData", columnData); assertNotNull("getColumnData", columnData.getHeader()); assertNotNull("getColumnData", columnData.getTooltip()); - + // Testing labelProvider ColumnLabelProvider labelProvider = columnData.getLabelProvider(); if (columnData.getHeader().compareTo(LEVEL_COLUMN) == 0) { @@ -155,7 +155,7 @@ public class TmfBaseColumnDataProviderTest extends TestCase { 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)); } } } diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java index e44ce0fe22..7ead7b038a 100755 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -84,9 +84,8 @@ public class TmfBaseColumnDataTest extends TestCase { if (parent == null) { return 0; - } else { - return (double) node.getValue().nbEvents / parent.getValue().nbEvents; } + return (double) node.getValue().nbEvents / parent.getValue().nbEvents; } }; diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/LoadersManagerTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/LoadersManagerTest.java index 89a7a6aa50..70905c0dc0 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/LoadersManagerTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/LoadersManagerTest.java @@ -4,8 +4,8 @@ * 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; @@ -26,7 +26,7 @@ public class LoadersManagerTest extends TestCase { 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$ @@ -47,9 +47,9 @@ public class LoadersManagerTest extends TestCase { 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() @@ -59,18 +59,18 @@ public class LoadersManagerTest extends TestCase { 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) @@ -88,7 +88,7 @@ public class LoadersManagerTest extends TestCase { // 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)); @@ -96,7 +96,7 @@ public class LoadersManagerTest extends TestCase { 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 @@ -113,24 +113,24 @@ public class LoadersManagerTest extends TestCase { 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 @@ -150,7 +150,7 @@ public class LoadersManagerTest extends TestCase { } @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; @@ -169,7 +169,7 @@ public class LoadersManagerTest extends TestCase { } } - private String getSavedLoader(String viewId) { + private static String getSavedLoader(String viewId) { IPreferenceStore p = Activator.getDefault().getPreferenceStore(); return p.getString(LOADER_PREFIX + viewId); } diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java index 08c59df64e..c35e6f28e2 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -21,10 +21,10 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal; 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 // ------------------------------------------------------------------------ @@ -44,13 +44,13 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal // ------------------------------------------------------------------------ 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())); @@ -58,19 +58,19 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal @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); } @@ -79,7 +79,7 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal public void endSynch(TmfEndSynchSignal signal) { fSignalDepth = fSignalDepth > 0 ? fSignalDepth - 1 : 0; } - + @Override public boolean isSignalReceived() { return fIsSignalReceived; @@ -123,8 +123,8 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal @Override public boolean isSignalError() { return fIsSignalError; - } - + } + @Override public void setSignalError(boolean fIsSignalError) { this.fIsSignalError = fIsSignalError; @@ -139,7 +139,7 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal public void setSource(Object source) { fSource = source; } - + @Override public TmfTimestamp getCurrentTime() { return fCurrentTimestamp; @@ -159,5 +159,5 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal public void setCurrentRange(TmfTimeRange currentRange) { fCurrentTimeRange = currentRange == null ? null : new TmfTimeRange(currentRange); } -}; +} diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java index d49139b262..2821a55dca 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java @@ -262,7 +262,7 @@ public class Uml2SDTestFacility { * @param page number to set */ public void setPage(final int page) { - fLoader.pageNumberChanged(page);; + fLoader.pageNumberChanged(page); fLoader.waitForCompletion(); delay(IUml2SDTestConstants.GUI_REFESH_DELAY); } diff --git a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/load/TestLoaders.java b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/load/TestLoaders.java index 1d26422b5b..d399c88a76 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/load/TestLoaders.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/load/TestLoaders.java @@ -151,7 +151,7 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro } } - 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); @@ -159,6 +159,7 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro testFrame.getLifeline(i).addExecution(occ); occ.setName("******************* Execution Occurance TEST ****************"); } + } Stop s = new Stop(); s.setLifeline(testFrame.getLifeline(1)); @@ -204,7 +205,7 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro occ.setEndOccurrence(testFrame.getSyncMessageReturn(i - 1).getEventOccurrence()); testFrame.getLifeline(0).addExecution(occ); } - } + } v.setFrame(testFrame); } @@ -216,28 +217,33 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro 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(); 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 msgs = new ArrayList(); 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) { @@ -248,13 +254,17 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro msgs = new ArrayList(); 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) { @@ -265,22 +275,21 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro @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 @@ -348,11 +357,12 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro } } - 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(); @@ -446,8 +456,9 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro @Override public void dispose() { - if (img != null) + if (img != null) { img.dispose(); + } } } @@ -456,7 +467,7 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro public void firstPage() { page = 0; createFrame(); - + } @Override diff --git a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceModelImplFactory.java b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceModelImplFactory.java index 1d296e0428..a1289ed4d0 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceModelImplFactory.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceModelImplFactory.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -20,9 +20,9 @@ public class TraceModelImplFactory { // Data // ======================================================================== private int count = 0; - private TraceStrings[] traceNames; + private final TraceStrings[] traceNames; private static final long msTons = 1000000; - private Long timeRef = new Date().getTime() * msTons; + private final Long timeRef = new Date().getTime() * msTons; // ======================================================================== // Constructor @@ -47,7 +47,7 @@ public class TraceModelImplFactory { } return traceArr; } - + /** * 5000 Events per Trace. * @param number @@ -67,13 +67,13 @@ public class TraceModelImplFactory { return traceArr; } - private void create5000Events(TraceImpl trace) { + private static void create5000Events(TraceImpl trace) { EventImpl event; Long eventTime; int numEvents = 5000; long sTime = trace.getStartTime(); long eTime = trace.getEndTime(); - long duration = (long) ((eTime - sTime)/numEvents); + long duration = (eTime - sTime)/numEvents; for (int i = 0; i < numEvents; i++) { eventTime = sTime + (i * duration); // eventTime = timeRef + (5 * (count % 4) + (5 * (int) (i/2) )); @@ -94,7 +94,7 @@ public class TraceModelImplFactory { long duration = 0; for (int i = 0; i < numEvents; i++) { eventTime = timeRef + msTons * i + (5 * msTons * count) + (5 * i); - duration = msTons + i * msTons + (long) ((i % 4)); + duration = msTons + i * msTons + ((i % 4)); // duration = i + (long) ((i % 4)); event = new EventImpl(eventTime, trace, getEventType(i)); event.setDuration(duration); @@ -102,39 +102,54 @@ public class TraceModelImplFactory { } } - private EventImpl.Type getEventType(int val) { - if (EventImpl.Type.ALARM.ordinal() == val) - return EventImpl.Type.ALARM; - if (EventImpl.Type.ERROR.ordinal() == val) - return EventImpl.Type.ERROR; - if (EventImpl.Type.EVENT.ordinal() == val) - return EventImpl.Type.EVENT; - if (EventImpl.Type.INFORMATION.ordinal() == val) - return EventImpl.Type.INFORMATION; - if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) - return EventImpl.Type.TIMEADJUSTMENT; - if (EventImpl.Type.WARNING.ordinal() == val) - return EventImpl.Type.WARNING; - if (EventImpl.Type.INFO1.ordinal() == val) - return EventImpl.Type.INFO1; - if (EventImpl.Type.INFO2.ordinal() == val) - return EventImpl.Type.INFO2; - if (EventImpl.Type.INFO3.ordinal() == val) - return EventImpl.Type.INFO3; - if (EventImpl.Type.INFO4.ordinal() == val) - return EventImpl.Type.INFO4; - if (EventImpl.Type.INFO5.ordinal() == val) - return EventImpl.Type.INFO5; - if (EventImpl.Type.INFO6.ordinal() == val) - return EventImpl.Type.INFO6; - if (EventImpl.Type.INFO7.ordinal() == val) - return EventImpl.Type.INFO7; - if (EventImpl.Type.INFO8.ordinal() == val) - return EventImpl.Type.INFO8; - if (EventImpl.Type.INFO9.ordinal() == val) - return EventImpl.Type.INFO9; - return EventImpl.Type.UNKNOWN; - } + private static EventImpl.Type getEventType(int val) { + if (EventImpl.Type.ALARM.ordinal() == val) { + return EventImpl.Type.ALARM; + } + if (EventImpl.Type.ERROR.ordinal() == val) { + return EventImpl.Type.ERROR; + } + if (EventImpl.Type.EVENT.ordinal() == val) { + return EventImpl.Type.EVENT; + } + if (EventImpl.Type.INFORMATION.ordinal() == val) { + return EventImpl.Type.INFORMATION; + } + if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) { + return EventImpl.Type.TIMEADJUSTMENT; + } + if (EventImpl.Type.WARNING.ordinal() == val) { + return EventImpl.Type.WARNING; + } + if (EventImpl.Type.INFO1.ordinal() == val) { + return EventImpl.Type.INFO1; + } + if (EventImpl.Type.INFO2.ordinal() == val) { + return EventImpl.Type.INFO2; + } + if (EventImpl.Type.INFO3.ordinal() == val) { + return EventImpl.Type.INFO3; + } + if (EventImpl.Type.INFO4.ordinal() == val) { + return EventImpl.Type.INFO4; + } + if (EventImpl.Type.INFO5.ordinal() == val) { + return EventImpl.Type.INFO5; + } + if (EventImpl.Type.INFO6.ordinal() == val) { + return EventImpl.Type.INFO6; + } + if (EventImpl.Type.INFO7.ordinal() == val) { + return EventImpl.Type.INFO7; + } + if (EventImpl.Type.INFO8.ordinal() == val) { + return EventImpl.Type.INFO8; + } + if (EventImpl.Type.INFO9.ordinal() == val) { + return EventImpl.Type.INFO9; + } + return EventImpl.Type.UNKNOWN; + } private void loadTraceNameStrings() { traceNames[0] = new TraceStrings(); @@ -176,7 +191,7 @@ public class TraceModelImplFactory { traceNames[9] = new TraceStrings(); traceNames[9].name = "TE Log - TATA BSC14"; traceNames[9].classNmme = "Board 14, SPO"; - + traceNames[10] = new TraceStrings(); traceNames[10].name = "INFO 1"; traceNames[10].classNmme = "All Boards"; @@ -196,7 +211,7 @@ public class TraceModelImplFactory { traceNames[14] = new TraceStrings(); traceNames[14].name = "MISC2"; traceNames[14].classNmme = "Board 11"; - + traceNames[15] = new TraceStrings(); traceNames[15].name = "MISC3"; traceNames[15].classNmme = "Board 23"; diff --git a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java index 1f7851a956..a42c3dfc3d 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -26,7 +26,6 @@ import org.eclipse.jface.dialogs.MessageDialog; 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; @@ -98,7 +97,7 @@ public class TsfTraceAnalysisView extends ViewPart implements */ class TreeObject implements IAdaptable { - private String name; + private final String name; private TreeParent parent; public TreeObject(String name) { @@ -130,7 +129,7 @@ public class TsfTraceAnalysisView extends ViewPart implements } class TreeParent extends TreeObject { - private ArrayList children; + private final ArrayList children; public TreeParent(String name) { super(name); @@ -157,8 +156,7 @@ public class TsfTraceAnalysisView extends ViewPart implements } } - class ViewContentProvider implements IStructuredContentProvider, - ITreeContentProvider { + class ViewContentProvider implements ITreeContentProvider { private TreeParent invisibleRoot; @Override @@ -172,8 +170,9 @@ public class TsfTraceAnalysisView extends ViewPart implements @Override public Object[] getElements(Object parent) { if (parent.equals(getViewSite())) { - if (invisibleRoot == null) - initialize(); + if (invisibleRoot == null) { + initialize(); + } return getChildren(invisibleRoot); } return getChildren(parent); @@ -197,8 +196,9 @@ public class TsfTraceAnalysisView extends ViewPart implements @Override public boolean hasChildren(Object parent) { - if (parent instanceof TreeParent) - return ((TreeParent) parent).hasChildren(); + if (parent instanceof TreeParent) { + return ((TreeParent) parent).hasChildren(); + } return false; } @@ -238,8 +238,9 @@ public class TsfTraceAnalysisView extends ViewPart implements @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); } @@ -347,10 +348,11 @@ public class TsfTraceAnalysisView extends ViewPart implements 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; } @@ -616,38 +618,36 @@ public class TsfTraceAnalysisView extends ViewPart implements @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 */ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java index 4031257d38..fb80cfe12b 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 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: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -15,9 +15,10 @@ package org.eclipse.linuxtools.internal.tmf.ui.dialogs; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition; @@ -50,7 +51,7 @@ public class ManageCustomParsersDialog extends Dialog { Button deleteButton; Button importButton; Button exportButton; - + public ManageCustomParsersDialog(Shell parent) { super(parent); setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle()); @@ -63,7 +64,7 @@ public class ManageCustomParsersDialog extends Dialog { protected Control createDialogArea(Composite parent) { getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader); getShell().setImage(image); - + Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(2, false)); @@ -73,13 +74,13 @@ public class ManageCustomParsersDialog extends Dialog { lcgl.marginHeight = 0; lcgl.marginWidth = 0; listContainer.setLayout(lcgl); - + Composite radioContainer = new Composite(listContainer, SWT.NONE); GridLayout rcgl = new GridLayout(2, true); rcgl.marginHeight = 0; rcgl.marginWidth = 0; radioContainer.setLayout(rcgl); - + txtButton = new Button(radioContainer, SWT.RADIO); txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel); txtButton.setSelection(true); @@ -90,7 +91,7 @@ public class ManageCustomParsersDialog extends Dialog { public void widgetSelected(SelectionEvent e) { fillParserList(); }}); - + xmlButton = new Button(radioContainer, SWT.RADIO); xmlButton.setText("XML"); //$NON-NLS-1$ xmlButton.addSelectionListener(new SelectionListener(){ @@ -100,7 +101,7 @@ public class ManageCustomParsersDialog extends Dialog { public void widgetSelected(SelectionEvent e) { fillParserList(); }}); - + parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); parserList.addSelectionListener(new SelectionListener(){ @@ -118,7 +119,7 @@ public class ManageCustomParsersDialog extends Dialog { exportButton.setEnabled(true); } }}); - + Composite buttonContainer = new Composite(composite, SWT.NULL); buttonContainer.setLayout(new GridLayout()); buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); @@ -139,12 +140,12 @@ public class ManageCustomParsersDialog extends Dialog { } if (dialog != null) { dialog.open(); - if (dialog.getReturnCode() == Dialog.OK) { + if (dialog.getReturnCode() == Window.OK) { fillParserList(); } } }}); - + editButton = new Button(buttonContainer, SWT.PUSH); editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel); @@ -164,7 +165,7 @@ public class ManageCustomParsersDialog extends Dialog { } if (dialog != null) { dialog.open(); - if (dialog.getReturnCode() == Dialog.OK) { + if (dialog.getReturnCode() == Window.OK) { fillParserList(); } } @@ -194,7 +195,7 @@ public class ManageCustomParsersDialog extends Dialog { }}); new Label(buttonContainer, SWT.NONE); // filler - + importButton = new Button(buttonContainer, SWT.PUSH); importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTraceDefinition.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTraceDefinition.java index 012076f87b..539d0e1caa 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTraceDefinition.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTraceDefinition.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 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: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -28,15 +28,15 @@ public abstract class CustomTraceDefinition { public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag; public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag; public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag; - + public String definitionName; public List outputs; public String timeStampOutputFormat; - + public static class OutputColumn { public String name; - public OutputColumn() {}; + public OutputColumn() {} public OutputColumn(String name) { this.name = name; @@ -52,7 +52,7 @@ public abstract class CustomTraceDefinition { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat); return simpleDateFormat.format(timestamp.getValue()); } - + public abstract void save(); public abstract void save(String path); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEvent.java index d59c233ba8..745a449266 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEvent.java @@ -54,19 +54,19 @@ public class CustomTxtEvent extends CustomEvent { continue; } String name = column.name; - if (column.action == CustomTxtTraceDefinition.ACTION_SET) { + if (column.action == CustomTraceDefinition.ACTION_SET) { fData.put(name, value); - if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format); } - } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) { + } else if (column.action == CustomTraceDefinition.ACTION_APPEND) { String s = fData.get(name); if (s != null) { fData.put(name, s + value); } else { fData.put(name, value); } - if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY); if (timeStampInputFormat != null) { fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format); @@ -74,14 +74,14 @@ public class CustomTxtEvent extends CustomEvent { fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format); } } - } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { + } else if (column.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { String s = fData.get(name); if (s != null) { fData.put(name, s + " | " + value); //$NON-NLS-1$ } else { fData.put(name, value); } - if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY); if (timeStampInputFormat != null) { fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java index 52fdbdcf7b..8c19d20fc8 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 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: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -35,8 +35,8 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -66,20 +66,20 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { private static final String ACTION_ATTRIBUTE = Messages.CustomTxtTraceDefinition_action; private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format; private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn; - + public List inputs; public CustomTxtTraceDefinition() { this("", new ArrayList(0), new ArrayList(0), ""); //$NON-NLS-1$ //$NON-NLS-2$ - }; - + } + public CustomTxtTraceDefinition(String logtype, List inputs, List outputs, String timeStampOutputFormat) { this.definitionName = logtype; this.inputs = inputs; this.outputs = outputs; this.timeStampOutputFormat = timeStampOutputFormat; } - + public static class InputLine { public List columns; public Cardinality cardinality; @@ -89,31 +89,31 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { public int level; public InputLine nextInput; public List childrenInputs; - - public InputLine() {}; - + + public InputLine() {} + public InputLine(Cardinality cardinality, String regex, List columns) { this.cardinality = cardinality; this.regex = regex; this.columns = columns; } - + public void setRegex(String regex) { this.regex = regex; this.pattern = null; } - + public String getRegex() { return regex; } - + public Pattern getPattern() throws PatternSyntaxException { if (pattern == null) { pattern = Pattern.compile(regex); } return pattern; } - + public void addChild(InputLine input) { if (childrenInputs == null) { childrenInputs = new ArrayList(1); @@ -166,7 +166,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } columns.add(column); } - + public List getNextInputs(Map countMap) { List nextInputs = new ArrayList(); InputLine next = nextInput; @@ -189,11 +189,11 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } return nextInputs; } - + public int getMinCount() { return cardinality.min; } - + public int getMaxCount() { return cardinality.max; } @@ -202,22 +202,22 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { public String toString() { return regex + " " + cardinality; //$NON-NLS-1$ } - + } public static class InputData { public String name; public int action; public String format; - - public InputData() {}; - + + public InputData() {} + public InputData(String name, int action, String format) { this.name = name; this.action = action; this.format = format; } - + public InputData(String name, int action) { this.name = name; this.action = action; @@ -229,11 +229,11 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { public final static Cardinality ONE = new Cardinality(1, 1); public final static Cardinality ONE_OR_MORE = new Cardinality(1, INF); public final static Cardinality ZERO_OR_ONE = new Cardinality(0, 1); - public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF); - - private int min; - private int max; - + public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF); + + private final int min; + private final int max; + public Cardinality(int min, int max) { this.min = min; this.max = max; @@ -267,23 +267,25 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { if (obj == null) { return false; } - if (!(obj instanceof Cardinality)) return false; + if (!(obj instanceof Cardinality)) { + return false; + } Cardinality other = (Cardinality) obj; return (this.min == other.min && this.max == other.max); } } - + @Override public void save() { save(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME); } - + @Override public void save(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); - + // The following allows xml parsing without access to the dtd EntityResolver resolver = new EntityResolver () { @Override @@ -305,7 +307,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { public void fatalError(SAXParseException saxparseexception) throws SAXException { throw saxparseexception; }}); - + Document doc = null; File file = new File(path); if (file.canRead()) { @@ -320,7 +322,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } Element root = doc.getDocumentElement(); - + NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); @@ -333,7 +335,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { Element definitionElement = doc.createElement(DEFINITION_ELEMENT); root.appendChild(definitionElement); definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName); - + Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT); definitionElement.appendChild(formatElement); formatElement.appendChild(doc.createTextNode(timeStampOutputFormat)); @@ -351,7 +353,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name); } } - + Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -360,7 +362,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = result.getWriter().toString(); - + FileWriter writer = new FileWriter(file); writer.write(xmlString); writer.close(); @@ -381,12 +383,12 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { private Element createInputLineElement(InputLine inputLine, Document doc) { Element inputLineElement = doc.createElement(INPUT_LINE_ELEMENT); - + Element cardinalityElement = doc.createElement(CARDINALITY_ELEMENT); inputLineElement.appendChild(cardinalityElement); cardinalityElement.setAttribute(MIN_ATTRIBUTE, Integer.toString(inputLine.cardinality.min)); cardinalityElement.setAttribute(MAX_ATTRIBUTE, Integer.toString(inputLine.cardinality.max)); - + Element regexElement = doc.createElement(REGEX_ELEMENT); inputLineElement.appendChild(regexElement); regexElement.appendChild(doc.createTextNode(inputLine.regex)); @@ -402,20 +404,20 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } } } - + if (inputLine.childrenInputs != null) { for (InputLine childInputLine : inputLine.childrenInputs) { inputLineElement.appendChild(createInputLineElement(childInputLine, doc)); } } - + return inputLineElement; } - + public static CustomTxtTraceDefinition[] loadAll() { return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME); } - + public static CustomTxtTraceDefinition[] loadAll(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -529,13 +531,15 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } return null; } - + public static CustomTxtTraceDefinition extractDefinition(Element definitionElement) { CustomTxtTraceDefinition def = new CustomTxtTraceDefinition(); - + def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE); - if (def.definitionName == null) return null; - + if (def.definitionName == null) { + return null; + } + NodeList nodeList = definitionElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); @@ -593,7 +597,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } return inputLine; } - + public static void delete(String definitionName) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -638,7 +642,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { root.removeChild(node); } } - + Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -647,7 +651,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = result.getWriter().toString(); - + FileWriter writer = new FileWriter(file); writer.write(xmlString); writer.close(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java index e9ffee7665..fb13a4c0cf 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -225,7 +225,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven } } catch (final IOException e) { Activator.getDefault().logError("Error parsing event. File: " + getPath(), e); //$NON-NLS-1$ - + } context.setLocation(NULL_LOCATION); return event; @@ -306,7 +306,8 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven } } - private void readQuote(final StringBuffer buffer, final RandomAccessFile raFile, final char eq) { + private static void readQuote(final StringBuffer buffer, + final RandomAccessFile raFile, final char eq) { try { int i; while ((i = raFile.read()) != -1) { @@ -323,7 +324,8 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven } } - private void readComment(final StringBuffer buffer, final RandomAccessFile raFile) { + private static void readComment(final StringBuffer buffer, + final RandomAccessFile raFile) { try { int numRead = 0; int i; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java index 6e3dd5f050..aa22b3ec33 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 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: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -32,8 +32,8 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -63,12 +63,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { private static final String ACTION_ATTRIBUTE = Messages.CustomXmlTraceDefinition_action; private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format; private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn; - + public InputElement rootInputElement; public CustomXmlTraceDefinition() { this("", null, new ArrayList(), ""); //$NON-NLS-1$ //$NON-NLS-2$ - }; + } public CustomXmlTraceDefinition(String logtype, InputElement rootElement, List outputs, String timeStampOutputFormat) { this.definitionName = logtype; @@ -87,9 +87,9 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { public InputElement parentElement; public InputElement nextElement; public List childElements; - - public InputElement() {}; - + + public InputElement() {} + public InputElement(String elementName, boolean logEntry, String inputName, int inputAction, String inputFormat, List attributes) { this.elementName = elementName; this.logEntry = logEntry; @@ -98,7 +98,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { this.inputFormat = inputFormat; this.attributes = attributes; } - + public void addAttribute(InputAttribute attribute) { if (attributes == null) { attributes = new ArrayList(1); @@ -157,9 +157,9 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { public String inputName; public int inputAction; public String inputFormat; - - public InputAttribute() {}; - + + public InputAttribute() {} + public InputAttribute(String attributeName, String inputName, int inputAction, String inputFormat) { this.attributeName = attributeName; this.inputName = inputName; @@ -172,13 +172,13 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { public void save() { save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME); } - + @Override public void save(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); - + // The following allows xml parsing without access to the dtd EntityResolver resolver = new EntityResolver () { @Override @@ -200,7 +200,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { public void fatalError(SAXParseException saxparseexception) throws SAXException { throw saxparseexception; }}); - + Document doc = null; File file = new File(path); if (file.canRead()) { @@ -215,7 +215,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } Element root = doc.getDocumentElement(); - + NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); @@ -228,7 +228,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { Element definitionElement = doc.createElement(DEFINITION_ELEMENT); root.appendChild(definitionElement); definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName); - + Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT); definitionElement.appendChild(formatElement); formatElement.appendChild(doc.createTextNode(timeStampOutputFormat)); @@ -244,7 +244,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name); } } - + Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -253,7 +253,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = result.getWriter().toString(); - + FileWriter writer = new FileWriter(file); writer.write(xmlString); writer.close(); @@ -271,11 +271,11 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$ } } - + private Element createInputElementElement(InputElement inputElement, Document doc) { Element inputElementElement = doc.createElement(INPUT_ELEMENT_ELEMENT); inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.elementName); - + if (inputElement.logEntry) { inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.logEntry)); } @@ -304,20 +304,20 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } } } - + if (inputElement.childElements != null) { for (InputElement childInputElement : inputElement.childElements) { inputElementElement.appendChild(createInputElementElement(childInputElement, doc)); } } - + return inputElementElement; } - + public static CustomXmlTraceDefinition[] loadAll() { return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME); } - + public static CustomXmlTraceDefinition[] loadAll(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -431,13 +431,15 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } return null; } - + public static CustomXmlTraceDefinition extractDefinition(Element definitionElement) { CustomXmlTraceDefinition def = new CustomXmlTraceDefinition(); - + def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE); - if (def.definitionName == null) return null; - + if (def.definitionName == null) { + return null; + } + NodeList nodeList = definitionElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); @@ -503,7 +505,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } return inputElement; } - + public static void delete(String definitionName) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -548,7 +550,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { root.removeChild(node); } } - + Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -557,7 +559,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = result.getWriter().toString(); - + FileWriter writer = new FileWriter(file); writer.write(xmlString); writer.close(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java index 636255ce35..e84e37d4ca 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java @@ -29,8 +29,9 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.internal.tmf.ui.Messages; +import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.Cardinality; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData; @@ -91,7 +92,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - private ISelection selection; + private final ISelection selection; private CustomTxtTraceDefinition definition; private String editDefinitionName; private String defaultDescription; @@ -113,7 +114,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { // variables used recursively through line traversal private String timeStampFormat; private boolean timestampFound; - + protected CustomTxtParserInputWizardPage(ISelection selection, CustomTxtTraceDefinition definition) { super("CustomParserWizardPage"); //$NON-NLS-1$ if (definition == null) { @@ -137,23 +138,23 @@ public class CustomTxtParserInputWizardPage extends WizardPage { container.setLayout(new GridLayout()); updateListener = new UpdateListener(); - + Composite headerComposite = new Composite(container, SWT.FILL); GridLayout headerLayout = new GridLayout(5, false); headerLayout.marginHeight = 0; headerLayout.marginWidth = 0; headerComposite.setLayout(headerLayout); headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + Label logtypeLabel = new Label(headerComposite, SWT.NULL); logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType); - + logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT)); - + Label timestampFormatLabel = new Label(headerComposite, SWT.NULL); timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat); - + timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT); @@ -167,11 +168,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { openHelpShell(SIMPLE_DATE_FORMAT_URL); } }); - + Label timestampPreviewLabel = new Label(headerComposite, SWT.NULL); timestampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1)); timestampPreviewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview); - + timestampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); timestampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp); @@ -181,14 +182,16 @@ public class CustomTxtParserInputWizardPage extends WizardPage { buttonBarLayout.marginHeight = 0; buttonBarLayout.marginWidth = 0; buttonBar.setLayout(buttonBarLayout); - + Button removeButton = new Button(buttonBar, SWT.PUSH); removeButton.setImage(deleteImage); removeButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeLine); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty() || selectedLine == null) return; + if (treeViewer.getSelection().isEmpty() || selectedLine == null) { + return; + } removeLine(); InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputLine.parentInput == null) { @@ -253,7 +256,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage { moveUpButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty()) return; + if (treeViewer.getSelection().isEmpty()) { + return; + } InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputLine.parentInput == null) { for (int i = 1; i < definition.inputs.size(); i++) { @@ -276,7 +281,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage { moveDownButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty()) return; + if (treeViewer.getSelection().isEmpty()) { + return; + } InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputLine.parentInput == null) { for (int i = 0; i < definition.inputs.size() - 1; i++) { @@ -293,7 +300,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { updatePreviews(); } }); - + SashForm vSash = new SashForm(container, SWT.VERTICAL); vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY)); @@ -311,15 +318,15 @@ public class CustomTxtParserInputWizardPage extends WizardPage { treeScrolledComposite.setContent(treeContainer); treeScrolledComposite.setExpandHorizontal(true); treeScrolledComposite.setExpandVertical(true); - + treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER); treeViewer.setContentProvider(new InputLineTreeNodeContentProvider()); treeViewer.setLabelProvider(new InputLineTreeLabelProvider()); treeViewer.addSelectionChangedListener(new InputLineTreeSelectionChangedListener()); treeContainer.layout(); - + treeScrolledComposite.setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); - + lineScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL); lineScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); lineContainer = new Composite(lineScrolledComposite, SWT.NONE); @@ -334,19 +341,19 @@ public class CustomTxtParserInputWizardPage extends WizardPage { if (definition == null) { definition = new CustomTxtTraceDefinition(); definition.inputs.add(new InputLine(Cardinality.ZERO_OR_MORE, DEFAULT_REGEX, - Arrays.asList(new InputData(CustomTxtTraceDefinition.TAG_MESSAGE, CustomTxtTraceDefinition.ACTION_SET)))); + Arrays.asList(new InputData(CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.ACTION_SET)))); } loadDefinition(definition); treeViewer.expandAll(); lineContainer.layout(); - + logtypeText.addModifyListener(updateListener); timestampOutputFormatText.addModifyListener(updateListener); - + lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1); hSash.setWeights(new int[] {1, 2}); - + Composite sashBottom = new Composite(vSash, SWT.NONE); GridLayout sashBottomLayout = new GridLayout(3, false); sashBottomLayout.marginHeight = 0; @@ -366,7 +373,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { updatePreviews(true); } }); - + Button legendButton = new Button(sashBottom, SWT.PUSH); legendButton.setImage(helpImage); legendButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_previewLegend); @@ -377,7 +384,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { openLegend(); } }); - + inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); if (fixedFont == null) { if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$ @@ -395,9 +402,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage { inputText.addModifyListener(updateListener); vSash.setWeights(new int[] {hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y}); - + setControl(container); - + validate(); updatePreviews(); } @@ -412,7 +419,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage { @Override public Object[] getChildren(Object parentElement) { InputLine inputLine = (InputLine) parentElement; - if (inputLine.childrenInputs == null) return new InputLine[0]; + if (inputLine.childrenInputs == null) { + return new InputLine[0]; + } return inputLine.childrenInputs.toArray(); } @@ -436,7 +445,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { return inputLine.parentInput; } } - + private class InputLineTreeLabelProvider extends ColumnLabelProvider { @Override @@ -449,9 +458,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { InputLine inputLine = (InputLine) element; if (inputLine.parentInput == null) { return "Root Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } else { - return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } @@ -473,7 +481,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.DialogPage#dispose() */ @@ -514,7 +522,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } return inputs; } - + public List getInputNames(InputLine inputLine) { List inputs = new ArrayList(); if (inputLine.columns != null) { @@ -536,7 +544,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } return inputs; } - + private void removeLine() { selectedLine.dispose(); selectedLine = null; @@ -575,7 +583,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } return ""; //$NON-NLS-1$ } - + private void updatePreviews() { updatePreviews(false); } @@ -586,7 +594,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { return; } inputText.setStyleRanges(new StyleRange[] {}); - + Scanner scanner = new Scanner(inputText.getText()); scanner.useDelimiter("\n"); //$NON-NLS-1$ int rawPos = 0; @@ -594,21 +602,21 @@ public class CustomTxtParserInputWizardPage extends WizardPage { if ((skip = scanner.findWithinHorizon("\\A\n+", 0)) != null) { //$NON-NLS-1$ rawPos += skip.length(); } - + timeStampFormat = null; if (selectedLine != null) { for (InputGroup input : selectedLine.inputs) { input.previewText.setText(Messages.CustomTxtParserInputWizardPage_noMathcingLine); } } - + Map data = new HashMap(); int rootLineMatches = 0; String firstEntryTimeStamp = null; String firstEntryTimeStampInputFormat = null; String log = null; - event: - while (log != null || scanner.hasNext()) { + event: + while (scanner.hasNext()) { if (rootLineMatches > 0 && !updateAll) { break; } @@ -632,7 +640,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { timeStampFormat = null; updatePreviewLine(rootInputLine, matcher, data, rawPos, rootLineMatches); if (rootLineMatches == 1) { - firstEntryTimeStamp = data.get(CustomTxtTraceDefinition.TAG_TIMESTAMP); + firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP); firstEntryTimeStampInputFormat = timeStampFormat; } HashMap countMap = new HashMap(); @@ -753,14 +761,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } scanner.close(); if (rootLineMatches == 1) { - firstEntryTimeStamp = data.get(CustomTxtTraceDefinition.TAG_TIMESTAMP); + firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP); firstEntryTimeStampInputFormat = timeStampFormat; } if (firstEntryTimeStamp == null) { timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noTimestampGroup); if (selectedLine != null) { for (InputGroup group : selectedLine.inputs) { - if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) { timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp); break; } @@ -801,33 +809,33 @@ public class CustomTxtParserInputWizardPage extends WizardPage { if (value.length() == 0) { continue; } - if (input.action == CustomTxtTraceDefinition.ACTION_SET) { + if (input.action == CustomTraceDefinition.ACTION_SET) { data.put(input.name, value); - if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { timeStampFormat = input.format; } - } else if (input.action == CustomTxtTraceDefinition.ACTION_APPEND) { + } else if (input.action == CustomTraceDefinition.ACTION_APPEND) { String s = data.get(input.name); if (s != null) { data.put(input.name, s + value); } else { data.put(input.name, value); } - if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { if (timeStampFormat != null) { timeStampFormat += input.format; } else { timeStampFormat = input.format; } } - } else if (input.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { + } else if (input.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { String s = data.get(input.name); if (s != null) { data.put(input.name, s + " | " + value); //$NON-NLS-1$ } else { data.put(input.name, value); } - if (input.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { if (timeStampFormat != null) { timeStampFormat += " | " + input.format; //$NON-NLS-1$ } else { @@ -856,7 +864,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } } - + private void openHelpShell(String url) { if (helpBrowser != null && !helpBrowser.isDisposed()) { helpBrowser.getShell().setActive(); @@ -895,8 +903,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { int line5start = line4start + line4.length(); String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine; int line6start = line5start + line5.length(); - String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + final Shell legendShell = new Shell(getShell(), SWT.DIALOG_TRIM); legendShell.setLayout(new FillLayout()); StyledText legendText = new StyledText(legendShell, SWT.MULTI); @@ -940,7 +948,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } - + private class Line { private static final String INFINITY_STRING = "\u221E"; //$NON-NLS-1$ InputLine inputLine; @@ -957,39 +965,39 @@ public class CustomTxtParserInputWizardPage extends WizardPage { List inputs = new ArrayList(); Button addGroupButton; Label addGroupLabel; - + public Line(Composite parent, String name, InputLine inputLine) { this.inputLine = inputLine; - + group = new Group(parent, SWT.NONE); group.setText(name); group.setLayout(new GridLayout(2, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + labelComposite = new Composite(group, SWT.FILL); GridLayout labelLayout = new GridLayout(1, false); labelLayout.marginWidth = 0; labelLayout.marginHeight = 0; labelComposite.setLayout(labelLayout); labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - + Label label = new Label(labelComposite, SWT.NULL); label.setText(Messages.CustomTxtParserInputWizardPage_regularExpression); - + Composite regexContainer = new Composite(group, SWT.NONE); GridLayout regexLayout = new GridLayout(2, false); regexLayout.marginHeight = 0; regexLayout.marginWidth = 0; regexContainer.setLayout(regexLayout); regexContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + regexText = new Text(regexContainer, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.widthHint = 0; regexText.setLayoutData(gd); regexText.setText(inputLine.getRegex()); regexText.addModifyListener(updateListener); - + Button regexHelpButton = new Button(regexContainer, SWT.PUSH); regexHelpButton.setImage(helpImage); regexHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_regularExpressionHelp); @@ -999,11 +1007,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { openHelpShell(PATTERN_URL); } }); - + label = new Label(group, SWT.NONE); label.setText(Messages.CustomTxtParserInputWizardPage_cardinality); label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - + cardinalityContainer = new Composite(group, SWT.NONE); GridLayout cardinalityLayout = new GridLayout(6, false); cardinalityLayout.marginHeight = 0; @@ -1043,23 +1051,23 @@ public class CustomTxtParserInputWizardPage extends WizardPage { validate(); updatePreviews(); }}); - + cardinalityMinLabel = new Label(cardinalityContainer, SWT.NONE); cardinalityMinLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); cardinalityMinLabel.setText(Messages.CustomTxtParserInputWizardPage_min); cardinalityMinLabel.setVisible(false); - + cardinalityMinText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE); gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); gd.widthHint = 20; cardinalityMinText.setLayoutData(gd); cardinalityMinText.setVisible(false); - + cardinalityMaxLabel = new Label(cardinalityContainer, SWT.NONE); cardinalityMaxLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); cardinalityMaxLabel.setText(Messages.CustomTxtParserInputWizardPage_max); cardinalityMaxLabel.setVisible(false); - + cardinalityMaxText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE); gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); gd.widthHint = 20; @@ -1099,7 +1107,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } infiniteButton.setVisible(true); } - + VerifyListener digitsListener = new VerifyListener() { @Override public void verifyText(VerifyEvent e) { @@ -1117,7 +1125,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } }}; - + cardinalityMinText.addModifyListener(updateListener); cardinalityMaxText.addModifyListener(updateListener); cardinalityMinText.addVerifyListener(digitsListener); @@ -1126,14 +1134,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { if (inputLine.columns != null) { for (InputData inputData : inputLine.columns) { InputGroup inputGroup = new InputGroup(group, this, inputs.size()+1); - if (inputData.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { inputGroup.tagCombo.select(0); inputGroup.tagText.setText(inputData.format); inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format); inputGroup.tagLabel.setVisible(true); inputGroup.tagText.setVisible(true); inputGroup.tagText.addModifyListener(updateListener); - } else if (inputData.name.equals(CustomTxtTraceDefinition.TAG_MESSAGE)) { + } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) { inputGroup.tagCombo.select(1); } else { inputGroup.tagCombo.select(2); @@ -1147,7 +1155,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { inputs.add(inputGroup); } } - + createAddGroupButton(); } @@ -1169,7 +1177,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { updatePreviews(); } }); - + addGroupLabel = new Label(group, SWT.NULL); addGroupLabel.setText(Messages.CustomTxtParserInputWizardPage_newGroup); } @@ -1178,7 +1186,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { addGroupButton.dispose(); addGroupLabel.dispose(); } - + private void removeInput(int inputNumber) { if (--inputNumber < inputs.size()) { inputs.remove(inputNumber).dispose(); @@ -1190,16 +1198,16 @@ public class CustomTxtParserInputWizardPage extends WizardPage { group.getParent().layout(); } } - + // private void setName(String name) { // this.name = name; // group.setText("Line " + name); // } - + private void dispose() { group.dispose(); } - + private void extractInputs() { inputLine.setRegex(selectedLine.regexText.getText()); switch (cardinalityCombo.getSelectionIndex()) { @@ -1241,11 +1249,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { for (int i = 0; i < inputs.size(); i++) { InputGroup group = inputs.get(i); InputData inputData = new InputData(); - if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_OTHER)) { + if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) { inputData.name = group.tagText.getText().trim(); } else { inputData.name = group.tagCombo.getText(); - if (group.tagCombo.getText().equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) { inputData.format = group.tagText.getText().trim(); } } @@ -1258,7 +1266,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { private class InputGroup { Line line; int inputNumber; - + // children of parent (must be disposed) Composite labelComposite; Composite tagComposite; @@ -1267,24 +1275,24 @@ public class CustomTxtParserInputWizardPage extends WizardPage { // children of labelComposite Label inputLabel; - + // children of tagComposite Combo tagCombo; Label tagLabel; Text tagText; Combo actionCombo; - + public InputGroup(Composite parent, Line line, int inputNumber) { this.line = line; this.inputNumber = inputNumber; - + labelComposite = new Composite(parent, SWT.FILL); GridLayout labelLayout = new GridLayout(2, false); labelLayout.marginWidth = 0; labelLayout.marginHeight = 0; labelComposite.setLayout(labelLayout); labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - + Button deleteButton = new Button(labelComposite, SWT.PUSH); deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); deleteButton.setImage(deleteImage); @@ -1297,7 +1305,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { updatePreviews(); } }); - + inputLabel = new Label(labelComposite, SWT.NULL); inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$ @@ -1308,11 +1316,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { tagLayout.marginHeight = 0; tagComposite.setLayout(tagLayout); tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY); - tagCombo.setItems(new String[] {CustomTxtTraceDefinition.TAG_TIMESTAMP, - CustomTxtTraceDefinition.TAG_MESSAGE, - CustomTxtTraceDefinition.TAG_OTHER}); + tagCombo.setItems(new String[] {CustomTraceDefinition.TAG_TIMESTAMP, + CustomTraceDefinition.TAG_MESSAGE, + CustomTraceDefinition.TAG_OTHER}); tagCombo.select(1); tagCombo.addSelectionListener(new SelectionListener(){ @Override @@ -1341,31 +1349,33 @@ public class CustomTxtParserInputWizardPage extends WizardPage { tagLabel.setVisible(false); tagText.setVisible(false); break; + default: + break; } tagComposite.layout(); validate(); updatePreviews(); }}); - + tagLabel = new Label(tagComposite, SWT.NULL); tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); tagLabel.setVisible(false); - + tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.widthHint = 0; tagText.setLayoutData(gd); tagText.setVisible(false); - + actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY); actionCombo.setItems(new String[] {Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith}); actionCombo.select(0); actionCombo.addSelectionListener(updateListener); - + previewLabel = new Label(parent, SWT.NULL); previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); previewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview); - + previewText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.widthHint = 0; @@ -1373,14 +1383,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatch); previewText.setBackground(COLOR_WIDGET_BACKGROUND); } - + private void dispose() { labelComposite.dispose(); tagComposite.dispose(); previewLabel.dispose(); previewText.dispose(); } - + private void setInputNumber(int inputNumber) { this.inputNumber = inputNumber; inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$ @@ -1392,14 +1402,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { definition.definitionName = logtypeText.getText().trim(); definition.timeStampOutputFormat = timestampOutputFormatText.getText().trim(); - + if (selectedLine != null) { selectedLine.extractInputs(); treeViewer.refresh(); } - + StringBuffer errors = new StringBuffer(); - + if (definition.definitionName.length() == 0) { errors.append("Enter a name for the new log type. "); //$NON-NLS-1$ logtypeText.setBackground(COLOR_LIGHT_RED); @@ -1415,10 +1425,10 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } } - + timestampFound = false; for (int i = 0; i < definition.inputs.size(); i++) { - + InputLine inputLine = definition.inputs.get(i); String name = Integer.toString(i+1); errors.append(validateLine(inputLine, name)); @@ -1436,7 +1446,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { timestampOutputFormatText.setBackground(COLOR_LIGHT_RED); } } - + } else { timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND); // timestampPreviewText.setBackground(COLOR_WIDGET_BACKGROUND); @@ -1457,53 +1467,83 @@ public class CustomTxtParserInputWizardPage extends WizardPage { public StringBuffer validateLine(InputLine inputLine, String name) { StringBuffer errors = new StringBuffer(); Line line = null; - if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) line = selectedLine; + if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) { + line = selectedLine; + } try { Pattern.compile(inputLine.getRegex()); - if (line != null) line.regexText.setBackground(COLOR_TEXT_BACKGROUND); + if (line != null) { + line.regexText.setBackground(COLOR_TEXT_BACKGROUND); + } } catch (PatternSyntaxException e) { errors.append("Enter a valid regular expression (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$ - if (line != null) line.regexText.setBackground(COLOR_LIGHT_RED); + if (line != null) { + line.regexText.setBackground(COLOR_LIGHT_RED); + } } if (inputLine.getMinCount() == -1) { errors.append("Enter a minimum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$ - if (line != null) line.cardinalityMinText.setBackground(COLOR_LIGHT_RED); + if (line != null) { + line.cardinalityMinText.setBackground(COLOR_LIGHT_RED); + } } else { - if (line != null) line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND); + if (line != null) { + line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND); + } } if (inputLine.getMaxCount() == -1) { errors.append("Enter a maximum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$ - if (line != null) line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED); + if (line != null) { + line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED); + } } else if (inputLine.getMinCount() > inputLine.getMaxCount()) { errors.append("Enter correct (min <= max) values for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$ - if (line != null) line.cardinalityMinText.setBackground(COLOR_LIGHT_RED); - if (line != null) line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED); + if (line != null) { + line.cardinalityMinText.setBackground(COLOR_LIGHT_RED); + } + if (line != null) { + line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED); + } } else { - if (line != null) line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND); + if (line != null) { + line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND); + } } for (int i = 0; inputLine.columns != null && i < inputLine.columns.size(); i++) { InputData inputData = inputLine.columns.get(i); InputGroup group = null; - if (line != null) group = line.inputs.get(i); - if (inputData.name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) { + if (line != null) { + group = line.inputs.get(i); + } + if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { timestampFound = true; if (inputData.format.length() == 0) { errors.append("Enter the input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED); + if (group != null) { + group.tagText.setBackground(COLOR_LIGHT_RED); + } } else { try { new SimpleDateFormat(inputData.format); - if (group != null) group.tagText.setBackground(COLOR_TEXT_BACKGROUND); + if (group != null) { + group.tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } catch (IllegalArgumentException e) { 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$ - if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED); + if (group != null) { + group.tagText.setBackground(COLOR_LIGHT_RED); + } } } } else if (inputData.name.length() == 0) { errors.append("Enter a name for the data group (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (group != null) group.tagText.setBackground(COLOR_LIGHT_RED); + if (group != null) { + group.tagText.setBackground(COLOR_LIGHT_RED); + } } else { - if (group != null) group.tagText.setBackground(COLOR_TEXT_BACKGROUND); + if (group != null) { + group.tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } } for (int i = 0; inputLine.childrenInputs != null && i < inputLine.childrenInputs.size(); i++) { @@ -1511,7 +1551,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } return errors; } - + public CustomTxtTraceDefinition getDefinition() { return definition; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java index 57f1da4090..11c6eb1c19 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java @@ -17,6 +17,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -27,8 +28,9 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.internal.tmf.ui.Messages; +import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute; @@ -301,8 +303,9 @@ public class CustomXmlParserInputWizardPage extends WizardPage { removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty() || selectedElement == null) + if (treeViewer.getSelection().isEmpty() || selectedElement == null) { return; + } removeElement(); InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputElement == definition.rootInputElement) { @@ -364,10 +367,9 @@ public class CustomXmlParserInputWizardPage extends WizardPage { InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (previousInputElement == definition.rootInputElement) { return; - } else { - previousInputElement.addNext(inputElement); - inputElement.elementName = getChildNameSuggestion(inputElement.parentElement); } + previousInputElement.addNext(inputElement); + inputElement.elementName = getChildNameSuggestion(inputElement.parentElement); } treeViewer.refresh(); treeViewer.setSelection(new StructuredSelection(inputElement), true); @@ -397,7 +399,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { } treeViewer.refresh(); treeViewer.setSelection(new StructuredSelection(inputElement), true); - treeViewer.expandToLevel(inputElement, TreeViewer.ALL_LEVELS); + treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS); } }); @@ -407,14 +409,14 @@ public class CustomXmlParserInputWizardPage extends WizardPage { moveUpButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty()) + if (treeViewer.getSelection().isEmpty()) { return; + } InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputElement == definition.rootInputElement) { return; - } else { - inputElement.moveUp(); } + inputElement.moveUp(); treeViewer.refresh(); validate(); updatePreviews(); @@ -427,14 +429,14 @@ public class CustomXmlParserInputWizardPage extends WizardPage { moveDownButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (treeViewer.getSelection().isEmpty()) + if (treeViewer.getSelection().isEmpty()) { return; + } InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (inputElement == definition.rootInputElement) { return; - } else { - inputElement.moveDown(); } + inputElement.moveDown(); treeViewer.refresh(); validate(); updatePreviews(); @@ -447,20 +449,18 @@ public class CustomXmlParserInputWizardPage extends WizardPage { String attributeName = getAttributeNameSuggestion(inputElement); if (attributeName.length() == 0) { break; - } else { - InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$ - inputElement.addAttribute(attribute); } + InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$ + inputElement.addAttribute(attribute); } while (true) { String childName = getChildNameSuggestion(inputElement); if (childName.length() == 0) { break; - } else { - InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ - inputElement.addChild(childElement); - feelingLucky(childElement); } + InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ + inputElement.addChild(childElement); + feelingLucky(childElement); } } @@ -471,16 +471,16 @@ public class CustomXmlParserInputWizardPage extends WizardPage { CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement; if (def.rootInputElement != null) { return new Object[] { def.rootInputElement }; - } else { - return new Object[0]; } + return new Object[0]; } @Override public Object[] getChildren(Object parentElement) { InputElement inputElement = (InputElement) parentElement; - if (inputElement.childElements == null) + if (inputElement.childElements == null) { return new InputElement[0]; + } return inputElement.childElements.toArray(); } @@ -562,7 +562,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.DialogPage#dispose() */ @Override @@ -599,7 +599,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) */ @Override @@ -908,8 +908,8 @@ public class CustomXmlParserInputWizardPage extends WizardPage { tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY); - tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomXmlTraceDefinition.TAG_TIMESTAMP, - CustomXmlTraceDefinition.TAG_MESSAGE, CustomXmlTraceDefinition.TAG_OTHER }); + tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP, + CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER }); tagCombo.setVisibleItemCount(tagCombo.getItemCount()); tagCombo.addSelectionListener(new SelectionListener() { @Override @@ -920,33 +920,35 @@ public class CustomXmlParserInputWizardPage extends WizardPage { public void widgetSelected(SelectionEvent e) { tagText.removeModifyListener(updateListener); switch (tagCombo.getSelectionIndex()) { - case 0: // Ignore - tagLabel.setVisible(false); - tagText.setVisible(false); - actionCombo.setVisible(false); - break; - case 1: // Time Stamp - tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); - tagLabel.setVisible(true); - tagText.setVisible(true); - tagText.addModifyListener(updateListener); - actionCombo.setVisible(true); - break; - case 2: // Message - tagLabel.setVisible(false); - tagText.setVisible(false); - actionCombo.setVisible(true); - break; - case 3: // Other - tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName); - tagLabel.setVisible(true); - if (tagText.getText().trim().length() == 0) { - tagText.setText(elementNameText.getText().trim()); - } - tagText.setVisible(true); - tagText.addModifyListener(updateListener); - actionCombo.setVisible(true); - break; + case 0: // Ignore + tagLabel.setVisible(false); + tagText.setVisible(false); + actionCombo.setVisible(false); + break; + case 1: // Time Stamp + tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); + tagLabel.setVisible(true); + tagText.setVisible(true); + tagText.addModifyListener(updateListener); + actionCombo.setVisible(true); + break; + case 2: // Message + tagLabel.setVisible(false); + tagText.setVisible(false); + actionCombo.setVisible(true); + break; + case 3: // Other + tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName); + tagLabel.setVisible(true); + if (tagText.getText().trim().length() == 0) { + tagText.setText(elementNameText.getText().trim()); + } + tagText.setVisible(true); + tagText.addModifyListener(updateListener); + actionCombo.setVisible(true); + break; + default: + break; } tagComposite.layout(); validate(); @@ -973,12 +975,12 @@ public class CustomXmlParserInputWizardPage extends WizardPage { tagLabel.setVisible(false); tagText.setVisible(false); actionCombo.setVisible(false); - } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { tagCombo.select(1); tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); tagText.setText(inputElement.inputFormat); tagText.addModifyListener(updateListener); - } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) { + } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) { tagCombo.select(2); tagLabel.setVisible(false); tagText.setVisible(false); @@ -1016,13 +1018,13 @@ public class CustomXmlParserInputWizardPage extends WizardPage { // log entry } } - if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) { + if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) { String value = previewText.getText().trim(); if (value.length() != 0) { - if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) { + if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) { timeStampValue = value; timeStampFormat = tagText.getText().trim(); - } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) { + } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) { if (timeStampValue != null) { timeStampValue += value; timeStampFormat += tagText.getText().trim(); @@ -1030,7 +1032,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { timeStampValue = value; timeStampFormat = tagText.getText().trim(); } - } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { + } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { if (timeStampValue != null) { timeStampValue += " | " + value; //$NON-NLS-1$ timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$ @@ -1048,11 +1050,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage { String value = element.getAttribute(attribute.attributeNameText.getText().trim()); if (value.length() != 0) { attribute.previewText.setText(value); - if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) { - if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) { + if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) { + if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) { timeStampValue = value; timeStampFormat = attribute.tagText.getText().trim(); - } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) { + } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) { if (timeStampValue != null) { timeStampValue += value; timeStampFormat += attribute.tagText.getText().trim(); @@ -1060,7 +1062,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { timeStampValue = value; timeStampFormat = attribute.tagText.getText().trim(); } - } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { + } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) { if (timeStampValue != null) { timeStampValue += " | " + value; //$NON-NLS-1$ timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$ @@ -1146,11 +1148,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage { inputElement.elementName = elementNameText.getText().trim(); if (inputElement.parentElement != null) { inputElement.logEntry = logEntryButton.getSelection(); - if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) { + if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) { inputElement.inputName = tagText.getText().trim(); } else { inputElement.inputName = tagCombo.getText(); - if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) { inputElement.inputFormat = tagText.getText().trim(); } } @@ -1161,11 +1163,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage { Attribute attribute = attributes.get(i); InputAttribute inputAttribute = new InputAttribute(); inputAttribute.attributeName = attribute.attributeNameText.getText().trim(); - if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) { + if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) { inputAttribute.inputName = attribute.tagText.getText().trim(); } else { inputAttribute.inputName = attribute.tagCombo.getText(); - if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) { inputAttribute.inputFormat = attribute.tagText.getText().trim(); } } @@ -1261,8 +1263,8 @@ public class CustomXmlParserInputWizardPage extends WizardPage { tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY); - tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_TIMESTAMP, CustomXmlTraceDefinition.TAG_MESSAGE, - CustomXmlTraceDefinition.TAG_OTHER }); + tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE, + CustomTraceDefinition.TAG_OTHER }); tagCombo.select(2); // Other tagCombo.addSelectionListener(new SelectionListener() { @Override @@ -1273,25 +1275,27 @@ public class CustomXmlParserInputWizardPage extends WizardPage { public void widgetSelected(SelectionEvent e) { tagText.removeModifyListener(updateListener); switch (tagCombo.getSelectionIndex()) { - case 0: // Time Stamp - tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); - tagLabel.setVisible(true); - tagText.setVisible(true); - tagText.addModifyListener(updateListener); - break; - case 1: // Message - tagLabel.setVisible(false); - tagText.setVisible(false); - break; - case 2: // Other - tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName); - tagLabel.setVisible(true); - if (tagText.getText().trim().length() == 0) { - tagText.setText(attributeNameText.getText().trim()); - } - tagText.setVisible(true); - tagText.addModifyListener(updateListener); - break; + case 0: // Time Stamp + tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); + tagLabel.setVisible(true); + tagText.setVisible(true); + tagText.addModifyListener(updateListener); + break; + case 1: // Message + tagLabel.setVisible(false); + tagText.setVisible(false); + break; + case 2: // Other + tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName); + tagLabel.setVisible(true); + if (tagText.getText().trim().length() == 0) { + tagText.setText(attributeNameText.getText().trim()); + } + tagText.setVisible(true); + tagText.addModifyListener(updateListener); + break; + default: + break; } tagComposite.layout(); validate(); @@ -1314,12 +1318,12 @@ public class CustomXmlParserInputWizardPage extends WizardPage { actionCombo.select(inputAttribute.inputAction); actionCombo.addSelectionListener(updateListener); - if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { tagCombo.select(0); tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format); tagText.setText(inputAttribute.inputFormat); tagText.addModifyListener(updateListener); - } else if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) { + } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) { tagCombo.select(1); tagLabel.setVisible(false); tagText.setVisible(false); @@ -1507,48 +1511,56 @@ public class CustomXmlParserInputWizardPage extends WizardPage { public StringBuffer validateElement(InputElement inputElement) { StringBuffer errors = new StringBuffer(); ElementNode elementNode = null; - if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) + if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) { elementNode = selectedElement; + } if (inputElement == definition.rootInputElement) { if (inputElement.elementName.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError); - if (elementNode != null) + if (elementNode != null) { elementNode.elementNameText.setBackground(COLOR_LIGHT_RED); + } } else { - if (elementNode != null) + if (elementNode != null) { elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND); + } } } if (inputElement != definition.rootInputElement) { if (inputElement.logEntry) { logEntryFound = true; } - if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { timeStampFound = true; if (inputElement.inputFormat.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.tagText.setBackground(COLOR_LIGHT_RED); + } } else { try { new SimpleDateFormat(inputElement.inputFormat); - if (elementNode != null) + if (elementNode != null) { elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } catch (IllegalArgumentException e) { errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.tagText.setBackground(COLOR_LIGHT_RED); + } } } } else if (inputElement.inputName.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError); - if (elementNode != null) + if (elementNode != null) { elementNode.tagText.setBackground(COLOR_LIGHT_RED); + } } else { - if (elementNode != null) + if (elementNode != null) { elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } } if (inputElement.attributes != null) { @@ -1572,62 +1584,73 @@ public class CustomXmlParserInputWizardPage extends WizardPage { if (attribute.attributeName.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED); + } } else if (duplicate) { errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED); + } } - if (attribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) { + if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) { timeStampFound = true; if (attribute.inputFormat.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED); + } } else { try { new SimpleDateFormat(attribute.inputFormat); - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } catch (IllegalArgumentException e) { errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED); + } } } } else if (attribute.inputName.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED); + } } else { - if (elementNode != null) + if (elementNode != null) { elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND); + } } } } if (inputElement.childElements != null) { for (InputElement child : inputElement.childElements) { ElementNode childElementNode = null; - if (selectedElement != null && selectedElement.inputElement.equals(child)) + if (selectedElement != null && selectedElement.inputElement.equals(child)) { childElementNode = selectedElement; - if (childElementNode != null) + } + if (childElementNode != null) { childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND); + } } for (int i = 0; i < inputElement.childElements.size(); i++) { InputElement child = inputElement.childElements.get(i); ElementNode childElementNode = null; - if (selectedElement != null && selectedElement.inputElement.equals(child)) + if (selectedElement != null && selectedElement.inputElement.equals(child)) { childElementNode = selectedElement; + } if (child.elementName.length() == 0) { errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (childElementNode != null) + if (childElementNode != null) { childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED); + } } else { boolean duplicate = false; for (int j = i + 1; j < inputElement.childElements.size(); j++) { @@ -1635,17 +1658,20 @@ public class CustomXmlParserInputWizardPage extends WizardPage { if (otherChild.elementName.equals(child.elementName)) { duplicate = true; ElementNode otherChildElementNode = null; - if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) + if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) { otherChildElementNode = selectedElement; - if (otherChildElementNode != null) + } + if (otherChildElementNode != null) { otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED); + } } } if (duplicate) { errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (childElementNode != null) + if (childElementNode != null) { childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED); + } } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java index 245aa07e00..906ce4ba9d 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -71,7 +71,7 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler { // There should be only one item selected as per the plugin.xml Object element = sel.getFirstElement(); List resourcesList = new ArrayList(); - + if (element instanceof TmfExperimentElement) { TmfExperimentElement trace = (TmfExperimentElement) element; @@ -87,7 +87,7 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler { } SelectSupplementaryResourcesDialog dialog = new SelectSupplementaryResourcesDialog(window.getShell(), resourcesList.toArray(new IResource[resourcesList.size()])); - + if (dialog.open() != Window.OK) { return null; } @@ -105,9 +105,7 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler { 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$ } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteTraceSupplementaryFilesHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteTraceSupplementaryFilesHandler.java index b18b6dc14a..89bc5da5e7 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteTraceSupplementaryFilesHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteTraceSupplementaryFilesHandler.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -45,8 +45,9 @@ public class DeleteTraceSupplementaryFilesHandler extends AbstractHandler { // 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(); @@ -70,7 +71,7 @@ public class DeleteTraceSupplementaryFilesHandler extends AbstractHandler { // Delete the selected resources IResource[] resources = trace.getSupplementaryResources(); - + SelectSupplementaryResourcesDialog dialog = new SelectSupplementaryResourcesDialog(window.getShell(), resources); if (dialog.open() != Window.OK) { return null; @@ -83,9 +84,7 @@ public class DeleteTraceSupplementaryFilesHandler extends AbstractHandler { 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$ } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DropAdapterAssistant.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DropAdapterAssistant.java index 3eca229f02..41986434ad 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DropAdapterAssistant.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DropAdapterAssistant.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -190,18 +190,19 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { 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()) { @@ -211,15 +212,16 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { } 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 @@ -267,12 +269,12 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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()); @@ -284,12 +286,12 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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()) { @@ -311,17 +313,17 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { } 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; @@ -362,12 +364,12 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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())) { @@ -384,11 +386,11 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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(); @@ -414,15 +416,15 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { } 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 { @@ -443,7 +445,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { } } 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); @@ -459,7 +461,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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 { @@ -476,15 +478,17 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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); @@ -493,10 +497,10 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { /** * 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()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java index c86afae79c..0abc69dbe9 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java @@ -207,7 +207,7 @@ public class OpenExperimentHandler extends AbstractHandler { 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java index d5c26bd89a..0b4ac7f69b 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java @@ -74,15 +74,17 @@ public class OpenTraceHandler extends AbstractHandler { // 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 @@ -91,8 +93,9 @@ public class OpenTraceHandler extends AbstractHandler { 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 @@ -109,12 +112,14 @@ public class OpenTraceHandler extends AbstractHandler { // 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(); @@ -139,9 +144,9 @@ public class OpenTraceHandler extends AbstractHandler { 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()) { @@ -152,18 +157,21 @@ public class OpenTraceHandler extends AbstractHandler { 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(); @@ -175,13 +183,14 @@ public class OpenTraceHandler extends AbstractHandler { 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()); @@ -194,7 +203,7 @@ public class OpenTraceHandler extends AbstractHandler { 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RenameTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RenameTraceHandler.java index cfcafe0d97..17c16e8b61 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RenameTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RenameTraceHandler.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -52,7 +52,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation; public class RenameTraceHandler extends AbstractHandler { private TmfTraceElement fTrace = null; - + // ------------------------------------------------------------------------ // isEnabled // ------------------------------------------------------------------------ @@ -62,15 +62,17 @@ public class RenameTraceHandler extends AbstractHandler { // 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 @@ -96,8 +98,9 @@ public class RenameTraceHandler extends AbstractHandler { // 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(); @@ -107,8 +110,9 @@ public class RenameTraceHandler extends AbstractHandler { 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; @@ -122,8 +126,9 @@ public class RenameTraceHandler extends AbstractHandler { } } } - if (newTrace == null) + if (newTrace == null) { return null; + } List removeOps = new ArrayList(); TmfExperimentFolder experimentFolder = newTrace.getProject().getExperimentsFolder(); @@ -132,7 +137,7 @@ public class RenameTraceHandler extends AbstractHandler { 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 @@ -154,11 +159,12 @@ public class RenameTraceHandler extends AbstractHandler { } 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(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java index e8095698bc..7adb4c201d 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -129,11 +129,12 @@ public class SelectTraceTypeContributionItem extends CompoundContributionItem { return list.toArray(new IContributionItem[list.size()]); } - private void addContributionItem(List list, - String traceBundle, String traceTypeId, String traceIcon, String label, boolean selected, + private static void addContributionItem(List list, + String traceBundle, String traceTypeId, String traceIcon, + String label, boolean selected, MenuManager subMenu) { Map params; - + params = new HashMap(); params.put(BUNDLE_PARAMETER, traceBundle); params.put(TYPE_PARAMETER, traceTypeId); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java index b77f207e83..aea2f9b9b1 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java @@ -136,7 +136,9 @@ public class SelectTraceTypeHandler extends AbstractHandler { 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); @@ -172,13 +174,14 @@ public class SelectTraceTypeHandler extends AbstractHandler { 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 { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java index c747dc1bb9..a579938601 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java @@ -95,8 +95,9 @@ public class EventsViewEditor extends TmfEditor { 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; @@ -106,15 +107,17 @@ public class EventsViewEditor extends TmfEditor { } 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)) { @@ -129,8 +132,9 @@ public class EventsViewEditor extends TmfEditor { 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 { @@ -160,8 +164,9 @@ public class EventsViewEditor extends TmfEditor { // 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) { @@ -179,14 +184,15 @@ public class EventsViewEditor extends TmfEditor { 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) { @@ -199,6 +205,7 @@ public class EventsViewEditor extends TmfEditor { TmfSignalManager.dispatchSignal(new TmfExperimentSelectedSignal(this, experiment)); break; } + } } } catch (final InvalidRegistryObjectException e) { Activator.getDefault().logError("Error initializing EventsViewEditor", e); //$NON-NLS-1$ @@ -206,10 +213,13 @@ public class EventsViewEditor extends TmfEditor { 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); } @@ -253,14 +263,16 @@ public class EventsViewEditor extends TmfEditor { 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$ @@ -275,13 +287,14 @@ public class EventsViewEditor extends TmfEditor { @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); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index 5de7b94cca..c0567eab38 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -355,15 +355,20 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } /** - * Get the events table for an experiment. - * If all traces in the experiment are of the same type, - * use the extension point specified event table - * @param experiment the experiment - * @param parent the parent Composite - * @param cacheSize the event table cache size + * Get the events table for an experiment. If all traces in the experiment + * are of the same type, use the extension point specified event table + * + * @param experiment + * the experiment + * @param parent + * the parent Composite + * @param cacheSize + * the event table cache size * @return an events table of the appropriate type */ - private TmfEventsTable getExperimentEventsTable(final TmfExperiment experiment, final Composite parent, final int cacheSize) { + private static TmfEventsTable getExperimentEventsTable( + final TmfExperiment experiment, final Composite parent, + final int cacheSize) { TmfEventsTable eventsTable = null; String commonTraceType = null; try { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java index fa5f22bc11..cf0b65c8e8 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java @@ -368,7 +368,8 @@ public class TmfNavigatorContentProvider implements IPipelinedTreeContentProvide * @param children * the current children */ - private void customizeTmfElements(Object[] elements, Set children) { + private static void customizeTmfElements(Object[] elements, + Set children) { if (elements != null && children != null) { for (Object element : elements) { if (element instanceof ITmfProjectModelElement) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java index 6c837b731b..951b15de52 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java @@ -69,7 +69,7 @@ public class TmfNavigatorLabelProvider implements ICommonLabelProvider { 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java index e868b74580..69175d9dc6 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java @@ -43,7 +43,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; * Implementation of trace model element representing a trace. It provides methods to instantiate * ITmfTrace and ITmfEvent as well as editor ID from the trace type * extension definition. - * + * * @version 1.0 * @author Francois Chouinard */ @@ -124,7 +124,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi // Constructors // ------------------------------------------------------------------------ /** - * Constructor. + * Constructor. * Creates trace model element under the trace folder. * @param name The name of trace * @param trace The trace resource. @@ -134,7 +134,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi 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. @@ -162,7 +162,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi } /** - * 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() { @@ -174,8 +174,8 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi } /** - * Instantiate a ITmfTrace object based on the trace type and the corresponding extension. - * + * Instantiate a ITmfTrace object based on the trace type and the corresponding extension. + * * @return the ITmfTrace or null for an error */ public ITmfTrace instantiateTrace() { @@ -210,8 +210,8 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi } /** - * Instantiate a ITmfEvent object based on the trace type and the corresponding extension. - * + * Instantiate a ITmfEvent object based on the trace type and the corresponding extension. + * * @return the ITmfEvent or null for an error */ public ITmfEvent instantiateEvent() { @@ -513,7 +513,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java index f3416fe407..6e938e6a94 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -22,6 +22,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.Activator; 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. @@ -81,7 +82,7 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { } setWindowTitle(Messages.ImportTraceWizard_DialogTitle); - setDefaultPageImageDescriptor(Activator.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH)); + setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH)); setNeedsProgressMonitor(true); } @@ -95,7 +96,7 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { fTraceImportWizardPage = new ImportTraceWizardPage(fWorkbench, fSelection); addPage(fTraceImportWizardPage); } - + /* * (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#performFinish() diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java index c8380a13e1..219605786f 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java @@ -291,7 +291,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { }; } - 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) { @@ -454,7 +454,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { 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; @@ -463,7 +463,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { 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(); @@ -537,7 +537,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java index f4eefa0d5c..c7781b9b89 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -93,7 +93,7 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab /* * (non-Javadoc) - * + * * @see org.eclipse.jface.wizard.Wizard#addPages() */ @Override @@ -106,7 +106,7 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab /* * (non-Javadoc) - * + * * @see org.eclipse.jface.wizard.Wizard#performCancel() */ @Override @@ -116,7 +116,7 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab /* * (non-Javadoc) - * + * * @see org.eclipse.jface.wizard.Wizard#performFinish() */ @Override @@ -128,7 +128,8 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab 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(); @@ -137,35 +138,40 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab 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; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java index 64cdeff85a..046ab245c8 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -50,7 +50,7 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog; /** * Implementation of a dialog box to rename an experiment. - *

+ *

* @version 1.0 * @author Francois Chouinard */ @@ -62,8 +62,8 @@ public class RenameExperimentDialog extends SelectionStatusDialog { private final TmfExperimentElement fExperiment; private Text fNewExperimentName; - private IContainer fExperimentFolder; - private TmfProjectElement fProject; + private final IContainer fExperimentFolder; + private final TmfProjectElement fProject; // ------------------------------------------------------------------------ // Constructor @@ -143,7 +143,7 @@ public class RenameExperimentDialog extends SelectionStatusDialog { } private void validateNewExperimentName() { - + String name = fNewExperimentName.getText(); IWorkspace workspace = fExperimentFolder.getWorkspace(); IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); @@ -152,12 +152,12 @@ public class RenameExperimentDialog extends SelectionStatusDialog { 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)); @@ -187,7 +187,7 @@ public class RenameExperimentDialog extends SelectionStatusDialog { super.create(); getButton(IDialogConstants.OK_ID).setEnabled(false); } - + /* * (non-Javadoc) * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed() @@ -219,7 +219,7 @@ public class RenameExperimentDialog extends SelectionStatusDialog { 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()) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java index 4e70547fc1..6ab6c9502a 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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 *******************************************************************************/ @@ -47,7 +47,7 @@ import org.eclipse.swt.widgets.TableColumn; /** * Implementation of a wizard page for selecting trace for an experiment. *

- * + * * @version 1.0 * @author Francois Chouinard */ @@ -178,14 +178,15 @@ public class SelectTracesWizardPage extends WizardPage { /** * 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 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()) { @@ -209,7 +210,8 @@ public class SelectTracesWizardPage extends WizardPage { } } - 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); @@ -222,8 +224,9 @@ public class SelectTracesWizardPage extends WizardPage { Vector traces = new Vector(); 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index 63920847e0..8708ac187f 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -38,12 +38,12 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; +import org.eclipse.jface.window.Window; import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; @@ -1603,7 +1603,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, final InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.TmfEventsTable_AddBookmarkDialogTitle, Messages.TmfEventsTable_AddBookmarkDialogText, defaultMessage.toString(), null); - if (dialog.open() == Dialog.OK) { + if (dialog.open() == Window.OK) { final String message = dialog.getValue(); try { final IMarker bookmark = bookmarksFile.createMarker(IMarker.BOOKMARK); @@ -1879,7 +1879,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, * * @param e the exception */ - private void displayException(final Exception e) { + private static void displayException(final Exception e) { final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); mb.setText(e.getClass().getName()); mb.setMessage(e.getMessage()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java index e366e3be1d..59d936f448 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java @@ -20,9 +20,9 @@ import java.util.List; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.window.Window; import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.internal.tmf.ui.Messages; import org.eclipse.linuxtools.tmf.ui.views.TmfView; @@ -530,7 +530,7 @@ public class ColorsView extends TmfView { FilterDialog dialog = new FilterDialog(fShell); dialog.setFilter(colorSetting.getFilter()); dialog.open(); - if (dialog.getReturnCode() == Dialog.OK) { + if (dialog.getReturnCode() == Window.OK) { if (dialog.getFilter() != null) { colorSetting.setFilter(dialog.getFilter()); filterText.setText(dialog.getFilter().toString()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java index 48d11d1575..ec41e48077 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java @@ -255,7 +255,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi 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(); @@ -550,7 +550,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi } } - 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java index d5dcae7232..6ad857d434 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java @@ -48,7 +48,7 @@ import org.eclipse.swt.widgets.Composite; *

  • the window span (size of the time window of the smaller histogram). * * The histograms x-axis show their respective time range. - * + * * @version 1.0 * @author Francois Chouinard */ @@ -267,7 +267,7 @@ public class HistogramView extends TmfView { /** * 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() { @@ -370,10 +370,10 @@ public class HistogramView extends TmfView { } /** - * 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 @@ -423,7 +423,7 @@ public class HistogramView extends TmfView { /** * 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 diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java index 9f40de8aab..48e6ecb92a 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java @@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.Viewer; 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; @@ -545,7 +544,7 @@ public class TmfStatisticsView extends TmfView { modelIncomplete(experiment.getName()); } }; - ((TmfExperiment) experiment).sendRequest((ITmfDataRequest) fRequest); + ((TmfExperiment) experiment).sendRequest(fRequest); waitCursor(true); } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java index c62df8a373..79efa68d18 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java @@ -147,9 +147,8 @@ public abstract class AbsTmfStatisticsTree { 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)); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java index 62b8888e06..d0dc21e729 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java @@ -77,9 +77,8 @@ public class TmfBaseColumnDataProvider implements ITmfColumnDataProvider { 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 @@ -97,9 +96,8 @@ public class TmfBaseColumnDataProvider implements ITmfColumnDataProvider { 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 @@ -120,9 +118,8 @@ public class TmfBaseColumnDataProvider implements ITmfColumnDataProvider { if (parent == null) { return 0; - } else { - return (double) node.getValue().nbEvents / parent.getValue().nbEvents; } + return (double) node.getValue().nbEvents / parent.getValue().nbEvents; } })); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java index c27c6d2c39..b6559c5b3d 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java @@ -109,9 +109,8 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { if (nestedIterator != null) { if (nestedIterator.hasNext()) { return true; - } else { - nestedIterator = null; } + nestedIterator = null; } long time = (lastTime == -1) ? fStartTime : lastTime; int index = (fReferenceTime == -1) ? 0 : (int) ((time - fReferenceTime) >> fPower); @@ -123,10 +122,9 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { lastTime = event.getTime() + event.getDuration(); next = event; return true; - } else { - nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration); - return nestedIterator.hasNext(); } + nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration); + return nestedIterator.hasNext(); } } } @@ -189,7 +187,7 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { index = (int) ((time - fReferenceTime) >> fPower); fTraceEvents.setSize((int) index + 1); } - TimeChartEvent event = (TimeChartEvent) fTraceEvents.get((int) index); + TimeChartEvent event = fTraceEvents.get((int) index); if (event == null) { fTraceEvents.set((int) index, (TimeChartEvent) timeEvent); } else { @@ -220,7 +218,7 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { TimeChartEvent event = fTraceEvents.get(i); if (event != null) { index = (int) ((event.getTime() - fReferenceTime) >> fPower); - TimeChartEvent mergedEvent = (TimeChartEvent) fTraceEvents.get(index); + TimeChartEvent mergedEvent = fTraceEvents.get(index); if (mergedEvent == null) { fTraceEvents.set(index, event); } else { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java index 9efa9c1668..2af8116ebe 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java @@ -82,7 +82,7 @@ public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider { } } - private void drawBookmark(Rectangle r, GC gc) { + private static void drawBookmark(Rectangle r, GC gc) { gc.setForeground(BOOKMARK_OUTER_COLOR); gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2); gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2); @@ -95,7 +95,7 @@ public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider { gc.drawPoint(r.x + 1, r.y + 3); } - private void drawSearchMatch(Rectangle r, GC gc) { + private static void drawSearchMatch(Rectangle r, GC gc) { gc.setForeground(SEARCH_MATCH_COLOR); gc.drawPoint(r.x, r.y + r.height); gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java index 460aa416e3..69e2899bd1 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java @@ -226,9 +226,8 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, if (fRefreshBusy) { fRefreshPending = true; return; - } else { - fRefreshBusy = true; } + fRefreshBusy = true; } // Perform the refresh on the UI thread Display.getDefault().asyncExec(new Runnable() { @@ -255,9 +254,8 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, if (fRedrawBusy) { fRedrawPending = true; return; - } else { - fRedrawBusy = true; } + fRedrawBusy = true; } final boolean reset = resetTimeIntervals; // Perform the refresh on the UI thread diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java index fd6650b6a7..f2f93bf6d1 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -15,7 +15,6 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd; 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; @@ -34,7 +33,7 @@ import org.eclipse.swt.widgets.Shell; * below, a scale to visually locate the value in a time range (usually the minimum an maximum elapsed time in the whole * diagram) *

    - * + * * @version 1.0 * @author sveyrier */ @@ -77,7 +76,7 @@ public class DrawableToolTip implements PaintListener { */ private static int fScaleLength = 100; /** - * The text to display + * The text to display */ protected String fMessage; /** @@ -91,7 +90,7 @@ public class DrawableToolTip implements PaintListener { /** * Creates a drawable tool tip instance. - * + * * @param parent The parent composite. */ public DrawableToolTip(Composite parent) { @@ -120,7 +119,7 @@ public class DrawableToolTip implements PaintListener { // ------------------------------------------------------------------------ /** * Returns the message to display. - * + * * @return the message to display. */ public String getText() { @@ -129,7 +128,7 @@ public class DrawableToolTip implements PaintListener { /** * Returns teh current time to display. - * + * * @return the current time to display */ public String getAccessibleText() { @@ -138,7 +137,7 @@ public class DrawableToolTip implements PaintListener { /** * Returns the horizontal margin. - * + * * @return the horizontal margin. */ protected static int getHorizontalMargin() { @@ -147,7 +146,7 @@ public class DrawableToolTip implements PaintListener { /** * Sets the horizontal margin. - * + * * @param margin The margin to set. */ protected static void setHorizontalMargin(int margin) { @@ -156,7 +155,7 @@ public class DrawableToolTip implements PaintListener { /** * Returns the vertical margin. - * + * * @return the vertical margin. */ protected static int getVerticalMargin() { @@ -165,7 +164,7 @@ public class DrawableToolTip implements PaintListener { /** * Sets the vertical margin. - * + * * @param margin The margin to set. */ protected static void setVerticalMargin(int margin) { @@ -174,7 +173,7 @@ public class DrawableToolTip implements PaintListener { /** * Returns the text scale margin. - * + * * @return the text scale margin. */ protected static int getTextScaleMargin() { @@ -191,7 +190,7 @@ public class DrawableToolTip implements PaintListener { /** * Returns the scale length. - * + * * @return the scale length. */ protected static int getScaleLength() { @@ -200,17 +199,17 @@ public class DrawableToolTip implements PaintListener { /** * 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 @@ -237,10 +236,11 @@ public class DrawableToolTip implements PaintListener { * 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) @@ -258,13 +258,13 @@ public class DrawableToolTip implements PaintListener { 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)); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java index dd924fef6c..7297b17ad3 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -33,8 +33,8 @@ import org.eclipse.swt.widgets.Display; *

    * This class implements the graphical context for the sequence diagram widgets. *

    - * - * @version 1.0 + * + * @version 1.0 * @author sveyrier */ public class NGC implements IGC { @@ -42,7 +42,7 @@ public class NGC implements IGC { // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ - + /** * The graphical context. */ @@ -76,15 +76,15 @@ public class NGC implements IGC { */ 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; /** - * true to draw with focus else false. + * true to draw with focus else false. */ protected boolean fDrawWithFocus = false; @@ -92,15 +92,15 @@ public class NGC implements IGC { * 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. */ @@ -187,7 +187,7 @@ public class NGC implements IGC { /** * 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 @@ -203,7 +203,7 @@ public class NGC implements IGC { } else if (y < fVisibleY) { c |= 0x02; // bottom } - + if (x > xx) { c |= 0x04; // right } else if (x < fVisibleX) { @@ -218,11 +218,11 @@ public class NGC implements IGC { */ @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); @@ -288,7 +288,7 @@ public class NGC implements IGC { 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()) { @@ -321,7 +321,7 @@ public class NGC implements IGC { } fContext.drawRectangle(localX, localY, localWidth, localHeight); } - + /* * (non-Javadoc) * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawFocus(int, int, int, int) @@ -373,10 +373,11 @@ public class NGC implements IGC { i++; localPoint[i] = fView.contentsToViewY(Math.round(points[i] * fView.fZoomValue)); } - - if (validatePolygonHeight(localPoint) <= 0) + + if (validatePolygonHeight(localPoint) <= 0) { return; - + } + fContext.fillPolygon(localPoint); } @@ -393,7 +394,7 @@ public class NGC implements IGC { i++; localPoint[i] = fView.contentsToViewY(Math.round(points[i] * fView.fZoomValue)); } - + if (validatePolygonHeight(localPoint) <= 0) { return; } @@ -455,7 +456,7 @@ public class NGC implements IGC { 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); @@ -493,14 +494,14 @@ public class NGC implements IGC { 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; } /* @@ -511,7 +512,7 @@ public class NGC implements IGC { 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); @@ -549,7 +550,7 @@ public class NGC implements IGC { 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); @@ -653,7 +654,7 @@ public class NGC implements IGC { /** * 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. @@ -695,7 +696,7 @@ public class NGC implements IGC { if (tx.y > localHeight) { return; } - + // Adjust height and y if (y < -fVisibleScreenBounds) { localHeight = localHeight + y + fVisibleScreenBounds; @@ -706,7 +707,7 @@ public class NGC implements IGC { } 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 { @@ -738,7 +739,7 @@ public class NGC implements IGC { 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); @@ -776,7 +777,7 @@ public class NGC implements IGC { 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(); @@ -884,7 +885,7 @@ public class NGC implements IGC { /** * Returns the current font height. - * + * * @return the current font height. */ protected int getCurrentFontHeight() { @@ -929,7 +930,7 @@ public class NGC implements IGC { public float getZoom() { if (fView != null) { return fView.fZoomValue; - } + } return 1; } @@ -977,10 +978,10 @@ public class NGC implements IGC { public void setDrawTextWithFocusStyle(boolean focus) { fDrawWithFocus = focus; } - + /** * Returns the screen bounds. - * + * * @return the screen bounds. */ protected static int getVscreenBounds() { @@ -989,20 +990,20 @@ public class NGC implements IGC { /** * 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 */ @@ -1011,7 +1012,7 @@ public class NGC implements IGC { 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; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java index d3b6b0f533..082047942d 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java @@ -56,7 +56,6 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDCollapseP 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; @@ -982,9 +981,7 @@ public class SDView extends ViewPart { if (getSDWidget() != null) { return getSDWidget().getFrame(); } - else { - return null; - } + return null; } /** @@ -1003,10 +1000,9 @@ public class SDView extends ViewPart { if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){ loader.setViewer(this); return false; - } else { - loadBlank(); - return true; } + loadBlank(); + return true; } /** diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java index a834327a96..19d1a0c388 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java @@ -515,7 +515,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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); @@ -543,8 +543,8 @@ public class SDWidget extends ScrollView implements SelectionListener, public void removeSelection(List 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); @@ -555,8 +555,8 @@ public class SDWidget extends ScrollView implements SelectionListener, */ 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(); @@ -700,7 +700,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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(); @@ -984,16 +984,16 @@ public class SDWidget extends ScrollView implements SelectionListener, // 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) { @@ -1008,7 +1008,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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); @@ -1144,7 +1144,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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(); @@ -1178,9 +1178,8 @@ public class SDWidget extends ScrollView implements SelectionListener, for (int i = 0; i < child.length; i++) { if (child[i].isFocusControl()) { return true; - } else { - checkFocusOnChilds(child[i]); } + checkFocusOnChilds(child[i]); } } return false; @@ -1312,16 +1311,16 @@ public class SDWidget extends ScrollView implements SelectionListener, // 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) { @@ -1336,7 +1335,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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); @@ -1352,7 +1351,7 @@ public class SDWidget extends ScrollView implements SelectionListener, fFrame.draw(context); if (fDragAndDrop != null) { - Lifeline node = (Lifeline) fDragAndDrop; + Lifeline node = fDragAndDrop; boolean isSelected = fDragAndDrop.isSelected(); boolean hasFocus = fDragAndDrop.hasFocus(); node.setSelected(false); @@ -1505,9 +1504,8 @@ public class SDWidget extends ScrollView implements SelectionListener, for (int i = 0; i < child.length; i++) { if (child[i].isFocusControl()) { return true; - } else { - checkFocusOnChilds(child[i]); } + checkFocusOnChilds(child[i]); } return false; } @@ -1718,20 +1716,20 @@ public class SDWidget extends ScrollView implements SelectionListener, 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); } } @@ -1883,10 +1881,9 @@ public class SDWidget extends ScrollView implements SelectionListener, 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(); @@ -2012,7 +2009,7 @@ public class SDWidget extends ScrollView implements SelectionListener, 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(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java index 3c5c0e986c..4e13af903d 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java @@ -85,7 +85,7 @@ public class SDWidgetSelectionProvider implements ISelectionProvider { 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)); } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java index c629dfd880..79763f1df0 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java @@ -317,7 +317,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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; @@ -332,7 +332,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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; @@ -347,9 +347,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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; @@ -364,9 +364,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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; @@ -392,8 +392,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { } 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(); @@ -493,9 +493,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { for (int i = 0; i < child.length; i++) { if (child[i].isFocusControl()) { return true; - } else { - checkFocusOnChilds(child[i]); } + checkFocusOnChilds(child[i]); } } return false; @@ -511,9 +510,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { for (int i = 0; i < child.length; i++) { if (child[i].isFocusControl()) { return true; - } else { - checkFocusOnChilds(child[i]); } + checkFocusOnChilds(child[i]); } return false; } @@ -551,8 +549,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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(); @@ -719,7 +717,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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) { @@ -825,8 +823,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { } 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(); @@ -870,7 +868,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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); } } @@ -906,8 +904,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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(); @@ -1007,16 +1005,15 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { } } 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; } } } @@ -1032,8 +1029,8 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { 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(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java index 02feebb873..beaf711cc4 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java @@ -299,11 +299,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange { 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; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java index 7e91071a47..79745a643f 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -26,13 +26,13 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; * representations (like asynchronous syncMessages) will be responsible to define the missing second eventOccurrence * property.
    *
    - * + * * @see Lifeline Lifeline for more event occurence details * @version 1.0 * @author sveyrier */ public abstract class BaseMessage extends GraphNode { - + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ @@ -45,7 +45,7 @@ public abstract class BaseMessage extends GraphNode { */ protected Lifeline fEndLifeline = null; /** - * The visiblitiy flag. + * The visiblitiy flag. */ protected boolean fVisible = true; @@ -79,20 +79,19 @@ public abstract class BaseMessage extends GraphNode { */ 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; @@ -127,7 +126,7 @@ public abstract class BaseMessage extends GraphNode { *
    * This method is typically used to faster execute none graphical operation like tooltip lookup.
    *
    - * + * * @param quick true to get an approximative value
    * false to get the exact x value
    * @return the graph node x coordinate @@ -172,7 +171,7 @@ public abstract class BaseMessage extends GraphNode { *
    * This method is typically used to faster execute none graphical operation like tooltip lookup.
    *
    - * + * * @param quick true to get an approximative value
    * false to get the exact x value * @return the graph node width @@ -238,7 +237,7 @@ public abstract class BaseMessage extends GraphNode { /** * Sets the visibility value. - * + * * @param value The visibility to set. */ public void setVisible(boolean value) { @@ -246,7 +245,7 @@ public abstract class BaseMessage extends GraphNode { } /** - * @return the visibility value. + * @return the visibility value. */ public boolean isVisible() { return fVisible; @@ -254,7 +253,7 @@ public abstract class BaseMessage extends GraphNode { /** * Set the lifeline from which this message has been sent. - * + * * @param lifeline - the message sender */ public void setStartLifeline(Lifeline lifeline) { @@ -263,7 +262,7 @@ public abstract class BaseMessage extends GraphNode { /** * Returns the lifeline from which this message has been sent. - * + * * @return the message sender */ public Lifeline getStartLifeline() { @@ -272,7 +271,7 @@ public abstract class BaseMessage extends GraphNode { /** * Returns the lifeline which has received this message. - * + * * @return the message receiver */ public Lifeline getEndLifeline() { @@ -281,7 +280,7 @@ public abstract class BaseMessage extends GraphNode { /** * Set the lifeline which has receive this message. - * + * * @param lifeline the message receiver */ public void setEndLifeline(Lifeline lifeline) { @@ -290,7 +289,7 @@ public abstract class BaseMessage extends GraphNode { /** * Set the event occurrence when this message occurs.
    - * + * * @param occurrence the event occurrence to assign to this message.
    * @see Lifeline Lifeline for more event occurence details */ @@ -300,7 +299,7 @@ public abstract class BaseMessage extends GraphNode { /** * Returns the event occurence when is message occurs.
    - * + * * @return the event occurrence assigned to this message.
    * @see Lifeline Lifeline for more event occurence details */ @@ -313,7 +312,7 @@ public abstract class BaseMessage extends GraphNode { * WARNING: this method will return a valid result only for execution occurrences which are visible in the View.
    * As consequence this method is only used for drawing purpose, especially to determine the exact message x * coordinate and width.
    - * + * * @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 @@ -345,7 +344,7 @@ public abstract class BaseMessage extends GraphNode { * WARNING: this method will return a valid result only for execution occurrences which are visible in the View.
    * As consequence this method is only used for drawing purpose, especially to determine the exact message x * coordinate and width.
    - * + * * @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 @@ -391,35 +390,35 @@ public abstract class BaseMessage extends GraphNode { * 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 @@ -428,7 +427,7 @@ public abstract class BaseMessage extends GraphNode { /** * Method to draw the message using the graphical context. - * + * * @param context A graphical context to draw in. */ protected void drawMessage(IGC context) { @@ -628,7 +627,7 @@ public abstract class BaseMessage extends GraphNode { } } } - + /* * (non-Javadoc) * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNodee#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) @@ -638,7 +637,7 @@ public abstract class BaseMessage extends GraphNode { if (!isVisible()) { return; } - + // Draw it selected?*/ if (isSelected()) { ISDPreferences pref = SDViewPref.getInstance(); @@ -670,10 +669,10 @@ public abstract class BaseMessage extends GraphNode { /** * 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 @@ -689,7 +688,7 @@ public abstract class BaseMessage extends GraphNode { /** * Method drawRot. - * + * * @param x A x coordinate * @param y A y coordinate * @param w A width diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java index 87ad83cc4d..55a4e243fb 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -21,11 +21,11 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; /** * 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 { @@ -42,7 +42,7 @@ public class BasicExecutionOccurrence extends GraphNode { // ------------------------------------------------------------------------ /** - * The corresponding lifeline. + * The corresponding lifeline. */ protected Lifeline fLifeline = null; @@ -119,7 +119,7 @@ public class BasicExecutionOccurrence extends GraphNode { 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; } @@ -137,14 +137,13 @@ public class BasicExecutionOccurrence extends GraphNode { 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) { @@ -153,7 +152,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Get the lifeline on which the execution occurrence appears. - * + * * @return - the parent lifeline */ public Lifeline getLifeline() { @@ -162,7 +161,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Get the execution start event occurrence - * + * * @return the start event occurrence to set */ @Override @@ -172,7 +171,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Set the execution end event occurrence - * + * * @return the end event occurrence to set */ @Override @@ -182,7 +181,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Set the execution start event occurrence - * + * * @param occurrence the start event occurrence to set */ public void setStartOccurrence(int occurrence) { @@ -191,7 +190,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Set the execution end event occurrence - * + * * @param occurrence the end event occurrence to set */ public void setEndOccurrence(int occurrence) { @@ -212,7 +211,7 @@ public class BasicExecutionOccurrence extends GraphNode { IColor tempStrokeColor = null; ISDPreferences pref = SDViewPref.getInstance(); - + // The execution occurrence is selected // if the owning lifeline is selected if (fLifeline.isSelected() || isSelected()) { @@ -242,7 +241,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Rewrite this method in your extension in order to support customized fill colors - * + * * @param context * @return IColor */ @@ -261,7 +260,7 @@ public class BasicExecutionOccurrence extends GraphNode { /** * Rewrite this method in your extension in order to support customized stroke colors - * + * * @param context * @return IColor */ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java index 3001373c0e..47ba4d0d54 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java @@ -201,9 +201,8 @@ public class BasicFrame extends GraphNode { 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; } /* @@ -243,7 +242,7 @@ public class BasicFrame extends GraphNode { 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 @@ -467,7 +466,7 @@ public class BasicFrame extends GraphNode { 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(); @@ -510,8 +509,8 @@ public class BasicFrame extends GraphNode { 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); } @@ -557,15 +556,15 @@ public class BasicFrame extends GraphNode { List timeArray = new ArrayList(); while (it.hasNext()) { String nodeType = it.next(); - List list = (List) fNodes.get(nodeType); + List 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)); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java index d63f62359c..1373c3af8d 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -23,11 +23,11 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; /** * 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 { @@ -35,7 +35,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi // 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; /** @@ -51,7 +51,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi */ protected IImage fEllipsesImage; /** - * The start time stamp. + * The start time stamp. */ protected ITmfTimestamp fStartTime; /** @@ -59,7 +59,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi */ 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; @@ -83,7 +83,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * 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. @@ -97,7 +97,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * 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. @@ -111,7 +111,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * Set the corresponding image. - * + * * @param image A image to set. */ public void setImage(IImage image) { @@ -120,7 +120,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * Set the top ellipses image. - * + * * @param image A image to set. */ public void setTopEllipsesImage(IImage image) { @@ -129,7 +129,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * Set the time when the execution occurrence starts. - * + * * @param time the time when the execution occurrence starts */ public void setStartTime(ITmfTimestamp time) { @@ -142,7 +142,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi /** * Set the time when the execution occurrence ends. - * + * * @param time the time when the execution occurrence ends */ public void setEndTime(ITmfTimestamp time) { @@ -216,9 +216,8 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi context.setBackground(tempFillColor); } return tempFillColor; - } else { - return super.setUnselectedFillColor(context); } + return super.setUnselectedFillColor(context); } /* @@ -231,8 +230,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]); context.setForeground(tempStrokeColor); return tempStrokeColor; - } else { - return super.setUnselectedStrokeColor(context); } + return super.setUnselectedStrokeColor(context); } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java index 2fbaa08468..dbe4cdd09b 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java @@ -81,7 +81,7 @@ public class Frame extends BasicFrame { if (!fHasChilden) { return null; } - return (List) fNodes.get(Lifeline.LIFELINE_TAG); + return fNodes.get(Lifeline.LIFELINE_TAG); } /** @@ -120,7 +120,7 @@ public class Frame extends BasicFrame { if (!fHasChilden) { return null; } - return (List) fNodes.get(SyncMessage.SYNC_MESS_TAG); + return fNodes.get(SyncMessage.SYNC_MESS_TAG); } /** @@ -158,7 +158,7 @@ public class Frame extends BasicFrame { if (!fHasChilden) { return null; } - return (List) fNodes.get(AsyncMessage.ASYNC_MESS_TAG); + return fNodes.get(AsyncMessage.ASYNC_MESS_TAG); } /** @@ -196,7 +196,7 @@ public class Frame extends BasicFrame { if (!fHasChilden) { return null; } - return (List) fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG); + return fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG); } /** @@ -234,7 +234,7 @@ public class Frame extends BasicFrame { if (!fHasChilden) { return null; } - return (List) fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG); + return fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG); } /** @@ -294,7 +294,7 @@ public class Frame extends BasicFrame { 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; } @@ -308,7 +308,7 @@ public class Frame extends BasicFrame { 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; } @@ -322,7 +322,7 @@ public class Frame extends BasicFrame { 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; } @@ -336,7 +336,7 @@ public class Frame extends BasicFrame { 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; } @@ -350,7 +350,7 @@ public class Frame extends BasicFrame { 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; } @@ -529,8 +529,8 @@ public class Frame extends BasicFrame { 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(); @@ -563,17 +563,17 @@ public class Frame extends BasicFrame { 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; } @@ -671,9 +671,9 @@ public class Frame extends BasicFrame { if (fIndexes.size() == 0) { return; } - int lifeLineDrawIndex = ((Integer) fIndexes.get(Lifeline.LIFELINE_TAG)).intValue(); - for (int i = lifeLineDrawIndex; i < ((List) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i = i + lifelineArryStep) { - Lifeline toDraw = (Lifeline) ((List) 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; } @@ -723,8 +723,8 @@ public class Frame extends BasicFrame { List timeArray = super.buildTimeArray(); fExecutionOccurrencesWithTime = null; if (getLifelines() != null) { - for (int i = 0; i < ((List) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i++) { - Lifeline lifeline = (Lifeline) ((List) 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 j = lifeline.getExecutions().iterator(); j.hasNext();) { GraphNode o = j.next(); @@ -782,7 +782,7 @@ public class Frame extends BasicFrame { 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)) { @@ -805,7 +805,7 @@ public class Frame extends BasicFrame { } } 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)) { @@ -842,7 +842,7 @@ public class Frame extends BasicFrame { 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)) { @@ -865,7 +865,7 @@ public class Frame extends BasicFrame { } } 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)) { @@ -917,9 +917,8 @@ public class Frame extends BasicFrame { 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) { @@ -939,10 +938,10 @@ public class Frame extends BasicFrame { 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) { @@ -969,10 +968,10 @@ public class Frame extends BasicFrame { 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) { @@ -998,7 +997,7 @@ public class Frame extends BasicFrame { 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; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java index 1ee3911e18..95ae7b3e7e 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java @@ -141,15 +141,15 @@ public abstract class GraphNode { } } - List fNodeList = (List) fForwardNodes.get(nodeToAdd.getArrayId()); + List fNodeList = fForwardNodes.get(nodeToAdd.getArrayId()); List bNodeList = null; if (fBackwardNodes != null) { - bNodeList = (List) 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 fcomp = nodeToAdd.getComparator(); Comparator bcomp = nodeToAdd.getBackComparator(); if ((fcomp != null) && (fcomp.compare(node, nodeToAdd) > 0)) { @@ -376,8 +376,8 @@ public abstract class GraphNode { GraphNode node = null; while (it.hasNext()) { Object nodeType = it.next(); - List list = (List) fNodes.get(nodeType); - int index = ((Integer) fIndexes.get(nodeType)).intValue(); + List list = fNodes.get(nodeType); + int index = fIndexes.get(nodeType).intValue(); node = getNodeFromListAt(x, y, list, index); if (toReturn == null) { toReturn = node; @@ -430,12 +430,12 @@ public abstract class GraphNode { Iterator it = fNodes.keySet().iterator(); while (it.hasNext()) { Object nodeType = it.next(); - List nodesList = (List) fNodes.get(nodeType); + List 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(); @@ -469,7 +469,7 @@ public abstract class GraphNode { 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; } @@ -517,12 +517,12 @@ public abstract class GraphNode { 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) fNodes.get(nodeType)).size() > 1)) { - if (((GraphNode) ((List) 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; } @@ -531,24 +531,24 @@ public abstract class GraphNode { } if ((direction == -1) && (fBackwardNodes.get(nodeType) != null)) { - GraphNode currentNode = (GraphNode) ((List) fNodes.get(nodeType)).get(drawIndex); - drawIndex = Arrays.binarySearch(((List) fBackwardNodes.get(nodeType)).toArray(new GraphNode[((List) fBackwardNodes.get(nodeType)).size()]), - ((List) fNodes.get(nodeType)).get(drawIndex), currentNode.getBackComparator()); - fNodes.put(nodeType, (List) 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) fBackwardNodes.get(nodeType)); + fNodes.put(nodeType, fBackwardNodes.get(nodeType)); } } GraphNode prev = null; - for (int i = drawIndex; i < ((List) 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) fNodes.get(nodeType)).get(i); + GraphNode currentNode = fNodes.get(nodeType).get(i); if (prev == null) { prev = currentNode; @@ -562,15 +562,15 @@ public abstract class GraphNode { sort = fBackwardSort; } - if (i < ((List) fNodes.get(nodeType)).size() - 1) { - GraphNode next = (GraphNode) ((List) 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) fNodes.get(nodeType)).get(i)).positiveDistanceToPoint(x, y)) { + if (fNodes.get(nodeType).get(i).positiveDistanceToPoint(x, y)) { break; } } else { @@ -594,10 +594,10 @@ public abstract class GraphNode { 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 list = (List) fNodes.get(nodeType); - List backList = (List) fBackwardNodes.get(nodeType); - GraphNode currentNode = (GraphNode) (backList.get(index)); + int index = fIndexes.get(nodeType).intValue(); + List list = fNodes.get(nodeType); + List 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) { @@ -607,8 +607,8 @@ public abstract class GraphNode { } } - for (int i = drawIndex; i < ((List) fNodes.get(nodeType)).size() && i >= 0; i++) { - GraphNode toDraw = (GraphNode) ((List) 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; @@ -643,10 +643,10 @@ public abstract class GraphNode { Iterator 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) fForwardNodes.get(nodeType)).toArray(new GraphNode[((List)fForwardNodes.get(nodeType)).size()]); - GraphNode node = (GraphNode) ((List) 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)); @@ -660,10 +660,10 @@ public abstract class GraphNode { Iterator 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) fBackwardNodes.get(nodeType)).toArray(new GraphNode[((List) fBackwardNodes.get(nodeType)).size()]); - GraphNode node = (GraphNode) ((List) 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)); @@ -687,10 +687,10 @@ public abstract class GraphNode { while (it3.hasNext()) { count = 0; Object nodeType = it3.next(); - GraphNode node = (GraphNode) ((List) 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) 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$ } @@ -721,13 +721,13 @@ public abstract class GraphNode { return 0; } - GraphNode node = (GraphNode) list.get(0); + GraphNode node = list.get(0); context.setFont(SDViewPref.getInstance().getFont(node.fPrefId)); Comparator 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); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java index db099e50d3..20a30043e1 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -20,7 +20,7 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; /** * Class to add a hot spot marker. - * + * * @version 1.0 * @author sveyrier */ @@ -52,7 +52,7 @@ public class HotSpot extends GraphNode { // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ - + /** * Default constructor */ @@ -66,7 +66,7 @@ public class HotSpot extends GraphNode { /** * Set the marker image. - * + * * @param img A image to set */ public void setImage(IImage img) { @@ -123,7 +123,7 @@ public class HotSpot extends GraphNode { /** * Set the lifeline on which the execution occurrence appears. - * + * * @param occ the parent lifeline */ public void setExecution(BasicExecutionOccurrence occ) { @@ -133,7 +133,7 @@ public class HotSpot extends GraphNode { /** * Get the lifeline on which the execution occurrence appears. - * + * * @return - the parent lifeline */ public BasicExecutionOccurrence getExecOcc() { @@ -141,8 +141,8 @@ public class HotSpot extends GraphNode { } /** - * Returns the occurrence number. - * + * Returns the occurrence number. + * * @return the occurrence number. */ public int getOccurrence() { @@ -151,7 +151,7 @@ public class HotSpot extends GraphNode { /** * Set the occurrence number. - * + * * @param occ A number to set. */ public void setOccurrence(int occ) { @@ -208,7 +208,7 @@ public class HotSpot extends GraphNode { 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; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java index 22c1f1aa82..7384e2165c 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -29,10 +29,10 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; * 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 { // ------------------------------------------------------------------------ @@ -120,7 +120,7 @@ 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[]) */ @@ -131,7 +131,7 @@ public class Lifeline extends GraphNode { /** * 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() { @@ -139,18 +139,15 @@ public class Lifeline extends GraphNode { 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.
    * Execution Occurrences are Y ordered in this array - * + * * @return the first visible Execution Occurrence */ public int getExecOccurrenceDrawIndex() { @@ -158,14 +155,14 @@ public class Lifeline extends GraphNode { 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) { @@ -180,7 +177,7 @@ public class Lifeline extends GraphNode { /** * Returns the frame which this lifeline is drawn - * + * * @return the Frame */ protected Frame getFrame() { @@ -189,7 +186,7 @@ public class Lifeline extends GraphNode { /** * Set the lifeline position index in the containing frame - * + * * @param index the lifeline X position */ protected void setIndex(int index) { @@ -198,7 +195,7 @@ public class Lifeline extends GraphNode { /** * Returns the lifeline position in de the containing frame - * + * * @return the X position */ public int getIndex() { @@ -210,7 +207,7 @@ public class Lifeline extends GraphNode { * 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) { @@ -222,7 +219,7 @@ public class Lifeline extends GraphNode { /** * Returns the last created event occurrence along the lifeline. - * + * * @return the current event occurrence */ public int getEventOccurrence() { @@ -231,7 +228,7 @@ public class Lifeline extends GraphNode { /** * Creates a new event occurrence along the lifeline. - * + * * @return the new created event occurrence */ public int getNewEventOccurrence() { @@ -242,7 +239,7 @@ public class Lifeline extends GraphNode { /** * Adds the execution occurrence given in parameter to the lifeline.
    * 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) { @@ -266,7 +263,7 @@ public class Lifeline extends GraphNode { /** * 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() { @@ -275,12 +272,12 @@ public class Lifeline extends GraphNode { /** * Returns the list of execution occurrence on this lifeline. - * + * * @return the execution occurrence list */ public List getExecutions() { if (fHasChilden) { - return (List) fNodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG); + return fNodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG); } return new ArrayList(); } @@ -299,10 +296,10 @@ public class Lifeline extends 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; } @@ -312,11 +309,11 @@ public class Lifeline extends GraphNode { 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; } } @@ -329,7 +326,7 @@ public class Lifeline extends GraphNode { /** * 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 @@ -347,8 +344,8 @@ public class Lifeline extends GraphNode { } /** - * Draws the name within the graphical context. - * + * Draws the name within the graphical context. + * * @param context The graphical context. */ protected void drawName(IGC context) { @@ -380,15 +377,15 @@ public class Lifeline extends GraphNode { /** * 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()) { @@ -474,7 +471,7 @@ public class Lifeline extends GraphNode { /** * 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 @@ -515,8 +512,9 @@ public class Lifeline extends GraphNode { */ @Override public boolean positiveDistanceToPoint(int x, int y) { - if (getX() > x - Metrics.swimmingLaneWidth()) + if (getX() > x - Metrics.swimmingLaneWidth()) { return true; + } return false; } @@ -538,7 +536,7 @@ public class Lifeline extends GraphNode { 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; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java index 621851d80f..a9ae4c181d 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java @@ -370,7 +370,7 @@ public class Criteria { StringBuffer ret = new StringBuffer(); String prefix = "["; //$NON-NLS-1$ for (Iterator 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$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java index e95a88aa3c..0bbb26c86b 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -20,10 +20,10 @@ import org.eclipse.jface.dialogs.DialogSettings; /** * A filter criteria is a criteria that can be activated or not, positive or not. - * + * * @version 1.0 * @author sveyrier - * + * */ public class FilterCriteria { @@ -35,11 +35,11 @@ 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$ @@ -47,7 +47,7 @@ public class FilterCriteria { // Attributes // ------------------------------------------------------------------------ /** - * The criteria reference. + * The criteria reference. */ protected Criteria fCriteria; /** @@ -68,9 +68,9 @@ public class FilterCriteria { // ------------------------------------------------------------------------ /** * Standard constructor - * + * * @param criteria A criteria reference - * @param isActive true if filter criteria is active else false + * @param isActive true if filter criteria is active else false * @param isPositive true for positive filter else false */ public FilterCriteria(Criteria criteria, boolean isActive, boolean isPositive) { @@ -79,9 +79,9 @@ public class FilterCriteria { /** * Constructor - * + * * @param criteria A criteria reference - * @param isActive true if filter criteria is active else false + * @param isActive true if filter criteria is active else false * @param isPositive true for positive filter else false * @param loaderClassName A loader class name */ @@ -140,7 +140,7 @@ public class FilterCriteria { /** * Returns the criteria reference. - * + * * @return the criteria reference */ public Criteria getCriteria() { @@ -149,7 +149,7 @@ public class FilterCriteria { /** * Sets the active flag. - * + * * @param isActive A active value. */ public void setActive(boolean isActive) { @@ -158,7 +158,7 @@ public class FilterCriteria { /** * Returns whether filter criteria is active or not. - * + * * @return whether filter criteria is active or not. */ public boolean isActive() { @@ -167,7 +167,7 @@ public class FilterCriteria { /** * Sets filter is for positive filtering or not. - * + * * @param isPositive The value to set. */ public void setPositive(boolean isPositive) { @@ -176,7 +176,7 @@ public class FilterCriteria { /** * Returns whether the filter si for positive filtering or not. - * + * * @return Returns the positive. */ public boolean isPositive() { @@ -185,7 +185,7 @@ public class FilterCriteria { /** * Sets the loader class name for this filter. - * + * * @param loaderClassName The loader class name to set */ public void setLoaderClassName(String loaderClassName) { @@ -194,7 +194,7 @@ public class FilterCriteria { /** * Returns the class loader name. - * + * * @return the class loader name. */ public String getLoaderClassName() { @@ -203,7 +203,7 @@ public class FilterCriteria { /** * 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 @@ -212,7 +212,7 @@ public class FilterCriteria { if (what != null && list != null) { try { for (Iterator i = list.iterator(); i.hasNext();) { - FilterCriteria fc = (FilterCriteria) i.next(); + FilterCriteria fc = i.next(); if (what.compareTo(fc)) { return fc; } @@ -226,7 +226,7 @@ public class FilterCriteria { /** * Compares this filter criteria with a given criteria. - * + * * @param to The filter criteria to compare. * @return usual comparison result (< 0, 0, > 0) */ @@ -244,7 +244,7 @@ public class FilterCriteria { /** * Saves current criteria attributes in the dialog settings. - * + * * @param settings The dialog settings */ public void save(DialogSettings settings) { @@ -262,7 +262,7 @@ public class FilterCriteria { /** * Loads the criteria with values of the dialog settings. - * + * * @param settings The dialog settings */ public void load(DialogSettings settings) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java index 376a3ce640..08bac589d6 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -39,7 +39,7 @@ import org.eclipse.ui.IViewPart; /** * This is the filters list dialog.
    * It is associated to an SDView and to a ISDFilterProvider.
    - * + * * @version 1.0 * @author sveyrier */ @@ -96,7 +96,7 @@ public class FilterListDialog extends Dialog { /** * Standard constructor - * + * * @param view The view reference * @param loader The filter provider implementation */ @@ -114,9 +114,9 @@ public class FilterListDialog extends Dialog { // ------------------------------------------------------------------------ /** * 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 */ @@ -127,7 +127,7 @@ public class FilterListDialog extends Dialog { /** * Replaces a selected criteria with a new criteria. - * + * * @param newCriteria A new criteria. */ protected void replaceSelectedCriteria(Criteria newCriteria) { @@ -195,7 +195,7 @@ public class FilterListDialog extends Dialog { }); if (fFilters != null) { for (Iterator i = fFilters.iterator(); i.hasNext();) { - FilterCriteria filterCriteria = (FilterCriteria) i.next(); + FilterCriteria filterCriteria = i.next(); addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName()); } } @@ -249,7 +249,7 @@ public class FilterListDialog extends Dialog { public void widgetDefaultSelected(SelectionEvent e) { // Nothing to do } - + /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) @@ -298,7 +298,7 @@ public class FilterListDialog extends Dialog { /** * 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 @@ -354,7 +354,7 @@ public class FilterListDialog extends Dialog { /** * Sets the list of filters. - * + * * @param filters The list of filters to set. */ public void setFilters(List filters) { @@ -363,7 +363,7 @@ public class FilterListDialog extends Dialog { /** * Returns the filters list after editing. - * + * * @return the filters list after editing */ public List getFilters() { @@ -376,14 +376,14 @@ public class FilterListDialog extends Dialog { protected void loadFiltersCriteria() { List globalFilters = getGlobalFilters(); for (Iterator 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 getGlobalFilters() { @@ -416,7 +416,7 @@ public class FilterListDialog extends Dialog { /** * Saves the filter criteria in the dialog settings. - * + * * @param globalFilters A list of filters to save. */ public static void saveFiltersCriteria(List globalFilters) { @@ -436,11 +436,11 @@ public class FilterListDialog extends Dialog { 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) { @@ -449,7 +449,7 @@ public class FilterListDialog extends Dialog { criteria.save(subSection); } } - + /** * Deactivates the saved global filters. */ @@ -490,9 +490,9 @@ public class FilterListDialog extends Dialog { /** * Constructor - * + * * @param parent The parent table - * @param isActive true if filter criteria is active else false + * @param isActive true if filter criteria is active else false * @param isPositive true for positive filter else false * @param loaderClassName The loader class name */ @@ -506,9 +506,9 @@ public class FilterListDialog extends Dialog { /** * Constructor - * + * * @param parent The parent table - * @param isActive true if filter criteria is active else false + * @param isActive true if filter criteria is active else false * @param isPositive true for positive filter else false * @param loaderClassName The loader class name * @param index The table item index @@ -522,7 +522,7 @@ public class FilterListDialog extends Dialog { /** * Sets the criteria. - * + * * @param criteria The criteria to set */ public void setCriteria(Criteria criteria) { @@ -540,7 +540,7 @@ public class FilterListDialog extends Dialog { /** * Returns whether positive filtering is active or not. - * + * * @return true for positive filter else false */ public boolean isPositive() { @@ -549,7 +549,7 @@ public class FilterListDialog extends Dialog { /** * Returns the loader class name. - * + * * @return the loader class name */ public String getLoaderClassName() { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java index 8eca2b1476..f0be212f64 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java @@ -255,7 +255,7 @@ public class SDPrintDialogUI { if (fSdView.getContentsHeight() > fSdView.getContentsHeight()) { return (int) (fSdView.getVisibleHeight() / (float) fTest / fSdView.fZoomValue); } - return (int) (super.getContentsHeight()); + return super.getContentsHeight(); } /* @@ -267,7 +267,7 @@ public class SDPrintDialogUI { if (fSdView.getVisibleWidth() > fSdView.getContentsWidth()) { return (int) (fSdView.getVisibleWidth() / (float) fTest / fSdView.fZoomValue); } - return (int) (super.getContentsWidth()); + return super.getContentsWidth(); } /* @@ -1139,20 +1139,20 @@ public class SDPrintDialogUI { 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; @@ -1160,7 +1160,7 @@ public class SDPrintDialogUI { 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) { @@ -1235,7 +1235,7 @@ public class SDPrintDialogUI { 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++; } @@ -1257,7 +1257,7 @@ public class SDPrintDialogUI { 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++; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java index 3c8d54e6d8..33bcaf760e 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java @@ -312,7 +312,7 @@ public class SearchFilterDialog extends Dialog { 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java index b132808834..f1cbcbffd8 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -23,17 +23,17 @@ import org.eclipse.swt.graphics.Image; /** * Default implementation of the IImage interface. - * + * * @version 1.0 * @author sveyrier - * + * */ public class ImageImpl implements IImage { // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ - + /** * The image reference */ @@ -44,7 +44,7 @@ public class ImageImpl implements IImage { // ------------------------------------------------------------------------ /** * Default constructor. - * + * * @param file A file name of image file. */ public ImageImpl(String file) { @@ -53,7 +53,7 @@ public class ImageImpl implements IImage { /** * Copy constructor - * + * * @param image THe image to copy */ public ImageImpl(Image image) { @@ -65,7 +65,7 @@ public class ImageImpl implements IImage { // ------------------------------------------------------------------------ /** * Returns Image object from file name. - * + * * @param name File name of image file * @return image object or null */ @@ -95,11 +95,11 @@ public class ImageImpl implements IImage { /** * Returns Image object from file name. - * + * * @param name File name of image file * @return image object or null */ - 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$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java index 3cb3bbfa79..a0613c6d5d 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java @@ -61,7 +61,7 @@ public class MoveSDUp extends Action { super(); setId(ID); setActionDefinitionId(ID); - fView = ((SDView) view); + fView = view; } // ------------------------------------------------------------------------ @@ -76,7 +76,7 @@ public class MoveSDUp extends Action { if (fView == null) { return; } - SDWidget viewer = ((SDView) fView).getSDWidget(); + SDWidget viewer = fView.getSDWidget(); if (viewer != null) { viewer.scrollBy(0, -viewer.getVisibleHeight()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java index 415cb44dfb..447a9c8bbe 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java @@ -132,7 +132,7 @@ public class LoadersManager { * @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(); } @@ -168,7 +168,7 @@ public class LoadersManager { 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); } @@ -237,7 +237,7 @@ public class LoadersManager { 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); } @@ -293,7 +293,7 @@ public class LoadersManager { * @return List of extension point configuration elements. */ private List getLoaderConfigurationElements(String viewId) { - List list = (List) fViewLoadersList.get(viewId); + List list = fViewLoadersList.get(viewId); if (list != null) { return list; } @@ -329,11 +329,12 @@ public class LoadersManager { * @param loaderElements The list of loader configuration elements * @return Extension point configuration element */ - private IConfigurationElement getLoaderConfigurationElement(String loaderClassName, List loaderElements) { + private static IConfigurationElement getLoaderConfigurationElement( + String loaderClassName, List loaderElements) { if (loaderClassName != null && loaderClassName.length() > 0) { // Find configuration element corresponding to the saved loader for (Iterator 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; } @@ -349,10 +350,11 @@ public class LoadersManager { * @param loaderElements The list of loader configuration elements * @return The default extension point configuration element. */ - private IConfigurationElement getDefaultLoader(List loaderElements) { + private static IConfigurationElement getDefaultLoader( + List loaderElements) { // Look for a default loader for (Iterator 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; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java index c78c6c59c6..d1aae15bc0 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java @@ -549,6 +549,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, return Messages.TmfUml2SDSyncLoader_CategoryLifeline; case ISDGraphNodeSupporter.SYNCMESSAGE: return Messages.TmfUml2SDSyncLoader_CategoryMessage; + default: + break; } return ""; //$NON-NLS-1$ } @@ -621,11 +623,10 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, 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(); } @@ -1314,7 +1315,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, } 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); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java index 83b79d41b7..19ef55dbef 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java @@ -246,7 +246,7 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener { @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); } @@ -258,7 +258,7 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener { @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); } @@ -270,7 +270,7 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener { @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); } @@ -305,8 +305,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener { */ @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(); } @@ -375,32 +375,32 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener { 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)); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java index 8ab0833e1f..ad4a84188f 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -37,7 +37,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage; /** * The Sequence Diagram preferences page implementation. - * + * * @version 1.0 * @author sveyrier */ @@ -50,7 +50,7 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference * Temporary preferences tag */ protected static final String TEMP_TAG = SDViewPref.TEMP_TAG; - + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ @@ -121,21 +121,21 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference 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(); @@ -150,7 +150,7 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference 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(); @@ -246,7 +246,7 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference performApply(); return true; } - + /* * (non-Javadoc) * @see org.eclipse.jface.preference.PreferencePage#performDefaults() @@ -335,7 +335,7 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference fTextColor.store(); String[] fontList = SDViewPref.getFontList(); - + // set the FontFieldEditor for the new selected graphNode font fFont.setPreferenceName(fontList[fClassItemList.getSelectionIndex()] + TEMP_TAG); fFont.load(); @@ -350,21 +350,21 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference 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); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java index 12e31d5b68..6dafc92f1a 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -20,19 +20,19 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage; 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.
    - * + * * 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, Serializable { - + // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ @@ -94,9 +94,8 @@ public class SortAsyncForBackward implements Comparator, Serializable } else { return -1; } - } else { - return 0; } + return 0; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java index 3a52094c19..4b788c262e 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java @@ -1,13 +1,13 @@ /********************************************************************** * 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 **********************************************************************/ @@ -22,12 +22,12 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode; /** * Asynchronous message comparator Compare two AsyncMessages only taking into account the event occurrence when their * appear.
    - * + * * 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, Serializable { @@ -91,9 +91,8 @@ public class SortAsyncMessageComparator implements Comparator, Serial } else { return -1; } - } else { - return 0; } + return 0; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java index 2747936308..72f9aa72bd 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java @@ -58,8 +58,7 @@ public class SortSyncMessageComparator implements Comparator, Seriali } else { return -1; } - } else { - return 0; } + return 0; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java index 860531d201..e9e9ac4f97 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java @@ -45,8 +45,8 @@ public class TimeEventComparator implements Comparator, Serializabl */ @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; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java index e6ff77486d..2ee72aee17 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java @@ -57,7 +57,7 @@ import org.eclipse.swt.widgets.Slider; * of visible lines in the StyledText control is set to fill the viewer display area. * An underlying data model is used to store a cache of event raw text line data. * The slider is ratio-based. - * + * * @version 1.0 * @author Patrick Tasse */ @@ -604,9 +604,8 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel private int getPreviousCaretOffset(int time) { if (fStoredCaretPosition[0].time == time) { return fStoredCaretPosition[1].caretOffset; - } else { - return fStoredCaretPosition[0].caretOffset; } + return fStoredCaretPosition[0].caretOffset; } private void updateHighlightedRank() { @@ -741,6 +740,8 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } break; } + default: + break; } //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents()))); if (e.detail != SWT.NONE) { @@ -917,6 +918,8 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } break; } + default: + break; } //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents()))); updateHighlightedRank(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java index 3cf854b64a..733d2800fa 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java @@ -128,27 +128,24 @@ public class TimeGraphCombo extends Composite { public Object[] getChildren(Object parentElement) { if (parentElement instanceof ITimeGraphEntry) { return contentProvider.getChildren(parentElement); - } else { - return new Object[0]; } + return new Object[0]; } @Override public Object getParent(Object element) { if (element instanceof ITimeGraphEntry) { return contentProvider.getParent(element); - } else { - return null; } + return null; } @Override public boolean hasChildren(Object element) { if (element instanceof ITimeGraphEntry) { return contentProvider.hasChildren(element); - } else { - return false; } + return false; } } @@ -177,9 +174,8 @@ public class TimeGraphCombo extends Composite { public boolean isLabelProperty(Object element, String property) { if (element instanceof ITimeGraphEntry) { return labelProvider.isLabelProperty(element, property); - } else { - return false; } + return false; } @Override @@ -191,18 +187,16 @@ public class TimeGraphCombo extends Composite { public Image getColumnImage(Object element, int columnIndex) { if (element instanceof ITimeGraphEntry) { return labelProvider.getColumnImage(element, columnIndex); - } else { - return null; } + return null; } @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof ITimeGraphEntry) { return labelProvider.getColumnText(element, columnIndex); - } else { - return null; } + return null; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java index b0f66740c0..d8061804b2 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java @@ -361,15 +361,14 @@ public class TimeGraphColorScheme { return getColor(BACKGROUND_NAME_SEL_NOFOCUS); } return getColor(BACKGROUND_NAME); - } else { - if (selected && focused) { - return getColor(BACKGROUND_SEL); - } - if (selected) { - return getColor(BACKGROUND_SEL_NOFOCUS); - } - return getColor(BACKGROUND); } + if (selected && focused) { + return getColor(BACKGROUND_SEL); + } + if (selected) { + return getColor(BACKGROUND_SEL_NOFOCUS); + } + return getColor(BACKGROUND); } /** diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java index 4d57e76514..dd11e43218 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java @@ -358,7 +358,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe boolean changed = false; if (idx < 0) { for (idx = 0; idx < _data._expandedItems.length; idx++) { - if (((Item) _data._expandedItems[idx])._selected) { + if (_data._expandedItems[idx]._selected) { break; } } @@ -577,17 +577,17 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe boolean changed = false; int lastSelection = -1; for (int i = 0; i < _data._expandedItems.length; i++) { - Item item = (Item) _data._expandedItems[i]; + Item item = _data._expandedItems[i]; if (item._selected) { lastSelection = i; if ((1 == n) && (i < _data._expandedItems.length - 1)) { item._selected = false; - item = (Item) _data._expandedItems[i + 1]; + item = _data._expandedItems[i + 1]; item._selected = true; changed = true; } else if ((-1 == n) && (i > 0)) { item._selected = false; - item = (Item) _data._expandedItems[i - 1]; + item = _data._expandedItems[i - 1]; item._selected = true; changed = true; } @@ -596,7 +596,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe } if (lastSelection < 0 && _data._expandedItems.length > 0) { - Item item = (Item) _data._expandedItems[0]; + Item item = _data._expandedItems[0]; item._selected = true; changed = true; } @@ -704,9 +704,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe } // to allow getting out of single point interval long newInterval; if (zoomIn) { - newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval()); + newInterval = Math.max(Math.round(interval * 0.8), _timeProvider.getMinTimeInterval()); } else { - newInterval = (long) Math.ceil((double) interval * 1.25); + newInterval = (long) Math.ceil(interval * 1.25); } long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval)); long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval); @@ -747,7 +747,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe long m = _timeProvider.getMinTimeInterval(); if ((time1 - time0) < m) { - time0 = selTime - (long) ((selTime - _time0) * m / _range); + time0 = selTime - (selTime - _time0) * m / _range; time1 = time0 + m; } @@ -798,7 +798,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe public int getSelectedIndex() { int idx = -1; for (int i = 0; i < _data._expandedItems.length; i++) { - Item item = (Item) _data._expandedItems[i]; + Item item = _data._expandedItems[i]; if (item._selected) { idx = i; break; @@ -810,7 +810,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe boolean toggle(int idx) { boolean toggled = false; if (idx >= 0 && idx < _data._expandedItems.length) { - Item item = (Item) _data._expandedItems[idx]; + Item item = _data._expandedItems[idx]; if (item._hasChildren) { item._expanded = !item._expanded; _data.updateExpandedItems(); @@ -853,9 +853,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe int nameWidth = _timeProvider.getNameSpace(); if (x > nameWidth - w && x < nameWidth + w) { return true; - } else { - return false; } + return false; } ITimeGraphEntry getEntry(Point pt) { @@ -890,13 +889,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe boolean changed = false; if (addSelection) { if (idx >= 0 && idx < _data._expandedItems.length) { - Item item = (Item) _data._expandedItems[idx]; + Item item = _data._expandedItems[idx]; changed = (item._selected == false); item._selected = true; } } else { for (int i = 0; i < _data._expandedItems.length; i++) { - Item item = (Item) _data._expandedItems[i]; + Item item = _data._expandedItems[i]; if ((i == idx && !item._selected) || (idx == -1 && item._selected)) { changed = true; } @@ -1049,7 +1048,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe long time1 = _timeProvider.getTime1(); long selectedTime = _timeProvider.getSelectedTime(); double pixelsPerNanoSec = (bounds.width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (bounds.width - nameSpace - RIGHT_MARGIN) / (time1 - time0); - int x = bounds.x + nameSpace + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec); + int x = bounds.x + nameSpace + (int) ((selectedTime - time0) * pixelsPerNanoSec); if (x >= nameSpace && x < bounds.x + bounds.width) { gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME)); gc.drawLine(x, bounds.y, x, bounds.y + bounds.height); @@ -1084,7 +1083,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe public void drawItems(Rectangle bounds, ITimeDataProvider timeProvider, Item[] items, int topIndex, int nameSpace, GC gc) { for (int i = topIndex; i < items.length; i++) { - Item item = (Item) items[i]; + Item item = items[i]; drawItem(item, bounds, timeProvider, i, nameSpace, gc); } fTimeGraphProvider.postDrawControl(bounds, gc); @@ -1911,7 +1910,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe if (idx < 0 || idx >= _expandedItems.length) { return; } - Item item = (Item) _expandedItems[idx]; + Item item = _expandedItems[idx]; if (item._hasChildren && !item._expanded) { item._expanded = true; updateExpandedItems(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java index 9abc7d2ff2..f25db8c5ef 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java @@ -18,7 +18,6 @@ package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution; import org.eclipse.swt.SWT; @@ -69,7 +68,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements private static final double LOG10_3 = Math.log10(3); private static final double LOG10_5 = Math.log10(5); - private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance(); + private static final Calendar GREGORIAN_CALENDAR = Calendar.getInstance(); private ITimeDataProvider _timeProvider; private int _dragState = 0; @@ -109,7 +108,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements } private void calcTimeDelta(int width, double pixelsPerNanoSec) { - double minDelta = (double) ((pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec); + double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec; long unit = 1; if (_timeProvider != null && _timeProvider.isCalendarFormat()) { if (minDelta > 6 * MONTH_IN_NS) { @@ -135,7 +134,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements return; } } - double log = Math.log10((double) minDelta / unit); + double log = Math.log10(minDelta / unit); long pow10 = (long) log; double remainder = log - pow10; if (remainder < LOG10_1) { @@ -266,7 +265,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements } // draw selected time - int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec); + int x = _rect0.x + (int) ((selectedTime - time0) * pixelsPerNanoSec); if (x >= _rect0.x && x < _rect0.x + _rect0.width) { gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME)); gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y @@ -620,7 +619,7 @@ class TimeDrawAbsYear extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = syearformat.format(new Date((long) (time / 1000000))); + String stime = syearformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @@ -635,7 +634,7 @@ class TimeDrawAbsMonth extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = smonthformat.format(new Date((long) (time / 1000000))); + String stime = smonthformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @@ -650,13 +649,13 @@ class TimeDrawAbsDay extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = sdayformat.format(new Date((long) (time / 1000000))); + String stime = sdayformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = sdayformatheader.format(new Date((long) (time / 1000000))); + String header = sdayformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -675,13 +674,13 @@ class TimeDrawAbsHrs extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = shrsformat.format(new Date((long) (time / 1000000))); + String stime = shrsformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = shrsformatheader.format(new Date((long) (time / 1000000))); + String header = shrsformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -700,13 +699,13 @@ class TimeDrawAbsMin extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = sminformat.format(new Date((long) (time / 1000000))); + String stime = sminformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = sminformatheader.format(new Date((long) (time / 1000000))); + String header = sminformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -726,13 +725,13 @@ class TimeDrawAbsSec extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = stimeformat.format(new Date((long) (time / 1000000))); + String stime = stimeformat.format(new Date(time / 1000000)); Utils.drawText(gc, stime, rect, true); } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = stimeformatheader.format(new Date((long) (time / 1000000))); + String header = stimeformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -751,7 +750,7 @@ class TimeDrawAbsMillisec extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = stimeformat.format(new Date((long) (time / 1000000))); + String stime = stimeformat.format(new Date(time / 1000000)); String ns = Utils.formatNs(time, Resolution.MILLISEC); Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$ @@ -759,7 +758,7 @@ class TimeDrawAbsMillisec extends TimeDraw { @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = stimeformatheader.format(new Date((long) (time / 1000000))); + String header = stimeformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -778,14 +777,14 @@ class TimeDrawAbsMicroSec extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = stimeformat.format(new Date((long) (time / 1000000))); + String stime = stimeformat.format(new Date(time / 1000000)); String micr = Utils.formatNs(time, Resolution.MICROSEC); Utils.drawText(gc, stime + "." + micr, rect, true); //$NON-NLS-1$ } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = stimeformatheader.format(new Date((long) (time / 1000000))); + String header = stimeformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); @@ -804,14 +803,14 @@ class TimeDrawAbsNanoSec extends TimeDraw { @Override public void draw(GC gc, long time, Rectangle rect) { - String stime = stimeformat.format(new Date((long) (time / 1000000))); + String stime = stimeformat.format(new Date(time / 1000000)); String ns = Utils.formatNs(time, Resolution.NANOSEC); Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$ } @Override public void drawAbsHeader(GC gc, long time, Rectangle rect) { - String header = stimeformatheader.format(new Date((long) (time / 1000000))); + String header = stimeformatheader.format(new Date(time / 1000000)); int headerwidth = gc.stringExtent(header).x + 4; if (headerwidth <= rect.width) { rect.x += (rect.width - headerwidth); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java index 0664b71956..97168988bb 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java @@ -160,7 +160,7 @@ public class TimeGraphTooltipHandler { Map eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent); if (eventAddOns != null) { for (Iterator iter = eventAddOns.keySet().iterator(); iter.hasNext();) { - String message = (String) iter.next(); + String message = iter.next(); addItem(message, eventAddOns.get(message)); } } @@ -169,15 +169,13 @@ public class TimeGraphTooltipHandler { long eventDuration = -1; long eventEndTime = -1; - if (threadEvent != null) { - eventStartTime = threadEvent.getTime(); - eventDuration = threadEvent.getDuration(); - if (eventDuration < 0 && nextEvent != null) { - eventEndTime = nextEvent.getTime(); - eventDuration = eventEndTime - eventStartTime; - } else { - eventEndTime = eventStartTime + eventDuration; - } + eventStartTime = threadEvent.getTime(); + eventDuration = threadEvent.getDuration(); + if (eventDuration < 0 && nextEvent != null) { + eventEndTime = nextEvent.getTime(); + eventDuration = eventEndTime - eventStartTime; + } else { + eventEndTime = eventStartTime + eventDuration; } // TODO: Check if we need "format" @@ -249,7 +247,7 @@ public class TimeGraphTooltipHandler { }); } - private void setHoverLocation(Shell shell, Point position) { + private static void setHoverLocation(Shell shell, Point position) { Rectangle displayBounds = shell.getDisplay().getBounds(); Rectangle shellBounds = shell.getBounds(); shellBounds.x = Math.max(Math.min(position.x, displayBounds.width diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java index f4895ca77f..7fb86d1a78 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java @@ -422,9 +422,8 @@ public class Utils { Iterator iterator = entry.getTimeEventsIterator(); if (iterator != null && iterator.hasNext()) { return iterator.next(); - } else { - return null; } + return null; } /** @@ -450,7 +449,7 @@ public class Utils { ITimeEvent prevEvent = null; while (iterator.hasNext()) { - nextEvent = (ITimeEvent) iterator.next(); + nextEvent = iterator.next(); long nextStartTime = nextEvent.getTime(); if (nextStartTime > time) { @@ -466,15 +465,13 @@ public class Utils { if (n == -1) { //previous if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) { return prevEvent; - } else { - return currEvent; } + return currEvent; } else if (n == 0) { //current if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) { return currEvent; - } else { - return null; } + return null; } else if (n == 1) { //next return nextEvent; } else if (n == 2) { //current or previous when in empty space @@ -540,7 +537,6 @@ public class Utils { * expects. * @return The mangled string of types */ - @SuppressWarnings("nls") static public String getTypeSignature(String type) { int dim = 0; for (int j = 0; j < type.length(); j++) { @@ -557,27 +553,27 @@ public class Utils { { sig.append("["); //$NON-NLS-1$ } - if (type.equals("boolean")) { - sig.append("Z"); //$NON-NLS-1$ - } else if (type.equals("byte")) { - sig.append("B"); //$NON-NLS-1$ - } else if (type.equals("char")) { - sig.append("C"); //$NON-NLS-1$ - } else if (type.equals("short")) { - sig.append("S"); //$NON-NLS-1$ - } else if (type.equals("int")) { - sig.append("I"); //$NON-NLS-1$ - } else if (type.equals("long")) { - sig.append("J"); //$NON-NLS-1$ - } else if (type.equals("float")) { - sig.append("F"); //$NON-NLS-1$ - } else if (type.equals("double")) { - sig.append("D"); //$NON-NLS-1$ - } else if (type.equals("void")) { - sig.append("V"); //$NON-NLS-1$ + if (type.equals("boolean")) { //$NON-NLS-1$ + sig.append('Z'); + } else if (type.equals("byte")) { //$NON-NLS-1$ + sig.append('B'); + } else if (type.equals("char")) { //$NON-NLS-1$ + sig.append('C'); + } else if (type.equals("short")) { //$NON-NLS-1$ + sig.append('S'); + } else if (type.equals("int")) { //$NON-NLS-1$ + sig.append('I'); + } else if (type.equals("long")) { //$NON-NLS-1$ + sig.append('J'); + } else if (type.equals("float")) { //$NON-NLS-1$ + sig.append('F'); + } else if (type.equals("double")) { //$NON-NLS-1$ + sig.append('D'); + } else if (type.equals("void")) { //$NON-NLS-1$ + sig.append('V'); } else { - sig.append("L").append(type.replace('.', '/')).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ + sig.append('L').append(type.replace('.', '/')).append(';'); } return sig.toString(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java index 47b8caafcb..61ebda9fbb 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java @@ -219,6 +219,8 @@ public class TmfVirtualTable extends Composite { case SWT.MouseWheel: shell.dispose (); break; + default: + break; } } }; @@ -251,35 +253,36 @@ public class TmfVirtualTable extends Composite { } 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; } } }; @@ -580,6 +583,8 @@ public class TmfVirtualTable extends Composite { refreshTable(); break; } + default: + break; } } }); @@ -763,9 +768,8 @@ public class TmfVirtualTable extends Composite { int index = fTable.indexOf(ti); if (index < fFrozenRowCount) { return index; - } else { - return (index - fFrozenRowCount) + getTopIndex(); } + return (index - fFrozenRowCount) + getTopIndex(); } /** @@ -935,9 +939,8 @@ public class TmfVirtualTable extends Composite { } if (index < fFrozenRowCount) { return index; - } else { - return (index - fFrozenRowCount) + getTopIndex(); } + return (index - fFrozenRowCount) + getTopIndex(); } /** -- 2.34.1