From aac4ec7851d9ff1ce32ac594ecf45f6d9244a6be Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Fri, 10 Dec 2010 16:01:47 +0300 Subject: [PATCH 01/11] Remove limitation on the master branch --- .../plugins/github/GithubRebaseAction.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java index fe1c677fc9e6..6796a0f969ec 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java @@ -26,7 +26,6 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; -import git4idea.GitBranch; import git4idea.GitRemote; import git4idea.GitUtil; import git4idea.actions.BasicAction; @@ -76,18 +75,6 @@ public class GithubRebaseAction extends DumbAwareAction { } try { - // Check current branch - final GitBranch currentBranch = GitBranch.current(project, root); - if (currentBranch == null) { - Messages.showErrorDialog(project, "Cannot find current branch", "Cannot perform github rebase"); - return; - } - if (!"master".equals(currentBranch.getName())) { - Messages.showErrorDialog(project, "Cannot perform rebase with '" + currentBranch.getName() + "' branch.\nPlease switch to master", - "Cannot perform github rebase"); - return; - } - // Check that given repository is properly configured git repository GitRemote githubRemote = null; final List gitRemotes = GitRemote.list(project, root); From a8ecdbf807c7441f361e667f6de3e8d6aa55f667 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Fri, 10 Dec 2010 17:06:32 +0300 Subject: [PATCH 02/11] DRY --- .../plugins/github/GithubRebaseAction.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java index 6796a0f969ec..449ef30de2c8 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java @@ -44,6 +44,7 @@ import java.util.List; public class GithubRebaseAction extends DumbAwareAction { public static final Icon ICON = IconLoader.getIcon("/icons/github.png"); private static final Logger LOG = Logger.getInstance(GithubRebaseAction.class.getName()); + private static final String CANNOT_PERFORM_GITHUB_REBASE = "Cannot perform github rebase"; public GithubRebaseAction() { super("Rebase my fork", "Rebase your forked repository relative to the origin", ICON); @@ -63,14 +64,14 @@ public class GithubRebaseAction extends DumbAwareAction { final Project project = e.getData(PlatformDataKeys.PROJECT); final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots(); if (roots.length == 0) { - Messages.showErrorDialog(project, "Project doesn't have any project roots", "Cannot create new GitHub repository"); + Messages.showErrorDialog(project, "Project doesn't have any project roots", CANNOT_PERFORM_GITHUB_REBASE); return; } final VirtualFile root = roots[0]; // Check if git is already initialized and presence of remote branch final boolean gitDetected = GitUtil.isUnderGit(root); if (!gitDetected) { - Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", "Cannot perform github rebase"); + Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", CANNOT_PERFORM_GITHUB_REBASE); return; } @@ -79,7 +80,7 @@ public class GithubRebaseAction extends DumbAwareAction { GitRemote githubRemote = null; final List gitRemotes = GitRemote.list(project, root); if (gitRemotes.isEmpty()) { - Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", "Cannot perform github rebase"); + Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", CANNOT_PERFORM_GITHUB_REBASE); return; } for (GitRemote gitRemote : gitRemotes) { @@ -89,7 +90,7 @@ public class GithubRebaseAction extends DumbAwareAction { } } if (githubRemote == null) { - Messages.showErrorDialog(project, "Configured own github repository is not found", "Cannot perform github rebase"); + Messages.showErrorDialog(project, "Configured own github repository is not found", CANNOT_PERFORM_GITHUB_REBASE); return; } @@ -98,7 +99,7 @@ public class GithubRebaseAction extends DumbAwareAction { final int index = pushUrl.lastIndexOf(login); if (index == -1) { Messages.showErrorDialog(project, "Github remote repository doesn't seem to be your own repository: " + pushUrl, - "Cannot perform github rebase"); + CANNOT_PERFORM_GITHUB_REBASE); return; } String repoName = pushUrl.substring(index + login.length() + 1); @@ -109,12 +110,12 @@ public class GithubRebaseAction extends DumbAwareAction { final RepositoryInfo repositoryInfo = GithubUtil.getDetailedRepositoryInfo(project, repoName); if (repositoryInfo == null) { Messages - .showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, "Cannot perform github rebase"); + .showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, CANNOT_PERFORM_GITHUB_REBASE); return; } if (!repositoryInfo.isFork()) { - Messages.showErrorDialog(project, "Github repository '" + repoName + "' is not a forked one", "Cannot perform github rebase"); + Messages.showErrorDialog(project, "Github repository '" + repoName + "' is not a forked one", CANNOT_PERFORM_GITHUB_REBASE); return; } @@ -148,7 +149,7 @@ public class GithubRebaseAction extends DumbAwareAction { addRemoteHandler.addParameters("add", repoName, parentRepoUrl); addRemoteHandler.run(); if (addRemoteHandler.getExitCode() != 0) { - Messages.showErrorDialog("Failed to add GitHub remote: '" + parentRepoUrl + "'", "Failed to add GitHub remote"); + Messages.showErrorDialog("Failed to add GitHub remote: '" + parentRepoUrl + "'", CANNOT_PERFORM_GITHUB_REBASE); return; } @@ -162,7 +163,7 @@ public class GithubRebaseAction extends DumbAwareAction { action.actionPerformed(actionEvent); } catch (VcsException e1) { - Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), "Cannot perform github rebase"); + Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), CANNOT_PERFORM_GITHUB_REBASE); return; } } From 71fe23e0db7e494b58db17dfb73d5cc7c236fff6 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Fri, 10 Dec 2010 17:37:04 +0300 Subject: [PATCH 03/11] Open in browser action --- plugins/github/src/META-INF/plugin.xml | 3 + .../github/GithubOpenInBrowserAction.java | 132 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java diff --git a/plugins/github/src/META-INF/plugin.xml b/plugins/github/src/META-INF/plugin.xml index c001c3a27454..fef2a86bae91 100644 --- a/plugins/github/src/META-INF/plugin.xml +++ b/plugins/github/src/META-INF/plugin.xml @@ -23,6 +23,9 @@ + + + \ No newline at end of file diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java new file mode 100644 index 000000000000..4e028514198b --- /dev/null +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java @@ -0,0 +1,132 @@ +/* + * Copyright 2000-2010 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 org.jetbrains.plugins.github; + +import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vfs.VirtualFile; +import git4idea.GitRemote; +import git4idea.GitUtil; + +import javax.swing.*; +import java.util.List; + +/** + * Created by IntelliJ IDEA. + * + * @author oleg + * @date 12/10/10 + */ +public class GithubOpenInBrowserAction extends DumbAwareAction { + public static final Icon ICON = IconLoader.getIcon("/icons/github.png"); + private static final Logger LOG = Logger.getInstance(GithubOpenInBrowserAction.class.getName()); + private static final String CANNOT_OPEN_IN_BROWSER = "Cannot open in browser"; + + protected GithubOpenInBrowserAction() { + super("Open in browser", "Open corresponding GitHub link in browser", ICON); + } + + @Override + public void update(final AnActionEvent e) { + final Project project = e.getData(PlatformDataKeys.PROJECT); + final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); + if (project == null || project.isDefault() || virtualFile == null) { + e.getPresentation().setEnabled(false); + return; + } + e.getPresentation().setEnabled(true); + } + + @Override + public void actionPerformed(final AnActionEvent e) { + final Project project = e.getData(PlatformDataKeys.PROJECT); + + final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots(); + if (roots.length == 0) { + Messages.showErrorDialog(project, "Project doesn't have any project roots", CANNOT_OPEN_IN_BROWSER); + return; + } + final VirtualFile root = roots[0]; + // Check if git is already initialized and presence of remote branch + final boolean gitDetected = GitUtil.isUnderGit(root); + if (!gitDetected) { + Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", CANNOT_OPEN_IN_BROWSER); + return; + } + final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); + final String rootPath = root.getPath(); + final String path = virtualFile.getPath(); + if (!path.startsWith(rootPath)){ + Messages.showErrorDialog(project, "File is not under project root", CANNOT_OPEN_IN_BROWSER); + return; + } + + + try { + // Check that given repository is properly configured git repository + GitRemote githubRemote = null; + final List gitRemotes = GitRemote.list(project, root); + if (gitRemotes.isEmpty()) { + Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", CANNOT_OPEN_IN_BROWSER); + return; + } + for (GitRemote gitRemote : gitRemotes) { + if (gitRemote.pushUrl().contains("git@github.com")) { + githubRemote = gitRemote; + break; + } + } + if (githubRemote == null) { + Messages.showErrorDialog(project, "Configured own github repository is not found", CANNOT_OPEN_IN_BROWSER); + return; + } + + final String pushUrl = githubRemote.pushUrl(); + final String login = GithubSettings.getInstance().getLogin(); + final int index = pushUrl.lastIndexOf(login); + if (index == -1) { + Messages.showErrorDialog(project, "Github remote repository doesn't seem to be your own repository: " + pushUrl, + CANNOT_OPEN_IN_BROWSER); + return; + } + String repoName = pushUrl.substring(index + login.length() + 1); + if (repoName.endsWith(".git")) { + repoName = repoName.substring(0, repoName.length() - 4); + } + final RepositoryInfo repositoryInfo = GithubUtil.getDetailedRepositoryInfo(project, repoName); + if (repositoryInfo == null) { + Messages + .showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, CANNOT_OPEN_IN_BROWSER); + return; + } + // TODO[oleg] support custom branches here + BrowserUtil.launchBrowser("https://github.com/" + login + "/" + repoName + "/blob/master" + path.substring(rootPath.length())); + + } catch (VcsException e1){ + Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), CANNOT_OPEN_IN_BROWSER); + return; + } + + } +} From 1503b4ce9d7c015e000add555da7612e6e175e9e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 10 Dec 2010 15:57:51 +0300 Subject: [PATCH 04/11] version number and JDK requirements updated --- bin/win/idea.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/win/idea.bat b/bin/win/idea.bat index 632ae9142b2d..b849c97c2729 100644 --- a/bin/win/idea.bat +++ b/bin/win/idea.bat @@ -6,7 +6,7 @@ :: --------------------------------------------------------------------- :: Before you run IntelliJ IDEA specify the location of the -:: JDK 1.5 installation directory which will be used for running IDEA +:: JDK 1.6 installation directory which will be used for running IDEA :: --------------------------------------------------------------------- IF "%IDEA_JDK%" == "" SET IDEA_JDK=%JDK_HOME% IF "%IDEA_JDK%" == "" goto error From c7f838f2004b1358a3b5114d5b3c93135b099af4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 10 Dec 2010 16:01:03 +0300 Subject: [PATCH 05/11] move Linux installation instructions to CE --- build/Install-Linux-tar.txt | 51 +++++++++++++++++++++++++++++++++++++ build/scripts/dist.gant | 1 + 2 files changed, 52 insertions(+) create mode 100644 build/Install-Linux-tar.txt diff --git a/build/Install-Linux-tar.txt b/build/Install-Linux-tar.txt new file mode 100644 index 000000000000..d51b005ba33d --- /dev/null +++ b/build/Install-Linux-tar.txt @@ -0,0 +1,51 @@ +IntelliJ IDEA + +INSTALLATION INSTRUCTIONS +=============================================================================== + + Linux Installation Instructions + ------------------------------------------------------------------------------ + 1. Unpack the IntelliJ IDEA distribution file that you downloaded to + where you wish to install the program. We will refer to this destination + location as your {installation home} below. + + 2. Open a console and cd into "{installation home}/bin" and type: + + ./idea.sh + + to start the application. + + 3. [OPTIONAL] Add the "{installation home}/bin" to your PATH environmental + variable so that you may start IntelliJ IDEA from any directory. + + 4. [OPTIONAL] To adjust the value of JVM heap size open idea.vmoptions and + modify the -Xms and -Xmx parameters. + + + [OPTIONAL] Changing location of "config" and "system" directory + ------------------------------------------------------------------------------ + By default IDEA stores all your settings under ~/.IntelliJIdea10/config directory + and stores data cache under ~/.IntelliJIdea10/system directory. + If you want to change these settings, + + 1. Open a console and cd into "{installation home}/bin" + + 2. Open file "idea.properties" in an editor. You should find strings like + + idea.system.path=~/.IntelliJIdea10/system + + and + + idea.config.path=~/.IntelliJIdea10/config + + and change them. + + 3. Note that we recommend to store data cache ("system" directory) at a disk + with at least 1G bytes free space + + + + +Enjoy! + +-IntelliJ IDEA Development Team diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index d2635baf3b05..bd8d82c0364d 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -198,6 +198,7 @@ def layoutLinux(Map args, String home, Paths paths) { fileset(dir: "$home/bin/nix") fileset(dir: "$home/build/images") } + fileset(dir: "$home/build", includes: "Install-Linux-tar.txt") } patchPropertiesFile(paths.distUnix) From 423d9b1fc1973fbfd251e98ca762a2b235154d8d Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Fri, 10 Dec 2010 18:01:10 +0300 Subject: [PATCH 06/11] Disable github share and option actions in non github bound project --- .../github/GithubOpenInBrowserAction.java | 4 +++ .../plugins/github/GithubRebaseAction.java | 21 ++++--------- .../jetbrains/plugins/github/GithubUtil.java | 31 +++++++++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java index 4e028514198b..872557ced4ac 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java @@ -55,6 +55,10 @@ public class GithubOpenInBrowserAction extends DumbAwareAction { e.getPresentation().setEnabled(false); return; } + if (GithubUtil.getGithubBoundRepository(project) == null){ + e.getPresentation().setEnabled(false); + return; + } e.getPresentation().setEnabled(true); } diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java index 449ef30de2c8..89defbbbe16e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java @@ -56,6 +56,10 @@ public class GithubRebaseAction extends DumbAwareAction { e.getPresentation().setEnabled(false); return; } + if (GithubUtil.getGithubBoundRepository(project) == null){ + e.getPresentation().setEnabled(false); + return; + } e.getPresentation().setEnabled(true); } @@ -77,22 +81,9 @@ public class GithubRebaseAction extends DumbAwareAction { try { // Check that given repository is properly configured git repository - GitRemote githubRemote = null; + final GitRemote githubRemote = GithubUtil.getGithubBoundRepository(project); final List gitRemotes = GitRemote.list(project, root); - if (gitRemotes.isEmpty()) { - Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", CANNOT_PERFORM_GITHUB_REBASE); - return; - } - for (GitRemote gitRemote : gitRemotes) { - if (gitRemote.pushUrl().contains("git@github.com")) { - githubRemote = gitRemote; - break; - } - } - if (githubRemote == null) { - Messages.showErrorDialog(project, "Configured own github repository is not found", CANNOT_PERFORM_GITHUB_REBASE); - return; - } + LOG.assertTrue(githubRemote != null); final String pushUrl = githubRemote.pushUrl(); final String login = GithubSettings.getInstance().getLogin(); diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java index b9bda80682de..45c2e8585af4 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java @@ -5,9 +5,14 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vfs.VirtualFile; +import git4idea.GitRemote; +import git4idea.GitUtil; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.UsernamePasswordCredentials; @@ -236,4 +241,30 @@ public class GithubUtil { return null; } } + + @Nullable + public static GitRemote getGithubBoundRepository(final Project project){ + final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots(); + if (roots.length == 0) { + return null; + } + final VirtualFile root = roots[0]; + // Check if git is already initialized and presence of remote branch + final boolean gitDetected = GitUtil.isUnderGit(root); + if (!gitDetected) { + return null; + } + try { + // Check that given repository is properly configured git repository + final List gitRemotes = GitRemote.list(project, root); + for (GitRemote gitRemote : gitRemotes) { + if (gitRemote.pushUrl().contains("git@github.com")) { + return gitRemote; + } + } + } catch (VcsException e){ + // ignore + } + return null; + } } From 5f90138e33226d7b1e4d65e3fbef334abb56a7f6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 10 Dec 2010 18:09:01 +0300 Subject: [PATCH 07/11] update keymap URL (IDEA-62851) --- community-resources/src/idea/IdeaApplicationInfo.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community-resources/src/idea/IdeaApplicationInfo.xml b/community-resources/src/idea/IdeaApplicationInfo.xml index 1bcdca8d3b40..3ab6ac4dd875 100644 --- a/community-resources/src/idea/IdeaApplicationInfo.xml +++ b/community-resources/src/idea/IdeaApplicationInfo.xml @@ -18,8 +18,8 @@ - + From b455facd0b4753411783b6da9d7d2c00332e685c Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Fri, 10 Dec 2010 18:30:08 +0300 Subject: [PATCH 08/11] IDEA-62762 increase default ddms timeout [rev=nnmatveev] --- plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java | 2 ++ .../android/src/org/jetbrains/android/util/AndroidUtils.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java b/plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java index 6ccea9c53dda..079fdfc678d1 100644 --- a/plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java +++ b/plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java @@ -17,6 +17,7 @@ package org.jetbrains.android.sdk; import com.android.ddmlib.AndroidDebugBridge; +import com.android.ddmlib.DdmPreferences; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.ISdkLog; import com.android.sdklib.SdkConstants; @@ -145,6 +146,7 @@ public abstract class AndroidSdk { String adbPath = getAdbPath(); if (!myDdmLibInitialized) { myDdmLibInitialized = true; + DdmPreferences.setTimeOut(AndroidUtils.TIMEOUT); AndroidDebugBridge.init(AndroidEnableDdmsAction.isDdmsEnabled()); AndroidDebugBridge.createBridge(adbPath, true); } diff --git a/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java b/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java index 38eda83180d4..282462bf5874 100644 --- a/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java +++ b/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java @@ -119,7 +119,7 @@ public class AndroidUtils { public static final String EXT_NATIVE_LIB = "so"; @NonNls public static final String RES_OVERLAY_DIR_NAME = "res-overlay"; - private static final int TIMEOUT = 30000; + public static final int TIMEOUT = 30000; private AndroidUtils() { } From f09dd6762657a78e30d99c876bce8168d454e040 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Fri, 10 Dec 2010 18:31:56 +0300 Subject: [PATCH 09/11] smart error messages after uploading; user should be able to stop uploading; remove uninstall-install workaround, because it doesn't work [rev=nnmatveev] --- .../android/run/AndroidRunningState.java | 82 +++++++++++++++++-- 1 file changed, 75 insertions(+), 7 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java b/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java index a583f1ebb399..38b51eaaa21e 100644 --- a/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java +++ b/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java @@ -613,6 +613,29 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb return true; } + private class MyISyncProgressMonitor implements SyncService.ISyncProgressMonitor { + @Override + public void start(int totalWork) { + } + + @Override + public void stop() { + } + + @Override + public boolean isCanceled() { + return myStopped; + } + + @Override + public void startSubTask(String name) { + } + + @Override + public void advance(int work) { + } + } + private boolean uploadApp(IDevice device, String remotePath, String localPath) throws IOException { if (myStopped) return false; getProcessHandler().notifyTextAvailable("Uploading file\n\tlocal path: " + localPath + "\n\tremote path: " + remotePath + '\n', STDOUT); @@ -621,12 +644,57 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb getProcessHandler().notifyTextAvailable("Can't upload file: device is not available.\n", STDERR); return false; } - SyncService.SyncResult result = service.pushFile(localPath, remotePath, SyncService.getNullProgressMonitor()); - if (result.getCode() != SyncService.RESULT_OK) { - getProcessHandler().notifyTextAvailable("Can't upload file: " + result.getMessage() + ".\n", STDERR); - return false; + SyncService.SyncResult result = service.pushFile(localPath, remotePath, new MyISyncProgressMonitor()); + int code = result.getCode(); + String errorMessage; + switch (code) { + case SyncService.RESULT_OK: + return true; + case SyncService.RESULT_CANCELED: + errorMessage = "Command canceled"; + break; + case SyncService.RESULT_CONNECTION_ERROR: + errorMessage = "Connection error"; + break; + case SyncService.RESULT_CONNECTION_TIMEOUT: + errorMessage = "Connection timeout"; + break; + case SyncService.RESULT_FILE_READ_ERROR: + errorMessage = "Cannot read the file"; + break; + case SyncService.RESULT_FILE_WRITE_ERROR: + errorMessage = "Cannot write the file"; + break; + case SyncService.RESULT_LOCAL_IS_DIRECTORY: + errorMessage = "Local is directory"; + break; + case SyncService.RESULT_NO_DIR_TARGET: + errorMessage = "Target directory not found"; + break; + case SyncService.RESULT_NO_LOCAL_FILE: + errorMessage = "Local file not found"; + break; + case SyncService.RESULT_NO_REMOTE_OBJECT: + errorMessage = "No remote object"; + break; + case SyncService.RESULT_REMOTE_IS_FILE: + errorMessage = "Remote is a file"; + break; + case SyncService.RESULT_REMOTE_PATH_ENCODING: + errorMessage = "Incorrect remote path encoding"; + break; + case SyncService.RESULT_REMOTE_PATH_LENGTH: + errorMessage = "Incorrect remote path length"; + break; + case SyncService.RESULT_TARGET_IS_FILE: + errorMessage = "Target is a file"; + break; + default: + errorMessage = "Can't upload file"; } - return true; + getProcessHandler() + .notifyTextAvailable(errorMessage + (result.getMessage() != null ? "\n" + result.getMessage() + "\n" : "\n"), STDERR); + return false; } @SuppressWarnings({"DuplicateThrows"}) @@ -676,13 +744,13 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb executeDeviceCommandAndWriteToConsole(device, "pm install -r \"" + remotePath + '\"', receiver); if (myStopped) return false; }*/ - if (!isSuccess(receiver)) { + /*if (!isSuccess(receiver)) { getProcessHandler().notifyTextAvailable("Can't reinstall application. Installing from scratch.\n", STDOUT); executeDeviceCommandAndWriteToConsole(device, "pm uninstall \"" + remotePath + '\"', receiver); if (myStopped) return false; executeDeviceCommandAndWriteToConsole(device, "pm install \"" + remotePath + '\"', receiver); if (myStopped) return false; - } + }*/ boolean success = isSuccess(receiver); getProcessHandler().notifyTextAvailable(receiver.output.toString(), success ? STDOUT : STDERR); return success; From b94400a66a5e5ceab13c6710cd524085af043163 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Fri, 10 Dec 2010 18:37:31 +0300 Subject: [PATCH 10/11] IDEA-62715 Automatic indentation doesn't work if you don't use braces 1. Providing correct indentation for incomplete brace-less 'if', 'for' and 'while' statements; 2. Corresponding test is added; --- .../java/BlockContainingJavaBlock.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java index c8b11d1f9f08..b5c7822cbb01 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java @@ -17,12 +17,15 @@ package com.intellij.psi.formatter.java; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; +import com.intellij.psi.JavaTokenType; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.impl.source.tree.ElementType; import com.intellij.psi.impl.source.tree.JavaDocElementType; +import com.intellij.psi.impl.source.tree.JavaElementType; import com.intellij.psi.impl.source.tree.StdTokenSets; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -30,6 +33,10 @@ import java.util.List; public class BlockContainingJavaBlock extends AbstractJavaBlock{ + private static final TokenSet TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES = TokenSet.create( + JavaElementType.IF_STATEMENT, JavaElementType.WHILE_STATEMENT, JavaElementType.FOR_STATEMENT + ); + private final static int BEFORE_FIRST = 0; private final static int BEFORE_BLOCK = 1; private final static int AFTER_ELSE = 2; @@ -207,12 +214,37 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{ return new ChildAttributes(getCodeBlockExternalIndent(), null); } + boolean useExternalIndent = false; if (newChildIndex == getSubBlocks().size()) { + useExternalIndent = true; + } + else if (TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES.contains(myNode.getElementType())) { + // There is a possible case that we have situation like below: + // if (true) + // + // System.out.println(); + // We would like to indent current caret position then because there is a high probability that the user starts + // typing there (populating statement body). So, we perform dedicated check for that here and use 'external indent' + // if necessary. + Block prevBlock = getSubBlocks().get(newChildIndex - 1); + Block nextBlock = getSubBlocks().get(newChildIndex); + if (prevBlock instanceof ASTBlock && nextBlock instanceof ASTBlock) { + ASTNode prevNode = ((ASTBlock)prevBlock).getNode(); + ASTNode nextNode = ((ASTBlock)nextBlock).getNode(); + if (prevNode != null && nextNode != null && prevNode.getElementType() == JavaTokenType.RPARENTH + && nextNode.getElementType() != JavaTokenType.LBRACE) + { + useExternalIndent = true; + } + } + } + + if (useExternalIndent) { return new ChildAttributes(getCodeBlockChildExternalIndent(newChildIndex), null); } - - return new ChildAttributes(myIndentsBefore.get(newChildIndex), null); - + else { + return new ChildAttributes(myIndentsBefore.get(newChildIndex), null); + } } private boolean isInsideForParens(final int newChildIndex) { From 8c0ad53b149fcd24d1ebec69ffc4736da4445f91 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 10 Dec 2010 18:42:33 +0300 Subject: [PATCH 11/11] Avoid grand VFS refresh in tests (fixed) --- .../src/com/intellij/codeInsight/CodeInsightTestCase.java | 3 +-- .../src/com/intellij/testFramework/PlatformTestCase.java | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index 4cbcebdc186a..6028e2bfb1c3 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -240,8 +240,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { } })); - // grand VFS refresh significantly slows down local tests and generally not needed - //VirtualFileManager.getInstance().refresh(false); + toDir.refresh(false, true); } else { editorInfos = new LinkedHashMap(); diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index 118d3202931d..a47d2d76d7e6 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -595,13 +595,6 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro public static File createTempDir(@NonNls final String prefix) throws IOException { final File tempDirectory = FileUtil.createTempDirectory(TEST_DIR_PREFIX + prefix, null); myFilesToDelete.add(tempDirectory); - // grand VFS refresh significantly slows down local tests and generally not needed - //ApplicationManager.getApplication().runWriteAction(new Runnable() { - // @Override - // public void run() { - // VirtualFileManager.getInstance().refresh(false); - // } - //}); return tempDirectory; }