mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
better place for stop_and_run button
This commit is contained in:
@@ -40,6 +40,7 @@ import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.runners.RestartAction;
|
||||
import com.intellij.execution.runners.StopAndRunAction;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ExecutionConsoleEx;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
@@ -263,9 +264,9 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
|
||||
RestartAction restarAction = new RestartAction(executor,
|
||||
myRunner, myRunContentDescriptor.getProcessHandler(), XDebuggerUIConstants.DEBUG_AGAIN_ICON,
|
||||
myRunContentDescriptor, myEnvironment);
|
||||
final RestartAction restarAction = new RestartAction(
|
||||
executor, myRunner, myRunContentDescriptor.getProcessHandler(), XDebuggerUIConstants.DEBUG_AGAIN_ICON, myRunContentDescriptor, myEnvironment
|
||||
);
|
||||
group.add(restarAction);
|
||||
restarAction.registerShortcut(myUi.getComponent());
|
||||
|
||||
@@ -284,6 +285,11 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
addActionToGroup(group, XDebuggerActions.RESUME);
|
||||
addActionToGroup(group, XDebuggerActions.PAUSE);
|
||||
addActionToGroup(group, IdeActions.ACTION_STOP_PROGRAM);
|
||||
final StopAndRunAction stopAndRunAction = new StopAndRunAction(
|
||||
executor, myRunner, myRunContentDescriptor.getProcessHandler(), XDebuggerUIConstants.STOP_AND_START_ICON, myRunContentDescriptor, myEnvironment
|
||||
);
|
||||
group.add(stopAndRunAction);
|
||||
stopAndRunAction.registerShortcut(myUi.getComponent());
|
||||
if (executionResult instanceof DefaultExecutionResult) {
|
||||
group.addAll(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -32,14 +32,11 @@ import javax.swing.*;
|
||||
* @author dyoma
|
||||
*/
|
||||
public class RestartAction extends AnAction implements DumbAware {
|
||||
private static final Icon STOP_AND_START_ICON = IconLoader.getIcon("/actions/restart.png");
|
||||
|
||||
private ProcessHandler myProcessHandler;
|
||||
private final ProgramRunner myRunner;
|
||||
private final RunContentDescriptor myDescriptor;
|
||||
private final Executor myExecutor;
|
||||
private final Icon myIcon;
|
||||
private final ExecutionEnvironment myEnvironment;
|
||||
protected final ProgramRunner myRunner;
|
||||
protected final Executor myExecutor;
|
||||
protected final ExecutionEnvironment myEnvironment;
|
||||
|
||||
public RestartAction(final Executor executor,
|
||||
final ProgramRunner runner,
|
||||
@@ -48,7 +45,6 @@ public class RestartAction extends AnAction implements DumbAware {
|
||||
final RunContentDescriptor descritor,
|
||||
final ExecutionEnvironment env) {
|
||||
super(null, null, icon);
|
||||
myIcon = icon;
|
||||
myEnvironment = env;
|
||||
getTemplatePresentation().setEnabled(false);
|
||||
myProcessHandler = processHandler;
|
||||
@@ -58,9 +54,13 @@ public class RestartAction extends AnAction implements DumbAware {
|
||||
// see IDEADEV-698
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ProcessHandler getProcessHandler() {
|
||||
return myProcessHandler;
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final DataContext dataContext = e.getDataContext();
|
||||
ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM).actionPerformed(e);
|
||||
doRestart(dataContext);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class RestartAction extends AnAction implements DumbAware {
|
||||
private void doRestart(final DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
if (ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId())) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final ExecutionEnvironment old = myEnvironment;
|
||||
@@ -92,9 +92,8 @@ public class RestartAction extends AnAction implements DumbAware {
|
||||
if (myProcessHandler != null && !isRunning) {
|
||||
myProcessHandler = null; // already terminated
|
||||
}
|
||||
presentation.setIcon(isRunning ? STOP_AND_START_ICON : myIcon);
|
||||
|
||||
presentation.setEnabled(true);
|
||||
presentation.setEnabled(!isRunning /*&& myRunner.canRun(, myProfile)*/ && !ExecutorRegistry.getInstance().isStarting(myEnvironment.getProject(), myExecutor.getId(), myRunner.getRunnerId()));
|
||||
}
|
||||
|
||||
public void registerShortcut(final JComponent component) {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
public class StopAndRunAction extends RestartAction{
|
||||
|
||||
public StopAndRunAction(Executor executor,
|
||||
ProgramRunner runner,
|
||||
ProcessHandler processHandler,
|
||||
Icon icon,
|
||||
RunContentDescriptor descritor, ExecutionEnvironment env) {
|
||||
super(executor, runner, processHandler, icon, descritor, env);
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM).actionPerformed(e);
|
||||
super.actionPerformed(e);
|
||||
}
|
||||
|
||||
|
||||
public void update(final AnActionEvent event) {
|
||||
super.update(event);
|
||||
final ProcessHandler handler = getProcessHandler();
|
||||
final boolean isRunning = handler != null && !handler.isProcessTerminated();
|
||||
final Presentation presentation = event.getPresentation();
|
||||
presentation.setEnabled(isRunning);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public class XDebuggerUIConstants {
|
||||
@NonNls public static final String EQ_TEXT = " = ";
|
||||
|
||||
public static final Icon DEBUG_AGAIN_ICON = IconLoader.getIcon("/actions/startDebugger.png");
|
||||
public static final Icon STOP_AND_START_ICON = IconLoader.getIcon("/actions/restart.png");
|
||||
public static final Icon FRAMES_TAB_ICON = IconLoader.getIcon("/debugger/frame.png");
|
||||
public static final Icon THREADS_TAB_ICON = IconLoader.getIcon("/debugger/threads.png");
|
||||
public static final Icon VARIABLES_TAB_ICON = IconLoader.getIcon("/debugger/value.png");
|
||||
|
||||
Reference in New Issue
Block a user