From 5218df258452fbaa2459c1a0f9956e88d0ded04b Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Tue, 19 May 2015 13:35:35 +0200 Subject: [PATCH] IDEA-140441 - Clouds: find clouds panel in settings --- .../impl/src/META-INF/RemoteServers.xml | 1 + .../RemoteServerListConfigurable.java | 31 +++++++++++++-- ...moteServerSearchableOptionContributor.java | 38 +++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerSearchableOptionContributor.java diff --git a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml index 64d832417ef6..80994381a28b 100644 --- a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml +++ b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml @@ -21,6 +21,7 @@ displayName="Clouds" id="RemoteServers" provider="com.intellij.remoteServer.impl.configuration.RemoteServerListConfigurableProvider"/> + diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java index 0d4f04253e96..64951713057b 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java @@ -13,14 +13,19 @@ import com.intellij.openapi.util.Condition; import com.intellij.remoteServer.ServerType; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.RemoteServersManager; +import com.intellij.ui.TreeSpeedSearch; +import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.util.IconUtil; import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.Convertor; import com.intellij.util.text.UniqueNameGenerator; import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.tree.TreePath; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -30,6 +35,10 @@ import java.util.Set; * @author nik */ public class RemoteServerListConfigurable extends MasterDetailsComponent implements SearchableConfigurable { + + @NonNls + public static final String ID = "RemoteServers"; + private final RemoteServersManager myServersManager; @Nullable private final ServerType myServerType; private RemoteServer myLastSelectedServer; @@ -83,13 +92,29 @@ public class RemoteServerListConfigurable extends MasterDetailsComponent impleme @NotNull @Override public String getId() { - return "RemoteServers"; + return ID; } @Nullable @Override - public Runnable enableSearch(String option) { - return null; + public Runnable enableSearch(final String option) { + return new Runnable() { + @Override + public void run() { + ObjectUtils.assertNotNull(SpeedSearchSupply.getSupply(myTree, true)).findAndSelectElement(option); + } + }; + } + + @Override + protected void initTree() { + super.initTree(); + new TreeSpeedSearch(myTree, new Convertor() { + @Override + public String convert(final TreePath treePath) { + return ((MyNode)treePath.getLastPathComponent()).getDisplayName(); + } + }, true); } @Override diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerSearchableOptionContributor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerSearchableOptionContributor.java new file mode 100644 index 000000000000..f4148efc18f1 --- /dev/null +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerSearchableOptionContributor.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2015 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.remoteServer.impl.configuration; + +import com.intellij.ide.ui.search.SearchableOptionContributor; +import com.intellij.ide.ui.search.SearchableOptionProcessor; +import com.intellij.remoteServer.ServerType; +import com.intellij.remoteServer.configuration.RemoteServer; +import com.intellij.remoteServer.configuration.RemoteServersManager; +import org.jetbrains.annotations.NotNull; + +public class RemoteServerSearchableOptionContributor extends SearchableOptionContributor { + + @Override + public void processOptions(@NotNull SearchableOptionProcessor processor) { + for (ServerType serverType : ServerType.EP_NAME.getExtensions()) { + String typeName = serverType.getPresentableName(); + processor.addOptions(typeName, null, typeName + " cloud type", RemoteServerListConfigurable.ID, null, false); + for (RemoteServer server : RemoteServersManager.getInstance().getServers(serverType)) { + String serverName = server.getName(); + processor.addOptions(serverName, null, serverName + " cloud instance", RemoteServerListConfigurable.ID, null, false); + } + } + } +}