mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
-1
@@ -19,18 +19,20 @@ package com.intellij.openapi.compiler.util;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.InspectionToolProvider;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -86,4 +88,8 @@ public abstract class InspectionValidator {
|
||||
return CompilerMessageCategory.INFORMATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<ProblemDescriptor, HighlightDisplayLevel> checkAdditionally(PsiFile file) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi
|
||||
}
|
||||
|
||||
protected final boolean isUpdateEnabled() {
|
||||
return myUpdateEnabled;
|
||||
return myUpdateEnabled || isShowing();
|
||||
}
|
||||
|
||||
public final void setUpdateEnabled(final boolean enabled) {
|
||||
|
||||
@@ -142,6 +142,7 @@ public class NewProjectUtil {
|
||||
|
||||
if (projectBuilder != null) {
|
||||
projectBuilder.commit(newProject, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
|
||||
newProject.save();
|
||||
}
|
||||
|
||||
final boolean need2OpenProjectStructure = projectBuilder == null || projectBuilder.isOpenProjectSettingsAfter();
|
||||
|
||||
+1
@@ -73,6 +73,7 @@ public class NewModuleAction extends AnAction implements DumbAware {
|
||||
ModulesConfigurator.showDialog(project, null, null);
|
||||
}
|
||||
}
|
||||
project.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -903,9 +903,12 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
|
||||
if (pkgContext) {
|
||||
PsiFile classFile = psiClass.getContainingFile();
|
||||
if (classFile instanceof PsiClassOwner && StringUtil.isEmpty(((PsiClassOwner)classFile).getPackageName())) {
|
||||
return false;
|
||||
PsiClass topLevel = PsiUtil.getTopLevelClass(psiClass);
|
||||
if (topLevel != null) {
|
||||
String fqName = topLevel.getQualifiedName();
|
||||
if (fqName != null && StringUtil.isEmpty(StringUtil.getPackageName(fqName))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -579,8 +579,8 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
@Nullable
|
||||
public static PsiClass getTopLevelClass(@NotNull PsiElement element) {
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file instanceof PsiJavaFile) {
|
||||
final PsiClass[] classes = ((PsiJavaFile)file).getClasses();
|
||||
if (file instanceof PsiClassOwner) {
|
||||
final PsiClass[] classes = ((PsiClassOwner)file).getClasses();
|
||||
for (PsiClass aClass : classes) {
|
||||
if (PsiTreeUtil.isAncestor(aClass, element, false)) return aClass;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ProjectScope {
|
||||
|
||||
@NotNull
|
||||
public static GlobalSearchScope getContentScope(@NotNull Project project) {
|
||||
GlobalSearchScope cached = project.getUserData(LIBRARIES_SCOPE_KEY);
|
||||
GlobalSearchScope cached = project.getUserData(CONTENT_SCOPE_KEY);
|
||||
return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(CONTENT_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildContentScope());
|
||||
}
|
||||
}
|
||||
|
||||
+43
-35
@@ -23,16 +23,21 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpleInspectionTool {
|
||||
private final boolean highlightErrorElements;
|
||||
private final boolean runAnnotators;
|
||||
@@ -85,13 +90,43 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkFile(@NotNull PsiFile file,
|
||||
@NotNull InspectionManager manager,
|
||||
public void checkFile(@NotNull PsiFile originalFile,
|
||||
@NotNull final InspectionManager manager,
|
||||
@NotNull ProblemsHolder problemsHolder,
|
||||
@NotNull GlobalInspectionContext globalContext,
|
||||
@NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
|
||||
PsiElementVisitor visitor = new MyPsiElementVisitor(manager, globalContext, problemDescriptionsProcessor, highlightErrorElements,runAnnotators);
|
||||
@NotNull final GlobalInspectionContext globalContext,
|
||||
@NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
|
||||
for (Pair<PsiFile, HighlightInfo> pair : runGeneralHighlighting(originalFile, highlightErrorElements, runAnnotators)) {
|
||||
PsiFile file = pair.first;
|
||||
HighlightInfo info = pair.second;
|
||||
TextRange range = new TextRange(info.startOffset, info.endOffset);
|
||||
PsiElement element = file.findElementAt(info.startOffset);
|
||||
|
||||
while (element != null && !element.getTextRange().contains(range)) {
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
if (element == null) {
|
||||
element = file;
|
||||
}
|
||||
GlobalInspectionUtil.createProblem(
|
||||
element,
|
||||
info.description,
|
||||
HighlightInfo.convertType(info.type),
|
||||
range.shiftRight(-element.getNode().getStartOffset()),
|
||||
manager,
|
||||
problemDescriptionsProcessor,
|
||||
globalContext
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Pair<PsiFile,HighlightInfo>> runGeneralHighlighting(PsiFile file,
|
||||
final boolean highlightErrorElements,
|
||||
final boolean runAnnotators) {
|
||||
MyPsiElementVisitor visitor = new MyPsiElementVisitor(highlightErrorElements, runAnnotators);
|
||||
file.accept(visitor);
|
||||
return new ArrayList<Pair<PsiFile, HighlightInfo>>(visitor.result);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@@ -102,20 +137,11 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl
|
||||
}
|
||||
|
||||
private static class MyPsiElementVisitor extends PsiElementVisitor {
|
||||
private final InspectionManager myManager;
|
||||
private final GlobalInspectionContext myGlobalContext;
|
||||
private final ProblemDescriptionsProcessor myProblemDescriptionsProcessor;
|
||||
private final boolean highlightErrorElements;
|
||||
private final boolean runAnnotators;
|
||||
final List<Pair<PsiFile,HighlightInfo>> result = ContainerUtil.createEmptyCOWList();
|
||||
|
||||
public MyPsiElementVisitor(final InspectionManager manager,
|
||||
final GlobalInspectionContext globalContext,
|
||||
final ProblemDescriptionsProcessor problemDescriptionsProcessor,
|
||||
boolean highlightErrorElements,
|
||||
boolean runAnnotators) {
|
||||
myManager = manager;
|
||||
myGlobalContext = globalContext;
|
||||
myProblemDescriptionsProcessor = problemDescriptionsProcessor;
|
||||
public MyPsiElementVisitor(boolean highlightErrorElements, boolean runAnnotators) {
|
||||
this.highlightErrorElements = highlightErrorElements;
|
||||
this.runAnnotators = runAnnotators;
|
||||
}
|
||||
@@ -147,27 +173,9 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl
|
||||
if (info == null) return true;
|
||||
if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) return true;
|
||||
if (info.severity == HighlightSeverity.INFORMATION) return true;
|
||||
ProblemHighlightType problemHighlightType = HighlightInfo.convertType(info.type);
|
||||
TextRange range = new TextRange(info.startOffset, info.endOffset);
|
||||
PsiElement element = file.findElementAt(info.startOffset);
|
||||
|
||||
while (element != null && !element.getTextRange().contains(range)) {
|
||||
element = element.getParent();
|
||||
}
|
||||
result.add(Pair.create(file, info));
|
||||
|
||||
if (element == null) {
|
||||
element = file;
|
||||
}
|
||||
|
||||
GlobalInspectionUtil.createProblem(
|
||||
element,
|
||||
info.description,
|
||||
problemHighlightType,
|
||||
range.shiftRight(-element.getNode().getStartOffset()),
|
||||
myManager,
|
||||
myProblemDescriptionsProcessor,
|
||||
myGlobalContext
|
||||
);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
+23
-13
@@ -63,17 +63,8 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority
|
||||
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.preparePsiElementForWrite(file)) return;
|
||||
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManagerEx.getInstance(project);
|
||||
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
|
||||
final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(myTool);
|
||||
tool.initialize(context);
|
||||
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
|
||||
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() {
|
||||
public void run() {
|
||||
tool.processFile(file, true, managerEx, true);
|
||||
}
|
||||
}, new EmptyProgressIndicator());
|
||||
final List<CommonProblemDescriptor> descriptions = new ArrayList<CommonProblemDescriptor>(tool.getProblemDescriptors());
|
||||
final List<CommonProblemDescriptor> descriptions = runInspectionOnFile(file, myTool);
|
||||
|
||||
Collections.sort(descriptions, new Comparator<CommonProblemDescriptor>() {
|
||||
public int compare(final CommonProblemDescriptor o1, final CommonProblemDescriptor o2) {
|
||||
final ProblemDescriptorImpl d1 = (ProblemDescriptorImpl)o1;
|
||||
@@ -95,8 +86,27 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority
|
||||
}
|
||||
}
|
||||
}
|
||||
((RefManagerImpl)context.getRefManager()).inspectionReadActionFinished();
|
||||
context.cleanup(managerEx);
|
||||
}
|
||||
|
||||
public static List<CommonProblemDescriptor> runInspectionOnFile(final PsiFile file,
|
||||
final LocalInspectionTool inspectionTool) {
|
||||
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(file.getProject());
|
||||
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
|
||||
final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(inspectionTool);
|
||||
tool.initialize(context);
|
||||
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
|
||||
try {
|
||||
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() {
|
||||
public void run() {
|
||||
tool.processFile(file, true, managerEx, true);
|
||||
}
|
||||
}, new EmptyProgressIndicator());
|
||||
return new ArrayList<CommonProblemDescriptor>(tool.getProblemDescriptors());
|
||||
}
|
||||
finally {
|
||||
((RefManagerImpl)context.getRefManager()).inspectionReadActionFinished();
|
||||
context.cleanup(managerEx);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
|
||||
|
||||
+54
-39
@@ -48,6 +48,7 @@ import java.util.*;
|
||||
* @author max
|
||||
*/
|
||||
public abstract class DescriptorProviderInspection extends InspectionTool implements ProblemDescriptionsProcessor {
|
||||
private static final Object lock = new Object();
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> myProblemElements;
|
||||
private HashMap<String, Set<RefEntity>> myContents = null;
|
||||
private HashSet<RefModule> myModulesProblems = null;
|
||||
@@ -68,14 +69,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
if (descriptions == null || descriptions.length == 0) return;
|
||||
if (filterSuppressed) {
|
||||
if (ourOutputPath == null || !(this instanceof LocalInspectionToolWrapper)) {
|
||||
CommonProblemDescriptor[] problems = getProblemElements().get(refElement);
|
||||
if (problems == null) {
|
||||
problems = descriptions;
|
||||
synchronized (lock) {
|
||||
Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements();
|
||||
CommonProblemDescriptor[] problems = problemElements.get(refElement);
|
||||
problems = problems == null ? descriptions : ArrayUtil.mergeArrays(problems, descriptions);
|
||||
problemElements.put(refElement, problems);
|
||||
}
|
||||
else {
|
||||
problems = ArrayUtil.mergeArrays(problems, descriptions);
|
||||
}
|
||||
getProblemElements().put(refElement, problems);
|
||||
for (CommonProblemDescriptor description : descriptions) {
|
||||
getProblemToElements().put(description, refElement);
|
||||
collectQuickFixes(description.getFixes(), refElement);
|
||||
@@ -164,19 +163,22 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
final QuickFix[] fixes = problem.getFixes();
|
||||
if (isIgnoreProblem(fixes, localQuickFixes, idx)){
|
||||
getProblemToElements().remove(problem);
|
||||
CommonProblemDescriptor[] descriptors = getProblemElements().get(refEntity);
|
||||
if (descriptors != null) {
|
||||
ArrayList<CommonProblemDescriptor> newDescriptors = new ArrayList<CommonProblemDescriptor>(Arrays.asList(descriptors));
|
||||
newDescriptors.remove(problem);
|
||||
getQuickFixActions().put(refEntity, null);
|
||||
if (!newDescriptors.isEmpty()) {
|
||||
getProblemElements().put(refEntity, newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()]));
|
||||
for (CommonProblemDescriptor descriptor : newDescriptors) {
|
||||
collectQuickFixes(descriptor.getFixes(), refEntity);
|
||||
Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements();
|
||||
synchronized (lock) {
|
||||
CommonProblemDescriptor[] descriptors = problemElements.get(refEntity);
|
||||
if (descriptors != null) {
|
||||
ArrayList<CommonProblemDescriptor> newDescriptors = new ArrayList<CommonProblemDescriptor>(Arrays.asList(descriptors));
|
||||
newDescriptors.remove(problem);
|
||||
getQuickFixActions().put(refEntity, null);
|
||||
if (!newDescriptors.isEmpty()) {
|
||||
problemElements.put(refEntity, newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()]));
|
||||
for (CommonProblemDescriptor descriptor : newDescriptors) {
|
||||
collectQuickFixes(descriptor.getFixes(), refEntity);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ignoreProblemElement(refEntity);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ignoreProblemElement(refEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,10 +226,13 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
myOldProblemElements = null;
|
||||
}
|
||||
|
||||
myProblemElements = null;
|
||||
myProblemToElements = null;
|
||||
myQuickFixActions = null;
|
||||
myIgnoredElements = null;
|
||||
synchronized (lock) {
|
||||
myProblemElements = null;
|
||||
myProblemToElements = null;
|
||||
myQuickFixActions = null;
|
||||
myIgnoredElements = null;
|
||||
}
|
||||
|
||||
myContents = null;
|
||||
myModulesProblems = null;
|
||||
}
|
||||
@@ -261,10 +266,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
public void exportResults(@NotNull final Element parentNode) {
|
||||
getRefManager().iterate(new RefVisitor() {
|
||||
@Override public void visitElement(final RefEntity refEntity) {
|
||||
if (getProblemElements().containsKey(refEntity)) {
|
||||
CommonProblemDescriptor[] descriptions = getDescriptions(refEntity);
|
||||
if (descriptions != null) {
|
||||
exportResults(descriptions, refEntity, parentNode);
|
||||
synchronized (lock) {
|
||||
if (getProblemElements().containsKey(refEntity)) {
|
||||
CommonProblemDescriptor[] descriptions = getDescriptions(refEntity);
|
||||
if (descriptions != null) {
|
||||
exportResults(descriptions, refEntity, parentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,10 +531,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
}
|
||||
|
||||
public Map<RefEntity, CommonProblemDescriptor[]> getProblemElements() {
|
||||
if (myProblemElements == null) {
|
||||
myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
synchronized (lock) {
|
||||
if (myProblemElements == null) {
|
||||
myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
}
|
||||
return myProblemElements;
|
||||
}
|
||||
return myProblemElements;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -536,23 +545,29 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
}
|
||||
|
||||
private Map<CommonProblemDescriptor, RefEntity> getProblemToElements() {
|
||||
if (myProblemToElements == null) {
|
||||
myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>());
|
||||
synchronized (lock) {
|
||||
if (myProblemToElements == null) {
|
||||
myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>());
|
||||
}
|
||||
return myProblemToElements;
|
||||
}
|
||||
return myProblemToElements;
|
||||
}
|
||||
|
||||
private Map<RefEntity, Set<QuickFix>> getQuickFixActions() {
|
||||
if (myQuickFixActions == null) {
|
||||
myQuickFixActions = Collections.synchronizedMap(new HashMap<RefEntity, Set<QuickFix>>());
|
||||
synchronized (lock) {
|
||||
if (myQuickFixActions == null) {
|
||||
myQuickFixActions = Collections.synchronizedMap(new HashMap<RefEntity, Set<QuickFix>>());
|
||||
}
|
||||
return myQuickFixActions;
|
||||
}
|
||||
return myQuickFixActions;
|
||||
}
|
||||
|
||||
private Map<RefEntity, CommonProblemDescriptor[]> getIgnoredElements() {
|
||||
if (myIgnoredElements == null) {
|
||||
myIgnoredElements = Collections.synchronizedMap(new HashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
synchronized (lock) {
|
||||
if (myIgnoredElements == null) {
|
||||
myIgnoredElements = Collections.synchronizedMap(new HashMap<RefEntity, CommonProblemDescriptor[]>());
|
||||
}
|
||||
return myIgnoredElements;
|
||||
}
|
||||
return myIgnoredElements;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
@@ -111,7 +110,6 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
};
|
||||
|
||||
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
|
||||
private final FileTypeManager myFtManager = FileTypeManager.getInstance();
|
||||
@Override
|
||||
public boolean acceptInput(final VirtualFile file) {
|
||||
if (!(file.getFileSystem() instanceof LocalFileSystem)) {
|
||||
|
||||
@@ -22,6 +22,10 @@ public class ExecutionException extends Exception {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public ExecutionException(final Throwable cause) {
|
||||
super(cause == null ? null : cause.getMessage(), cause);
|
||||
}
|
||||
|
||||
public ExecutionException(final String s, Throwable cause) {
|
||||
super(s, cause);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ log.monitor.is.skipped.column=Skip Content
|
||||
log.monitor.edit.aliases.title=Edit Log Files Aliases
|
||||
log.monitor.edit.aliases.name=&Alias:
|
||||
log.monitor.edit.aliases.location=&Log File Location:
|
||||
log.monitor.edit.aliases.show.all.checkbox.title=&Show All Files Coverable By Pattern
|
||||
log.monitor.edit.aliases.show.all.checkbox.title=&Show all files coverable by pattern
|
||||
log.console.filter.show.errors=errors
|
||||
log.console.filter.show.errors.and.warnings=warnings
|
||||
log.console.filter.show.all=all
|
||||
|
||||
@@ -163,7 +163,7 @@ module.add.error.title=Add Module
|
||||
module.add.action=Add
|
||||
module.remove.action=Remove
|
||||
module.remove.last.confirmation=Are you sure you want to remove the only module from this project?\nNo files will be deleted on disk.
|
||||
module.remove.confirmation=Remove module \"{0}\" from the project?\nNo files will be deleted on disk.
|
||||
module.remove.confirmation=Remove module ''{0}'' from the project?\nNo files will be deleted on disk.
|
||||
module.remove.confirmation.title=Remove Module
|
||||
module.classpath.button.edit=Ed&it...
|
||||
module.libraries.include.all.button=Include All
|
||||
|
||||
@@ -479,7 +479,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
|
||||
public static <T> T assertInstanceOf(Object o, Class<T> aClass) {
|
||||
Assert.assertNotNull(o);
|
||||
Assert.assertTrue(o.getClass().getName(), aClass.isInstance(o));
|
||||
Assert.assertTrue("Expected instance of: " + aClass.getName() + " actual: " + o.getClass().getName(), aClass.isInstance(o));
|
||||
return (T)o;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,12 +105,23 @@ public class SystemInfo {
|
||||
*/
|
||||
public static final boolean isMacOSLion = isLion();
|
||||
|
||||
/**
|
||||
* Running under MacOS X version 10.8 or later;
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static final boolean isMacOSMountainLion = isMountainLion();
|
||||
|
||||
/**
|
||||
* Operating system is supposed to have middle mouse button click occupied by paste action.
|
||||
* @since 6.0
|
||||
*/
|
||||
public static boolean X11PasteEnabledSystem = isUnix && !isMac;
|
||||
|
||||
private static boolean isIntelMac() {
|
||||
return isMac && "i386".equals(OS_ARCH);
|
||||
}
|
||||
|
||||
private static boolean isTiger() {
|
||||
return isMac &&
|
||||
!OS_VERSION.startsWith("10.0") &&
|
||||
@@ -119,10 +130,6 @@ public class SystemInfo {
|
||||
!OS_VERSION.startsWith("10.3");
|
||||
}
|
||||
|
||||
private static boolean isIntelMac() {
|
||||
return isMac && "i386".equals(OS_ARCH);
|
||||
}
|
||||
|
||||
private static boolean isLeopard() {
|
||||
return isMac && isTiger() && !OS_VERSION.startsWith("10.4");
|
||||
}
|
||||
@@ -135,6 +142,10 @@ public class SystemInfo {
|
||||
return isMac && isSnowLeopard() && !OS_VERSION.startsWith("10.6");
|
||||
}
|
||||
|
||||
private static boolean isMountainLion() {
|
||||
return isMac && isLion() && !OS_VERSION.startsWith("10.7");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getMacOSVersionCode() {
|
||||
return getMacOSVersionCode(OS_VERSION);
|
||||
|
||||
@@ -1553,9 +1553,9 @@ public class UIUtil {
|
||||
if (size == FontSize.MINI) {
|
||||
defFont = defFont.deriveFont(Math.max(defFont.getSize() - 4f, 9f));
|
||||
}
|
||||
if (isBold) {
|
||||
defFont = defFont.deriveFont(Font.BOLD);
|
||||
}
|
||||
//if (isBold) {
|
||||
// defFont = defFont.deriveFont(Font.BOLD);
|
||||
//}
|
||||
return defFont;
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -32,6 +32,7 @@ import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
|
||||
import com.intellij.openapi.vcs.impl.VcsBackgroundableActions;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
import com.intellij.vcsUtil.VcsSelection;
|
||||
import com.intellij.vcsUtil.VcsSelectionUtil;
|
||||
|
||||
@@ -77,11 +78,15 @@ public class SelectedBlockHistoryAction extends AbstractVcsAction {
|
||||
final int selectionStart = selection.getSelectionStartLineNumber();
|
||||
final int selectionEnd = selection.getSelectionEndLineNumber();
|
||||
|
||||
final VcsException[] preloadException = new VcsException[1];
|
||||
final CachedRevisionsContents cachedRevisionsContents = new CachedRevisionsContents(project, file);
|
||||
new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()).
|
||||
createSessionFor(activeVcs.getKeyInstanceMethod(), new FilePathImpl(file),
|
||||
new Consumer<VcsHistorySession>() {
|
||||
public void consume(VcsHistorySession session) {
|
||||
if (preloadException[0] != null) {
|
||||
reportError(preloadException[0]);
|
||||
}
|
||||
if (session == null) return;
|
||||
final VcsHistoryDialog vcsHistoryDialog =
|
||||
new VcsHistoryDialog(project,
|
||||
@@ -103,7 +108,12 @@ public class SelectedBlockHistoryAction extends AbstractVcsAction {
|
||||
cachedRevisionsContents.setRevisions(revisionList);
|
||||
if (VcsConfiguration.getInstance(project).SHOW_ONLY_CHANGED_IN_SELECTION_DIFF) {
|
||||
// preload while in bckgrnd
|
||||
cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()]));
|
||||
try {
|
||||
cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()]));
|
||||
}
|
||||
catch (VcsException e) {
|
||||
preloadException[0] = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ public class VcsHistoryUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static int compareNumbers(VcsFileRevision first, VcsFileRevision second) {
|
||||
public static int compareNumbers(VcsFileRevision first, VcsFileRevision second) {
|
||||
return first.getRevisionNumber().compareTo(second.getRevisionNumber());
|
||||
}
|
||||
|
||||
|
||||
+20
-14
@@ -42,7 +42,7 @@ import java.util.*;
|
||||
*/
|
||||
public class CachedRevisionsContents {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.history.impl.CachedRevisionsContents");
|
||||
private final Map<VcsRevisionNumber, String> myCachedContents = new HashMap<VcsRevisionNumber, String>();
|
||||
private final Map<VcsRevisionNumber, String> myCachedContents;
|
||||
private final Project myProject;
|
||||
// managed outside, for reference here
|
||||
private List<VcsFileRevision> myRevisions;
|
||||
@@ -51,13 +51,14 @@ public class CachedRevisionsContents {
|
||||
public CachedRevisionsContents(final Project project, final VirtualFile file) {
|
||||
myProject = project;
|
||||
myFile = file;
|
||||
myCachedContents = Collections.synchronizedMap(new HashMap<VcsRevisionNumber, String>());
|
||||
}
|
||||
|
||||
public void setRevisions(List<VcsFileRevision> revisions) {
|
||||
myRevisions = revisions;
|
||||
}
|
||||
|
||||
public void loadContentsFor(final VcsFileRevision[] revisions) {
|
||||
public void loadContentsFor(final VcsFileRevision[] revisions) throws VcsException {
|
||||
final VcsFileRevision[] revisionsToLoad = revisionsNeededToBeLoaded(revisions);
|
||||
|
||||
final List<VcsFileRevision> toBeLoaded = new LinkedList<VcsFileRevision>();
|
||||
@@ -67,6 +68,7 @@ public class CachedRevisionsContents {
|
||||
}
|
||||
if (toBeLoaded.isEmpty()) return;
|
||||
|
||||
final VcsException[] exception = new VcsException[1];
|
||||
final Runnable process = new Runnable() {
|
||||
public void run() {
|
||||
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
@@ -91,19 +93,17 @@ public class CachedRevisionsContents {
|
||||
vcsFileRevision.loadContent();
|
||||
}
|
||||
catch (final VcsException e) {
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
|
||||
public void run() {
|
||||
Messages.showErrorDialog(VcsBundle.message("message.text.cannot.load.version.because.of.error",
|
||||
vcsFileRevision.getRevisionNumber(), e.getLocalizedMessage()),
|
||||
VcsBundle.message("message.title.load.version"));
|
||||
}
|
||||
}, null, myProject);
|
||||
exception[0] = new VcsException(e);
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
catch (ProcessCanceledException ex) {
|
||||
return;
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
exception[0] = new VcsException(e);
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
String content = null;
|
||||
try {
|
||||
@@ -113,13 +113,16 @@ public class CachedRevisionsContents {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
exception[0] = new VcsException(e);
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
catch (VcsException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
exception[0] = new VcsException(e);
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
myCachedContents.put(vcsFileRevision.getRevisionNumber(), content);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,9 +139,12 @@ public class CachedRevisionsContents {
|
||||
} else {
|
||||
process.run();
|
||||
}
|
||||
if (exception[0] != null) {
|
||||
throw exception[0];
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentOf(VcsFileRevision revision) {
|
||||
public String getContentOf(VcsFileRevision revision) throws VcsException {
|
||||
if (! myCachedContents.containsKey(revision.getRevisionNumber())) {
|
||||
loadContentsFor(new VcsFileRevision[]{revision});
|
||||
}
|
||||
@@ -157,7 +163,7 @@ public class CachedRevisionsContents {
|
||||
private Collection<VcsFileRevision> collectRevisionsFromFirstTo(VcsFileRevision revision) {
|
||||
ArrayList<VcsFileRevision> result = new ArrayList<VcsFileRevision>();
|
||||
for (VcsFileRevision vcsFileRevision : myRevisions) {
|
||||
if (VcsHistoryUtil.compare(revision, vcsFileRevision) > 0) continue;
|
||||
if (VcsHistoryUtil.compareNumbers(revision, vcsFileRevision) > 0) continue;
|
||||
result.add(vcsFileRevision);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.diff.FindBlock;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.DiffManager;
|
||||
import com.intellij.openapi.diff.DiffPanel;
|
||||
@@ -29,12 +30,11 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.history.*;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.table.TableView;
|
||||
@@ -61,6 +61,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
private final int mySelectionStart;
|
||||
private final int mySelectionEnd;
|
||||
|
||||
// todo equals???
|
||||
private final Map<VcsFileRevision, Block> myRevisionToContentMap = new com.intellij.util.containers.HashMap<VcsFileRevision, Block>();
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.history.impl.VcsHistoryDialog");
|
||||
@@ -173,11 +174,11 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
});
|
||||
|
||||
|
||||
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
final ListSelectionListener selectionListener = new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
final VcsFileRevision revision;
|
||||
if (myList.getSelectedRowCount() == 1) {
|
||||
revision = (VcsFileRevision) myList.getItems().get(myList.getSelectedRow());
|
||||
if (myList.getSelectedRowCount() == 1 && !myList.isEmpty()) {
|
||||
revision = (VcsFileRevision)myList.getItems().get(myList.getSelectedRow());
|
||||
myComments.setText(revision.getCommitMessage());
|
||||
myComments.setCaretPosition(0);
|
||||
}
|
||||
@@ -190,21 +191,34 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
}
|
||||
updateDiff();
|
||||
}
|
||||
});
|
||||
};
|
||||
myList.getSelectionModel().addListSelectionListener(selectionListener);
|
||||
|
||||
myChangesOnlyCheckBox.setSelected(configuration.SHOW_ONLY_CHANGED_IN_SELECTION_DIFF);
|
||||
updateRevisionsList();
|
||||
try {
|
||||
updateRevisionsList();
|
||||
}
|
||||
catch (final VcsException e) {
|
||||
// todo test it, always exception
|
||||
canNotLoadRevisionMessage(e);
|
||||
}
|
||||
myChangesOnlyCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
configuration.SHOW_ONLY_CHANGED_IN_SELECTION_DIFF = myChangesOnlyCheckBox.isSelected();
|
||||
updateRevisionsList();
|
||||
try {
|
||||
updateRevisionsList();
|
||||
}
|
||||
catch (VcsException e1) {
|
||||
canNotLoadRevisionMessage(e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (! VcsHistoryDialog.this.isShowing()) return;
|
||||
myList.getSelectionModel().addSelectionInterval(0, 0);
|
||||
}
|
||||
});
|
||||
@@ -212,6 +226,21 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
setTitle(VcsBundle.message("dialog.title.history.for.file", file.getName()));
|
||||
}
|
||||
|
||||
private void canNotLoadRevisionMessage(final VcsException e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (! VcsHistoryDialog.this.isShowing()) return;
|
||||
VcsBalloonProblemNotifier.showBalloonForComponent(VcsHistoryDialog.this.getRootPane(),
|
||||
canNoLoadMessage(e), MessageType.ERROR, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String canNoLoadMessage(VcsException e) {
|
||||
return "Can not load revision contents: " + e.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myList;
|
||||
@@ -235,15 +264,15 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String getContentOf(VcsFileRevision revision) {
|
||||
protected String getContentOf(VcsFileRevision revision) throws VcsException {
|
||||
return myCachedContents.getContentOf(revision);
|
||||
}
|
||||
|
||||
private void loadContentsFor(final VcsFileRevision[] revisions) {
|
||||
private void loadContentsFor(final VcsFileRevision[] revisions) throws VcsException {
|
||||
myCachedContents.loadContentsFor(revisions);
|
||||
}
|
||||
|
||||
private void updateRevisionsList() {
|
||||
private void updateRevisionsList() throws VcsException {
|
||||
if (myIsInLoading) return;
|
||||
if (myChangesOnlyCheckBox.isSelected()) {
|
||||
loadContentsFor(myRevisions.toArray(new VcsFileRevision[myRevisions.size()]));
|
||||
@@ -267,7 +296,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
|
||||
}
|
||||
|
||||
private List<VcsFileRevision> filteredRevisions() throws FilesTooBigForDiffException {
|
||||
private List<VcsFileRevision> filteredRevisions() throws FilesTooBigForDiffException, VcsException {
|
||||
ArrayList<VcsFileRevision> result = new ArrayList<VcsFileRevision>();
|
||||
VcsFileRevision nextRevision = myRevisions.get(myRevisions.size() - 1);
|
||||
result.add(nextRevision);
|
||||
@@ -282,6 +311,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
}
|
||||
|
||||
private synchronized void updateDiff() {
|
||||
if (myList.isEmpty()) return;
|
||||
int[] selectedIndices = myList.getSelectedRows();
|
||||
if (selectedIndices.length == 0) {
|
||||
updateDiff(CURRENT, CURRENT);
|
||||
@@ -314,6 +344,12 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
catch (FilesTooBigForDiffException e) {
|
||||
myDiffPanel.setTooBigFileErrorContents();
|
||||
}
|
||||
catch (VcsException e) {
|
||||
final String text = canNoLoadMessage(e);
|
||||
myDiffPanel.setContents(new SimpleContent(text, myContentFileType),
|
||||
new SimpleContent(text, myContentFileType));
|
||||
canNotLoadRevisionMessage(e);
|
||||
}
|
||||
myDiffPanel.setTitle1(VcsBundle.message("diff.content.title.revision.number", firstRev.getRevisionNumber()));
|
||||
myDiffPanel.setTitle2(VcsBundle.message("diff.content.title.revision.number", secondRev.getRevisionNumber()));
|
||||
|
||||
@@ -414,14 +450,14 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getContentToShow(VcsFileRevision revision) throws FilesTooBigForDiffException {
|
||||
protected String getContentToShow(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException {
|
||||
final Block block = getBlock(revision);
|
||||
if (block == null) return "";
|
||||
return block.getBlockContent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException {
|
||||
private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException {
|
||||
if (myRevisionToContentMap.containsKey(revision))
|
||||
return myRevisionToContentMap.get(revision);
|
||||
|
||||
|
||||
@@ -20,9 +20,17 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Shows a notification balloon over one of version control related tool windows: Changes View or Version Control View.
|
||||
* By default the notification is shown over the Changes View.
|
||||
@@ -74,4 +82,24 @@ public class VcsBalloonProblemNotifier implements Runnable {
|
||||
public void run() {
|
||||
NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(myProject.isDefault() ? null : myProject);
|
||||
}
|
||||
|
||||
public static void showBalloonForComponent(@NotNull JComponent component, @NotNull final String message, final MessageType type,
|
||||
final boolean atTop) {
|
||||
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, type, null);
|
||||
Balloon balloon = balloonBuilder.createBalloon();
|
||||
Dimension size = component.getSize();
|
||||
Balloon.Position position;
|
||||
int x;
|
||||
int y;
|
||||
if (size == null) {
|
||||
x = y = 0;
|
||||
position = Balloon.Position.above;
|
||||
}
|
||||
else {
|
||||
x = Math.min(10, size.width / 2);
|
||||
y = size.height;
|
||||
position = Balloon.Position.below;
|
||||
}
|
||||
balloon.show(new RelativePoint(component, new Point(x, y)), position);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-6
@@ -25,9 +25,7 @@ import com.android.sdklib.IAndroidTarget;
|
||||
import com.intellij.android.designer.componentTree.AndroidTreeDecorator;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.designSurface.ComponentDecorator;
|
||||
import com.intellij.designer.designSurface.DecorationLayer;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.*;
|
||||
import com.intellij.designer.designSurface.selection.DirectionResizePoint;
|
||||
import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator;
|
||||
import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
|
||||
@@ -193,9 +191,17 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
|
||||
@Override
|
||||
protected ComponentDecorator getRootSelectionDecorator() {
|
||||
return new ResizeSelectionDecorator(Color.RED, 1, new DirectionResizePoint(Position.EAST),
|
||||
new DirectionResizePoint(Position.SOUTH_EAST),
|
||||
new DirectionResizePoint(Position.SOUTH));
|
||||
return new ResizeSelectionDecorator(Color.RED, 1, new DirectionResizePoint(Position.EAST, "top_resize_"),
|
||||
new DirectionResizePoint(Position.SOUTH_EAST, "top_resize"),
|
||||
new DirectionResizePoint(Position.SOUTH, "top_resize"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EditOperation processRootOperation(OperationContext context) {
|
||||
if (context.is("top_resize")) {
|
||||
return new ResizeOperation(context);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class RootView extends JComponent {
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.designSurface.EditOperation;
|
||||
import com.intellij.designer.designSurface.FeedbackLayer;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.designSurface.feedbacks.AlphaComponent;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.utils.Position;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ResizeOperation implements EditOperation {
|
||||
private final OperationContext myContext;
|
||||
private RadComponent myComponent;
|
||||
private JComponent myFeedback;
|
||||
|
||||
public ResizeOperation(OperationContext context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponent(RadComponent component) {
|
||||
myComponent = component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponents(List<RadComponent> component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFeedback() {
|
||||
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
|
||||
|
||||
if (myFeedback == null) {
|
||||
myFeedback = new AlphaComponent(Color.GREEN, Color.LIGHT_GRAY);
|
||||
layer.add(myFeedback);
|
||||
}
|
||||
|
||||
myFeedback.setBounds(myContext.getTransformedRectangle(myComponent.getBounds(layer)));
|
||||
layer.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseFeedback() {
|
||||
if (myFeedback != null) {
|
||||
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
|
||||
layer.remove(myFeedback);
|
||||
layer.repaint();
|
||||
myFeedback = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute() {
|
||||
return myContext.getResizeDirection() != Position.SOUTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -56,6 +56,11 @@ public class RadViewComponent extends RadComponent {
|
||||
return myBounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle getBounds(Component relativeTo) {
|
||||
return SwingUtilities.convertRectangle(myNativeComponent, myBounds, relativeTo);
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
myBounds.setBounds(x, y, width, height);
|
||||
}
|
||||
@@ -68,9 +73,4 @@ public class RadViewComponent extends RadComponent {
|
||||
public Point convertPoint(Component component, int x, int y) {
|
||||
return SwingUtilities.convertPoint(component, x, y, myNativeComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point convertPoint(int x, int y, Component component) {
|
||||
return SwingUtilities.convertPoint(myNativeComponent, x, y, component);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class GroovyMethodInfo {
|
||||
Map<String, List<GroovyMethodInfo>> methodMap = res.get(key);
|
||||
if (methodMap == null) {
|
||||
methodMap = new HashMap<String, List<GroovyMethodInfo>>();
|
||||
res.put(key.intern(), methodMap);
|
||||
res.put(key, methodMap);
|
||||
}
|
||||
|
||||
List<GroovyMethodInfo> methodsList = methodMap.get(methodName);
|
||||
|
||||
+2
-1
@@ -200,7 +200,8 @@ public class MavenModelConverter {
|
||||
}
|
||||
|
||||
public static MavenArtifact convertArtifact(Artifact artifact, File localRepository) {
|
||||
return new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(),
|
||||
return new MavenArtifact(artifact.getGroupId(),
|
||||
artifact.getArtifactId(),
|
||||
artifact.getVersion(),
|
||||
artifact.getBaseVersion(),
|
||||
artifact.getType(),
|
||||
|
||||
+1
-6
@@ -422,12 +422,7 @@ public class MavenProjectReader {
|
||||
MavenProjectProblem.ProblemType.PARENT));
|
||||
}
|
||||
|
||||
model = MavenServerManager.getInstance().assembleInheritance(model, parentModel);
|
||||
List<MavenProfile> profiles = model.getProfiles();
|
||||
for (MavenProfile each : parentModel.getProfiles()) {
|
||||
addProfileIfDoesNotExist(each, profiles);
|
||||
}
|
||||
return model;
|
||||
return MavenServerManager.getInstance().assembleInheritance(model, parentModel);
|
||||
}
|
||||
finally {
|
||||
recursionGuard.remove(file);
|
||||
|
||||
@@ -208,7 +208,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> {
|
||||
}
|
||||
params.getVMParametersList().addParametersString("-Xmx512m");
|
||||
|
||||
//params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5009");
|
||||
//params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5009");
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
+42
-11
@@ -24,6 +24,7 @@ import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
|
||||
import java.io.File;
|
||||
@@ -107,6 +108,36 @@ public class StructureImportingTest extends MavenImportingTestCase {
|
||||
assertModules("project", "m1", "m2");
|
||||
}
|
||||
|
||||
public void testModulesAreNotInheritedFromParentsProfiles() throws Exception {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
|
||||
"<profiles>\n" +
|
||||
" <profile>\n" +
|
||||
" <id>one</id>\n" +
|
||||
" <modules>" +
|
||||
" <module>m</module>" +
|
||||
" </modules>" +
|
||||
" </profile>" +
|
||||
"</profiles>");
|
||||
|
||||
createModulePom("m", "<groupId>test</groupId>" +
|
||||
"<artifactId>m</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</parent>");
|
||||
|
||||
importProjectWithProfiles("one");
|
||||
|
||||
assertSize(1, myProjectsManager.findProject(new MavenId("test", "project", "1")).getModulePaths());
|
||||
assertSize(0, myProjectsManager.findProject(new MavenId("test", "m", "1")).getModulePaths());
|
||||
}
|
||||
|
||||
public void testModulesWithSlashesAtTheEnds() throws Exception {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
@@ -344,18 +375,18 @@ public class StructureImportingTest extends MavenImportingTestCase {
|
||||
if (!hasMavenInstallation()) return;
|
||||
|
||||
final VirtualFile parent = createModulePom("parent",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
|
||||
"<dependencies>" +
|
||||
" <dependency>" +
|
||||
" <groupId>junit</groupId>" +
|
||||
" <artifactId>junit</artifactId>" +
|
||||
" <version>4.0</version>" +
|
||||
" </dependency>" +
|
||||
"</dependencies>");
|
||||
"<dependencies>" +
|
||||
" <dependency>" +
|
||||
" <groupId>junit</groupId>" +
|
||||
" <artifactId>junit</artifactId>" +
|
||||
" <version>4.0</version>" +
|
||||
" </dependency>" +
|
||||
"</dependencies>");
|
||||
executeGoal("parent", "install");
|
||||
|
||||
new WriteAction() {
|
||||
|
||||
+37
-46
@@ -23,10 +23,11 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.idea.maven.MavenTestCase;
|
||||
import org.jetbrains.idea.maven.model.*;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.model.MavenModel;
|
||||
import org.jetbrains.idea.maven.model.MavenProjectProblem;
|
||||
import org.jetbrains.idea.maven.model.MavenResource;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -493,7 +494,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertEquals("${prop2}", p.getPackaging());
|
||||
}
|
||||
|
||||
public void testHandlingRecursionProprielyAndDoNotForgetCoClearRecursionGuard() throws Exception {
|
||||
public void testHandlingRecursionProperlyAndDoNotForgetCoClearRecursionGuard() throws Exception {
|
||||
File repositoryPath = new File(myDir, "repository");
|
||||
setRepositoryPath(repositoryPath.getPath());
|
||||
|
||||
@@ -999,44 +1000,6 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertEquals("xxx", p.getBuild().getFinalName());
|
||||
}
|
||||
|
||||
|
||||
public void testInheritingParentProfiles() throws Exception {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<profiles>" +
|
||||
" <profile>" +
|
||||
" <id>profileFromParent</id>" +
|
||||
" </profile>" +
|
||||
"</profiles>");
|
||||
|
||||
VirtualFile module = createModulePom("module",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>module</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>parent</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</parent>" +
|
||||
|
||||
"<profiles>" +
|
||||
" <profile>" +
|
||||
" <id>profileFromChild</id>" +
|
||||
" </profile>" +
|
||||
"</profiles>");
|
||||
|
||||
MavenModel p = readProject(module);
|
||||
assertOrderedElementsAreEqual(ContainerUtil.map(p.getProfiles(), new Function<MavenProfile, Object>() {
|
||||
@Override
|
||||
public Object fun(MavenProfile profile) {
|
||||
return profile.getId();
|
||||
}
|
||||
}), "profileFromChild", "profileFromParent");
|
||||
}
|
||||
|
||||
public void testCorrectlyCollectProfilesFromDifferentSources() throws Exception {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
@@ -1116,8 +1079,8 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
p = readProject(module);
|
||||
assertEquals(1, p.getProfiles().size());
|
||||
assertEquals("parent", p.getProfiles().get(0).getModules().get(0));
|
||||
assertEquals("pom", p.getProfiles().get(0).getSource());
|
||||
assertEquals("settings", p.getProfiles().get(0).getModules().get(0));
|
||||
assertEquals("settings.xml", p.getProfiles().get(0).getSource());
|
||||
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
@@ -1125,8 +1088,8 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
p = readProject(module);
|
||||
assertEquals(1, p.getProfiles().size());
|
||||
assertEquals("parentProfiles", p.getProfiles().get(0).getModules().get(0));
|
||||
assertEquals("profiles.xml", p.getProfiles().get(0).getSource());
|
||||
assertEquals("settings", p.getProfiles().get(0).getModules().get(0));
|
||||
assertEquals("settings.xml", p.getProfiles().get(0).getSource());
|
||||
|
||||
new WriteCommandAction.Simple(myProject) {
|
||||
@Override
|
||||
@@ -1142,6 +1105,34 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertEquals("settings.xml", p.getProfiles().get(0).getSource());
|
||||
}
|
||||
|
||||
public void testModulesAreNotInheritedFromParentsProfiles() throws Exception {
|
||||
VirtualFile p = createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
|
||||
"<profiles>" +
|
||||
" <profile>" +
|
||||
" <id>one</id>" +
|
||||
" <modules>" +
|
||||
" <module>m</module>" +
|
||||
" </modules>" +
|
||||
" </profile>" +
|
||||
"</profiles>");
|
||||
|
||||
VirtualFile m = createModulePom("m", "<groupId>test</groupId>" +
|
||||
"<artifactId>m</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</parent>");
|
||||
|
||||
assertSize(1, readProject(p, "one").getModules());
|
||||
assertSize(0, readProject(m, "one").getModules());
|
||||
}
|
||||
|
||||
public void testActivatingProfilesByDefault() throws Exception {
|
||||
createProjectPom("<profiles>" +
|
||||
" <profile>" +
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.tmatesoft.svn.core.SVNErrorCode;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.wc.ISVNChangelistHandler;
|
||||
import org.tmatesoft.svn.core.wc.SVNChangelistClient;
|
||||
import org.tmatesoft.svn.core.wc.SVNStatus;
|
||||
import org.tmatesoft.svn.core.wc.SVNStatusClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -177,21 +179,10 @@ public class SvnChangelistListener implements ChangeListListener {
|
||||
public static String getCurrentMapping(final Project project, final File file) {
|
||||
final SvnVcs17 vcs = SvnVcs17.getInstance(project);
|
||||
final SVNChangelistClient client = vcs.createChangelistClient();
|
||||
final SVNStatusClient statusClient = vcs.createStatusClient();
|
||||
try {
|
||||
final Ref<String> refResult = new Ref<String>();
|
||||
final ISVNChangelistHandler handler = new ISVNChangelistHandler() {
|
||||
public void handle(final File path, final String changelistName) {
|
||||
if (refResult.isNull() && Comparing.equal(path, file)) {
|
||||
refResult.set(changelistName);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (file.exists()) {
|
||||
client.doGetChangeLists(file, null, SVNDepth.EMPTY, handler);
|
||||
} else if (file.getParentFile() != null) {
|
||||
client.doGetChangeLists(file.getParentFile(), null, SVNDepth.IMMEDIATES, handler);
|
||||
}
|
||||
return refResult.get();
|
||||
final SVNStatus status = statusClient.doStatus(file, false);
|
||||
return status.getChangelistName();
|
||||
}
|
||||
catch (SVNException e) {
|
||||
final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode();
|
||||
|
||||
+4
-9
@@ -98,13 +98,6 @@ public class SvnCommandLineStatusClient implements SvnStatusClientI {
|
||||
|
||||
final SVNInfo infoBase = myInfoClient.doInfo(base, revision);
|
||||
|
||||
// TODO check file case
|
||||
// TODO check file case
|
||||
// TODO check file case
|
||||
// TODO check file case
|
||||
// TODO check file case
|
||||
|
||||
|
||||
// todo can not understand why revision can be used here
|
||||
final SvnSimpleCommand command = new SvnSimpleCommand(myProject, base, SvnCommandName.st);
|
||||
|
||||
@@ -136,8 +129,10 @@ public class SvnCommandLineStatusClient implements SvnStatusClientI {
|
||||
final PortableStatus pending = svnHandl[0].getPending();
|
||||
pending.setChangelistName(changelistName[0]);
|
||||
try {
|
||||
final String append = SVNPathUtil.append(infoBase.getURL().toString(), FileUtil.toSystemIndependentName(pending.getPath()));
|
||||
pending.setURL(SVNURL.parseURIEncoded(append));
|
||||
if (infoBase != null) {
|
||||
final String append = SVNPathUtil.append(infoBase.getURL().toString(), FileUtil.toSystemIndependentName(pending.getPath()));
|
||||
pending.setURL(SVNURL.parseURIEncoded(append));
|
||||
}
|
||||
handler.handleStatus(pending);
|
||||
}
|
||||
catch (SVNException e) {
|
||||
|
||||
@@ -104,7 +104,6 @@ public class SvnNativeListsTest extends SvnTestCase {
|
||||
verify(runSvn("status"), "", "--- Changelist 'newOne':", "M a.txt");
|
||||
}
|
||||
|
||||
@Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix")
|
||||
@Test
|
||||
public void testEditAndMove() throws Throwable {
|
||||
final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null);
|
||||
@@ -156,7 +155,6 @@ public class SvnNativeListsTest extends SvnTestCase {
|
||||
verify(runSvn("status"), "", "--- Changelist 'newOne':", "A + b.txt", "D a.txt");
|
||||
}
|
||||
|
||||
@Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix")
|
||||
@Test
|
||||
public void testMoveMove() throws Throwable {
|
||||
final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class SvnRenameTest extends SvnTestCase {
|
||||
}
|
||||
|
||||
// IDEA-13824
|
||||
@Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix")
|
||||
@Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-136")
|
||||
@Test
|
||||
public void testRenameFileRenameDir() throws Exception {
|
||||
final VirtualFile child = prepareDirectoriesForRename();
|
||||
|
||||
-6
@@ -65,10 +65,4 @@ public class DecorationLayer extends JComponent {
|
||||
}
|
||||
return parent.getLayout().getChildSelectionDecorator(component);
|
||||
}
|
||||
|
||||
public Rectangle getComponentBounds(RadComponent component) {
|
||||
Rectangle bounds = component.getBounds();
|
||||
Point location = component.convertPoint(bounds.x, bounds.y, this);
|
||||
return new Rectangle(location.x, location.y, bounds.width, bounds.height);
|
||||
}
|
||||
}
|
||||
+12
@@ -30,6 +30,7 @@ import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -130,6 +131,11 @@ public abstract class DesignerEditorPanel extends JPanel implements ToolProvider
|
||||
return DesignerEditorPanel.this.getRootSelectionDecorator();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EditOperation processRootOperation(OperationContext context) {
|
||||
return DesignerEditorPanel.this.processRootOperation(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedbackLayer getFeedbackLayer() {
|
||||
return myFeedbackLayer;
|
||||
@@ -175,6 +181,9 @@ public abstract class DesignerEditorPanel extends JPanel implements ToolProvider
|
||||
|
||||
protected abstract ComponentDecorator getRootSelectionDecorator();
|
||||
|
||||
@Nullable
|
||||
protected abstract EditOperation processRootOperation(OperationContext context);
|
||||
|
||||
public InputTool getActiveTool() {
|
||||
return myTool;
|
||||
}
|
||||
@@ -244,6 +253,9 @@ public abstract class DesignerEditorPanel extends JPanel implements ToolProvider
|
||||
int height = 0;
|
||||
|
||||
if (myRootComponent != null) {
|
||||
width = Math.max(width, (int)myRootComponent.getBounds().getMaxX());
|
||||
height = Math.max(height, (int)myRootComponent.getBounds().getMaxY());
|
||||
|
||||
for (RadComponent component : myRootComponent.getChildren()) {
|
||||
width = Math.max(width, (int)component.getBounds().getMaxX());
|
||||
height = Math.max(height, (int)component.getBounds().getMaxY());
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface EditOperation {
|
||||
void setComponent(RadComponent component);
|
||||
|
||||
void setComponents(List<RadComponent> component);
|
||||
|
||||
void showFeedback();
|
||||
|
||||
void eraseFeedback();
|
||||
|
||||
boolean canExecute();
|
||||
|
||||
void execute() throws Exception;
|
||||
}
|
||||
+14
@@ -92,7 +92,21 @@ public abstract class EditableArea {
|
||||
|
||||
public abstract ComponentDecorator getRootSelectionDecorator();
|
||||
|
||||
@Nullable
|
||||
public EditOperation processRootOperation(OperationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract FeedbackLayer getFeedbackLayer();
|
||||
|
||||
public abstract RadComponent getRootComponent();
|
||||
|
||||
public boolean isTree() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FeedbackTreeLayer getFeedbackTreeLayer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface FeedbackTreeLayer {
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class OperationContext {
|
||||
private final Object myType;
|
||||
private EditableArea myArea;
|
||||
private List<RadComponent> myComponents;
|
||||
private InputEvent myInputEvent;
|
||||
private Point myLocation;
|
||||
private Point myMoveDelta;
|
||||
private Dimension mySizeDelta;
|
||||
private int myResizeDirection;
|
||||
private Object myNewObject;
|
||||
|
||||
public OperationContext(Object type) {
|
||||
myType = type;
|
||||
}
|
||||
|
||||
public Object getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
public boolean is(Object type) {
|
||||
return type == null ? myType == null : type.equals(myType);
|
||||
}
|
||||
|
||||
public EditableArea getArea() {
|
||||
return myArea;
|
||||
}
|
||||
|
||||
public void setArea(EditableArea area) {
|
||||
myArea = area;
|
||||
}
|
||||
|
||||
public List<RadComponent> getComponents() {
|
||||
return myComponents;
|
||||
}
|
||||
|
||||
public void setComponents(List<RadComponent> components) {
|
||||
myComponents = components;
|
||||
}
|
||||
|
||||
public InputEvent getInputEvent() {
|
||||
return myInputEvent;
|
||||
}
|
||||
|
||||
public void setInputEvent(InputEvent inputEvent) {
|
||||
myInputEvent = inputEvent;
|
||||
}
|
||||
|
||||
public Point getLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
public void setLocation(Point location) {
|
||||
myLocation = location;
|
||||
}
|
||||
|
||||
public Point getMoveDelta() {
|
||||
return myMoveDelta;
|
||||
}
|
||||
|
||||
public void setMoveDelta(Point moveDelta) {
|
||||
myMoveDelta = moveDelta;
|
||||
}
|
||||
|
||||
public Dimension getSizeDelta() {
|
||||
return mySizeDelta;
|
||||
}
|
||||
|
||||
public void setSizeDelta(Dimension sizeDelta) {
|
||||
mySizeDelta = sizeDelta;
|
||||
}
|
||||
|
||||
public Rectangle getTransformedRectangle(Rectangle r) {
|
||||
return new Rectangle(r.x + myMoveDelta.x, r.y + myMoveDelta.y, r.width + mySizeDelta.width, r.height + mySizeDelta.height);
|
||||
}
|
||||
|
||||
public int getResizeDirection() {
|
||||
return myResizeDirection;
|
||||
}
|
||||
|
||||
public void setResizeDirection(int resizeDirection) {
|
||||
myResizeDirection = resizeDirection;
|
||||
}
|
||||
|
||||
public Object getNewObject() {
|
||||
return myNewObject;
|
||||
}
|
||||
|
||||
public void setNewObject(Object newObject) {
|
||||
myNewObject = newObject;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.designSurface.feedbacks;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class AlphaComponent extends JComponent {
|
||||
private static final AlphaComposite myComposite1 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.3f);
|
||||
private static final AlphaComposite myComposite2 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.6f);
|
||||
|
||||
private final Color myColor;
|
||||
private final Color myBorderColor;
|
||||
|
||||
public AlphaComponent(Color color) {
|
||||
this(color, color);
|
||||
}
|
||||
|
||||
public AlphaComponent(Color color, Color borderColor) {
|
||||
myColor = color;
|
||||
myBorderColor = borderColor;
|
||||
}
|
||||
|
||||
protected void paintComponent(final Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
super.paintComponent(g);
|
||||
final Composite oldComposite = g2d.getComposite();
|
||||
final Color oldColor = g2d.getColor();
|
||||
|
||||
g2d.setColor(myColor);
|
||||
g2d.setComposite(myComposite1);
|
||||
g2d.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
g2d.setColor(myBorderColor);
|
||||
g2d.setComposite(myComposite2);
|
||||
g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
||||
|
||||
g2d.setColor(oldColor);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -28,16 +28,19 @@ import java.awt.*;
|
||||
*/
|
||||
public class DirectionResizePoint extends ResizePoint {
|
||||
private int myDirection;
|
||||
private Object myType;
|
||||
private double myXSeparator;
|
||||
private double myYSeparator;
|
||||
|
||||
public DirectionResizePoint(int direction) {
|
||||
public DirectionResizePoint(int direction, Object type) {
|
||||
setDirection(direction);
|
||||
myType = type;
|
||||
}
|
||||
|
||||
public DirectionResizePoint(Color color, Color border, int direction) {
|
||||
public DirectionResizePoint(Color color, Color border, int direction, Object type) {
|
||||
super(color, border);
|
||||
setDirection(direction);
|
||||
myType = type;
|
||||
}
|
||||
|
||||
private void setDirection(int direction) {
|
||||
@@ -68,12 +71,12 @@ public class DirectionResizePoint extends ResizePoint {
|
||||
|
||||
@Override
|
||||
protected InputTool createTool(RadComponent component) {
|
||||
return new ResizeTracker(myDirection);
|
||||
return new ResizeTracker(myDirection, myType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Point getLocation(DecorationLayer layer, RadComponent component) {
|
||||
Rectangle bounds = layer.getComponentBounds(component);
|
||||
Rectangle bounds = component.getBounds(layer);
|
||||
int size = (getSize() + 1) / 2;
|
||||
int x = bounds.x + (int) (bounds.width * myXSeparator) - size;
|
||||
int y = bounds.y + (int) (bounds.height * myYSeparator) - size;
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@ package com.intellij.designer.designSurface.selection;
|
||||
|
||||
import com.intellij.designer.designSurface.ComponentDecorator;
|
||||
import com.intellij.designer.designSurface.DecorationLayer;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.tools.DragTracker;
|
||||
import com.intellij.designer.designSurface.tools.InputTool;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
@@ -38,7 +37,7 @@ public class NonResizeSelectionDecorator implements ComponentDecorator {
|
||||
|
||||
@Override
|
||||
public InputTool findTargetTool(DecorationLayer layer, RadComponent component, int x, int y) {
|
||||
Rectangle bounds = layer.getComponentBounds(component);
|
||||
Rectangle bounds = component.getBounds(layer);
|
||||
int lineWidth = Math.max(myLineWidth, 2);
|
||||
|
||||
Rectangle top = new Rectangle(bounds.x, bounds.y, bounds.width, lineWidth);
|
||||
@@ -60,7 +59,7 @@ public class NonResizeSelectionDecorator implements ComponentDecorator {
|
||||
g.setStroke(new BasicStroke(myLineWidth));
|
||||
}
|
||||
|
||||
Rectangle bounds = layer.getComponentBounds(component);
|
||||
Rectangle bounds = component.getBounds(layer);
|
||||
g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
}
|
||||
}
|
||||
+9
@@ -18,13 +18,22 @@ package com.intellij.designer.designSurface.tools;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.utils.Cursors;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class DragTracker extends SelectionTracker {
|
||||
private static final Cursor myDragCursor = Cursors.getMoveCursor();
|
||||
|
||||
public DragTracker(RadComponent component) {
|
||||
super(component);
|
||||
setDefaultCursor(Cursors.RESIZE_ALL);
|
||||
setDisabledCursor(Cursors.getNoCursor());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Cursor getDefaultCursor() {
|
||||
return myState == STATE_NONE ? super.getDefaultCursor() : myDragCursor;
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -37,7 +37,7 @@ public abstract class InputTool {
|
||||
protected ToolProvider myToolProvider;
|
||||
protected EditableArea myArea;
|
||||
|
||||
private Object myCommand;
|
||||
protected Object myCommand;
|
||||
|
||||
private boolean myActive;
|
||||
private boolean myCanUnload = true;
|
||||
@@ -100,10 +100,6 @@ public abstract class InputTool {
|
||||
}
|
||||
}
|
||||
|
||||
protected final boolean unloadWhenFinished() {
|
||||
return myCanUnload;
|
||||
}
|
||||
|
||||
public final void setUnloadWhenFinished(boolean value) {
|
||||
myCanUnload = value;
|
||||
}
|
||||
@@ -144,7 +140,7 @@ public abstract class InputTool {
|
||||
return getDefaultCursor();
|
||||
}
|
||||
|
||||
protected final Cursor getDefaultCursor() {
|
||||
protected Cursor getDefaultCursor() {
|
||||
return myDefaultCursor;
|
||||
}
|
||||
|
||||
@@ -228,7 +224,7 @@ public abstract class InputTool {
|
||||
protected void handleAreaExited() {
|
||||
}
|
||||
|
||||
protected void handleFinished() {
|
||||
protected final void handleFinished() {
|
||||
if (myCanUnload) {
|
||||
myToolProvider.loadDefaultTool();
|
||||
}
|
||||
|
||||
+3
-25
@@ -18,6 +18,7 @@ package com.intellij.designer.designSurface.tools;
|
||||
import com.intellij.designer.designSurface.FeedbackLayer;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadComponentVisitor;
|
||||
import com.intellij.designer.designSurface.feedbacks.AlphaComponent;
|
||||
import com.intellij.designer.utils.Cursors;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -30,8 +31,6 @@ import java.util.List;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class MarqueeTracker extends InputTool {
|
||||
private static final AlphaComposite myComposite1 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.3f);
|
||||
private static final AlphaComposite myComposite2 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.6f);
|
||||
private static final Color myColor = new Color(47, 67, 96);
|
||||
|
||||
private static final int TOGGLE_MODE = 1;
|
||||
@@ -111,24 +110,7 @@ public class MarqueeTracker extends InputTool {
|
||||
FeedbackLayer layer = myArea.getFeedbackLayer();
|
||||
|
||||
if (myFeedback == null) {
|
||||
myFeedback = new JComponent() {
|
||||
protected void paintComponent(final Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
super.paintComponent(g);
|
||||
final Composite oldComposite = g2d.getComposite();
|
||||
final Color oldColor = g2d.getColor();
|
||||
g2d.setColor(myColor);
|
||||
|
||||
g2d.setComposite(myComposite1);
|
||||
g2d.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
g2d.setComposite(myComposite2);
|
||||
g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
||||
|
||||
g2d.setColor(oldColor);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
};
|
||||
myFeedback = new AlphaComponent(myColor);
|
||||
layer.add(myFeedback);
|
||||
}
|
||||
|
||||
@@ -156,11 +138,7 @@ public class MarqueeTracker extends InputTool {
|
||||
myArea.getRootComponent().accept(new RadComponentVisitor() {
|
||||
@Override
|
||||
public void endVisit(RadComponent component) {
|
||||
Rectangle bounds = component.getBounds();
|
||||
Point location = component.convertPoint(bounds.x, bounds.y, myArea.getNativeComponent());
|
||||
|
||||
if (selectionRectangle.contains(location) &&
|
||||
selectionRectangle.contains(location.x + bounds.width, location.y + bounds.height)) {
|
||||
if (selectionRectangle.contains(component.getBounds(myArea.getNativeComponent()))) {
|
||||
newSelection.add(component);
|
||||
}
|
||||
}
|
||||
|
||||
+168
-1
@@ -15,13 +15,180 @@
|
||||
*/
|
||||
package com.intellij.designer.designSurface.tools;
|
||||
|
||||
import com.intellij.designer.designSurface.EditOperation;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.utils.Cursors;
|
||||
import com.intellij.designer.utils.Position;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ResizeTracker extends InputTool {
|
||||
public ResizeTracker(int direction) {
|
||||
private OperationContext myContext;
|
||||
private List<EditOperation> myOperations;
|
||||
private boolean myShowFeedback;
|
||||
private final int myDirection;
|
||||
|
||||
public ResizeTracker(int direction, Object type) {
|
||||
myDirection = direction;
|
||||
myContext = new OperationContext(type);
|
||||
myContext.setResizeDirection(direction);
|
||||
setDefaultCursor(Cursors.getResizeCursor(direction));
|
||||
setDisabledCursor(Cursors.getNoCursor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
eraseFeedback();
|
||||
myContext = null;
|
||||
myOperations = null;
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Cursor calculateCursor() {
|
||||
if (myState == STATE_DRAG) {
|
||||
return getDefaultCursor();
|
||||
}
|
||||
return super.calculateCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonDown(int button) {
|
||||
if (button == 1) {
|
||||
if (myState == STATE_INIT) {
|
||||
myState = STATE_DRAG;
|
||||
}
|
||||
}
|
||||
else {
|
||||
myState = STATE_INVALID;
|
||||
eraseFeedback();
|
||||
setCommand(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonUp(int button) {
|
||||
if (myState == STATE_DRAG_IN_PROGRESS) {
|
||||
myState = STATE_NONE;
|
||||
eraseFeedback();
|
||||
executeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleDragStarted() {
|
||||
if (myState == STATE_DRAG) {
|
||||
myState = STATE_DRAG_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleDragInProgress() {
|
||||
if (myState == STATE_DRAG_IN_PROGRESS) {
|
||||
updateContext();
|
||||
showFeedback();
|
||||
setCommand();
|
||||
}
|
||||
}
|
||||
|
||||
private void showFeedback() {
|
||||
for (EditOperation operation : getOperations()) {
|
||||
operation.showFeedback();
|
||||
}
|
||||
myShowFeedback = true;
|
||||
}
|
||||
|
||||
private void eraseFeedback() {
|
||||
if (myShowFeedback) {
|
||||
myShowFeedback = false;
|
||||
for (EditOperation operation : getOperations()) {
|
||||
operation.eraseFeedback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void executeCommand() {
|
||||
if (myCommand != null) {
|
||||
try {
|
||||
for (EditOperation operation : getOperations()) {
|
||||
if (operation.canExecute()) {
|
||||
operation.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
myToolProvider.showError("Execute command: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setCommand() {
|
||||
for (EditOperation operation : getOperations()) {
|
||||
if (operation.canExecute()) {
|
||||
setCommand(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setCommand(null);
|
||||
}
|
||||
|
||||
private void updateContext() {
|
||||
myContext.setArea(myArea);
|
||||
myContext.setInputEvent(myInputEvent);
|
||||
|
||||
Point corner = new Point();
|
||||
Dimension resize = new Dimension();
|
||||
|
||||
int moveDeltaHeight = myCurrentScreenY - myStartScreenY;
|
||||
if ((myDirection & Position.NORTH) != 0) {
|
||||
corner.y += moveDeltaHeight;
|
||||
resize.height -= moveDeltaHeight;
|
||||
}
|
||||
else if ((myDirection & Position.SOUTH) != 0) {
|
||||
resize.height += moveDeltaHeight;
|
||||
}
|
||||
|
||||
int moveDeltaWidth = myCurrentScreenX - myStartScreenX;
|
||||
if ((myDirection & Position.WEST) != 0) {
|
||||
corner.x += moveDeltaWidth;
|
||||
resize.width -= moveDeltaWidth;
|
||||
}
|
||||
else if ((myDirection & Position.EAST) != 0) {
|
||||
resize.width += moveDeltaWidth;
|
||||
}
|
||||
|
||||
myContext.setMoveDelta(corner);
|
||||
myContext.setSizeDelta(resize);
|
||||
myContext.setLocation(new Point(myCurrentScreenX, myCurrentScreenY));
|
||||
}
|
||||
|
||||
private List<EditOperation> getOperations() {
|
||||
if (myOperations == null) {
|
||||
myContext.setComponents(new ArrayList<RadComponent>(myArea.getSelection()));
|
||||
myOperations = new ArrayList<EditOperation>();
|
||||
|
||||
for (RadComponent component : myContext.getComponents()) {
|
||||
EditOperation operation;
|
||||
RadComponent parent = component.getParent();
|
||||
if (parent == null) {
|
||||
operation = myArea.processRootOperation(myContext);
|
||||
}
|
||||
else {
|
||||
operation = parent.getLayout().processChildOperation(myContext);
|
||||
}
|
||||
if (operation != null) {
|
||||
myOperations.add(operation);
|
||||
operation.setComponent(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
return myOperations;
|
||||
}
|
||||
}
|
||||
+26
-22
@@ -32,26 +32,43 @@ import java.util.List;
|
||||
public class SelectionTool extends InputTool {
|
||||
private InputTool myTracker;
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
deactivateTracker();
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshCursor() {
|
||||
if (myTracker == null) {
|
||||
super.refreshCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonDown(int button) {
|
||||
if (myState == STATE_INIT) {
|
||||
myState = STATE_DRAG;
|
||||
deactivateTracker();
|
||||
|
||||
if (myInputEvent.isAltDown()) {
|
||||
setTracker(new MarqueeTracker());
|
||||
return;
|
||||
}
|
||||
if (!myArea.isTree()) {
|
||||
if (myInputEvent.isAltDown()) {
|
||||
setTracker(new MarqueeTracker());
|
||||
return;
|
||||
}
|
||||
|
||||
InputTool tracker = myArea.findTargetTool(myCurrentScreenX, myCurrentScreenY);
|
||||
if (tracker != null) {
|
||||
setTracker(tracker);
|
||||
return;
|
||||
InputTool tracker = myArea.findTargetTool(myCurrentScreenX, myCurrentScreenY);
|
||||
if (tracker != null) {
|
||||
setTracker(tracker);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RadComponent component = myArea.findTarget(myCurrentScreenX, myCurrentScreenY);
|
||||
if (component == null) {
|
||||
setTracker(new MarqueeTracker());
|
||||
if (!myArea.isTree()) {
|
||||
setTracker(new MarqueeTracker());
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTracker(component.getDragTracker());
|
||||
@@ -78,19 +95,6 @@ public class SelectionTool extends InputTool {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
deactivateTracker();
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshCursor() {
|
||||
if (myTracker == null) {
|
||||
super.refreshCursor();
|
||||
}
|
||||
}
|
||||
|
||||
private void setTracker(@Nullable InputTool tracker) {
|
||||
if (myTracker != tracker) {
|
||||
deactivateTracker();
|
||||
|
||||
+32
-2
@@ -36,6 +36,12 @@ public abstract class RadComponent {
|
||||
private RadLayout myLayout;
|
||||
private final Map<Object, Object> myClientProperties = new HashMap<Object, Object>();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Hierarchy
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public RadComponent getRoot() {
|
||||
return myParent == null ? this : myParent.getRoot();
|
||||
}
|
||||
@@ -56,15 +62,21 @@ public abstract class RadComponent {
|
||||
return getChildren().toArray();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Point convertPoint(Component component, int x, int y) {
|
||||
public Rectangle getBounds(Component relativeTo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Point convertPoint(int x, int y, Component component) {
|
||||
public Point convertPoint(Component relativeFrom, int x, int y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -72,6 +84,12 @@ public abstract class RadComponent {
|
||||
return new DragTracker(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// layout
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public RadLayout getLayout() {
|
||||
return myLayout;
|
||||
}
|
||||
@@ -85,6 +103,12 @@ public abstract class RadComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<Property> getProperties() {
|
||||
return null;
|
||||
}
|
||||
@@ -97,6 +121,12 @@ public abstract class RadComponent {
|
||||
myClientProperties.put(key, value);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visitor
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void accept(RadComponentVisitor visitor, boolean forward) {
|
||||
if (visitor.visit(this)) {
|
||||
List<RadComponent> children = getChildren();
|
||||
|
||||
@@ -16,10 +16,18 @@
|
||||
package com.intellij.designer.model;
|
||||
|
||||
import com.intellij.designer.designSurface.ComponentDecorator;
|
||||
import com.intellij.designer.designSurface.EditOperation;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class RadLayout {
|
||||
public abstract ComponentDecorator getChildSelectionDecorator(RadComponent component);
|
||||
|
||||
@Nullable
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,26 @@ public final class Cursors {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace on better cursor (self image)
|
||||
public static Cursor getMoveCursor() {
|
||||
try {
|
||||
return Cursor.getSystemCustomCursor("MoveDrop.32x32");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return Cursor.getDefaultCursor();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace on better cursor (self image)
|
||||
public static Cursor getCopyCursor() {
|
||||
try {
|
||||
return Cursor.getSystemCustomCursor("CopyDrop.32x32");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return Cursor.getDefaultCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Cursor getResizeCursor(int direction) {
|
||||
int cursor;
|
||||
|
||||
@@ -124,6 +124,7 @@ class XsContentDFA extends XmlContentDFA {
|
||||
}
|
||||
|
||||
private static QName createQName(XmlTag tag) {
|
||||
//todo don't use intern to not pollute PermGen
|
||||
String namespace = tag.getNamespace();
|
||||
return new QName(tag.getNamespacePrefix().intern(),
|
||||
tag.getLocalName().intern(),
|
||||
|
||||
Reference in New Issue
Block a user