--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.model.trange;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.model.trange.messages"; //$NON-NLS-1$
+ public static String TimeRangeViewerProvider_BadRangeExtraInfo;
+ public static String TimeRangeViewerProvider_EndTime;
+ public static String TimeRangeViewerProvider_ProcessType;
+ public static String TimeRangeViewerProvider_StartTime;
+ public static String TimeRangeViewerProvider_UndefinedEndTime;
+ public static String TimeRangeViewerProvider_UndefinedStartTime;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
\r
public class TimeRangeViewerProvider extends TmfTimeAnalysisProvider {\r
- // ========================================================================\r
- // Data\r
- // =======================================================================\r
- Map<String, StateColor> procStateToColor = new HashMap<String, StateColor>(\r
- 16);\r
- Map<String, StateColor> bdevStateToColor = new HashMap<String, StateColor>(\r
- 4);\r
- Map<String, StateColor> softIrqStateToColor = new HashMap<String, StateColor>(\r
- 4);\r
- Map<String, StateColor> trapStateToColor = new HashMap<String, StateColor>(\r
- 4);\r
- Map<String, StateColor> irqStateToColor = new HashMap<String, StateColor>(4);\r
- Map<String, StateColor> cpuStateToColor = new HashMap<String, StateColor>(8);\r
-\r
- private final ParamsUpdater fviewParameters;\r
-\r
- // ========================================================================\r
- // Constructors\r
- // =======================================================================\r
- public TimeRangeViewerProvider(ParamsUpdater paramsUpdater) {\r
- // Fill the statemode to color maps\r
- fillProcessStateToColor();\r
- fillBdevStateToColor();\r
- fillSoftIRQStateToColor();\r
- fillTrapStateToColor();\r
- fillIrqStateToColor();\r
- fillCpuStateToColor();\r
- fviewParameters = paramsUpdater;\r
- }\r
-\r
- // ========================================================================\r
- // Methods\r
- // =======================================================================\r
- @Override\r
- public StateColor getEventColor(ITimeEvent event) {\r
- StateColor retColor = null;\r
- \r
- if (event instanceof TimeRangeEvent) {\r
- TimeRangeEvent devent = (TimeRangeEvent) event;\r
- String stateMode = devent.getStateMode();\r
- switch (devent.getEventType()) {\r
- case PROCESS_MODE:\r
- retColor = procStateToColor.get(stateMode);\r
- break;\r
- case BDEV_MODE:\r
- retColor = bdevStateToColor.get(stateMode);\r
- break;\r
- case IRQ_MODE:\r
- retColor = irqStateToColor.get(stateMode);\r
- break;\r
- case SOFT_IRQ_MODE:\r
- retColor = softIrqStateToColor.get(stateMode);\r
- break;\r
- case CPU_MODE:\r
- retColor = cpuStateToColor.get(stateMode);\r
- break;\r
- case TRAP_MODE:\r
- retColor = trapStateToColor.get(stateMode);\r
- break;\r
- }\r
- }\r
- \r
- if (retColor == null) {\r
- return StateColor.MAGENTA3;\r
- }\r
- return retColor;\r
- }\r
\r
- /* (non-Javadoc)\r
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.TsfTmAbstractImplProvider#getStateName(org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.TsfTmAbstractImplProvider.StateColor)\r
- */\r
- @Override\r
- public String getStateName(StateColor color) {\r
- //Override to multiple instances of the widget, the same color can have multiple meanings\r
- return "Not mapped"; //$NON-NLS-1$\r
+ // ------------------------------------------------------------------------\r
+ // Data\r
+ // ------------------------------------------------------------------------\r
+\r
+ Map<String, StateColor> procStateToColor = new HashMap<String, StateColor>(16);\r
+ Map<String, StateColor> bdevStateToColor = new HashMap<String, StateColor>(4);\r
+ Map<String, StateColor> softIrqStateToColor = new HashMap<String, StateColor>(4);\r
+ Map<String, StateColor> trapStateToColor = new HashMap<String, StateColor>(4);\r
+ Map<String, StateColor> irqStateToColor = new HashMap<String, StateColor>(4);\r
+ Map<String, StateColor> cpuStateToColor = new HashMap<String, StateColor>(8);\r
+\r
+ private final ParamsUpdater fviewParameters;\r
+\r
+ // ------------------------------------------------------------------------\r
+ // Constructors\r
+ // ------------------------------------------------------------------------\r
+\r
+ public TimeRangeViewerProvider(ParamsUpdater paramsUpdater) {\r
+ // Fill the state mode to color maps\r
+ fillProcessStateToColor();\r
+ fillBdevStateToColor();\r
+ fillSoftIRQStateToColor();\r
+ fillTrapStateToColor();\r
+ fillIrqStateToColor();\r
+ fillCpuStateToColor();\r
+ fviewParameters = paramsUpdater;\r
+ }\r
+\r
+ // ------------------------------------------------------------------------\r
+ // Methods\r
+ // ------------------------------------------------------------------------\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider#getEventColor(org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent)\r
+ */\r
+ @Override\r
+ public StateColor getEventColor(ITimeEvent event) {\r
+ StateColor retColor = null;\r
+\r
+ if (event instanceof TimeRangeEvent) {\r
+ TimeRangeEvent devent = (TimeRangeEvent) event;\r
+ String stateMode = devent.getStateMode();\r
+ switch (devent.getEventType()) {\r
+ case PROCESS_MODE:\r
+ retColor = procStateToColor.get(stateMode);\r
+ break;\r
+ case BDEV_MODE:\r
+ retColor = bdevStateToColor.get(stateMode);\r
+ break;\r
+ case IRQ_MODE:\r
+ retColor = irqStateToColor.get(stateMode);\r
+ break;\r
+ case SOFT_IRQ_MODE:\r
+ retColor = softIrqStateToColor.get(stateMode);\r
+ break;\r
+ case CPU_MODE:\r
+ retColor = cpuStateToColor.get(stateMode);\r
+ break;\r
+ case TRAP_MODE:\r
+ retColor = trapStateToColor.get(stateMode);\r
+ break;\r
+ }\r
}\r
\r
- @Override\r
- public Map<String, String> getEventHoverToolTipInfo(ITimeEvent revent) {\r
- Map<String, String> toolTipEventMsgs = new HashMap<String, String>();\r
- //if the selected resource is a Process, add the Process type to the tool tip\r
- if (revent instanceof TimeRangeComponent) {\r
- ITimeRangeComponent parent = ((TimeRangeComponent) revent)\r
- .getEventParent();\r
-\r
- // if the event start time is unknown, indicate it to the user\r
- String extraInfo = "\ni.e. outside of data time window";\r
- long eventStart = revent.getTime();\r
- if (eventStart < fviewParameters.getStartTime()) {\r
- toolTipEventMsgs.put("Start Time:", "Actual Event Start Time is undefined" + extraInfo);\r
- // avoid repeated details\r
- extraInfo = ""; //$NON-NLS-1$\r
- }\r
-\r
- long eventEnd = revent.getTime() + revent.getDuration();\r
- if (eventEnd > fviewParameters.getEndTime()) {\r
- toolTipEventMsgs.put("Stop Time:", "Actual Event Stop Time is undefined" + extraInfo);\r
- }\r
-\r
- if (parent != null && parent instanceof TimeRangeEventProcess) {\r
- TimeRangeEventProcess localProcess = (TimeRangeEventProcess) parent;\r
- toolTipEventMsgs.put("Process Type", localProcess.getProcessType());\r
- }\r
- }\r
-\r
- return toolTipEventMsgs;\r
+ if (retColor == null) {\r
+ return StateColor.MAGENTA3;\r
}\r
-\r
- @Override\r
- public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
- String name = null;\r
- //The relevant event name for the time range is the actual state mode\r
- if (event instanceof TimeRangeEvent) {\r
- TimeRangeEvent devent = (TimeRangeEvent) event;\r
- StringBuilder sb = new StringBuilder(devent.getStateMode());\r
- name = sb.toString();\r
- }\r
- \r
- if (name == null) {\r
- return "Unknown"; //$NON-NLS-1$\r
- }\r
- return name;\r
+ return retColor;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider#getStateName(org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider.StateColor)\r
+ */\r
+ @Override\r
+ public String getStateName(StateColor color) {\r
+ // Override to multiple instances of the widget, the same color can have\r
+ // multiple meanings\r
+ return "Not mapped"; //$NON-NLS-1$\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent)\r
+ */\r
+ @Override\r
+ public Map<String, String> getEventHoverToolTipInfo(ITimeEvent revent) {\r
+ Map<String, String> toolTipEventMsgs = new HashMap<String, String>();\r
+ // if the selected resource is a Process, add the Process type to the\r
+ // tool tip\r
+ if (revent instanceof TimeRangeComponent) {\r
+ ITimeRangeComponent parent = ((TimeRangeComponent) revent).getEventParent();\r
+\r
+ // if the event start time is unknown, indicate it to the user\r
+ String extraInfo = "\n" + Messages.TimeRangeViewerProvider_BadRangeExtraInfo; //$NON-NLS-1$\r
+ long eventStart = revent.getTime();\r
+ if (eventStart < fviewParameters.getStartTime()) {\r
+ toolTipEventMsgs.put(Messages.TimeRangeViewerProvider_StartTime, Messages.TimeRangeViewerProvider_UndefinedStartTime + extraInfo);\r
+ // avoid repeated details\r
+ extraInfo = ""; //$NON-NLS-1$\r
+ }\r
+\r
+ long eventEnd = revent.getTime() + revent.getDuration();\r
+ if (eventEnd > fviewParameters.getEndTime()) {\r
+ toolTipEventMsgs.put(Messages.TimeRangeViewerProvider_EndTime, Messages.TimeRangeViewerProvider_UndefinedEndTime + extraInfo);\r
+ }\r
+\r
+ if (parent != null && parent instanceof TimeRangeEventProcess) {\r
+ TimeRangeEventProcess localProcess = (TimeRangeEventProcess) parent;\r
+ toolTipEventMsgs.put(Messages.TimeRangeViewerProvider_ProcessType, localProcess.getProcessType());\r
+ }\r
}\r
\r
- @Override\r
- public String getTraceClassName(ITmfTimeAnalysisEntry trace) {\r
- String name = ""; //$NON-NLS-1$\r
- if (trace instanceof TimeRangeComposite) {\r
- TimeRangeComposite dTrace = (TimeRangeComposite) trace;\r
- name = dTrace.getClassName();\r
- }\r
- return name;\r
+ return toolTipEventMsgs;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider#getEventName(org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent, boolean, boolean)\r
+ */\r
+ @Override\r
+ public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
+ String name = null;\r
+ // The relevant event name for the time range is the actual state mode\r
+ if (event instanceof TimeRangeEvent) {\r
+ TimeRangeEvent devent = (TimeRangeEvent) event;\r
+ StringBuilder sb = new StringBuilder(devent.getStateMode());\r
+ name = sb.toString();\r
}\r
\r
- private void fillCpuStateToColor() {\r
- cpuStateToColor.put(CpuMode.LTTV_CPU_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- cpuStateToColor.put(CpuMode.LTTV_CPU_IDLE.getInName(), StateColor.GRAY);\r
- cpuStateToColor.put(CpuMode.LTTV_CPU_BUSY.getInName(),\r
- StateColor.LIGHT_BLUE);\r
- cpuStateToColor\r
- .put(CpuMode.LTTV_CPU_IRQ.getInName(), StateColor.ORANGE);\r
- cpuStateToColor.put(CpuMode.LTTV_CPU_SOFT_IRQ.getInName(),\r
- StateColor.PURPLE1);\r
- cpuStateToColor.put(CpuMode.LTTV_CPU_TRAP.getInName(), StateColor.GOLD);\r
+ if (name == null) {\r
+ return "Unknown"; //$NON-NLS-1$\r
}\r
-\r
- private void fillIrqStateToColor() {\r
- irqStateToColor.put(IRQMode.LTTV_IRQ_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- irqStateToColor.put(IRQMode.LTTV_IRQ_IDLE.getInName(), StateColor.GRAY);\r
- irqStateToColor.put(IRQMode.LTTV_IRQ_BUSY.getInName(),\r
- StateColor.ORANGE);\r
- }\r
-\r
- private void fillTrapStateToColor() {\r
- trapStateToColor.put(TrapMode.LTTV_TRAP_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- trapStateToColor.put(TrapMode.LTTV_TRAP_IDLE.getInName(),\r
- StateColor.BLACK);\r
- trapStateToColor.put(TrapMode.LTTV_TRAP_BUSY.getInName(),\r
- StateColor.GOLD);\r
- }\r
-\r
- private void fillSoftIRQStateToColor() {\r
- softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_IDLE.getInName(),\r
- StateColor.BLACK);\r
- softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_PENDING.getInName(),\r
- StateColor.PINK1);\r
- softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_BUSY.getInName(),\r
- StateColor.PURPLE1);\r
- }\r
-\r
- private void fillBdevStateToColor() {\r
- softIrqStateToColor.put(BdevMode.LTTV_BDEV_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- softIrqStateToColor.put(BdevMode.LTTV_BDEV_IDLE.getInName(),\r
- StateColor.BLACK);\r
- softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_READING.getInName(),\r
- StateColor.DARK_BLUE);\r
- softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_WRITING.getInName(),\r
- StateColor.RED);\r
- }\r
-\r
- private void fillProcessStateToColor() {\r
- // Process Status\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_UNNAMED.getInName(),\r
- StateColor.GRAY);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_DEAD.getInName(),\r
- StateColor.BLACK);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_FORK.getInName(),\r
- StateColor.DARK_GREEN);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_CPU.getInName(),\r
- StateColor.DARK_YELLOW);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_EXIT.getInName(),\r
- StateColor.MAGENTA3);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_ZOMBIE.getInName(),\r
- StateColor.PURPLE1);\r
- procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT.getInName(),\r
- StateColor.RED);\r
-\r
- // Execution Mode\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_MODE_UNKNOWN.getInName(),\r
- StateColor.BLACK);\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_USER_MODE.getInName(),\r
- StateColor.GREEN);\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_SYSCALL.getInName(),\r
- StateColor.DARK_BLUE);\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_TRAP.getInName(),\r
- StateColor.GOLD);\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_IRQ.getInName(),\r
- StateColor.ORANGE);\r
- procStateToColor.put(ExecutionMode.LTTV_STATE_SOFT_IRQ.getInName(),\r
- StateColor.PINK1);\r
+ return name;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider#getTraceClassName(org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry)\r
+ */\r
+ @Override\r
+ public String getTraceClassName(ITmfTimeAnalysisEntry trace) {\r
+ String name = ""; //$NON-NLS-1$\r
+ if (trace instanceof TimeRangeComposite) {\r
+ TimeRangeComposite dTrace = (TimeRangeComposite) trace;\r
+ name = dTrace.getClassName();\r
}\r
+ return name;\r
+ }\r
+\r
+ private void fillCpuStateToColor() {\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_UNKNOWN.getInName(), StateColor.BLACK);\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_IDLE.getInName(), StateColor.GRAY);\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_BUSY.getInName(), StateColor.LIGHT_BLUE);\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_IRQ.getInName(), StateColor.ORANGE);\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_SOFT_IRQ.getInName(), StateColor.PURPLE1);\r
+ cpuStateToColor.put(CpuMode.LTTV_CPU_TRAP.getInName(), StateColor.GOLD);\r
+ }\r
+\r
+ private void fillIrqStateToColor() {\r
+ irqStateToColor.put(IRQMode.LTTV_IRQ_UNKNOWN.getInName(), StateColor.BLACK);\r
+ irqStateToColor.put(IRQMode.LTTV_IRQ_IDLE.getInName(), StateColor.GRAY);\r
+ irqStateToColor.put(IRQMode.LTTV_IRQ_BUSY.getInName(), StateColor.ORANGE);\r
+ }\r
+\r
+ private void fillTrapStateToColor() {\r
+ trapStateToColor.put(TrapMode.LTTV_TRAP_UNKNOWN.getInName(), StateColor.BLACK);\r
+ trapStateToColor.put(TrapMode.LTTV_TRAP_IDLE.getInName(), StateColor.BLACK);\r
+ trapStateToColor.put(TrapMode.LTTV_TRAP_BUSY.getInName(), StateColor.GOLD);\r
+ }\r
+\r
+ private void fillSoftIRQStateToColor() {\r
+ softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_UNKNOWN.getInName(), StateColor.BLACK);\r
+ softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_IDLE.getInName(), StateColor.BLACK);\r
+ softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_PENDING.getInName(), StateColor.PINK1);\r
+ softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_BUSY.getInName(), StateColor.PURPLE1);\r
+ }\r
+\r
+ private void fillBdevStateToColor() {\r
+ softIrqStateToColor.put(BdevMode.LTTV_BDEV_UNKNOWN.getInName(), StateColor.BLACK);\r
+ softIrqStateToColor.put(BdevMode.LTTV_BDEV_IDLE.getInName(), StateColor.BLACK);\r
+ softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_READING.getInName(), StateColor.DARK_BLUE);\r
+ softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_WRITING.getInName(), StateColor.RED);\r
+ }\r
+\r
+ private void fillProcessStateToColor() {\r
+ // Process Status\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_UNNAMED.getInName(), StateColor.GRAY);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_DEAD.getInName(), StateColor.BLACK);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_FORK.getInName(), StateColor.DARK_GREEN);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_CPU.getInName(), StateColor.DARK_YELLOW);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_EXIT.getInName(), StateColor.MAGENTA3);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_ZOMBIE.getInName(), StateColor.PURPLE1);\r
+ procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT.getInName(), StateColor.RED);\r
+\r
+ // Execution Mode\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_MODE_UNKNOWN.getInName(), StateColor.BLACK);\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_USER_MODE.getInName(), StateColor.GREEN);\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_SYSCALL.getInName(), StateColor.DARK_BLUE);\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_TRAP.getInName(), StateColor.GOLD);\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_IRQ.getInName(), StateColor.ORANGE);\r
+ procStateToColor.put(ExecutionMode.LTTV_STATE_SOFT_IRQ.getInName(), StateColor.PINK1);\r
+ }\r
}\r
--- /dev/null
+TimeRangeViewerProvider_BadRangeExtraInfo=(i.e. outside of data time window)
+TimeRangeViewerProvider_EndTime=Stop Time
+TimeRangeViewerProvider_ProcessType=Process Type
+TimeRangeViewerProvider_StartTime=Start Time
+TimeRangeViewerProvider_UndefinedEndTime=Actual Event Stop Time is undefined
+TimeRangeViewerProvider_UndefinedStartTime=Actual Event Start Time is undefined
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DataTransferMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.project.dialogs.messages"; //$NON-NLS-1$
+ public static String ImportTraceWizard_LocationError;
+ public static String ImportTraceWizard_LocationErrorMsg1;
+ public static String ImportTraceWizard_LocationErrorMsg2;
+ public static String ImportTraceWizard_LocationErrorMsg3;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, DataTransferMessages.class);
+ }
+
+ private DataTransferMessages() {
+ }
+}
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
+
+import org.eclipse.osgi.util.NLS;
+
+public class IDEWorkbenchMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.project.dialogs.messages"; //$NON-NLS-1$
+ public static String NewExperimentDialog_DialogTitle;
+ public static String NewExperimentDialog_ExperimentLabel;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, IDEWorkbenchMessages.class);
+ }
+
+ private IDEWorkbenchMessages() {
+ }
+}
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
-import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
/**
* <b><u>ImportTraceWizard</u></b>
* <p>
- *
+ *
* TODO: Implement me. Please.
*/
@SuppressWarnings("restriction")
private IStructuredSelection fSelection;
private ImportTraceWizardPage fMainPage;
- /**
+ /**
*
*/
private final String IMPORT_WIZARD = "LTTngTraceImportWizard"; //$NON-NLS-1$
+
public ImportTraceWizard() {
- IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
- IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
- if (section == null) {
- section = workbenchSettings.addNewSection(IMPORT_WIZARD);
- }
-
- setDialogSettings(section);
+ IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
+ if (section == null) {
+ section = workbenchSettings.addNewSection(IMPORT_WIZARD);
+ }
+
+ setDialogSettings(section);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
- public void addPages() {
- super.addPages();
- fMainPage = new ImportTraceWizardPage(fWorkbench, fSelection);
- addPage(fMainPage);
+ public void addPages() {
+ super.addPages();
+ fMainPage = new ImportTraceWizardPage(fWorkbench, fSelection);
+ addPage(fMainPage);
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
*/
- @Override
- @SuppressWarnings("rawtypes")
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- fWorkbench = workbench;
- fSelection = selection;
-
- List selectedResources = IDE.computeSelectedResources(selection);
- if (!selectedResources.isEmpty()) {
- fSelection = new StructuredSelection(selectedResources);
- }
-
- setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
- setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png")); //$NON-NLS-1$
- setNeedsProgressMonitor(true);
+ @Override
+ @SuppressWarnings("rawtypes")
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ fWorkbench = workbench;
+ fSelection = selection;
+
+ List selectedResources = IDE.computeSelectedResources(selection);
+ if (!selectedResources.isEmpty()) {
+ fSelection = new StructuredSelection(selectedResources);
+ }
+
+ setWindowTitle(""); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
}
-
+
public ImportTraceWizardPage getMainPage() {
- return fMainPage;
- }
-
- /**
- * performFinish is called after the "finish" button is pressed in the import wizard
- * If we return "false", the wizard will not close.
- *
- * We perform here version check on the imported LTTng trace
- *
- */
+ return fMainPage;
+ }
+
+ /**
+ * performFinish is called after the "finish" button is pressed in the
+ * import wizard If we return "false", the wizard will not close.
+ *
+ * We perform here version check on the imported LTTng trace
+ *
+ */
@Override
- public boolean performFinish() {
-
- if ( fMainPage.getDestination().equals( fMainPage.getInitialContainerString() ) ) {
-
- String errMessage[] = { "Error : import destination is wrong." };
- errMessage = fMainPage.extendErrorMessage(errMessage, "");
- errMessage = fMainPage.extendErrorMessage(errMessage, "You cannot import your trace directly into the \"" + fMainPage.getInitialContainerString() + "\"");
- errMessage = fMainPage.extendErrorMessage(errMessage, "The trace has to be into a subdirectly, like \"" + fMainPage.getInitialContainerString() + "/MyTrace\"" );
- errMessage = fMainPage.extendErrorMessage(errMessage, "");
- errMessage = fMainPage.extendErrorMessage(errMessage, "Please change the destination folder.");
- fMainPage.showVersionErrorPopup(errMessage);
-
- return false;
- }
-
- return fMainPage.finish();
+ public boolean performFinish() {
+ if (fMainPage.getDestination().equals(fMainPage.getInitialContainerString())) {
+ String errMessage[] = { org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationError };
+ errMessage = fMainPage.extendErrorMessage(errMessage, ""); //$NON-NLS-1$
+ errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg1 + fMainPage.getInitialContainerString() + "\""); //$NON-NLS-1$
+ errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg2 + fMainPage.getInitialContainerString() + "/MyTrace\""); //$NON-NLS-1$
+ errMessage = fMainPage.extendErrorMessage(errMessage, ""); //$NON-NLS-1$
+ errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg3);
+ fMainPage.showVersionErrorPopup(errMessage);
+ return false;
+ }
+ return fMainPage.finish();
}
-
+
@Override
- public boolean canFinish() {
- return fMainPage.isSelectedElementsValidLttngTraces();
+ public boolean canFinish() {
+ return fMainPage.isSelectedElementsValidLttngTraces();
}
}
*/
@SuppressWarnings("restriction")
public class ImportTraceWizardPage extends WizardFileSystemResourceImportPage1 {
-
- private boolean isContainerSet = false;
- private String initialContainerString = ""; //$NON-NLS-1$
- private String selectedSourceDirectory = ""; //$NON-NLS-1$
-
- public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
- super(workbench, selection);
-
- LTTngProjectNode folder = (LTTngProjectNode) selection.getFirstElement();
- String path = folder.getTracesFolder().getFolder().getFullPath().toOSString();
-
- initialContainerString = path;
- setContainerFieldValue(path);
- }
-
-
- public String getTraceDirectory() {
- String tmpPath = ""; //$NON-NLS-1$
- if ( (getSourceDirectory() != null) && (getSourceDirectory().getName() != null) ) {
- tmpPath = this.getSourceDirectory().getName().toString();
- }
-
- return tmpPath;
- }
-
- public String getInitialContainerString() {
- return initialContainerString;
+
+ private boolean isContainerSet = false;
+ private String initialContainerString = ""; //$NON-NLS-1$
+ private String selectedSourceDirectory = ""; //$NON-NLS-1$
+
+ public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
+ super(workbench, selection);
+
+ LTTngProjectNode folder = (LTTngProjectNode) selection.getFirstElement();
+ String path = folder.getTracesFolder().getFolder().getFullPath().toOSString();
+
+ initialContainerString = path;
+ setContainerFieldValue(path);
+ }
+
+ public String getTraceDirectory() {
+ String tmpPath = ""; //$NON-NLS-1$
+ if ((getSourceDirectory() != null) && (getSourceDirectory().getName() != null)) {
+ tmpPath = this.getSourceDirectory().getName().toString();
}
-
- public String getTracepath() {
- String tmpPath = ""; //$NON-NLS-1$
- if ( (getSourceDirectory() != null) && (getSourceDirectory().getPath() != null) ) {
- tmpPath = this.getSourceDirectory().getPath().toString();
- }
-
- return tmpPath;
+
+ return tmpPath;
+ }
+
+ public String getInitialContainerString() {
+ return initialContainerString;
+ }
+
+ public String getTracepath() {
+ String tmpPath = ""; //$NON-NLS-1$
+ if ((getSourceDirectory() != null) && (getSourceDirectory().getPath() != null)) {
+ tmpPath = this.getSourceDirectory().getPath().toString();
}
-
- public String getDestination() {
- String returnPath = null;
-
- if ( getContainerFullPath() != null ) {
- returnPath = getContainerFullPath().toString();
- }
- return returnPath;
+
+ return tmpPath;
+ }
+
+ public String getDestination() {
+ String returnPath = null;
+
+ if (getContainerFullPath() != null) {
+ returnPath = getContainerFullPath().toString();
}
-
- public boolean isSelectedElementsValidLttngTraces() {
- boolean returnedValue = true;
-
- // We don't want to test until something is selected
- if ( selectionGroup.getCheckedElementCount() > 0 ) {
-
- // We don't want to revalidate each time, only want a new directory is selected
- if ( ! selectedSourceDirectory.equals(getSourceDirectory().getAbsolutePath().toString()) )
- {
- try {
- if ( isPathLttngTrace( getSourceDirectory().getAbsolutePath() ) == false ) {
- returnedValue = false;
- selectedSourceDirectory = ""; //$NON-NLS-1$
-
- String errMessage[] = { "Couldn't get LTTng version number for the path : " };
- errMessage = extendErrorMessage(errMessage, getSourceDirectory().getAbsolutePath() );
- errMessage = extendErrorMessage(errMessage, "");
- errMessage = extendErrorMessage(errMessage, "Verify that the directory is a valid LTTng trace directory.");
- errMessage = extendErrorMessage(errMessage, "Make sure the top directory is the trace itself and not any of its parent.");
- showVersionErrorPopup(errMessage);
- selectionGroup.setAllSelections(false);
- }
- else {
- selectedSourceDirectory = getSourceDirectory().getAbsolutePath();
-
- if ( isContainerSet == false ) {
- isContainerSet = true;
-
- if ( ! getDestination().toString().equals( getInitialContainerString() + "/" + getTraceDirectory() ) ) { //$NON-NLS-1$
- // *** HACK ***
- // Force a sane destination to avoid imported files to end up in the root of the "Traces/" directory
- setContainerFieldValue(getInitialContainerString() + "/" + getTraceDirectory()); //$NON-NLS-1$
- }
- }
- }
- }
- catch (LttngException e) {
- String[] errorMessages = e.toString().split("\n"); //$NON-NLS-1$
- String exceptionMessage[] = { "Version check failed for the path : ", this.getTracepath(), "", "Returned error was :" }; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
- for ( int pos=0; pos<errorMessages.length; pos++) {
- exceptionMessage = extendErrorMessage(exceptionMessage, errorMessages[pos]);
- }
-
- showVersionErrorPopup(exceptionMessage);
- selectionGroup.setAllSelections(false);
- returnedValue = false;
- }
+ return returnPath;
+ }
+
+ public boolean isSelectedElementsValidLttngTraces() {
+ boolean returnedValue = true;
+
+ // We don't want to test until something is selected
+ if (selectionGroup.getCheckedElementCount() > 0) {
+
+ // We don't want to revalidate each time, only want a new directory
+ // is selected
+ if (!selectedSourceDirectory.equals(getSourceDirectory().getAbsolutePath().toString())) {
+ try {
+ if (isPathLttngTrace(getSourceDirectory().getAbsolutePath()) == false) {
+ returnedValue = false;
+ selectedSourceDirectory = ""; //$NON-NLS-1$
+
+ String errMessage[] = { Messages.ImportTraceWizardPage_BadTraceVersion + getSourceDirectory().getAbsolutePath() };
+ errMessage = extendErrorMessage(errMessage, ""); //$NON-NLS-1$
+ errMessage = extendErrorMessage(errMessage, Messages.ImportTraceWizardPage_BadTraceVersionMsg1);
+ errMessage = extendErrorMessage(errMessage, Messages.ImportTraceWizardPage_BadTraceVersionMsg2);
+ showVersionErrorPopup(errMessage);
+ selectionGroup.setAllSelections(false);
+ } else {
+ selectedSourceDirectory = getSourceDirectory().getAbsolutePath();
+
+ if (isContainerSet == false) {
+ isContainerSet = true;
+
+ if (!getDestination().toString().equals(getInitialContainerString() + "/" + getTraceDirectory())) { //$NON-NLS-1$
+ // *** HACK ***
+ // Force a sane destination to avoid imported
+ // files to end up in the root of the "Traces/"
+ // directory
+ setContainerFieldValue(getInitialContainerString() + "/" + getTraceDirectory()); //$NON-NLS-1$
+ }
}
+ }
+ } catch (LttngException e) {
+ String[] errorMessages = e.toString().split("\n"); //$NON-NLS-1$
+ String exceptionMessage[] = { "Version check failed for the path : ", this.getTracepath(), "", "Returned error was :" }; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+
+ for (int pos = 0; pos < errorMessages.length; pos++) {
+ exceptionMessage = extendErrorMessage(exceptionMessage, errorMessages[pos]);
+ }
+
+ showVersionErrorPopup(exceptionMessage);
+ selectionGroup.setAllSelections(false);
+ returnedValue = false;
}
- isContainerSet = false;
-
- return returnedValue;
+ }
}
-
-
- public boolean isPathLttngTrace(String path) throws LttngException {
-
- boolean returnedValue = true;
-
- // Ask for a LttngTraceVersion for the given path
- LTTngTraceVersion traceVersion = new LTTngTraceVersion( path );
-
- // If this is not a valid LTTng trace
- if ( traceVersion.isValidLttngTrace() == false ) {
- returnedValue = false;
- }
-
- return returnedValue;
+ isContainerSet = false;
+
+ return returnedValue;
+ }
+
+ public boolean isPathLttngTrace(String path) throws LttngException {
+
+ boolean returnedValue = true;
+
+ // Ask for a LttngTraceVersion for the given path
+ LTTngTraceVersion traceVersion = new LTTngTraceVersion(path);
+
+ // If this is not a valid LTTng trace
+ if (traceVersion.isValidLttngTrace() == false) {
+ returnedValue = false;
}
-
-
- public String[] extendErrorMessage(String[] oldErrorMessage, String lineToAdd) {
- String tmSwapMessage[] = new String[oldErrorMessage.length + 1];
- for ( int pos = 0; pos<oldErrorMessage.length; pos++) {
- tmSwapMessage[pos] = oldErrorMessage[pos];
- }
- tmSwapMessage[oldErrorMessage.length] = lineToAdd;
-
- return tmSwapMessage;
+
+ return returnedValue;
+ }
+
+ public String[] extendErrorMessage(String[] oldErrorMessage, String lineToAdd) {
+ String tmSwapMessage[] = new String[oldErrorMessage.length + 1];
+ for (int pos = 0; pos < oldErrorMessage.length; pos++) {
+ tmSwapMessage[pos] = oldErrorMessage[pos];
}
-
-
+ tmSwapMessage[oldErrorMessage.length] = lineToAdd;
+
+ return tmSwapMessage;
+ }
+
/**
- * This function will show a version error popup that contain the given message.
+ * This function will show a version error popup that contain the given
+ * message.
*
*/
public void showVersionErrorPopup(String[] errMessages) {
- TraceErrorHandler errorDialog = new TraceErrorHandler(errMessages);
- try {
- errorDialog.execute(null);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ TraceErrorHandler errorDialog = new TraceErrorHandler(errMessages);
+ try {
+ errorDialog.execute(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
-
-// // *** HACK HACK AND HACK ***
-// // Everything below is a proof of concept on how we could tweak the import wizard to act according to our plan
-// // Uncomment everything below if you want to test it, but please, does not put any of this into production
-// @SuppressWarnings({ "unchecked", "rawtypes" })
-// @Override
-// public boolean finish() {
-// if (!ensureSourceIsValid()) {
-// return false;
-// }
-// saveWidgetValues();
-//
-// Iterator resourcesEnum = getSelectedResources().iterator();
-// List listRealFiles = new ArrayList();
-//
-// // ****
-// // HACK #1 :
-// // We need to convert everything into java.io.File because ImportOperation does NOT support FileSystemElement
-// while (resourcesEnum.hasNext()) {
-// FileSystemElement tmpFileElement = ((FileSystemElement)resourcesEnum.next());
-// java.io.File tmpRealFile = new java.io.File(tmpFileElement.getFileSystemObject().toString());
-//
-// listRealFiles.add(tmpRealFile);
-// }
-//
-// if (listRealFiles.size() > 0) {
-// // Call import ressources (code is below)
-// return importResources(listRealFiles);
-// }
-//
-// MessageDialog.openInformation(getContainer().getShell(),
-// DataTransferMessages.DataTransfer_information,
-// DataTransferMessages.FileImport_noneSelected);
-// return false;
-// }
-//
-// @Override
-// protected boolean importResources(List fileSystemObjects) {
-// // *** Explanation of the hackssss
-// // We want the import wizard to import everything in the form of :
-// // trace1/ -> tracefiles*
-// //
-// // However, the wizard is too dumb to do the following and will recreate the full architecture the user selected.
-// // So, depending what the user select, we could end up with something like :
-// // home/user/somewhere/trace1/ -> tracefiles*
-// //
-// // Since there is nothing to do with that, we need to change the "source" and the "to-import files" to reflect this.
-// // Basically, from the case above, the "source" should be changed to "trace1/" and "to-import files"
-// // should have the correct parent so the wizard can still find them
-// //
-// // Let's see how fun it is to do with mr. import wizard.
-//
-//
-// List listRealFilesShortPath = new ArrayList();
-// java.io.File newFullSource = getSourceDirectory();
-//
-// // We will loop for every "to-import full path files" we have and recreate "short path" files
-// // Mean, the current path of the file is currently something like :
-// // Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
-// // And we want something less dumb like :
-// // Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
-// for (int pos=0; pos<fileSystemObjects.size(); pos++) {
-// java.io.File oldFile = (java.io.File)fileSystemObjects.get(pos);
-// java.io.File newShortPathFile = oldFile;
-//
-// // ***
-// // HACK #2 : We need to ajust the source of the files!
-// // Our current source is probably like :
-// // (Source) Path : / (or null?)
-// // (Files) Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
-// // We want something like :
-// // (Source) Path : /home/billybob/mytraces/trace1/
-// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
-// //
-// // *BUG : However, we might need MULTIPLE sources since we could have MULTIPLE traces selected...
-// // THIS IS NOT HANDLED YET.
-//
-// // Make a new path like -> /home/billybob/mytraces/trace1/
-// String newParent = oldFile.getAbsolutePath().substring(0, oldFile.getAbsolutePath().lastIndexOf("/") );
-//
-// // Create a "short path file" with the good parent from it. This give :
-// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
-// newShortPathFile = new java.io.File(newParent, oldFile.getName() );
-//
-// // Create a new "full source" directory -> /home/billybob/mytraces/trace1/
-// newFullSource = new java.io.File( newParent );
-//
-// // Add our pretty file to the new List
-// listRealFilesShortPath.add(newShortPathFile);
-// }
-//
-// // ***
-// // HACK #3
-// // Now that we have everything, we need to AJUST THE DESTINATION
-// // To do so, we ajust the "ContainerValue" text field.
-// //
-// // Right now we have something like :
-// // Path -> /where/to/import/
-// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
-// // We want something like :
-// // Path -> /where/to/import/trace1/
-// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
-// //
-//
-// // We take the current text field and we add the "full source" name
-// // Note : the "name" is the last directory name so "trace1" is returned for a path like "/home/billybob/mytraces/trace1/"
-// setContainerFieldValue(getContainerFullPath() + "/" + newFullSource.getName());
-//
-// /*
-// System.out.println("\n\n" + getContainerFullPath());
-// System.out.println(newFullSource);
-// System.out.println(FileSystemStructureProvider.INSTANCE);
-// System.out.println(this.getContainer());
-// System.out.println(fileSystemObjects);
-// */
-//
-// // Finally import !!
-// ImportOperation operation = new ImportOperation(getContainerFullPath(), newFullSource, FileSystemStructureProvider.INSTANCE, this, listRealFilesShortPath);
-//
-// operation.setContext(getShell());
-// return executeImportOperation(operation);
-// }
-//
-// // This function test if the selected directory are LTTng traces
-// // This one is made to work with the madness above.
-// public boolean isSelectedElementsValidLttngTraces() {
-// boolean returnedValue = true;
-//
-// String errMessage[] = { "Couldn't get LTTng version number for the path : " };
-//
-// // We don't want to test until something is selected
-// if ( selectionGroup.getCheckedElementCount() > 0 ) {
-// try {
-// List<MinimizedFileSystemElement> selectionList = selectionGroup.getAllWhiteCheckedItems();
-// MinimizedFileSystemElement tmpSelectedElement = null;
-//
-// for ( int x=0; x<selectionList.size(); x++) {
-// tmpSelectedElement = selectionList.get(x);
-//
-// // *** VERIFY ***
-// // Not sure ALL directory are checked.
-// if ( tmpSelectedElement.isDirectory() ) {
-// String tmpPath = tmpSelectedElement.getFileSystemObject().toString();
-// if ( isPathLttngTrace( tmpPath ) == false ) {
-// returnedValue = false;
-// errMessage = extendErrorMessage(errMessage, tmpPath);
-// }
-// }
-// }
-//
-// if ( returnedValue == false ) {
-// errMessage = extendErrorMessage(errMessage, "");
-// errMessage = extendErrorMessage(errMessage, "Verify that the directory is a valid LTTng trace directory.");
-// showVersionErrorPopup(errMessage);
-// selectionGroup.setAllSelections(false);
-// }
-// }
-// catch (LttngException e) {
-// String exceptionMessage[] = { "Version check failed for the path : ", this.getTracepath(), "", "Returned error was :", e.toString() };
-// showVersionErrorPopup(exceptionMessage);
-// selectionGroup.setAllSelections(false);
-// returnedValue = false;
-// }
-// }
-//
-// return returnedValue;
-// }
-
+
+ // // *** HACK HACK AND HACK ***
+ // // Everything below is a proof of concept on how we could tweak the
+ // import wizard to act according to our plan
+ // // Uncomment everything below if you want to test it, but please, does
+ // not put any of this into production
+ // @SuppressWarnings({ "unchecked", "rawtypes" })
+ // @Override
+ // public boolean finish() {
+ // if (!ensureSourceIsValid()) {
+ // return false;
+ // }
+ // saveWidgetValues();
+ //
+ // Iterator resourcesEnum = getSelectedResources().iterator();
+ // List listRealFiles = new ArrayList();
+ //
+ // // ****
+ // // HACK #1 :
+ // // We need to convert everything into java.io.File because
+ // ImportOperation does NOT support FileSystemElement
+ // while (resourcesEnum.hasNext()) {
+ // FileSystemElement tmpFileElement =
+ // ((FileSystemElement)resourcesEnum.next());
+ // java.io.File tmpRealFile = new
+ // java.io.File(tmpFileElement.getFileSystemObject().toString());
+ //
+ // listRealFiles.add(tmpRealFile);
+ // }
+ //
+ // if (listRealFiles.size() > 0) {
+ // // Call import ressources (code is below)
+ // return importResources(listRealFiles);
+ // }
+ //
+ // MessageDialog.openInformation(getContainer().getShell(),
+ // DataTransferMessages.DataTransfer_information,
+ // DataTransferMessages.FileImport_noneSelected);
+ // return false;
+ // }
+ //
+ // @Override
+ // protected boolean importResources(List fileSystemObjects) {
+ // // *** Explanation of the hackssss
+ // // We want the import wizard to import everything in the form of :
+ // // trace1/ -> tracefiles*
+ // //
+ // // However, the wizard is too dumb to do the following and will recreate
+ // the full architecture the user selected.
+ // // So, depending what the user select, we could end up with something
+ // like :
+ // // home/user/somewhere/trace1/ -> tracefiles*
+ // //
+ // // Since there is nothing to do with that, we need to change the "source"
+ // and the "to-import files" to reflect this.
+ // // Basically, from the case above, the "source" should be changed to
+ // "trace1/" and "to-import files"
+ // // should have the correct parent so the wizard can still find them
+ // //
+ // // Let's see how fun it is to do with mr. import wizard.
+ //
+ //
+ // List listRealFilesShortPath = new ArrayList();
+ // java.io.File newFullSource = getSourceDirectory();
+ //
+ // // We will loop for every "to-import full path files" we have and
+ // recreate "short path" files
+ // // Mean, the current path of the file is currently something like :
+ // // Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
+ // // And we want something less dumb like :
+ // // Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
+ // for (int pos=0; pos<fileSystemObjects.size(); pos++) {
+ // java.io.File oldFile = (java.io.File)fileSystemObjects.get(pos);
+ // java.io.File newShortPathFile = oldFile;
+ //
+ // // ***
+ // // HACK #2 : We need to ajust the source of the files!
+ // // Our current source is probably like :
+ // // (Source) Path : / (or null?)
+ // // (Files) Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
+ // // We want something like :
+ // // (Source) Path : /home/billybob/mytraces/trace1/
+ // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
+ // //
+ // // *BUG : However, we might need MULTIPLE sources since we could have
+ // MULTIPLE traces selected...
+ // // THIS IS NOT HANDLED YET.
+ //
+ // // Make a new path like -> /home/billybob/mytraces/trace1/
+ // String newParent = oldFile.getAbsolutePath().substring(0,
+ // oldFile.getAbsolutePath().lastIndexOf("/") );
+ //
+ // // Create a "short path file" with the good parent from it. This give :
+ // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
+ // newShortPathFile = new java.io.File(newParent, oldFile.getName() );
+ //
+ // // Create a new "full source" directory ->
+ // /home/billybob/mytraces/trace1/
+ // newFullSource = new java.io.File( newParent );
+ //
+ // // Add our pretty file to the new List
+ // listRealFilesShortPath.add(newShortPathFile);
+ // }
+ //
+ // // ***
+ // // HACK #3
+ // // Now that we have everything, we need to AJUST THE DESTINATION
+ // // To do so, we ajust the "ContainerValue" text field.
+ // //
+ // // Right now we have something like :
+ // // Path -> /where/to/import/
+ // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
+ // // We want something like :
+ // // Path -> /where/to/import/trace1/
+ // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
+ // //
+ //
+ // // We take the current text field and we add the "full source" name
+ // // Note : the "name" is the last directory name so "trace1" is returned
+ // for a path like "/home/billybob/mytraces/trace1/"
+ // setContainerFieldValue(getContainerFullPath() + "/" +
+ // newFullSource.getName());
+ //
+ // /*
+ // System.out.println("\n\n" + getContainerFullPath());
+ // System.out.println(newFullSource);
+ // System.out.println(FileSystemStructureProvider.INSTANCE);
+ // System.out.println(this.getContainer());
+ // System.out.println(fileSystemObjects);
+ // */
+ //
+ // // Finally import !!
+ // ImportOperation operation = new ImportOperation(getContainerFullPath(),
+ // newFullSource, FileSystemStructureProvider.INSTANCE, this,
+ // listRealFilesShortPath);
+ //
+ // operation.setContext(getShell());
+ // return executeImportOperation(operation);
+ // }
+ //
+ // // This function test if the selected directory are LTTng traces
+ // // This one is made to work with the madness above.
+ // public boolean isSelectedElementsValidLttngTraces() {
+ // boolean returnedValue = true;
+ //
+ // String errMessage[] = {
+ // "Couldn't get LTTng version number for the path : " };
+ //
+ // // We don't want to test until something is selected
+ // if ( selectionGroup.getCheckedElementCount() > 0 ) {
+ // try {
+ // List<MinimizedFileSystemElement> selectionList =
+ // selectionGroup.getAllWhiteCheckedItems();
+ // MinimizedFileSystemElement tmpSelectedElement = null;
+ //
+ // for ( int x=0; x<selectionList.size(); x++) {
+ // tmpSelectedElement = selectionList.get(x);
+ //
+ // // *** VERIFY ***
+ // // Not sure ALL directory are checked.
+ // if ( tmpSelectedElement.isDirectory() ) {
+ // String tmpPath = tmpSelectedElement.getFileSystemObject().toString();
+ // if ( isPathLttngTrace( tmpPath ) == false ) {
+ // returnedValue = false;
+ // errMessage = extendErrorMessage(errMessage, tmpPath);
+ // }
+ // }
+ // }
+ //
+ // if ( returnedValue == false ) {
+ // errMessage = extendErrorMessage(errMessage, "");
+ // errMessage = extendErrorMessage(errMessage,
+ // "Verify that the directory is a valid LTTng trace directory.");
+ // showVersionErrorPopup(errMessage);
+ // selectionGroup.setAllSelections(false);
+ // }
+ // }
+ // catch (LttngException e) {
+ // String exceptionMessage[] = { "Version check failed for the path : ",
+ // this.getTracepath(), "", "Returned error was :", e.toString() };
+ // showVersionErrorPopup(exceptionMessage);
+ // selectionGroup.setAllSelections(false);
+ // returnedValue = false;
+ // }
+ // }
+ //
+ // return returnedValue;
+ // }
+
}
public static String AddTraceWizardPage_columnHeader;
public static String AddTraceWizardPage_description;
public static String AddTraceWizardPage_windowTitle;
+ public static String ImportTraceWizardPage_BadTraceVersion;
+ public static String ImportTraceWizardPage_BadTraceVersionMsg1;
+ public static String ImportTraceWizardPage_BadTraceVersionMsg2;
+ public static String NewProjectWizard_Description;
+ public static String NewProjectWizard_Title;
+ public static String TraceErrorDialog_DalogTitle;
+ public static String TraceErrorDialog_DialogMsgLabel;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
@SuppressWarnings("restriction")
public class NewExperimentDialog extends SelectionStatusDialog {
- private Text folderNameField;
- private IContainer container;
- private boolean firstLinkCheck = true;
- private CreateLinkedResourceGroup linkedResourceGroup;
+ private Text folderNameField;
+ private IContainer container;
+ private boolean firstLinkCheck = true;
+ private CreateLinkedResourceGroup linkedResourceGroup;
- /**
- * Creates a NewFolderDialog
- *
- * @param parentShell parent of the new dialog
- * @param container parent of the new folder
- */
- public NewExperimentDialog(Shell parentShell, LTTngExperimentFolderNode experimentFolder) {
- super(parentShell);
- this.container = experimentFolder.getFolder();
- setTitle("LTTng Experiment");
- setStatusLineAboveButtons(true);
- }
+ /**
+ * Creates a NewFolderDialog
+ *
+ * @param parentShell
+ * parent of the new dialog
+ * @param container
+ * parent of the new folder
+ */
+ public NewExperimentDialog(Shell parentShell, LTTngExperimentFolderNode experimentFolder) {
+ super(parentShell);
+ this.container = experimentFolder.getFolder();
+ setTitle(org.eclipse.linuxtools.lttng.ui.views.project.dialogs.IDEWorkbenchMessages.NewExperimentDialog_DialogTitle);
+ setStatusLineAboveButtons(true);
+ }
- /**
- * Creates the folder using the name and link target entered by the user.
- * Sets the dialog result to the created folder.
- */
- @Override
- protected void computeResult() {
- }
+ /**
+ * Creates the folder using the name and link target entered by the user.
+ * Sets the dialog result to the created folder.
+ */
+ @Override
+ protected void computeResult() {
+ }
- /**
- * @see org.eclipse.jface.window.Window#create()
- */
- @Override
- public void create() {
- super.create();
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
+ /**
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ @Override
+ public void create() {
+ super.create();
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
- /**
- * Creates the widget for advanced options.
- *
- * @param parent the parent composite
- */
- protected void createLinkResourceGroup(Composite parent) {
- linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER,
- new Listener() {
- @Override
- public void handleEvent(Event e) {
- validateLinkedResource();
- firstLinkCheck = false;
- }
- }, new CreateLinkedResourceGroup.IStringValue() {
- @Override
- public void setValue(String string) {
- folderNameField.setText(string);
- }
+ /**
+ * Creates the widget for advanced options.
+ *
+ * @param parent
+ * the parent composite
+ */
+ protected void createLinkResourceGroup(Composite parent) {
+ linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ validateLinkedResource();
+ firstLinkCheck = false;
+ }
+ }, new CreateLinkedResourceGroup.IStringValue() {
+ @Override
+ public void setValue(String string) {
+ folderNameField.setText(string);
+ }
- @Override
- public String getValue() {
- return folderNameField.getText();
- }
+ @Override
+ public String getValue() {
+ return folderNameField.getText();
+ }
- @Override
- public IResource getResource() {
- // TODO Auto-generated method stub
- return null;
- }
- });
- }
+ @Override
+ public IResource getResource() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ });
+ }
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ /*
+ * (non-Javadoc) Method declared on Dialog.
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- createFolderNameGroup(composite);
- createLinkResourceGroup(composite);
- return composite;
- }
+ createFolderNameGroup(composite);
+ createLinkResourceGroup(composite);
+ return composite;
+ }
- /**
- * Creates the folder name specification controls.
- *
- * @param parent the parent composite
- */
- private void createFolderNameGroup(Composite parent) {
- Font font = parent.getFont();
- Composite folderGroup = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- folderGroup.setLayout(layout);
- folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ /**
+ * Creates the folder name specification controls.
+ *
+ * @param parent
+ * the parent composite
+ */
+ private void createFolderNameGroup(Composite parent) {
+ Font font = parent.getFont();
+ Composite folderGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ folderGroup.setLayout(layout);
+ folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // new folder label
- Label folderLabel = new Label(folderGroup, SWT.NONE);
- folderLabel.setFont(font);
- folderLabel.setText("Experiment name: ");
+ // new folder label
+ Label folderLabel = new Label(folderGroup, SWT.NONE);
+ folderLabel.setFont(font);
+ folderLabel.setText(org.eclipse.linuxtools.lttng.ui.views.project.dialogs.IDEWorkbenchMessages.NewExperimentDialog_ExperimentLabel);
- // new folder name entry field
- folderNameField = new Text(folderGroup, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- folderNameField.setLayoutData(data);
- folderNameField.setFont(font);
- folderNameField.addListener(SWT.Modify, new Listener() {
- @Override
- public void handleEvent(Event event) {
- validateLinkedResource();
- }
- });
- }
+ // new folder name entry field
+ folderNameField = new Text(folderGroup, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ folderNameField.setLayoutData(data);
+ folderNameField.setFont(font);
+ folderNameField.addListener(SWT.Modify, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ validateLinkedResource();
+ }
+ });
+ }
- /**
- * Creates a folder resource handle for the folder with the given name.
- * The folder handle is created relative to the container specified during
- * object creation.
- *
- * @param folderName the name of the folder resource to create a handle for
- * @return the new folder resource handle
- */
- private IFolder createFolderHandle(String folderName) {
- IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot();
- IPath folderPath = container.getFullPath().append(folderName);
- IFolder folderHandle = workspaceRoot.getFolder(folderPath);
+ /**
+ * Creates a folder resource handle for the folder with the given name. The
+ * folder handle is created relative to the container specified during
+ * object creation.
+ *
+ * @param folderName
+ * the name of the folder resource to create a handle for
+ * @return the new folder resource handle
+ */
+ private IFolder createFolderHandle(String folderName) {
+ IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot();
+ IPath folderPath = container.getFullPath().append(folderName);
+ IFolder folderHandle = workspaceRoot.getFolder(folderPath);
- return folderHandle;
- }
+ return folderHandle;
+ }
- /**
- * Creates a new folder with the given name and optionally linking to
- * the specified link target.
- *
- * @param folderName name of the new folder
- * @param linkTarget name of the link target folder. may be null.
- * @return IFolder the new folder
- */
- private IFolder createNewFolder(String folderName, final URI linkTarget) {
- final IFolder folderHandle = createFolderHandle(folderName);
+ /**
+ * Creates a new folder with the given name and optionally linking to the
+ * specified link target.
+ *
+ * @param folderName
+ * name of the new folder
+ * @param linkTarget
+ * name of the link target folder. may be null.
+ * @return IFolder the new folder
+ */
+ private IFolder createNewFolder(String folderName, final URI linkTarget) {
+ final IFolder folderHandle = createFolderHandle(folderName);
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
- @Override
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(IDEWorkbenchMessages.NewFolderDialog_progress, 2000);
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- if (linkTarget == null) {
- folderHandle.create(false, true, monitor);
- } else {
- folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor);
- }
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- } finally {
- monitor.done();
- }
- }
- };
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ public void execute(IProgressMonitor monitor) throws CoreException {
try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation);
- } catch (InterruptedException exception) {
- return null;
- } catch (InvocationTargetException exception) {
- if (exception.getTargetException() instanceof CoreException) {
- ErrorDialog.openError(getShell(),
- IDEWorkbenchMessages.NewFolderDialog_errorTitle, null, // no special message
- ((CoreException) exception.getTargetException()).getStatus());
- } else {
- // CoreExceptions are handled above, but unexpected runtime exceptions and errors may still occur.
- IDEWorkbenchPlugin.log(getClass(),
- "createNewExperiment", exception.getTargetException());
- MessageDialog.openError(getShell(),
- IDEWorkbenchMessages.NewFolderDialog_errorTitle,
- NLS.bind(IDEWorkbenchMessages.NewFolderDialog_internalError,
- exception.getTargetException().getMessage()));
- }
- return null;
+ monitor.beginTask(IDEWorkbenchMessages.NewFolderDialog_progress, 2000);
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ if (linkTarget == null) {
+ folderHandle.create(false, true, monitor);
+ } else {
+ folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor);
+ }
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ } finally {
+ monitor.done();
}
- return folderHandle;
+ }
+ };
+ try {
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation);
+ } catch (InterruptedException exception) {
+ return null;
+ } catch (InvocationTargetException exception) {
+ if (exception.getTargetException() instanceof CoreException) {
+ ErrorDialog.openError(getShell(), IDEWorkbenchMessages.NewFolderDialog_errorTitle, null,
+ ((CoreException) exception.getTargetException()).getStatus());
+ } else {
+ // CoreExceptions are handled above, but unexpected runtime
+ // exceptions and errors may still occur.
+ IDEWorkbenchPlugin.log(getClass(), "createNewExperiment", exception.getTargetException()); //$NON-NLS-1$
+ MessageDialog.openError(getShell(), IDEWorkbenchMessages.NewFolderDialog_errorTitle,
+ NLS.bind(IDEWorkbenchMessages.NewFolderDialog_internalError, exception.getTargetException().getMessage()));
+ }
+ return null;
}
+ return folderHandle;
+ }
- /**
- * Update the dialog's status line to reflect the given status. It is safe to call
- * this method before the dialog has been opened.
- */
- @Override
- protected void updateStatus(IStatus status) {
- if (firstLinkCheck && status != null) {
- Status newStatus = new Status(IStatus.OK, status.getPlugin(),
- status.getCode(), status.getMessage(), status.getException());
- super.updateStatus(newStatus);
- } else {
- super.updateStatus(status);
- }
+ /**
+ * Update the dialog's status line to reflect the given status. It is safe
+ * to call this method before the dialog has been opened.
+ */
+ @Override
+ protected void updateStatus(IStatus status) {
+ if (firstLinkCheck && status != null) {
+ Status newStatus = new Status(IStatus.OK, status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
+ super.updateStatus(newStatus);
+ } else {
+ super.updateStatus(status);
}
+ }
- /**
- * Update the dialog's status line to reflect the given status. It is safe to call
- * this method before the dialog has been opened.
- * @param severity
- * @param message
- */
- private void updateStatus(int severity, String message) {
- updateStatus(new Status(severity, IDEWorkbenchPlugin.IDE_WORKBENCH, severity, message, null));
- }
+ /**
+ * Update the dialog's status line to reflect the given status. It is safe
+ * to call this method before the dialog has been opened.
+ *
+ * @param severity
+ * @param message
+ */
+ private void updateStatus(int severity, String message) {
+ updateStatus(new Status(severity, IDEWorkbenchPlugin.IDE_WORKBENCH, severity, message, null));
+ }
- /**
- * Checks whether the folder name and link location are valid.
- * Disable the OK button if the folder name and link location are valid.
- * a message that indicates the problem otherwise.
- */
- private void validateLinkedResource() {
- boolean valid = validateFolderName();
+ /**
+ * Checks whether the folder name and link location are valid. Disable the
+ * OK button if the folder name and link location are valid. a message that
+ * indicates the problem otherwise.
+ */
+ private void validateLinkedResource() {
+ boolean valid = validateFolderName();
- if (valid) {
- IFolder linkHandle = createFolderHandle(folderNameField.getText());
- IStatus status = linkedResourceGroup.validateLinkLocation(linkHandle);
+ if (valid) {
+ IFolder linkHandle = createFolderHandle(folderNameField.getText());
+ IStatus status = linkedResourceGroup.validateLinkLocation(linkHandle);
- if (status.getSeverity() != IStatus.ERROR) {
- getOkButton().setEnabled(true);
- } else {
- getOkButton().setEnabled(false);
- }
+ if (status.getSeverity() != IStatus.ERROR) {
+ getOkButton().setEnabled(true);
+ } else {
+ getOkButton().setEnabled(false);
+ }
- if (status.isOK() == false) {
- updateStatus(status);
- }
- } else {
- getOkButton().setEnabled(false);
- }
+ if (status.isOK() == false) {
+ updateStatus(status);
+ }
+ } else {
+ getOkButton().setEnabled(false);
}
+ }
- /**
- * Checks if the folder name is valid.
- *
- * @return null if the new folder name is valid.
- * a message that indicates the problem otherwise.
- */
- private boolean validateFolderName() {
- String name = folderNameField.getText();
- IWorkspace workspace = container.getWorkspace();
- IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
+ /**
+ * Checks if the folder name is valid.
+ *
+ * @return null if the new folder name is valid. a message that indicates
+ * the problem otherwise.
+ */
+ private boolean validateFolderName() {
+ String name = folderNameField.getText();
+ IWorkspace workspace = container.getWorkspace();
+ IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
- if ("".equals(name)) { //$NON-NLS-1$
- updateStatus(IStatus.ERROR, "Experiment name is empty"); //$NON-NLS-1$
- return false;
- }
- if (nameStatus.isOK() == false) {
- updateStatus(nameStatus);
- return false;
- }
- IPath path = new Path(name);
- if (container.getFolder(path).exists()
- || container.getFile(path).exists()) {
- updateStatus(IStatus.ERROR, NLS.bind("Experiment already exists", name)); //$NON-NLS-1$
- return false;
- }
- updateStatus(IStatus.OK, ""); //$NON-NLS-1$
- return true;
+ if ("".equals(name)) { //$NON-NLS-1$
+ updateStatus(IStatus.ERROR, "Experiment name is empty"); //$NON-NLS-1$
+ return false;
+ }
+ if (nameStatus.isOK() == false) {
+ updateStatus(nameStatus);
+ return false;
}
+ IPath path = new Path(name);
+ if (container.getFolder(path).exists() || container.getFile(path).exists()) {
+ updateStatus(IStatus.ERROR, NLS.bind("Experiment already exists", name)); //$NON-NLS-1$
+ return false;
+ }
+ updateStatus(IStatus.OK, ""); //$NON-NLS-1$
+ return true;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed()
- */
- @Override
- protected void okPressed() {
- URI linkTarget = linkedResourceGroup.getLinkTargetURI();
- IFolder folder = createNewFolder(folderNameField.getText(), linkTarget);
- if (folder == null) {
- return;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ URI linkTarget = linkedResourceGroup.getLinkTargetURI();
+ IFolder folder = createNewFolder(folderNameField.getText(), linkTarget);
+ if (folder == null) {
+ return;
+ }
- setSelectionResult(new IFolder[] { folder });
+ setSelectionResult(new IFolder[] { folder });
- super.okPressed();
- }
+ super.okPressed();
+ }
}
\ No newline at end of file
*
*/
public NewProjectWizard() {
- this("LTTng Project", "Create an LTTng Project");
+ this(Messages.NewProjectWizard_Title, Messages.NewProjectWizard_Description);
}
/**
*/
@Override
public void addPages() {
- fMainPage= new NewProjectMainWizardPage("LTTng Project");
+ fMainPage= new NewProjectMainWizardPage(Messages.NewProjectWizard_Title);
fMainPage.setTitle(fTtitle);
fMainPage.setDescription(fDescription);
addPage(fMainPage);
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque - Initial API and implementation
*******************************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
public class TraceErrorDialog extends SelectionStatusDialog {
-
- private String[] messages = null;
-
- public TraceErrorDialog(Shell parentShell, String[] newMessages) {
- super(parentShell);
-
- messages = newMessages;
- setTitle("Trace Selection");
- setStatusLineAboveButtons(true);
- }
-
- @Override
- protected void computeResult() {
- }
-
- @Override
- public void create() {
- super.create();
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- getButton(IDialogConstants.OK_ID).setAlignment(GridData.CENTER);
- getButton(IDialogConstants.CANCEL_ID).setVisible(false);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createFolderNameGroup(composite);
- return composite;
- }
-
- private void createFolderNameGroup(Composite parent) {
- Font font = parent.getFont();
- Composite folderGroup = new Composite(parent, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.verticalSpacing = 3;
- folderGroup.setLayout(layout);
- folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-
- // Position grid for the messages
- GridData positionningData = new GridData(GridData.FILL_VERTICAL);
-
- // New message label
- Label lblMessage = new Label(folderGroup, SWT.NONE);
- lblMessage.setFont(font);
- lblMessage.setText("Error while opening the trace! Error message was : ");
- lblMessage.setLayoutData(positionningData);
-
- // The actual messages
- GC graphicContext = new GC(parent);
- String longuestLine = ""; //$NON-NLS-1$
- int msgSize = 0;
-
- // *** Font and FontData are nowhere near elegant to use.
- Font errorFont = new Font(graphicContext.getDevice(), font.getFontData()[0].getName(), font.getFontData()[0].getHeight(), SWT.ITALIC);
-
- Label[] lblErrorMessages = new Label[messages.length];
- for(int x=0; x<messages.length; x++) {
- lblErrorMessages[x] = new Label(folderGroup, SWT.NONE);
- lblErrorMessages[x].setFont(errorFont);
-
- lblErrorMessages[x].setForeground(new Color(lblErrorMessages[x].getForeground().getDevice(), 255, 0, 0));
- lblErrorMessages[x].setText(messages[x]);
- lblErrorMessages[x].setLayoutData(positionningData);
-
- if ( messages[x].length() > longuestLine.length() ) {
- longuestLine = messages[x];
- }
- }
-
- for ( int pos=0; pos<longuestLine.length(); pos++ ) {
- msgSize += graphicContext.getAdvanceWidth( longuestLine.charAt(pos) );
- }
- // Seems we need to count the final \n of the line otherwise we miss some space
- msgSize += graphicContext.getAdvanceWidth( '\n' );
-
- positionningData.widthHint = msgSize;
- positionningData.grabExcessHorizontalSpace = true;
-
- graphicContext.dispose();
-
+
+ private String[] messages = null;
+
+ public TraceErrorDialog(Shell parentShell, String[] newMessages) {
+ super(parentShell);
+ messages = newMessages;
+ setTitle(Messages.TraceErrorDialog_DalogTitle);
+ setStatusLineAboveButtons(true);
+ }
+
+ @Override
+ protected void computeResult() {
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ getButton(IDialogConstants.OK_ID).setAlignment(GridData.CENTER);
+ getButton(IDialogConstants.CANCEL_ID).setVisible(false);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createFolderNameGroup(composite);
+ return composite;
+ }
+
+ private void createFolderNameGroup(Composite parent) {
+ Font font = parent.getFont();
+ Composite folderGroup = new Composite(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 3;
+ folderGroup.setLayout(layout);
+ folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Position grid for the messages
+ GridData positionningData = new GridData(GridData.FILL_VERTICAL);
+
+ // New message label
+ Label lblMessage = new Label(folderGroup, SWT.NONE);
+ lblMessage.setFont(font);
+ lblMessage.setText(Messages.TraceErrorDialog_DialogMsgLabel);
+ lblMessage.setLayoutData(positionningData);
+
+ // The actual messages
+ GC graphicContext = new GC(parent);
+ String longuestLine = ""; //$NON-NLS-1$
+ int msgSize = 0;
+
+ // *** Font and FontData are nowhere near elegant to use.
+ Font errorFont = new Font(graphicContext.getDevice(), font.getFontData()[0].getName(), font.getFontData()[0].getHeight(), SWT.ITALIC);
+
+ Label[] lblErrorMessages = new Label[messages.length];
+ for (int x = 0; x < messages.length; x++) {
+ lblErrorMessages[x] = new Label(folderGroup, SWT.NONE);
+ lblErrorMessages[x].setFont(errorFont);
+
+ lblErrorMessages[x].setForeground(new Color(lblErrorMessages[x].getForeground().getDevice(), 255, 0, 0));
+ lblErrorMessages[x].setText(messages[x]);
+ lblErrorMessages[x].setLayoutData(positionningData);
+
+ if (messages[x].length() > longuestLine.length()) {
+ longuestLine = messages[x];
+ }
}
-
-
- @Override
- protected void updateStatus(IStatus status) {
- if (status != null) {
- Status newStatus = new Status(IStatus.OK, status.getPlugin(),
- status.getCode(), status.getMessage(), status.getException());
- super.updateStatus(newStatus);
- } else {
- super.updateStatus(status);
- }
+
+ for (int pos = 0; pos < longuestLine.length(); pos++) {
+ msgSize += graphicContext.getAdvanceWidth(longuestLine.charAt(pos));
}
-
- @Override
- protected void okPressed() {
- super.okPressed();
+ // Seems we need to count the final \n of the line otherwise we miss
+ // some space
+ msgSize += graphicContext.getAdvanceWidth('\n');
+
+ positionningData.widthHint = msgSize;
+ positionningData.grabExcessHorizontalSpace = true;
+
+ graphicContext.dispose();
+
+ }
+
+ @Override
+ protected void updateStatus(IStatus status) {
+ if (status != null) {
+ Status newStatus = new Status(IStatus.OK, status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
+ super.updateStatus(newStatus);
+ } else {
+ super.updateStatus(status);
}
+ }
+
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+ }
}
AddTraceWizardPage_columnHeader=Trace
AddTraceWizardPage_description=Select the traces to add to the experiment
AddTraceWizardPage_windowTitle=Select traces
+ImportTraceWizard_LocationError=Error: Trace location is wrong.
+ImportTraceWizard_LocationErrorMsg1=You cannot import your trace directly into "
+ImportTraceWizard_LocationErrorMsg2=The trace has to be into a directory, like "
+ImportTraceWizard_LocationErrorMsg3=Please adjust the location of the LTTng trace.
+ImportTraceWizardPage_BadTraceVersion=Error: Unrecognized trace version for
+ImportTraceWizardPage_BadTraceVersionMsg1=Verify that the directory is a valid LTTng trace directory.
+ImportTraceWizardPage_BadTraceVersionMsg2=Make sure the top directory is the trace itself and not any of its parent.
+NewExperimentDialog_DialogTitle=LTTng Experiment
+NewExperimentDialog_ExperimentLabel=Experiment name:
+NewFolderDialog_errorTitle=
+NewFolderDialog_internalError=
+NewFolderDialog_progress=
+NewProjectWizard_Description=Create an LTTng Project
+NewProjectWizard_Title=LTTng Project
+TraceErrorDialog_DalogTitle=Trace Selection
+TraceErrorDialog_DialogMsgLabel=Error while opening the trace\! Error message:
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.statistics;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.statistics.messages"; //$NON-NLS-1$
+ public static String StatisticsView_CPUTimeColumn;
+ public static String StatisticsView_CPUTimeTip;
+ public static String StatisticsView_CumCPUTimeColumn;
+ public static String StatisticsView_CumCPUTimeTip;
+ public static String StatisticsView_ElapsedTimeColumn;
+ public static String StatisticsView_ElapsedTimeTip;
+ public static String StatisticsView_LevelColumn;
+ public static String StatisticsView_LevelColumnTip;
+ public static String StatisticsView_NbEventsColumn;
+ public static String StatisticsView_NbEventsTip;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
private TreeViewer treeViewer;
// Table column names
- private final String LEVEL_COLUMN = "Level";
- private final String EVENTS_COUNT_COLUMN = "Number of Events";
- private final String CPU_TIME_COLUMN = "CPU Time";
- private final String CUMULATIVE_CPU_TIME_COLUMN = "Cumulative CPU Time";
- private final String ELAPSED_TIME_COLUMN = "Elapsed Time";
+ private final String LEVEL_COLUMN = Messages.StatisticsView_LevelColumn;
+ private final String EVENTS_COUNT_COLUMN = Messages.StatisticsView_NbEventsColumn;
+ private final String CPU_TIME_COLUMN = Messages.StatisticsView_CPUTimeColumn;
+ private final String CUMULATIVE_CPU_TIME_COLUMN = Messages.StatisticsView_CumCPUTimeColumn;
+ private final String ELAPSED_TIME_COLUMN = Messages.StatisticsView_ElapsedTimeColumn;
// Table column tooltips
- private final String LEVEL_COLUMN_TIP = "Level at which statistics apply.";
- private final String EVENTS_COUNT_COLUMN_TIP = "Total amount of events that are tied to given resource.";
- private final String CPU_TIME_COLUMN_TIP = "Total amount of time the CPU was used excluding wait times(I/O, etc.) at that level.";
- private final String CUMULATIVE_CPU_TIME_COLUMN_TIP = "Total amount of time between the first and last event excluding wait times in a level.";
- private final String ELAPSED_TIME_COLUMN_TIP = "Total amount of time the CPU was used including wait times(I/O, etc.) at that level.";
+ private final String LEVEL_COLUMN_TIP = Messages.StatisticsView_LevelColumnTip;
+ private final String EVENTS_COUNT_COLUMN_TIP = Messages.StatisticsView_NbEventsTip;
+ private final String CPU_TIME_COLUMN_TIP = Messages.StatisticsView_CPUTimeTip;
+ private final String CUMULATIVE_CPU_TIME_COLUMN_TIP = Messages.StatisticsView_CumCPUTimeTip;
+ private final String ELAPSED_TIME_COLUMN_TIP = Messages.StatisticsView_ElapsedTimeTip;
// Level for which statistics should not be displayed.
- private Set<String> folderLevels = new HashSet<String>(Arrays
- .asList(new String[] { "Event Types", "Modes", "Submodes", "CPUs",
- "Processes", "Functions" }));
+ private Set<String> folderLevels = new HashSet<String>(Arrays.asList(
+ new String[] { "Event Types", "Modes", "Submodes", "CPUs", "Processes", "Functions" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
// Levels for which sub-levels should not contain time-related statistics.
- private Set<String> levelsWithEmptyTime = new HashSet<String>(Arrays
- .asList(new String[] { "Event Types" }));
+ private Set<String> levelsWithEmptyTime = new HashSet<String>(Arrays.asList(
+ new String[] { "Event Types" })); //$NON-NLS-1$
- private DecimalFormat decimalFormat = new DecimalFormat("0.#########");
+ private DecimalFormat decimalFormat = new DecimalFormat("0.#########"); //$NON-NLS-1$
private Cursor fwaitCursor = null;
private static final Long STATS_INPUT_CHANGED_REFRESH = 5000L;
--- /dev/null
+StatisticsView_CPUTimeColumn=CPU Time
+StatisticsView_CPUTimeTip=Total amount of time the CPU was used excluding wait times(I/O, etc.) at that level.
+StatisticsView_CumCPUTimeColumn=Cumulative CPU Time
+StatisticsView_CumCPUTimeTip=Total amount of time between the first and last event excluding wait times in a level.
+StatisticsView_ElapsedTimeColumn=Elapsed Time
+StatisticsView_ElapsedTimeTip=Total amount of time the CPU was used including wait times(I/O, etc.) at that level.
+StatisticsView_LevelColumn=Level
+StatisticsView_LevelColumnTip=Level at which statistics apply.
+StatisticsView_NbEventsColumn=Number of Events
+StatisticsView_NbEventsTip=Total amount of events that are tied to given resource.
* <h4>Class that process the LTTng kernel events.</h4>
*/
public class KernelStatisticsData extends StatisticsData {
- /**
- * <h4>Header for the mode categories.</h4>
- */
- private static final String HEADER_CPUS = "CPUs";
- /**
- * <h4>Header for the event types categories.</h4>
- */
- private static final String HEADER_EVENT_TYPES = "Event Types";
- /**
- * <h4>Header for the function categories.</h4>
- */
- private static final String HEADER_FUNCTIONS = "Functions";
- /**
- * <h4>Header for the mode categories.</h4>
- */
- private static final String HEADER_MODES = "Modes";
- /**
- * <h4>Header for the processes categories.</h4>
- */
- private static final String HEADER_PROCESSES = "Processes";
- /**
- * <h4>Header for the submode categories.</h4>
- */
- private static final String HEADER_SUBMODES ="Submodes";
- /**
- * <h4>Indicate that it's a value.</h4>
- * <p>Used when checking the possible child node for a node.</p>
- * <p>It differentiate a category of a value by being appended to a value.</p>
- */
- private static final String NODE = "z";
- private static final String ROOT_NODE_KEY = mergeString(ROOT.get(0), NODE);
- /**
- * <h4>Constructor.</h4>
- * @param traceName
- */
- public KernelStatisticsData(String traceName) {
- super();
- Map<String, Set<String>> keys = getKeys();
-
- ////////////// Adding category sets
- keys.put(HEADER_PROCESSES, new HashSet<String>());
- keys.put(HEADER_MODES, new HashSet<String>());
- keys.put(HEADER_CPUS, new HashSet<String>(4)); // Over 4 CPUs is not common
- keys.put(HEADER_SUBMODES, new HashSet<String>());
- keys.put(HEADER_EVENT_TYPES, new HashSet<String>());
- keys.put(HEADER_FUNCTIONS, new HashSet<String>(4)); // Seems to be always one.
-
- ///////////// Adding value sets
- // Under a trace
- Set<String> temp = new HashSet<String>(8);
- temp.add(HEADER_PROCESSES);
- temp.add(HEADER_MODES);
- temp.add(HEADER_CPUS);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(ROOT_NODE_KEY, temp);
- // Under a process
- temp = new HashSet<String>(4);
- temp.add(HEADER_MODES);
- temp.add(HEADER_CPUS);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(mergeString(HEADER_PROCESSES,NODE), temp);
- // Under a CPUs : Functions is a special case
- temp = new HashSet<String>(4);
- temp.add(HEADER_MODES);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(mergeString(HEADER_CPUS,NODE), temp);
- // Under a functions
- temp = new HashSet<String>(4);
- temp.add(HEADER_MODES);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(mergeString(HEADER_FUNCTIONS,NODE), temp);
- // Under a mode
- temp = new HashSet<String>(4);
- temp.add(HEADER_SUBMODES);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(mergeString(HEADER_MODES,NODE), temp);
- // Under a submodes
- temp = new HashSet<String>(2);
- temp.add(HEADER_EVENT_TYPES);
- keys.put(mergeString(HEADER_SUBMODES,NODE), temp);
- // Under an event type
- temp = new HashSet<String>(16);
- keys.put(mergeString(HEADER_EVENT_TYPES,NODE),temp);
-
- ////////////// CREATE root
- keys.put(ROOT.get(0), new HashSet<String>(2)); // 1 trace at the time
- getOrCreate(ROOT);
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#endTraceset(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
- */
- @Override
- public void endTraceset(LttngEvent event, LttngTraceState traceState) {
- // TODO Should we uncomment the rest?
- // It include in the cpu time the time between the last event of each cpu and the time of the last global event.
- // Because we know that there won't be a change of mode or process between those time.
- /*if(last_ == null)
- return;
-
- LttngProcessState process = traceState.getRunning_process().get(0L);
- System.out.println(process.getState().getChange_LttTime());
- for(long cpu : traceState.getRunning_process().keySet()) {
- LttngEventType newType = new LttngEventType(last_.getType().getTracefileName(), cpu, last_.getType().getMarkerName(), last_.getType().getLabels());
- last_.setType(newType);
- increase(last_, traceState,
- Values.CPU_TIME | Values.CUMULATIVE_CPU_TIME | Values.ELAPSED_TIME | Values.STATE_CUMULATIVE_CPU_TIME);
- // TODO Are all those values required?
- }*/
- }
+ /**
+ * <h4>Header for the mode categories.</h4>
+ */
+ private static final String HEADER_CPUS = Messages.KernelStatisticsData_CPUs;
+ /**
+ * <h4>Header for the event types categories.</h4>
+ */
+ private static final String HEADER_EVENT_TYPES = Messages.KernelStatisticsData_EventTypes;
+ /**
+ * <h4>Header for the function categories.</h4>
+ */
+ private static final String HEADER_FUNCTIONS = Messages.KernelStatisticsData_Functions;
+ /**
+ * <h4>Header for the mode categories.</h4>
+ */
+ private static final String HEADER_MODES = Messages.KernelStatisticsData_Modes;
+ /**
+ * <h4>Header for the processes categories.</h4>
+ */
+ private static final String HEADER_PROCESSES = Messages.KernelStatisticsData_Processes;
+ /**
+ * <h4>Header for the submode categories.</h4>
+ */
+ private static final String HEADER_SUBMODES = Messages.KernelStatisticsData_SubModes;
+ /**
+ * <h4>Indicate that it's a value.</h4>
+ * <p>
+ * Used when checking the possible child node for a node.
+ * </p>
+ * <p>
+ * It differentiate a category of a value by being appended to a value.
+ * </p>
+ */
+ private static final String NODE = "z"; //$NON-NLS-1$
+ private static final String ROOT_NODE_KEY = mergeString(ROOT.get(0), NODE);
+
+ /**
+ * <h4>Constructor.</h4>
+ *
+ * @param traceName
+ */
+ public KernelStatisticsData(String traceName) {
+ super();
+ Map<String, Set<String>> keys = getKeys();
+
+ // //////////// Adding category sets
+ keys.put(HEADER_PROCESSES, new HashSet<String>());
+ keys.put(HEADER_MODES, new HashSet<String>());
+ keys.put(HEADER_CPUS, new HashSet<String>(4)); // Over 4 CPUs is not
+ // common
+ keys.put(HEADER_SUBMODES, new HashSet<String>());
+ keys.put(HEADER_EVENT_TYPES, new HashSet<String>());
+ keys.put(HEADER_FUNCTIONS, new HashSet<String>(4)); // Seems to be
+ // always one.
+
+ // /////////// Adding value sets
+ // Under a trace
+ Set<String> temp = new HashSet<String>(8);
+ temp.add(HEADER_PROCESSES);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_CPUS);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(ROOT_NODE_KEY, temp);
+ // Under a process
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_CPUS);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_PROCESSES, NODE), temp);
+ // Under a CPUs : Functions is a special case
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_CPUS, NODE), temp);
+ // Under a functions
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_FUNCTIONS, NODE), temp);
+ // Under a mode
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_SUBMODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_MODES, NODE), temp);
+ // Under a submodes
+ temp = new HashSet<String>(2);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_SUBMODES, NODE), temp);
+ // Under an event type
+ temp = new HashSet<String>(16);
+ keys.put(mergeString(HEADER_EVENT_TYPES, NODE), temp);
+
+ // //////////// CREATE root
+ keys.put(ROOT.get(0), new HashSet<String>(2)); // 1 trace at the time
+ getOrCreate(ROOT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #endTraceset(org.eclipse.linuxtools.lttng.event.LttngEvent,
+ * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void endTraceset(LttngEvent event, LttngTraceState traceState) {
+ // TODO Should we uncomment the rest?
+ // It include in the cpu time the time between the last event of each
+ // cpu and the time of the last global event.
+ // Because we know that there won't be a change of mode or process
+ // between those time.
/*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#getChildren(org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
- */
- @Override
- public Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path) {
- LinkedList<StatisticsTreeNode> result = new LinkedList<StatisticsTreeNode>();
-
- if(path.size() % 2 == 0) { // if we are at a Category
- StatisticsTreeNode current = null;
- for(String value : getKeys().get(path.get(path.size() - 1))) {
- current = get(path.append(value));
- if(current != null && current.getValue().nbEvents != 0)
- result.add(current);
- }
- }
- else if(path.size() == 1) { // Special case.
- if(path.equals(ROOT)) // Asking for the root.
- for(String value : getKeys().get(ROOT.get(0)))
- result.add(getOrCreate(new FixedArray<String>(value)));
- else // Get value under the root
- for (String value : getKeys().get(ROOT_NODE_KEY))
- result.add(getOrCreate(path.append(value)));
- }
- else {// If we are at a value
- for(String value : getKeys().get(mergeString(path.get(path.size() -2),NODE))) // Search the parent name + NODE
- result.add(getOrCreate(path.append(value)));
-
- if(path.size() == 5 && path.get(3).equals(HEADER_CPUS)) // Special the Functions is just there. We want the fourth element but it start at 0. So #3
- result.add(getOrCreate(path.append(HEADER_FUNCTIONS)));
- }
-
- return result;
- }
- /**
- * <h4>Get the standard paths for an event.</h4>
- * @param event Event to get the path for.
- * @param traceState State of the trace for this event.
- * @return Array of FixedArray representing the paths.
+ * if(last_ == null) return;
+ *
+ * LttngProcessState process = traceState.getRunning_process().get(0L);
+ * System.out.println(process.getState().getChange_LttTime()); for(long
+ * cpu : traceState.getRunning_process().keySet()) { LttngEventType
+ * newType = new LttngEventType(last_.getType().getTracefileName(), cpu,
+ * last_.getType().getMarkerName(), last_.getType().getLabels());
+ * last_.setType(newType); increase(last_, traceState, Values.CPU_TIME |
+ * Values.CUMULATIVE_CPU_TIME | Values.ELAPSED_TIME |
+ * Values.STATE_CUMULATIVE_CPU_TIME); // TODO Are all those values
+ * required? }
*/
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private FixedArray<String>[] getNormalPaths(LttngEvent event, LttngTraceState traceState) {
- String trace = traceState.getContext().getTraceId();
- Long cpu = event.getCpuId();
- String cpus = String.valueOf(cpu);
- LttngProcessState process = traceState.getRunning_process().get(cpu);
- String processName = getProcessName(process);
- String mode = process.getState().getExec_mode().getInName();
- String submode = process.getState().getExec_submode();
- String function = process.getCurrent_function().toString();
-
- FixedArray[] paths = {
- new FixedArray<String>(trace),
- new FixedArray<String>(trace,HEADER_MODES,mode),
- new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_SUBMODES,submode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode, HEADER_SUBMODES, submode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_SUBMODES,submode),
- new FixedArray<String>(trace,HEADER_CPUS,cpus),
- new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode),
- new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode),
- };
-
- return paths;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #getChildren
+ * (org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
+ */
+ @Override
+ public Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path) {
+ LinkedList<StatisticsTreeNode> result = new LinkedList<StatisticsTreeNode>();
+
+ if (path.size() % 2 == 0) { // if we are at a Category
+ StatisticsTreeNode current = null;
+ for (String value : getKeys().get(path.get(path.size() - 1))) {
+ current = get(path.append(value));
+ if (current != null && current.getValue().nbEvents != 0)
+ result.add(current);
+ }
+ } else if (path.size() == 1) { // Special case.
+ if (path.equals(ROOT)) // Asking for the root.
+ for (String value : getKeys().get(ROOT.get(0)))
+ result.add(getOrCreate(new FixedArray<String>(value)));
+ else
+ // Get value under the root
+ for (String value : getKeys().get(ROOT_NODE_KEY))
+ result.add(getOrCreate(path.append(value)));
+ } else {// If we are at a value
+ for (String value : getKeys().get(mergeString(path.get(path.size() - 2), NODE)))
+ // Search the parent name + NODE
+ result.add(getOrCreate(path.append(value)));
+
+ if (path.size() == 5 && path.get(3).equals(HEADER_CPUS)) // Special
+ // the
+ // Functions
+ // is just
+ // there.
+ // We want
+ // the
+ // fourth
+ // element
+ // but it
+ // start at
+ // 0. So #3
+ result.add(getOrCreate(path.append(HEADER_FUNCTIONS)));
}
- /**
- * <h4>Get the event types paths.</h4>
- * @param event Event to get the path for.
- * @param traceState State of the trace for this event.
- * @return Array of FixedArray representing the paths.
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private FixedArray<String>[] getTypePaths(LttngEvent event, LttngTraceState traceState) {
- String trace = traceState.getContext().getTraceId();
- Long cpu = event.getCpuId();
- String cpus = String.valueOf(cpu);
- LttngProcessState process = traceState.getRunning_process().get(cpu);
- String processName = getProcessName(process);
- String mode = process.getState().getExec_mode().getInName();
- String submode = process.getState().getExec_submode();
- String function = process.getCurrent_function().toString();
- //String type = event.getType().getTypeId(); // Add too much informations
- String type = event.getMarkerName();
-
- FixedArray[] paths = {
- new FixedArray<String>(trace,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode, HEADER_SUBMODES, submode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
- new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
- };
-
- return paths;
+
+ return result;
+ }
+
+ /**
+ * <h4>Get the standard paths for an event.</h4>
+ *
+ * @param event
+ * Event to get the path for.
+ * @param traceState
+ * State of the trace for this event.
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private FixedArray<String>[] getNormalPaths(LttngEvent event, LttngTraceState traceState) {
+ String trace = traceState.getContext().getTraceId();
+ Long cpu = event.getCpuId();
+ String cpus = String.valueOf(cpu);
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+ String processName = getProcessName(process);
+ String mode = process.getState().getExec_mode().getInName();
+ String submode = process.getState().getExec_submode();
+ String function = process.getCurrent_function().toString();
+
+ FixedArray[] paths = { new FixedArray<String>(trace), new FixedArray<String>(trace, HEADER_MODES, mode), new FixedArray<String>(trace, HEADER_MODES, mode, HEADER_SUBMODES, submode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName), new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function, HEADER_MODES, mode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function, HEADER_MODES, mode, HEADER_SUBMODES, submode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_MODES, mode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_SUBMODES, submode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_MODES, mode),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_MODES, mode, HEADER_SUBMODES, submode), new FixedArray<String>(trace, HEADER_CPUS, cpus),
+ new FixedArray<String>(trace, HEADER_CPUS, cpus, HEADER_MODES, mode), new FixedArray<String>(trace, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_SUBMODES, submode), };
+
+ return paths;
+ }
+
+ /**
+ * <h4>Get the event types paths.</h4>
+ *
+ * @param event
+ * Event to get the path for.
+ * @param traceState
+ * State of the trace for this event.
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private FixedArray<String>[] getTypePaths(LttngEvent event, LttngTraceState traceState) {
+ String trace = traceState.getContext().getTraceId();
+ Long cpu = event.getCpuId();
+ String cpus = String.valueOf(cpu);
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+ String processName = getProcessName(process);
+ String mode = process.getState().getExec_mode().getInName();
+ String submode = process.getState().getExec_submode();
+ String function = process.getCurrent_function().toString();
+ // String type = event.getType().getTypeId(); // Add too much
+ // informations
+ String type = event.getMarkerName();
+
+ FixedArray[] paths = { new FixedArray<String>(trace, HEADER_EVENT_TYPES, type), new FixedArray<String>(trace, HEADER_MODES, mode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_MODES, mode, HEADER_SUBMODES, submode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function, HEADER_MODES, mode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_FUNCTIONS, function, HEADER_MODES, mode, HEADER_SUBMODES, submode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_SUBMODES, submode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_MODES, mode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_PROCESSES, processName, HEADER_MODES, mode, HEADER_SUBMODES, submode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_CPUS, cpus, HEADER_EVENT_TYPES, type), new FixedArray<String>(trace, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_EVENT_TYPES, type),
+ new FixedArray<String>(trace, HEADER_CPUS, cpus, HEADER_MODES, mode, HEADER_SUBMODES, submode, HEADER_EVENT_TYPES, type), };
+
+ return paths;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #process_exit(org.eclipse.linuxtools.lttng.event.LttngEvent,
+ * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void process_exit(LttngEvent event, LttngTraceState traceState) {
+ FixedArray<String>[] paths = getNormalPaths(event, traceState);
+ Long cpu = event.getCpuId();
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+
+ for (FixedArray<String> path : paths) {
+ StatisticsTreeNode node = getOrCreate(path);
+
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ }
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#process_exit(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
- */
- @Override
- public void process_exit(LttngEvent event, LttngTraceState traceState) {
- FixedArray<String>[] paths = getNormalPaths(event,traceState);
- Long cpu = event.getCpuId();
- LttngProcessState process = traceState.getRunning_process().get(cpu);
-
- for(FixedArray<String> path : paths) {
- StatisticsTreeNode node = getOrCreate(path);
-
- if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- }
+
+ // TODO Unstacks cumulative CPU time
+ // TODO Elapsed time?
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #increase(org.eclipse.linuxtools.lttng.event.LttngEvent,
+ * org.eclipse.linuxtools.lttng.state.model.LttngTraceState, int)
+ */
+ @Override
+ public void increase(LttngEvent event, LttngTraceState traceState, int values) {
+ FixedArray<String>[] paths = getNormalPaths(event, traceState);
+ Long cpu = event.getCpuId();
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+
+ for (FixedArray<String> path : paths) {
+ StatisticsTreeNode node = getOrCreate(path);
+
+ if ((values & Values.CPU_TIME) != 0) {
+ // TODO Uncomment if the event after process_exit need to be
+ // count.
+ if ((process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) /*
+ * ||
+ * process
+ * .
+ * getState
+ * (
+ * )
+ * .
+ * getProc_status
+ * (
+ * )
+ * .
+ * equals
+ * (
+ * ProcessStatus
+ * .
+ * LTTV_STATE_EXIT
+ * )
+ */) && !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
}
-
- // TODO Unstacks cumulative CPU time
- // TODO Elapsed time?
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#increase(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState, int)
- */
- @Override
- public void increase(LttngEvent event, LttngTraceState traceState, int values) {
- FixedArray<String>[] paths = getNormalPaths(event, traceState);
- Long cpu = event.getCpuId();
- LttngProcessState process = traceState.getRunning_process().get(cpu);
-
- for(FixedArray<String> path : paths)
- {
- StatisticsTreeNode node = getOrCreate(path);
-
- if((values & Values.CPU_TIME) != 0) {
- // TODO Uncomment if the event after process_exit need to be count.
- if ((process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) /*|| process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_EXIT)*/) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- }
- }
- if((values & Values.CUMULATIVE_CPU_TIME) != 0) {
- if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
- }
- else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
- }
- }
- if((values & Values.ELAPSED_TIME) != 0) {
- if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- node.getValue().elapsedTime += event.getTimestamp().getValue()
- - process.getState().getEntry_LttTime();
- }
- }
- if((values & Values.STATE_CUMULATIVE_CPU_TIME) != 0) {
- if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- }
- }
+ }
+ if ((values & Values.CUMULATIVE_CPU_TIME) != 0) {
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
+ } else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) && !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
}
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#registerEvent(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
- */
- @Override
- public void registerEvent(LttngEvent event, LttngTraceState traceState) {
- FixedArray<String>[] paths = getNormalPaths(event, traceState);
- for(FixedArray<String> path : paths)
- ++(getOrCreate(path).getValue().nbEvents);
-
- paths = getTypePaths(event, traceState);
- for(FixedArray<String> path : paths)
- ++(getOrCreate(path).getValue().nbEvents);
-
- //last_ = event; // TODOÂ Used by endTraceset
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#registerName(org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
- */
- @Override
- protected void registerName(final FixedArray<String> path) {
- if(path.size() == 1) {
- if(!path.equals(ROOT))
- getKeys().get(ROOT.get(0)).add(path.get(0));
+ }
+ if ((values & Values.ELAPSED_TIME) != 0) {
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().elapsedTime += event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
}
- else if(path.size() % 2 != 0)
- getKeys().get(path.get(path.size() - 2)).add(path.get(path.size() - 1));
+ }
+ if ((values & Values.STATE_CUMULATIVE_CPU_TIME) != 0) {
+ if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) && !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ }
+ }
}
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #registerEvent(org.eclipse.linuxtools.lttng.event.LttngEvent,
+ * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void registerEvent(LttngEvent event, LttngTraceState traceState) {
+ FixedArray<String>[] paths = getNormalPaths(event, traceState);
+ for (FixedArray<String> path : paths)
+ ++(getOrCreate(path).getValue().nbEvents);
+
+ paths = getTypePaths(event, traceState);
+ for (FixedArray<String> path : paths)
+ ++(getOrCreate(path).getValue().nbEvents);
+
+ // last_ = event; // TODOÂ Used by endTraceset
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData
+ * #registerName
+ * (org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
+ */
+ @Override
+ protected void registerName(final FixedArray<String> path) {
+ if (path.size() == 1) {
+ if (!path.equals(ROOT))
+ getKeys().get(ROOT.get(0)).add(path.get(0));
+ } else if (path.size() % 2 != 0)
+ getKeys().get(path.get(path.size() - 2)).add(path.get(path.size() - 1));
+ }
}
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.statistics.model.messages"; //$NON-NLS-1$
+ public static String KernelStatisticsData_CPUs;
+ public static String KernelStatisticsData_EventTypes;
+ public static String KernelStatisticsData_Functions;
+ public static String KernelStatisticsData_Modes;
+ public static String KernelStatisticsData_Processes;
+ public static String KernelStatisticsData_SubModes;
+ public static String StatisticsData_UnknowProcess;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
/**
* <h4>Base class for the statistics storage.</h4>
- * <p>It allow to implement a tree structure while avoiding the need to run through the tree each time you need to add a node at a given place.</p>
+ * <p>
+ * It allow to implement a tree structure while avoiding the need to run through
+ * the tree each time you need to add a node at a given place.
+ * </p>
*/
public abstract class StatisticsData {
+ /**
+ * <h4>Define values that can be used like a C++ enumeration.</h4>
+ * <p>
+ * The values can be used with binary "or" and "and" to mix them.
+ * </p>
+ */
+ public static class Values {
/**
- * <h4>Define values that can be used like a C++ enumeration.</h4>
- * <p>The values can be used with binary "or" and "and" to mix them.</p>
+ * <h4>Indicate the cpu time</h4>
+ * <p>
+ * The actual time the cpu as passed in this state making calculations.
+ * </p>
*/
- public static class Values {
- /**
- * <h4>Indicate the cpu time</h4>
- * <p>The actual time the cpu as passed in this state making calculations.</p>
- */
- public static final int CPU_TIME = 1;
- /**
- * <h4>Indicate the cumulative cpu time</h4>
- * <p>Include the time the cpu as passed in this state and substate.</p>
- * <p>Example:
- * <ul>
- * <li>PID:1, Mode:USER_MODE</li>
- * <ul>
- * <li>PID:1, Mode:SYSCALL</li>
- * </ul>
- * <li>PID:2, Mode:USER_MODE</li>
- * </ul>
- * </p>
- * <p>In this example, the cumulative cpu time for "PID:1, Mode:USER_MODE" would
- * be equal to its cpu time plus the cpu time of "PID:1, Mode:SYSCALL".</p>
- * TODO Validate values. Not tested in LTTv.
- * TODO Validate description.
- */
- public static final int CUMULATIVE_CPU_TIME = 2;
- /**
- * <h4>Elapsed time</h4>
- * <p>Description...</p>
- * TODO Give a correct description.
- */
- public static final int ELAPSED_TIME = 4;
- /**
- * <h4>State cumulative cpu time</h4>
- * <p>Description...</p>
- * TODO Give a correct description.
- */
- public static final int STATE_CUMULATIVE_CPU_TIME = 8;
- }
- /**
- * <h4>String builder used to merge string with more efficacy.</h4>
- */
- protected static StringBuilder fBuilder = new StringBuilder();
- /**
- * <h4>Identification of the root.</h4>
- */
- public static final FixedArray<String> ROOT = new FixedArray<String>("root"); //$NON-NLS-1$
- /**
- * <h4>Function to merge many string with more efficacy.</h4>
- * @param strings Strings to merge.
- * @return A new string containing all the strings.
- */
- protected synchronized static String mergeString(String...strings) {
- fBuilder.setLength(0);
- for(String s : strings)
- fBuilder.append(s);
- return fBuilder.toString();
- }
- /**
- * <h4>Define what child a node can have. </h4>
- * <p>The management and usage of this map is done by subclass.</p>
- * <p>HashSet are always faster than TreeSet.</p>
- */
- private Map<String, Set<String>> fKeys;
- /**
- * <h4>The nodes in the tree.</f4>
- */
- private HashMap<FixedArray<String>, StatisticsTreeNode> fNodes;
- /**
- * <h4>Constructor.</h4>
- */
- public StatisticsData() {
- fNodes = new HashMap<FixedArray<String>,StatisticsTreeNode>();
- fKeys = new HashMap<String, Set<String>>();
- }
+ public static final int CPU_TIME = 1;
/**
- * <h4>Indicate the end of the traceset</4>
- * <p>Can be used to trigger necessary calculations.</p>
- * @param event Event receive (May have timestamp of 0).
- * @param traceState State of the trace at that moment.
+ * <h4>Indicate the cumulative cpu time</h4>
+ * <p>
+ * Include the time the cpu as passed in this state and substate.
+ * </p>
+ * <p>
+ * Example:
+ * <ul>
+ * <li>PID:1, Mode:USER_MODE</li>
+ * <ul>
+ * <li>PID:1, Mode:SYSCALL</li>
+ * </ul>
+ * <li>PID:2, Mode:USER_MODE</li>
+ * </ul>
+ * </p>
+ * <p>
+ * In this example, the cumulative cpu time for "PID:1, Mode:USER_MODE"
+ * would be equal to its cpu time plus the cpu time of
+ * "PID:1, Mode:SYSCALL".
+ * </p>
+ * TODO Validate values. Not tested in LTTv. TODO Validate description.
*/
- public abstract void endTraceset(LttngEvent event, LttngTraceState traceState);
+ public static final int CUMULATIVE_CPU_TIME = 2;
/**
- * <h4>Get a node.</h4>
- * @param path Path to the node.
- * @return The node or null.
+ * <h4>Elapsed time</h4>
+ * <p>
+ * Description...
+ * </p>
+ * TODO Give a correct description.
*/
- public StatisticsTreeNode get(final FixedArray<String> path) {
- return fNodes.get(path);
- }
+ public static final int ELAPSED_TIME = 4;
/**
- * <h4>Get the children of a node.</h4>
- * @param path Path to the node.
- * @return Collection containing the children.
+ * <h4>State cumulative cpu time</h4>
+ * <p>
+ * Description...
+ * </p>
+ * TODO Give a correct description.
*/
- public abstract Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path);
- /**
- * <h4>Get the map of existing elements of path classified by parent.</h4>
- * @return The map.
- */
- protected Map<String, Set<String>> getKeys() {
- return fKeys;
- }
- /**
- * <h4>Get or create a node.</h4>
- * @param path Path to the node.
- * @return The node.
- */
- public StatisticsTreeNode getOrCreate(final FixedArray<String> path) {
- StatisticsTreeNode current = fNodes.get(path);
- if(current == null) {
- registerName(path);
- current = new StatisticsTreeNode(path,this);
- fNodes.put(path, current);
- }
- return current;
- }
- /**
- * <h4>Get the parent of a node.</h4>
- * @param path Path to the node.
- * @return Parent node or null.
- */
- public StatisticsTreeNode getParent(final FixedArray<String> path) {
- if(path.size() == 1) {
- if(path.equals(ROOT))
- return null;
- else
- return get(ROOT);
- }
- // TODO Get or GetOrCreate?
- return get(path.subArray(0,path.size()-1));
+ public static final int STATE_CUMULATIVE_CPU_TIME = 8;
+ }
+
+ /**
+ * <h4>String builder used to merge string with more efficacy.</h4>
+ */
+ protected static StringBuilder fBuilder = new StringBuilder();
+ /**
+ * <h4>Identification of the root.</h4>
+ */
+ public static final FixedArray<String> ROOT = new FixedArray<String>("root"); //$NON-NLS-1$
+
+ /**
+ * <h4>Function to merge many string with more efficacy.</h4>
+ *
+ * @param strings
+ * Strings to merge.
+ * @return A new string containing all the strings.
+ */
+ protected synchronized static String mergeString(String... strings) {
+ fBuilder.setLength(0);
+ for (String s : strings)
+ fBuilder.append(s);
+ return fBuilder.toString();
+ }
+
+ /**
+ * <h4>Define what child a node can have.</h4>
+ * <p>
+ * The management and usage of this map is done by subclass.
+ * </p>
+ * <p>
+ * HashSet are always faster than TreeSet.
+ * </p>
+ */
+ private Map<String, Set<String>> fKeys;
+ /**
+ * <h4>The nodes in the tree.</f4>
+ */
+ private HashMap<FixedArray<String>, StatisticsTreeNode> fNodes;
+
+ /**
+ * <h4>Constructor.</h4>
+ */
+ public StatisticsData() {
+ fNodes = new HashMap<FixedArray<String>, StatisticsTreeNode>();
+ fKeys = new HashMap<String, Set<String>>();
+ }
+
+ /**
+ * <h4>Indicate the end of the traceset</4>
+ * <p>
+ * Can be used to trigger necessary calculations.
+ * </p>
+ *
+ * @param event
+ * Event receive (May have timestamp of 0).
+ * @param traceState
+ * State of the trace at that moment.
+ */
+ public abstract void endTraceset(LttngEvent event, LttngTraceState traceState);
+
+ /**
+ * <h4>Get a node.</h4>
+ *
+ * @param path
+ * Path to the node.
+ * @return The node or null.
+ */
+ public StatisticsTreeNode get(final FixedArray<String> path) {
+ return fNodes.get(path);
+ }
+
+ /**
+ * <h4>Get the children of a node.</h4>
+ *
+ * @param path
+ * Path to the node.
+ * @return Collection containing the children.
+ */
+ public abstract Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path);
+
+ /**
+ * <h4>Get the map of existing elements of path classified by parent.</h4>
+ *
+ * @return The map.
+ */
+ protected Map<String, Set<String>> getKeys() {
+ return fKeys;
+ }
+
+ /**
+ * <h4>Get or create a node.</h4>
+ *
+ * @param path
+ * Path to the node.
+ * @return The node.
+ */
+ public StatisticsTreeNode getOrCreate(final FixedArray<String> path) {
+ StatisticsTreeNode current = fNodes.get(path);
+ if (current == null) {
+ registerName(path);
+ current = new StatisticsTreeNode(path, this);
+ fNodes.put(path, current);
}
- /**
- * <h4>Get the name of a process.</h4>
- * @param process The process.
- * @return The name of the process.
- * //TODO Adding the creation time of the process may be needed to differentiate two process.
- */
- protected String getProcessName(LttngProcessState process) {
- if(process.getPid() == -1)
- return "Unknown process";
- if(process.getName() == null)
- return mergeString("Unknown process - ", String.valueOf(process.getPid()));
- if(process.getName().equals("")) //$NON-NLS-1$
- return process.getPid().toString();
- else
- return mergeString(process.getName(), " - ",String.valueOf(process.getPid())); //$NON-NLS-1$
+ return current;
+ }
+
+ /**
+ * <h4>Get the parent of a node.</h4>
+ *
+ * @param path
+ * Path to the node.
+ * @return Parent node or null.
+ */
+ public StatisticsTreeNode getParent(final FixedArray<String> path) {
+ if (path.size() == 1) {
+ if (path.equals(ROOT))
+ return null;
+ else
+ return get(ROOT);
}
- /**
- * <h4>Increase some values.</h4>
- * <p>Values is an binary or operation on the desired values between {@link Values#CPU_TIME}, {@link Values#CUMULATIVE_CPU_TIME}, {@link Values#ELAPSED_TIME} and {@link Values#STATE_CUMULATIVE_CPU_TIME} .
- * @param event Current event.
- * @param traceState State of the trace at that moment.
- * @param values Values desired.
- */
- public abstract void increase(LttngEvent event, LttngTraceState traceState, int values);
- /**
- * <h4>Register an event.</h4>
- * <p>This method must be implemented by subclass.</p>
- * @param event Event to process.
- * @param traceState State of the trace at the moment of the event.
- */
- public abstract void registerEvent(LttngEvent event, LttngTraceState traceState);
- /**
- * <h4>Register that a new node was created.</h4>
- * <p>Must make sure the {@link #getChildren(FixedArray)} on the parent node will return the newly created node.</p>
- * @param path Path of the new node.
- */
- protected abstract void registerName(final FixedArray<String> path);
- /**
- * <h4>Reset a node.</h4>
- * <p>Work recursively.</p>
- * @param path Path to the node.
- */
- public void reset(final FixedArray<String> path) {
- for(StatisticsTreeNode node : getChildren(path)) {
- reset(node.getPath());
- fNodes.remove(node.getPath());
- }
+ // TODO Get or GetOrCreate?
+ return get(path.subArray(0, path.size() - 1));
+ }
+
+ /**
+ * <h4>Get the name of a process.</h4>
+ *
+ * @param process
+ * The process.
+ * @return The name of the process. //TODO Adding the creation time of the
+ * process may be needed to differentiate two process.
+ */
+ protected String getProcessName(LttngProcessState process) {
+ if (process.getPid() == -1)
+ return Messages.StatisticsData_UnknowProcess;
+ if (process.getName() == null)
+ return mergeString(Messages.StatisticsData_UnknowProcess + " - ", String.valueOf(process.getPid())); //$NON-NLS-1$
+ if (process.getName().equals("")) //$NON-NLS-1$
+ return process.getPid().toString();
+ else
+ return mergeString(process.getName(), " - ", String.valueOf(process.getPid())); //$NON-NLS-1$
+ }
+
+ /**
+ * <h4>Increase some values.</h4>
+ * <p>
+ * Values is an binary or operation on the desired values between
+ * {@link Values#CPU_TIME}, {@link Values#CUMULATIVE_CPU_TIME},
+ * {@link Values#ELAPSED_TIME} and {@link Values#STATE_CUMULATIVE_CPU_TIME}
+ * .
+ *
+ * @param event
+ * Current event.
+ * @param traceState
+ * State of the trace at that moment.
+ * @param values
+ * Values desired.
+ */
+ public abstract void increase(LttngEvent event, LttngTraceState traceState, int values);
+
+ /**
+ * <h4>Register an event.</h4>
+ * <p>
+ * This method must be implemented by subclass.
+ * </p>
+ *
+ * @param event
+ * Event to process.
+ * @param traceState
+ * State of the trace at the moment of the event.
+ */
+ public abstract void registerEvent(LttngEvent event, LttngTraceState traceState);
+
+ /**
+ * <h4>Register that a new node was created.</h4>
+ * <p>
+ * Must make sure the {@link #getChildren(FixedArray)} on the parent node
+ * will return the newly created node.
+ * </p>
+ *
+ * @param path
+ * Path of the new node.
+ */
+ protected abstract void registerName(final FixedArray<String> path);
+
+ /**
+ * <h4>Reset a node.</h4>
+ * <p>
+ * Work recursively.
+ * </p>
+ *
+ * @param path
+ * Path to the node.
+ */
+ public void reset(final FixedArray<String> path) {
+ for (StatisticsTreeNode node : getChildren(path)) {
+ reset(node.getPath());
+ fNodes.remove(node.getPath());
}
- /**
- * Indicate that the process is finishing.
- * @param event The event indicating the end of the process.
- * @param traceState State of the trace at that moment.
- */
- public abstract void process_exit(LttngEvent event, LttngTraceState traceState);
+ }
+
+ /**
+ * Indicate that the process is finishing.
+ *
+ * @param event
+ * The event indicating the end of the process.
+ * @param traceState
+ * State of the trace at that moment.
+ */
+ public abstract void process_exit(LttngEvent event, LttngTraceState traceState);
}
--- /dev/null
+KernelStatisticsData_CPUs=CPUs
+KernelStatisticsData_EventTypes=Event Types
+KernelStatisticsData_Functions=Functions
+KernelStatisticsData_Modes=Modes
+KernelStatisticsData_Processes=Processes
+KernelStatisticsData_SubModes=Submodes
+StatisticsData_UnknowProcess=Unknown process
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.timeframe;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.timeframe.messages"; //$NON-NLS-1$
+ public static String TimeFrameView_CurrentTime;
+ public static String TimeFrameView_WindowEndTime;
+ public static String TimeFrameView_WindowRange;
+ public static String TimeFrameView_WindowStartTime;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
* <b><u>TimeFrameView</u></b>
* <p>
* The TimeFrameView provides a set of spinners to monitor and set the start
- * time, end time, the current time interval and current time of the trace
- * set at the nanosecond level.
+ * time, end time, the current time interval and current time of the trace set
+ * at the nanosecond level.
* <p>
* It ensures that the following relations are always true:
* <p>
* <li>[ startTime >= start time of the trace ]
* <li>[ endTime <= end time of the trace ]
* <li>[ startTime <= currentTime <= endTime ]
- * <li>[ interval == (endTime - startTime) ]
- * </li>
+ * <li>[ interval == (endTime - startTime) ]</li>
* <p>
* It provides a slider to rapidly set the current time within the time range
* (i.e. between startTime and endTime).
public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.timeframe"; //$NON-NLS-1$
- // ========================================================================
+ // ------------------------------------------------------------------------
// TimeFrameView
- // ========================================================================
+ // ------------------------------------------------------------------------
// The event log timestamp characteristics
private TmfTimestamp fTraceStartTime = new TmfTimestamp();
- private TmfTimestamp fTraceEndTime = new TmfTimestamp();
+ private TmfTimestamp fTraceEndTime = new TmfTimestamp();
+
+ private TmfTimestamp fCurrentTime = new TmfTimestamp();
- private TmfTimestamp fCurrentTime = new TmfTimestamp();
-
private TmfTimeRange fTraceTimeRange = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
- private TmfTimeRange fTraceSpan = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
+ private TmfTimeRange fTraceSpan = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
private byte fScale = 0;
// Labels
- private static final String START_TIME_LABEL = "Window Start Time";
- private static final String END_TIME_LABEL = "Window End Time";
- private static final String TIME_RANGE_LABEL = "Window Range";
- private static final String CURRENT_TIME_LABEL = "Current Time";
+ private static final String START_TIME_LABEL = Messages.TimeFrameView_WindowStartTime;
+ private static final String END_TIME_LABEL = Messages.TimeFrameView_WindowEndTime;
+ private static final String TIME_RANGE_LABEL = Messages.TimeFrameView_WindowRange;
+ private static final String CURRENT_TIME_LABEL = Messages.TimeFrameView_CurrentTime;
private static final int SLIDER_RANGE = 10000;
// The current experiment
TmfExperiment<LttngEvent> fExperiment = null;
- // notify external listeners may not be needed if the update originated
- // externally
- private boolean fupdateExternalListeners = true;
+ // notify external listeners may not be needed if the update originated externally
+ private boolean fupdateExternalListeners = true;
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
/**
* Constructor
*/
public TimeFrameView() {
- super("TimeFrameView");
+ super("TimeFrameView"); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
+ * .Composite)
*/
- @Override
- public void createPartControl(Composite parent) {
+ @Override
+ public void createPartControl(Composite parent) {
- // Set the view layout
- GridLayout layout = new GridLayout(4, true);
- parent.setLayout(layout);
+ // Set the view layout
+ GridLayout layout = new GridLayout(4, true);
+ parent.setLayout(layout);
- fStartGroup = new SpinnerGroup(this, parent, START_TIME_LABEL, fTraceTimeRange, fTraceStartTime);
- fEndGroup = new SpinnerGroup(this, parent, END_TIME_LABEL, fTraceTimeRange, fTraceEndTime);
- fRangeGroup = new SpinnerGroup(this, parent, TIME_RANGE_LABEL, fTraceTimeRange, fTraceEndTime);
- fCurrentGroup = new SpinnerGroup(this, parent, CURRENT_TIME_LABEL, fTraceTimeRange, fTraceStartTime);
+ fStartGroup = new SpinnerGroup(this, parent, START_TIME_LABEL, fTraceTimeRange, fTraceStartTime);
+ fEndGroup = new SpinnerGroup(this, parent, END_TIME_LABEL, fTraceTimeRange, fTraceEndTime);
+ fRangeGroup = new SpinnerGroup(this, parent, TIME_RANGE_LABEL, fTraceTimeRange, fTraceEndTime);
+ fCurrentGroup = new SpinnerGroup(this, parent, CURRENT_TIME_LABEL, fTraceTimeRange, fTraceStartTime);
- // Create the slider
- createSlider(parent);
+ // Create the slider
+ createSlider(parent);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
- @Override
- public void setFocus() {
- // TODO Auto-generated method stub
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
}
- // ========================================================================
+ // ------------------------------------------------------------------------
// Operators
- // ========================================================================
+ // ------------------------------------------------------------------------
/**
* One of the spinners has been updated. Synchronize the other widgets.
*/
public void synchTimeFrameWidgets(SpinnerGroup trigger) {
- boolean trangeUpdated = false;
-
- // Collect the data
- TmfTimestamp startTime = fStartGroup.getCurrentTime();
- TmfTimestamp endTime = fEndGroup.getCurrentTime();
- TmfTimestamp timeRange = fRangeGroup.getCurrentTime();
- TmfTimestamp currentTime = fCurrentGroup.getCurrentTime();
-
- // If startTime was set beyond endTime, adjust endTime and interval
- if (trigger == fStartGroup) {
- if (startTime.compareTo(endTime, false) > 0) {
- endTime = startTime;
- trangeUpdated = true;
- }
- }
-
- // If endTime was set beyond startTime, adjust startTime and interval
- if (trigger == fEndGroup) {
- if (endTime.compareTo(startTime, false) < 0) {
- startTime = endTime;
- trangeUpdated = true;
- }
- }
-
- // If timeRange was set, adjust endTime
- if (trigger == fRangeGroup) {
- long start = startTime.getValue();
- long span = timeRange.getValue();
- TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0);
- if (ts.compareTo(fTraceEndTime, false) > 0) {
- ts = fTraceEndTime.synchronize(fTraceEndTime.getValue(), startTime.getScale());
- }
- endTime = ts;
- trangeUpdated = true;
- }
-
- // Compute the new time range
- TmfTimeRange subrange = new TmfTimeRange(startTime, endTime);
- byte scale = startTime.getScale();
- TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime, scale), scale, 0);
-
- // Update the spinner groups
- fStartGroup.setContent(fTraceTimeRange, startTime);
- fEndGroup.setContent(fTraceTimeRange, endTime);
- fRangeGroup.setContent(fTraceSpan, interval);
- fCurrentGroup.setContent(subrange, currentTime);
-
- updateSlider(subrange, currentTime);
- // Notify other views, only if the update originated from this view
- if (fupdateExternalListeners) {
- if (!fCurrentTime.equals(currentTime)) {
- fCurrentTime = currentTime;
- broadcast(new TmfTimeSynchSignal(this, currentTime));
- }
-
- // Notify the views if the time range has been impacted
- if (trangeUpdated) {
- TmfTimeRange trange = new TmfTimeRange(startTime, endTime);
- broadcast(new TmfRangeSynchSignal(this, trange, currentTime));
- }
- }
+ boolean trangeUpdated = false;
+
+ // Collect the data
+ TmfTimestamp startTime = fStartGroup.getCurrentTime();
+ TmfTimestamp endTime = fEndGroup.getCurrentTime();
+ TmfTimestamp timeRange = fRangeGroup.getCurrentTime();
+ TmfTimestamp currentTime = fCurrentGroup.getCurrentTime();
+
+ // If startTime was set beyond endTime, adjust endTime and interval
+ if (trigger == fStartGroup) {
+ if (startTime.compareTo(endTime, false) > 0) {
+ endTime = startTime;
+ trangeUpdated = true;
+ }
+ }
+
+ // If endTime was set beyond startTime, adjust startTime and interval
+ if (trigger == fEndGroup) {
+ if (endTime.compareTo(startTime, false) < 0) {
+ startTime = endTime;
+ trangeUpdated = true;
+ }
+ }
+
+ // If timeRange was set, adjust endTime
+ if (trigger == fRangeGroup) {
+ long start = startTime.getValue();
+ long span = timeRange.getValue();
+ TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0);
+ if (ts.compareTo(fTraceEndTime, false) > 0) {
+ ts = fTraceEndTime.synchronize(fTraceEndTime.getValue(), startTime.getScale());
+ }
+ endTime = ts;
+ trangeUpdated = true;
+ }
+
+ // Compute the new time range
+ TmfTimeRange subrange = new TmfTimeRange(startTime, endTime);
+ byte scale = startTime.getScale();
+ TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime, scale), scale, 0);
+
+ // Update the spinner groups
+ fStartGroup.setContent(fTraceTimeRange, startTime);
+ fEndGroup.setContent(fTraceTimeRange, endTime);
+ fRangeGroup.setContent(fTraceSpan, interval);
+ fCurrentGroup.setContent(subrange, currentTime);
+
+ updateSlider(subrange, currentTime);
+ // Notify other views, only if the update originated from this view
+ if (fupdateExternalListeners) {
+ if (!fCurrentTime.equals(currentTime)) {
+ fCurrentTime = currentTime;
+ broadcast(new TmfTimeSynchSignal(this, currentTime));
+ }
+
+ // Notify the views if the time range has been impacted
+ if (trangeUpdated) {
+ TmfTimeRange trange = new TmfTimeRange(startTime, endTime);
+ broadcast(new TmfRangeSynchSignal(this, trange, currentTime));
+ }
+ }
}
- // ========================================================================
+ // ------------------------------------------------------------------------
// Slider Handling
- // ========================================================================
+ // ------------------------------------------------------------------------
/**
* @param parent
*/
private void createSlider(Composite parent) {
- fSlider = new Slider(parent, SWT.SMOOTH | SWT.FILL);
- fSlider.setMinimum(0);
- fSlider.setMaximum(SLIDER_RANGE + fSlider.getThumb());
- fSlider.setIncrement(SLIDER_RANGE / 100);
- fSlider.setPageIncrement(SLIDER_RANGE / 10);
- fSlider.setSelection(0);
-
- GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false);
- gridData.horizontalAlignment = SWT.FILL;
- gridData.horizontalSpan = 4;
- fSlider.setLayoutData(gridData);
-
- fSlider.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int ratio = fSlider.getSelection();
- TmfTimestamp span = fCurrentGroup.getSpan();
- long value = span.getValue() * ratio / SLIDER_RANGE;
- TmfTimestamp start = fCurrentGroup.getStartTime();
- TmfTimestamp current = new TmfTimestamp(start.getValue() + value, start.getScale(), 0);
- fCurrentGroup.setValue(current);
- }
- });
+ fSlider = new Slider(parent, SWT.SMOOTH | SWT.FILL);
+ fSlider.setMinimum(0);
+ fSlider.setMaximum(SLIDER_RANGE + fSlider.getThumb());
+ fSlider.setIncrement(SLIDER_RANGE / 100);
+ fSlider.setPageIncrement(SLIDER_RANGE / 10);
+ fSlider.setSelection(0);
+
+ GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false);
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.horizontalSpan = 4;
+ fSlider.setLayoutData(gridData);
+
+ fSlider.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int ratio = fSlider.getSelection();
+ TmfTimestamp span = fCurrentGroup.getSpan();
+ long value = span.getValue() * ratio / SLIDER_RANGE;
+ TmfTimestamp start = fCurrentGroup.getStartTime();
+ TmfTimestamp current = new TmfTimestamp(start.getValue() + value, start.getScale(), 0);
+ fCurrentGroup.setValue(current);
+ }
+ });
}
*/
private void updateSlider(TmfTimeRange range, TmfTimestamp timestamp) {
- // Ignore update if disposed
- if (fSlider.isDisposed()) return;
-
- // Determine the new relative position
- byte scale = range.getEndTime().getScale();
- long total = range.getStartTime().getAdjustment(range.getEndTime(), scale);
- long relative = range.getStartTime().getAdjustment(timestamp, scale);
-
- // Set the slider value
- final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0;
-
- // Update the slider on the UI thread
- long current = fSlider.getSelection();
- if (position != current) {
- fSlider.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- fSlider.setSelection((int) position);
- }
- });
- }
+ // Ignore update if disposed
+ if (fSlider.isDisposed())
+ return;
+
+ // Determine the new relative position
+ byte scale = range.getEndTime().getScale();
+ long total = range.getStartTime().getAdjustment(range.getEndTime(), scale);
+ long relative = range.getStartTime().getAdjustment(timestamp, scale);
+
+ // Set the slider value
+ final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0;
+
+ // Update the slider on the UI thread
+ long current = fSlider.getSelection();
+ if (position != current) {
+ fSlider.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ fSlider.setSelection((int) position);
+ }
+ });
+ }
}
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return "[TimeFrameView]";
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ @SuppressWarnings("nls")
+ public String toString() {
+ return "[TimeFrameView]";
+ }
- // ========================================================================
- // TMF Signal Handling
- // ========================================================================
+ // ------------------------------------------------------------------------
+ // Signal Handling
+ // ------------------------------------------------------------------------
- /**
+ /**
* @param signal
*/
@SuppressWarnings("unchecked")
@TmfSignalHandler
public void experimentSelected(TmfExperimentSelectedSignal<LttngEvent> signal) {
- // Update the trace reference
- fExperiment = (TmfExperiment<LttngEvent>) signal.getExperiment();
+ // Update the trace reference
+ fExperiment = (TmfExperiment<LttngEvent>) signal.getExperiment();
- // Update the time frame
- fTraceTimeRange = fExperiment.getTimeRange();
- fTraceStartTime = fTraceTimeRange.getStartTime();
- fTraceEndTime = fTraceTimeRange.getEndTime();
- fScale = fTraceStartTime.getScale();
+ // Update the time frame
+ fTraceTimeRange = fExperiment.getTimeRange();
+ fTraceStartTime = fTraceTimeRange.getStartTime();
+ fTraceEndTime = fTraceTimeRange.getEndTime();
+ fScale = fTraceStartTime.getScale();
- // Update the widgets
- fStartGroup.setContent(fTraceTimeRange, fTraceStartTime);
- fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
- fCurrentGroup.setContent(fTraceTimeRange, fTraceStartTime);
+ // Update the widgets
+ fStartGroup.setContent(fTraceTimeRange, fTraceStartTime);
+ fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
+ fCurrentGroup.setContent(fTraceTimeRange, fTraceStartTime);
- fCurrentTime = fTraceStartTime;
+ fCurrentTime = fTraceStartTime;
- TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
- fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
-// fRangeGroup.setContent(fTraceSpan, delta);
- TmfTimestamp start = new TmfTimestamp(1, (byte) -1, 0);
- fRangeGroup.setContent(fTraceSpan, start);
+ TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+ fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
+ // fRangeGroup.setContent(fTraceSpan, delta);
+ TmfTimestamp start = new TmfTimestamp(1, (byte) -1, 0);
+ fRangeGroup.setContent(fTraceSpan, start);
}
/**
@TmfSignalHandler
public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
- // Update the time frame
-// fTraceTimeRange = signal.getTrace().getTimeRange();
- fTraceTimeRange = signal.getExperiment().getTimeRange();
- fTraceStartTime = fTraceTimeRange.getStartTime();
- fTraceEndTime = fTraceTimeRange.getEndTime();
- fScale = fTraceStartTime.getScale();
-
- // Update the widgets
- fStartGroup.setContent(fTraceTimeRange, fStartGroup.getCurrentTime());
- fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
- fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime());
-
- TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
- fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
- fRangeGroup.setContent(fTraceSpan, delta);
+ // Update the time frame
+ // fTraceTimeRange = signal.getTrace().getTimeRange();
+ fTraceTimeRange = signal.getExperiment().getTimeRange();
+ fTraceStartTime = fTraceTimeRange.getStartTime();
+ fTraceEndTime = fTraceTimeRange.getEndTime();
+ fScale = fTraceStartTime.getScale();
+
+ // Update the widgets
+ fStartGroup.setContent(fTraceTimeRange, fStartGroup.getCurrentTime());
+ fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
+ fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime());
+
+ TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+ fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
+ fRangeGroup.setContent(fTraceSpan, delta);
}
- /**
- * @param signal
- */
- @TmfSignalHandler
- public void currentTimeRangeUpdated(TmfRangeSynchSignal signal) {
- if (signal.getSource() != this) {
- // Update the time frame
- TmfTimeRange selTimeRange = signal.getCurrentRange();
- TmfTimestamp selStart = selTimeRange.getStartTime().synchronize(0,
- fScale);
- TmfTimestamp selEnd = selTimeRange.getEndTime().synchronize(0,
- fScale);
-
- fupdateExternalListeners = false;
- // Update the widgets and prevent broadcast notifications to
- // the views which have been notified already.
- {
- fStartGroup.setContent(fTraceTimeRange, selStart);
- fEndGroup.setContent(fTraceTimeRange, selEnd);
-
- TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment(
- selEnd, fScale), fScale, 0);
-
- fRangeGroup.setContent(fTraceSpan, delta);
- }
-
- // restore the external notification flag
- fupdateExternalListeners = true;
+ /**
+ * @param signal
+ */
+ @TmfSignalHandler
+ public void currentTimeRangeUpdated(TmfRangeSynchSignal signal) {
+ if (signal.getSource() != this) {
+ // Update the time frame
+ TmfTimeRange selTimeRange = signal.getCurrentRange();
+ TmfTimestamp selStart = selTimeRange.getStartTime().synchronize(0, fScale);
+ TmfTimestamp selEnd = selTimeRange.getEndTime().synchronize(0, fScale);
+
+ fupdateExternalListeners = false;
+ // Update the widgets and prevent broadcast notifications to
+ // the views which have been notified already.
+ {
+ fStartGroup.setContent(fTraceTimeRange, selStart);
+ fEndGroup.setContent(fTraceTimeRange, selEnd);
+
+ TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment(selEnd, fScale), fScale, 0);
+
+ fRangeGroup.setContent(fTraceSpan, delta);
+ }
+
+ // restore the external notification flag
+ fupdateExternalListeners = true;
- }
}
+ }
/**
* @param signal
*/
@TmfSignalHandler
public void currentTimeUpdated(TmfTimeSynchSignal signal) {
- if (signal.getSource() != this) {
- // prevent loop to external notifications
- fupdateExternalListeners = false;
- fCurrentTime = signal.getCurrentTime().synchronize(0, fStartGroup.getCurrentTime().getScale());
- if (fStartGroup.getCurrentTime().compareTo(fCurrentTime, false) > 0) {
- fStartGroup.setContent(new TmfTimeRange(fCurrentTime, fEndGroup.getCurrentTime()), fCurrentTime);
- }
- if (fEndGroup.getCurrentTime().compareTo(fCurrentTime, false) < 0) {
- fEndGroup.setContent(new TmfTimeRange(fStartGroup.getCurrentTime(), fCurrentTime), fCurrentTime);
- }
- fCurrentGroup.setContent(null, fCurrentTime);
- updateSlider(fCurrentGroup.getTimeRange(), fCurrentTime);
-
- // Enable external notifications
- fupdateExternalListeners = true;
- }
+ if (signal.getSource() != this) {
+ // prevent loop to external notifications
+ fupdateExternalListeners = false;
+ fCurrentTime = signal.getCurrentTime().synchronize(0, fStartGroup.getCurrentTime().getScale());
+ if (fStartGroup.getCurrentTime().compareTo(fCurrentTime, false) > 0) {
+ fStartGroup.setContent(new TmfTimeRange(fCurrentTime, fEndGroup.getCurrentTime()), fCurrentTime);
+ }
+ if (fEndGroup.getCurrentTime().compareTo(fCurrentTime, false) < 0) {
+ fEndGroup.setContent(new TmfTimeRange(fStartGroup.getCurrentTime(), fCurrentTime), fCurrentTime);
+ }
+ fCurrentGroup.setContent(null, fCurrentTime);
+ updateSlider(fCurrentGroup.getTimeRange(), fCurrentTime);
+
+ // Enable external notifications
+ fupdateExternalListeners = true;
+ }
}
}
\ No newline at end of file
--- /dev/null
+TimeFrameView_CurrentTime=Current Time
+TimeFrameView_WindowEndTime=Window End Time
+TimeFrameView_WindowRange=Window Range
+TimeFrameView_WindowStartTime=Window Start Time