Merge remote-tracking branch 'origin/master'

This commit is contained in:
anna
2013-07-24 13:51:11 +02:00
28 changed files with 290 additions and 145 deletions
@@ -0,0 +1,38 @@
/*
* Copyright 2000-2013 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 com.intellij.compiler.impl.javaCompiler.javac;
import com.intellij.openapi.application.PathMacroFilter;
import org.jdom.Attribute;
import org.jdom.Element;
/**
* @author nik
*/
public class JavacConfigurationMacroFilter extends PathMacroFilter {
@Override
public boolean recursePathMacros(Attribute attribute) {
if (attribute.getName().equals("value")) {
Element parent = attribute.getParent();
if (parent != null && "option".equals(parent.getName()) && "ADDITIONAL_OPTIONS_STRING".equals(parent.getAttributeValue("name"))) {
Element grandParent = parent.getParentElement();
return grandParent != null && grandParent.getName().equals("component")
&& grandParent.getAttributeValue("name").equals("JavacSettings");
}
}
return false;
}
}
@@ -468,6 +468,9 @@ public class StandardInstructionVisitor extends InstructionVisitor {
return true;
}
}
if (PsiTreeUtil.findChildOfType(element, PsiAssignmentExpression.class) != null) {
return true;
}
return false;
}
}
@@ -620,6 +620,9 @@ public class JavaCompletionUtil {
if (element instanceof PsiJavaCodeReferenceElement) {
return mayHaveSideEffects(((PsiJavaCodeReferenceElement)element).getQualifier());
}
if (element instanceof PsiParenthesizedExpression) {
return mayHaveSideEffects(((PsiParenthesizedExpression)element).getExpression());
}
return true;
}
@@ -119,5 +119,5 @@ public class DataFlowInspectionAncientTest extends InspectionTestCase {
public void testSwitchEnumCases() { doTest15(); }
public void testSCR15406() { doTest(); }
//public void testIDEADEV11033() { doTest15(); } // added by max, 2007
public void testIDEADEV11033() { doTest15(); }
}
@@ -19,6 +19,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.GlobalInspectionContext;
import com.intellij.codeInspection.InspectionEP;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.lang.Language;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -85,6 +86,10 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
return myTool != null;
}
/**
* @see #applyToDialects()
* @see #isApplicable(com.intellij.lang.Language)
*/
@Nullable
public String getLanguage() {
return myEP == null ? null : myEP.language;
@@ -94,6 +99,11 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
return myEP != null && myEP.applyToDialects;
}
public boolean isApplicable(@NotNull Language language) {
String langId = getLanguage();
return langId == null || language.getID().equals(langId) || applyToDialects() && language.isKindOf(langId);
}
@NotNull
public String getShortName() {
return myEP != null ? myEP.getShortName() : getTool().getShortName();
@@ -198,6 +198,15 @@ public abstract class Language extends UserDataHolderBase {
return false;
}
public final boolean isKindOf(String anotherLanguageId) {
Language l = this;
while (l != null) {
if (l.getID().equals(anotherLanguageId)) return true;
l = l.getBaseLanguage();
}
return false;
}
public List<Language> getDialects() {
return myDialects;
}
@@ -5,6 +5,7 @@ import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.filters.TextConsoleBuilderImpl;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessOutputTypes;
@@ -28,7 +29,6 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.net.NetUtils;
import com.intellij.util.xmlb.XmlSerializer;
@@ -109,7 +109,7 @@ public class ExternalSystemRunConfiguration extends RunConfigurationBase impleme
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
return new MyRunnableState(mySettings, getProject(), ToolWindowId.DEBUG.equals(executor.getId()));
return new MyRunnableState(mySettings, getProject(), DefaultDebugExecutor.EXECUTOR_ID.equals(executor.getId()));
}
@Override
@@ -21,12 +21,12 @@ import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RemoteConnection;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,7 +46,7 @@ public class ExternalSystemTaskDebugRunner extends GenericDebuggerRunner {
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
return profile instanceof ExternalSystemRunConfiguration && ToolWindowId.DEBUG.equals(executorId);
return profile instanceof ExternalSystemRunConfiguration && DefaultDebugExecutor.EXECUTOR_ID.equals(executorId);
}
@Nullable
@@ -20,13 +20,13 @@ import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.GenericProgramRunner;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,7 +44,7 @@ public class ExternalSystemTaskRunner extends GenericProgramRunner {
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
return profile instanceof ExternalSystemRunConfiguration && ToolWindowId.RUN.equals(executorId);
return profile instanceof ExternalSystemRunConfiguration && DefaultRunExecutor.EXECUTOR_ID.equals(executorId);
}
@Nullable
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.externalSystem.service.task.ui;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.ExternalSystemUiAware;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
@@ -23,7 +24,6 @@ import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecution
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo;
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.util.containers.ContainerUtilRt;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
@@ -220,7 +220,7 @@ public class ExternalSystemTasksTreeModel extends DefaultTreeModel {
settings.setExternalProjectPath(task.getLinkedExternalProjectPath());
settings.setTaskNames(Collections.singletonList(task.getName()));
settings.setExternalSystemIdString(myExternalSystemId.toString());
return new ExternalTaskExecutionInfo(settings, ToolWindowId.RUN);
return new ExternalTaskExecutionInfo(settings, DefaultRunExecutor.EXECUTOR_ID);
}
@SuppressWarnings("unchecked")
@@ -17,6 +17,8 @@ package com.intellij.openapi.externalSystem.util;
import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.rmi.RemoteUtil;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
@@ -56,7 +58,6 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowEP;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.openapi.wm.impl.ToolWindowImpl;
@@ -90,8 +91,8 @@ public class ExternalSystemUtil {
@NotNull private static final Map<String, String> RUNNER_IDS = ContainerUtilRt.newHashMap();
static {
RUNNER_IDS.put(ToolWindowId.RUN, ExternalSystemConstants.RUNNER_ID);
RUNNER_IDS.put(ToolWindowId.DEBUG, ExternalSystemConstants.DEBUG_RUNNER_ID);
RUNNER_IDS.put(DefaultRunExecutor.EXECUTOR_ID, ExternalSystemConstants.RUNNER_ID);
RUNNER_IDS.put(DefaultDebugExecutor.EXECUTOR_ID, ExternalSystemConstants.DEBUG_RUNNER_ID);
}
private ExternalSystemUtil() {
@@ -729,6 +729,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
List<LocalInspectionToolWrapper> enabled = new ArrayList<LocalInspectionToolWrapper>();
final InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(element);
InspectionProfileWrapper.checkInspectionsDuplicates(toolWrappers);
Language language = myFile.getLanguage();
for (InspectionToolWrapper toolWrapper : toolWrappers) {
if (!profile.isToolEnabled(HighlightDisplayKey.find(toolWrapper.getShortName()), element)) continue;
LocalInspectionToolWrapper wrapper = null;
@@ -736,8 +737,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
wrapper = (LocalInspectionToolWrapper)toolWrapper;
}
if (wrapper == null) continue;
if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) {
continue;
if (myIgnoreSuppressed) {
if (wrapper.isApplicable(language) && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) {
continue;
}
}
enabled.add(wrapper);
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
@@ -31,9 +32,15 @@ import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.SearchTextField;
import com.intellij.ui.components.JBList;
@@ -48,7 +55,9 @@ import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Konstantin Bulenkov
@@ -75,6 +84,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
createSearchField();
}
});
myList.setCellRenderer(new MyListRenderer());
}
@@ -123,6 +133,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
public void focusLost(FocusEvent e) {
editor.setColumns(7);
myAlarm.cancelAllRequests();
myList.setModel(new DefaultListModel());
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
@@ -151,13 +162,44 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
myActions = myActionModel.getNames(true);
}
List<MatchResult> classes = ContainerUtil.getFirstItems(collectResults(pattern, myClasses, myClassModel), 20);
List<MatchResult> files = ContainerUtil.getFirstItems(collectResults(pattern, myFiles, myFileModel), 20);
List<MatchResult> actions = ContainerUtil.getFirstItems(collectResults(pattern, myActions, myActionModel), 20);
List<MatchResult> classes = ContainerUtil.getFirstItems(collectResults(pattern, myClasses, myClassModel), 30);
List<MatchResult> files = ContainerUtil.getFirstItems(collectResults(pattern, myFiles, myFileModel), 30);
List<MatchResult> actions = ContainerUtil.getFirstItems(collectResults(pattern, myActions, myActionModel), 30);
final DefaultListModel listModel = new DefaultListModel();
for (MatchResult o : classes) listModel.addElement(o);
for (MatchResult o : files) listModel.addElement(o);
for (MatchResult o : actions) listModel.addElement(o);
Set<VirtualFile> alreadyAddedFiles = new HashSet<VirtualFile>();
for (MatchResult o : classes) {
Object[] objects = myClassModel.getElementsByName(o.elementName, false, pattern);
for (Object object : objects) {
if (!listModel.contains(object)) {
listModel.addElement(object);
if (object instanceof PsiElement) {
VirtualFile file = PsiUtilCore.getVirtualFile((PsiElement)object);
if (file != null) {
alreadyAddedFiles.add(file);
}
}
}
}
}
for (MatchResult o : files) {
Object[] objects = myFileModel.getElementsByName(o.elementName, false, pattern);
for (Object object : objects) {
if (!listModel.contains(object)) {
if (object instanceof PsiFile) {
object = ((PsiFile)object).getVirtualFile();
}
if (!alreadyAddedFiles.contains(object)) {
listModel.addElement(object);
}
}
}
}
for (MatchResult o : actions) {
Object[] objects = myActionModel.getElementsByName(o.elementName, true, pattern);
for (Object object : objects) {
listModel.addElement(object);
}
}
myList.setModel(listModel);
if (myPopup == null || !myPopup.isVisible()) {
@@ -243,4 +285,32 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
}
}
private class MyListRenderer extends ColoredListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
try {
if (value instanceof PsiNamedElement) {
String name = ((PsiNamedElement)value).getName();
assert name != null;
append(name);
}
else if (value instanceof VirtualFile) {
append(((VirtualFile)value).getName());
}
else {
append(value.toString());
}
}
finally {
token.finish();
}
}
}
}
@@ -88,15 +88,15 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
textAndProgress.add(myText, BorderLayout.CENTER);
final NonOpaquePanel progressWrapper = new NonOpaquePanel(new GridBagLayout());
progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
final GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.weighty = 1;
c.insets = new Insets(SystemInfo.isMacOSLion ? 1 : 0, 0, 1, 4);
c.insets = new Insets(SystemInfo.isMacOSLion ? 1 : 0, 0, 1, myInfo.isCancellable() ? 0 : 4);
c.fill = GridBagConstraints.HORIZONTAL;
progressWrapper.add(myProgress, c);
textAndProgress.add(progressWrapper, BorderLayout.WEST);
textAndProgress.add(progressWrapper, BorderLayout.EAST);
myComponent.add(textAndProgress, BorderLayout.CENTER);
myComponent.add(myCancelButton, BorderLayout.EAST);
myComponent.setToolTipText(processInfo.getTitle() + ". " + IdeBundle.message("progress.text.clickToViewProgressWindow"));
@@ -15,12 +15,15 @@
*/
package com.intellij.openapi.components.impl;
import com.intellij.application.options.PathMacrosCollector;
import com.intellij.application.options.PathMacrosImpl;
import com.intellij.application.options.ReplacePathToMacroMap;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.components.CompositePathMacroFilter;
import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -37,6 +40,7 @@ import org.jetbrains.jps.model.serialization.PathMacroUtil;
import java.util.*;
public class BasePathMacroManager extends PathMacroManager {
private static CompositePathMacroFilter ourFilter = new CompositePathMacroFilter(Extensions.getExtensions(PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME));
private PathMacrosImpl myPathMacros;
public BasePathMacroManager(@Nullable PathMacros pathMacros) {
@@ -183,7 +187,7 @@ public class BasePathMacroManager extends PathMacroManager {
@Override
public void collapsePaths(final Element element) {
getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive);
getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, false, ourFilter);
}
public int hashCode() {
@@ -19,6 +19,7 @@ import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
import com.intellij.util.Query;
@@ -52,8 +53,7 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
@Override
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message(
"type.may.be.weakened.display.name");
return InspectionGadgetsBundle.message("type.may.be.weakened.display.name");
}
@Override
@@ -180,7 +180,9 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
type = factory.createTypeByFQClassName(fqClassName, scope);
}
final PsiJavaCodeReferenceElement referenceElement = factory.createReferenceElementByType(type);
componentReferenceElement.replace(referenceElement);
final PsiElement replacement = componentReferenceElement.replace(referenceElement);
final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
javaCodeStyleManager.shortenClassReferences(replacement);
}
}
@@ -222,7 +224,7 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
}
}
if (isOnTheFly() && variable instanceof PsiField) {
// checking variables with greater visibiltiy is too expensive
// checking variables with greater visibility is too expensive
// for error checking in the editor
if (!variable.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
@@ -0,0 +1,13 @@
package com.siyeh.igfixes.abstraction.type_may_be_weakened;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class Shorten {
private static void m() {
Collection<String> players = new ArrayList<String>();
players.add("new Player()");
}
}
@@ -0,0 +1,12 @@
package com.siyeh.igfixes.abstraction.type_may_be_weakened;
import java.util.ArrayList;
import java.util.List;
public class Shorten {
private static void m() {
List<String> <caret>players = new ArrayList<String>();
players.add("new Player()");
}
}
@@ -0,0 +1,21 @@
package com.siyeh.ig.fixes.abstraction;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.IGQuickFixesTestCase;
import com.siyeh.ig.abstraction.TypeMayBeWeakenedInspection;
/**
* @author Bas Leijdekkers
*/
public class TypeMayBeWeakenedFixTest extends IGQuickFixesTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new TypeMayBeWeakenedInspection());
myRelativePath = "abstraction/type_may_be_weakened";
}
public void testShorten() { doTest(InspectionGadgetsBundle.message("type.may.be.weakened.quickfix", "java.util.Collection")); }
}
@@ -66,7 +66,7 @@ public class GitTaskHandler extends VcsTaskHandler {
MultiMap<String, String> map = new MultiMap<String, String>();
if (!problems.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode() ||
Messages.showDialog("<html>The following repositories already have specified branch <b>" + taskName + "</b>:<br>" +
Messages.showDialog(myProject, "<html>The following repositories already have specified branch <b>" + taskName + "</b>:<br>" +
StringUtil.join(problems, "<br>") + ".<br>" +
"Do you want to checkout existing branch?", "Branch Already Exists",
new String[]{Messages.YES_BUTTON, Messages.NO_BUTTON}, 0,
@@ -78,8 +78,6 @@ public abstract class TaskManager {
public abstract LocalTask activateTask(@NotNull Task task, boolean clearContext);
public abstract void activateInVcs(LocalTask task, @Nullable LocalTask previousActive, VcsOperation operation, String name);
@NotNull
public abstract LocalTask getActiveTask();
@@ -73,22 +73,17 @@
</component>
</children>
</grid>
<grid id="637f6" binding="myVcsPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="637f6" binding="myVcsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="etched" title="VCS operations"/>
<children>
<component id="55d4e" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create dedicated &amp;branch"/>
</properties>
</component>
<component id="5f744" class="javax.swing.JTextField" binding="myBranchName">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
@@ -99,14 +94,6 @@
<enabled value="false"/>
</properties>
</component>
<component id="c4150" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Do &amp;nothing"/>
</properties>
</component>
<component id="3b431" class="javax.swing.JTextField" binding="myChangelistName">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
@@ -117,23 +104,24 @@
<enabled value="false"/>
</properties>
</component>
<component id="b1f13" class="com.intellij.ui.components.JBRadioButton">
<component id="ff04b" class="com.intellij.ui.components.JBCheckBox" binding="myCreateBranchJBCheckBox" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create new change&amp;list"/>
<text value="Create &amp;branch"/>
</properties>
</component>
<component id="807e3" class="com.intellij.ui.components.JBCheckBox" binding="myCreateChangelistJBCheckBox" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create change&amp;list"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<buttonGroups>
<group name="myVcsGroup" bound="true">
<member id="55d4e"/>
<member id="b1f13"/>
<member id="c4150"/>
</group>
</buttonGroups>
</form>
@@ -25,12 +25,10 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.VcsType;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.tasks.*;
import com.intellij.tasks.impl.TaskManagerImpl;
import com.intellij.tasks.impl.TaskUtil;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.RadioButtonEnumModel;
import com.intellij.ui.components.JBCheckBox;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,11 +51,11 @@ public class OpenTaskDialog extends DialogWrapper {
private JPanel myVcsPanel;
private JTextField myBranchName;
private JTextField myChangelistName;
private ButtonGroup myVcsGroup;
private JBCheckBox myCreateBranchJBCheckBox;
private JBCheckBox myCreateChangelistJBCheckBox;
private final Project myProject;
private final Task myTask;
private final RadioButtonEnumModel<TaskManager.VcsOperation> myButtonEnumModel;
public OpenTaskDialog(@NotNull final Project project, @NotNull final Task task) {
super(project, false);
@@ -81,54 +79,48 @@ public class OpenTaskDialog extends DialogWrapper {
TaskManagerImpl.Config state = taskManager.getState();
myClearContext.setSelected(state.clearContext);
myButtonEnumModel = RadioButtonEnumModel.bindEnum(TaskManager.VcsOperation.class, myVcsGroup);
AbstractVcs vcs = manager.getActiveVcs();
if (vcs == null) {
myVcsPanel.setVisible(false);
}
else {
if (vcs.getType() != VcsType.distributed) {
myButtonEnumModel.getButton(TaskManager.VcsOperation.CREATE_BRANCH).setVisible(false);
myBranchName.setVisible(false);
}
if (state.vcsOperation == -1) {
state.vcsOperation = vcs.getType() == VcsType.distributed
? TaskManager.VcsOperation.CREATE_BRANCH.ordinal()
: TaskManager.VcsOperation.CREATE_CHANGELIST.ordinal();
}
myVcsPanel.setBorder(IdeBorderFactory.createTitledBorder(vcs.getDisplayName() + " operations", false));
myBranchName.setText(taskManager.suggestBranchName(task));
myChangelistName.setText(taskManager.getChangelistName(task));
myButtonEnumModel.addActionListener(new ActionListener() {
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TaskManager.VcsOperation selected = myButtonEnumModel.getSelected();
myChangelistName.setEnabled(false);
myBranchName.setEnabled(false);
if (selected == TaskManager.VcsOperation.CREATE_BRANCH) {
myBranchName.setEnabled(true);
myBranchName.requestFocus();
}
else if (selected == TaskManager.VcsOperation.CREATE_CHANGELIST) {
myChangelistName.setEnabled(true);
IdeFocusManager.getInstance(myProject).requestFocus(myChangelistName, true);
myChangelistName.requestFocus();
}
updateFields();
}
});
myButtonEnumModel.setSelected(state.vcsOperation);
};
myCreateChangelistJBCheckBox.addActionListener(listener);
myCreateBranchJBCheckBox.addActionListener(listener);
myCreateChangelistJBCheckBox.setSelected(manager.getState().createChangelist);
myCreateBranchJBCheckBox.setSelected(manager.getState().createBranch);
if (vcs.getType() != VcsType.distributed) {
myCreateBranchJBCheckBox.setSelected(false);
myCreateBranchJBCheckBox.setVisible(false);
myBranchName.setVisible(false);
}
myBranchName.setText(taskManager.suggestBranchName(task));
myChangelistName.setText(taskManager.getChangelistName(task));
updateFields();
}
init();
}
private void updateFields() {
myBranchName.setEnabled(myCreateBranchJBCheckBox.isSelected());
myChangelistName.setEnabled(myCreateChangelistJBCheckBox.isSelected());
}
@Override
protected void doOKAction() {
TaskManagerImpl taskManager = (TaskManagerImpl)TaskManager.getManager(myProject);
taskManager.getState().markAsInProgress = isMarkAsInProgress();
TaskManager.VcsOperation operation = getVcsOperation();
taskManager.getState().vcsOperation = operation.ordinal();
taskManager.getState().createChangelist = myCreateChangelistJBCheckBox.isSelected();
taskManager.getState().createBranch = myCreateBranchJBCheckBox.isSelected();
TaskRepository repository = myTask.getRepository();
if (isMarkAsInProgress() && repository != null) {
@@ -142,7 +134,7 @@ public class OpenTaskDialog extends DialogWrapper {
}
LocalTask localTask = taskManager.activateTask(myTask, isClearContext());
LocalTask activeTask = taskManager.getActiveTask();
taskManager.activateInVcs(localTask, activeTask, operation, myBranchName.getText());
taskManager.createBranch(localTask, activeTask, myBranchName.getText());
if (myTask.getType() == TaskType.EXCEPTION && AnalyzeTaskStacktraceAction.hasTexts(myTask)) {
AnalyzeTaskStacktraceAction.analyzeStacktrace(myTask, myProject);
}
@@ -152,24 +144,22 @@ public class OpenTaskDialog extends DialogWrapper {
@Nullable
@Override
protected ValidationInfo doValidate() {
switch (myButtonEnumModel.getSelected()) {
case CREATE_BRANCH:
String branchName = myBranchName.getText().trim();
if (branchName.isEmpty()) {
return new ValidationInfo("Branch name should not be empty", myBranchName);
}
else if (branchName.contains(" ")) {
return new ValidationInfo("Branch name should not contain spaces");
}
else {
return null;
}
case CREATE_CHANGELIST:
if (myChangelistName.getText().trim().isEmpty()) {
return new ValidationInfo("Changelist name should not be empty");
}
case DO_NOTHING:
if (myCreateBranchJBCheckBox.isSelected()) {
String branchName = myBranchName.getText().trim();
if (branchName.isEmpty()) {
return new ValidationInfo("Branch name should not be empty", myBranchName);
}
else if (branchName.contains(" ")) {
return new ValidationInfo("Branch name should not contain spaces");
}
else {
return null;
}
}
if (myCreateChangelistJBCheckBox.isSelected()) {
if (myChangelistName.getText().trim().isEmpty()) {
return new ValidationInfo("Changelist name should not be empty");
}
}
return null;
}
@@ -178,15 +168,6 @@ public class OpenTaskDialog extends DialogWrapper {
return myClearContext.isSelected();
}
private TaskManager.VcsOperation getVcsOperation() {
if (myVcsPanel.isVisible()) {
return myButtonEnumModel.getSelected();
}
else {
return TaskManager.VcsOperation.DO_NOTHING;
}
}
private boolean isMarkAsInProgress() {
return myMarkAsInProgressBox.isSelected() && myMarkAsInProgressBox.isVisible();
}
@@ -198,13 +179,10 @@ public class OpenTaskDialog extends DialogWrapper {
@Override
public JComponent getPreferredFocusedComponent() {
TaskManager.VcsOperation operation = getVcsOperation();
if (operation == TaskManager.VcsOperation.CREATE_BRANCH) {
myBranchName.setEnabled(true);
if (myCreateBranchJBCheckBox.isSelected()) {
return myBranchName;
}
else if (operation == TaskManager.VcsOperation.CREATE_CHANGELIST) {
myChangelistName.setEnabled(true);
else if (myCreateChangelistJBCheckBox.isSelected()) {
return myChangelistName;
}
else return null;
@@ -387,20 +387,13 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
return task;
}
@Override
public void activateInVcs(LocalTask task, LocalTask previousActive, VcsOperation operation, String name) {
if (operation == VcsOperation.CREATE_CHANGELIST) {
String comment = TaskUtil.getChangeListComment(task);
createChangeList(task, name, comment);
}
else if (operation == VcsOperation.CREATE_BRANCH) {
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
for (VcsTaskHandler handler : handlers) {
if (previousActive != null) {
addBranches(previousActive, handler.getActiveTask());
}
addBranches(task, handler.startNewTask(name));
public void createBranch(LocalTask task, LocalTask previousActive, String name) {
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
for (VcsTaskHandler handler : handlers) {
if (previousActive != null) {
addBranches(previousActive, handler.getActiveTask());
}
addBranches(task, handler.startNewTask(name));
}
}
@@ -933,7 +926,8 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
public boolean clearContext = true;
public int vcsOperation = -1;
public boolean createChangelist = true;
public boolean createBranch = true;
public boolean saveContextOnCommit = true;
public boolean trackContextForNewChangelist = false;
@@ -19,7 +19,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.VcsTaskHandler;
import com.intellij.tasks.BranchInfo;
import com.intellij.tasks.LocalTask;
import com.intellij.tasks.TaskManager;
import com.intellij.tasks.TaskManagerTestCase;
import com.intellij.tasks.impl.LocalTaskImpl;
import com.intellij.util.Function;
@@ -76,7 +75,7 @@ public class TaskBranchesTest extends TaskManagerTestCase {
assertNotNull(defaultTask);
LocalTaskImpl foo = myTaskManager.createLocalTask("foo");
LocalTask localTask = myTaskManager.activateTask(foo, false);
myTaskManager.activateInVcs(localTask, defaultTask, TaskManager.VcsOperation.CREATE_BRANCH, myTaskManager.suggestBranchName(localTask));
myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask));
List<BranchInfo> branches = localTask.getBranches();
assertEquals(2, branches.size());
assertEquals(2, defaultTask.getBranches().size());
@@ -86,7 +85,7 @@ public class TaskBranchesTest extends TaskManagerTestCase {
foo = myTaskManager.createLocalTask("foo");
localTask = myTaskManager.activateTask(foo, false);
myTaskManager.activateInVcs(localTask, defaultTask, TaskManager.VcsOperation.CREATE_BRANCH, myTaskManager.suggestBranchName(localTask));
myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask));
assertEquals("foo", repositories.get(0).getCurrentBranch().getName());
}
@@ -192,11 +192,9 @@ public class TaskVcsTest extends CodeInsightFixtureTestCase {
}
private void activateAndCreateChangelist(Task task) {
LocalTask activeTask = myTaskManager.getActiveTask();
LocalTask localTask = myTaskManager.activateTask(task, false);
if (localTask.getChangeLists().isEmpty()) {
myTaskManager.activateInVcs(localTask, activeTask, TaskManager.VcsOperation.CREATE_CHANGELIST,
myTaskManager.getChangelistName(localTask));
myTaskManager.createChangeList(localTask, myTaskManager.getChangelistName(localTask));
}
}
@@ -223,6 +223,7 @@
serviceImplementation="com.intellij.compiler.impl.rmiCompiler.RmicConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.jikes.JikesConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.jikes.JikesConfiguration"/>
<pathMacroFilter implementation="com.intellij.compiler.impl.javaCompiler.javac.JavacConfigurationMacroFilter"/>
<applicationService serviceInterface="com.intellij.openapi.wm.impl.FrameTitleBuilder"
serviceImplementation="com.intellij.openapi.wm.IdeaFrameTitleBuilder"/>