Merge remote branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-01-26 20:38:13 +01:00
9 changed files with 170 additions and 131 deletions
@@ -177,6 +177,20 @@ class DependencyContext {
log.debug(comment + getValue(s));
}
}
@Override
public void debug(String comment, String t) {
if (log.isDebugEnabled()){
log.debug(comment + t);
}
}
@Override
public void debug(String comment, boolean t) {
if (log.isDebugEnabled()) {
log.debug(comment + Boolean.toString(t));
}
}
};
}
}
@@ -24,4 +24,6 @@ package org.jetbrains.ether.dependencyView;
*/
public interface Logger<T> {
void debug(String comment, T t);
void debug(String comment, String t);
void debug(String comment, boolean t);
}
@@ -1,13 +1,12 @@
package org.jetbrains.ether.dependencyView;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.Nullable;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes;
import com.intellij.openapi.diagnostic.Logger;
import org.jetbrains.annotations.*;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.ElementType;
@@ -22,7 +21,7 @@ import java.util.*;
* To change this template use File | Settings | File Templates.
*/
public class Mappings {
private final static Logger LOG = Logger.getInstance ("#org.jetbrains.ether.dependencyView.Mappings");
private final static Logger LOG = Logger.getInstance("#org.jetbrains.ether.dependencyView.Mappings");
private final static String CLASS_TO_SUBCLASSES = "classToSubclasses.tab";
private final static String CLASS_TO_CLASS = "classToClass.tab";
@@ -38,7 +37,7 @@ public class Mappings {
private DependencyContext myContext;
private org.jetbrains.ether.dependencyView.Logger<DependencyContext.S> myDebugS;
private void debug(final String s) {
private static void debug(final String s) {
LOG.debug(s);
}
@@ -46,6 +45,14 @@ public class Mappings {
myDebugS.debug(comment, s);
}
private void debug(final String comment, final String s) {
myDebugS.debug(comment, s);
}
private void debug(final String comment, final boolean s) {
myDebugS.debug(comment, s);
}
private MultiMaplet<DependencyContext.S, DependencyContext.S> myClassToSubclasses;
private MultiMaplet<DependencyContext.S, DependencyContext.S> myClassToClassDependency;
@@ -535,7 +542,7 @@ public class Mappings {
final Collection<DependencyContext.S> dependants,
final boolean usages) {
debug("Affecting subclasses of class: ", className);
final DependencyContext.S fileName = myClassToSourceFile.get(className);
if (fileName == null) {
@@ -588,6 +595,7 @@ public class Mappings {
dependents.addAll(deps);
}
debug("Affect field usage referenced of class ", p);
affectedUsages
.add(rootUsage instanceof UsageRepr.FieldAssignUsage ? field.createAssignUsage(myContext, p) : field.createUsage(myContext, p));
}
@@ -607,6 +615,8 @@ public class Mappings {
dependents.addAll(deps);
}
debug("Affect method usage referenced of class ", p);
affectedUsages
.add(rootUsage instanceof UsageRepr.MetaMethodUsage ? method.createMetaUsage(myContext, p) : method.createUsage(myContext, p));
}
@@ -752,16 +762,16 @@ public class Mappings {
for (DependencyContext.S className : propagated) {
final String fileName = myContext.getValue(myClassToSourceFile.get(className));
debug("Adding " + fileName);
debug("Adding ", fileName);
affectedFiles.add(new File(fileName));
}
}
final String packageName = ClassRepr.getPackageName(myContext.getValue(isField ? owner : member.name));
debug("Softening non-incremental decision: adding all package classes for a recompilation");
debug("Package name: " + packageName);
debug("Package name: ", packageName);
// Package-local branch
for (Map.Entry<DependencyContext.S, DependencyContext.S> e : myClassToSourceFile.entrySet()) {
final DependencyContext.S className = e.getKey();
@@ -769,7 +779,7 @@ public class Mappings {
if (ClassRepr.getPackageName(myContext.getValue(className)).equals(packageName)) {
final String f = myContext.getValue(fileName);
debug("Adding: " + f);
debug("Adding: ", f);
affectedFiles.add(new File(f));
}
}
@@ -783,7 +793,7 @@ public class Mappings {
final Collection<File> compiledFiles,
final Collection<File> affectedFiles) {
debug("Begin of Differentiate:");
delta.compensateRemovedContent(filesToCompile);
final Util u = new Util(delta);
@@ -830,16 +840,16 @@ public class Mappings {
final boolean signatureChanged = (diff.base() & Difference.SIGNATURE) > 0;
if (superClassChanged || interfacesChanged || signatureChanged) {
debug("Superclass changed: " + superClassChanged);
debug("Interfaces changed: " + interfacesChanged);
debug("Signature changed " + signatureChanged);
debug("Superclass changed: ", superClassChanged);
debug("Interfaces changed: ", interfacesChanged);
debug("Signature changed ", signatureChanged);
final boolean extendsChanged = superClassChanged && !diff.extendsAdded();
final boolean interfacesRemoved = interfacesChanged && !diff.interfaces().removed().isEmpty();
debug("Extends changed: " + extendsChanged);
debug("Interfaces removed: " + interfacesRemoved);
debug("Extends changed: ", extendsChanged);
debug("Interfaces removed: ", interfacesRemoved);
u.affectSubclasses(it.name, affectedFiles, affectedUsages, dependants, extendsChanged || interfacesRemoved || signatureChanged);
}
@@ -851,7 +861,7 @@ public class Mappings {
if (it.isAnnotation() && it.policy == RetentionPolicy.SOURCE) {
debug("Annotation, retention policy = SOURCE => a switch to non-incremental mode requested");
if (!incrementalDecision(it.outerClassName, it, affectedFiles)) {
debug("End of Differentiate, returning false");
debug("End of Differentiate, returning false");
return false;
}
}
@@ -884,7 +894,7 @@ public class Mappings {
if (it.isAnnotation()) {
debug("Class is annotation, performing annotation-specific analysis");
if (diff.retentionChanged()) {
debug("Retention policy change detected, adding class usage to affected usages");
affectedUsages.add(it.createUsage());
@@ -895,7 +905,7 @@ public class Mappings {
if (removedtargets.contains(ElementType.LOCAL_VARIABLE)) {
debug("Removed target contains LOCAL_VARIABLE => a switch to non-incremental mode requested");
if (!incrementalDecision(it.outerClassName, it, affectedFiles)) {
debug("End of Differentiate, returning false");
debug("End of Differentiate, returning false");
return false;
}
}
@@ -908,20 +918,20 @@ public class Mappings {
for (MethodRepr m : diff.methods().added()) {
if (!m.hasValue()) {
debug("Added method with no default value: " + m.name);
debug("Added method with no default value: ", m.name);
debug("Adding class usage to affected usages");
affectedUsages.add(it.createUsage());
}
}
}
debug("End of annotation-specific analysis");
}
debug("Processing added methods: ");
for (MethodRepr m : diff.methods().added()) {
debug("Method: ", m.name);
if (it.isAnnotation()) {
debug("Class is annotation, skipping method analysis");
continue;
@@ -977,10 +987,10 @@ public class Mappings {
else {
debug("Method: ", mm.name);
debug("Class : ", cc.name);
if (overrides.satisfy(mm)) {
debug("Current method overrides that found");
final Option<Boolean> subtypeOf = u.isSubtypeOf(mm.type, m.type);
if (weakerAccess(mm.access, m.access) ||
@@ -993,15 +1003,15 @@ public class Mappings {
final DependencyContext.S file = myClassToSourceFile.get(cc.name);
if (file != null) {
final String f = myContext.getValue(file);
debug("Complex condition is satisfied, affecting file " + f);
final String f = myContext.getValue(file);
debug("Complex condition is satisfied, affecting file ", f);
affectedFiles.add(new File(f));
}
}
}
else {
debug("Current method does not override that found");
final Collection<DependencyContext.S> yetPropagated = self.propagateMethodAccess(mm.name, cc.name);
final Collection<DependencyContext.S> deps = myClassToClassDependency.get(cc.name);
@@ -1025,9 +1035,9 @@ public class Mappings {
if (r != null && sourceFileName != null) {
final DependencyContext.S outerClass = r.outerClassName;
if (u.methodVisible(outerClass, m)) {
if (u.methodVisible(outerClass, m)) {
final String f = myContext.getValue(sourceFileName);
debug("Affecting file " + f + " due to local overriding");
debug("Affecting file due to local overriding: ", f);
affectedFiles.add(new File(f));
}
}
@@ -1036,11 +1046,11 @@ public class Mappings {
}
}
debug("End of added methods processing");
debug("Processing removed methods:");
debug("Processing removed methods:");
for (MethodRepr m : diff.methods().removed()) {
debug("Method ", m.name);
final Collection<Pair<MethodRepr, ClassRepr>> overridenMethods = u.findOverridenMethods(m, it);
final Collection<DependencyContext.S> propagated = u.propagateMethodAccess(m.name, it.name);
@@ -1104,8 +1114,10 @@ public class Mappings {
if (source != null) {
final String f = myContext.getValue(source);
debug("Removed method is not abstract & is overrides some abstract method which is not then over-overriden in subclass ", p);
debug("Affecting subclass source file " + f);
debug(
"Removed method is not abstract & is overrides some abstract method which is not then over-overriden in subclass ",
p);
debug("Affecting subclass source file ", f);
affectedFiles.add(new File(f));
}
}
@@ -1113,8 +1125,8 @@ public class Mappings {
}
}
}
debug("End of removed methods processing");
debug("End of removed methods processing");
debug("Processing changed methods:");
for (Pair<MethodRepr, Difference> mr : diff.methods().changed()) {
final MethodRepr m = mr.first;
@@ -1122,7 +1134,7 @@ public class Mappings {
final boolean throwsChanged = (d.exceptions().added().size() > 0) || (d.exceptions().changed().size() > 0);
debug("Method: ", m.name);
if (it.isAnnotation()) {
if (d.defaultRemoved()) {
debug("Class is annotation, default value is removed => adding annotation query");
@@ -1200,8 +1212,8 @@ public class Mappings {
}
}
}
debug("End of changed methods processing");
debug("End of changed methods processing");
final int mask = Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
debug("Processing added fields");
@@ -1216,32 +1228,34 @@ public class Mappings {
if (!fPrivate) {
final Collection<DependencyContext.S> subClasses = getAllSubclasses(it.name);
if (subClasses != null) {
for (final DependencyContext.S subClass : subClasses) {
final ClassRepr r = u.reprByName(subClass);
final DependencyContext.S sourceFileName = myClassToSourceFile.get(subClass);
for (final DependencyContext.S subClass : subClasses) {
final ClassRepr r = u.reprByName(subClass);
final DependencyContext.S sourceFileName = myClassToSourceFile.get(subClass);
if (r != null && sourceFileName != null) {
if (r.isLocal) {
if (r != null && sourceFileName != null) {
if (r.isLocal) {
debug("Affecting local subclass (introduced field can potentially hide surrounding method parameters/local variables): ",
sourceFileName);
affectedFiles.add(new File(myContext.getValue(sourceFileName)));
}
else {
final DependencyContext.S outerClass = r.outerClassName;
if (!empty(outerClass) && u.fieldVisible(outerClass, f)) {
debug("Affecting inner subclass (introduced field can potentially hide surrounding class fields): ", sourceFileName);
affectedFiles.add(new File(myContext.getValue(sourceFileName)));
}
else {
final DependencyContext.S outerClass = r.outerClassName;
if (!empty(outerClass) && u.fieldVisible(outerClass, f)) {
affectedFiles.add(new File(myContext.getValue(sourceFileName)));
}
}
}
}
final Collection<DependencyContext.S> propagated = u.propagateFieldAccess(f.name, subClass);
u.affectFieldUsages(f, propagated, f.createUsage(myContext, subClass), affectedUsages, dependants);
debug("Affecting field usages referenced from subclass ", subClass);
final Collection<DependencyContext.S> propagated = u.propagateFieldAccess(f.name, subClass);
u.affectFieldUsages(f, propagated, f.createUsage(myContext, subClass), affectedUsages, dependants);
final Collection<DependencyContext.S> deps = myClassToClassDependency.get(subClass);
final Collection<DependencyContext.S> deps = myClassToClassDependency.get(subClass);
if (deps != null) {
dependants.addAll(deps);
}
if (deps != null) {
dependants.addAll(deps);
}
}
}
@@ -1261,6 +1275,7 @@ public class Mappings {
final Collection<DependencyContext.S> propagated = o.propagateFieldAccess(ff.name, cc.name);
final Set<UsageRepr.Usage> localUsages = new HashSet<UsageRepr.Usage>();
debug("Affecting usages of overridden field in class ", cc.name);
u.affectFieldUsages(ff, propagated, ff.createUsage(myContext, cc.name), localUsages, dependants);
if (fPrivate || (fPublic && (ffPublic || ffPLocal)) || (fProtected && ffProtected) || (fPLocal && ffPLocal)) {
@@ -1290,7 +1305,7 @@ public class Mappings {
}
}
debug("End of added fields processing");
debug("Processing removed fields:");
for (FieldRepr f : diff.fields().removed()) {
debug("Field: ", it.name);
@@ -1298,7 +1313,7 @@ public class Mappings {
if ((f.access & Opcodes.ACC_PRIVATE) == 0 && (f.access & mask) == mask && f.hasValue()) {
debug("Field had value and was (non-private) final static => a switch to non-incremental mode requested");
if (!incrementalDecision(it.name, f, affectedFiles)) {
debug("End of Differentiate, returning false");
debug("End of Differentiate, returning false");
return false;
}
}
@@ -1318,8 +1333,8 @@ public class Mappings {
if ((field.access & Opcodes.ACC_PRIVATE) == 0 && (field.access & mask) == mask) {
if ((d.base() & Difference.ACCESS) > 0 || (d.base() & Difference.VALUE) > 0) {
debug("Inline field changed it's access or value => a switch to non-incremental mode requested");
if (!incrementalDecision(it.name, field, affectedFiles)){
debug("End of Differentiate, returning false");
if (!incrementalDecision(it.name, field, affectedFiles)) {
debug("End of Differentiate, returning false");
return false;
}
}
@@ -1371,10 +1386,10 @@ public class Mappings {
}
}
}
debug("End of changed fields processing");
debug("End of changed fields processing");
}
debug("End of changed classes processing");
debug("Processing removed classes:");
for (ClassRepr c : classDiff.removed()) {
debug("Adding usages of class ", c.name);
@@ -1392,7 +1407,7 @@ public class Mappings {
if (fName != null) {
final String f = myContext.getValue(fName);
debug("Adding dependent file " + f);
debug("Adding dependent file ", f);
affectedFiles.add(new File(f));
}
}
@@ -1420,7 +1435,7 @@ public class Mappings {
continue filewise;
}
debug("Dependent file: " + theFile.getAbsolutePath());
debug("Dependent file: ", depFile);
final Collection<UsageRepr.Cluster> depClusters = mySourceFileToUsages.get(depFile);
@@ -1474,15 +1489,13 @@ public class Mappings {
}
}
final Collection<File> removedFiles = new HashSet<File>();
for (String r : removed) {
removedFiles.add(new File(r));
if (removed != null) {
for (String r : removed) {
affectedFiles.remove(new File(r));
}
}
affectedFiles.removeAll(removedFiles);
debug("End of Differentiate, returning true");
debug("End of Differentiate, returning true");
return true;
}
@@ -1527,7 +1540,6 @@ public class Mappings {
}
}
myClassToSubclasses.putAll(delta.myClassToSubclasses);
mySourceFileToClasses.putAll(delta.mySourceFileToClasses);
mySourceFileToUsages.putAll(delta.mySourceFileToUsages);
@@ -268,10 +268,14 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder());
final DefaultActionGroup actions = new DefaultActionGroup();
actions.add(new BackAction());
actions.add(new ForwardAction());
final BackAction back = new BackAction();
final ForwardAction forward = new ForwardAction();
actions.add(back);
actions.add(forward);
actions.add(myExternalDocAction = new ExternalDocAction());
back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this);
forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this);
myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this);
if (additionalActions != null) {
for (final AnAction action : additionalActions) {
actions.add(action);
@@ -4,13 +4,13 @@
<file>StringBufferReplaceableByString.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant StringBuffer may be String</problem_class>
<description>Constant StringBuffer &lt;code&gt;builder&lt;/code&gt; may be declared as String #loc</description>
<description>Constant &lt;code&gt;StringBuilder builder&lt;/code&gt; may be declared as 'String' #loc</description>
</problem>
<problem>
<file>StringBufferReplaceableByString.java</file>
<line>7</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant StringBuffer may be String</problem_class>
<description>Constant StringBuffer &lt;code&gt;buffer&lt;/code&gt; may be declared as String #loc</description>
<description>Constant &lt;code&gt;StringBuffer buffer&lt;/code&gt; may be declared as 'String' #loc</description>
</problem>
</problems>
+2 -2
View File
@@ -115,8 +115,8 @@
<add-to-group anchor="last" group-id="GenerateGroup"/>
</action>
<action internal="true" class="org.jetbrains.idea.devkit.actions.GenerateHighlightingMarkupAction" text="Generate Expected Highlighting Markup"
id="GenerateHighlightingMarkup">
<action internal="true" class="org.jetbrains.idea.devkit.actions.ToggleHighlightingMarkupAction" text="Toggle Expected Highlighting Markup"
id="ToggleHighlightingMarkup">
<add-to-group anchor="last" group-id="Internal"/>
</action>
@@ -41,7 +41,7 @@ import java.util.regex.Pattern;
/**
* @author gregsh
*/
public class GenerateHighlightingMarkupAction extends AnAction {
public class ToggleHighlightingMarkupAction extends AnAction {
@Override
public void update(AnActionEvent e) {
Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext());
@@ -59,7 +59,7 @@ public class GenerateHighlightingMarkupAction extends AnAction {
Object commandToken = commandProcessor.startCommand(project, e.getPresentation().getText(), e.getPresentation().getText(), UndoConfirmationPolicy.DEFAULT);
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
perform(project, editor.getDocument(), true);
perform(project, editor.getDocument());
}
finally {
token.finish();
@@ -67,16 +67,27 @@ public class GenerateHighlightingMarkupAction extends AnAction {
}
}
private static void perform(Project project, final Document document, final boolean compact) {
private static void perform(Project project, final Document document) {
final CharSequence sequence = document.getCharsSequence();
final StringBuilder sb = new StringBuilder();
Pattern pattern = Pattern.compile("<(error|warning|EOLError|EOLWarning)(?:\\s|=|\\w+|\\\"(?:[^\"]|\\\\\\\")*?\\\")*>(.*?)</\\1>");
Pattern pattern = Pattern.compile("<(error|warning|EOLError|EOLWarning)((?:\\s|=|\\w+|\\\"(?:[^\"]|\\\\\\\")*?\\\")*?)>(.*?)</\\1>");
Matcher matcher = pattern.matcher(sequence);
if (matcher.find()) {
boolean compactMode = false;
int pos = 0;
do {
sb.append(sequence, pos, matcher.start(0));
sb.append(sequence, matcher.start(2), matcher.end(2));
if (matcher.start(2) < matcher.end(2)) {
if (!compactMode) {
sb.setLength(pos = 0);
compactMode = true;
}
sb.append(sequence, pos, matcher.start(2));
sb.append(sequence, matcher.end(2), matcher.end(0));
}
else if (!compactMode) {
sb.append(sequence, pos, matcher.start(0));
sb.append(sequence, matcher.start(3), matcher.end(3));
}
pos = matcher.end(0);
}
while (matcher.find(pos));
@@ -91,11 +102,11 @@ public class GenerateHighlightingMarkupAction extends AnAction {
@Override
public boolean process(HighlightInfo info) {
if (info.severity != HighlightSeverity.WARNING && info.severity != HighlightSeverity.ERROR) return true;
offset[0] = appendInfo(info, sb, sequence, offset[0], infos, compact);
offset[0] = appendInfo(info, sb, sequence, offset[0], infos, false);
return true;
}
});
offset[0] = appendInfo(null, sb, sequence, offset[0], infos, compact);
offset[0] = appendInfo(null, sb, sequence, offset[0], infos, false);
sb.append(sequence.subSequence(offset[0], sequence.length()));
}
document.setText(sb);
@@ -21,9 +21,11 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import com.intellij.psi.*;
import com.intellij.ui.AutoScrollFromSourceHandler;
import com.intellij.ui.AutoScrollToSourceHandler;
import com.intellij.ui.content.ContentManager;
import com.intellij.util.Alarm;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.containers.ContainerUtil;
@@ -67,7 +69,7 @@ import java.util.List;
*/
public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements IdeView {
private final CopyPasteDelegator myCopyPasteDelegator;
private final JPanel myComponent;
private final JComponent myComponent;
private final DeleteProvider myDeletePSIElementProvider;
private final ModuleDeleteProvider myDeleteModuleProvider = new ModuleDeleteProvider();
@@ -120,9 +122,7 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
project.getMessageBus().connect(this).subscribe(PsiModificationTracker.TOPIC, new TreeUpdater());
myComponent = new JPanel(new BorderLayout());
myComponent.add(createComponent(), BorderLayout.CENTER);
myComponent.add(createToolbar(), BorderLayout.NORTH);
myComponent = createComponent();
DataManager.registerDataProvider(myComponent, this);
myCopyPasteDelegator = new CopyPasteDelegator(project, myComponent) {
@@ -135,18 +135,33 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
myDeletePSIElementProvider = new DeleteHandler.DefaultDeleteProvider();
}
private JComponent createToolbar() {
public void setup(ToolWindowEx toolWindow) {
JPanel p = new JPanel(new BorderLayout());
p.add(myComponent, BorderLayout.CENTER);
ContentManager contentManager = toolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(p, null, false);
content.setDisposer(this);
content.setCloseable(false);
content.setPreferredFocusableComponent(createComponent());
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
DefaultActionGroup group = new DefaultActionGroup();
group.add(new HideEmptyMiddlePackagesAction());
group.add(myAutoScrollToSourceHandler.createToggleAction());
group.add(myAutoScrollFromSourceHandler.createToggleAction());
final TreeExpander expander = new DefaultTreeExpander(myTree);
final CommonActionsManager actionsManager = CommonActionsManager.getInstance();
group.addAction(new ScrollFromSourceAction());
group.addAction(myAutoScrollFromSourceHandler.createToggleAction()).setAsSecondary(true);
group.addAction(myAutoScrollToSourceHandler.createToggleAction()).setAsSecondary(true);
group.add(actionsManager.createCollapseAllAction(expander, myTree));
group.addAction(new HideEmptyMiddlePackagesAction()).setAsSecondary(true);
toolWindow.setAdditionalGearActions(group);
return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
TreeExpander expander = new DefaultTreeExpander(myTree);
CommonActionsManager actionsManager = CommonActionsManager.getInstance();
AnAction collapseAction = actionsManager.createCollapseAllAction(expander, myTree);
collapseAction.getTemplatePresentation().setIcon(IconLoader.getIcon("/general/collapseAll.png"));
toolWindow.setTitleActions(new AnAction[]{new ScrollFromSourceAction(), collapseAction});
}
@Override
@@ -158,10 +173,6 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
return component;
}
public JPanel getComponent() {
return myComponent;
}
public String getTitle() {
throw new UnsupportedOperationException();
}
@@ -436,10 +447,9 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
scrollFromSource();
}
private class ScrollFromSourceAction extends AnAction implements DumbAware {
private ScrollFromSourceAction() {
super("Scroll from Source", "Select the file open in the active editor", IconLoader.getIcon("/general/autoscrollFromSource.png"));
super("Scroll from Source", "Select the file open in the active editor", IconLoader.getIcon("/general/locate.png"));
}
@Override
@@ -475,7 +485,7 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
public void run() {
if (myProject.isDisposed() || !getComponent().isShowing()) return;
if (myProject.isDisposed() || !myComponent.isShowing()) return;
if (myAutoScrollFromSource) {
selectElementAtCaretNotLosingFocus();
}
@@ -25,17 +25,15 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.mvc.MvcFramework;
import org.jetbrains.plugins.groovy.mvc.MvcModuleStructureUtil;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.List;
/**
@@ -58,20 +56,8 @@ public abstract class MvcToolWindowDescriptor implements ToolWindowFactory, Cond
toolWindow.setToHideOnEmptyContent(true);
toolWindow.setTitle(myFramework.getDisplayName());
final MvcProjectViewPane view = new MvcProjectViewPane(project, this);
final JPanel p = new JPanel(new BorderLayout());
p.add(view.getComponent(), BorderLayout.CENTER);
final ContentManager contentManager = toolWindow.getContentManager();
final Content content = contentManager.getFactory().createContent(p, null, false);
content.setDisposer(view);
content.setCloseable(false);
content.setPreferredFocusableComponent(view.createComponent());
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
MvcProjectViewPane view = new MvcProjectViewPane(project, this);
view.setup((ToolWindowEx)toolWindow);
}
public boolean value(Project project) {