mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -60,10 +60,9 @@ private class DefaultWebServerRootsProvider : WebServerRootsProvider() {
|
||||
runReadAction { ModuleManager.getInstance(project).modules }
|
||||
.computeOrNull { module ->
|
||||
if (!module.isDisposed) {
|
||||
val result = findByRelativePath(path, rootProvider.getRoots(ModuleRootManager.getInstance(module)), resolver, null)
|
||||
if (result != null) {
|
||||
result.moduleName = getModuleNameQualifier(project, module)
|
||||
return result
|
||||
findByRelativePath(path, rootProvider.getRoots(ModuleRootManager.getInstance(module)), resolver, null)?.let {
|
||||
it.moduleName = getModuleNameQualifier(project, module)
|
||||
return it
|
||||
}
|
||||
}
|
||||
null
|
||||
|
||||
@@ -11,9 +11,9 @@ import com.intellij.util.writeChild
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
private class BuiltInWebServerTest : BuiltInServerTestCase() {
|
||||
internal class BuiltInWebServerTest : BuiltInServerTestCase() {
|
||||
override val urlPathPrefix: String
|
||||
get() = "/${BuiltInServerTestCase.projectRule.project.name}"
|
||||
get() = "/${projectRule.project.name}"
|
||||
|
||||
@Test
|
||||
@TestManager.TestDescriptor(filePath = "foo/index.html", doNotCreate = true, status = 200)
|
||||
@@ -34,7 +34,7 @@ private class BuiltInWebServerTest : BuiltInServerTestCase() {
|
||||
}
|
||||
|
||||
private fun testIndex(vararg paths: String) {
|
||||
val project = BuiltInServerTestCase.projectRule.project
|
||||
val project = projectRule.project
|
||||
val newPath = tempDirManager.newPath()
|
||||
newPath.writeChild(manager.filePath!!, "hello")
|
||||
newPath.refreshVfs()
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.junit.Test
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
private class RestApiTest : BuiltInServerTestCase() {
|
||||
internal class RestApiTest : BuiltInServerTestCase() {
|
||||
override val urlPathPrefix = "/api/file"
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.intellij.openapi.application.TransactionId;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -178,22 +177,14 @@ public class AutoPopupController implements Disposable {
|
||||
}
|
||||
|
||||
final PsiFile file1 = file;
|
||||
final Runnable request = new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
if (myProject.isDisposed() || DumbService.isDumb(myProject)) return;
|
||||
documentManager.commitAllDocuments();
|
||||
if (editor.isDisposed() || !editor.getComponent().isShowing()) return;
|
||||
Runnable request = () -> {
|
||||
if (!myProject.isDisposed() && !DumbService.isDumb(myProject) && !editor.isDisposed() && editor.getComponent().isShowing()) {
|
||||
int lbraceOffset = editor.getCaretModel().getOffset() - 1;
|
||||
try {
|
||||
ShowParameterInfoHandler.invoke(myProject, editor, file1, lbraceOffset, highlightedMethod, false);
|
||||
}
|
||||
catch (IndexNotReadyException ignored) { //anything can happen on alarm
|
||||
}
|
||||
ShowParameterInfoHandler.invoke(myProject, editor, file1, lbraceOffset, highlightedMethod, false);
|
||||
}
|
||||
};
|
||||
|
||||
addRequest(request, settings.PARAMETER_INFO_DELAY);
|
||||
addRequest(() -> documentManager.performLaterWhenAllCommitted(request), settings.PARAMETER_INFO_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.PrivacyPolicy;
|
||||
import com.intellij.ide.customize.CustomizeIDEWizardDialog;
|
||||
import com.intellij.ide.customize.CustomizeIDEWizardStepsProvider;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
@@ -25,14 +23,9 @@ import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ConfigImportHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
@@ -40,15 +33,10 @@ import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.ui.HyperlinkAdapter;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.EnvironmentUtil;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.SwingHelper;
|
||||
import com.sun.jna.Native;
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -58,15 +46,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.io.BuiltInServer;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -137,7 +120,12 @@ public class StartupUtil {
|
||||
if (!checkSystemFolders()) {
|
||||
System.exit(Main.DIR_CHECK_FAILED);
|
||||
}
|
||||
if (!lockSystemFolders(args)) {
|
||||
|
||||
ActivationResult result = lockSystemFolders(args);
|
||||
if (result == ActivationResult.ACTIVATED) {
|
||||
System.exit(0);
|
||||
}
|
||||
else if (result != ActivationResult.STARTED) {
|
||||
System.exit(Main.INSTANCE_CHECK_FAILED);
|
||||
}
|
||||
|
||||
@@ -154,20 +142,7 @@ public class StartupUtil {
|
||||
if (!Main.isHeadless()) {
|
||||
AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
|
||||
AppUIUtil.registerBundledFonts();
|
||||
final Pair<PrivacyPolicy.Version, String> policy = PrivacyPolicy.getContent();
|
||||
if (!PrivacyPolicy.isVersionAccepted(policy.getFirst())) {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showPrivacyPolicyAgreement(policy.getSecond());
|
||||
}
|
||||
});
|
||||
PrivacyPolicy.setVersionAccepted(policy.getFirst());
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
AppUIUtil.showPrivacyPolicy();
|
||||
}
|
||||
|
||||
appStarter.start(newConfigFolder);
|
||||
@@ -305,7 +280,9 @@ public class StartupUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized static boolean lockSystemFolders(String[] args) {
|
||||
private enum ActivationResult { STARTED, ACTIVATED, FAILED }
|
||||
|
||||
private synchronized static @NotNull ActivationResult lockSystemFolders(String[] args) {
|
||||
if (ourSocketLock != null) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
@@ -318,33 +295,30 @@ public class StartupUtil {
|
||||
}
|
||||
catch (Exception e) {
|
||||
Main.showMessage("Cannot Lock System Folders", e);
|
||||
return false;
|
||||
return ActivationResult.FAILED;
|
||||
}
|
||||
|
||||
if (status == SocketLock.ActivateStatus.NO_INSTANCE) {
|
||||
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (StartupUtil.class) {
|
||||
ourSocketLock.dispose();
|
||||
ourSocketLock = null;
|
||||
}
|
||||
ShutDownTracker.getInstance().registerShutdownTask(() -> {
|
||||
//noinspection SynchronizeOnThis
|
||||
synchronized (StartupUtil.class) {
|
||||
ourSocketLock.dispose();
|
||||
ourSocketLock = null;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return ActivationResult.STARTED;
|
||||
}
|
||||
else if (status == SocketLock.ActivateStatus.ACTIVATED) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println("Already running");
|
||||
return ActivationResult.ACTIVATED;
|
||||
}
|
||||
else if (Main.isHeadless() || status == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
|
||||
String message = "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time.";
|
||||
Main.showMessage("Too Many Instances", message, true);
|
||||
}
|
||||
|
||||
if (status == SocketLock.ActivateStatus.ACTIVATED) {
|
||||
System.out.println("Already running");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
return false;
|
||||
return ActivationResult.FAILED;
|
||||
}
|
||||
|
||||
private static void fixProcessEnvironment(Logger log) {
|
||||
@@ -438,76 +412,6 @@ public class StartupUtil {
|
||||
log.info("JNU charset: " + System.getProperty("sun.jnu.encoding"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param htmlText Updated version of Privacy Policy text if any.
|
||||
* If it's <code>null</code> the standard text from bundled resources would be used.
|
||||
*/
|
||||
public static void showPrivacyPolicyAgreement(@NotNull String htmlText) {
|
||||
DialogWrapper dialog = new DialogWrapper(true) {
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
|
||||
JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
|
||||
viewer.setFocusable(true);
|
||||
viewer.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
URL url = e.getURL();
|
||||
if (url != null) {
|
||||
BrowserUtil.browse(url);
|
||||
}
|
||||
else {
|
||||
SwingHelper.scrollToReference(viewer, e.getDescription());
|
||||
}
|
||||
}
|
||||
});
|
||||
viewer.setText(htmlText);
|
||||
StyleSheet styleSheet = ((HTMLDocument)viewer.getDocument()).getStyleSheet();
|
||||
styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
|
||||
styleSheet.addRule("body {margin-top:0;padding-top:0;}");
|
||||
styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
|
||||
styleSheet.addRule("h2, em {margin-top:" + JBUI.scaleFontSize(20) + "pt;}");
|
||||
styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
|
||||
styleSheet.addRule("p, h1 {margin-top:0;padding-top:"+JBUI.scaleFontSize(6)+"pt;}");
|
||||
styleSheet.addRule("li {margin-bottom:" + JBUI.scaleFontSize(6) + "pt;}");
|
||||
styleSheet.addRule("h2 {margin-top:0;padding-top:"+JBUI.scaleFontSize(13)+"pt;}");
|
||||
viewer.setCaretPosition(0);
|
||||
viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
|
||||
centerPanel.add(new JLabel("Please read and accept these terms and conditions:"), BorderLayout.NORTH);
|
||||
centerPanel
|
||||
.add(new JBScrollPane(viewer, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER),
|
||||
BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions();
|
||||
init();
|
||||
setOKButtonText("Accept");
|
||||
setCancelButtonText("Reject and Exit");
|
||||
setAutoAdjustable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
super.doCancelAction();
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
if (application == null) {
|
||||
System.exit(Main.PRIVACY_POLICY_REJECTION);
|
||||
}
|
||||
else {
|
||||
((ApplicationImpl)application).exit(true, true, false, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
dialog.setModal(true);
|
||||
dialog.setTitle(ApplicationNamesInfo.getInstance().getFullProductName() + " Privacy Policy Agreement");
|
||||
dialog.setSize(JBUI.scale(509), JBUI.scale(395));
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
static void runStartupWizard() {
|
||||
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
|
||||
@@ -535,4 +439,4 @@ public class StartupUtil {
|
||||
PluginManagerCore.invalidatePlugins();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.intellij.ide.actions.DeleteAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.fileChooser.ex.FileChooserKeys;
|
||||
|
||||
public class FileDeleteAction extends DeleteAction {
|
||||
@@ -34,13 +35,19 @@ public class FileDeleteAction extends DeleteAction {
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
Presentation presentation = event.getPresentation();
|
||||
final Boolean available = event.getData(FileChooserKeys.DELETE_ACTION_AVAILABLE);
|
||||
if (available != null && !available) {
|
||||
presentation.setEnabled(false);
|
||||
presentation.setVisible(false);
|
||||
FileSystemTree tree = event.getData(FileSystemTree.DATA_KEY);
|
||||
if (tree == null) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final Boolean available = event.getData(FileChooserKeys.DELETE_ACTION_AVAILABLE);
|
||||
if (available != null && !available) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
presentation.setEnabledAndVisible(true);
|
||||
super.update(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,18 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public final class ShowHiddensAction extends ToggleAction implements DumbAware {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
FileSystemTree tree = e.getData(FileSystemTree.DATA_KEY);
|
||||
e.getPresentation().setEnabled(tree != null);
|
||||
}
|
||||
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
final FileSystemTree fileSystemTree = e.getData(FileSystemTree.DATA_KEY);
|
||||
return fileSystemTree != null && fileSystemTree.areHiddensShown();
|
||||
|
||||
@@ -411,25 +411,16 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
|
||||
|
||||
@Override
|
||||
public void smartInvokeLater(@NotNull final Runnable runnable) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runWhenSmart(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return runnable.toString();
|
||||
}
|
||||
}, myProject.getDisposed());
|
||||
smartInvokeLater(runnable, ModalityState.defaultModalityState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smartInvokeLater(@NotNull final Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runWhenSmart(runnable);
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (isDumb()) {
|
||||
runWhenSmart(() -> smartInvokeLater(runnable, modalityState));
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}, modalityState, myProject.getDisposed());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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,27 +15,39 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.PrivacyPolicy;
|
||||
import com.intellij.idea.Main;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.SwingHelper;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@@ -43,6 +55,9 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
@@ -71,18 +86,13 @@ public class AppUIUtil {
|
||||
return images;
|
||||
}
|
||||
|
||||
public static void invokeLaterIfProjectAlive(@NotNull final Project project, @NotNull final Runnable runnable) {
|
||||
public static void invokeLaterIfProjectAlive(@NotNull Project project, @NotNull Runnable runnable) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
application.invokeLater(runnable, new Condition() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
return !project.isOpen() || project.isDisposed();
|
||||
}
|
||||
});
|
||||
application.invokeLater(runnable, o -> !project.isOpen() || project.isDisposed());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,14 +168,11 @@ public class AppUIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideToolWindowBalloon(@NotNull final String id, @NotNull final Project project) {
|
||||
invokeLaterIfProjectAlive(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Balloon balloon = ToolWindowManager.getInstance(project).getToolWindowBalloon(id);
|
||||
if (balloon != null) {
|
||||
balloon.hide();
|
||||
}
|
||||
public static void hideToolWindowBalloon(@NotNull String id, @NotNull Project project) {
|
||||
invokeLaterIfProjectAlive(project, () -> {
|
||||
Balloon balloon = ToolWindowManager.getInstance(project).getToolWindowBalloon(id);
|
||||
if (balloon != null) {
|
||||
balloon.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -173,30 +180,112 @@ public class AppUIUtil {
|
||||
private static final int MIN_ICON_SIZE = 32;
|
||||
|
||||
@Nullable
|
||||
public static String findIcon(final String iconsPath) {
|
||||
final File iconsDir = new File(iconsPath);
|
||||
public static String findIcon(@NotNull String iconsPath) {
|
||||
String[] childFiles = ObjectUtils.notNull(new File(iconsPath).list(), ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
|
||||
// 1. look for .svg icon
|
||||
for (String child : iconsDir.list()) {
|
||||
for (String child : childFiles) {
|
||||
if (child.endsWith(".svg")) {
|
||||
return iconsPath + '/' + child;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. look for .png icon of max size
|
||||
int max = 0;
|
||||
int best = MIN_ICON_SIZE - 1;
|
||||
String iconPath = null;
|
||||
for (String child : iconsDir.list()) {
|
||||
if (!child.endsWith(".png")) continue;
|
||||
final String path = iconsPath + '/' + child;
|
||||
final Icon icon = new ImageIcon(path);
|
||||
final int size = icon.getIconHeight();
|
||||
if (size >= MIN_ICON_SIZE && size > max && size == icon.getIconWidth()) {
|
||||
max = size;
|
||||
iconPath = path;
|
||||
for (String child : childFiles) {
|
||||
if (child.endsWith(".png")) {
|
||||
String path = iconsPath + '/' + child;
|
||||
Icon icon = new ImageIcon(path);
|
||||
int size = icon.getIconHeight();
|
||||
if (size > best && size == icon.getIconWidth()) {
|
||||
best = size;
|
||||
iconPath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iconPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showPrivacyPolicy() {
|
||||
Pair<PrivacyPolicy.Version, String> policy = PrivacyPolicy.getContent();
|
||||
if (!PrivacyPolicy.isVersionAccepted(policy.getFirst())) {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> showPrivacyPolicyAgreement(policy.getSecond()));
|
||||
PrivacyPolicy.setVersionAccepted(policy.getFirst());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.getInstance(AppUIUtil.class).warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param htmlText Updated version of Privacy Policy text if any.
|
||||
* If it's {@code null}, the standard text from bundled resources would be used.
|
||||
*/
|
||||
public static void showPrivacyPolicyAgreement(@NotNull String htmlText) {
|
||||
DialogWrapper dialog = new DialogWrapper(true) {
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
|
||||
JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
|
||||
viewer.setFocusable(true);
|
||||
viewer.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
URL url = e.getURL();
|
||||
if (url != null) {
|
||||
BrowserUtil.browse(url);
|
||||
}
|
||||
else {
|
||||
SwingHelper.scrollToReference(viewer, e.getDescription());
|
||||
}
|
||||
}
|
||||
});
|
||||
viewer.setText(htmlText);
|
||||
StyleSheet styleSheet = ((HTMLDocument)viewer.getDocument()).getStyleSheet();
|
||||
styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
|
||||
styleSheet.addRule("body {margin-top:0;padding-top:0;}");
|
||||
styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
|
||||
styleSheet.addRule("h2, em {margin-top:" + JBUI.scaleFontSize(20) + "pt;}");
|
||||
styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
|
||||
styleSheet.addRule("p, h1 {margin-top:0;padding-top:"+JBUI.scaleFontSize(6)+"pt;}");
|
||||
styleSheet.addRule("li {margin-bottom:" + JBUI.scaleFontSize(6) + "pt;}");
|
||||
styleSheet.addRule("h2 {margin-top:0;padding-top:"+JBUI.scaleFontSize(13)+"pt;}");
|
||||
viewer.setCaretPosition(0);
|
||||
viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
|
||||
centerPanel.add(new JLabel("Please read and accept these terms and conditions:"), BorderLayout.NORTH);
|
||||
centerPanel.add(new JBScrollPane(viewer, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions();
|
||||
init();
|
||||
setOKButtonText("Accept");
|
||||
setCancelButtonText("Reject and Exit");
|
||||
setAutoAdjustable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
super.doCancelAction();
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
if (application == null) {
|
||||
System.exit(Main.PRIVACY_POLICY_REJECTION);
|
||||
}
|
||||
else {
|
||||
((ApplicationImpl)application).exit(true, true, false, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
dialog.setModal(true);
|
||||
dialog.setTitle(ApplicationNamesInfo.getInstance().getFullProductName() + " Privacy Policy Agreement");
|
||||
dialog.setSize(JBUI.scale(509), JBUI.scale(395));
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ fun Path.refreshVfs() {
|
||||
|
||||
inline fun <R> Path.directoryStreamIfExists(task: (stream: DirectoryStream<Path>) -> R): R? {
|
||||
try {
|
||||
Files.newDirectoryStream(this).use(task)
|
||||
return Files.newDirectoryStream(this).use(task)
|
||||
}
|
||||
catch (ignored: NoSuchFileException) {
|
||||
}
|
||||
@@ -150,7 +150,7 @@ inline fun <R> Path.directoryStreamIfExists(task: (stream: DirectoryStream<Path>
|
||||
|
||||
inline fun <R> Path.directoryStreamIfExists(noinline filter: ((path: Path) -> Boolean), task: (stream: DirectoryStream<Path>) -> R): R? {
|
||||
try {
|
||||
Files.newDirectoryStream(this, { filter.invoke(it) }).use(task)
|
||||
return Files.newDirectoryStream(this, { filter.invoke(it) }).use(task)
|
||||
}
|
||||
catch (ignored: NoSuchFileException) {
|
||||
}
|
||||
|
||||
@@ -33,6 +33,22 @@ import static com.intellij.openapi.util.Conditions.not;
|
||||
*/
|
||||
public class TreeTraverserTest extends TestCase {
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* --- 5
|
||||
* --- 2 --- 6
|
||||
* / --- 7
|
||||
* /
|
||||
* / --- 8
|
||||
* 1 --- 3 --- 9
|
||||
* \ --- 10
|
||||
* \
|
||||
* \ --- 11
|
||||
* --- 4 --- 12
|
||||
* --- 13
|
||||
* </pre>
|
||||
*/
|
||||
private static Map<Integer, Collection<Integer>> numbers() {
|
||||
return ContainerUtil.<Integer, Collection<Integer>>immutableMapBuilder().
|
||||
put(1, Arrays.asList(2, 3, 4)).
|
||||
@@ -455,7 +471,17 @@ public class TreeTraverserTest extends TestCase {
|
||||
assertEquals(Arrays.asList(5, 6, 3, 11, 12, 13), t.withRoot(1).regard(not(inRange(7, 10))).traverse(TreeTraversal.LEAVES_DFS).toList());
|
||||
}
|
||||
|
||||
public void testSkipExpandedBfs() {
|
||||
public void testHideOneNodeDfs() {
|
||||
JBTreeTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(1, 2, 5, 6, 7, 4, 11, 12, 13), t.withRoot(1).expandAndFilter(x -> x != 3).traverse(TreeTraversal.PRE_ORDER_DFS).toList());
|
||||
}
|
||||
|
||||
public void testHideOneNodeCompletelyBfs() {
|
||||
JBTreeTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(1, 2, 4, 5, 6, 7, 11, 12, 13), t.withRoot(1).expandAndFilter(x -> x != 3).traverse(TreeTraversal.PLAIN_BFS).toList());
|
||||
}
|
||||
|
||||
public void testSkipExpandedCompletelyBfs() {
|
||||
JBTreeTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(2, 4, 8, 9, 10), t.withRoot(1).expand(IS_ODD).traverse(TreeTraversal.LEAVES_BFS).toList());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.project.ex.ProjectEx
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl
|
||||
@@ -132,7 +131,6 @@ class ProjectRule() : ApplicationRule() {
|
||||
|
||||
val module: Module
|
||||
get() {
|
||||
var project = project
|
||||
var result = sharedModule
|
||||
if (result == null) {
|
||||
runInEdtAndWait {
|
||||
@@ -141,9 +139,6 @@ class ProjectRule() : ApplicationRule() {
|
||||
result = module
|
||||
sharedModule = module
|
||||
}
|
||||
|
||||
override fun sourceRootCreated(sourceRoot: VirtualFile) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.EmptyModuleType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -34,7 +33,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.IndexableFileSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -50,33 +48,27 @@ public class LightProjectDescriptor {
|
||||
public static final LightProjectDescriptor EMPTY_PROJECT_DESCRIPTOR = new LightProjectDescriptor();
|
||||
|
||||
public void setUpProject(@NotNull final Project project, @NotNull final SetupHandler handler) throws Exception {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Module module = createMainModule(project);
|
||||
handler.moduleCreated(module);
|
||||
VirtualFile sourceRoot = createSourcesRoot(module);
|
||||
if (sourceRoot != null) {
|
||||
handler.sourceRootCreated(sourceRoot);
|
||||
createContentEntry(module, sourceRoot);
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
Module module = createMainModule(project);
|
||||
handler.moduleCreated(module);
|
||||
VirtualFile sourceRoot = createSourcesRoot(module);
|
||||
if (sourceRoot != null) {
|
||||
handler.sourceRootCreated(sourceRoot);
|
||||
createContentEntry(module, sourceRoot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Module createMainModule(@NotNull final Project project) {
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<Module>() {
|
||||
@Override
|
||||
public Module compute() {
|
||||
String moduleFilePath = "light_idea_test_case.iml";
|
||||
File imlFile = new File(moduleFilePath);
|
||||
if (imlFile.exists()) {
|
||||
//temporary workaround for IDEA-147530: otherwise if someone saved module with this name before the created module will get its settings
|
||||
FileUtil.delete(imlFile);
|
||||
}
|
||||
return ModuleManager.getInstance(project).newModule(moduleFilePath, getModuleType().getId());
|
||||
return ApplicationManager.getApplication().runWriteAction((Computable<Module>)() -> {
|
||||
String moduleFilePath = "light_idea_test_case.iml";
|
||||
File imlFile = new File(moduleFilePath);
|
||||
if (imlFile.exists()) {
|
||||
//temporary workaround for IDEA-147530: otherwise if someone saved module with this name before the created module will get its settings
|
||||
FileUtil.delete(imlFile);
|
||||
}
|
||||
return ModuleManager.getInstance(project).newModule(moduleFilePath, getModuleType().getId());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,30 +111,22 @@ public class LightProjectDescriptor {
|
||||
}
|
||||
};
|
||||
FileBasedIndex.getInstance().registerIndexableSet(indexableFileSet, null);
|
||||
Disposer.register(module.getProject(), new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
FileBasedIndex.getInstance().removeIndexableSet(indexableFileSet);
|
||||
}
|
||||
});
|
||||
Disposer.register(module.getProject(), () -> FileBasedIndex.getInstance().removeIndexableSet(indexableFileSet));
|
||||
|
||||
return srcRoot;
|
||||
}
|
||||
|
||||
protected void createContentEntry(@NotNull final Module module, @NotNull final VirtualFile srcRoot) {
|
||||
updateModel(module, new Consumer<ModifiableRootModel>() {
|
||||
@Override
|
||||
public void consume(ModifiableRootModel model) {
|
||||
Sdk sdk = getSdk();
|
||||
if (sdk != null) {
|
||||
model.setSdk(sdk);
|
||||
}
|
||||
|
||||
ContentEntry contentEntry = model.addContentEntry(srcRoot);
|
||||
contentEntry.addSourceFolder(srcRoot, false);
|
||||
|
||||
configureModule(module, model, contentEntry);
|
||||
updateModel(module, model -> {
|
||||
Sdk sdk = getSdk();
|
||||
if (sdk != null) {
|
||||
model.setSdk(sdk);
|
||||
}
|
||||
|
||||
ContentEntry contentEntry = model.addContentEntry(srcRoot);
|
||||
contentEntry.addSourceFolder(srcRoot, false);
|
||||
|
||||
configureModule(module, model, contentEntry);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,9 +147,12 @@ public class LightProjectDescriptor {
|
||||
|
||||
protected void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
}
|
||||
|
||||
|
||||
public interface SetupHandler {
|
||||
void moduleCreated(@NotNull Module module);
|
||||
void sourceRootCreated(@NotNull VirtualFile sourceRoot);
|
||||
}
|
||||
default void moduleCreated(@NotNull Module module) {
|
||||
}
|
||||
|
||||
default void sourceRootCreated(@NotNull VirtualFile sourceRoot) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ public abstract class BaseOutputReader extends BaseDataReader {
|
||||
processLine(myInputBuffer, myLineBuffer, n);
|
||||
}
|
||||
|
||||
boolean isReady = availableUnsupported || myReader.ready();
|
||||
boolean isReady = myReader.ready();
|
||||
|
||||
if (!isReady) {
|
||||
if (!availableUnsupported && !isReady) {
|
||||
TimeoutUtil.sleep(mySleepingPolicy.getTimeToSleep(n > 0));
|
||||
isReady = myReader.ready();
|
||||
}
|
||||
|
||||
@@ -93,7 +93,10 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
|
||||
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@")).and(attributeValueInFxml),
|
||||
new JavaFxLocationReferenceProvider());
|
||||
|
||||
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("$")).and(attributeValueInFxml),
|
||||
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("$"))
|
||||
.withParent(XmlPatterns.xmlAttribute()
|
||||
.andNot(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_VALUE)))
|
||||
.and(attributeValueInFxml),
|
||||
new JavaFxComponentIdReferenceProvider());
|
||||
|
||||
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName("url")).and(attributeValueInFxml),
|
||||
|
||||
@@ -49,10 +49,6 @@ class JavaFxComponentIdReferenceProvider extends PsiReferenceProvider {
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext context) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof XmlAttribute && FxmlConstants.FX_VALUE.equals(((XmlAttribute)parent).getName())) {
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)element;
|
||||
final String value = xmlAttributeValue.getValue();
|
||||
if (JavaFxPsiUtil.isIncorrectExpressionBinding(value)) {
|
||||
|
||||
@@ -160,17 +160,27 @@ public class MavenPlugin implements Serializable {
|
||||
private final List<String> myGoals;
|
||||
private final Element myConfiguration;
|
||||
private final String myExecutionId;
|
||||
private final String myPhase;
|
||||
|
||||
public Execution(String executionId, List<String> goals, Element configuration) {
|
||||
this(executionId, null, goals, configuration);
|
||||
}
|
||||
|
||||
public Execution(String executionId, String phase, List<String> goals, Element configuration) {
|
||||
myGoals = goals;
|
||||
myConfiguration = configuration;
|
||||
myExecutionId = executionId;
|
||||
myPhase = phase;
|
||||
}
|
||||
|
||||
public String getExecutionId() {
|
||||
return myExecutionId;
|
||||
}
|
||||
|
||||
public String getPhase() {
|
||||
return myPhase;
|
||||
}
|
||||
|
||||
public List<String> getGoals() {
|
||||
return myGoals;
|
||||
}
|
||||
@@ -189,6 +199,7 @@ public class MavenPlugin implements Serializable {
|
||||
|
||||
if (myGoals != null ? !myGoals.equals(that.myGoals) : that.myGoals != null) return false;
|
||||
if (myExecutionId != null ? !myExecutionId.equals(that.myExecutionId) : that.myExecutionId != null) return false;
|
||||
if (myPhase != null ? !myPhase.equals(that.myPhase) : that.myPhase != null) return false;
|
||||
if (!JDOMUtil.areElementsEqual(myConfiguration, that.myConfiguration)) return false;
|
||||
|
||||
return true;
|
||||
@@ -200,6 +211,9 @@ public class MavenPlugin implements Serializable {
|
||||
if (myExecutionId != null) {
|
||||
result = 31 * result + myExecutionId.hashCode();
|
||||
}
|
||||
if (myPhase != null) {
|
||||
result = 31 * result + myPhase.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class Maven2ModelConverter {
|
||||
}
|
||||
|
||||
public static MavenPlugin.Execution convertExecution(PluginExecution execution) throws RemoteException {
|
||||
return new MavenPlugin.Execution(execution.getId(), execution.getGoals(), convertConfiguration(execution.getConfiguration()));
|
||||
return new MavenPlugin.Execution(execution.getId(), execution.getPhase(), execution.getGoals(), convertConfiguration(execution.getConfiguration()));
|
||||
}
|
||||
|
||||
private static Element convertConfiguration(Object config) throws RemoteException {
|
||||
|
||||
@@ -264,7 +264,7 @@ public class MavenModelConverter {
|
||||
}
|
||||
|
||||
public static MavenPlugin.Execution convertExecution(PluginExecution execution) throws RemoteException {
|
||||
return new MavenPlugin.Execution(execution.getId(), execution.getGoals(), convertConfiguration(execution.getConfiguration()));
|
||||
return new MavenPlugin.Execution(execution.getId(), execution.getPhase(), execution.getGoals(), convertConfiguration(execution.getConfiguration()));
|
||||
}
|
||||
|
||||
private static Element convertConfiguration(Object config) throws RemoteException {
|
||||
|
||||
Reference in New Issue
Block a user