summaryrefslogtreecommitdiff
path: root/platform/platform-api/src/com/intellij
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-api/src/com/intellij')
-rw-r--r--platform/platform-api/src/com/intellij/execution/util/ExecUtil.java60
-rw-r--r--platform/platform-api/src/com/intellij/ide/BrowserUtil.java5
-rw-r--r--platform/platform-api/src/com/intellij/ide/actions/ContextHelpAction.java2
-rw-r--r--platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java4
-rw-r--r--platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.java5
-rw-r--r--platform/platform-api/src/com/intellij/notification/Notification.java3
-rw-r--r--platform/platform-api/src/com/intellij/notification/NotificationGroup.java6
-rw-r--r--platform/platform-api/src/com/intellij/notification/NotificationListener.java4
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java8
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java5
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java20
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java8
-rw-r--r--platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java7
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java54
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java25
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java2
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java17
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java2
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java18
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java11
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java1
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java11
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java20
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/Messages.java52
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java30
-rw-r--r--platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java30
-rw-r--r--platform/platform-api/src/com/intellij/ui/CollectionListModel.java1
-rw-r--r--platform/platform-api/src/com/intellij/ui/SimpleColoredText.java8
-rw-r--r--platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java2
-rw-r--r--platform/platform-api/src/com/intellij/ui/table/JBTable.java2
-rw-r--r--platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java14
-rw-r--r--platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java4
-rw-r--r--platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java16
-rw-r--r--platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java64
-rw-r--r--platform/platform-api/src/com/intellij/util/ui/Animator.java10
36 files changed, 354 insertions, 183 deletions
diff --git a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java
index 00c20735da1b..ca99fca910f8 100644
--- a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java
+++ b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java
@@ -83,16 +83,35 @@ public class ExecUtil {
private ExecUtil() { }
+ /**
+ * Run the command using safe escaping and quoting when appropriate.
+ *
+ * @param command the command and its arguments, can contain any characters
+ * @param workDir working directory
+ * @param environment environment variables
+ * @return the running process
+ */
+ @NotNull
+ public static Process exec(@NotNull final List<String> command, @Nullable final String workDir,
+ @Nullable final Map<String, String> environment) throws ExecutionException {
+ assert command.size() > 0;
+ final GeneralCommandLine commandLine = new GeneralCommandLine(command);
+ if (workDir != null) {
+ commandLine.setWorkDirectory(workDir);
+ }
+ if (environment != null) {
+ commandLine.getEnvironment().putAll(environment);
+ }
+ return commandLine.createProcess();
+ }
+
public static int execAndGetResult(final String... command) throws ExecutionException, InterruptedException {
assert command != null && command.length > 0;
return execAndGetResult(Arrays.asList(command));
}
public static int execAndGetResult(@NotNull final List<String> command) throws ExecutionException, InterruptedException {
- assert command.size() > 0;
- final GeneralCommandLine commandLine = new GeneralCommandLine(command);
- final Process process = commandLine.createProcess();
- return process.waitFor();
+ return exec(command, null, null).waitFor();
}
@NotNull
@@ -151,10 +170,7 @@ public class ExecUtil {
@NotNull
public static ProcessOutput execAndGetOutput(@NotNull final List<String> command,
@Nullable final String workDir) throws ExecutionException {
- assert command.size() > 0;
- final GeneralCommandLine commandLine = new GeneralCommandLine(command);
- commandLine.setWorkDirectory(workDir);
- final Process process = commandLine.createProcess();
+ final Process process = exec(command, workDir, null);
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
return processHandler.runProcess();
}
@@ -167,7 +183,7 @@ public class ExecUtil {
@Nullable
public static String execAndReadLine(@Nullable Charset charset, final String... command) {
try {
- return readFirstLine(new GeneralCommandLine(command).createProcess().getInputStream(), charset);
+ return readFirstLine(exec(Arrays.asList(command), null, null).getInputStream(), charset);
}
catch (Exception ignored) {
return null;
@@ -199,12 +215,12 @@ public class ExecUtil {
* @param command the command and its arguments, can contain any characters
* @param prompt the prompt string for the users
* @param workDir working directory
+ * @param environment environment variables
* @return the results of running the process
*/
@NotNull
- public static ProcessOutput sudoAndGetOutput(@NotNull List<String> command,
- @NotNull String prompt,
- @Nullable String workDir) throws IOException, ExecutionException {
+ public static Process sudo(@NotNull final List<String> command, @NotNull final String prompt, @Nullable final String workDir,
+ @Nullable final Map<String, String> environment) throws ExecutionException, IOException {
if (SystemInfo.isMac) {
final String escapedCommandLine = StringUtil.join(command, new Function<String, String>() {
@Override
@@ -213,28 +229,28 @@ public class ExecUtil {
}
}, " & \" \" & ");
final String escapedScript = "do shell script " + escapedCommandLine + " with administrator privileges";
- return execAndGetOutput(Arrays.asList(getOsascriptPath(), "-e", escapedScript), workDir);
+ return exec(Arrays.asList(getOsascriptPath(), "-e", escapedScript), workDir, environment);
}
else if ("root".equals(System.getenv("USER"))) {
- return execAndGetOutput(command, workDir);
+ return exec(command, workDir, environment);
}
else if (hasGkSudo.getValue()) {
final List<String> sudoCommand = new ArrayList<String>();
sudoCommand.addAll(Arrays.asList("gksudo", "--message", prompt, "--"));
sudoCommand.addAll(command);
- return execAndGetOutput(sudoCommand, workDir);
+ return exec(sudoCommand, workDir, environment);
}
else if (hasKdeSudo.getValue()) {
final List<String> sudoCommand = new ArrayList<String>();
sudoCommand.addAll(Arrays.asList("kdesudo", "--comment", prompt, "--"));
sudoCommand.addAll(command);
- return execAndGetOutput(sudoCommand, workDir);
+ return exec(sudoCommand, workDir, environment);
}
else if (hasPkExec.getValue()) {
final List<String> sudoCommand = new ArrayList<String>();
sudoCommand.add("pkexec");
sudoCommand.addAll(command);
- return execAndGetOutput(sudoCommand, workDir);
+ return exec(sudoCommand, workDir, environment);
}
else if (SystemInfo.isUnix && hasTerminalApp()) {
final String escapedCommandLine = StringUtil.join(command, new Function<String, String>() {
@@ -253,13 +269,21 @@ public class ExecUtil {
"echo\n" +
"read -p \"Press Enter to close this window...\" TEMP\n" +
"exit $STATUS\n");
- return execAndGetOutput(getTerminalCommand("Install", script.getAbsolutePath()), workDir);
+ return exec(getTerminalCommand("Install", script.getAbsolutePath()), workDir, environment);
}
throw new UnsupportedSystemException();
}
@NotNull
+ public static ProcessOutput sudoAndGetOutput(@NotNull List<String> command, @NotNull String prompt,
+ @Nullable String workDir) throws IOException, ExecutionException {
+ final Process process = sudo(command, prompt, workDir, null);
+ final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
+ return processHandler.runProcess();
+ }
+
+ @NotNull
private static String escapeAppleScriptArgument(@NotNull String arg) {
return "quoted form of \"" + arg.replace("\"", "\\\"") + "\"";
}
diff --git a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
index cd1d1b0dba49..85c0efd2b5cd 100644
--- a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
+++ b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 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.
@@ -35,6 +35,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -53,7 +54,7 @@ public class BrowserUtil {
private BrowserUtil() { }
public static boolean isAbsoluteURL(String url) {
- return ourExternalPrefix.matcher(url.toLowerCase()).find();
+ return ourExternalPrefix.matcher(url.toLowerCase(Locale.ENGLISH)).find();
}
public static String getDocURL(String url) {
diff --git a/platform/platform-api/src/com/intellij/ide/actions/ContextHelpAction.java b/platform/platform-api/src/com/intellij/ide/actions/ContextHelpAction.java
index b453bb2e174c..1ba3368f2066 100644
--- a/platform/platform-api/src/com/intellij/ide/actions/ContextHelpAction.java
+++ b/platform/platform-api/src/com/intellij/ide/actions/ContextHelpAction.java
@@ -55,7 +55,7 @@ public class ContextHelpAction extends AnAction implements DumbAware {
return;
}
- if (ActionPlaces.MAIN_MENU.equals(event.getPlace())) {
+ if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
DataContext dataContext = event.getDataContext();
presentation.setEnabled(getHelpId(dataContext) != null);
}
diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
index 10285d05fbee..cd8499850430 100644
--- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
+++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
@@ -1305,7 +1305,7 @@ public class AbstractTreeUi {
}
if (isSelectionInside(node)) {
- addSelectionPath(getPathFor(node), true, Condition.TRUE, null);
+ addSelectionPath(getPathFor(node), true, Conditions.alwaysTrue(), null);
}
processInnerChange(new Runnable() {
@@ -4853,7 +4853,7 @@ public class AbstractTreeUi {
}
if (pathToSelect != null && myTree.isSelectionEmpty()) {
- addSelectionPath(pathToSelect, true, Condition.FALSE, null);
+ addSelectionPath(pathToSelect, true, Conditions.alwaysFalse(), null);
}
}
}
diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.java b/platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.java
index d8ab18646aee..e1b0d7f63fe6 100644
--- a/platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.java
+++ b/platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.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.
@@ -17,6 +17,7 @@ package com.intellij.ide.util.treeView;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
@@ -214,7 +215,7 @@ public class UpdaterTreeState {
if (!children.contains(eachToSelect)) {
toSelect.remove();
if (!myToSelect.containsKey(readyElement) && !myUi.getSelectedElements().contains(eachToSelect)) {
- addAdjustedSelection(eachToSelect, Condition.FALSE, null);
+ addAdjustedSelection(eachToSelect, Conditions.alwaysFalse(), null);
}
}
}
diff --git a/platform/platform-api/src/com/intellij/notification/Notification.java b/platform/platform-api/src/com/intellij/notification/Notification.java
index 674e20282334..7b3ecd67ca47 100644
--- a/platform/platform-api/src/com/intellij/notification/Notification.java
+++ b/platform/platform-api/src/com/intellij/notification/Notification.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -62,7 +63,7 @@ public class Notification {
myType = type;
myListener = listener;
- LOG.assertTrue(myContent.trim().length() > 0, "Notification should have content, groupId: " + myGroupId);
+ LOG.assertTrue(!StringUtil.isEmptyOrSpaces(myContent), "Notification should have content, groupId: " + myGroupId);
}
@SuppressWarnings("MethodMayBeStatic")
diff --git a/platform/platform-api/src/com/intellij/notification/NotificationGroup.java b/platform/platform-api/src/com/intellij/notification/NotificationGroup.java
index df68daff1584..a1b838676f41 100644
--- a/platform/platform-api/src/com/intellij/notification/NotificationGroup.java
+++ b/platform/platform-api/src/com/intellij/notification/NotificationGroup.java
@@ -54,18 +54,22 @@ public final class NotificationGroup {
ourRegisteredGroups.put(displayId, this);
}
+ @NotNull
public static NotificationGroup balloonGroup(@NotNull String displayId) {
return new NotificationGroup(displayId, NotificationDisplayType.BALLOON, true);
}
+ @NotNull
public static NotificationGroup logOnlyGroup(@NotNull String displayId) {
return new NotificationGroup(displayId, NotificationDisplayType.NONE, true);
}
+ @NotNull
public static NotificationGroup toolWindowGroup(@NotNull String displayId, @NotNull String toolWindowId, final boolean logByDefault) {
return new NotificationGroup(displayId, NotificationDisplayType.TOOL_WINDOW, logByDefault, toolWindowId);
}
+ @NotNull
public static NotificationGroup toolWindowGroup(@NotNull String displayId, @NotNull String toolWindowId) {
return toolWindowGroup(displayId, toolWindowId, true);
}
@@ -78,10 +82,12 @@ public final class NotificationGroup {
return createNotification(content, type.toNotificationType());
}
+ @NotNull
public Notification createNotification(@NotNull final String content, @NotNull final NotificationType type) {
return createNotification("", content, type, null);
}
+ @NotNull
public Notification createNotification(@NotNull final String title,
@NotNull final String content,
@NotNull final NotificationType type,
diff --git a/platform/platform-api/src/com/intellij/notification/NotificationListener.java b/platform/platform-api/src/com/intellij/notification/NotificationListener.java
index 8577d7d6a469..e88204f6888a 100644
--- a/platform/platform-api/src/com/intellij/notification/NotificationListener.java
+++ b/platform/platform-api/src/com/intellij/notification/NotificationListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 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.
@@ -35,7 +35,7 @@ public interface NotificationListener {
protected abstract void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e);
}
- NotificationListener URL_OPENING_LISTENER = new UrlOpeningListener(false);
+ NotificationListener URL_OPENING_LISTENER = new UrlOpeningListener(true);
class UrlOpeningListener extends Adapter {
private final boolean myExpireNotification;
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java
index 16a81d2218d2..aa1248775a21 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java
@@ -26,6 +26,9 @@ import org.jetbrains.annotations.NotNull;
public abstract class ActionPlaces {
public static final String UNKNOWN = "unknown";
+ /**
+ * consider to use {@link #isMainMenuOrActionSearch(String)} instead
+ */
public static final String MAIN_MENU = "MainMenu";
public static final String MAIN_TOOLBAR = "MainToolbar";
public static final String EDITOR_POPUP = "EditorPopup";
@@ -45,6 +48,7 @@ public abstract class ActionPlaces {
public static final String STATUS_BAR_PLACE = "StatusBarPlace";
public static final String SCOPE_VIEW_POPUP = "ScopeViewPopup";
+ public static final String ACTION_SEARCH = "GoToAction";
public static final String TESTTREE_VIEW_POPUP = "TestTreeViewPopup";
public static final String TESTTREE_VIEW_TOOLBAR = "TestTreeViewToolbar";
@@ -127,6 +131,10 @@ public abstract class ActionPlaces {
return ArrayUtil.find(ourToolbarPlaces, place) != -1;
}
+ public static boolean isMainMenuOrActionSearch(String place) {
+ return MAIN_MENU.equals(place) || ACTION_SEARCH.equals(place);
+ }
+
private static final String[] ourPopupPlaces = {EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP,
PROJECT_VIEW_POPUP, FAVORITES_VIEW_POPUP, SCOPE_VIEW_POPUP, TESTTREE_VIEW_POPUP, TESTSTATISTICS_VIEW_POPUP, TYPE_HIERARCHY_VIEW_POPUP,
METHOD_HIERARCHY_VIEW_POPUP, CALL_HIERARCHY_VIEW_POPUP, J2EE_ATTRIBUTES_VIEW_POPUP, J2EE_VIEW_POPUP, USAGE_VIEW_POPUP,
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java
index 2dd2ee50d120..191c8c01ce32 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java
@@ -42,6 +42,11 @@ public final class Separator extends AnAction implements DumbAware {
}
@Override
+ public String toString() {
+ return "Separator (" + myText + ")";
+ }
+
+ @Override
public void actionPerformed(AnActionEvent e){
throw new UnsupportedOperationException();
}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java
index 5f179baad831..3e52f26d0b87 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java
@@ -43,12 +43,8 @@ public abstract class CheckboxAction extends ToggleAction implements CustomCompo
public JComponent createCustomComponent(Presentation presentation) {
// this component cannot be stored right here because of action system architecture:
// one action can be shown on multiple toolbars simultaneously
- JCheckBox checkBox = new JCheckBox(presentation.getText());
+ JCheckBox checkBox = new JCheckBox();
checkBox.setOpaque(false);
- checkBox.setToolTipText(presentation.getDescription());
- checkBox.setMnemonic(presentation.getMnemonic());
- checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex());
- checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)));
checkBox.addActionListener(new ActionListener() {
@Override
@@ -69,13 +65,19 @@ public abstract class CheckboxAction extends ToggleAction implements CustomCompo
@Override
public void update(final AnActionEvent e) {
super.update(e);
- Object property = e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
+ Presentation presentation = e.getPresentation();
+ Object property = presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY);
if (property instanceof JCheckBox) {
JCheckBox checkBox = (JCheckBox)property;
- checkBox.setSelected(Boolean.TRUE.equals(e.getPresentation().getClientProperty(SELECTED_PROPERTY)));
- checkBox.setEnabled(e.getPresentation().isEnabled());
- checkBox.setVisible(e.getPresentation().isVisible());
+ checkBox.setText(presentation.getText());
+ checkBox.setToolTipText(presentation.getDescription());
+ checkBox.setMnemonic(presentation.getMnemonic());
+ checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex());
+ checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)));
+
+ checkBox.setEnabled(presentation.isEnabled());
+ checkBox.setVisible(presentation.isVisible());
}
}
}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
index 7398bf706c78..6ce522141f16 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
@@ -26,10 +26,7 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
-import com.intellij.ui.ColorUtil;
-import com.intellij.ui.Gray;
-import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.JBColor;
+import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.UIUtil;
@@ -103,7 +100,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
return 1;
}
- protected class ComboBoxButton extends JButton {
+ protected class ComboBoxButton extends JButton implements UserActivityProviderComponent {
private final Presentation myPresentation;
private boolean myForcePressed = false;
private PropertyChangeListener myButtonSynchronizer;
@@ -227,6 +224,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
}
});
repaint();
+ fireStateChanged();
}
};
diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java
index c4b3a6384f56..86e322f6e0e3 100644
--- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java
+++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.application;
+import org.jetbrains.annotations.Nullable;
+
/**
* Implementers of the interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER}
* may be capable of processing an external command line within a running IntelliJ Platform instance.
@@ -28,5 +30,10 @@ public abstract class ApplicationStarterEx implements ApplicationStarter {
return false;
}
+ @Deprecated
public void processExternalCommandLine(String[] args) { }
+
+ public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) {
+ processExternalCommandLine(args);
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java
index 9f1b8e06b39e..c68e45189a95 100644
--- a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java
+++ b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.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.
@@ -18,6 +18,8 @@ package com.intellij.openapi.diagnostic;
import com.intellij.openapi.extensions.PluginAware;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.util.Consumer;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -44,33 +46,43 @@ public abstract class ErrorReportSubmitter implements PluginAware {
}
/**
- * @return "Report to vendor" action text to be used in Error Reporter user interface. For example: "Report to JetBrains".
+ * @return an action text to be used in Error Reporter user interface, e.g. "Report to JetBrains".
*/
public abstract String getReportActionText();
/**
- * This method is called whenever fatal error (aka exception) in plugin code had happened and user decided to report this problem to
- * plugin vendor.
- * @param events sequence of the fatal error descriptors. Fatal errors that happened immediately one after another most probably caused
- * by first one that happened so it's a common practice to submit only first one. Array passed is guaranteed to have at least one element.
- * @param parentComponent one usually wants to show up a dialog asking user for additional details and probably authentication info.
- * parentComponent parameter is passed so dialog that would come up would be properly aligned with its parent dialog (IDE Fatal Errors).
- * @return submission result status.
+ * This method is called whenever an exception in a plugin code had happened and a user decided to report a problem to the plugin vendor.
+ *
+ * @param events a non-empty sequence of error descriptors.
+ * @param additionalInfo additional information provided by a user.
+ * @param parentComponent UI component to use as a parent in any UI activity from a submitter.
+ * @param consumer a callback to be called after sending is finished (or failed).
+ * @return {@code true} if reporting was started, {@code false} if a report can't be sent at the moment.
*/
- public abstract SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parentComponent);
-
- public void submitAsync(IdeaLoggingEvent[] events,
- String additionalInfo,
- Component parentComponent,
- Consumer<SubmittedReportInfo> consumer) {
- consumer.consume(submit(events, parentComponent));
+ @SuppressWarnings("deprecation")
+ public boolean submit(@NotNull IdeaLoggingEvent[] events,
+ @Nullable String additionalInfo,
+ @NotNull Component parentComponent,
+ @NotNull Consumer<SubmittedReportInfo> consumer) {
+ return trySubmitAsync(events, additionalInfo, parentComponent, consumer);
}
- public boolean trySubmitAsync(IdeaLoggingEvent[] events,
- String additionalInfo,
- Component parentComponent,
- Consumer<SubmittedReportInfo> consumer) {
- submitAsync(events, additionalInfo, parentComponent, consumer);
+ /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */
+ @SuppressWarnings({"deprecation", "unused"})
+ public boolean trySubmitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<SubmittedReportInfo> consumer) {
+ submitAsync(events, info, parent, consumer);
return true;
}
+
+ /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */
+ @SuppressWarnings({"deprecation", "unused"})
+ public void submitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<SubmittedReportInfo> consumer) {
+ consumer.consume(submit(events, parent));
+ }
+
+ /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */
+ @SuppressWarnings({"deprecation", "unused"})
+ public SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parent) {
+ throw new UnsupportedOperationException("Deprecated API called");
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java b/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java
index 6bad8c45df93..8ead30567681 100644
--- a/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java
+++ b/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.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.
@@ -15,6 +15,9 @@
*/
package com.intellij.openapi.diagnostic;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
/**
* Simple bean representing error submission status.
*/
@@ -31,29 +34,27 @@ public class SubmittedReportInfo {
DUPLICATE,
/**
- * Submission failed. (For network connection reasons for example)
+ * Submission failed (e.g. because of network problem)
*/
FAILED
}
- private final String myURL;
+ private final String myUrl;
private final String myLinkText;
private final SubmissionStatus myStatus;
- /**
- * Create new submission status bean
- * @param URL url that points to newly created issue. Optional. Pass <code>null</code> value if N/A or failed
- * @param linkText short text that UI interface pointing to the issue should have.
- * @param status submission success/failure
- */
- public SubmittedReportInfo(final String URL, final String linkText, final SubmissionStatus status) {
- myURL = URL;
+ public SubmittedReportInfo(SubmissionStatus status) {
+ this(null, null, status);
+ }
+
+ public SubmittedReportInfo(@Nullable String url, @Nullable String linkText, @NotNull SubmissionStatus status) {
+ myUrl = url;
myLinkText = linkText;
myStatus = status;
}
public String getURL() {
- return myURL;
+ return myUrl;
}
public String getLinkText() {
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java
index 9e0bf738a7cf..fee268813d14 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java
@@ -52,7 +52,7 @@ public class FileChooser {
@Nullable final Project project,
@Nullable final VirtualFile toSelect) {
final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, parent);
- return chooser.choose(toSelect, project);
+ return chooser.choose(project, toSelect);
}
@Nullable
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java
index c12ab422a942..324979dff228 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java
@@ -23,7 +23,22 @@ import org.jetbrains.annotations.Nullable;
public interface FileChooserDialog {
DataKey<Boolean> PREFER_LAST_OVER_TO_SELECT = PathChooserDialog.PREFER_LAST_OVER_EXPLICIT;
-
+
+ /**
+ * @deprecated Please use {@link #choose(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile...)} because
+ * it supports several selections
+ */
+ @Deprecated
@NotNull
VirtualFile[] choose(@Nullable VirtualFile toSelect, @Nullable Project project);
+
+ /**
+ * Choose one or more files
+ *
+ * @param project use this project (you may pass null if you already set project in ctor)
+ * @param toSelect files to be selected automatically.
+ * @return files chosen by user
+ */
+ @NotNull
+ VirtualFile[] choose(@Nullable Project project, @NotNull VirtualFile... toSelect);
} \ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
index 86e719eef48d..dcb1327f1a10 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
@@ -197,5 +197,5 @@ public abstract class FileEditorManager {
* @param fileEditorProviderId the ID of the file editor to open; matches the return value of
* {@link com.intellij.openapi.fileEditor.FileEditorProvider#getEditorTypeId()}
*/
- public abstract void setSelectedEditor(@NotNull VirtualFile file, String fileEditorProviderId);
+ public abstract void setSelectedEditor(@NotNull VirtualFile file, @NotNull String fileEditorProviderId);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
index 78a4c1ece130..828907c13cfb 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
@@ -175,9 +175,25 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
return getDisplayName();
}
+ public boolean canCreateConfigurable() {
+ if (providerClass == null) {
+ return implementationClass != null || instanceClass != null;
+ }
+ try {
+ ConfigurableProvider provider = instantiate(providerClass, myPicoContainer);
+ return provider.canCreateConfigurable(); // do not load heavy configurables
+ }
+ catch (Exception ignored) {
+ return true; // see InstanceFromProviderFactory#compute
+ }
+ }
+
private class InstanceFromProviderFactory extends AtomicNotNullLazyValue<ConfigurableProvider> implements NullableFactory<T> {
public T create() {
- return (T)getValue().createConfigurable();
+ ConfigurableProvider provider = getValue();
+ return provider.canCreateConfigurable()
+ ? (T)provider.createConfigurable()
+ : null;
}
@NotNull
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java
index 5a71ffa73050..cf2bc0390c5a 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java
@@ -29,4 +29,15 @@ public abstract class ConfigurableProvider {
@Nullable
public abstract Configurable createConfigurable();
+ /**
+ * Defines whether this provider creates a configurable or not.
+ * Note that the {@code createConfigurable} method will be called
+ * if this method returns {@code true}.
+ *
+ * @return {@code true} if this provider creates configurable,
+ * {@code false} otherwise
+ */
+ public boolean canCreateConfigurable() {
+ return true;
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java b/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java
index 473dce3dda6c..2395fa27f4c1 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.options;
+@Deprecated
public interface CurrentUserHolder {
String getCurrentUserName();
}
diff --git a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
index e98bb05aba99..b426e35d77a8 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
@@ -34,6 +34,12 @@ public interface SearchableConfigurable extends Configurable {
interface Parent extends SearchableConfigurable, Composite {
boolean hasOwnContent();
+
+ /**
+ * @deprecated use {@link ConfigurableProvider#canCreateConfigurable()} instead
+ * to specify configurables which should not be visible
+ */
+ @Deprecated
boolean isVisible();
abstract class Abstract implements Parent {
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
index 741f67dee2c4..a291ab32e950 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
@@ -2001,12 +2001,19 @@ public abstract class DialogWrapper {
*/
public interface DoNotAskOption {
+ /**
+ * @return default selection state of checkbox (false -> checkbox selected)
+ */
boolean isToBeShown();
- void setToBeShown(boolean value, int exitCode);
+ /**
+ * @param toBeShown - if dialog should be shown next time (checkbox selected -> false)
+ * @param exitCode of corresponding DialogWrapper
+ */
+ void setToBeShown(boolean toBeShown, int exitCode);
/**
- * Should be 'true' for checkbox to be visible.
+ * @return true if checkbox should be shown
*/
boolean canBeHidden();
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
index a262ea0a3b85..547fa03e438d 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
@@ -131,7 +131,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
protected MasterDetailsComponent(MasterDetailsState state) {
myState = state;
- mySplitter = Registry.is("ide.new.project.settings") ? new OnePixelSplitter(false, .2f) : new JBSplitter(false, .2f);
+ mySplitter = isNewProjectSettings() ? new OnePixelSplitter(false, .2f) : new JBSplitter(false, .2f);
mySplitter.setSplitterProportionKey("ProjectStructure.SecondLevelElements");
mySplitter.setHonorComponentsMinimumSize(true);
@@ -139,6 +139,20 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
reInitWholePanelIfNeeded();
}
+ private boolean isNewProjectSettings() {
+ if (!Registry.is("ide.new.project.settings")) {
+ return false;
+ }
+ try {
+ // assume that only project structure dialog uses the following base class for details:
+ String name = "com.intellij.openapi.roots.ui.configuration.projectRoot.BaseStructureConfigurable";
+ return Class.forName(name).isAssignableFrom(getClass());
+ }
+ catch (ClassNotFoundException ignored) {
+ return false;
+ }
+ }
+
protected void reInitWholePanelIfNeeded() {
if (!myToReInitWholePanel) return;
@@ -170,7 +184,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
}
};
- if (Registry.is("ide.new.project.settings")) {
+ if (isNewProjectSettings()) {
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree);
DefaultActionGroup group = createToolbarActionGroup();
if (group != null) {
@@ -281,7 +295,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
}
private void initToolbar() {
- if (Registry.is("ide.new.project.settings")) return;
+ if (isNewProjectSettings()) return;
DefaultActionGroup group = createToolbarActionGroup();
if (group != null) {
final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
index 1a07b33d696d..e963871cfd5f 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
@@ -377,6 +377,33 @@ public class Messages {
* @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
*/
@YesNoResult
+ public static int showYesNoDialog(@Nullable Project project,
+ String message,
+ @NotNull String title,
+ @NotNull String yesText,
+ @NotNull String noText,
+ @Nullable Icon icon,
+ @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
+ try {
+ if (canShowMacSheetPanel()) {
+ return MacMessages.getInstance()
+ .showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption);
+ }
+ }
+ catch (Exception exception) {
+ LOG.error(exception);
+ }
+
+ int result = showDialog(project, message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption) == 0 ? YES : NO;
+ //noinspection ConstantConditions
+ LOG.assertTrue(result == YES || result == NO, result);
+ return result;
+ }
+
+ /**
+ * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
+ */
+ @YesNoResult
public static int showYesNoDialog(@Nullable Project project, String message, @NotNull String title, @Nullable Icon icon) {
try {
if (canShowMacSheetPanel()) {
@@ -394,6 +421,31 @@ public class Messages {
return result;
}
+ /**
+ * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
+ */
+ @YesNoResult
+ public static int showYesNoDialog(@Nullable Project project,
+ String message,
+ @NotNull String title,
+ @Nullable Icon icon,
+ @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
+ try {
+ if (canShowMacSheetPanel()) {
+ return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON,
+ WindowManager.getInstance().suggestParentWindow(project), doNotAskOption);
+ }
+ }
+ catch (Exception exception) {
+ LOG.error(exception);
+ }
+
+ int result = showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon, doNotAskOption);
+
+ LOG.assertTrue(result == YES || result == NO, result);
+ return result;
+ }
+
/**
* @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java
index 2a55c3bd342a..3bb5302e7f2e 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 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,16 +32,16 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T
private List<Icon> myIcons;
private int myDefaultOptionIndex = -1;
- public BaseListPopupStep(@Nullable String aTitle, T[] aValues) {
- this(aTitle, aValues, new Icon[]{});
+ public BaseListPopupStep(@Nullable String title, T[] values) {
+ this(title, values, new Icon[]{});
}
- public BaseListPopupStep(@Nullable String aTitle, List<? extends T> aValues) {
- this(aTitle, aValues, new ArrayList<Icon>());
+ public BaseListPopupStep(@Nullable String title, List<? extends T> values) {
+ this(title, values, new ArrayList<Icon>());
}
- public BaseListPopupStep(@Nullable String aTitle, T[] aValues, Icon[] aIcons) {
- this(aTitle, Arrays.asList(aValues), Arrays.asList(aIcons));
+ public BaseListPopupStep(@Nullable String title, T[] values, Icon[] icons) {
+ this(title, Arrays.asList(values), Arrays.asList(icons));
}
public BaseListPopupStep(@Nullable String aTitle, @NotNull List<? extends T> aValues, Icon aSameIcon) {
@@ -53,16 +53,16 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T
init(aTitle, aValues, icons);
}
- public BaseListPopupStep(@Nullable String aTitle, @NotNull List<? extends T> aValues, List<Icon> aIcons) {
- init(aTitle, aValues, aIcons);
+ public BaseListPopupStep(@Nullable String title, @NotNull List<? extends T> values, List<Icon> icons) {
+ init(title, values, icons);
}
protected BaseListPopupStep() { }
- protected final void init(@Nullable String aTitle, @NotNull List<? extends T> aValues, @Nullable List<Icon> aIcons) {
- myTitle = aTitle;
- myValues = new ArrayList<T>(aValues);
- myIcons = aIcons;
+ protected final void init(@Nullable String title, @NotNull List<? extends T> values, @Nullable List<Icon> icons) {
+ myTitle = title;
+ myValues = new ArrayList<T>(values);
+ myIcons = icons;
}
@Nullable
@@ -79,8 +79,8 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T
return FINAL_CHOICE;
}
- public Icon getIconFor(T aValue) {
- int index = myValues.indexOf(aValue);
+ public Icon getIconFor(T value) {
+ int index = myValues.indexOf(value);
if (index != -1 && myIcons != null && index < myIcons.size()) {
return myIcons.get(index);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
index 965b3c0de9bf..3c775f5b2e8c 100644
--- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
+++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
@@ -21,7 +21,6 @@ package com.intellij.openapi.vfs.newvfs;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.DataInputOutputUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -60,33 +59,12 @@ public class FileAttribute {
@Nullable
public DataInputStream readAttribute(@NotNull VirtualFile file) {
- DataInputStream stream = ManagingFS.getInstance().readAttribute(file, this);
- if (stream != null) {
- try {
- int actualVersion = DataInputOutputUtil.readINT(stream);
- if (actualVersion != myVersion) {
- stream.close();
- return null;
- }
- }
- catch (IOException e) {
- return null;
- }
- }
- return stream;
+ return ManagingFS.getInstance().readAttribute(file, this);
}
@NotNull
public DataOutputStream writeAttribute(@NotNull VirtualFile file) {
- final DataOutputStream stream = ManagingFS.getInstance().writeAttribute(file, this);
- try {
- DataInputOutputUtil.writeINT(stream, myVersion);
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- return stream;
+ return ManagingFS.getInstance().writeAttribute(file, this);
}
@Nullable
@@ -131,4 +109,8 @@ public class FileAttribute {
public FileAttribute newVersion(int newVersion) {
return new FileAttribute(newVersion, myFixedSize, myId);
}
+
+ public int getVersion() {
+ return myVersion;
+ }
}
diff --git a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
index c301aa3be252..d806eb2e06b8 100644
--- a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
+++ b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
@@ -103,6 +103,7 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
Collections.sort(myItems, comparator);
}
+ @NotNull
public List<T> getItems() {
return Collections.unmodifiableList(myItems);
}
diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredText.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredText.java
index af851951e363..8c899f1a6b5c 100644
--- a/platform/platform-api/src/com/intellij/ui/SimpleColoredText.java
+++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredText.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.
@@ -45,6 +45,12 @@ public class SimpleColoredText implements ColoredTextContainer {
myAttributes.add(attributes);
}
+ public void insert(int index, @NotNull String fragment, @NotNull SimpleTextAttributes attributes) {
+ myTexts.add(index, fragment);
+ myCachedToString = null;
+ myAttributes.add(index, attributes);
+ }
+
@Override
public void append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes, Object tag) {
append(fragment, attributes);
diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java
index 129217ec7e4a..0416008d1d57 100644
--- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java
+++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java
@@ -204,6 +204,8 @@ public class LinkLabel<T> extends JLabel {
}
private boolean isInClickableArea(Point pt) {
+ Insets insets = getInsets(); // border is set
+ pt.translate(-insets.left, -insets.top);
if (getIcon() != null) {
if (pt.getX() < getIcon().getIconWidth() && pt.getY() < getIcon().getIconHeight()) {
return true;
diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java
index c1146be40aba..a65c209399bf 100644
--- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java
+++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java
@@ -572,7 +572,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
private final class MyMouseListener extends MouseAdapter {
@Override
public void mousePressed(@NotNull final MouseEvent e) {
- if (SwingUtilities.isRightMouseButton(e)) {
+ if (JBSwingUtilities.isRightMouseButton(e)) {
final int[] selectedRows = getSelectedRows();
if (selectedRows.length < 2) {
final int row = rowAtPoint(e.getPoint());
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
index c8c50bc94680..30314135a543 100644
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
@@ -20,14 +20,12 @@ import com.intellij.ide.util.treeView.*;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.*;
import com.intellij.util.ReflectionUtil;
-import com.intellij.util.ui.AsyncProcessIcon;
-import com.intellij.util.ui.ComponentWithEmptyText;
-import com.intellij.util.ui.StatusText;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.*;
import com.intellij.util.ui.tree.WideSelectionTreeUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -143,7 +141,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
@SuppressWarnings("unchecked")
@NotNull
protected Condition<Integer> getWideSelectionBackgroundCondition() {
- return Condition.TRUE;
+ return Conditions.alwaysTrue();
}
@Override
@@ -673,8 +671,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
private class MyMouseListener extends MouseAdapter {
@Override
public void mousePressed(MouseEvent mouseevent) {
- if (!SwingUtilities.isLeftMouseButton(mouseevent) &&
- (SwingUtilities.isRightMouseButton(mouseevent) || SwingUtilities.isMiddleMouseButton(mouseevent))) {
+ if (!JBSwingUtilities.isLeftMouseButton(mouseevent) &&
+ (JBSwingUtilities.isRightMouseButton(mouseevent) || JBSwingUtilities.isMiddleMouseButton(mouseevent))) {
TreePath treepath = getPathForLocation(mouseevent.getX(), mouseevent.getY());
if (treepath != null) {
if (getSelectionModel().getSelectionMode() != TreeSelectionModel.SINGLE_TREE_SELECTION) {
@@ -842,7 +840,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
* @return the deepest visible component of the renderer
*/
@Nullable
- protected Component getDeepestRendererComponentAt(int x, int y) {
+ public Component getDeepestRendererComponentAt(int x, int y) {
int row = getRowForLocation(x, y);
if (row >= 0) {
TreeCellRenderer renderer = getCellRenderer();
diff --git a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java
index 34238e57c635..ffcb0870dc3c 100644
--- a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java
+++ b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 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.
@@ -75,7 +75,7 @@ public class QueueProcessor<T> {
* Constructs a QueueProcessor, which will autostart as soon as the first element is added to it.
*/
public QueueProcessor(@NotNull Consumer<T> processor) {
- this(processor, Condition.FALSE);
+ this(processor, Conditions.alwaysFalse());
}
/**
diff --git a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
index 0f9855001b63..757706127a38 100644
--- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
+++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
@@ -61,7 +61,7 @@ import java.util.*;
@Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml"),
@Storage(file = StoragePathMacros.APP_CONFIG + "/proxy.settings.xml")
},
- storageChooser = HttpConfigurable.StorageChooser.class
+ storageChooser = LastStorageChooserForWrite.class
)
public class HttpConfigurable implements PersistentStateComponent<HttpConfigurable>, ExportableApplicationComponent {
public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("idea.connection.timeout", 10000);
@@ -519,20 +519,6 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
return "Proxy Settings";
}
- public static class StorageChooser implements StateStorageChooser<HttpConfigurable> {
- @Override
- public Storage[] selectStorages(Storage[] storages, HttpConfigurable component, StateStorageOperation operation) {
- if (operation == StateStorageOperation.WRITE) {
- for (Storage storage : storages) {
- if (storage.file().equals(StoragePathMacros.APP_CONFIG + "/proxy.settings.xml")) {
- return new Storage[] {storage};
- }
- }
- }
- return storages;
- }
- }
-
public static class ProxyInfo {
public boolean myStore;
public String myUsername;
diff --git a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java
index a1e36236c0e4..ff86990d7d16 100644
--- a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java
+++ b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateUtil.java
@@ -1,8 +1,21 @@
+/*
+ * 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.
+ * 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.util.net.ssl;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.io.StreamUtil;
-import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,55 +26,46 @@ import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
/**
+ * Names in constants match
+ * <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html">Standard Algorithm Name Documentation</a>.
+ *
* @author Mikhail Golubev
*/
public class CertificateUtil {
- private static final Logger LOG = Logger.getInstance(CertificateUtil.class);
+ public static final String X509 = "X.509";
+ public static final String JKS = "JKS";
+ public static final String PKCS12 = "PKCS12";
+ public static final String PKIX = "PKIX";
+ public static final String TLS = "TLS";
private static final CertificateFactory ourFactory = createFactory();
private static CertificateFactory createFactory() {
try {
- return CertificateFactory.getInstance("X509");
+ return CertificateFactory.getInstance(X509);
}
catch (CertificateException e) {
- throw new AssertionError("Can't initialize X509 certificate factory");
+ throw new RuntimeException("Can't initialize X.509 certificate factory", e);
}
}
- // Standard Names
- // See complete reference at http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html
- // certificate format
- @Nls public static final String X509 = "X.509";
- // Java Key Store - standard type of keystores used by keytool utility
- @Nls public static final String JKS = "JKS";
- // another standard type of keystore
- @Nls public static final String PKCS12 = "PKCS12";
- // type of trust manager factory
- @Nls public static final String PKIX = "PKIX";
- @Nls public static final String TLS = "TLS";
-
- /**
- * Utility class
- */
- private CertificateUtil() {
- // empty
- }
+ private CertificateUtil() { }
@Nullable
public static X509Certificate loadX509Certificate(@NotNull String path) {
- InputStream stream = null;
try {
- stream = new FileInputStream(path);
- return (X509Certificate)ourFactory.generateCertificate(stream);
+ InputStream stream = new FileInputStream(path);
+ try {
+ return (X509Certificate)ourFactory.generateCertificate(stream);
+ }
+ finally {
+ stream.close();
+ }
}
catch (Exception e) {
- LOG.error("Can't add certificate for path: " + path, e);
+ Logger.getInstance(CertificateUtil.class).error("Can't add certificate for path: " + path, e);
return null;
}
- finally {
- StreamUtil.closeStream(stream);
- }
}
/**
diff --git a/platform/platform-api/src/com/intellij/util/ui/Animator.java b/platform/platform-api/src/com/intellij/util/ui/Animator.java
index 94da2b15ba7a..55578fe8d994 100644
--- a/platform/platform-api/src/com/intellij/util/ui/Animator.java
+++ b/platform/platform-api/src/com/intellij/util/ui/Animator.java
@@ -64,7 +64,7 @@ public abstract class Animator implements Disposable {
reset();
- if (ApplicationManager.getApplication() == null) {
+ if (noApplication()) {
animationDone();
}
}
@@ -133,8 +133,7 @@ public abstract class Animator implements Disposable {
}
public void resume() {
- final Application app = ApplicationManager.getApplication();
- if (app == null || app.isUnitTestMode()) {
+ if (noApplication()) {
animationDone();
return;
}
@@ -164,6 +163,11 @@ public abstract class Animator implements Disposable {
}
}
+ protected boolean noApplication() {
+ Application app = ApplicationManager.getApplication();
+ return app == null || app.isUnitTestMode();
+ }
+
public abstract void paintNow(int frame, int totalFrames, int cycle);
@Override