Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
Kirill Kalishev
2010-06-30 14:41:08 +04:00
59 changed files with 354 additions and 756 deletions
@@ -51,7 +51,7 @@ public class CompositePackagingElementNode extends PackagingElementNode<Composit
PackagingTreeNodeFactory.addNodes(element.getChildren(), this, element, myContext, mySubstitutionParameters, getNodeSource(element), children,
myArtifactType, new HashSet<PackagingElement<?>>());
}
return children.toArray(new SimpleNode[children.size()]);
return children.isEmpty() ? NO_CHILDREN : children.toArray(new SimpleNode[children.size()]);
}
@Override
@@ -71,7 +71,7 @@ public abstract class SourceItemNodeBase extends ArtifactsTreeNode {
}
}
}
return children.toArray(new SimpleNode[children.size()]);
return children.isEmpty() ? NO_CHILDREN : children.toArray(new SimpleNode[children.size()]);
}
@Nullable
@@ -224,11 +224,11 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
final PathsList classPath;
if (jdk.getSdkType() instanceof JavaSdk) {
classPath = OrderEnumerator.orderEntries(myProject).withoutSdk().withoutThisModuleContent().getPathsList();
classPath = OrderEnumerator.orderEntries(myProject).withoutSdk().withoutModuleSourceEntries().getPathsList();
}
else {
//libraries are included into jdk
classPath = OrderEnumerator.orderEntries(myProject).withoutThisModuleContent().getPathsList();
classPath = OrderEnumerator.orderEntries(myProject).withoutModuleSourceEntries().getPathsList();
}
final String classPathString = classPath.getPathsString();
if (classPathString.length() > 0) {
@@ -35,7 +35,7 @@ import javax.swing.*;
import java.util.*;
public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColorSettingsPage {
private static final AttributesDescriptor[] ourDescriptors = new AttributesDescriptor[] {
private static final AttributesDescriptor[] ourDescriptors = {
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.keyword"), SyntaxHighlighterColors.KEYWORD),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.number"), SyntaxHighlighterColors.NUMBER),
@@ -82,8 +82,6 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.annotation.attribute.name"), CodeInsightColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES)
};
private static final ColorDescriptor[] ourColorDescriptors = new ColorDescriptor[0];
@NonNls private static final Map<String, TextAttributesKey> ourTags = new HashMap<String, TextAttributesKey>();
static {
ourTags.put("field", CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
@@ -135,7 +133,7 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
@NotNull
public ColorDescriptor[] getColorDescriptors() {
return ourColorDescriptors;
return ColorDescriptor.EMPTY_ARRAY;
}
@NotNull
@@ -300,13 +300,15 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
OrderRootType.COMPILATION_CLASSES.equals(type) ||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
final VirtualFile outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputPathForTests();
if (outputPathForTests != null) {
result.add(outputPathForTests);
}
VirtualFile outputRoot = getCompilerOutputPath();
if (outputRoot != null) result.add(outputRoot);
if (!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final VirtualFile outputPathForTests = getCompilerOutputPathForTests();
if (outputPathForTests != null && !outputPathForTests.equals(outputRoot)) {
result.add(outputPathForTests);
}
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
result.add(outputRoot);
}
return VfsUtil.toVirtualFileArray(result);
}
@@ -319,13 +321,15 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
OrderRootType.COMPILATION_CLASSES.equals(type) ||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final List<String> result = new ArrayList<String>();
final String outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputUrlForTests();
if (outputPathForTests != null) {
result.add(outputPathForTests);
}
String outputRoot = getCompilerOutputUrl();
if (outputRoot != null) result.add(outputRoot);
if (!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final String outputPathForTests = getCompilerOutputUrlForTests();
if (outputPathForTests != null && !outputPathForTests.equals(outputRoot)) {
result.add(outputPathForTests);
}
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
result.add(outputRoot);
}
return ArrayUtil.toStringArray(result);
}
@@ -15,7 +15,6 @@
*/
package com.intellij.psi.impl.compiled;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
@@ -35,8 +34,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements PsiJavaCodeReferenceElement {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl");
private final PsiElement myParent;
private final String myCanonicalText;
private final String myQualifiedName;
@@ -44,6 +41,7 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
private volatile PsiType[] myTypeParametersCachedTypes = null; // in left-to-right-order
@NonNls private static final String EXTENDS_PREFIX = "?extends";
@NonNls private static final String SUPER_PREFIX = "?super";
public static final ClsJavaCodeReferenceElementImpl[] EMPTY_ARRAY = new ClsJavaCodeReferenceElementImpl[0];
public ClsJavaCodeReferenceElementImpl(PsiElement parent, String canonicalText) {
myParent = parent;
@@ -36,10 +36,12 @@ public class ClsReferenceListImpl extends ClsRepositoryPsiElement<PsiClassRefere
synchronized (LAZY_BUILT_LOCK) {
if (myRefs == null) {
final String[] strings = getStub().getReferencedNames();
ClsJavaCodeReferenceElementImpl[] res = new ClsJavaCodeReferenceElementImpl[strings.length];
ClsJavaCodeReferenceElementImpl[] res = strings.length == 0 ?
ClsJavaCodeReferenceElementImpl.EMPTY_ARRAY :
new ClsJavaCodeReferenceElementImpl[strings.length];
for (int i = 0; i < res.length; i++) {
res[i] = new ClsJavaCodeReferenceElementImpl(this, strings[i]);
}
res[i] = new ClsJavaCodeReferenceElementImpl(this, strings[i]);
}
myRefs = res;
}
return myRefs;
@@ -146,7 +146,9 @@ class ExtractInterfaceDialog extends JavaExtractSuperBaseDialog {
@Override
protected String getPackageNameLabelText() {
return isExtractSuperclass() ? RefactoringBundle.message("package.for.new.interface") : "Package name for original class";
return isExtractSuperclass()
? RefactoringBundle.message("package.for.new.interface")
: RefactoringBundle.message("package.for.original.class");
}
protected JLabel getPackageNameLabel() {
@@ -122,7 +122,9 @@ class ExtractSuperclassDialog extends JavaExtractSuperBaseDialog {
@Override
protected String getPackageNameLabelText() {
return isExtractSuperclass() ? RefactoringBundle.message("package.for.new.superclass") : "Package name for original class";
return isExtractSuperclass()
? RefactoringBundle.message("package.for.new.superclass")
: RefactoringBundle.message("package.for.original.class");
}
protected String getEntityName() {
@@ -90,6 +90,7 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
}
public void stateChanged() {
if (project.isDisposed()) return;
if (toolWindow.getAnchor() != myAnchor) {
myAnchor = myToolWindow.getAnchor();
layoutPanel();
@@ -1,6 +1,3 @@
import com.intellij.ui.ScrollPaneFactory;
import javax.swing.*;
import java.awt.*;
public class ComponentCaller extends JComponent{
@@ -13,7 +10,7 @@ public class ComponentCaller extends JComponent{
private void buildUI() {
setLayout(new BorderLayout());
add(ScrollPaneFactory.createScrollPane((Component)component1));
add(new JScrollPane(component1));
}
public void doSomething(){
@@ -1,6 +1,3 @@
import com.intellij.ui.ScrollPaneFactory;
import javax.swing.*;
import java.awt.*;
public class ComponentCaller extends JComponent{
@@ -13,7 +10,7 @@ public class ComponentCaller extends JComponent{
private void buildUI() {
setLayout(new BorderLayout());
add(ScrollPaneFactory.createScrollPane((Component)component1));
add(new JScrollPane(component1));
}
public void doSomething(){
@@ -3,9 +3,10 @@ package com.intellij.roots;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderEnumerator;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.roots.ModuleRootManagerTestCase;
import com.intellij.util.PathsList;
/**
* @author nik
@@ -28,8 +29,8 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
assertOrderFiles(OrderRootType.CLASSES, getRtJar());
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot);
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), output, testOutput);
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), output, testOutput);
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), testOutput, output);
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), testOutput, output);
assertOrderFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES, getRtJar(), output);
}
@@ -54,8 +55,8 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot, getJDomSources());
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), output, testOutput, getJDomJar());
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), output, testOutput, getJDomJar());
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), testOutput, output, getJDomJar());
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), testOutput, output, getJDomJar());
assertOrderFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES, getRtJar(), output, getJDomJar());
}
@@ -85,6 +86,27 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
private void assertOrderFiles(final OrderRootType type, VirtualFile... files) {
assertOrderedEquals(ModuleRootManager.getInstance(myModule).getFiles(type), files);
assertRoots(collectByOrderEnumerator(type), files);
}
private PathsList collectByOrderEnumerator(OrderRootType type) {
final OrderEnumerator base = OrderEnumerator.orderEntries(myModule);
if (type == OrderRootType.CLASSES_AND_OUTPUT) {
return base.recursively().getPathsList();
}
if (type == OrderRootType.COMPILATION_CLASSES) {
return base.recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
return base.productionOnly().recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.CLASSES) {
return base.withoutModuleSourceEntries().recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.SOURCES) {
return base.recursively().exportedOnly().getSourcePathsList();
}
throw new AssertionError(type);
}
}
@@ -55,13 +55,13 @@ public class ProjectRootsTraversingTest extends ModuleRootManagerTestCase {
private PathsList collectByOrderEnumerator(ProjectRootsTraversing.RootTraversePolicy policy) {
if (policy == ProjectRootsTraversing.LIBRARIES_AND_JDK) {
return OrderEnumerator.orderEntries(myModule).withoutDepModules().withoutThisModuleContent().getPathsList();
return OrderEnumerator.orderEntries(myModule).withoutDepModules().withoutModuleSourceEntries().getPathsList();
}
if (policy == ProjectRootsTraversing.PROJECT_SOURCES) {
return OrderEnumerator.orderEntries(myModule).withoutSdk().withoutLibraries().withoutDepModules().getSourcePathsList();
}
if (policy == ProjectRootsTraversing.PROJECT_LIBRARIES) {
return OrderEnumerator.orderEntries(myModule).withoutSdk().withoutThisModuleContent().recursively().getPathsList();
return OrderEnumerator.orderEntries(myModule).withoutSdk().withoutModuleSourceEntries().recursively().getPathsList();
}
throw new AssertionError(policy);
}
@@ -149,7 +149,11 @@ public interface ModuleRootModel {
<R> R processOrder(RootPolicy<R> policy, R initialValue);
/**
* @since 10
* Returns {@link OrderEnumerator} instance which can be used to process order entries of the module (with or without dependencies) and
* collect classes or source roots
*
* @return {@link OrderEnumerator} instance
* @since 10.0
*/
@NotNull
OrderEnumerator orderEntries();
@@ -27,41 +27,115 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* Interface for convenient processing dependencies of a module or a project. Allows to process {@link OrderEntry}s and collect classes
* and source roots
*
* Use {@link #orderEntries(com.intellij.openapi.module.Module)} or {@link ModuleRootModel#orderEntries()} to process dependencies of a module
* and use {@link #orderEntries(com.intellij.openapi.project.Project)} to process dependencies of all modules in a project
*
* @since 10.0
*
*
* @author nik
*/
public abstract class OrderEnumerator {
/**
* Skip test dependencies
* @return this instance
*/
public abstract OrderEnumerator productionOnly();
/**
* Skip runtime-only dependencies
* @return this instance
*/
public abstract OrderEnumerator compileOnly();
public abstract OrderEnumerator runtimeOnly();
/**
* Skip compile-only dependencies
* @return this instance
*/
public abstract OrderEnumerator runtimeOnly();
public abstract OrderEnumerator withoutSdk();
public abstract OrderEnumerator withoutLibraries();
public abstract OrderEnumerator withoutDepModules();
public abstract OrderEnumerator withoutThisModuleContent();
public abstract OrderEnumerator withoutModuleSourceEntries();
/**
* Recursively process modules on which the module depends
* @return this instance
*/
public abstract OrderEnumerator recursively();
/**
* Skip not exported dependencies. If this method is called after {@link #recursively()} then
* @return this instance
*/
public abstract OrderEnumerator exportedOnly();
/**
* Process only entries which satisfies the specified condition
* @param condition filtering condition
* @return this instance
*/
public abstract OrderEnumerator satisfying(Condition<OrderEntry> condition);
/**
* @return classes roots for all entries processed by this enumerator
*/
public abstract Collection<VirtualFile> getClassesRoots();
/**
* @return source roots for all entries processed by this enumerator
*/
public abstract Collection<VirtualFile> getSourceRoots();
/**
* @return list containing classes roots for all entries processed by this enumerator
*/
public abstract PathsList getPathsList();
/**
* Add classes roots for all entries processed by this enumerator
* @param list list to append paths
*/
public abstract void collectPaths(PathsList list);
/**
* @return list containing source roots for all entries processed by this enumerator
*/
public abstract PathsList getSourcePathsList();
/**
* Add source roots for all entries processed by this enumerator
* @param list list to append paths
*/
public abstract void collectSourcePaths(PathsList list);
/**
* Runs <code>processor.process()</code> for each entry processed by this enumerator.
* @param processor processor
*/
public abstract void forEach(Processor<OrderEntry> processor);
public abstract void forEachLibrary(Processor<Library> processor);
/**
* Creates new enumerator instance to process dependencies of <code>module</code>
* @param module module
* @return new enumerator instance
*/
public static OrderEnumerator orderEntries(@NotNull Module module) {
return ModuleRootManager.getInstance(module).orderEntries();
}
/**
* Creates new enumerator instance to process dependencies of all modules in <code>project</code>. Only first level dependencies of
* modules are processed so {@link #recursively()} option is ignored and {@link #withoutDepModules()} option is forced
* @param project project
* @return new enumerator instance
*/
public static OrderEnumerator orderEntries(@NotNull Project project) {
return ProjectRootManager.getInstance(project).orderEntries();
}
@@ -42,7 +42,7 @@ public class OrderRootType {
* Runtime classpath.
* Includes:
* <li> production and test output for modules
* <li> classes roots for libraries unless scope is 'provided'
* <li> classes roots for libraries and jdk unless scope is 'provided'
* <li> recursively for module dependencies with scope != 'provided'
*/
public static final OrderRootType CLASSES_AND_OUTPUT = new OrderRootType("CLASSES_AND_OUTPUT");
@@ -51,7 +51,7 @@ public class OrderRootType {
* Classpath for compilation.
* Includes:
* <li> production and test output for modules
* <li> classes roots for libraries
* <li> classes roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType COMPILATION_CLASSES = new OrderRootType("COMPILATION_CLASSES");
@@ -60,7 +60,7 @@ public class OrderRootType {
* Classpath for compilation without tests.
* Includes:
* <li> production output for modules
* <li> classes roots for libraries with scope suitable for production compile
* <li> classes roots for libraries and jdk with scope suitable for production compile
* <li> recursively for module dependencies with scope suitable for production compile: only exported items
*/
public static final OrderRootType PRODUCTION_COMPILATION_CLASSES = new OrderRootType("PRODUCTION_COMPILATION_CLASSES");
@@ -68,7 +68,7 @@ public class OrderRootType {
/**
* Classpath without output directories for this module.
* Includes:
* <li> classes roots for libraries
* <li> classes roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType CLASSES = new PersistentOrderRootType("CLASSES", "classPath", null, "classPathEntry");
@@ -77,6 +77,7 @@ public class OrderRootType {
* Sources.
* Includes:
* <li> production and test source roots for modules
* <li> source roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType SOURCES = new PersistentOrderRootType("SOURCES", "sourcePath", null, "sourcePathEntry");
@@ -63,6 +63,7 @@ import java.util.*;
* _inside_, not outside of the read action
*/
public class FileTemplateManagerImpl extends FileTemplateManager implements ExportableComponent, JDOMExternalizable {
private static final FileTemplateManagerImpl[] EMPTY_ARRAY = new FileTemplateManagerImpl[0];
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl");
@NonNls private static final String DEFAULT_TEMPLATE_EXTENSION = "ft";
@NonNls private static final String TEMPLATES_DIR = "fileTemplates";
@@ -137,7 +138,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo
myPatternsManager = patternsManager;
myCodeTemplatesManager = codeTemplatesManager;
myJ2eeTemplatesManager = j2eeTemplatesManager;
myChildren = internalTemplatesManager == null ? new FileTemplateManagerImpl[0] : new FileTemplateManagerImpl[]{internalTemplatesManager,patternsManager,codeTemplatesManager,j2eeTemplatesManager};
myChildren = internalTemplatesManager == null ? EMPTY_ARRAY : new FileTemplateManagerImpl[]{internalTemplatesManager,patternsManager,codeTemplatesManager,j2eeTemplatesManager};
if (ApplicationManager.getApplication().isUnitTestMode() && defaultTemplatesDirName.equals(INTERNAL_DIR)) {
for (String tname : Arrays.asList("Class", "AnnotationType", "Enum", "Interface")) {
@@ -32,8 +32,7 @@ import javax.swing.*;
import java.util.Map;
public class CustomColorsPage implements ColorSettingsPage {
private static final ColorDescriptor[] COLORS = new ColorDescriptor[0];
private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[] {
private static final AttributesDescriptor[] ATTRS = {
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword1"), CustomHighlighterColors.CUSTOM_KEYWORD1_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword2"), CustomHighlighterColors.CUSTOM_KEYWORD2_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword3"), CustomHighlighterColors.CUSTOM_KEYWORD3_ATTRIBUTES),
@@ -46,7 +45,7 @@ public class CustomColorsPage implements ColorSettingsPage {
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.invalid.string.escape"), CustomHighlighterColors.CUSTOM_INVALID_STRING_ESCAPE),
};
@NonNls private final static SyntaxTable SYNTAX_TABLE = new SyntaxTable();
@NonNls private static final SyntaxTable SYNTAX_TABLE = new SyntaxTable();
static {
SYNTAX_TABLE.setLineComment("#");
SYNTAX_TABLE.setStartComment("/*");
@@ -81,7 +80,7 @@ public class CustomColorsPage implements ColorSettingsPage {
@NotNull
public ColorDescriptor[] getColorDescriptors() {
return COLORS;
return ColorDescriptor.EMPTY_ARRAY;
}
@NotNull
@@ -30,20 +30,21 @@ import org.jetbrains.annotations.NotNull;
public interface ProjectRootContainer {
@NotNull
VirtualFile[] getRootFiles(OrderRootType type);
ProjectRoot[] getRoots(OrderRootType type);
VirtualFile[] getRootFiles(@NotNull OrderRootType type);
@NotNull ProjectRoot[] getRoots(@NotNull OrderRootType type);
void startChange();
void finishChange();
ProjectRoot addRoot(VirtualFile virtualFile, OrderRootType type);
void addRoot(ProjectRoot root, OrderRootType type);
void removeRoot(ProjectRoot root, OrderRootType type);
void removeAllRoots(OrderRootType type);
@NotNull
ProjectRoot addRoot(@NotNull VirtualFile virtualFile, @NotNull OrderRootType type);
void addRoot(@NotNull ProjectRoot root, @NotNull OrderRootType type);
void removeRoot(@NotNull ProjectRoot root, @NotNull OrderRootType type);
void removeAllRoots(@NotNull OrderRootType type);
void removeAllRoots();
void removeRoot(VirtualFile root, OrderRootType type);
void removeRoot(@NotNull VirtualFile root, @NotNull OrderRootType type);
void update();
}
@@ -62,11 +62,12 @@ public class ProjectRootContainerImpl implements JDOMExternalizable, ProjectRoot
}
@NotNull
public VirtualFile[] getRootFiles(OrderRootType type) {
public VirtualFile[] getRootFiles(@NotNull OrderRootType type) {
return myFiles.get(type);
}
public ProjectRoot[] getRoots(OrderRootType type) {
@NotNull
public ProjectRoot[] getRoots(@NotNull OrderRootType type) {
return myRoots.get(type).getProjectRoots();
}
@@ -116,27 +117,28 @@ public class ProjectRootContainerImpl implements JDOMExternalizable, ProjectRoot
}
public void removeRoot(ProjectRoot root, OrderRootType type) {
public void removeRoot(@NotNull ProjectRoot root, @NotNull OrderRootType type) {
LOG.assertTrue(myInsideChange);
myRoots.get(type).remove(root);
}
public ProjectRoot addRoot(VirtualFile virtualFile, OrderRootType type) {
@NotNull
public ProjectRoot addRoot(@NotNull VirtualFile virtualFile, @NotNull OrderRootType type) {
LOG.assertTrue(myInsideChange);
return myRoots.get(type).add(virtualFile);
}
public void addRoot(ProjectRoot root, OrderRootType type) {
public void addRoot(@NotNull ProjectRoot root, @NotNull OrderRootType type) {
LOG.assertTrue(myInsideChange);
myRoots.get(type).add(root);
}
public void removeAllRoots(OrderRootType type ) {
public void removeAllRoots(@NotNull OrderRootType type ) {
LOG.assertTrue(myInsideChange);
myRoots.get(type).clear();
}
public void removeRoot(VirtualFile root, OrderRootType type) {
public void removeRoot(@NotNull VirtualFile root, @NotNull OrderRootType type) {
LOG.assertTrue(myInsideChange);
myRoots.get(type).remove(root);
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -39,12 +40,12 @@ public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable {
private boolean myInitialized = false;
@NonNls private static final String ATTRIBUTE_URL = "url";
SimpleProjectRoot(VirtualFile file) {
SimpleProjectRoot(@NotNull VirtualFile file) {
myFile = file;
myUrl = myFile.getUrl();
}
public SimpleProjectRoot(String url) {
public SimpleProjectRoot(@NotNull String url) {
myUrl = url;
}
@@ -94,7 +94,7 @@ public abstract class OrderEnumeratorBase extends OrderEnumerator {
}
@Override
public OrderEnumerator withoutThisModuleContent() {
public OrderEnumerator withoutModuleSourceEntries() {
myWithoutThisModuleContent = true;
return this;
}
@@ -56,6 +56,7 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesUtil;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ThrowableRunnable;
@@ -765,27 +766,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
//element.checkDelete(); //move != delete + add
newContainer.checkAdd(element);
checkIfMoveIntoSelf(element, newContainer);
}
private static void checkIfMoveIntoSelf(PsiElement element, PsiElement newContainer) throws IncorrectOperationException {
PsiElement container = newContainer;
while (container != null) {
if (container == element) {
if (element instanceof PsiDirectory) {
if (element == newContainer) {
throw new IncorrectOperationException("Cannot place directory into itself.");
}
else {
throw new IncorrectOperationException("Cannot place directory into its subdirectory.");
}
}
else {
throw new IncorrectOperationException();
}
}
container = container.getParent();
}
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(element, newContainer);
}
public void startBatchFilesProcessingMode() {
@@ -82,7 +82,7 @@ public class ReferenceProvidersRegistry extends PsiReferenceRegistrar {
};
private final Project myProject;
private final static NotNullLazyKey<ReferenceProvidersRegistry, Project> INSTANCE_CACHE =
private static final NotNullLazyKey<ReferenceProvidersRegistry, Project> INSTANCE_CACHE =
ServiceManager.createLazyKey(ReferenceProvidersRegistry.class);
public static ReferenceProvidersRegistry getInstance(Project project) {
@@ -267,7 +267,6 @@ public class ReferenceProvidersRegistry extends PsiReferenceRegistrar {
}
}
}
return ContainerUtil.toArray(result, new PsiReference[result.size()]);
return result.isEmpty() ? PsiReference.EMPTY_ARRAY : ContainerUtil.toArray(result, new PsiReference[result.size()]);
}
}
@@ -29,6 +29,7 @@ import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesUtil;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
@@ -80,6 +81,7 @@ public class CopyFilesOrDirectoriesHandler implements CopyHandlerDelegate {
if (dialog.isOK()) {
final String newName = elements.length == 1 ? dialog.getNewName() : null;
final PsiManager psiManager = PsiManager.getInstance(project);
final PsiDirectory targetDirectory = dialog.getTargetDirectory();
try {
for (PsiElement element : elements) {
PsiFileSystemItem psiElement = (PsiFileSystemItem)element;
@@ -87,18 +89,19 @@ public class CopyFilesOrDirectoriesHandler implements CopyHandlerDelegate {
if (!psiElement.isDirectory()) {
psiElement = (PsiFileSystemItem)psiElement.copy();
psiElement.setName(newName);
psiManager.checkMove(psiElement, targetDirectory);
} else {
dialog.getTargetDirectory().checkCreateSubdirectory(newName);
targetDirectory.checkCreateSubdirectory(newName);
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(psiElement, targetDirectory);
}
}
psiManager.checkMove(psiElement, dialog.getTargetDirectory());
}
}
catch (IncorrectOperationException e) {
CommonRefactoringUtil.showErrorHint(project, null, e.getMessage(), CommonBundle.getErrorTitle(), null);
return;
}
copyImpl(elements, newName, dialog.getTargetDirectory(), false);
copyImpl(elements, newName, targetDirectory, false);
}
}
@@ -177,4 +177,24 @@ public class MoveFilesOrDirectoriesUtil {
return null;
}
}
public static void checkIfMoveIntoSelf(PsiElement element, PsiElement newContainer) throws IncorrectOperationException {
PsiElement container = newContainer;
while (container != null) {
if (container == element) {
if (element instanceof PsiDirectory) {
if (element == newContainer) {
throw new IncorrectOperationException("Cannot place directory into itself.");
}
else {
throw new IncorrectOperationException("Cannot place directory into its subdirectory.");
}
}
else {
throw new IncorrectOperationException();
}
}
container = container.getParent();
}
}
}
@@ -67,7 +67,7 @@ public abstract class AnAction {
private boolean myEnabledInModalContext;
private static final ShortcutSet ourEmptyShortcutSet = new CustomShortcutSet(new Shortcut[0]);
private static final ShortcutSet ourEmptyShortcutSet = new CustomShortcutSet();
private boolean myIsDefaultIcon = true;
private boolean myWorksInInjected;
@@ -39,10 +39,10 @@ public final class CustomShortcutSet implements ShortcutSet {
* @param shortcuts keyboard shortcuts
*/
public CustomShortcutSet(Shortcut... shortcuts){
myShortcuts = (Shortcut[])shortcuts.clone();
myShortcuts = shortcuts.length == 0 ? Shortcut.EMPTY_ARRAY : shortcuts.clone();
}
public Shortcut[] getShortcuts(){
return (Shortcut[])myShortcuts.clone();
return myShortcuts.length == 0 ? Shortcut.EMPTY_ARRAY : myShortcuts.clone();
}
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.keymap.KeymapUtil;
* @see ShortcutSet
*/
public abstract class Shortcut {
public static final Shortcut[] EMPTY_ARRAY = new Shortcut[0];
Shortcut(){
}
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
public interface StreamProvider {
StreamProvider[] EMPTY_ARRAY = new StreamProvider[0];
StreamProvider DEFAULT = new StreamProvider(){
public void saveContent(final String fileSpec, final InputStream content, final long size, final RoamingType roamingType, boolean async) throws IOException {
@@ -23,7 +23,7 @@ import java.util.List;
public abstract class SimpleMutableNode extends CachingSimpleNode {
private final List myChildren = new ArrayList();
private final List<SimpleNode> myChildren = new ArrayList<SimpleNode>();
public SimpleMutableNode() {
}
@@ -37,7 +37,7 @@ public abstract class SimpleMutableNode extends CachingSimpleNode {
}
protected final SimpleNode[] buildChildren() {
return (SimpleNode[]) myChildren.toArray(new SimpleNode[myChildren.size()]);
return myChildren.isEmpty() ? NO_CHILDREN : myChildren.toArray(new SimpleNode[myChildren.size()]);
}
public final SimpleNode add(SimpleNode child) {
@@ -48,8 +48,8 @@ public abstract class SimpleMutableNode extends CachingSimpleNode {
public final SimpleNode[] addAll(SimpleNode[] children) {
for (int i = 0; i < children.length; i++) {
add(children[i]);
for (SimpleNode aChildren : children) {
add(aChildren);
}
return children;
@@ -164,7 +164,7 @@ public class FilteringTreeStructure extends AbstractTreeStructure {
}
protected SimpleNode[] buildChildren() {
return myChildren.toArray(new SimpleNode[myChildren.size()]);
return myChildren.isEmpty() ? NO_CHILDREN : myChildren.toArray(new SimpleNode[myChildren.size()]);
}
public Object[] getEqualityObjects() {
@@ -332,7 +332,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
public StreamProvider[] getStreamProviders(RoamingType type) {
synchronized (myStreamProviders) {
final Collection<StreamProvider> providers = myStreamProviders.get(type);
return providers.toArray(new StreamProvider[providers.size()]);
return providers.isEmpty() ? EMPTY_ARRAY : providers.toArray(new StreamProvider[providers.size()]);
}
}
@@ -450,7 +450,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentList
}
}
myCachedVisible = visible.toArray(new FoldRegion[visible.size()]);
myCachedVisible = visible.isEmpty() ? FoldRegion.EMPTY_ARRAY : visible.toArray(new FoldRegion[visible.size()]);
Arrays.sort(myCachedVisible, BY_END_OFFSET_REVERSE);
@@ -516,7 +516,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return ourEmptyShortcutsArray;
}
}
return shortcuts.toArray(new Shortcut[shortcuts.size()]);
return shortcuts.isEmpty() ? ourEmptyShortcutsArray : shortcuts.toArray(new Shortcut[shortcuts.size()]);
}
private KeymapManagerEx getKeymapManager() {
@@ -43,9 +43,9 @@ public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements
if (baseDirPath != null) {
SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T,E>(fileSpec, processor, roamingType,
((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProviders(roamingType),
new File(baseDirPath));
StreamProvider[] providers =
((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProviders(roamingType);
SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T,E>(fileSpec, processor, roamingType, providers, new File(baseDirPath));
myRegisteredManagers.add(manager);
return manager;
}
@@ -431,13 +431,12 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
protected SimpleNode[] buildChildren() {
ArrayList<SimpleNode> result = new ArrayList<SimpleNode>();
for (int i = 0; i < myGroups.size(); i++) {
ConfigurableGroup eachGroup = myGroups.get(i);
List<SimpleNode> result = new ArrayList<SimpleNode>();
for (ConfigurableGroup eachGroup : myGroups) {
result.addAll(buildGroup(eachGroup));
}
return result.toArray(new SimpleNode[result.size()]);
return result.isEmpty() ? NO_CHILDREN : result.toArray(new SimpleNode[result.size()]);
}
private List<EditorNode> buildGroup(final ConfigurableGroup eachGroup) {
@@ -458,7 +457,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
}
private boolean isInvisibleNode(final Configurable child) {
private static boolean isInvisibleNode(final Configurable child) {
return child instanceof SearchableConfigurable.Parent && !((SearchableConfigurable.Parent)child).isVisible();
}
@@ -495,8 +494,8 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
}
private static final EditorNode[] EMPTY_EN_ARRAY = new EditorNode[0];
class EditorNode extends Base {
Configurable myConfigurable;
ConfigurableGroup myGroup;
@@ -510,7 +509,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
protected EditorNode[] buildChildren() {
List<EditorNode> list = OptionsTree.this.buildChildren(myConfigurable, this, null);
return list.toArray(new EditorNode[list.size()]);
return list.isEmpty() ? EMPTY_EN_ARRAY : list.toArray(new EditorNode[list.size()]);
}
@Override
@@ -198,7 +198,7 @@ public class FilteringTreeBuilderTest extends BaseTreeTestCase {
}
protected SimpleNode[] buildChildren() {
return myKids.values().toArray(new Node[myKids.size()]);
return myKids.isEmpty() ? NO_CHILDREN : myKids.values().toArray(new Node[myKids.size()]);
}
@Override
@@ -100,6 +100,7 @@ superinterface.name=&Super interface name:
delegate.members=Delegate members
generate.getter.for.delegated.component=Generate &getter for delegated component
package.for.new.superclass=&Package for new superclass:
package.for.original.class=&Package for original class:
ExtractSuperClass.superclass=Superclass
members.to.form.superclass=Members to form superclass
no.superclass.name.specified=No superclass name specified
@@ -1,74 +0,0 @@
/*
* Copyright 2000-2009 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.util.containers;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CoModifiableList<T> extends AbstractList<T> {
private ArrayList<T> myAfterIteratingElements = null;
private final List<T> myElements;
public CoModifiableList(List<T> elements) {
myElements = elements;
}
public synchronized boolean add(T rangeMarker) {
if (myAfterIteratingElements != null) myAfterIteratingElements.add(rangeMarker);
else myElements.add(rangeMarker);
return true;
}
public synchronized T remove(int index) {
return myElements.remove(index);
}
public T get(int index) {
return myElements.get(index);
}
public int size() {
return myElements.size();
}
public void forEach(InnerIterator<T> innerIterator) {
if (myAfterIteratingElements != null) {
throw new RuntimeException("Nested iterations aren't supported");
}
try {
myAfterIteratingElements = new ArrayList<T>();
for (Iterator<T> iterator = myElements.iterator(); iterator.hasNext();) {
T rangeMarker = iterator.next();
if (rangeMarker == null) continue;
innerIterator.process(rangeMarker, iterator);
}
} finally {
synchronized(this) {
for (Iterator<T> iterator = myAfterIteratingElements.iterator(); iterator.hasNext();) {
T rangeMarker = iterator.next();
myElements.add(rangeMarker);
}
myAfterIteratingElements = null;
}
}
}
public interface InnerIterator<T> {
void process(T rangeMarker, Iterator<T> iterator);
}
}
@@ -24,7 +24,7 @@ import java.io.*;
class IoFile implements IFile {
private final File myFile;
private final IFile[] EMPTY_ARRAY = new IFile[0];
private static final IFile[] EMPTY_ARRAY = new IFile[0];
public IoFile(@NotNull final File file) {
myFile = file;
@@ -1,83 +0,0 @@
/*
* Copyright 2000-2009 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.util.containers;
import com.intellij.util.Assertion;
import com.intellij.openapi.util.text.StringUtil;
import java.util.ArrayList;
import java.util.Iterator;
public class CoModifiableListTest extends junit.framework.TestCase {
private final Assertion CHECK = new Assertion();
private final ArrayList mySourceList = new ArrayList();
private final com.intellij.util.containers.CoModifiableList myList = new com.intellij.util.containers.CoModifiableList(mySourceList);
public void testAdd() {
myList.add("1");
myList.add("2");
checkElements(new Object[]{"1", "2"});
}
public void testInnerIterator() {
mySourceList.add("a1");
mySourceList.add("b2");
mySourceList.add("a2");
myList.forEach(new CoModifiableList.InnerIterator() {
public void process(Object object, Iterator iterator) {
if (StringUtil.startsWithChar(object.toString(), 'b')) iterator.remove();
}
});
checkElements(new Object[]{"a1", "a2"});
}
public void testAddDuringItarating() {
myList.add("1");
myList.add("2");
final int[] count = new int[] { 0 };
myList.forEach(new CoModifiableList.InnerIterator() {
public void process(Object object, Iterator iterator) {
count[0]++;
myList.add("new" + object);
}
});
junit.framework.Assert.assertEquals(2, count[0]);
checkElements(new Object[]{"1", "2", "new1", "new2"});
}
public void testRemoveDuringItarating() {
myList.add("1");
myList.add("2");
final int[] count = new int[] { 0 };
myList.forEach(new CoModifiableList.InnerIterator() {
public void process(Object object, Iterator iterator) {
count[0]++;
if (object.equals("2")) {
iterator.remove();
}
}
});
junit.framework.Assert.assertEquals(2, count[0]);
checkElements(new Object[]{"1"});
}
private void checkElements(Object[] expected) {
CHECK.compareAll(expected, mySourceList);
CHECK.compareAll(expected, myList);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,15 +16,33 @@
package org.jetbrains.idea.eclipse.config;
import com.intellij.openapi.components.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleServiceManager;
import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class EclipseModuleManager {
@State(
name = "EclipseModuleManager",
storages = {
@Storage(
id = "default",
file = "$MODULE_FILE$"
)
}
)
public class EclipseModuleManager implements PersistentStateComponent<Element>{
@NonNls private static final String VALUE_ATTR = "value";
@NonNls private static final String VARELEMENT = "varelement";
@NonNls private static final String VAR_ATTRIBUTE = "var";
@NonNls private static final String CONELEMENT = "conelement";
@NonNls private static final String FORCED_JDK = "forced_jdk";
private CachedXmlDocumentSet myDocumentSet;
private final Map<String, String> myEclipseVariablePaths = new HashMap<String, String>();
private final Set<String> myEclipseUrls = new HashSet<String>();
@@ -32,8 +50,12 @@ public class EclipseModuleManager {
private boolean myForceConfigureJDK = false;
private static final String SRC_PREFIX = "src:";
private static final String SRC_LINK_PREFIX = "linksrc:";
private final Module myModule;
@NonNls private static final String LIBELEMENT = "libelement";
public EclipseModuleManager(Module module) {}
public EclipseModuleManager(Module module) {
myModule = module;
}
public static EclipseModuleManager getInstance(Module module) {
return ModuleServiceManager.getService(module, EclipseModuleManager.class);
@@ -94,4 +116,51 @@ public class EclipseModuleManager {
public boolean isEclipseLibUrl(String url) {
return myEclipseUrls.contains(url);
}
public Element getState() {
if (ClasspathStorage.getStorageType(myModule) != EclipseClasspathStorageProvider.ID) {
if (!myEclipseUrls.isEmpty() || !myEclipseVariablePaths.isEmpty() || myForceConfigureJDK || !myUnknownCons.isEmpty()) {
Element root = new Element("EclipseModuleSettings");
for (String eclipseUrl : myEclipseUrls) {
final Element libElement = new Element(LIBELEMENT);
libElement.setAttribute(VALUE_ATTR, eclipseUrl);
root.addContent(libElement);
}
for (String var : myEclipseVariablePaths.keySet()) {
Element varElement = new Element(VARELEMENT);
varElement.setAttribute(VAR_ATTRIBUTE, var);
varElement.setAttribute(VALUE_ATTR, myEclipseVariablePaths.get(var));
root.addContent(varElement);
}
for (String unknownCon : myUnknownCons) {
Element conElement = new Element(CONELEMENT);
conElement.setAttribute(VALUE_ATTR, unknownCon);
root.addContent(conElement);
}
if (myForceConfigureJDK) {
root.setAttribute(FORCED_JDK, String.valueOf(true));
}
return root;
}
}
return null;
}
public void loadState(Element state) {
for (Object o : state.getChildren(LIBELEMENT)) {
myEclipseUrls.add(((Element)o).getAttributeValue(VALUE_ATTR));
}
for (Object o : state.getChildren(VARELEMENT)) {
myEclipseVariablePaths.put(((Element)o).getAttributeValue(VAR_ATTRIBUTE), ((Element)o).getAttributeValue(VALUE_ATTR));
}
for (Object o : state.getChildren(CONELEMENT)) {
myUnknownCons.add(((Element)o).getAttributeValue(VALUE_ATTR));
}
final String forcedJdk = state.getAttributeValue(FORCED_JDK);
myForceConfigureJDK = forcedJdk != null && Boolean.parseBoolean(forcedJdk);
}
}
@@ -24,16 +24,16 @@ import java.lang.reflect.InvocationTargetException;
public class HgExecutableValidator {
private static final Logger LOG = Logger.getInstance(HgExecutableValidator.class.getName());
private final Project project;
private final Project myProject;
private boolean myValidHgExecutable;
public HgExecutableValidator(Project project) {
this.project = project;
this.myProject = project;
}
public boolean check(final HgGlobalSettings globalSettings) {
final HgVersionCommand command = new HgVersionCommand();
if (command.isValid(globalSettings.getHgExecutable())) {
if (command.isValid(HgVcs.getInstance(myProject).getHgExecutable())) {
return true;
}
@@ -48,7 +48,7 @@ public class HgExecutableValidator {
String previousHgPath = globalSettings.getHgExecutable();
HgSetExecutableDialog dialog;
do {
dialog = new HgSetExecutableDialog(project);
dialog = new HgSetExecutableDialog(myProject);
dialog.setBadHgPath(previousHgPath);
dialog.show();
myValidHgExecutable = dialog.isOK() && command.isValid(dialog.getNewHgPath());
@@ -90,7 +90,7 @@ public abstract class HgUtil {
}
/**
* Runs the given task as a write action in the event dispatching thread.
* Runs the given task as a write action in the event dispatching thread and waits for its completion.
*/
public static void runWriteActionAndWait(@NotNull final Runnable runnable) throws InvocationTargetException, InterruptedException {
GuiUtils.runOrInvokeAndWait(new Runnable() {
@@ -100,6 +100,17 @@ public abstract class HgUtil {
});
}
/**
* Schedules the given task to be run as a write action in the event dispatching thread.
*/
public static void runWriteActionLater(@NotNull final Runnable runnable) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(runnable);
}
});
}
/**
* Returns a temporary python file that will be deleted on exit.
*
+22 -18
View File
@@ -17,6 +17,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
@@ -38,7 +39,6 @@ import com.intellij.openapi.vfs.VirtualFileListener;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.messages.Topic;
import org.zmlx.hg4idea.provider.*;
@@ -75,6 +75,8 @@ public class HgVcs extends AbstractVcs {
public static final String NOTIFICATION_GROUP_ID = "Mercurial";
public static final String HG_EXECUTABLE_FILE_NAME = (SystemInfo.isWindows ? "hg.exe" : "hg");
private static final String ORIG_FILE_PATTERN = "*.orig";
private final HgChangeProvider changeProvider;
private final HgProjectConfigurable configurable;
private final HgRollbackEnvironment rollbackEnvironment;
@@ -225,17 +227,18 @@ public class HgVcs extends AbstractVcs {
@Override
public void activate() {
// validate hg executable
if (ApplicationManager.getApplication().isUnitTestMode()) {
started = true;
} else {
HgExecutableValidator validator = new HgExecutableValidator(myProject);
started = validator.check(globalSettings);
}
if (!started) {
return;
}
// status bar
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
if (statusBar != null) {
statusBar.addWidget(hgCurrentBranchStatus, myProject);
@@ -243,30 +246,21 @@ public class HgVcs extends AbstractVcs {
statusBar.addWidget(outgoingChangesStatus, myProject);
}
final HgIncomingStatusUpdater incomingUpdater =
new HgIncomingStatusUpdater(incomingChangesStatus, projectSettings);
final HgOutgoingStatusUpdater outgoingUpdater =
new HgOutgoingStatusUpdater(outgoingChangesStatus, projectSettings);
// updaters and listeners
final HgIncomingStatusUpdater incomingUpdater = new HgIncomingStatusUpdater(incomingChangesStatus, projectSettings);
final HgOutgoingStatusUpdater outgoingUpdater = new HgOutgoingStatusUpdater(outgoingChangesStatus, projectSettings);
changesUpdaterScheduledFuture = JobScheduler.getScheduler().scheduleWithFixedDelay(
new Runnable() {
public void run() {
incomingUpdater.update(myProject);
outgoingUpdater.update(myProject);
}
}, 0, globalSettings.getIncomingCheckIntervalSeconds(), TimeUnit.SECONDS);
MessageBus messageBus = myProject.getMessageBus();
messageBusConnection = messageBus.connect();
}, 0, HgGlobalSettings.getIncomingCheckIntervalSeconds(), TimeUnit.SECONDS);
messageBusConnection = myProject.getMessageBus().connect();
messageBusConnection.subscribe(INCOMING_TOPIC, incomingUpdater);
messageBusConnection.subscribe(OUTGOING_TOPIC, outgoingUpdater);
messageBusConnection.subscribe(
BRANCH_TOPIC, new HgCurrentBranchStatusUpdater(hgCurrentBranchStatus)
);
messageBusConnection.subscribe(BRANCH_TOPIC, new HgCurrentBranchStatusUpdater(hgCurrentBranchStatus));
messageBusConnection.subscribe(
FileEditorManagerListener.FILE_EDITOR_MANAGER,
new FileEditorManagerAdapter() {
@@ -281,8 +275,18 @@ public class HgVcs extends AbstractVcs {
);
myVFSListener = new HgVFSListener(myProject, this);
VirtualFileManager.getInstance().addVirtualFileListener(myDirStateChangeListener);
// ignore temporary files
final String ignoredPattern = FileTypeManager.getInstance().getIgnoredFilesList();
if (!ignoredPattern.contains(ORIG_FILE_PATTERN)) {
final String newPattern = ignoredPattern + (ignoredPattern.endsWith(";") ? "" : ";") + ORIG_FILE_PATTERN;
HgUtil.runWriteActionLater(new Runnable() {
public void run() {
FileTypeManager.getInstance().setIgnoredFilesList(newPattern);
}
});
}
}
@Override
@@ -12,16 +12,9 @@
// limitations under the License.
package org.zmlx.hg4idea.ui;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.zmlx.hg4idea.HgProjectSettings;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Insets;
import javax.swing.*;
public class HgConfigurationProjectPanel {
@@ -54,49 +47,4 @@ public class HgConfigurationProjectPanel {
return panel;
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
panel = new JPanel();
panel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
final Spacer spacer1 = new Spacer();
panel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
panel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Changesets"));
checkIncomingCbx = new JCheckBox();
checkIncomingCbx.setSelected(true);
checkIncomingCbx.setText("Check for incoming changesets");
checkIncomingCbx.setMnemonic('I');
checkIncomingCbx.setDisplayedMnemonicIndex(10);
panel1.add(checkIncomingCbx, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
panel1.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
checkOutgoingCbx = new JCheckBox();
checkOutgoingCbx.setSelected(true);
checkOutgoingCbx.setText("Check for outgoing changesets");
checkOutgoingCbx.setMnemonic('O');
checkOutgoingCbx.setDisplayedMnemonicIndex(10);
panel1.add(checkOutgoingCbx, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return panel;
}
}
@@ -14,13 +14,9 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import org.apache.commons.lang.StringUtils;
import javax.swing.*;
import java.awt.*;
public class HgGlobalStatusDialog extends DialogWrapper {
private JPanel contentPanel;
@@ -46,34 +42,4 @@ public class HgGlobalStatusDialog extends DialogWrapper {
return contentPanel;
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPanel = new JPanel();
contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
final JScrollPane scrollPane1 = ScrollPaneFactory.createScrollPane();
contentPanel.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(300, 350), null, null, 0, false));
outputTextArea = new JTextArea();
outputTextArea.setEditable(false);
scrollPane1.setViewportView(outputTextArea);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPanel;
}
}
@@ -15,24 +15,14 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.apache.commons.lang.StringUtils;
import org.zmlx.hg4idea.command.HgShowConfigCommand;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
@@ -127,61 +117,4 @@ public class HgPushDialog extends DialogWrapper {
&& !(revisionCbx.isSelected() && StringUtils.isBlank(revisionTxt.getText()));
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPanel = new JPanel();
contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Destination Repository URL:");
label1.setDisplayedMnemonic('D');
label1.setDisplayedMnemonicIndex(0);
panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
repositoryTxt = new JTextField();
panel1.add(repositoryTxt, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
panel1.add(panel2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(-1, 100), null, null, 0, false));
panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options"));
revisionCbx = new JCheckBox();
revisionCbx.setText("Revision");
revisionCbx.setMnemonic('R');
revisionCbx.setDisplayedMnemonicIndex(0);
panel2.add(revisionCbx, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
revisionTxt = new JTextField();
revisionTxt.setEnabled(false);
revisionTxt.setText("tip");
panel2.add(revisionTxt, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final Spacer spacer2 = new Spacer();
panel2.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer3 = new Spacer();
panel2.add(spacer3, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
hgRepositorySelectorComponent = new HgRepositorySelectorComponent();
panel1.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
label1.setLabelFor(repositoryTxt);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPanel;
}
}
@@ -15,21 +15,11 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.components.JBList;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.zmlx.hg4idea.HgFile;
import org.zmlx.hg4idea.command.HgResolveCommand;
import org.zmlx.hg4idea.command.HgResolveStatusEnum;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
@@ -85,39 +75,4 @@ public class HgRunConflictResolverDialog extends DialogWrapper {
conflictsList.setModel(model);
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
repositorySelector = new HgRepositorySelectorComponent();
mainPanel.add(repositorySelector.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.setBorder(BorderFactory.createTitledBorder("Files with conflicts:"));
conflictsList = new JBList();
panel1.add(conflictsList, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 150), null, 0, false));
final Spacer spacer1 = new Spacer();
mainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return mainPanel;
}
}
@@ -10,7 +10,7 @@
<children>
<component id="2e454" class="org.zmlx.hg4idea.ui.HgSetExecutablePathPanel" binding="myHgExecutablePath" custom-create="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="9" fill="0" indent="0" use-parent-layout="false">
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
@@ -15,25 +15,12 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.zmlx.hg4idea.command.HgTagBranch;
import org.zmlx.hg4idea.command.HgTagBranchCommand;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
@@ -145,77 +132,4 @@ public class HgSwitchDialog extends DialogWrapper {
return contentPanel;
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPanel = new JPanel();
contentPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1));
final Spacer spacer1 = new Spacer();
contentPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPanel.add(spacer2, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
cleanCbx = new JCheckBox();
cleanCbx.setText("Overwrite locally modified files (no backup)");
cleanCbx.setMnemonic('O');
cleanCbx.setDisplayedMnemonicIndex(0);
contentPanel.add(cleanCbx, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.setBorder(BorderFactory.createTitledBorder("Switch to:"));
branchOption = new JRadioButton();
branchOption.setSelected(true);
branchOption.setText("Branch");
branchOption.setMnemonic('B');
branchOption.setDisplayedMnemonicIndex(0);
panel1.add(branchOption, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
branchSelector = new JComboBox();
branchSelector.setEnabled(true);
final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
branchSelector.setModel(defaultComboBoxModel1);
panel1.add(branchSelector, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
revisionOption = new JRadioButton();
revisionOption.setSelected(false);
revisionOption.setText("Revision");
revisionOption.setMnemonic('R');
revisionOption.setDisplayedMnemonicIndex(0);
panel1.add(revisionOption, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
revisionTxt = new JTextField();
revisionTxt.setEnabled(false);
revisionTxt.setText("");
panel1.add(revisionTxt, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
tagOption = new JRadioButton();
tagOption.setText("Tag");
tagOption.setMnemonic('T');
tagOption.setDisplayedMnemonicIndex(0);
panel1.add(tagOption, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
tagSelector = new JComboBox();
panel1.add(tagSelector, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
hgRepositorySelectorComponent = new HgRepositorySelectorComponent();
contentPanel.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
ButtonGroup buttonGroup;
buttonGroup = new ButtonGroup();
buttonGroup.add(revisionOption);
buttonGroup.add(branchOption);
buttonGroup.add(tagOption);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPanel;
}
}
@@ -15,19 +15,11 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.apache.commons.lang.StringUtils;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.Dimension;
import java.awt.Insets;
import java.util.Collection;
public class HgTagDialog extends DialogWrapper {
@@ -84,43 +76,4 @@ public class HgTagDialog extends DialogWrapper {
return StringUtils.isNotBlank(tagTxt.getText());
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPanel = new JPanel();
contentPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
final Spacer spacer1 = new Spacer();
contentPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
hgRepositorySelectorComponent = new HgRepositorySelectorComponent();
contentPanel.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Tag name:");
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
tagTxt = new JTextField();
panel1.add(tagTxt, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPanel;
}
}
@@ -12,13 +12,9 @@
// limitations under the License.
package org.zmlx.hg4idea.ui;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.zmlx.hg4idea.provider.update.HgUpdater;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -67,57 +63,4 @@ public class HgUpdateDialog {
commitAfterMergeCheckBox.setSelected(updateConfiguration.shouldCommitAfterMerge());
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1));
pullCheckBox = new JCheckBox();
pullCheckBox.setText("pull");
pullCheckBox.setMnemonic('P');
pullCheckBox.setDisplayedMnemonicIndex(0);
pullCheckBox.setToolTipText("pull from the default remote repository");
contentPane.add(pullCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
updateCheckBox = new JCheckBox();
updateCheckBox.setText("update");
updateCheckBox.setMnemonic('U');
updateCheckBox.setDisplayedMnemonicIndex(0);
updateCheckBox.setToolTipText("update to the head of the current branch");
contentPane.add(updateCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
mergeCheckBox = new JCheckBox();
mergeCheckBox.setText("merge");
mergeCheckBox.setMnemonic('M');
mergeCheckBox.setDisplayedMnemonicIndex(0);
mergeCheckBox.setToolTipText("merge if pulling resulted in extra heads");
contentPane.add(mergeCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
commitAfterMergeCheckBox = new JCheckBox();
commitAfterMergeCheckBox.setText("commit after merge without conflicts");
commitAfterMergeCheckBox.setMnemonic('C');
commitAfterMergeCheckBox.setDisplayedMnemonicIndex(0);
commitAfterMergeCheckBox.setToolTipText("commit automatically after the merge");
contentPane.add(commitAfterMergeCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}
@@ -14,17 +14,8 @@ package org.zmlx.hg4idea.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.Spacer;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Insets;
import java.awt.Dimension;
import javax.swing.*;
public class HgUsernamePasswordDialog extends DialogWrapper {
private JPanel basePanel;
@@ -53,48 +44,4 @@ public class HgUsernamePasswordDialog extends DialogWrapper {
return basePanel;
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
basePanel = new JPanel();
basePanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
final JLabel label1 = new JLabel();
label1.setText("Username");
label1.setDisplayedMnemonic('U');
label1.setDisplayedMnemonicIndex(0);
basePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
usernameTxt = new JTextField();
basePanel.add(usernameTxt, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Password");
label2.setDisplayedMnemonic('P');
label2.setDisplayedMnemonicIndex(0);
basePanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
basePanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
passwordTxt = new JPasswordField();
passwordTxt.setText("");
basePanel.add(passwordTxt, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
label1.setLabelFor(usernameTxt);
label2.setLabelFor(passwordTxt);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return basePanel;
}
}
@@ -361,7 +361,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
private void setPackage(final PsiPackage aPackage) {
if (aPackage == null) return;
((LabeledComponent<TextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.ALL_IN_PACKAGE).getComponent()).setText(aPackage.getQualifiedName());
((LabeledComponent<TextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.ALL_IN_PACKAGE)).getComponent().setText(aPackage.getQualifiedName());
}
@NotNull
@@ -55,7 +55,7 @@ public class XmlTagValueImpl implements XmlTagValue{
for (final XmlTagChild element : myElements) {
if (element instanceof XmlText) textElementsList.add((XmlText)element);
}
return myTextElements = ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]);
return myTextElements = textElementsList.isEmpty() ? XmlText.EMPTY_ARRAY : ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]);
}
@NotNull
@@ -36,4 +36,5 @@ public interface XmlText extends XmlTagChild {
@Nullable
XmlText split(int displayIndex);
XmlText[] EMPTY_ARRAY = new XmlText[0];
}