Search in sources :

Example 31 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class ActionsTreeUtil method createPluginsActionsGroup.

private static Group createPluginsActionsGroup(Condition<AnAction> filtered) {
    Group pluginsGroup = new Group(KeyMapBundle.message("plugins.group.title"), null, null);
    final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    ActionManagerEx managerEx = ActionManagerEx.getInstanceEx();
    final List<IdeaPluginDescriptor> plugins = new ArrayList<>();
    Collections.addAll(plugins, PluginManagerCore.getPlugins());
    Collections.sort(plugins, Comparator.comparing(IdeaPluginDescriptor::getName));
    List<PluginId> collected = new ArrayList<>();
    for (IdeaPluginDescriptor plugin : plugins) {
        collected.add(plugin.getPluginId());
        Group pluginGroup;
        if (plugin.getName().equals("IDEA CORE")) {
            continue;
        } else {
            pluginGroup = new Group(plugin.getName(), null, null);
        }
        final String[] pluginActions = managerEx.getPluginActions(plugin.getPluginId());
        if (pluginActions.length == 0) {
            continue;
        }
        Arrays.sort(pluginActions, Comparator.comparing(ActionsTreeUtil::getTextToCompare));
        for (String pluginAction : pluginActions) {
            if (keymapManager.getBoundActions().contains(pluginAction))
                continue;
            final AnAction anAction = managerEx.getActionOrStub(pluginAction);
            if (filtered == null || filtered.value(anAction)) {
                pluginGroup.addActionId(pluginAction);
            }
        }
        if (pluginGroup.getSize() > 0) {
            pluginsGroup.addGroup(pluginGroup);
        }
    }
    for (PluginId pluginId : PluginId.getRegisteredIds().values()) {
        if (collected.contains(pluginId))
            continue;
        Group pluginGroup = new Group(pluginId.getIdString(), null, null);
        final String[] pluginActions = managerEx.getPluginActions(pluginId);
        if (pluginActions.length == 0) {
            continue;
        }
        for (String pluginAction : pluginActions) {
            if (keymapManager.getBoundActions().contains(pluginAction))
                continue;
            final AnAction anAction = managerEx.getActionOrStub(pluginAction);
            if (filtered == null || filtered.value(anAction)) {
                pluginGroup.addActionId(pluginAction);
            }
        }
        if (pluginGroup.getSize() > 0) {
            pluginsGroup.addGroup(pluginGroup);
        }
    }
    return pluginsGroup;
}
Also used : KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 32 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class StoreUtil method getStateSpecOrError.

@NotNull
public static State getStateSpecOrError(@NotNull Class<? extends PersistentStateComponent> componentClass) {
    State spec = getStateSpec(componentClass);
    if (spec != null) {
        return spec;
    }
    PluginId pluginId = PluginManagerCore.getPluginByClassName(componentClass.getName());
    if (pluginId == null) {
        throw new RuntimeException("No @State annotation found in " + componentClass);
    } else {
        throw new PluginException("No @State annotation found in " + componentClass, pluginId);
    }
}
Also used : State(com.intellij.openapi.components.State) PluginException(com.intellij.diagnostic.PluginException) PluginId(com.intellij.openapi.extensions.PluginId) NotNull(org.jetbrains.annotations.NotNull)

Example 33 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class ActionManagerImpl method unregisterAction.

@Override
public void unregisterAction(@NotNull String actionId) {
    synchronized (myLock) {
        if (!myId2Action.containsKey(actionId)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("action with ID " + actionId + " wasn't registered");
                return;
            }
        }
        AnAction oldValue = myId2Action.remove(actionId);
        myAction2Id.remove(oldValue);
        myId2Index.remove(actionId);
        for (PluginId pluginName : myPlugin2Id.keySet()) {
            final THashSet<String> pluginActions = myPlugin2Id.get(pluginName);
            if (pluginActions != null) {
                pluginActions.remove(actionId);
            }
        }
    }
}
Also used : PluginId(com.intellij.openapi.extensions.PluginId)

Example 34 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class PluginManager method processException.

