Search in sources :

Example 1 with RemoteModule

use of org.sonarsource.sonarlint.core.client.api.connected.RemoteModule in project sonarlint-core by SonarSource.

the class AllModulesReader method get.

@Override
public Map<String, RemoteModule> get() {
    Map<String, RemoteModule> results = new HashMap<>();
    ModuleList readModuleListFromStorage = storageReader.readModuleList();
    Map<String, Module> modulesByKey = readModuleListFromStorage.getModulesByKeyMap();
    for (Map.Entry<String, Module> entry : modulesByKey.entrySet()) {
        results.put(entry.getKey(), new DefaultRemoteModule(entry.getValue()));
    }
    return results;
}
Also used : RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule) HashMap(java.util.HashMap) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) Module(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList.Module) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule) Map(java.util.Map) HashMap(java.util.HashMap) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule)

Example 2 with RemoteModule

use of org.sonarsource.sonarlint.core.client.api.connected.RemoteModule in project sonarlint-intellij by SonarSource.

the class SearchProjectKeyDialog method setProjectsInList.

private void setProjectsInList(Collection<RemoteModule> modules) {
    Comparator<RemoteModule> moduleComparator = (o1, o2) -> {
        int c1 = o1.getName().compareToIgnoreCase(o2.getName());
        if (c1 != 0) {
            return c1;
        }
        return o1.getKey().compareToIgnoreCase(o2.getKey());
    };
    List<RemoteModule> sortedModules = modules.stream().filter(RemoteModule::isRoot).sorted(moduleComparator).collect(Collectors.toList());
    RemoteModule selected = null;
    if (lastSelectedProjectKey != null) {
        selected = sortedModules.stream().filter(module -> lastSelectedProjectKey.equals(module.getKey())).findAny().orElse(null);
    }
    CollectionListModel<RemoteModule> projectListModel = new CollectionListModel<>(sortedModules);
    projectList.setModel(projectListModel);
    projectList.setCellRenderer(new ProjectListRenderer());
    setSelectedProject(selected);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Map(java.util.Map) MouseAdapter(java.awt.event.MouseAdapter) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Nullable(javax.annotation.Nullable) JComponent(javax.swing.JComponent) JBList(com.intellij.ui.components.JBList) Collection(java.util.Collection) Convertor(com.intellij.util.containers.Convertor) JList(javax.swing.JList) CollectionListModel(com.intellij.ui.CollectionListModel) Component(java.awt.Component) Collectors(java.util.stream.Collectors) MouseEvent(java.awt.event.MouseEvent) JBScrollPane(com.intellij.ui.components.JBScrollPane) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) Comparator(java.util.Comparator) ListSelectionListener(javax.swing.event.ListSelectionListener) CheckForNull(javax.annotation.CheckForNull) JPanel(javax.swing.JPanel) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) CollectionListModel(com.intellij.ui.CollectionListModel)

Example 3 with RemoteModule

use of org.sonarsource.sonarlint.core.client.api.connected.RemoteModule in project sonarlint-intellij by SonarSource.

the class SearchProjectKeyDialog method createProjectList.

private void createProjectList() {
    projectList = new JBList();
    projectList.setEmptyText("No projects found in the selected SonarQube Server");
    projectList.setCellRenderer(new ProjectListRenderer());
    projectList.addListSelectionListener(new ProjectItemListener());
    projectList.addMouseListener(new ProjectMouseListener());
    projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    projectList.setVisibleRowCount(10);
    projectList.setBorder(IdeBorderFactory.createBorder());
    Convertor<Object, String> convertor = o -> {
        RemoteModule module = (RemoteModule) o;
        return module.getName() + " " + module.getKey();
    };
    new ListSpeedSearch(projectList, convertor);
    scrollPane = new JBScrollPane(projectList);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Map(java.util.Map) MouseAdapter(java.awt.event.MouseAdapter) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Nullable(javax.annotation.Nullable) JComponent(javax.swing.JComponent) JBList(com.intellij.ui.components.JBList) Collection(java.util.Collection) Convertor(com.intellij.util.containers.Convertor) JList(javax.swing.JList) CollectionListModel(com.intellij.ui.CollectionListModel) Component(java.awt.Component) Collectors(java.util.stream.Collectors) MouseEvent(java.awt.event.MouseEvent) JBScrollPane(com.intellij.ui.components.JBScrollPane) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) Comparator(java.util.Comparator) ListSelectionListener(javax.swing.event.ListSelectionListener) CheckForNull(javax.annotation.CheckForNull) JPanel(javax.swing.JPanel) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) JBList(com.intellij.ui.components.JBList) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Aggregations

Map (java.util.Map)3 RemoteModule (org.sonarsource.sonarlint.core.client.api.connected.RemoteModule)3 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)2 CollectionListModel (com.intellij.ui.CollectionListModel)2 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)2 IdeBorderFactory (com.intellij.ui.IdeBorderFactory)2 ListSpeedSearch (com.intellij.ui.ListSpeedSearch)2 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)2 JBList (com.intellij.ui.components.JBList)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 Convertor (com.intellij.util.containers.Convertor)2 Component (java.awt.Component)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 Collection (java.util.Collection)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 CheckForNull (javax.annotation.CheckForNull)2 Nullable (javax.annotation.Nullable)2