Build tool window: use parallel builds view instead of the grouped tabbed view for taslk running

This commit is contained in:
Vladislav.Soroka
2017-09-18 13:11:25 +03:00
parent 7345e8b0ef
commit 4820293f5d
9 changed files with 154 additions and 34 deletions
@@ -52,10 +52,8 @@ import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
@@ -118,6 +116,10 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
return false;
}
protected Map<BuildInfo, BuildView> getBuildsMap() {
return Collections.unmodifiableMap(myViewMap);
}
@Override
public void onEvent(BuildEvent event) {
List<Runnable> runnables = new SmartList<>();
@@ -261,10 +263,11 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
consoleComponent.add(ActionManager.getInstance().createActionToolbar(
"BuildView", toolbarActions, false).getComponent(), BorderLayout.WEST);
toolbarActions.addAll(buildView.createConsoleActions());
Icon contentIcon = getContentIcon();
myContent = myBuildContentManager.addTabbedContent(
consoleComponent, getViewName(),
buildInfo.getTitle() + ", " + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + " ",
AllIcons.CodeStyle.Gear, buildView);
contentIcon, buildView);
}
return buildView;
});
@@ -305,6 +308,7 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
else {
myThreeComponentsSplitter.setFirstComponent(null);
}
onBuildStart(buildInfo);
myProgressWatcher.addBuild(buildInfo);
//view.getPrimaryView().print("\r", ConsoleViewContentType.SYSTEM_OUTPUT);
@@ -389,6 +393,8 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
myContent = new ContentImpl(consoleComponent, getViewName(), true);
myContent.setCloseable(false);
Icon contentIcon = getContentIcon();
myContent.setIcon(contentIcon);
myBuildContentManager.addContent(myContent);
List<Runnable> postponedRunnables = new ArrayList<>(myPostponedRunnables);
@@ -408,6 +414,14 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
}
}
@Nullable
protected Icon getContentIcon() {
return null;
}
protected void onBuildStart(BuildDescriptor buildDescriptor) {
}
protected void onBuildFinish(BuildDescriptor buildDescriptor) {
BuildInfo buildInfo = (BuildInfo)buildDescriptor;
if (buildInfo.result instanceof FailureResult) {
@@ -126,22 +126,35 @@ public class BuildContentManagerImpl implements BuildContentManager {
for (Content existingContent : existingContents) {
existingContent.setDisplayName(existingContent.getTabName());
}
Content firstContent = contentManager.getContent(0);
assert firstContent != null;
if (!Build.equals(firstContent.getTabName())) {
if (contentManager.getContentCount() > 1) {
setIdLabelHidden(false);
}
else {
// we are going to adjust display name, so we need to ensure tab name is not retrieved based on display name
content.setTabName(content.getTabName());
content.setDisplayName(Build + ": " + content.getTabName());
}
String tabName = content.getTabName();
updateTabDisplayName(content, tabName);
});
}
public void updateTabDisplayName(Content content, String tabName) {
String displayName;
ContentManager contentManager = myToolWindow.getContentManager();
Content firstContent = contentManager.getContent(0);
assert firstContent != null;
if (!Build.equals(firstContent.getTabName())) {
if (contentManager.getContentCount() > 1) {
setIdLabelHidden(false);
displayName = tabName;
}
else {
setIdLabelHidden(true);
displayName = Build + ": " + tabName;
}
});
}
else {
displayName = tabName;
setIdLabelHidden(true);
}
if (!displayName.equals(content.getDisplayName())) {
// we are going to adjust display name, so we need to ensure tab name is not retrieved based on display name
content.setTabName(tabName);
content.setDisplayName(displayName);
}
}
@Override
@@ -188,9 +201,13 @@ public class BuildContentManagerImpl implements BuildContentManager {
public void startBuildNotified(Content content) {
Pair<Icon, AtomicInteger> pair = liveContentsMap.computeIfAbsent(content, c -> Pair.pair(c.getIcon(), new AtomicInteger(0)));
pair.second.incrementAndGet();
content.setIcon(ExecutionUtil.getLiveIndicator(pair.first));
myToolWindow.setIcon(ExecutionUtil.getLiveIndicator(AllIcons.Actions.Compile));
content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
content.setIcon(ExecutionUtil.getLiveIndicator(pair.first));
JComponent component = content.getComponent();
if (component != null) {
component.invalidate();
}
myToolWindow.setIcon(ExecutionUtil.getLiveIndicator(AllIcons.Actions.Compile));
}
public void finishBuildNotified(Content content) {
@@ -328,7 +328,7 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
if (event instanceof FinishBuildEvent) {
String aHint = event.getHint();
String time = DateFormatUtil.formatTime(event.getEventTime());
String time = DateFormatUtil.formatDateTime(event.getEventTime());
aHint = aHint == null ? " at " + time : aHint + " at " + time;
currentNode.setHint(aHint);
myProgressAnimator.stopMovie();
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2017 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.build;
import com.intellij.openapi.project.Project;
/**
* @author Vladislav.Soroka
*/
public class DebugTasksViewManager extends TasksViewManager {
public DebugTasksViewManager(Project project, BuildContentManager buildContentManager) {
super(project, buildContentManager);
}
@Override
public String getViewName() {
return "Debug";
}
}
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2017 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.build;
import com.intellij.openapi.project.Project;
/**
* @author Vladislav.Soroka
*/
public class RunTasksViewManager extends TasksViewManager {
public RunTasksViewManager(Project project, BuildContentManager buildContentManager) {
super(project, buildContentManager);
}
@Override
public String getViewName() {
return "Run";
}
}
@@ -15,24 +15,41 @@
*/
package com.intellij.build;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.ui.content.Content;
import javax.swing.*;
import java.util.Map;
/**
* @author Vladislav.Soroka
*/
public class TasksViewManager extends AbstractViewManager {
public abstract class TasksViewManager extends AbstractViewManager {
public TasksViewManager(Project project, BuildContentManager buildContentManager) {
super(project, buildContentManager);
}
@Override
public String getViewName() {
return "Run";
protected void onBuildStart(BuildDescriptor buildDescriptor) {
if (!isTabbedView()) {
BuildInfo buildInfo = (BuildInfo)buildDescriptor;
Content content = buildInfo.content;
Map<BuildInfo, BuildView> buildsMap = getBuildsMap();
String tabName = buildsMap.size() > 1 ? getViewName() : getViewName() + ": " + buildInfo.getTitle();
((BuildContentManagerImpl)myBuildContentManager).updateTabDisplayName(content, tabName);
}
}
@Override
protected boolean isTabbedView() {
return true;
return false;
}
@Override
protected Icon getContentIcon() {
return AllIcons.CodeStyle.Gear;
}
@Override
@@ -16,7 +16,7 @@
package com.intellij.build.internal;
import com.intellij.build.BuildContentManager;
import com.intellij.build.SyncViewManager;
import com.intellij.build.TasksViewManager;
import com.intellij.build.events.BuildEvent;
import com.intellij.build.events.FinishBuildEvent;
import com.intellij.openapi.project.Project;
@@ -24,11 +24,16 @@ import com.intellij.openapi.project.Project;
/**
* @author Vladislav.Soroka
*/
public class DummyTasksViewManager extends SyncViewManager {
public class DummyTasksViewManager extends TasksViewManager {
public DummyTasksViewManager(Project project, BuildContentManager buildContentManager) {
super(project, buildContentManager);
}
@Override
protected String getViewName() {
return "Tasks";
}
@Override
public void onEvent(BuildEvent event) {
if(event instanceof FinishBuildEvent) {
@@ -15,10 +15,7 @@
*/
package com.intellij.openapi.externalSystem.service.execution;
import com.intellij.build.BuildProgressListener;
import com.intellij.build.BuildViewManager;
import com.intellij.build.DefaultBuildDescriptor;
import com.intellij.build.TasksViewManager;
import com.intellij.build.*;
import com.intellij.build.events.BuildEvent;
import com.intellij.build.events.impl.FailureResultImpl;
import com.intellij.build.events.impl.FinishBuildEventImpl;
@@ -301,11 +298,14 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase i
Class<? extends BuildProgressListener> progressListenerClazz = task.getUserData(PROGRESS_LISTENER_KEY);
final BuildProgressListener progressListener = progressListenerClazz != null
? ServiceManager.getService(myProject, progressListenerClazz)
: ServiceManager.getService(myProject, TasksViewManager.class);
: myDebugPort > 0
? ServiceManager.getService(myProject, DebugTasksViewManager.class)
: ServiceManager.getService(myProject, RunTasksViewManager.class);
final String executionName = StringUtil.isNotEmpty(mySettings.getExecutionName())
? mySettings.getExecutionName()
: AbstractExternalSystemTaskConfigurationType.generateName(
: StringUtil.isNotEmpty(myConfiguration.getName())
? myConfiguration.getName() : AbstractExternalSystemTaskConfigurationType.generateName(
myProject, mySettings.getExternalSystemId(), mySettings.getExternalProjectPath(),
mySettings.getTaskNames(), mySettings.getExecutionName(), ": ", "");
+5 -2
View File
@@ -184,8 +184,11 @@
<projectService serviceInterface="com.intellij.build.SyncViewManager"
serviceImplementation="com.intellij.build.SyncViewManager"
testServiceImplementation="com.intellij.build.internal.DummySyncViewManager"/>
<projectService serviceInterface="com.intellij.build.TasksViewManager"
serviceImplementation="com.intellij.build.TasksViewManager"
<projectService serviceInterface="com.intellij.build.RunTasksViewManager"
serviceImplementation="com.intellij.build.RunTasksViewManager"
testServiceImplementation="com.intellij.build.internal.DummyTasksViewManager"/>
<projectService serviceInterface="com.intellij.build.DebugTasksViewManager"
serviceImplementation="com.intellij.build.DebugTasksViewManager"
testServiceImplementation="com.intellij.build.internal.DummyTasksViewManager"/>
<projectService serviceInterface="com.intellij.execution.runners.ExecutionEnvironmentProvider"