Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2014-03-17 00:50:31 +01:00
12 changed files with 46 additions and 49 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -42,7 +43,7 @@ public class DefaultExecutionResult implements ExecutionResult {
myActions = AnAction.EMPTY_ARRAY;
}
public DefaultExecutionResult(final ExecutionConsole console, @NotNull final ProcessHandler processHandler) {
public DefaultExecutionResult(@Nullable ExecutionConsole console, @NotNull final ProcessHandler processHandler) {
this(console, processHandler, AnAction.EMPTY_ARRAY);
}
@@ -322,6 +322,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
@SuppressWarnings("UnusedDeclaration")
@NotNull
@Deprecated
public LightVirtualFile getHistoryFile() {
return myHistoryFile;
}
@@ -42,5 +42,5 @@ public abstract class BrowserLauncher {
@Nullable String browserPath,
@Nullable WebBrowser browser,
@Nullable Project project,
@NotNull String... additionalParameters);
@NotNull String[] additionalParameters);
}
@@ -133,7 +133,7 @@ public class BrowserLauncherAppless extends BrowserLauncher {
}
}
browseUsingPath(uri.toString(), settings.getBrowserPath(), null, null);
browseUsingPath(uri.toString(), settings.getBrowserPath(), null, null, ArrayUtil.EMPTY_STRING_ARRAY);
}
private void openOrBrowse(@NotNull String url, boolean browse) {
@@ -384,7 +384,7 @@ public class BrowserLauncherAppless extends BrowserLauncher {
@Nullable String browserPath,
@Nullable WebBrowser browser,
@Nullable Project project,
@NotNull String... additionalParameters) {
@NotNull String[] additionalParameters) {
return doLaunch(url, browserPath == null && browser != null ? PathUtil.toSystemDependentName(browser.getPath()) : browserPath, browser, project, additionalParameters);
}
@@ -394,9 +394,8 @@ public class BrowserLauncherAppless extends BrowserLauncher {
@Nullable Project project,
@NotNull String[] additionalParameters) {
if (StringUtil.isEmptyOrSpaces(browserPath)) {
final String error = browser == null ? IdeBundle.message("error.please.specify.path.to.web.browser", CommonBundle.settingsActionPath()) : browser
.getBrowserNotFoundMessage();
doShowError(error, browser, project, IdeBundle.message("title.browser.not.found"));
doShowError(browser == null ? IdeBundle.message("error.please.specify.path.to.web.browser", CommonBundle.settingsActionPath()) : browser
.getBrowserNotFoundMessage(), browser, project, IdeBundle.message("title.browser.not.found"));
return false;
}
@@ -30,6 +30,7 @@ public abstract class BrowserSpecificSettings implements Cloneable {
return Collections.emptyList();
}
@Override
public BrowserSpecificSettings clone() {
try {
return (BrowserSpecificSettings)super.clone();
@@ -1138,6 +1138,7 @@ public class AllIcons {
public static final Icon Chromium16 = IconLoader.getIcon("/xml/browsers/chromium16.png"); // 16x16
public static final Icon Explorer16 = IconLoader.getIcon("/xml/browsers/explorer16.png"); // 16x16
public static final Icon Firefox16 = IconLoader.getIcon("/xml/browsers/firefox16.png"); // 16x16
public static final Icon Node_webkit16 = IconLoader.getIcon("/xml/browsers/node-webkit16.png"); // 16x16
public static final Icon Opera16 = IconLoader.getIcon("/xml/browsers/opera16.png"); // 16x16
public static final Icon Safari16 = IconLoader.getIcon("/xml/browsers/safari16.png"); // 16x16
public static final Icon Yandex16 = IconLoader.getIcon("/xml/browsers/yandex16.png"); // 16x16
@@ -68,12 +68,22 @@ final class ConfigurableWebBrowser extends WebBrowser {
else if (checkNameAndPath("Opera")) {
return AllIcons.Xml.Browsers.Opera16;
}
else if (checkNameAndPath("node-webkit") || checkNameAndPath("nw")) {
return AllIcons.Xml.Browsers.Node_webkit16;
}
}
return family.getIcon();
}
private boolean checkNameAndPath(@NotNull String what) {
return StringUtil.containsIgnoreCase(name, what) || path != null && StringUtil.containsIgnoreCase(path, what);
if (StringUtil.containsIgnoreCase(name, what)) {
return true;
}
if (path != null) {
int index = path.lastIndexOf('/');
return index > 0 ? path.indexOf(what, index + 1) != -1 : path.contains(what);
}
return false;
}
@Nullable
@@ -12,6 +12,7 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.TextBrowseFolderListener;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
@@ -58,12 +59,12 @@ public class StartBrowserPanel {
// IDEA-118202
project = ProjectManager.getInstance().getDefaultProject();
}
setupUrlField(myUrlField, project);
setupUrlField(myUrlField, project, false, null);
}
});
}
else {
setupUrlField(myUrlField, project);
setupUrlField(myUrlField, project, false, null);
}
}
});
@@ -119,7 +120,7 @@ public class StartBrowserPanel {
}
@Nullable
private static Url virtualFileToUrl(VirtualFile file, Project project) {
private static Url virtualFileToUrl(@NotNull VirtualFile file, @NotNull Project project) {
PsiFile psiFile;
AccessToken token = ReadAction.start();
try {
@@ -141,10 +142,16 @@ public class StartBrowserPanel {
return browserSettings;
}
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field, @NotNull final Project project) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field,
@NotNull final Project project,
boolean chooseFolders,
@Nullable final Condition<VirtualFile> additionalFileCondition) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, chooseFolders, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (additionalFileCondition != null && additionalFileCondition.value(file)) {
return true;
}
return HtmlUtil.isHtmlFile(file) || virtualFileToUrl(file, project) != null;
}
};
@@ -157,6 +164,10 @@ public class StartBrowserPanel {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
if (chosenFile.isDirectory()) {
return chosenFile.getPath();
}
Url url = virtualFileToUrl(chosenFile, project);
return url == null ? chosenFile.getUrl() : url.toDecodedForm();
}
@@ -132,43 +132,15 @@ public abstract class BaseOpenInBrowserAction extends DumbAwareAction {
}
}
else {
final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(context);
if (psiFile != null) {
return OpenInBrowserRequest.create(psiFile);
PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(context);
VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
Project project = CommonDataKeys.PROJECT.getData(context);
if (virtualFile != null && !virtualFile.isDirectory() && virtualFile.isValid() && project != null && project.isInitialized()) {
psiFile = PsiManager.getInstance(project).findFile(virtualFile);
}
final VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
final Project project = CommonDataKeys.PROJECT.getData(context);
if (virtualFile != null && !virtualFile.isDirectory() && virtualFile.isValid() && project != null && project.isInitialized()) {
return new OpenInBrowserRequest() {
@NotNull
@Override
public VirtualFile getVirtualFile() {
return virtualFile;
}
@NotNull
@Override
public Project getProject() {
return project;
}
@NotNull
@Override
public PsiElement getElement() {
return getFile();
}
@NotNull
@Override
public PsiFile getFile() {
if (file == null) {
file = PsiManager.getInstance(getProject()).findFile(virtualFile);
LOG.assertTrue(file != null, virtualFile.getPath());
}
return file;
}
};
if (psiFile != null) {
return OpenInBrowserRequest.create(psiFile);
}
}
return null;
@@ -19,12 +19,13 @@ import com.intellij.ide.browsers.BrowserLauncher;
import com.intellij.ide.browsers.UrlOpener;
import com.intellij.ide.browsers.WebBrowser;
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
final class DefaultUrlOpener extends UrlOpener {
@Override
public boolean openUrl(@NotNull WebBrowser browser, @NotNull String url, @Nullable Project project) {
return BrowserLauncher.getInstance().browseUsingPath(url, null, browser, project);
return BrowserLauncher.getInstance().browseUsingPath(url, null, browser, project, ArrayUtil.EMPTY_STRING_ARRAY);
}
}