import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
+import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/** Parent directory for UST traces */
public static final String UST_PARENT_DIRECTORY = "ust"; //$NON-NLS-1$
+ /** Name of metadata file of trace */
+ public static final String METADATA_FILE_NAME = "metadata"; //$NON-NLS-1$
+
+ /** Default name of kernel traces */
+ public static final String DEFAULT_KERNEL_TRACE_NAME = "kernel"; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
* The parent where the new node should be added.
*/
private TraceSessionComponent fSession = null;
+
+ /**
+ * The name of the default project name
+ */
+ private String fDefaultProjectName = null;
/**
* List of traces to import
*/
fSession = session;
}
+ @Override
+ public void setDefaultProject(String defaultProject) {
+ fDefaultProjectName = defaultProject;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
try {
- if (fSession.isStreamedTrace()) {
- createLocalComposite();
- } else {
- createRemoteComposite();
- }
+ createRemoteComposite();
} catch (CoreException e) {
createErrorComposite(parent, e.fillInStackTrace());
return fDialogComposite;
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
- Button importLocallyButton = createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- if (fSession.isStreamedTrace()) {
- importLocallyButton.setText("&Next..."); //$NON-NLS-1$
- }
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
}
@Override
return;
}
- if (fSession.isStreamedTrace()) {
- // For streaming use standard import wizard from TMF because exact location
- // is not available (lttng backend limitation)
- IProject project = fProjects.get(fCombo.getSelectionIndex());
- ImportTraceWizard wizard = new ImportTraceWizard();
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- if (dialog.open() == Window.OK) {
- super.okPressed();
- }
- super.cancelPressed();
- return;
- }
-
IProject project = fProjects.get(fProjectIndex);
IFolder traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
Object[] checked = fFolderViewer.getCheckedElements();
for (int i = 0; i < checked.length; i++) {
IRemoteFile file = (IRemoteFile) checked[i];
+ if (!file.isDirectory() && file.getName().equals(METADATA_FILE_NAME)) {
+ IRemoteFile trace = file.getParentRemoteFile();
+ IRemoteFile parent = trace.getParentRemoteFile();
+ boolean isKernel = false;
+ if (trace.getName().equals(DEFAULT_KERNEL_TRACE_NAME)) {
+ isKernel = true;
+ }
+ StringBuffer traceName = new StringBuffer();
+ traceName.append(trace.getName());
+ traceName.insert(0, '-');
- // Only add actual trace directories
- if (file.isDirectory() && !UST_PARENT_DIRECTORY.equals(file.getName())) {
+ String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
- ImportFileInfo info = new ImportFileInfo(file, file.getName(), overwriteAll);
- String traceName = info.getLocalTraceName();
- IFolder folder = traceFolder.getFolder(traceName);
+ while (!parent.getAbsolutePath().equals(path)) {
+ traceName.insert(0, parent.getName());
+ traceName.insert(0, '-');
+ parent = parent.getParentRemoteFile();
+ }
+ traceName.insert(0, parent.getName());
+
+ ImportFileInfo info = new ImportFileInfo(trace, traceName.toString(), overwriteAll, isKernel);
+ IFolder folder = traceFolder.getFolder(traceName.toString());
// Verify if trace directory already exists (and not overwrite)
if (folder.exists() && !overwriteAll) {
// Ask user for overwrite or new name
IImportConfirmationDialog conf = TraceControlDialogFactory.getInstance().getImportConfirmationDialog();
- conf.setTraceName(traceName);
+ conf.setTraceName(traceName.toString());
// Don't add trace to list if dialog was cancelled.
if (conf.open() == Window.OK) {
IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem();
- IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSession.getSessionPath(), new NullProgressMonitor());
+ final String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
+ final IRemoteFile remoteFolder = fsss.getRemoteFileObject(path, new NullProgressMonitor());
+ // make sure that remote directory is read and not cached
+ remoteFolder.markStale(true, true);
fFolderViewer = new CheckboxTreeViewer(contextGroup, SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
});
fFolderViewer.setInput(remoteFolder);
+ Object[] children = remoteFolder.getContents(RemoteChildrenContentsType.getInstance());
+ // children can be null if there the path doesn't exist. This happens when a trace
+ // session hadn't been started and no output was created.
+ if (children != null) {
+ // Select all traces by default
+ for (int i = 0; i < children.length; i++) {
+ fFolderViewer.setSubtreeChecked(children[i], true);
+ }
+ }
+
Group projectGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
projectGroup.setText(Messages.TraceControl_ImportDialogProjectsGroupName);
layout = new GridLayout(1, true);
fProjects = new ArrayList<IProject>();
List<String> projectNames = new ArrayList<String>();
+
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if (project.isOpen() && project.hasNature(TmfProjectNature.ID)) {
fProjects.add(project);
fCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
fCombo.setItems(projectNames.toArray(new String[projectNames.size()]));
+ if (fDefaultProjectName != null) {
+ int select = projectNames.indexOf(fDefaultProjectName);
+ fCombo.select(select);
+ }
+
Group overrideGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
layout = new GridLayout(1, true);
overrideGroup.setLayout(layout);
getShell().setMinimumSize(new Point(500, 400));
}
- private void createLocalComposite() throws CoreException {
-
- Group projectGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- projectGroup.setText(Messages.TraceControl_ImportDialogProjectsGroupName);
- GridLayout layout = new GridLayout(1, true);
- projectGroup.setLayout(layout);
- projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fProjects = new ArrayList<IProject>();
- List<String> projectNames = new ArrayList<String>();
- for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
- if (project.isOpen() && project.hasNature(TmfProjectNature.ID)) {
- fProjects.add(project);
- projectNames.add(project.getName());
- }
- }
-
- fCombo = new CCombo(projectGroup, SWT.READ_ONLY);
- fCombo.setToolTipText(Messages.TraceControl_ImportDialogProjectsTooltip);
- fCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
- fCombo.setItems(projectNames.toArray(new String[projectNames.size()]));
-
- getShell().setMinimumSize(new Point(500, 50));
- }
}