use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class ImportHandler method execute.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
CommandParameter param;
fLock.lock();
try {
param = fParam;
if (param == null) {
return null;
}
param = param.clone();
} finally {
fLock.unlock();
}
// create default project
IProject project = TmfProjectRegistry.createProject(RemoteFetchLogWizardRemotePage.DEFAULT_REMOTE_PROJECT_NAME, null, null);
if (param.getSession().isLiveTrace()) {
importLiveTrace(new LttngRelaydConnectionInfo(param.getSession().getLiveUrl(), param.getSession().getLivePort(), param.getSession().getName()), project);
return null;
} else if (param.getSession().isStreamedTrace()) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
String notify = store.getString(NOTIFY_IMPORT_STREAMED_PREF_KEY);
if (!MessageDialogWithToggle.ALWAYS.equals(notify)) {
MessageDialogWithToggle.openInformation(window.getShell(), null, Messages.TraceControl_ImportDialogStreamedTraceNotification, Messages.TraceControl_ImportDialogStreamedTraceNotificationToggle, false, store, NOTIFY_IMPORT_STREAMED_PREF_KEY);
}
// Streamed trace
TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
TmfTraceFolder traceFolder = projectElement.getTracesFolder();
ImportTraceWizard wizard = new ImportTraceWizard();
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder));
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.open();
return null;
}
// Generate the profile
TraceSessionComponent session = param.getSession();
// $NON-NLS-1$
RemoteImportProfileElement profile = new RemoteImportProfileElement(null, "LTTng Remote Traces");
RemoteSystemProxy proxy = session.getTargetNode().getRemoteSystemProxy();
IRemoteConnection rc = proxy.getRemoteConnection();
String name = rc.getName();
if (!rc.hasService(IRemoteConnectionHostService.class)) {
return null;
}
String scheme = rc.getConnectionType().getScheme();
IRemoteConnectionHostService hostService = checkNotNull(rc.getService(IRemoteConnectionHostService.class));
String address = hostService.getHostname();
String user = hostService.getUsername();
int port = hostService.getPort();
URI remoteUri;
try {
remoteUri = new URI(scheme, user, address, port, null, null, null);
} catch (URISyntaxException e) {
return false;
}
RemoteImportConnectionNodeElement connection = new RemoteImportConnectionNodeElement(profile, name, remoteUri.toString());
String pathString = session.isSnapshotSession() ? session.getSnapshotInfo().getSnapshotPath() : session.getSessionPath();
IPath path = new Path(pathString);
RemoteImportTraceGroupElement group = new RemoteImportTraceGroupElement(connection, path.toString());
group.setRecursive(true);
// $NON-NLS-1$//$NON-NLS-2$
TracePackageElement element = new TracePackageTraceElement(group, "", "");
// $NON-NLS-1$
new TracePackageFilesElement(element, ".*");
String experimentName = path.lastSegment();
if (!experimentName.startsWith(session.getName())) {
experimentName = session.getName();
}
RemoteFetchLogWizard wizard = new RemoteFetchLogWizard(profile, experimentName);
wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.open();
return null;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class RemoteFetchLogWizardRemotePage method createElementViewer.
@Override
protected void createElementViewer(Composite compositeParent) {
super.createElementViewer(compositeParent);
CheckboxTreeViewer elementViewer = getElementViewer();
elementViewer.setLabelProvider(new TracePackageLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof TracePackageTraceElement) {
for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
if (files instanceof TracePackageFilesElement) {
return ((TracePackageFilesElement) files).getFileName();
}
}
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof TracePackageTraceElement) {
for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
return files.getImage();
}
}
return super.getImage(element);
}
});
elementViewer.setComparator(new ViewerComparator() {
@Override
public int category(Object element) {
if (element instanceof TracePackageTraceElement) {
return 1;
}
return 0;
}
});
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class RemoteProfilesPreferencePage method newTraceGroup.
private RemoteImportTraceGroupElement newTraceGroup(TracePackageElement parent, TracePackageElement previous) {
RemoteImportTraceGroupElement traceGroup = new RemoteImportTraceGroupElement(null, DEFAULT_ROOT_IMPORT_PATH);
TracePackageTraceElement trace = new TracePackageTraceElement(traceGroup, DEFAULT_IMPORT_NAME, null);
new TracePackageFilesElement(trace, DEFAULT_FILE_PATTERN);
int index = previous == null ? parent.getChildren().length : parent.indexOf(previous) + 1;
parent.addChild(index, traceGroup);
newElementAdded(traceGroup);
return traceGroup;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class RemoteProfilesPreferencePage method newProfile.
private RemoteImportProfileElement newProfile(TracePackageElement previous) {
RemoteImportProfileElement profile = new RemoteImportProfileElement(null, RemoteMessages.RemoteProfilesPreferencePage_DefaultProfileName);
RemoteImportConnectionNodeElement node = new RemoteImportConnectionNodeElement(profile, RemoteMessages.RemoteProfilesPreferencePage_DefaultConnectionNodeName, RemoteMessages.RemoteProfilesPreferencePage_DefaultConnectionNodeURI);
RemoteImportTraceGroupElement traceGroup = new RemoteImportTraceGroupElement(node, DEFAULT_ROOT_IMPORT_PATH);
TracePackageTraceElement trace = new TracePackageTraceElement(traceGroup, DEFAULT_IMPORT_NAME, null);
new TracePackageFilesElement(trace, DEFAULT_FILE_PATTERN);
int index = previous == null ? fProfiles.size() : fProfiles.indexOf(previous) + 1;
fProfiles.add(index, profile);
newElementAdded(profile);
return profile;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class ExportTracePackageWizardPage method createElementViewerInput.
@Override
protected Object createElementViewerInput() {
List<TracePackageTraceElement> traceElements = new ArrayList<>();
for (TmfCommonProjectElement projectElement : fSelectedTraces) {
TracePackageTraceElement traceElement;
if (projectElement instanceof TmfExperimentElement) {
TmfExperimentElement experimentElement = (TmfExperimentElement) projectElement;
traceElement = new TracePackageExperimentElement(null, experimentElement);
for (TmfTraceElement expTrace : experimentElement.getTraces()) {
((TracePackageExperimentElement) traceElement).addExpTrace(expTrace.getElementPath());
}
} else {
traceElement = new TracePackageTraceElement(null, projectElement);
}
// Trace files
TracePackageFilesElement filesElement = new TracePackageFilesElement(traceElement, projectElement.getResource());
filesElement.setChecked(true);
// Supplementary files
try {
String supplementaryFolder = projectElement.getResource().getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
TracePackageSupplFilesElement suppFilesElement = new TracePackageSupplFilesElement(null);
IResource[] supplementaryResources = projectElement.getSupplementaryResources();
for (IResource res : supplementaryResources) {
String name = supplementaryFolder == null ? res.getName() : res.getLocation().makeRelativeTo(new Path(supplementaryFolder)).toString();
new TracePackageSupplFileElement(res, name, suppFilesElement);
}
if (supplementaryFolder != null) {
// If the supplementary folder path is in a shadow project,
// the resources must be taken from the parent project.
IFolder projectSupplementaryFolder = projectElement.getProject().getSupplementaryFolder();
IPath path = new Path(supplementaryFolder).append(TmfCommonConstants.TRACE_PROPERTIES_FOLDER);
IFolder propertiesFolder = projectSupplementaryFolder.getFolder(path.makeRelativeTo(projectSupplementaryFolder.getLocation()));
if (propertiesFolder.exists()) {
for (IResource res : propertiesFolder.members()) {
String name = res.getLocation().makeRelativeTo(new Path(supplementaryFolder)).toString();
new TracePackageSupplFileElement(res, name, suppFilesElement);
}
}
}
if (suppFilesElement.getChildren().length > 0) {
traceElement.addChild(suppFilesElement);
}
} catch (CoreException e) {
// Should not happen
// $NON-NLS-1$
Activator.getDefault().logError("Error finding supplementary files", e);
}
// Bookmarks
IFile bookmarksFile = projectElement.getBookmarksFile();
if (bookmarksFile != null && bookmarksFile.exists()) {
IMarker[] findMarkers;
try {
findMarkers = bookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
if (findMarkers.length > 0) {
new TracePackageBookmarkElement(traceElement, null);
}
} catch (CoreException e) {
// Should not happen since we just checked bookmarksFile.exists() but log it just in case
// $NON-NLS-1$
Activator.getDefault().logError("Error finding bookmarks", e);
}
}
traceElements.add(traceElement);
}
return traceElements.toArray(new TracePackageTraceElement[] {});
}
Aggregations