Search in sources :

Example 1 with ImportTraceWizard

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard 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;
}
Also used : RemoteImportConnectionNodeElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement) IRemoteConnectionHostService(org.eclipse.remote.core.IRemoteConnectionHostService) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) URISyntaxException(java.net.URISyntaxException) RemoteImportProfileElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement) URI(java.net.URI) ImportTraceWizard(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) RemoteFetchLogWizard(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.RemoteFetchLogWizard) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TraceSessionComponent(org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent) IPath(org.eclipse.core.runtime.IPath) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) RemoteImportTraceGroupElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement) IProject(org.eclipse.core.resources.IProject) RemoteSystemProxy(org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy) LttngRelaydConnectionInfo(org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConnectionInfo) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with ImportTraceWizard

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard in project tracecompass by tracecompass.

the class AbstractStandardImportWizardTest method openImportWizard.

/**
 * Open the import wizard
 */
public void openImportWizard() {
    fWizard = new ImportTraceWizard();
    UIThreadRunnable.asyncExec(new VoidResult() {

        @Override
        public void run() {
            final IWorkbench workbench = PlatformUI.getWorkbench();
            // Fire the Import Trace Wizard
            if (workbench != null) {
                final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                Shell shell = activeWorkbenchWindow.getShell();
                assertNotNull(shell);
                ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
                WizardDialog dialog = new WizardDialog(shell, fWizard);
                dialog.open();
            }
        }
    });
    fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ImportTraceWizard(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 3 with ImportTraceWizard

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard in project tracecompass by tracecompass.

the class StandardImportAndReadSmokeTest method openImportWizard.

private static void openImportWizard() {
    fWizard = new ImportTraceWizard();
    UIThreadRunnable.asyncExec(new VoidResult() {

        @Override
        public void run() {
            final IWorkbench workbench = PlatformUI.getWorkbench();
            // Fire the Import Trace Wizard
            if (workbench != null) {
                final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                Shell shell = activeWorkbenchWindow.getShell();
                assertNotNull(shell);
                ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
                WizardDialog dialog = new WizardDialog(shell, fWizard);
                dialog.open();
            }
        }
    });
    fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ImportTraceWizard(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with ImportTraceWizard

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard in project tracecompass by tracecompass.

the class ImportTraceHandler method execute.

// ------------------------------------------------------------------------
// Execution
// ------------------------------------------------------------------------
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ImportTraceWizard w = new ImportTraceWizard();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    // Menu Selection is only not null for context-sensitive menu
    ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
    IStructuredSelection sec = StructuredSelection.EMPTY;
    // Only use the selection if handler is called from context-sensitive menu
    if ((menuSelection != null) && (currentSelection instanceof IStructuredSelection)) {
        sec = (IStructuredSelection) currentSelection;
    }
    w.init(PlatformUI.getWorkbench(), sec);
    WizardDialog dialog = new WizardDialog(window.getShell(), w);
    dialog.open();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ImportTraceWizard(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

WizardDialog (org.eclipse.jface.wizard.WizardDialog)4 ImportTraceWizard (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 Shell (org.eclipse.swt.widgets.Shell)2 VoidResult (org.eclipse.swtbot.swt.finder.results.VoidResult)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 IWorkbench (org.eclipse.ui.IWorkbench)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IRemoteConnection (org.eclipse.remote.core.IRemoteConnection)1 IRemoteConnectionHostService (org.eclipse.remote.core.IRemoteConnectionHostService)1 LttngRelaydConnectionInfo (org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConnectionInfo)1 TraceSessionComponent (org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent)1