summaryrefslogtreecommitdiff
path: root/platform/platform-api/src/com/intellij/openapi
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi')
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java3
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java7
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java12
-rw-r--r--platform/platform-api/src/com/intellij/openapi/application/ApplicationStarter.java27
-rw-r--r--platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java18
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diff/ActionButtonPresentation.java2
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diff/ApplicationStarterBase.java177
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diff/DiffApplication.java81
-rw-r--r--platform/platform-api/src/com/intellij/openapi/diff/MergeApplication.java53
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java54
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java89
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableBase.java98
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java3
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableUi.java31
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java8
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/SimpleConfigurable.java52
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/Banner.java3
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java88
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java38
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java8
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java21
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java1
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/Messages.java9
-rw-r--r--platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java14
-rw-r--r--platform/platform-api/src/com/intellij/openapi/util/registry/RegistryState.java14
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java1
26 files changed, 446 insertions, 466 deletions
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 e3248b863aba..16a81d2218d2 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java
@@ -76,6 +76,7 @@ public abstract class ActionPlaces {
public static final String ANT_MESSAGES_TOOLBAR = "AntMessagesToolbar";
public static final String ANT_EXPLORER_POPUP = "AntExplorerPopup";
public static final String ANT_EXPLORER_TOOLBAR = "AntExplorerToolbar";
+ public static final String GULP_VIEW_POPUP = "JavaScriptGulpPopup";
//todo: probably these context should be splitted into several contexts
public static final String CODE_INSPECTION = "CodeInspection";
@@ -133,7 +134,7 @@ public abstract class ActionPlaces {
FILEVIEW_POPUP, CHECKOUT_POPUP, LVCS_DIRECTORY_HISTORY_POPUP, GUI_DESIGNER_EDITOR_POPUP, GUI_DESIGNER_COMPONENT_TREE_POPUP,
GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP,
CREATE_EJB_POPUP, CHANGES_VIEW_POPUP, REMOTE_HOST_VIEW_POPUP, REMOTE_HOST_DIALOG_POPUP, TFS_TREE_POPUP,
- ACTION_PLACE_VCS_QUICK_LIST_POPUP_ACTION, PHING_EXPLORER_POPUP, NAVIGATION_BAR_POPUP
+ ACTION_PLACE_VCS_QUICK_LIST_POPUP_ACTION, PHING_EXPLORER_POPUP, NAVIGATION_BAR_POPUP, GULP_VIEW_POPUP
};
public static boolean isPopupPlace(@NotNull String place) {
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java
index 09896aaf0da8..c96ce2aa3371 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java
@@ -29,6 +29,7 @@ public class ActionStub extends AnAction{
private static final Logger LOG=Logger.getInstance("#com.intellij.openapi.actionSystem.ActionStub");
private final String myClassName;
+ private final String myProjectType;
private final String myId;
private final String myText;
private final ClassLoader myLoader;
@@ -40,9 +41,10 @@ public class ActionStub extends AnAction{
@NotNull String text,
ClassLoader loader,
PluginId pluginId,
- String iconPath) {
+ String iconPath, String projectType) {
myLoader = loader;
myClassName=actionClass;
+ myProjectType = projectType;
LOG.assertTrue(!id.isEmpty());
myId=id;
myText=text;
@@ -102,4 +104,7 @@ public class ActionStub extends AnAction{
targetAction.setShortcutSet(getShortcutSet());
}
+ public String getProjectType() {
+ return myProjectType;
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
index 994dd130c384..a1441565d90b 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
@@ -15,9 +15,11 @@
*/
package com.intellij.openapi.actionSystem;
+import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.util.SystemInfo;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.InputEvent;
@@ -148,9 +150,13 @@ public class CommonShortcuts {
return shortcutsById(IdeActions.ACTION_DELETE);
}
+ @NotNull
private static CustomShortcutSet shortcutsById(String actionId) {
- if (ApplicationManager.getApplication() == null) return new CustomShortcutSet(Shortcut.EMPTY_ARRAY);
-
- return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId));
+ Application application = ApplicationManager.getApplication();
+ KeymapManager keymapManager = application == null ? null : application.getComponent(KeymapManager.class);
+ if (keymapManager == null) {
+ return new CustomShortcutSet(Shortcut.EMPTY_ARRAY);
+ }
+ return new CustomShortcutSet(keymapManager.getActiveKeymap().getShortcuts(actionId));
}
}
diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarter.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarter.java
index cd0dd2aef263..ffacf59315cd 100644
--- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarter.java
+++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarter.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.
@@ -20,8 +20,8 @@ import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NonNls;
/**
- * Implementors of this interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER} contribute a
- * command line application based on IDEA platform.
+ * Implementers of the interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER}
+ * contribute to a command-line processing capability of an application.
*
* @author max
* @see ApplicationStarterEx
@@ -30,25 +30,26 @@ public interface ApplicationStarter {
ExtensionPointName<ApplicationStarter> EP_NAME = ExtensionPointName.create(ExtensionPoints.APPLICATION_STARTER);
/**
- * Command line switch to start with this runner. For example return "inspect" if you'd like to start app with
- * <code>idea.exe inspect</code> cmdline.
- * @return command line selector.
+ * Command-line switch to start with this runner.
+ * For example return {@code "inspect"} if you'd like to start an app with {@code "idea.exe inspect ..."} command).
+ *
+ * @return command-line selector.
*/
@NonNls
String getCommandName();
/**
- * Called before application initialization. Invoked in awt dispatch thread.
- * @param args cmdline arguments including declared selector. For example <code>"idea.exe inspect myproject.ipr"</code>
- * will pass <code>{"inspect", "myproject.ipr"}</code>
+ * Called before application initialization. Invoked in event dispatch thread.
+ *
+ * @param args program arguments (including the selector)
*/
void premain(String[] args);
/**
- * Called when application have been initialized. Invoked in awt dispatch thread. An application starter should take care terminating
- * JVM itself when appropriate by calling {@link java.lang.System#exit}(0);
- * @param args cmdline arguments including declared selector. For example <code>"idea.exe inspect myproject.ipr"</code>
- * will pass <code>{"inspect", "myproject.ipr"}</code>
+ * <p>Called when application has been initialized. Invoked in event dispatch thread.</p>
+ * <p>An application starter should take care of terminating JVM when appropriate by calling {@link System#exit}.</p>
+ *
+ * @param args program arguments (including the selector)
*/
void main(String[] args);
}
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 f84fc1481547..c4b3a6384f56 100644
--- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java
+++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.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.
@@ -16,11 +16,17 @@
package com.intellij.openapi.application;
/**
- * Implementors of this interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER} are also capable of processing
- * an external command line within a running IntelliJ Platform instance.
-
+ * 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.
+ *
* @author yole
*/
-public interface ApplicationStarterEx extends ApplicationStarter {
- void processExternalCommandLine(String[] args);
+public abstract class ApplicationStarterEx implements ApplicationStarter {
+ public abstract boolean isHeadless();
+
+ public boolean canProcessExternalCommandLine() {
+ return false;
+ }
+
+ public void processExternalCommandLine(String[] args) { }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/ActionButtonPresentation.java b/platform/platform-api/src/com/intellij/openapi/diff/ActionButtonPresentation.java
index a8dbcdbc45e0..c4ae87fb1e02 100644
--- a/platform/platform-api/src/com/intellij/openapi/diff/ActionButtonPresentation.java
+++ b/platform/platform-api/src/com/intellij/openapi/diff/ActionButtonPresentation.java
@@ -29,7 +29,7 @@ public abstract class ActionButtonPresentation {
}
};
- public static ActionButtonPresentation CANCEL_WITH_PROMPT = new ActionButtonPresentation(CommonBundle.getCancelButtonText()) {
+ public static ActionButtonPresentation CANCEL_WITH_PROMPT = new ActionButtonPresentation("Revert") {
@Override
public void run(DialogWrapper dialog) {
if (Messages.showYesNoDialog(dialog.getRootPane(),
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/ApplicationStarterBase.java b/platform/platform-api/src/com/intellij/openapi/diff/ApplicationStarterBase.java
deleted file mode 100644
index 21e9f7595082..000000000000
--- a/platform/platform-api/src/com/intellij/openapi/diff/ApplicationStarterBase.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2000-2012 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.openapi.diff;
-
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ApplicationStarterEx;
-import com.intellij.openapi.application.PathManager;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.io.StreamUtil;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.JarFileSystem;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Arrays;
-
-/**
- * @author Konstantin Bulenkov
- */
-@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
-public abstract class ApplicationStarterBase implements ApplicationStarterEx {
- private final String myCommandName;
- private final int[] myArgsCount;
-
- protected ApplicationStarterBase(String commandName, int... possibleArgumentsCount) {
- myCommandName = commandName;
- myArgsCount = possibleArgumentsCount;
- }
-
- @Override
- public String getCommandName() {
- return myCommandName;
- }
-
- @Override
- public void processExternalCommandLine(String[] args) {
- if (!checkArguments(args)) {
- Messages.showMessageDialog(getUsageMessage(), StringUtil.toTitleCase(getCommandName()), Messages.getInformationIcon());
- return;
- }
- try {
- processCommand(args);
- }
- catch (Exception e) {
- Messages.showMessageDialog(String.format("Error showing %s: %s", getCommandName(), e.getMessage()),
- StringUtil.toTitleCase(getCommandName()),
- Messages.getErrorIcon());
- }
- finally {
- saveAll();
- }
- }
-
- private static void saveAll() {
- FileDocumentManager.getInstance().saveAllDocuments();
- ApplicationManager.getApplication().saveSettings();
- }
-
- private boolean checkArguments(String[] args) {
- return Arrays.binarySearch(myArgsCount, args.length - 1) != -1 && getCommandName().equals(args[0]);
- }
-
- public abstract String getUsageMessage();
-
- protected abstract void processCommand(String[] args) throws Exception;
-
- @Override
- public void premain(String[] args) {
- if (!checkArguments(args)) {
- System.err.println(getUsageMessage());
- System.exit(1);
- }
- }
-
- @Override
- public void main(String[] args) {
- try {
- processCommand(args);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- catch (Throwable t) {
- t.printStackTrace();
- System.exit(2);
- }
- finally {
- saveAll();
- }
-
- System.exit(0);
- }
-
- public static VirtualFile findOrCreateFile(String path) throws IOException {
- final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path));
- if (file == null) {
- boolean result = new File(path).createNewFile();
- if (result) {
- return findFile(path);
- }
- else {
- throw new FileNotFoundException("Can't create file " + path);
- }
- }
- return file;
- }
-
- /**
- * Get direct from file because IDEA cache files(see #IDEA-81067)
- */
- public static String getText(VirtualFile file) throws IOException {
- FileInputStream inputStream = new FileInputStream(file.getPath());
- try {
- return StreamUtil.readText(inputStream);
- }
- finally {
- inputStream.close();
- }
- }
-
- public static boolean haveDirs(VirtualFile... files) {
- for (VirtualFile file : files) {
- if (file.isDirectory()) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean areJars(VirtualFile file1, VirtualFile file2) {
- return JarFileSystem.PROTOCOL.equalsIgnoreCase(file1.getExtension()) && JarFileSystem.PROTOCOL.equalsIgnoreCase(file2.getExtension());
- }
-
- public static boolean areDirs(VirtualFile file1, VirtualFile file2) {
- return file1.isDirectory() && file2.isDirectory();
- }
-
- public static class OperationFailedException extends IOException {
- public OperationFailedException(@NotNull String message) {
- super(message);
- }
- }
-
- @NotNull
- public static VirtualFile findFile(final String path) throws OperationFailedException {
- File ioFile = new File(path);
- if (!ioFile.exists()) {
- final String dir = PathManager.getOriginalWorkingDir();
- ioFile = new File(dir + File.separator + path);
- }
- final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
- if (file == null) {
- throw new OperationFailedException("Can't find file " + path);
- }
- return file;
- }
-}
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/DiffApplication.java b/platform/platform-api/src/com/intellij/openapi/diff/DiffApplication.java
deleted file mode 100644
index ceb075a17095..000000000000
--- a/platform/platform-api/src/com/intellij/openapi/diff/DiffApplication.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2000-2012 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.openapi.diff;
-
-import com.intellij.ide.diff.DiffElement;
-import com.intellij.ide.diff.DirDiffSettings;
-import com.intellij.openapi.application.ApplicationNamesInfo;
-import com.intellij.openapi.fileTypes.UnknownFileType;
-import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.vfs.VirtualFile;
-
-/**
- * @author max
- * @author Konstantin Bulenkov
- */
-@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
-public class DiffApplication extends ApplicationStarterBase {
- public DiffApplication() {
- super("diff", 2);
- }
-
- public String getUsageMessage() {
- final String scriptName = ApplicationNamesInfo.getInstance().getScriptName();
- return DiffBundle.message("diff.application.usage.parameters.and.description", scriptName);
- }
-
- public void processCommand(String[] args) throws OperationFailedException {
- final String path1 = args[1];
- final String path2 = args[2];
- final VirtualFile file1 = findFile(path1);
- final VirtualFile file2 = findFile(path2);
- final boolean areDirs = areDirs(file1, file2);
- final boolean areJars = areJars(file1, file2);
- if (areDirs || areJars) {
- final DirDiffManager diffManager = DirDiffManager.getInstance(ProjectManager.getInstance().getDefaultProject());
- final DiffElement d1 = diffManager.createDiffElement(file1);
- final DiffElement d2 = diffManager.createDiffElement(file2);
- if (d1 == null) {
- throw new OperationFailedException(DiffBundle.message("cannot.create.diff.error", path1));
- }
- if (d2 == null) {
- throw new OperationFailedException(DiffBundle.message("cannot.create.diff.error", path1));
- }
- else if (!diffManager.canShow(d1, d2)) {
- throw new OperationFailedException(DiffBundle.message("cannot.compare.error", path1, path2));
- }
-
- final DirDiffSettings settings = new DirDiffSettings();
- settings.showInFrame = false;
- diffManager.showDiff(d1, d2, settings, null);
- }
- else {
- file1.refresh(false, false);
- file2.refresh(false, false);
-
- if (file1.getFileType() == UnknownFileType.INSTANCE) {
- throw new OperationFailedException(DiffBundle.message("unknown.file.type.error", path1));
- }
- else if (file2.getFileType() == UnknownFileType.INSTANCE) {
- throw new OperationFailedException(DiffBundle.message("unknown.file.type.error", path2));
- }
-
- SimpleDiffRequest request = SimpleDiffRequest.compareFiles(file1, file2, ProjectManager.getInstance().getDefaultProject());
- request.addHint(DiffTool.HINT_SHOW_MODAL_DIALOG);
- DiffManager.getInstance().getIdeaDiffTool().show(request);
- }
- }
-}
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/MergeApplication.java b/platform/platform-api/src/com/intellij/openapi/diff/MergeApplication.java
deleted file mode 100644
index b2e29f1bc88d..000000000000
--- a/platform/platform-api/src/com/intellij/openapi/diff/MergeApplication.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2000-2012 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.openapi.diff;
-
-import com.intellij.openapi.application.ApplicationNamesInfo;
-import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.vfs.VirtualFile;
-
-/**
- * @author Konstantin Bulenkov
- */
-public class MergeApplication extends ApplicationStarterBase {
- public MergeApplication() {
- super("merge", 3 ,4);
- }
-
- @Override
- public String getUsageMessage() {
- final String script = ApplicationNamesInfo.getInstance().getScriptName();
- return String.format("Usage:\n\t%s merge <file1> <file2> <original>\n\t%s merge <file1> <file2> <original> <output>", script, script);
- }
-
- @Override
- protected void processCommand(String[] args) throws Exception {
- final VirtualFile left = findFile(args[1]);
- final VirtualFile right = findFile(args[2]);
- final VirtualFile middle = findFile(args[3]);
- final VirtualFile result = findOrCreateFile(args.length == 4 ? args[3] : args[4]);
-
- MergeRequest request = DiffRequestFactory.getInstance()
- .createMergeRequest(getText(left), getText(right), getText(middle), result,
- ProjectManager.getInstance().getDefaultProject(),
- ActionButtonPresentation.APPLY,
- ActionButtonPresentation.CANCEL_WITH_PROMPT);
- request.addHint(DiffTool.HINT_SHOW_MODAL_DIALOG);
- request.setWindowTitle("Merge");
- request.setVersionTitles(new String[]{left.getPresentableUrl(), result.getPresentableUrl(), middle.getPresentableUrl()});
- DiffManager.getInstance().getDiffTool().show(request);
- }
-}
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
index c19173c7e906..7509394a2368 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.fileChooser;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.FileTypes;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VFileProperty;
@@ -51,6 +52,7 @@ public class FileChooserDescriptor implements Cloneable {
private boolean myShowFileSystemRoots = true;
private boolean myTreeRootVisible = false;
private boolean myShowHiddenFiles = false;
+ private Condition<VirtualFile> myFileFilter = null;
private final Map<String, Object> myUserData = new HashMap<String, Object>();
@@ -218,18 +220,15 @@ public class FileChooserDescriptor implements Cloneable {
}
/**
- * Defines whether file can be chosen or not
+ * Sets simple boolean condition for use in {@link #isFileVisible(VirtualFile, boolean)} and {@link #isFileSelectable(VirtualFile)}.
*/
- public boolean isFileSelectable(VirtualFile file) {
- if (file == null) return false;
- if (file.isDirectory() && myChooseFolders) return true;
- if (acceptAsJarFile(file)) return true;
- if (acceptAsGeneralFile(file)) return true;
- return false;
+ public FileChooserDescriptor withFileFilter(@Nullable Condition<VirtualFile> filter) {
+ myFileFilter = filter;
+ return this;
}
/**
- * Defines whether file is visible in the tree
+ * Defines whether a file is visible in the tree.
*/
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
if (!file.isDirectory()) {
@@ -238,28 +237,47 @@ public class FileChooserDescriptor implements Cloneable {
return false;
}
}
- else {
- if (!myChooseFiles) {
- return false;
- }
+ else if (!myChooseFiles) {
+ return false;
+ }
+ if (myFileFilter != null && !myFileFilter.value(file)) {
+ return false;
}
}
- // do not include ignored files
if (isHideIgnored() && FileTypeManager.getInstance().isFileIgnored(file)) {
return false;
}
- // do not include hidden files
- if (!showHiddenFiles) {
- if (FileElement.isFileHidden(file)) {
- return false;
- }
+ if (!showHiddenFiles && FileElement.isFileHidden(file)) {
+ return false;
}
return true;
}
+ /**
+ * Defines whether a file can be chosen.
+ */
+ public boolean isFileSelectable(VirtualFile file) {
+ if (file == null) return false;
+
+ if (file.isDirectory() && myChooseFolders) {
+ return true;
+ }
+ if (acceptAsJarFile(file)) {
+ return true;
+ }
+ if (acceptAsGeneralFile(file)) {
+ return true;
+ }
+ if (myFileFilter != null && !file.isDirectory() && myFileFilter.value(file)) {
+ return true;
+ }
+
+ return false;
+ }
+
public Icon getIcon(final VirtualFile file) {
if (file.isDirectory()) {
return dressIcon(file, PlatformIcons.DIRECTORY_CLOSED_ICON);
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java
index c958dbca878e..2eee60aa3061 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java
@@ -16,14 +16,13 @@
package com.intellij.openapi.fileChooser;
import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.UIBundle;
-import org.jetbrains.annotations.NotNull;
public class FileChooserDescriptorFactory {
- private FileChooserDescriptorFactory() {
- }
+ private FileChooserDescriptorFactory() { }
public static FileChooserDescriptor createAllButJarContentsDescriptor() {
return new FileChooserDescriptor(true, true, true, true, false, true);
@@ -45,13 +44,7 @@ public class FileChooserDescriptorFactory {
return new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
- if (super.isFileSelectable(file)) return true;
-
- if (SystemInfo.isMac && file.isDirectory() && "app".equals(file.getExtension())) {
- return true;
- }
-
- return false;
+ return super.isFileSelectable(file) || SystemInfo.isMac && file.isDirectory() && "app".equals(file.getExtension());
}
};
}
@@ -60,6 +53,24 @@ public class FileChooserDescriptorFactory {
return new FileChooserDescriptor(true, true, true, true, false, false);
}
+ public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType) {
+ return new FileChooserDescriptor(true, false, false, false, false, false).withFileFilter(new Condition<VirtualFile>() {
+ @Override
+ public boolean value(VirtualFile file) {
+ return file.getFileType() == fileType;
+ }
+ });
+ }
+
+ public static FileChooserDescriptor createSingleFileDescriptor(final String extension) {
+ return new FileChooserDescriptor(true, false, false, false, false, false).withFileFilter(new Condition<VirtualFile>() {
+ @Override
+ public boolean value(VirtualFile file) {
+ return Comparing.equal(file.getExtension(), extension, SystemInfo.isFileSystemCaseSensitive);
+ }
+ });
+ }
+
public static FileChooserDescriptor createSingleFolderDescriptor() {
return new FileChooserDescriptor(false, true, false, false, false, false);
}
@@ -72,54 +83,40 @@ public class FileChooserDescriptorFactory {
return new FileChooserDescriptor(true, true, false, false, false, false);
}
- public static FileChooserDescriptor getDirectoryChooserDescriptor(String aSearchedObjectName) {
- final FileChooserDescriptor singleFolderDescriptor = createSingleFolderDescriptor();
- singleFolderDescriptor.setTitle(UIBundle.message("file.chooser.select.object.title", aSearchedObjectName));
- return singleFolderDescriptor;
+ public static FileChooserDescriptor createSingleFileOrFolderDescriptor(final FileType fileType) {
+ return new FileChooserDescriptor(true, true, false, false, false, false).withFileFilter(new Condition<VirtualFile>() {
+ @Override
+ public boolean value(VirtualFile file) {
+ return file.getFileType() == fileType;
+ }
+ });
}
- public static FileChooserDescriptor getFileChooserDescriptor(String aSearchedObjectName) {
- final FileChooserDescriptor fileChooserDescriptor = createSingleFileNoJarsDescriptor();
- fileChooserDescriptor.setTitle(UIBundle.message("file.chooser.select.object.title", aSearchedObjectName));
- return fileChooserDescriptor;
+ /** @deprecated use {@link #createSingleFileDescriptor(FileType)} or {@link #createSingleFileOrFolderDescriptor(FileType)} (to be removed in IDEA 14) */
+ @SuppressWarnings("UnusedDeclaration")
+ public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType, final boolean supportDirectories) {
+ return supportDirectories ? createSingleFileOrFolderDescriptor(fileType) : createSingleFileDescriptor(fileType);
}
- public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType) {
- return createSingleFileDescriptor(fileType, false);
+ /** @deprecated not very useful (to be removed in IDEA 15) */
+ @SuppressWarnings("UnusedDeclaration")
+ public static FileChooserDescriptor getDirectoryChooserDescriptor(String objectName) {
+ return createSingleFolderDescriptor().withTitle("Select " + objectName);
}
- /**
- * Creates file descriptor with certain type and (possible) folders.
- * @param fileType supported type
- * @param supportDirectories support directories or not
- * @return descriptor
- */
- @NotNull
- public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType, final boolean supportDirectories) {
- return new FileChooserDescriptor(true, supportDirectories, false, false, false, false) {
- @Override
- public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) {
- return file.isDirectory() || file.getFileType() == fileType;
- }
-
- @Override
- public boolean isFileSelectable(final VirtualFile file) {
- return super.isFileSelectable(file) && (file.getFileType() == fileType || ((file.isDirectory() && supportDirectories)));
- }
- };
+ /** @deprecated not very useful (to be removed in IDEA 15) */
+ @SuppressWarnings("UnusedDeclaration")
+ public static FileChooserDescriptor getFileChooserDescriptor(String objectName) {
+ return createSingleFileNoJarsDescriptor().withTitle("Select " + objectName);
}
- /**
- * @deprecated use {@link #createSingleFileNoJarsDescriptor()} (to be removed in IDEA 15)
- */
+ /** @deprecated use {@link #createSingleFileNoJarsDescriptor()} (to be removed in IDEA 15) */
@SuppressWarnings({"UnusedDeclaration", "deprecation"})
public static FileChooserDescriptorBuilder onlyFiles() {
return FileChooserDescriptorBuilder.onlyFiles();
}
- /**
- * @deprecated use {@link #createSingleFileOrFolderDescriptor()} ()} (to be removed in IDEA 15)
- */
+ /** @deprecated use {@link #createSingleFileOrFolderDescriptor()} ()} (to be removed in IDEA 15) */
@SuppressWarnings({"UnusedDeclaration", "deprecation"})
public static FileChooserDescriptorBuilder filesAndFolders() {
return FileChooserDescriptorBuilder.filesAndFolders();
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableBase.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableBase.java
new file mode 100644
index 000000000000..d7c7dca2f19b
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableBase.java
@@ -0,0 +1,98 @@
+/*
+ * 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.openapi.options;
+
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public abstract class ConfigurableBase<UI extends ConfigurableUi<S>, S> implements SearchableConfigurable, Configurable.NoScroll {
+ private final String id;
+ private final String displayName;
+ private final String helpTopic;
+
+ private UI ui;
+
+ protected ConfigurableBase(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic) {
+ this.id = id;
+ this.displayName = displayName;
+ this.helpTopic = helpTopic;
+ }
+
+ @NotNull
+ @Override
+ public final String getId() {
+ return id;
+ }
+
+ @Nls
+ @Override
+ public final String getDisplayName() {
+ return displayName;
+ }
+
+ @Nullable
+ @Override
+ public final String getHelpTopic() {
+ return helpTopic;
+ }
+
+ @Nullable
+ @Override
+ public Runnable enableSearch(String option) {
+ return null;
+ }
+
+ @NotNull
+ protected abstract S getSettings();
+
+ @Override
+ public void reset() {
+ if (ui != null) {
+ ui.reset(getSettings());
+ }
+ }
+
+ @Nullable
+ @Override
+ public final JComponent createComponent() {
+ if (ui == null) {
+ ui = createUi();
+ }
+ return ui.getComponent();
+ }
+
+ protected abstract UI createUi();
+
+ @Override
+ public final boolean isModified() {
+ return ui != null && ui.isModified(getSettings());
+ }
+
+ @Override
+ public final void apply() {
+ if (ui != null) {
+ ui.apply(getSettings());
+ }
+ }
+
+ @Override
+ public void disposeUIResources() {
+ ui = null;
+ }
+} \ No newline at end of file
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 11c8bdd90052..78a4c1ece130 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
@@ -93,6 +93,9 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
@Attribute("groupId")
public String groupId;
+ @Attribute("groupWeight")
+ public int groupWeight;
+
/** Marks project level configurables that do not apply to the default project. */
@Attribute("nonDefaultProject")
public boolean nonDefaultProject;
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableUi.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableUi.java
new file mode 100644
index 000000000000..0ecb19a7ce8e
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableUi.java
@@ -0,0 +1,31 @@
+/*
+ * 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.openapi.options;
+
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+public interface ConfigurableUi<S> {
+ void reset(@NotNull S settings);
+
+ boolean isModified(@NotNull S settings);
+
+ void apply(@NotNull S settings);
+
+ @NotNull
+ JComponent getComponent();
+} \ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java b/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java
index aa6d9618482a..34eaf920d78d 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java
@@ -41,21 +41,25 @@ public abstract class ShowSettingsUtil {
public abstract boolean editConfigurable(@Nullable Project project, Configurable configurable, @Nullable Runnable advancedInitialization);
- public abstract boolean editConfigurable(Component parent, Configurable configurable);
+ public abstract boolean editConfigurable(@Nullable Component parent, @NotNull Configurable configurable);
- public abstract boolean editConfigurable(Component parent, Configurable configurable, Runnable advancedInitialization);
+ public abstract boolean editConfigurable(Component parent, Configurable configurable, @NotNull Runnable advancedInitialization);
public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable);
+ public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable, boolean showApplyButton);
+
public abstract boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable);
/**
* @deprecated create a new instance of configurable instead
+ * to remove in IDEA 15
*/
public abstract <T extends Configurable> T findProjectConfigurable(Project project, Class<T> confClass);
/**
* @deprecated create a new instance of configurable instead
+ * to remove in IDEA 15
*/
public abstract <T extends Configurable> T findApplicationConfigurable(Class<T> confClass);
diff --git a/platform/platform-api/src/com/intellij/openapi/options/SimpleConfigurable.java b/platform/platform-api/src/com/intellij/openapi/options/SimpleConfigurable.java
new file mode 100644
index 000000000000..9812165932a2
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/options/SimpleConfigurable.java
@@ -0,0 +1,52 @@
+/*
+ * 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.openapi.options;
+
+import com.intellij.openapi.util.Getter;
+import com.intellij.util.ReflectionUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public final class SimpleConfigurable<UI extends ConfigurableUi<S>, S> extends ConfigurableBase<UI, S> {
+ private final Class<UI> uiClass;
+ private final Getter<S> settingsGetter;
+
+ private SimpleConfigurable(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ super(id, displayName, helpTopic);
+
+ this.uiClass = uiClass;
+ this.settingsGetter = settingsGetter;
+ }
+
+ public static <UI extends ConfigurableUi<S>, S> SimpleConfigurable<UI, S> create(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ return new SimpleConfigurable<UI, S>(id, displayName, helpTopic, uiClass, settingsGetter);
+ }
+
+ public static <UI extends ConfigurableUi<S>, S> SimpleConfigurable<UI, S> create(@NotNull String id, @NotNull String displayName, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ return create(id, displayName, id, uiClass, settingsGetter);
+ }
+
+ @NotNull
+ @Override
+ protected S getSettings() {
+ return settingsGetter.get();
+ }
+
+ @Override
+ protected UI createUi() {
+ return ReflectionUtil.newInstance(uiClass);
+ }
+} \ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java
index 8dbe02228bae..59f99ad46a05 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.ui;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.options.OptionsBundle;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.ui.components.panels.NonOpaquePanel;
@@ -45,7 +46,7 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{
public Banner() {
setLayout(new BorderLayout());
- setBorder(new EmptyBorder(2, 6, 2, 4));
+ setBorder(new EmptyBorder(2, Registry.is("ide.new.settings.dialog") ? 12 : 6, 2, 4));
myProjectIcon.setVisible(false);
myProjectIcon.setBorder(new EmptyBorder(0, 12, 0, 4));
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
index 463d950ae900..00440b0dd8a6 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
@@ -17,6 +17,7 @@
package com.intellij.openapi.ui;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.ArrayUtil;
@@ -65,47 +66,54 @@ public class DetailsComponent {
protected void paintComponent(final Graphics g) {
if (NullableComponent.Check.isNull(myContent) || !myDetailsEnabled) return;
- GraphicsConfig c = new GraphicsConfig(g);
- c.setAntialiasing(true);
-
- Insets insets = getInsets();
- if (insets == null) {
- insets = new Insets(0, 0, 0, 0);
+ GraphicsConfig c = null;
+ Insets insets = null;
+ final int leftX;
+ final int rightX;
+ final int rightY;
+ if (!Registry.is("ide.new.settings.dialog")) {
+ c = new GraphicsConfig(g);
+ c.setAntialiasing(true);
+
+ insets = getInsets();
+ if (insets == null) {
+ insets = new Insets(0, 0, 0, 0);
+ }
+
+ g.setColor(UIUtil.getFocusedFillColor());
+
+ final Rectangle banner = myBanner.getBounds();
+ final GeneralPath header = new GeneralPath();
+
+ leftX = insets.left;
+ final int leftY = insets.top;
+ rightX = insets.left + getWidth() - 1 - insets.right;
+ rightY = banner.y + banner.height;
+
+ header.moveTo(leftX, rightY);
+ int arc = 8;
+ header.lineTo(leftX, leftY + arc);
+ header.quadTo(leftX, leftY, leftX + arc, leftY);
+ header.lineTo(rightX - arc, leftY);
+ header.quadTo(rightX, leftY, rightX, leftY + arc);
+ header.lineTo(rightX, rightY);
+ header.closePath();
+
+ c.getG().fill(header);
+
+ g.setColor(UIUtil.getFocusedBoundsColor());
+
+ c.getG().draw(header);
+
+
+ if (myPaintBorder) {
+ final int down = getHeight() - insets.top - insets.bottom - 1;
+ g.drawLine(leftX, rightY, leftX, down);
+ g.drawLine(rightX, rightY, rightX, down);
+ g.drawLine(leftX, down, rightX, down);
+ }
+ c.restore();
}
-
- g.setColor(UIUtil.getFocusedFillColor());
-
- final Rectangle banner = myBanner.getBounds();
- final GeneralPath header = new GeneralPath();
-
- final int leftX = insets.left;
- final int leftY = insets.top;
- final int rightX = insets.left + getWidth() - 1 - insets.right;
- final int rightY = banner.y + banner.height;
-
- header.moveTo(leftX, rightY);
- int arc = 8;
- header.lineTo(leftX, leftY + arc);
- header.quadTo(leftX, leftY, leftX + arc, leftY);
- header.lineTo(rightX - arc, leftY);
- header.quadTo(rightX, leftY, rightX, leftY + arc);
- header.lineTo(rightX, rightY);
- header.closePath();
-
- c.getG().fill(header);
-
- g.setColor(UIUtil.getFocusedBoundsColor());
-
- c.getG().draw(header);
-
- if (myPaintBorder) {
- final int down = getHeight() - insets.top - insets.bottom - 1;
- g.drawLine(leftX, rightY, leftX, down);
- g.drawLine(rightX, rightY, rightX, down);
- g.drawLine(leftX, down, rightX, down);
- }
-
- c.restore();
}
};
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
index ed374a905462..e4c8c6852727 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
@@ -55,26 +56,34 @@ public class DialogBuilder implements Disposable {
return showImpl(true).getExitCode();
}
+ public boolean showAndGet() {
+ return showImpl(true).isOK();
+ }
+
public void showNotModal() {
showImpl(false);
}
- public DialogBuilder(Project project) {
+ public DialogBuilder(@Nullable Project project) {
myDialogWrapper = new MyDialogWrapper(project, true);
Disposer.register(myDialogWrapper.getDisposable(), this);
}
- public DialogBuilder(Component parent) {
+ public DialogBuilder(@Nullable Component parent) {
myDialogWrapper = new MyDialogWrapper(parent, true);
Disposer.register(myDialogWrapper.getDisposable(), this);
}
+ public DialogBuilder() {
+ this(((Project)null));
+ }
+
@Override
public void dispose() {
}
private MyDialogWrapper showImpl(boolean isModal) {
- LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0,
+ LOG.assertTrue(!StringUtil.isEmptyOrSpaces(myTitle),
String.format("Dialog title shouldn't be empty or null: [%s]", myTitle));
myDialogWrapper.setTitle(myTitle);
myDialogWrapper.init();
@@ -91,6 +100,12 @@ public class DialogBuilder implements Disposable {
}
@NotNull
+ public DialogBuilder centerPanel(@NotNull JComponent centerPanel) {
+ myCenterPanel = centerPanel;
+ return this;
+ }
+
+ @NotNull
public DialogBuilder setNorthPanel(@NotNull JComponent northPanel) {
myNorthPanel = northPanel;
return this;
@@ -100,6 +115,7 @@ public class DialogBuilder implements Disposable {
myTitle = title;
}
+ @NotNull
public DialogBuilder title(@NotNull String title) {
myTitle = title;
return this;
@@ -196,6 +212,18 @@ public class DialogBuilder implements Disposable {
myDialogWrapper.setOKActionEnabled(isEnabled);
}
+ @NotNull
+ public DialogBuilder okActionEnabled(boolean isEnabled) {
+ myDialogWrapper.setOKActionEnabled(isEnabled);
+ return this;
+ }
+
+ @NotNull
+ public DialogBuilder resizable(boolean resizable) {
+ myDialogWrapper.setResizable(resizable);
+ return this;
+ }
+
public CustomizableAction getOkAction() {
return get(getActionDescriptors(), OkActionDescriptor.class);
}
@@ -267,7 +295,7 @@ public class DialogBuilder implements Disposable {
protected Action createAction(final DialogWrapper dialogWrapper) {
return new AbstractAction(){
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(@NotNull ActionEvent e) {
dialogWrapper.close(myExitCode);
}
};
@@ -325,7 +353,7 @@ public class DialogBuilder implements Disposable {
private class MyDialogWrapper extends DialogWrapper {
private String myHelpId = null;
- private MyDialogWrapper(Project project, boolean canBeParent) {
+ private MyDialogWrapper(@Nullable Project project, boolean canBeParent) {
super(project, canBeParent);
}
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 75cb4de7af74..741f67dee2c4 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
@@ -1233,6 +1233,7 @@ public abstract class DialogWrapper {
if (SystemInfo.isWindows) {
installEnterHook(root);
}
+ myErrorTextAlarm.setActivationComponent(root);
}
@NotNull
@@ -1838,15 +1839,14 @@ public abstract class DialogWrapper {
return;
}
myLastErrorText = text;
- if (myActualSize == null && !StringUtil.isEmpty(text)) {
- myActualSize = getSize();
- }
-
myErrorTextAlarm.cancelAllRequests();
myErrorTextAlarm.addRequest(new Runnable() {
@Override
public void run() {
final String text = myLastErrorText;
+ if (myActualSize == null && !StringUtil.isEmpty(text)) {
+ myActualSize = getSize();
+ }
myErrorText.setError(text);
if (text != null && text.length() > myMaxErrorTextLength) {
// during the first update, resize only for growing. during a subsequent update,
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java
index c9515a884f97..c1239e523896 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java
@@ -24,17 +24,24 @@ import org.jetbrains.annotations.Nullable;
import java.awt.*;
public abstract class DialogWrapperPeerFactory {
+ @NotNull
public static DialogWrapperPeerFactory getInstance() {
if (ApplicationManager.getApplication() == null) {
- try {
- return (DialogWrapperPeerFactory)Class.forName("com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl").newInstance();
- }
- catch (Exception e) {
- throw new RuntimeException("Can't instantiate DialogWrapperPeerFactory", e);
- }
+ return getInstanceByName();
}
- return ServiceManager.getService(DialogWrapperPeerFactory.class);
+ DialogWrapperPeerFactory factory = ServiceManager.getService(DialogWrapperPeerFactory.class);
+ return factory == null ? getInstanceByName() : factory;
+ }
+
+ @NotNull
+ private static DialogWrapperPeerFactory getInstanceByName() {
+ try {
+ return (DialogWrapperPeerFactory)Class.forName("com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl").newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Can't instantiate DialogWrapperPeerFactory", e);
+ }
}
@NotNull
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java
index ab193aff20c2..7819ef68a7e5 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java
@@ -40,6 +40,7 @@ public abstract class MessageDialogBuilder<T extends MessageDialogBuilder> {
myMessage = message;
}
+ @NotNull
public static YesNo yesNo(@NotNull String title, @NotNull String message) {
return new YesNo(title, message).icon(Messages.getQuestionIcon());
}
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 dae35d4b685d..1a07b33d696d 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
@@ -143,9 +143,12 @@ public class Messages {
try {
if (canShowMacSheetPanel()) {
- Window parentWindow = WindowManager.getInstance().suggestParentWindow(project);
- return MacMessages.getInstance()
- .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption);
+ WindowManager windowManager = WindowManager.getInstance();
+ if (windowManager != null) {
+ Window parentWindow = windowManager.suggestParentWindow(project);
+ return MacMessages.getInstance()
+ .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption);
+ }
}
}
catch (Exception exception) {
diff --git a/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java b/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java
index 4ba3fa7c1516..c4995a34ac27 100644
--- a/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java
+++ b/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java
@@ -15,13 +15,17 @@
*/
package com.intellij.openapi.util;
+import org.jetbrains.annotations.Nullable;
+
public class PasswordUtil {
private PasswordUtil() { }
// weak encryption just to avoid plain text passwords in text files
- public static String encodePassword(String password) {
+ public static String encodePassword(@Nullable String password) {
String result = "";
- if (password == null) return result;
+ if (password == null) {
+ return result;
+ }
for (int i = 0; i < password.length(); i++) {
int c = password.charAt(i);
c ^= 0xdfaa;
@@ -30,9 +34,11 @@ public class PasswordUtil {
return result;
}
- public static String decodePassword(String password) throws NumberFormatException {
+ public static String decodePassword(@Nullable String password) throws NumberFormatException {
String result = "";
- if (password == null) return result;
+ if (password == null) {
+ return result;
+ }
for (int i = 0; i < password.length(); i += 4) {
String s = password.substring(i, i + 4);
int c = Integer.parseInt(s, 16);
diff --git a/platform/platform-api/src/com/intellij/openapi/util/registry/RegistryState.java b/platform/platform-api/src/com/intellij/openapi/util/registry/RegistryState.java
index 7a6c15ef495f..cf10656a24ed 100644
--- a/platform/platform-api/src/com/intellij/openapi/util/registry/RegistryState.java
+++ b/platform/platform-api/src/com/intellij/openapi/util/registry/RegistryState.java
@@ -16,9 +16,14 @@
package com.intellij.openapi.util.registry;
import com.intellij.openapi.components.*;
+import com.intellij.openapi.diagnostic.Logger;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
@State(
name = "Registry",
storages = {
@@ -26,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
file = StoragePathMacros.APP_CONFIG + "/other.xml")}
)
public class RegistryState implements BaseComponent, PersistentStateComponent<Element> {
+ private static final Logger LOG = Logger.getInstance(RegistryState.class);
public RegistryState() {
}
@@ -36,6 +42,14 @@ public class RegistryState implements BaseComponent, PersistentStateComponent<El
public void loadState(Element state) {
Registry.getInstance().loadState(state);
+ SortedMap<String, String> userProperties = new TreeMap<String, String>(Registry.getInstance().getUserProperties());
+ userProperties.remove("ide.firstStartup");
+ if (!userProperties.isEmpty()) {
+ LOG.info("Registry values changed by user:");
+ for (Map.Entry<String, String> entry : userProperties.entrySet()) {
+ LOG.info(" " + entry.getKey() + " = " + entry.getValue());
+ }
+ }
}
@NotNull
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java
index edcf3b87ae2a..7adbfd16b324 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java
@@ -38,4 +38,5 @@ public interface ToolWindowId {
String DOCUMENTATION = UIBundle.message("tool.window.name.documentation");
String TASKS = UIBundle.message("tool.window.name.tasks");
String DATABASE_VIEW = UIBundle.message("tool.window.name.database");
+ String PREVIEW = UIBundle.message("tool.window.name.preview");
} \ No newline at end of file