public static void processException(Throwable t) {
    if (!IdeaApplication.isLoaded()) {
        @SuppressWarnings("ThrowableResultOfMethodCallIgnored") StartupAbortedException se = findCause(t, StartupAbortedException.class);
        if (se == null)
            se = new StartupAbortedException(t);
        @SuppressWarnings("ThrowableResultOfMethodCallIgnored") PluginException pe = findCause(t, PluginException.class);
        PluginId pluginId = pe != null ? pe.getPluginId() : null;
        if (Logger.isInitialized() && !(t instanceof ProcessCanceledException)) {
            try {
                getLogger().error(t);
            } catch (Throwable ignore) {
            }
        }
        final ImplementationConflictException conflictException = findCause(t, ImplementationConflictException.class);
        if (conflictException != null) {
            PluginConflictReporter.INSTANCE.reportConflictByClasses(conflictException.getConflictingClasses());
        }
        if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
            disablePlugin(pluginId.getIdString());
            StringWriter message = new StringWriter();
            message.append("Plugin '").append(pluginId.getIdString()).append("' failed to initialize and will be disabled. ");
            message.append(" Please restart ").append(ApplicationNamesInfo.getInstance().getFullProductName()).append('.');
            message.append("\n\n");
            pe.getCause().printStackTrace(new PrintWriter(message));
            Main.showMessage("Plugin Error", message.toString(), false);
            System.exit(Main.PLUGIN_ERROR);
        } else {
            Main.showMessage("Start Failed", t);
            System.exit(se.exitCode());
        }
    } else if (!(t instanceof ProcessCanceledException)) {
        getLogger().error(t);
    }
}
Also used : StringWriter(java.io.StringWriter) PluginException(com.intellij.diagnostic.PluginException) PluginId(com.intellij.openapi.extensions.PluginId) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ImplementationConflictException(com.intellij.diagnostic.ImplementationConflictException) PrintWriter(java.io.PrintWriter)

