summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/ide/actions
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/ide/actions')
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java14
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java40
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java14
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java9
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/SplitterActionBase.java25
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/Switcher.java2
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/TabsAlphabeticalModeSwitcher.java5
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/UnsplitAllAction.java6
8 files changed, 65 insertions, 50 deletions
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
index 7bbc3e0c6cba..006830479db3 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.FieldPanel;
import com.intellij.util.Consumer;
+import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -55,15 +56,14 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
private final boolean myShowFilePath;
private final String myDescription;
- public ChooseComponentsToExportDialog(List<ExportableComponent> components,
- Map<File, Set<ExportableComponent>> fileToComponents,
+ public ChooseComponentsToExportDialog(MultiMap<File, ExportableComponent> fileToComponents,
boolean showFilePath, final String title, String description) {
super(false);
myDescription = description;
myShowFilePath = showFilePath;
Map<ExportableComponent, ComponentElementProperties> componentToContainingListElement = new LinkedHashMap<ExportableComponent, ComponentElementProperties>();
- for (ExportableComponent component : components) {
+ for (ExportableComponent component : fileToComponents.values()) {
if (!addToExistingListElement(component, componentToContainingListElement, fileToComponents)) {
ComponentElementProperties componentElementProperties = new ComponentElementProperties();
componentElementProperties.addComponent(component);
@@ -149,14 +149,14 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
}
private static boolean addToExistingListElement(ExportableComponent component,
- Map<ExportableComponent,ComponentElementProperties> componentToContainingListElement,
- Map<File, Set<ExportableComponent>> fileToComponents) {
+ Map<ExportableComponent, ComponentElementProperties> componentToContainingListElement,
+ MultiMap<File, ExportableComponent> fileToComponents) {
final File[] exportFiles = component.getExportFiles();
File file = null;
for (File exportFile : exportFiles) {
- final Set<ExportableComponent> tiedComponents = fileToComponents.get(exportFile);
+ Collection<ExportableComponent> tiedComponents = fileToComponents.get(exportFile);
- for (final ExportableComponent tiedComponent : tiedComponents) {
+ for (ExportableComponent tiedComponent : tiedComponents) {
if (tiedComponent == component) continue;
final ComponentElementProperties elementProperties = componentToContainingListElement.get(tiedComponent);
if (elementProperties != null && !FileUtil.filesEqual(exportFile, file)) {
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
index e82e22d926ea..19a6502b8add 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
@@ -35,7 +35,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.MultiMap;
import com.intellij.util.io.ZipUtil;
+import org.jetbrains.annotations.NotNull;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -47,10 +49,18 @@ import java.util.jar.JarOutputStream;
public class ExportSettingsAction extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
Project project = getEventProject(e);
- List<ExportableComponent> exportableComponents = new ArrayList<ExportableComponent>();
- Map<File,Set<ExportableComponent>> fileToComponents = getRegisteredComponentsAndFiles(exportableComponents);
- final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(exportableComponents, fileToComponents, true,
+ ApplicationManager.getApplication().saveSettings();
+
+ MultiMap<File, ExportableComponent> fileToComponents = getExportableComponentsMap();
+ for (Iterator<File> it = fileToComponents.keySet().iterator(); it.hasNext(); ) {
+ File file = it.next();
+ if (!file.exists()) {
+ it.remove();
+ }
+ }
+
+ final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(fileToComponents, true,
IdeBundle.message("title.select.components.to.export"),
IdeBundle.message(
"prompt.please.check.all.components.to.export"));
@@ -65,8 +75,6 @@ public class ExportSettingsAction extends AnAction implements DumbAware {
ContainerUtil.addAll(exportFiles, markedComponent.getExportFiles());
}
- ApplicationManager.getApplication().saveSettings();
-
final File saveFile = dialog.getExportFile();
try {
if (saveFile.exists()) {
@@ -121,24 +129,18 @@ public class ExportSettingsAction extends AnAction implements DumbAware {
}
}
- public static Map<File, Set<ExportableComponent>> getRegisteredComponentsAndFiles(List<ExportableComponent> exportableComponents) {
- Map<File,Set<ExportableComponent>> fileToComponents = new HashMap<File, Set<ExportableComponent>>();
+ @NotNull
+ public static MultiMap<File, ExportableComponent> getExportableComponentsMap() {
+ MultiMap<File, ExportableComponent> result = MultiMap.createSet();
- final List<ExportableComponent> components = new ArrayList<ExportableComponent>(Arrays.asList(ApplicationManager.getApplication().getComponents(ExportableApplicationComponent.class)));
+ ExportableApplicationComponent[] components1 = ApplicationManager.getApplication().getComponents(ExportableApplicationComponent.class);
+ List<ExportableComponent> components2 = ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent.class);
- components.addAll(ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent.class));
-
- for (ExportableComponent component : components) {
- exportableComponents.add(component);
+ for (ExportableComponent component : ContainerUtil.concat(Arrays.asList(components1), components2)) {
for (File exportFile : component.getExportFiles()) {
- Set<ExportableComponent> componentsTied = fileToComponents.get(exportFile);
- if (componentsTied == null) {
- componentsTied = new HashSet<ExportableComponent>();
- fileToComponents.put(exportFile, componentsTied);
- }
- componentsTied.add(component);
+ result.putValue(exportFile, component);
}
}
- return fileToComponents;
+ return result;
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
index 1e989946ab2f..f06c45e1af7a 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
@@ -36,13 +36,17 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.Consumer;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.MultiMap;
import com.intellij.util.io.ZipUtil;
import java.awt.*;
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
@@ -77,10 +81,10 @@ public class ImportSettingsAction extends AnAction implements DumbAware {
return;
}
- final ArrayList<ExportableComponent> registeredComponents = new ArrayList<ExportableComponent>();
- final Map<File, Set<ExportableComponent>> filesToComponents = ExportSettingsAction.getRegisteredComponentsAndFiles(registeredComponents);
- List<ExportableComponent> components = getComponentsStored(saveFile, registeredComponents);
- final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(components, filesToComponents, false,
+ MultiMap<File, ExportableComponent> filesToComponents = ExportSettingsAction.getExportableComponentsMap();
+ List<ExportableComponent> components = getComponentsStored(saveFile, ContainerUtil.newArrayList(filesToComponents.values()));
+ filesToComponents.values().retainAll(components);
+ final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(filesToComponents, false,
IdeBundle.message("title.select.components.to.import"),
IdeBundle.message("prompt.check.components.to.import"));
dialog.show();
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
index 40bfe41fb26f..4a72eda21a3e 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
@@ -27,17 +27,20 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
import com.intellij.ui.LicensingFacade;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
public class SendFeedbackAction extends AnAction implements DumbAware {
+ @Override
public void actionPerformed(AnActionEvent e) {
- launchBrowser();
+ launchBrowser(e.getProject());
}
- public static void launchBrowser() {
+ public static void launchBrowser(@Nullable Project project) {
final ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
boolean eap = appInfo.isEAP();
String urlTemplate = eap ? appInfo.getEAPFeedbackUrl() : appInfo.getReleaseFeedbackUrl();
@@ -47,7 +50,7 @@ public class SendFeedbackAction extends AnAction implements DumbAware {
.replace("$VERSION", appInfo.getFullVersion())
.replace("$EVAL", isEvaluationLicense() ? "true" : "false")
.replace("$DESCR", getDescription());
- BrowserUtil.browse(urlTemplate);
+ BrowserUtil.browse(urlTemplate, project);
}
private static String getDescription() {
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SplitterActionBase.java b/platform/platform-impl/src/com/intellij/ide/actions/SplitterActionBase.java
index 851c9096a38b..dde5a5c898dd 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/SplitterActionBase.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/SplitterActionBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,14 +27,9 @@ public abstract class SplitterActionBase extends AnAction implements DumbAware {
public void update(final AnActionEvent event) {
final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
final Presentation presentation = event.getPresentation();
- boolean enabled;
- if (project == null) {
- enabled = false;
- }
- else {
- enabled = isActionEnabled(project);
- }
- if (ActionPlaces.isPopupPlace(event.getPlace())) {
+ boolean inContextMenu = ActionPlaces.isPopupPlace(event.getPlace());
+ boolean enabled = project != null && isActionEnabled(project, inContextMenu);
+ if (inContextMenu) {
presentation.setVisible(enabled);
}
else {
@@ -42,7 +37,17 @@ public abstract class SplitterActionBase extends AnAction implements DumbAware {
}
}
- protected boolean isActionEnabled(Project project) {
+ /**
+ * This method determines whether the action is enabled for {@code project}
+ * if {@code inContextMenu} is set to {@code false}. Otherwise,
+ * it determines whether the action is visible in the context menu.
+ *
+ * @param project the specified project
+ * @param inContextMenu whether the action is used in context menu
+ * @return {@code true} if the action is enabled,
+ * {@code false} otherwise
+ */
+ protected boolean isActionEnabled(Project project, boolean inContextMenu) {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
return fileEditorManager.isInSplitter();
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
index 4541f4664751..cb35b5a504f9 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
@@ -1071,7 +1071,7 @@ public class Switcher extends AnAction implements DumbAware {
public void layoutContainer(Container target) {
final JScrollPane scrollPane = UIUtil.getParentOfType(JScrollPane.class, files);
JComponent filesPane = scrollPane != null ? scrollPane : files;
- if (sBounds == null) {
+ if (sBounds == null || !target.isShowing()) {
super.layoutContainer(target);
sBounds = separator.getBounds();
tBounds = toolWindows.getBounds();
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/TabsAlphabeticalModeSwitcher.java b/platform/platform-impl/src/com/intellij/ide/actions/TabsAlphabeticalModeSwitcher.java
index 8431364c5d61..7b000f530bdf 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/TabsAlphabeticalModeSwitcher.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/TabsAlphabeticalModeSwitcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.tabs.impl.JBEditorTabs;
import javax.swing.*;
@@ -28,7 +29,7 @@ import javax.swing.*;
public class TabsAlphabeticalModeSwitcher extends ToggleAction {
@Override
public boolean isSelected(AnActionEvent e) {
- return JBEditorTabs.isAlphabeticalMode();
+ return Registry.is(JBEditorTabs.TABS_ALPHABETICAL_KEY);
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/UnsplitAllAction.java b/platform/platform-impl/src/com/intellij/ide/actions/UnsplitAllAction.java
index 12df75e75656..ec724884ef2d 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/UnsplitAllAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/UnsplitAllAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -32,8 +32,8 @@ public final class UnsplitAllAction extends SplitterActionBase {
}
@Override
- protected boolean isActionEnabled(Project project) {
+ protected boolean isActionEnabled(Project project, boolean inContextMenu) {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
- return fileEditorManager.getWindowSplitCount() > 2;
+ return inContextMenu ? fileEditorManager.getWindowSplitCount() > 2 : fileEditorManager.isInSplitter();
}
}