Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 68f750e98661ca626cb39ba562a4fd1c2d294701 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*******************************************************************************
 * Copyright (c) 2013 Red Hat.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat - initial implementation
 *******************************************************************************/

package org.eclipse.linuxtools.internal.systemtap.ui.consolelog.actions;

import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.Localization;
import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.ScriptConsole;
import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.ScriptConsole.ScriptConsoleObserver;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;

public class CloseStapConsoleAction extends ConsoleAction implements ScriptConsoleObserver {

    @Override
    public void run() {
        PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
		    if(null != console){
		        ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{console});
		    }
		});
    }

    public CloseStapConsoleAction(ScriptConsole fConsole) {
        super(fConsole,
                ConsoleLogPlugin.getDefault().getBundle().getEntry("icons/actions/progress_rem.gif"), //$NON-NLS-1$
                Localization.getString("action.closeConsole.name"), //$NON-NLS-1$
                Localization.getString("action.closeConsole.desc")); //$NON-NLS-1$
        setEnabled(false);
        console.addScriptConsoleObserver(this);
    }

    @Override
    public void runningStateChanged(boolean started, boolean stopped) {
        setEnabled(stopped);
    }

}

Back to the top