Example 35 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class PluginsTableRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (myPluginDescriptor != null) {
        Couple<Color> colors = UIUtil.getCellColors(table, isSelected, row, column);
        Color fg = colors.getFirst();
        final Color background = colors.getSecond();
        Color grayedFg = isSelected ? fg : new JBColor(Gray._130, Gray._120);
        myPanel.setBackground(background);
        myName.setForeground(fg);
        myCategory.setForeground(grayedFg);
        myStatus.setForeground(grayedFg);
        myLastUpdated.setForeground(grayedFg);
        myDownloads.setForeground(grayedFg);
        myName.clear();
        myName.setOpaque(false);
        myCategory.clear();
        myCategory.setOpaque(false);
        String pluginName = myPluginDescriptor.getName() + "  ";
        Object query = table.getClientProperty(SpeedSearchSupply.SEARCH_QUERY_KEY);
        SimpleTextAttributes attr = new SimpleTextAttributes(UIUtil.getListBackground(isSelected), UIUtil.getListForeground(isSelected), JBColor.RED, SimpleTextAttributes.STYLE_PLAIN);
        Matcher matcher = NameUtil.buildMatcher("*" + query, NameUtil.MatchingCaseSensitivity.NONE);
        if (query instanceof String) {
            SpeedSearchUtil.appendColoredFragmentForMatcher(pluginName, myName, attr, matcher, UIUtil.getTableBackground(isSelected), true);
        } else {
            myName.append(pluginName);
        }
        String category = myPluginDescriptor.getCategory() == null ? null : StringUtil.toUpperCase(myPluginDescriptor.getCategory());
        if (category != null) {
            if (query instanceof String) {
                SpeedSearchUtil.appendColoredFragmentForMatcher(category, myCategory, attr, matcher, UIUtil.getTableBackground(isSelected), true);
            } else {
                myCategory.append(category);
            }
        } else if (!myPluginsView) {
            myCategory.append(AvailablePluginsManagerMain.N_A);
        }
        myStatus.setIcon(AllIcons.Nodes.Plugin);
        if (myPluginDescriptor.isBundled()) {
            myCategory.append(" [Bundled]");
            myStatus.setIcon(AllIcons.Nodes.PluginJB);
        }
        String vendor = myPluginDescriptor.getVendor();
        if (vendor != null && StringUtil.containsIgnoreCase(vendor, "jetbrains")) {
            myStatus.setIcon(AllIcons.Nodes.PluginJB);
        }
        String downloads = myPluginDescriptor.getDownloads();
        if (downloads != null && myPluginDescriptor instanceof PluginNode) {
            if (downloads.length() > 3) {
                downloads = new DecimalFormat("#,###").format(Integer.parseInt(downloads));
            }
            myDownloads.setText(downloads);
            myRating.setRate(((PluginNode) myPluginDescriptor).getRating());
            myLastUpdated.setText(DateFormatUtil.formatBetweenDates(((PluginNode) myPluginDescriptor).getDate(), System.currentTimeMillis()));
        }
        // plugin state-dependent rendering
        PluginId pluginId = myPluginDescriptor.getPluginId();
        IdeaPluginDescriptor installed = PluginManager.getPlugin(pluginId);
        if (installed != null && ((IdeaPluginDescriptorImpl) installed).isDeleted()) {
            // existing plugin uninstalled (both views)
            myStatus.setIcon(AllIcons.Nodes.PluginRestart);
            if (!isSelected)
                myName.setForeground(FileStatus.DELETED.getColor());
            myPanel.setToolTipText(IdeBundle.message("plugin.manager.uninstalled.tooltip"));
        } else if (ourState.wasInstalled(pluginId)) {
            // new plugin installed (both views)
            myStatus.setIcon(AllIcons.Nodes.PluginRestart);
            if (!isSelected)
                myName.setForeground(FileStatus.ADDED.getColor());
            myPanel.setToolTipText(IdeBundle.message("plugin.manager.installed.tooltip"));
        } else if (ourState.wasUpdated(pluginId)) {
            // existing plugin updated (both views)
            myStatus.setIcon(AllIcons.Nodes.PluginRestart);
            if (!isSelected)
                myName.setForeground(FileStatus.ADDED.getColor());
            myPanel.setToolTipText(IdeBundle.message("plugin.manager.updated.tooltip"));
        } else if (ourState.hasNewerVersion(pluginId)) {
            // existing plugin has a newer version (both views)
            myStatus.setIcon(AllIcons.Nodes.Pluginobsolete);
            if (!isSelected)
                myName.setForeground(FileStatus.MODIFIED.getColor());
            if (!myPluginsView && installed != null) {
                myPanel.setToolTipText(IdeBundle.message("plugin.manager.new.version.tooltip", installed.getVersion()));
            } else {
                myPanel.setToolTipText(IdeBundle.message("plugin.manager.update.available.tooltip"));
            }
        } else if (isIncompatible(myPluginDescriptor, table.getModel())) {
            // a plugin is incompatible with current installation (both views)
            if (!isSelected)
                myName.setForeground(JBColor.RED);
            myPanel.setToolTipText(whyIncompatible(myPluginDescriptor, table.getModel()));
        } else if (!myPluginDescriptor.isEnabled() && myPluginsView) {
            // a plugin is disabled (plugins view only)
            myStatus.setIcon(IconLoader.getDisabledIcon(myStatus.getIcon()));
        }
    }
    return myPanel;
}
Also used : Matcher(com.intellij.util.text.Matcher) JBColor(com.intellij.ui.JBColor) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) DecimalFormat(java.text.DecimalFormat) JBColor(com.intellij.ui.JBColor) PluginId(com.intellij.openapi.extensions.PluginId)

Aggregations

PluginId (com.intellij.openapi.extensions.PluginId)54 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)25 NotNull (org.jetbrains.annotations.NotNull)10 IOException (java.io.IOException)8 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)6 Project (com.intellij.openapi.project.Project)6 Nullable (org.jetbrains.annotations.Nullable)6 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)5 PluginException (com.intellij.diagnostic.PluginException)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 NonNls (org.jetbrains.annotations.NonNls)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)3 PluginDownloader (com.intellij.openapi.updateSettings.impl.PluginDownloader)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 AbstractMessage (com.intellij.diagnostic.AbstractMessage)2 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 DataManager (com.intellij.ide.DataManager)2