mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Build tool window: window/tabs live indicators
This commit is contained in:
@@ -25,6 +25,7 @@ import com.intellij.execution.ui.*;
|
||||
import com.intellij.execution.ui.actions.CloseAction;
|
||||
import com.intellij.execution.ui.layout.impl.RunnerLayoutUiImpl;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.actions.PinActiveTabAction;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -37,7 +38,6 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.impl.ContentImpl;
|
||||
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -239,9 +239,9 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
|
||||
consoleComponent.add(buildView, BorderLayout.CENTER);
|
||||
DefaultActionGroup toolbarActions = new DefaultActionGroup();
|
||||
consoleComponent.add(ActionManager.getInstance().createActionToolbar(
|
||||
"", toolbarActions, false).getComponent(), BorderLayout.WEST);
|
||||
"BuildView", toolbarActions, false).getComponent(), BorderLayout.WEST);
|
||||
toolbarActions.addAll(buildView.createConsoleActions());
|
||||
myBuildContentManager.addTabbedContent(
|
||||
myContent = myBuildContentManager.addTabbedContent(
|
||||
consoleComponent, getViewName(), buildInfo.title + ", " + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + " ",
|
||||
true, AllIcons.CodeStyle.Gear, buildView);
|
||||
}
|
||||
@@ -277,6 +277,8 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
|
||||
}
|
||||
myProgressWatcher.addBuild(buildInfo);
|
||||
//view.getPrimaryView().print("\r", ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
|
||||
((BuildContentManagerImpl)myBuildContentManager).startBuildNotified(myContent);
|
||||
}
|
||||
else {
|
||||
if (event instanceof FinishBuildEvent) {
|
||||
@@ -284,6 +286,7 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
|
||||
buildInfo.message = event.getMessage();
|
||||
buildInfo.result = ((FinishBuildEvent)event).getResult();
|
||||
myProgressWatcher.stopBuild(buildInfo);
|
||||
((BuildContentManagerImpl)myBuildContentManager).finishBuildNotified(myContent);
|
||||
}
|
||||
else {
|
||||
buildInfo.statusMessage = event.getMessage();
|
||||
@@ -349,7 +352,7 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
|
||||
consoleComponent.add(myThreeComponentsSplitter, BorderLayout.CENTER);
|
||||
myToolbarActions = new DefaultActionGroup();
|
||||
consoleComponent.add(ActionManager.getInstance().createActionToolbar(
|
||||
"", myToolbarActions, false).getComponent(), BorderLayout.WEST);
|
||||
"BuildView", myToolbarActions, false).getComponent(), BorderLayout.WEST);
|
||||
|
||||
myContent = new ContentImpl(consoleComponent, getViewName(), true);
|
||||
myContent.setCloseable(false);
|
||||
@@ -472,7 +475,7 @@ public abstract class AbstractViewManager implements BuildProgressListener, Disp
|
||||
}
|
||||
}
|
||||
else if (!(anAction instanceof FakeRerunAction ||
|
||||
anAction instanceof PinToolwindowTabAction ||
|
||||
anAction instanceof PinActiveTabAction ||
|
||||
anAction instanceof CloseAction)) {
|
||||
consoleActionGroup.add(anAction);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ public interface BuildContentManager {
|
||||
|
||||
void selectContent(final String tabName);
|
||||
|
||||
void addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable);
|
||||
Content addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package com.intellij.build;
|
||||
|
||||
import com.intellij.execution.runners.ExecutionUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
@@ -29,16 +31,17 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.TabbedContent;
|
||||
import com.intellij.util.ContentUtilEx;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.intellij.util.ContentUtilEx.getFullName;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
@@ -50,6 +53,7 @@ public class BuildContentManagerImpl implements BuildContentManager {
|
||||
private static final String[] ourPresetOrder = {Build, Sync};
|
||||
private ToolWindow myToolWindow;
|
||||
private final List<Runnable> myPostponedRunnables = new ArrayList<>();
|
||||
private Map<Content, Pair<Icon, AtomicInteger>> liveContentsMap = ContainerUtil.newConcurrentMap();
|
||||
|
||||
public BuildContentManagerImpl(Project project) {
|
||||
init(project);
|
||||
@@ -165,23 +169,45 @@ public class BuildContentManagerImpl implements BuildContentManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable) {
|
||||
runWhenInitialized(() -> {
|
||||
ContentManager contentManager = myToolWindow.getContentManager();
|
||||
ContentUtilEx.addTabbedContent(contentManager, contentComponent, groupPrefix, tabName, select, childDisposable);
|
||||
if (icon != null) {
|
||||
TabbedContent tabbedContent = ContentUtilEx.findTabbedContent(contentManager, groupPrefix);
|
||||
if (tabbedContent != null) {
|
||||
tabbedContent.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
|
||||
tabbedContent.setIcon(icon);
|
||||
}
|
||||
public Content addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable) {
|
||||
ContentManager contentManager = myToolWindow.getContentManager();
|
||||
ContentUtilEx.addTabbedContent(contentManager, contentComponent, groupPrefix, tabName, select, childDisposable);
|
||||
Content content = contentManager.findContent(getFullName(groupPrefix, tabName));
|
||||
if (icon != null) {
|
||||
TabbedContent tabbedContent = ContentUtilEx.findTabbedContent(contentManager, groupPrefix);
|
||||
if (tabbedContent != null) {
|
||||
tabbedContent.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
|
||||
tabbedContent.setIcon(icon);
|
||||
}
|
||||
});
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void finishBuildNotified(Content content) {
|
||||
Pair<Icon, AtomicInteger> pair = liveContentsMap.get(content);
|
||||
if (pair.second.decrementAndGet() == 0) {
|
||||
content.setIcon(pair.first);
|
||||
if (pair.first == null) {
|
||||
content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.FALSE);
|
||||
}
|
||||
liveContentsMap.remove(content);
|
||||
if (liveContentsMap.isEmpty()) {
|
||||
myToolWindow.setIcon(AllIcons.Actions.Compile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setIdLabelHidden(boolean hide) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.build.internal;
|
||||
import com.intellij.build.BuildContentManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.impl.ContentImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,11 +45,12 @@ public class DummyBuildContentManager implements BuildContentManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable) {
|
||||
public Content addTabbedContent(@NotNull JComponent contentComponent,
|
||||
@NotNull String groupPrefix,
|
||||
@NotNull String tabName,
|
||||
boolean select,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Disposable childDisposable) {
|
||||
return new ContentImpl(contentComponent, tabName, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user