From 912cf5ec658778098e982d530341b352f9e3bd3e Mon Sep 17 00:00:00 2001
From: Bas Leijdekkers
Date: Mon, 15 Oct 2012 10:57:50 +0200
Subject: [PATCH 01/19] EA-39960 (IOE:
PsiJavaParserFacadeImpl.createStatementFromText)
---
.../ReplaceConditionalWithIfPredicate.java | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/conditional/ReplaceConditionalWithIfPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/conditional/ReplaceConditionalWithIfPredicate.java
index 67dbca89f8a2..e3b8c7a02edd 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/conditional/ReplaceConditionalWithIfPredicate.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/conditional/ReplaceConditionalWithIfPredicate.java
@@ -26,20 +26,13 @@ class ReplaceConditionalWithIfPredicate implements PsiElementPredicate {
return false;
}
final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)element;
- if (JspPsiUtil.isInJspFile(element)) {
- final PsiExpression thenExpression = conditionalExpression.getThenExpression();
- if (thenExpression == null) {
- return false;
- }
- final PsiExpression elseExpression = conditionalExpression.getElseExpression();
- if (elseExpression == null) {
- return false;
- }
- }
final PsiElement parent = conditionalExpression.getParent();
if (parent instanceof PsiExpressionStatement) {
return false;
}
+ if (JspPsiUtil.isInJspFile(element)) {
+ return false;
+ }
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
if (member instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)member;
From 4f725efed9cd65991de607fd2a2f2535ffdb45d4 Mon Sep 17 00:00:00 2001
From: "Nadya.Zabrodina"
Date: Mon, 15 Oct 2012 13:14:51 +0400
Subject: [PATCH 02/19] IDEA-64887 Mercurial: change dialog that appears on
deleted-modified conflict
---
.../zmlx/hg4idea/command/HgUpdateCommand.java | 3 +-
.../hg4idea/execution/HgCommandExecutor.java | 93 ++++++++-----------
.../HgDeleteModifyPromptHandler.java | 90 ++++++++++++++++++
.../hg4idea/execution/HgPromptChoice.java | 61 ++++++++++++
.../hg4idea/execution/HgPromptHandler.java | 47 ++++++++++
5 files changed, 240 insertions(+), 54 deletions(-)
create mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgDeleteModifyPromptHandler.java
create mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptChoice.java
create mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptHandler.java
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java
index 6194efa48996..f389393ac909 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgVcs;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
+import org.zmlx.hg4idea.execution.HgDeleteModifyPromptHandler;
import java.util.LinkedList;
import java.util.List;
@@ -66,7 +67,7 @@ public class HgUpdateCommand {
final HgCommandExecutor executor = new HgCommandExecutor(project);
executor.setShowOutput(true);
- final HgCommandResult result = executor.executeInCurrentThread(repo, "update", arguments);
+ final HgCommandResult result = executor.executeInCurrentThread(repo, "update", arguments,new HgDeleteModifyPromptHandler());
project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project);
return result;
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
index 5204f2ded5cb..575cb123fcb8 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
@@ -13,9 +13,9 @@
package org.zmlx.hg4idea.execution;
import com.intellij.execution.ui.ConsoleViewContentType;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsImplUtil;
@@ -28,7 +28,6 @@ import org.zmlx.hg4idea.util.HgEncodingUtil;
import org.zmlx.hg4idea.util.HgErrorUtil;
import org.zmlx.hg4idea.util.HgUtil;
-import javax.swing.*;
import java.awt.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -52,7 +51,7 @@ import java.util.List;
*
*/
public final class HgCommandExecutor {
-
+
private static final Logger LOG = Logger.getInstance(HgCommandExecutor.class.getName());
private static final List DEFAULT_OPTIONS = Arrays.asList("--config", "ui.merge=internal:merge");
@@ -100,6 +99,12 @@ public final class HgCommandExecutor {
@Nullable
public HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo, @NotNull final String operation,
@Nullable final List arguments) {
+ return executeInCurrentThread(repo, operation, arguments, null);
+ }
+
+ @Nullable
+ public HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo, @NotNull final String operation,
+ @Nullable final List arguments, @Nullable HgPromptHandler handler) {
//LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread()); disabled for release
if (myProject == null || myProject.isDisposed() || myVcs == null) {
return null;
@@ -114,11 +119,11 @@ public final class HgCommandExecutor {
WarningReceiver warningReceiver = new WarningReceiver();
PassReceiver passReceiver = new PassReceiver(myProject);
-
- SocketServer promptServer = new SocketServer(new PromptReceiver());
+
+ SocketServer promptServer = new SocketServer(new PromptReceiver(handler));
SocketServer warningServer = new SocketServer(warningReceiver);
SocketServer passServer = new SocketServer(passReceiver);
-
+
try {
int promptPort = promptServer.start();
int warningPort = warningServer.start();
@@ -258,37 +263,46 @@ public final class HgCommandExecutor {
}
private static class PromptReceiver extends SocketServer.Protocol {
+ @Nullable HgPromptHandler myHandler;
+
+ public PromptReceiver(@Nullable HgPromptHandler handler) {
+ myHandler = handler;
+ }
public boolean handleConnection(Socket socket) throws IOException {
DataInputStream dataInput = new DataInputStream(socket.getInputStream());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
final String message = new String(readDataBlock(dataInput));
int numOfChoices = dataInput.readInt();
- final Choice[] choices = new Choice[numOfChoices];
+ final HgPromptChoice[] choices = new HgPromptChoice[numOfChoices];
for (int i = 0; i < numOfChoices; i++) {
String choice = new String(readDataBlock(dataInput));
- choices[i] = new Choice(choice);
+ choices[i] = new HgPromptChoice(i, choice);
}
int defaultChoiceInt = dataInput.readInt();
- final Choice defaultChoice = choices[defaultChoiceInt];
-
+ final HgPromptChoice defaultChoice = choices[defaultChoiceInt];
+ if (myHandler != null && myHandler.shouldHandle(message)) {
+ int chosen = myHandler.promptUser(message, choices, defaultChoice).getChosenIndex();
+ sendChoiceToHg(out, chosen);
+ return true;
+ }
final int[] index = new int[]{-1};
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
- Window parent = ApplicationManager.getApplication().getComponent(Window.class);
- index[0] = JOptionPane
- .showOptionDialog(parent, message, "hg4idea", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choices,
- defaultChoice);
+ String[] choicePresentationArray = new String[choices.length];
+ for (int i = 0; i < choices.length; ++i) {
+ choicePresentationArray[i] = choices[i].toString();
+ }
+ index[0] = Messages
+ .showChooseDialog(message, "hg4idea",
+ choicePresentationArray,
+ defaultChoice.toString(), Messages.getQuestionIcon());
}
});
-
+
int chosen = index[0];
- if (chosen == JOptionPane.CLOSED_OPTION) {
- out.writeInt(-1);
- } else {
- out.writeInt(chosen);
- }
+ sendChoiceToHg(out, chosen);
return true;
}
catch (InterruptedException e) {
@@ -301,43 +315,16 @@ public final class HgCommandExecutor {
}
}
- private static class Choice{
- private final String fullString;
- private final String representation;
- private final String choiceChar;
-
- private Choice(String fullString) {
- this.fullString = fullString;
- this.representation = fullString.replaceAll("&", "");
- int index = fullString.indexOf("&");
- this.choiceChar = "" + fullString.charAt(index + 1);
-
+ private static void sendChoiceToHg(@NotNull DataOutputStream outStream, int choice) throws IOException {
+ if (choice == HgPromptChoice.CLOSED_OPTION) {
+ outStream.writeInt(-1);
}
-
- @Override
- public String toString() {
- return representation;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Choice choice = (Choice) o;
-
- if (!fullString.equals(choice.fullString)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return fullString.hashCode();
+ else {
+ outStream.writeInt(choice);
}
}
}
-
+
private static class PassReceiver extends SocketServer.Protocol{
private final Project myProject;
private HgCommandAuthenticator myAuthenticator;
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgDeleteModifyPromptHandler.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgDeleteModifyPromptHandler.java
new file mode 100644
index 000000000000..ce545ca8f69a
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgDeleteModifyPromptHandler.java
@@ -0,0 +1,90 @@
+/*
+ * 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 org.zmlx.hg4idea.execution;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ui.Messages;
+import org.jetbrains.annotations.NotNull;
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgDeleteModifyPromptHandler implements HgPromptHandler {
+
+ private static final Logger LOG = Logger.getInstance("#org.zmlx.hg4idea.execution.HgDeleteModifyPromptHandler");
+
+ private static final Pattern LOCAL_DELETE_REMOTE_MODIFIED_CONFLICT_MESSAGE_PATTERN = Pattern.compile(
+ "remote\\schanged(.+)which\\slocal\\sdeleted\\s.+");
+ private static final Pattern REMOTE_DELETE_LOCAL_MODIFIED_CONFLICT_MESSAGE_PATTERN = Pattern.compile(
+ "\\slocal\\schanged(.+)which\\sremote\\sdeleted\\s.+");
+
+ private String myMessage = "";
+
+ public HgPromptChoice promptUser(final String message,
+ @NotNull final HgPromptChoice[] choices,
+ @NotNull final HgPromptChoice defaultChoice) {
+
+ final int[] chosen = new int[]{-1};
+ try {
+ EventQueue.invokeAndWait
+ (new Runnable() {
+ public void run() {
+ String[] choicePresentationArray = new String[choices.length];
+ for (int i = 0; i < choices.length; ++i) {
+ choicePresentationArray[i] = choices[i].toString();
+ }
+ chosen[0] = Messages
+ .showChooseDialog(myMessage, "Delete-Modify Conflict",
+ choicePresentationArray,
+ defaultChoice.toString(), Messages.getQuestionIcon());
+ }
+ });
+ }
+ catch (InterruptedException e) {
+ LOG.error(e);
+ return defaultChoice;
+ }
+ catch (InvocationTargetException e) {
+ LOG.error(e);
+ return defaultChoice;
+ }
+ return chosen[0] >= 0 ? choices[chosen[0]] : HgPromptChoice.ABORT;
+ }
+
+ public boolean shouldHandle(String message) {
+ Matcher localDelMatcher = LOCAL_DELETE_REMOTE_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ Matcher locaModifMatcher = REMOTE_DELETE_LOCAL_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ String filename;
+ if (localDelMatcher.matches()) {
+ filename = localDelMatcher.group(1);
+ myMessage =
+ "File " + filename + " is deleted locally, but modified remotely. Do you want to keep the modified version or remove the file?";
+ return true;
+ }
+ else if (locaModifMatcher.matches()) {
+ filename = locaModifMatcher.group(1);
+ myMessage =
+ "File " + filename + " is deleted remotely, but modified locally. Do you want to keep the modified version or remove the file?";
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptChoice.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptChoice.java
new file mode 100644
index 000000000000..2880bc983dba
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptChoice.java
@@ -0,0 +1,61 @@
+/*
+ * 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 org.zmlx.hg4idea.execution;
+
+
+public class HgPromptChoice {
+ private final String fullString;
+ private final String representation;
+ private final String choiceChar;
+ private final int chosenIndex;
+ public static final int CLOSED_OPTION = -1;
+ public static final HgPromptChoice ABORT = new HgPromptChoice(-1, "AbortChoice");
+
+ public int getChosenIndex() {
+ return chosenIndex;
+ }
+
+
+ HgPromptChoice(int chosenIndex, String fullString) {
+ this.fullString = fullString;
+ this.representation = fullString.replaceAll("&", "");
+ int index = fullString.indexOf("&");
+ this.choiceChar = String.valueOf(fullString.charAt(index + 1));
+ this.chosenIndex = chosenIndex;
+ }
+
+ @Override
+ public String toString() {
+ return representation;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (null == o) return true;
+ if (getClass() != o.getClass()) return false;
+
+ HgPromptChoice choice = (HgPromptChoice)o;
+
+ if (!fullString.equals(choice.fullString)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return fullString.hashCode();
+ }
+}
\ No newline at end of file
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptHandler.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptHandler.java
new file mode 100644
index 000000000000..66e75abca9b6
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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 org.zmlx.hg4idea.execution;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * HgPromptHandler is used by {@link HgCommandExecutor}, when you want to change the behavior of standart commands execution in the Mercurial.
+ *
+ * @author Nadya Zabrodina
+ */
+public interface HgPromptHandler {
+
+ /**
+ * Checks you need to change the default behavior.
+ *
+ * @param message standart output message from Mercurial
+ * @return
+ */
+ boolean shouldHandle(String message);
+
+ /**
+ * Change default behavior in commands execution.
+ *
+ *
+ * @param message standard output message from Mercurial
+ * @param choices possible choices
+ * @param defaultChoice
+ * @return
+ */
+ HgPromptChoice promptUser(final String message,
+ @NotNull final HgPromptChoice[] choices,
+ @NotNull final HgPromptChoice defaultChoice);
+}
From 76a6c2d0958810e4a4bc042d7c9883d3087abfa5 Mon Sep 17 00:00:00 2001
From: Alexey Gopachenko
Date: Mon, 15 Oct 2012 11:21:59 +0200
Subject: [PATCH 03/19] PHP WI-13885 IDE hangs on remote JS debug (Console
linking/file existence checking) / more improvements and diagnostics
---
.../com/intellij/execution/filters/CompositeFilter.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java b/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java
index 2cff2aaf6291..a4310072872e 100644
--- a/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java
+++ b/platform/lang-api/src/com/intellij/execution/filters/CompositeFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.execution.filters;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
@@ -26,6 +27,7 @@ import java.util.List;
public class CompositeFilter implements Filter, FilterMixin {
private final List myFilters = new ArrayList();
+ private static final Logger LOG = Logger.getInstance(CompositeFilter.class);
private boolean myIsAnyHeavy;
private final DumbService myDumbService;
@@ -42,7 +44,10 @@ public class CompositeFilter implements Filter, FilterMixin {
for (int i = 0; i < count; i++) {
Filter filter = filters.get(i);
if (!dumb || DumbService.isDumbAware(filter)) {
+ long t0 = System.currentTimeMillis();
final Result info = filter.applyFilter(line, entireLength);
+ t0 = (System.currentTimeMillis() - t0);
+ if (t0 < 100) LOG.error("applyFilter " + filter.getClass().getSimpleName() + " took" + t0 + "ms on '''" + line + "'''");
if (info != null) {
return info;
}
From c473c135230ea910b8b1706f1fdd0b5578bb924a Mon Sep 17 00:00:00 2001
From: Eugene Zhuravlev
Date: Mon, 15 Oct 2012 11:39:19 +0200
Subject: [PATCH 04/19] adapt maven tests to compiler working in dedicated
thread
---
.../jetbrains/idea/maven/MavenImportingTestCase.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
index 9d32c7109ef1..9c657396a854 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
@@ -40,6 +40,7 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PathUtil;
+import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.idea.maven.execution.*;
@@ -49,6 +50,7 @@ import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.project.MavenProjectsTree;
+import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -522,6 +524,8 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
final CompileScope scope = new ModuleCompileScope(myProject, modules.toArray(new Module[modules.size()]), false);
+ final Semaphore semaphore = new Semaphore();
+ semaphore.down();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
@@ -531,10 +535,16 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
//assertFalse(aborted);
//assertEquals(collectMessages(compileContext, CompilerMessageCategory.ERROR), 0, errors);
//assertEquals(collectMessages(compileContext, CompilerMessageCategory.WARNING), 0, warnings);
+ semaphore.up();
}
});
}
});
+ while (!semaphore.waitFor(100)) {
+ if (SwingUtilities.isEventDispatchThread()) {
+ UIUtil.dispatchAllInvocationEvents();
+ }
+ }
}
private static String collectMessages(CompileContext compileContext, CompilerMessageCategory messageType) {
From 90e6edb6dd88f243615be7b5b0ed6b611ccdf184 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Mon, 15 Oct 2012 13:42:54 +0400
Subject: [PATCH 05/19] specific steps added to standard module templates
---
.../modes/CreateFromScratchMode.java | 22 ++++++++++++++-----
.../modes/CreateFromTemplateMode.java | 5 +----
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
index ff24e526f97e..8717ac1786b4 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
@@ -53,18 +53,30 @@ public class CreateFromScratchMode extends WizardMode {
@Nullable
protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
- final StepSequence sequence = new StepSequence();
- sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, this));
+ for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
+ myBuildersMap.put(builder.getBuilderId(), builder);
+ }
+ myBuildersMap.put(ModuleType.EMPTY.getId(), new EmptyModuleBuilder());
+ return createSequence(context, modulesProvider, this);
+ }
+
+ static StepSequence createSequence(WizardContext context,
+ ModulesProvider modulesProvider,
+ WizardMode mode,
+ ModuleWizardStep... firstSteps) {
+ final StepSequence sequence = new StepSequence(firstSteps);
+ sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, mode));
for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
addModuleBuilder(builder, context, modulesProvider, sequence);
}
- myBuildersMap.put(ModuleType.EMPTY.getId(), new EmptyModuleBuilder());
return sequence;
}
- private void addModuleBuilder(ModuleBuilder builder, WizardContext context, ModulesProvider modulesProvider, StepSequence myStepSequence) {
+ private static void addModuleBuilder(ModuleBuilder builder,
+ WizardContext context,
+ ModulesProvider modulesProvider,
+ StepSequence myStepSequence) {
final String id = builder.getBuilderId();
- myBuildersMap.put(id, builder);
for (ModuleWizardStep step : builder.createWizardSteps(context, modulesProvider)) {
myStepSequence.addSpecificStep(id, step);
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
index 06731b5ef68e..3fab1f499da9 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.util.newProjectWizard.modes;
-import com.intellij.ide.util.newProjectWizard.ProjectNameWithTypeStep;
import com.intellij.ide.util.newProjectWizard.SelectTemplateStep;
import com.intellij.ide.util.newProjectWizard.StepSequence;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
@@ -55,9 +54,7 @@ public class CreateFromTemplateMode extends WizardMode {
@Override
protected StepSequence createSteps(WizardContext context, @NotNull ModulesProvider modulesProvider) {
mySelectTemplateStep = new SelectTemplateStep(context);
- StepSequence sequence = new StepSequence(mySelectTemplateStep);
- sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, this));
- return sequence;
+ return CreateFromScratchMode.createSequence(context, modulesProvider, this, mySelectTemplateStep);
}
@Nullable
From 8bc1f6e39937cf5efb8c7345cf3744054180a045 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Mon, 15 Oct 2012 14:24:00 +0400
Subject: [PATCH 06/19] selecting module type with specific steps
---
.../ProjectNameWithTypeStep.java | 23 +++++++++++--------
.../newProjectWizard/SelectTemplateStep.java | 12 +++++++++-
.../modes/CreateFromScratchMode.java | 11 ++++-----
.../modes/CreateFromTemplateMode.java | 10 ++++----
4 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java
index 271d39872974..c002951d4551 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java
@@ -356,17 +356,23 @@ public class ProjectNameWithTypeStep extends ProjectNameStep {
public void updateStep() {
super.updateStep();
- if (myCreateModuleCb.isSelected()) {
- mySequence.setType(getSelectedBuilderId());
- } else {
- mySequence.setType(null);
+ if (myHeader.isVisible()) {
+ if (myCreateModuleCb.isSelected()) {
+ mySequence.setType(getSelectedBuilderId());
+ } else {
+ mySequence.setType(null);
+ }
}
}
public void updateDataModel() {
- if (myCreateModuleCb.isSelected()) {
- mySequence.setType(getSelectedBuilderId());
- super.updateDataModel();
+
+ if (myHeader.isVisible()) {
+ mySequence.setType(myCreateModuleCb.isSelected() ? getSelectedBuilderId() : null);
+ }
+ super.updateDataModel();
+
+ if (myHeader.isVisible() && myCreateModuleCb.isSelected()) {
final ModuleBuilder builder = (ModuleBuilder)myMode.getModuleBuilder();
assert builder != null;
final String moduleName = getModuleName();
@@ -374,9 +380,6 @@ public class ProjectNameWithTypeStep extends ProjectNameStep {
builder.setModuleFilePath(
FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
builder.setContentEntryPath(FileUtil.toSystemIndependentName(myModuleContentRoot.getText()));
- } else {
- mySequence.setType(null);
- super.updateDataModel();
}
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
index 59d67f4a8ca0..7af6ca11b872 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
@@ -76,13 +76,16 @@ public class SelectTemplateStep extends ModuleWizardStep {
private JPanel myDescriptionPanel;
private final WizardContext myContext;
+ private final StepSequence mySequence;
+
private final ElementFilter.Active.Impl myFilter;
private final FilteringTreeBuilder myBuilder;
private MinusculeMatcher[] myMatchers;
- public SelectTemplateStep(WizardContext context) {
+ public SelectTemplateStep(WizardContext context, StepSequence sequence) {
myContext = context;
+ mySequence = sequence;
Messages.installHyperlinkSupport(myDescriptionPane);
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
@@ -242,6 +245,12 @@ public class SelectTemplateStep extends ModuleWizardStep {
@Override
public void updateStep() {
myBuilder.queueUpdate();
+ setModuleType();
+ }
+
+ private void setModuleType() {
+ ProjectTemplate template = getSelectedTemplate();
+ mySequence.setType(template == null ? null : template.createModuleBuilder().getBuilderId());
}
@Override
@@ -342,6 +351,7 @@ public class SelectTemplateStep extends ModuleWizardStep {
@Override
public void updateDataModel() {
+ setModuleType();
}
@Override
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
index 8717ac1786b4..1874404a7fbb 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
@@ -57,14 +57,13 @@ public class CreateFromScratchMode extends WizardMode {
myBuildersMap.put(builder.getBuilderId(), builder);
}
myBuildersMap.put(ModuleType.EMPTY.getId(), new EmptyModuleBuilder());
- return createSequence(context, modulesProvider, this);
+ return addSteps(context, modulesProvider, this, new StepSequence());
}
- static StepSequence createSequence(WizardContext context,
- ModulesProvider modulesProvider,
- WizardMode mode,
- ModuleWizardStep... firstSteps) {
- final StepSequence sequence = new StepSequence(firstSteps);
+ static StepSequence addSteps(WizardContext context,
+ ModulesProvider modulesProvider,
+ WizardMode mode,
+ StepSequence sequence) {
sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, mode));
for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
addModuleBuilder(builder, context, modulesProvider, sequence);
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
index 3fab1f499da9..ec5e18e76afc 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java
@@ -17,7 +17,7 @@ package com.intellij.ide.util.newProjectWizard.modes;
import com.intellij.ide.util.newProjectWizard.SelectTemplateStep;
import com.intellij.ide.util.newProjectWizard.StepSequence;
-import com.intellij.ide.util.projectWizard.ProjectBuilder;
+import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
@@ -53,13 +53,15 @@ public class CreateFromTemplateMode extends WizardMode {
@Nullable
@Override
protected StepSequence createSteps(WizardContext context, @NotNull ModulesProvider modulesProvider) {
- mySelectTemplateStep = new SelectTemplateStep(context);
- return CreateFromScratchMode.createSequence(context, modulesProvider, this, mySelectTemplateStep);
+ StepSequence sequence = new StepSequence();
+ mySelectTemplateStep = new SelectTemplateStep(context, sequence);
+ sequence.addCommonStep(mySelectTemplateStep);
+ return CreateFromScratchMode.addSteps(context, modulesProvider, this, sequence);
}
@Nullable
@Override
- public ProjectBuilder getModuleBuilder() {
+ public ModuleBuilder getModuleBuilder() {
final ProjectTemplate template = mySelectTemplateStep.getSelectedTemplate();
if (template == null) {
return null;
From 4cf835a9d156681f6b10b8c069280c7dd650b5a3 Mon Sep 17 00:00:00 2001
From: Alexey Kudravtsev
Date: Fri, 12 Oct 2012 16:04:56 +0400
Subject: [PATCH 07/19] Redraw show usages popup incrementally, save the
selection
---
.../find/actions/ShowUsagesAction.java | 372 ++++++++++++------
.../actions/ShowUsagesTableCellRenderer.java | 2 +-
.../ide/util/gotoByName/ChooseByNameBase.java | 126 +++---
.../ide/util/gotoByName/ModelDiff.java | 124 ++++++
.../intellij/ui/JBTableWithHintProvider.java | 7 +-
.../com/intellij/util/ui/ListTableModel.java | 33 +-
6 files changed, 449 insertions(+), 215 deletions(-)
create mode 100644 platform/lang-impl/src/com/intellij/ide/util/gotoByName/ModelDiff.java
diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java
index 94f359b9b696..2daa054cab0d 100644
--- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java
+++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java
@@ -24,6 +24,7 @@ import com.intellij.find.findUsages.*;
import com.intellij.find.impl.FindManagerImpl;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
+import com.intellij.ide.util.gotoByName.ModelDiff;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
@@ -44,7 +45,10 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.search.PsiElementProcessor;
@@ -57,17 +61,18 @@ import com.intellij.usages.*;
import com.intellij.usages.impl.*;
import com.intellij.usages.rules.UsageFilteringRuleProvider;
import com.intellij.util.Alarm;
-import com.intellij.util.ArrayUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.Processor;
+import com.intellij.util.containers.TransferToEDTQueue;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.AsyncProcessIcon;
+import com.intellij.util.ui.ColumnInfo;
+import com.intellij.util.ui.ListTableModel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -82,13 +87,13 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
static final NullUsage MORE_USAGES_SEPARATOR = NullUsage.INSTANCE;
private static final UsageNode MORE_USAGES_SEPARATOR_NODE = UsageViewImpl.NULL_NODE;
- private static final Comparator