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;
}
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);
}
}
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);
}
}
}
}
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);
}
}
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;
}
Aggregations