mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add ability to activate and focus Services tool window on selectNode()
This commit is contained in:
@@ -5,14 +5,17 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public interface ServiceViewManager {
|
||||
Key<Boolean> SERVICE_VIEW_MASTER_COMPONENT = Key.create("SERVICE_VIEW_MASTER_COMPONENT");
|
||||
|
||||
void selectNode(Object node);
|
||||
|
||||
static ServiceViewManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, ServiceViewManager.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Promise<Void> selectNode(Object node, boolean activate, boolean focus);
|
||||
}
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ public class RunDashboardManagerImpl implements RunDashboardManager, PersistentS
|
||||
if (configurationSettings != null) {
|
||||
RunConfigurationNode node = new RunConfigurationNode(myProject, Pair.create(configurationSettings, contentDescriptor),
|
||||
getContributor(configurationSettings.getType()));
|
||||
ServiceViewManager.getInstance(myProject).selectNode(node);
|
||||
ServiceViewManager.getInstance(myProject).selectNode(node, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.intellij.util.xmlb.annotations.Property;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.concurrency.AsyncPromise;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -63,14 +65,30 @@ public final class ServiceViewManagerImpl implements ServiceViewManager, Persist
|
||||
toolWindow.getContentManager().addContent(toolWindowContent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void selectNode(Object node) {
|
||||
public Promise<Void> selectNode(Object node, boolean activate, boolean focus) {
|
||||
AsyncPromise<Void> result = new AsyncPromise<>();
|
||||
AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> {
|
||||
ServiceView content = myServiceView;
|
||||
if (content != null) {
|
||||
content.selectNode(node);
|
||||
Runnable runnable = () -> {
|
||||
ServiceView view = myServiceView;
|
||||
if (view == null) {
|
||||
result.setError("");
|
||||
}
|
||||
else {
|
||||
view.selectNode(node);
|
||||
result.setResult(null);
|
||||
}
|
||||
};
|
||||
ToolWindow window = activate ? ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.SERVICES) : null;
|
||||
if (window != null) {
|
||||
window.activate(runnable, false, focus);
|
||||
}
|
||||
else {
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateToolWindow(ServiceViewContributor.ServiceEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user