Search in sources :

Example 6 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class NotificationView method saveLaunchElementAs.

/**
 * Saves the contents of a tree starting at the provided launch config node.
 *
 * @param shell the shell to be used to display dialogs.
 * @param actualInput the launch configuration to start from.
 */
public static void saveLaunchElementAs(final Shell shell, final ITreeLeaf actualInput) {
    final FileDialog dialog = new FileDialog(shell, SWT.NONE);
    dialog.setFilterExtensions(new String[] { "log" });
    final String filePath = dialog.open();
    if (null == filePath) {
        return;
    }
    final File file = new File(filePath);
    if (file.exists()) {
        if (!file.canWrite()) {
            ErrorDialog.openError(shell, "Read-only file", "The file is read-only, please choose another file", Status.OK_STATUS);
            return;
        }
    } else {
        try {
            file.createNewFile();
        } catch (IOException e) {
            ErrorDialog.openError(shell, "Can not create file", "The file could not be created and will not be saved", Status.OK_STATUS);
            return;
        }
    }
    if (null == actualInput || !(actualInput instanceof LaunchElement)) {
        // nothing or wrong kind of element selected
        return;
    }
    PrintWriter out = null;
    try {
        out = new PrintWriter(new FileWriter(file));
        final List<ITreeLeaf> children = ((LaunchElement) actualInput).children();
        for (ITreeLeaf aChildren : children) {
            final BaseExecutor executor = ((MainControllerElement) aChildren).executor();
            if (null != executor) {
                List<Notification> tempList = executor.notifications();
                for (Notification aTempList : tempList) {
                    out.println(aTempList.toString());
                }
            }
        }
    } catch (IOException e) {
        ErrorDialog.openError(shell, "Can not write the file", "An error occured while writing to the file\n" + filePath, Status.OK_STATUS);
        return;
    } finally {
        IOUtils.closeQuietly(out);
    }
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final IFile[] outputFiles = root.findFilesForLocationURI(URIUtil.toURI(filePath));
    ResourceUtils.refreshResources(Arrays.asList(outputFiles));
}
Also used : IFile(org.eclipse.core.resources.IFile) FileWriter(java.io.FileWriter) IOException(java.io.IOException) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) FileDialog(org.eclipse.swt.widgets.FileDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File) LaunchElement(org.eclipse.titan.executor.views.executormonitor.LaunchElement) PrintWriter(java.io.PrintWriter) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Example 7 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class BaseExecutor method startSession.

/**
 * This is called as the last command of the launch of an Executor. It tries to connect a main controller root to the launch that started, and the
 * executor itself.
 * <p>
 * This is not a Main Controller start session.
 *
 * @param launch the ILaunch instance to start the session with.
 */
public void startSession(final ILaunch launch) {
    launchStarted = launch;
    deleteLogFiles();
    if (LaunchStorage.getLaunchElementMap().containsKey(launch)) {
        mainControllerRoot = new MainControllerElement(MAIN_CONTROLLER, this);
        LaunchStorage.getLaunchElementMap().get(launch).addChildToEnd(mainControllerRoot);
    }
    ExecutorStorage.getExecutorMap().put(launch, this);
    if (Activator.getMainView() != null) {
        Activator.getMainView().expandToLevel(mainControllerRoot, 0);
        Activator.getMainView().refreshAll();
    }
    saveLastTimeUsageInfo();
}
Also used : MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Aggregations

MainControllerElement (org.eclipse.titan.executor.views.executormonitor.MainControllerElement)7 BaseExecutor (org.eclipse.titan.executor.executors.BaseExecutor)4 ITreeLeaf (org.eclipse.titan.executor.executors.ITreeLeaf)4 LaunchElement (org.eclipse.titan.executor.views.executormonitor.LaunchElement)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 InformationElement (org.eclipse.titan.executor.views.executormonitor.InformationElement)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 IFile (org.eclipse.core.resources.IFile)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 ComponentStruct (org.eclipse.titan.executor.jni.ComponentStruct)1 HostStruct (org.eclipse.titan.executor.jni.HostStruct)1 JNIMiddleWare (org.eclipse.titan.executor.jni.JNIMiddleWare)1 McStateEnum (org.eclipse.titan.executor.jni.McStateEnum)1 QualifiedName (org.eclipse.titan.executor.jni.QualifiedName)1