diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointDefaults.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointDefaults.java
index 96a1d0eb2aa4..89b5f9c17dc3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointDefaults.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointDefaults.java
@@ -40,7 +40,7 @@ public final class BreakpointDefaults {
}
public void setSuspendPolicy(String suspendPolicy) {
- if (DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy) || DebuggerSettings.SUSPEND_THREAD.equals(suspendPolicy) || DebuggerSettings.SUSPEND_ALL.equals( suspendPolicy)) {
+ if (DebuggerSettings.SUSPEND_THREAD.equals(suspendPolicy) || DebuggerSettings.SUSPEND_ALL.equals( suspendPolicy)) {
mySuspendPolicy = suspendPolicy;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
index 09a73fd894c9..cc7aaaa8c9aa 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
@@ -34,7 +34,6 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerContextListener;
import com.intellij.debugger.impl.DebuggerManagerImpl;
import com.intellij.debugger.impl.DebuggerSession;
-import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
import com.intellij.debugger.ui.DebuggerExpressionTextField;
import com.intellij.openapi.application.ApplicationManager;
@@ -318,7 +317,7 @@ public class BreakpointManager implements JDOMExternalizable {
String text = selection != null ? selection : DebuggerBundle.message("breakpoint.log.message",
breakpoint.getDisplayName());
breakpoint.setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, text));
- breakpoint.SUSPEND_POLICY = DebuggerSettings.SUSPEND_NONE;
+ breakpoint.SUSPEND = false;
DialogWrapper dialog = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager()
.createConfigurationDialog(breakpoint, BreakpointPropertiesPanel.CONTROL_LOG_MESSAGE);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
index 3f24242ac3fa..7d71e2166522 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
@@ -48,7 +48,7 @@
-
+
@@ -56,7 +56,7 @@
-
+
@@ -77,7 +77,7 @@
-
+
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
index 893cdd9d06ad..705b30011c0a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
@@ -51,7 +51,6 @@ import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointChooser;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointNoneItem;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -101,9 +100,9 @@ public abstract class BreakpointPropertiesPanel {
private JPanel mySpecialBoxPanel;
private PsiClass myBreakpointPsiClass;
- private JRadioButton mySuspendThreadRadio;
- private JRadioButton mySuspendAllRadio;
- private JBCheckBox mySuspendJBCheckBox;
+ private JRadioButton myRbSuspendThread;
+ private JRadioButton myRbSuspendAll;
+ private JBCheckBox myCbSuspend;
private JButton myMakeDefaultButton;
private JRadioButton myDisableAgainRadio;
@@ -119,8 +118,7 @@ public abstract class BreakpointPropertiesPanel {
private JBCheckBox myConditionCheckbox;
ButtonGroup mySuspendPolicyGroup;
- @NonNls public static final String CONTROL_LOG_MESSAGE = "logMessage";
- private static final int MAX_COMBO_WIDTH = 300;
+ public static final String CONTROL_LOG_MESSAGE = "logMessage";
private final FixedSizeButton myConditionMagnifierButton;
private boolean myMoreOptionsVisible = true;
private Breakpoint myBreakpoint;
@@ -154,10 +152,6 @@ public abstract class BreakpointPropertiesPanel {
};
}
- public DetailView getDetailView() {
- return myDetailView;
- }
-
public interface Delegate {
void showActionsPanel();
@@ -233,8 +227,8 @@ public abstract class BreakpointPropertiesPanel {
myCompact = compact;
mySuspendPolicyGroup = new ButtonGroup();
- mySuspendPolicyGroup.add(mySuspendAllRadio);
- mySuspendPolicyGroup.add(mySuspendThreadRadio);
+ mySuspendPolicyGroup.add(myRbSuspendAll);
+ mySuspendPolicyGroup.add(myRbSuspendThread);
updateSuspendPolicyRbFont();
final ItemListener suspendPolicyChangeListener = new ItemListener() {
@@ -244,17 +238,18 @@ public abstract class BreakpointPropertiesPanel {
}
};
- mySuspendJBCheckBox.addActionListener(new ActionListener() {
+ myCbSuspend.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
- mySuspendAllRadio.setEnabled(mySuspendJBCheckBox.isSelected());
- mySuspendThreadRadio.setEnabled(mySuspendJBCheckBox.isSelected());
+ final boolean enabled = myCbSuspend.isSelected();
+ myRbSuspendAll.setEnabled(enabled);
+ myRbSuspendThread.setEnabled(enabled);
}
});
- mySuspendAllRadio.addItemListener(suspendPolicyChangeListener);
- mySuspendThreadRadio.addItemListener(suspendPolicyChangeListener);
+ myRbSuspendAll.addItemListener(suspendPolicyChangeListener);
+ myRbSuspendThread.addItemListener(suspendPolicyChangeListener);
myConditionCheckbox.addItemListener(suspendPolicyChangeListener);
myMakeDefaultButton.addActionListener(new ActionListener() {
@@ -264,10 +259,10 @@ public abstract class BreakpointPropertiesPanel {
breakpointManager.setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(suspendPolicy, myConditionCheckbox.isSelected()));
updateSuspendPolicyRbFont();
if (DebuggerSettings.SUSPEND_THREAD.equals(suspendPolicy)) {
- mySuspendThreadRadio.requestFocus();
+ myRbSuspendThread.requestFocus();
}
else {
- mySuspendAllRadio.requestFocus();
+ myRbSuspendAll.requestFocus();
}
myMakeDefaultButton.setEnabled(false);
}
@@ -380,7 +375,7 @@ public abstract class BreakpointPropertiesPanel {
DebuggerUIUtil.focusEditorOnCheck(myClassFiltersCheckBox, myClassFiltersField.getTextField());
DebuggerUIUtil.focusEditorOnCheck(myConditionCheckbox, myConditionCombo);
- IJSwingUtilities.adjustComponentsOnMac(mySuspendJBCheckBox);
+ IJSwingUtilities.adjustComponentsOnMac(myCbSuspend);
IJSwingUtilities.adjustComponentsOnMac(myLogExpressionCheckBox);
IJSwingUtilities.adjustComponentsOnMac(myLogMessageCheckBox);
}
@@ -415,19 +410,12 @@ public abstract class BreakpointPropertiesPanel {
return;
}
}
- getBreakpointManager(myProject).addBreakpointRule(new EnableBreakpointRule(getBreakpointManager(myProject),
- masterBreakpoint,
- myBreakpoint,
- selected));
+ getBreakpointManager(myProject).addBreakpointRule(new EnableBreakpointRule(getBreakpointManager(myProject), masterBreakpoint, myBreakpoint, selected));
}
-
}
private String getSelectedSuspendPolicy() {
- if (!mySuspendJBCheckBox.isSelected()) {
- return DebuggerSettings.SUSPEND_NONE;
- }
- if (mySuspendThreadRadio.isSelected()) {
+ if (myRbSuspendThread.isSelected()) {
return DebuggerSettings.SUSPEND_THREAD;
}
return DebuggerSettings.SUSPEND_ALL;
@@ -436,11 +424,11 @@ public abstract class BreakpointPropertiesPanel {
private void updateSuspendPolicyRbFont() {
final String defPolicy = getBreakpointManager(myProject).getBreakpointDefaults(myBreakpointCategory).getSuspendPolicy();
- final Font font = mySuspendAllRadio.getFont().deriveFont(Font.PLAIN);
+ final Font font = myRbSuspendAll.getFont().deriveFont(Font.PLAIN);
final Font boldFont = font.deriveFont(Font.BOLD);
- mySuspendAllRadio.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
- mySuspendThreadRadio.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
+ myRbSuspendAll.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
+ myRbSuspendThread.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
}
protected ClassFilter createClassConditionFilter() {
@@ -491,32 +479,32 @@ public abstract class BreakpointPropertiesPanel {
myConditionCombo.setContext(context);
- mySuspendJBCheckBox.setSelected(!breakpoint.SUSPEND_POLICY.equals(DebuggerSettings.SUSPEND_NONE));
- mySuspendThreadRadio.setEnabled(mySuspendJBCheckBox.isSelected());
- mySuspendAllRadio.setEnabled(mySuspendJBCheckBox.isSelected());
+ myCbSuspend.setSelected(breakpoint.SUSPEND);
+ myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
+ myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
- if(DebuggerSettings.SUSPEND_NONE.equals(breakpoint.SUSPEND_POLICY)) {
+ if(!breakpoint.SUSPEND) {
actionsPanelVisible = true;
}
- else if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.SUSPEND_POLICY)){
- mySuspendPolicyGroup.setSelected(mySuspendThreadRadio.getModel(), true);
+ if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.SUSPEND_POLICY)){
+ myRbSuspendThread.setSelected(true);
}
else {
- mySuspendPolicyGroup.setSelected(mySuspendAllRadio.getModel(), true);
+ myRbSuspendAll.setSelected(true);
}
- mySuspendJBCheckBox.addActionListener(new ActionListener() {
+ myCbSuspend.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (!myActionsPanel.isVisible()) {
- if (!mySuspendJBCheckBox.isSelected()) {
+ if (!myCbSuspend.isSelected()) {
if (myDelegate != null) {
myDelegate.showActionsPanel();
}
}
}
- mySuspendThreadRadio.setEnabled(mySuspendJBCheckBox.isSelected());
- mySuspendAllRadio.setEnabled(mySuspendJBCheckBox.isSelected());
+ myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
+ myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
}
});
myLogMessageCheckBox.setSelected(breakpoint.LOG_ENABLED);
@@ -635,6 +623,7 @@ public abstract class BreakpointPropertiesPanel {
breakpoint.setLogMessage(myLogExpressionCombo.getText());
breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected();
breakpoint.LOG_ENABLED = myLogMessageCheckBox.isSelected();
+ breakpoint.SUSPEND = myCbSuspend.isSelected();
breakpoint.SUSPEND_POLICY = getSelectedSuspendPolicy();
reloadInstanceFilters();
reloadClassFilters();
@@ -652,10 +641,6 @@ public abstract class BreakpointPropertiesPanel {
breakpoint.updateUI(afterUpdate);
}
- private static String concatWith(List s, String concator) {
- return StringUtil.join(s, concator);
- }
-
private static String concatWithEx(List s, String concator, int N, String NthConcator) {
String result = "";
int i = 1;
@@ -665,7 +650,8 @@ public abstract class BreakpointPropertiesPanel {
if(iterator.hasNext()){
if(i % N == 0){
result += NthConcator;
- } else {
+ }
+ else {
result += concator;
}
}
@@ -681,8 +667,7 @@ public abstract class BreakpointPropertiesPanel {
}
}
if (updateText) {
- String editorText = concatWith(filters, " ");
- myInstanceFiltersField.setText(editorText);
+ myInstanceFiltersField.setText(StringUtil.join(filters, " "));
}
String tipText = concatWithEx(filters, " ", (int)Math.sqrt(myInstanceFilters.length) + 1, "\n");
@@ -695,9 +680,12 @@ public abstract class BreakpointPropertiesPanel {
ArrayList idxs = new ArrayList();
int startNumber = -1;
for(int i = 0; i <= filtersText.length(); i++) {
- if(i < filtersText.length() && Character.isDigit(filtersText.charAt(i))){
- if(startNumber == -1) startNumber = i;
- } else {
+ if(i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) {
+ if(startNumber == -1) {
+ startNumber = i;
+ }
+ }
+ else {
if(startNumber >=0) {
idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i)));
startNumber = -1;
@@ -705,7 +693,9 @@ public abstract class BreakpointPropertiesPanel {
}
}
for (InstanceFilter instanceFilter : myInstanceFilters) {
- if (!instanceFilter.isEnabled()) idxs.add(instanceFilter);
+ if (!instanceFilter.isEnabled()) {
+ idxs.add(instanceFilter);
+ }
}
myInstanceFilters = idxs.toArray(new InstanceFilter[idxs.size()]);
}
@@ -724,18 +714,21 @@ public abstract class BreakpointPropertiesPanel {
}
}
if (updateText) {
- String editorText = concatWith(filters, " ");
- if(!filters.isEmpty()) editorText += " ";
- editorText += concatWith(excludeFilters, " ");
+ String editorText = StringUtil.join(filters, " ");
+ if(!filters.isEmpty()) {
+ editorText += " ";
+ }
+ editorText += StringUtil.join(excludeFilters, " ");
myClassFiltersField.setText(editorText);
}
int width = (int)Math.sqrt(myClassExclusionFilters.length + myClassFilters.length) + 1;
String tipText = concatWithEx(filters, " ", width, "\n");
- if(!filters.isEmpty()) tipText += "\n";
+ if(!filters.isEmpty()) {
+ tipText += "\n";
+ }
tipText += concatWithEx(excludeFilters, " ", width, "\n");
myClassFiltersField.getTextField().setToolTipText(tipText);
-
}
private void reloadClassFilters() {
@@ -746,12 +739,16 @@ public abstract class BreakpointPropertiesPanel {
int startFilter = -1;
for(int i = 0; i <= filtersText.length(); i++) {
if(i < filtersText.length() && !Character.isWhitespace(filtersText.charAt(i))){
- if(startFilter == -1) startFilter = i;
- } else {
+ if(startFilter == -1) {
+ startFilter = i;
+ }
+ }
+ else {
if(startFilter >=0) {
- if(filtersText.charAt(startFilter) == '-'){
+ if(filtersText.charAt(startFilter) == '-') {
exclusionFilters.add(new com.intellij.ui.classFilter.ClassFilter(filtersText.substring(startFilter + 1, i)));
- } else {
+ }
+ else {
classFilters.add(new com.intellij.ui.classFilter.ClassFilter(filtersText.substring(startFilter, i)));
}
startFilter = -1;
@@ -759,10 +756,14 @@ public abstract class BreakpointPropertiesPanel {
}
}
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassFilters) {
- if (!classFilter.isEnabled()) classFilters.add(classFilter);
+ if (!classFilter.isEnabled()) {
+ classFilters.add(classFilter);
+ }
}
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassExclusionFilters) {
- if (!classFilter.isEnabled()) exclusionFilters.add(classFilter);
+ if (!classFilter.isEnabled()) {
+ exclusionFilters.add(classFilter);
+ }
}
myClassFilters = classFilters .toArray(new com.intellij.ui.classFilter.ClassFilter[classFilters .size()]);
myClassExclusionFilters = exclusionFilters.toArray(new com.intellij.ui.classFilter.ClassFilter[exclusionFilters.size()]);
@@ -809,7 +810,7 @@ public abstract class BreakpointPropertiesPanel {
return myPanel;
}
- private BreakpointManager getBreakpointManager(Project project) {
+ private static BreakpointManager getBreakpointManager(Project project) {
return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
}
@@ -841,8 +842,7 @@ public abstract class BreakpointPropertiesPanel {
@Nullable
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout());
- myEditor = new DebuggerStatementEditor(myProject, myTargetEditor.getContext(), myTargetEditor.getRecentsId(),
- DefaultCodeFragmentFactory.getInstance());
+ myEditor = new DebuggerStatementEditor(myProject, myTargetEditor.getContext(), myTargetEditor.getRecentsId(), DefaultCodeFragmentFactory.getInstance());
myEditor.setPreferredSize(new Dimension(400, 150));
myEditor.setText(myTargetEditor.getText());
panel.add(myEditor, BorderLayout.CENTER);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
index e84f445ad0a0..e8fd23ead332 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
@@ -48,6 +48,7 @@ import java.util.List;
public abstract class FilteredRequestor implements LocatableEventRequestor, JDOMExternalizable {
public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
+ public boolean SUSPEND = true;
public boolean COUNT_FILTER_ENABLED = false;
public int COUNT_FILTER = 0;
@@ -82,7 +83,7 @@ public abstract class FilteredRequestor implements LocatableEventRequestor, JDOM
}
public String getSuspendPolicy() {
- return SUSPEND_POLICY;
+ return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE;
}
/**
@@ -122,6 +123,10 @@ public abstract class FilteredRequestor implements LocatableEventRequestor, JDOM
public void readExternal(Element parentNode) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, parentNode);
+ if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format
+ SUSPEND = false;
+ SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
+ }
String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
if (condition != null) {
setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
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 ff24e526f97e..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
@@ -53,18 +53,29 @@ 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 addSteps(context, modulesProvider, this, new StepSequence());
+ }
+
+ 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);
}
- 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..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
@@ -15,10 +15,9 @@
*/
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;
+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;
@@ -54,15 +53,15 @@ public class CreateFromTemplateMode extends WizardMode {
@Nullable
@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;
+ 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;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/Java18CompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/Java18CompletionData.java
index a113ec229635..8ca01064da91 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/Java18CompletionData.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/Java18CompletionData.java
@@ -42,7 +42,9 @@ public class Java18CompletionData extends Java15CompletionData {
}
if (AFTER_DOUBLE_COLON.accepts(position)) {
- result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), TailType.SEMICOLON));
+ final PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiMethodReferenceExpression.class);
+ final TailType tailType = parent != null && !LambdaUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
+ result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), tailType));
return;
}
}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java b/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
index 8f14fbd2d9ed..b91e1dee7e53 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public abstract class DaemonCodeAnalyzer {
public static DaemonCodeAnalyzer getInstance(Project project) {
@@ -35,15 +36,15 @@ public abstract class DaemonCodeAnalyzer {
public abstract void updateVisibleHighlighters(@NotNull Editor editor);
public abstract void setUpdateByTimerEnabled(boolean value);
- public abstract void disableUpdateByTimer(Disposable parentDisposable);
+ public abstract void disableUpdateByTimer(@NotNull Disposable parentDisposable);
- public abstract boolean isHighlightingAvailable(PsiFile file);
+ public abstract boolean isHighlightingAvailable(@Nullable PsiFile file);
public abstract void setImportHintsEnabled(@NotNull PsiFile file, boolean value);
public abstract void resetImportHintsEnabledForProject();
public abstract void setHighlightingEnabled(@NotNull PsiFile file, boolean value);
public abstract boolean isImportHintsEnabled(@NotNull PsiFile file);
- public abstract boolean isAutohintsAvailable(PsiFile file);
+ public abstract boolean isAutohintsAvailable(@Nullable PsiFile file);
/**
* Force rehighlighting for all files
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..f052cdfa82de 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 > 1000) LOG.error("applyFilter " + filter.getClass().getSimpleName() + " took" + t0 + "ms on '''" + line + "'''");
if (info != null) {
return info;
}
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
index fe8844a58ea2..09b5b4980538 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
@@ -79,12 +79,15 @@ public abstract class ModuleBuilder extends ProjectBuilder{
return myName;
}
+ @Nullable
public String getBuilderId() {
- return getModuleType().getId();
+ ModuleType moduleType = getModuleType();
+ return moduleType == null ? null : moduleType.getId();
}
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider) {
- return getModuleType().createWizardSteps(wizardContext, this, modulesProvider);
+ ModuleType moduleType = getModuleType();
+ return moduleType == null ? ModuleWizardStep.EMPTY_ARRAY : moduleType.createWizardSteps(wizardContext, this, modulesProvider);
}
public void setName(String name) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 478a33fcc001..d4c48bd7f24d 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -381,9 +381,11 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
private int myDisableCount = 0;
@Override
- public void disableUpdateByTimer(Disposable parentDisposable) {
+ public void disableUpdateByTimer(@NotNull Disposable parentDisposable) {
setUpdateByTimerEnabled(false);
myDisableCount++;
+ ApplicationManager.getApplication().assertIsDispatchThread();
+
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
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
*/
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..1402d6b735f3
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgDeleteModifyPromptHandler.java
@@ -0,0 +1,100 @@
+/*
+ * 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 org.jetbrains.annotations.Nullable;
+
+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.+");
+
+
+ public HgPromptChoice promptUser(@NotNull final String message,
+ @NotNull final HgPromptChoice[] choices,
+ @NotNull final HgPromptChoice defaultChoice) {
+
+ Matcher localDelMatcher = LOCAL_DELETE_REMOTE_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ Matcher localModifyMatcher = REMOTE_DELETE_LOCAL_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ String filename;
+ final String modifiedMessage;
+ if (localDelMatcher.matches()) {
+ filename = localDelMatcher.group(1);
+ modifiedMessage =
+ "File " + filename + " is deleted locally, but modified remotely. Do you want to keep the modified version or remove the file?";
+ }
+ else if (localModifyMatcher.matches()) {
+ filename = localModifyMatcher.group(1);
+ modifiedMessage =
+ "File " + filename + " is deleted remotely, but modified locally. Do you want to keep the modified version or remove the file?";
+ }
+ else {
+ modifiedMessage = "";
+ }
+ 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(modifiedMessage, "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(@Nullable String message) {
+ if (message == null) {
+ return false;
+ }
+ Matcher localDelMatcher = LOCAL_DELETE_REMOTE_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ Matcher localModifyMatcher = REMOTE_DELETE_LOCAL_MODIFIED_CONFLICT_MESSAGE_PATTERN.matcher(message);
+ if (localDelMatcher.matches() || localModifyMatcher.matches()) {
+ 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..2291528e6274
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptChoice.java
@@ -0,0 +1,58 @@
+/*
+ * 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 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("&", "");
+ 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..0acdbde5178b
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptHandler.java
@@ -0,0 +1,48 @@
+/*
+ * 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;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * HgPromptHandler is used by {@link HgCommandExecutor}, when you want to change the behavior of
+ * standard commands execution in the Mercurial.
+ *
+ * @author Nadya Zabrodina
+ */
+public interface HgPromptHandler {
+
+ /**
+ * Checks you need to change the default behavior.
+ *
+ * @param message standard output message from Mercurial
+ * @return
+ */
+ boolean shouldHandle(@Nullable String message);
+
+ /**
+ * Change default behavior in commands execution. Execute only if shouldHandle method return true.
+ *
+ * @param message standard output message from Mercurial
+ * @param choices possible choices
+ * @param defaultChoice
+ * @return
+ */
+ HgPromptChoice promptUser(@NotNull final String message,
+ @NotNull final HgPromptChoice[] choices,
+ @NotNull final HgPromptChoice defaultChoice);
+}
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) {