mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Merge remote branch 'origin/master'
Conflicts: platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
@@ -108,6 +109,11 @@ class CompAPIDriver {
|
||||
finally {
|
||||
compiling = false;
|
||||
myCompilationResults.offer(GUARD);
|
||||
try {
|
||||
manager.close();
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -30,7 +30,6 @@ import java.net.URI;
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
@SuppressWarnings({"Since15"})
|
||||
abstract class CompilationEvent {
|
||||
protected abstract void process(OutputParser.Callback callback);
|
||||
static CompilationEvent progress(final String title, final JavaFileObject fileObject) {
|
||||
@@ -111,16 +110,18 @@ abstract class CompilationEvent {
|
||||
}
|
||||
|
||||
public static CompilationEvent fileProcessed() {
|
||||
return new CompilationEvent() {
|
||||
@Override
|
||||
protected void process(OutputParser.Callback callback) {
|
||||
callback.fileProcessed(null);
|
||||
}
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Processed";
|
||||
}
|
||||
};
|
||||
return FILE_PROCESSED;
|
||||
}
|
||||
private static final CompilationEvent FILE_PROCESSED = new CompilationEvent() {
|
||||
@Override
|
||||
protected void process(OutputParser.Callback callback) {
|
||||
callback.fileProcessed(null);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Processed";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+41
-1
@@ -2,6 +2,7 @@ package com.intellij.codeInsight.editorActions.smartEnter;
|
||||
|
||||
import com.intellij.javadoc.JavadocHelper;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -44,7 +45,33 @@ public class JavadocFixer {
|
||||
|
||||
final JavadocHelper.JavadocParameterInfo next = findNext(pair.second, pair.first);
|
||||
if (next == null) {
|
||||
return false;
|
||||
final int line = pair.first.lastLine + 1;
|
||||
final Document document = editor.getDocument();
|
||||
if (line < document.getLineCount()) {
|
||||
StringBuilder indent = new StringBuilder();
|
||||
boolean insertIndent = true;
|
||||
final CharSequence text = document.getCharsSequence();
|
||||
for (int i = document.getLineStartOffset(line), max = document.getLineEndOffset(line); i < max; i++) {
|
||||
final char c = text.charAt(i);
|
||||
if (c == ' ' || c == '\t') {
|
||||
indent.append(c);
|
||||
continue;
|
||||
}
|
||||
else if (c == '*') {
|
||||
indent.append("* ");
|
||||
if (i < max - 1 && text.charAt(i + 1) != '/') {
|
||||
insertIndent = false;
|
||||
}
|
||||
}
|
||||
indent.append("\n");
|
||||
break;
|
||||
}
|
||||
if (insertIndent) {
|
||||
document.insertString(document.getLineStartOffset(line), indent);
|
||||
}
|
||||
}
|
||||
moveCaretToTheLineEndIfPossible(editor, line);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (next.parameterDescriptionStartPosition != null) {
|
||||
@@ -57,6 +84,19 @@ public class JavadocFixer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void moveCaretToTheLineEndIfPossible(@NotNull Editor editor, int line) {
|
||||
final Document document = editor.getDocument();
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
int offset;
|
||||
if (line >= document.getLineCount()) {
|
||||
offset = document.getTextLength();
|
||||
}
|
||||
else {
|
||||
offset = document.getLineEndOffset(line);
|
||||
}
|
||||
caretModel.moveToOffset(offset);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JavadocHelper.JavadocParameterInfo findNext(@NotNull Collection<JavadocHelper.JavadocParameterInfo> data,
|
||||
@NotNull JavadocHelper.JavadocParameterInfo anchor)
|
||||
|
||||
@@ -39,6 +39,11 @@ public class EnterInJavadocParamDescriptionHandler extends EnterHandlerDelegateA
|
||||
}
|
||||
|
||||
final LogicalPosition caretPosition = caretModel.getLogicalPosition();
|
||||
final LogicalPosition nameEndPosition = pair.first.parameterNameEndPosition;
|
||||
if (nameEndPosition.line == caretPosition.line && caretPosition.column <= nameEndPosition.column) {
|
||||
return Result.Continue;
|
||||
}
|
||||
|
||||
final int descriptionStartColumn = pair.first.parameterDescriptionStartPosition.column;
|
||||
final LogicalPosition desiredPosition = new LogicalPosition(caretPosition.line, descriptionStartColumn);
|
||||
final Document document = editor.getDocument();
|
||||
|
||||
@@ -205,14 +205,19 @@ public class JavadocHelper {
|
||||
if (elementType == JavaDocTokenType.DOC_COMMENT_DATA) {
|
||||
return new JavadocParameterInfo(
|
||||
editor.offsetToLogicalPosition(paramRef.getTextRange().getEndOffset()),
|
||||
editor.offsetToLogicalPosition(e.getTextRange().getStartOffset())
|
||||
editor.offsetToLogicalPosition(e.getTextRange().getStartOffset()),
|
||||
editor.getDocument().getLineNumber(e.getTextRange().getEndOffset())
|
||||
);
|
||||
}
|
||||
else if (elementType == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new JavadocParameterInfo(editor.offsetToLogicalPosition(paramRef.getTextRange().getEndOffset()), null);
|
||||
return new JavadocParameterInfo(
|
||||
editor.offsetToLogicalPosition(paramRef.getTextRange().getEndOffset()),
|
||||
null,
|
||||
editor.getDocument().getLineNumber(paramRef.getTextRange().getEndOffset())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,10 +237,16 @@ public class JavadocHelper {
|
||||
*/
|
||||
@NotNull public final LogicalPosition parameterNameEndPosition;
|
||||
@Nullable public final LogicalPosition parameterDescriptionStartPosition;
|
||||
/** Last logical line occupied by the current javadoc parameter. */
|
||||
public final int lastLine;
|
||||
|
||||
public JavadocParameterInfo(@NotNull LogicalPosition parameterNameEndPosition, LogicalPosition parameterDescriptionStartPosition) {
|
||||
public JavadocParameterInfo(@NotNull LogicalPosition parameterNameEndPosition,
|
||||
LogicalPosition parameterDescriptionStartPosition,
|
||||
int lastLine)
|
||||
{
|
||||
this.parameterNameEndPosition = parameterNameEndPosition;
|
||||
this.parameterDescriptionStartPosition = parameterDescriptionStartPosition;
|
||||
this.lastLine = lastLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i desc
|
||||
* @param j desc<caret>
|
||||
*/
|
||||
void test(int i, int j) {
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i desc
|
||||
* @param j desc<caret>
|
||||
* @return
|
||||
*/
|
||||
int test(int i, int j) {
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i desc
|
||||
* @param j desc
|
||||
* @return<caret>
|
||||
*/
|
||||
int test(int i, int j) {
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i desc
|
||||
* @param j desc
|
||||
* <caret>
|
||||
*/
|
||||
void test(int i, int j) {
|
||||
}
|
||||
}
|
||||
@@ -223,6 +223,10 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testFromJavadocParameterDescriptionEndToNextParameter() throws Exception { doTest(); }
|
||||
|
||||
public void testFromJavadocParameterDescriptionMiddleToNextParameter() throws Exception { doTest(); }
|
||||
|
||||
public void testLastJavadocParameterDescription() throws Exception { doTest(); }
|
||||
|
||||
public void testLastJavadocParameterDescriptionToReturn() throws Exception { doTest(); }
|
||||
|
||||
private void doTestBracesNextLineStyle() throws Exception {
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.concurrency.JobUtil;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
@@ -110,7 +111,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
int oldWidth = myDelegateIcon.getIconWidth();
|
||||
myDelegateIcon = evaluate();
|
||||
|
||||
final boolean shouldRevalidate = myDelegateIcon.getIconWidth() != oldWidth;
|
||||
final boolean shouldRevalidate = Registry.is("ide.tree.deferredicon.invalidates.cache") && myDelegateIcon.getIconWidth() != oldWidth;
|
||||
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@@ -17,7 +17,8 @@ package com.intellij.lexer;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.ImmutableUserMap;
|
||||
import com.intellij.util.containers.Queue;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -28,8 +29,8 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
|
||||
private final Lexer myBaseLexer;
|
||||
private int myTokenStart;
|
||||
private final Queue<IElementType> myTypeCache = new Queue<IElementType>(50);
|
||||
private final Queue<Integer> myEndOffsetCache = new Queue<Integer>(50);
|
||||
private final LinkedList<IElementType> myTypeCache = new LinkedList<IElementType>();
|
||||
private final LinkedList<Integer> myEndOffsetCache = new LinkedList<Integer>();
|
||||
|
||||
public LookAheadLexer(final Lexer baseLexer) {
|
||||
myBaseLexer = baseLexer;
|
||||
@@ -40,8 +41,8 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
}
|
||||
|
||||
protected void addToken(int endOffset, IElementType type) {
|
||||
myTypeCache.addLast(type);
|
||||
myEndOffsetCache.addLast(endOffset);
|
||||
myTypeCache.add(type);
|
||||
myEndOffsetCache.add(endOffset);
|
||||
}
|
||||
|
||||
protected void lookAhead(Lexer baseLexer) {
|
||||
@@ -50,8 +51,8 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
|
||||
public void advance() {
|
||||
if (!myTypeCache.isEmpty()) {
|
||||
myTypeCache.pullFirst();
|
||||
myTokenStart = myEndOffsetCache.pullFirst();
|
||||
myTypeCache.removeFirst();
|
||||
myTokenStart = myEndOffsetCache.removeFirst();
|
||||
}
|
||||
if (myTypeCache.isEmpty()) {
|
||||
doLookAhead();
|
||||
@@ -80,8 +81,8 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
|
||||
protected void resetCacheSize(int size) {
|
||||
while (myTypeCache.size() > size) {
|
||||
myTypeCache.pullFirst();
|
||||
myEndOffsetCache.pullFirst();
|
||||
myTypeCache.removeLast();
|
||||
myEndOffsetCache.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
}
|
||||
|
||||
public int getTokenEnd() {
|
||||
return myEndOffsetCache.peekFirst();
|
||||
return myEndOffsetCache.getFirst();
|
||||
}
|
||||
|
||||
public int getTokenStart() {
|
||||
@@ -114,7 +115,7 @@ public abstract class LookAheadLexer extends LexerBase{
|
||||
}
|
||||
|
||||
public IElementType getTokenType() {
|
||||
return myTypeCache.peekFirst();
|
||||
return myTypeCache.getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import com.intellij.openapi.diff.DirDiffManager;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
@@ -63,7 +62,7 @@ public class CompareDirectoriesAction extends AnAction {
|
||||
public void update(AnActionEvent e) {
|
||||
final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
if (files != null && files.length > 0 && files.length < 3) {
|
||||
if (files[0].isDirectory() && (files.length == 1 || files[1].isDirectory()) && files[0].getFileSystem() == LocalFileSystem.getInstance()) {
|
||||
if (files[0].isDirectory() && (files.length == 1 || files[1].isDirectory())) {
|
||||
e.getPresentation().setEnabled(true);
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setText(files.length == 1 ? "Compare Directory with..." : "Compare Directories");
|
||||
|
||||
+2
-3
@@ -364,9 +364,8 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
return Pair.create(myInfoPanel.getText(), myCurrentRequestor);
|
||||
}
|
||||
|
||||
final boolean logMode = StringUtil.isEmpty(text) && !hasProgressIndicators();
|
||||
myInfoPanel.updateText(logMode, text);
|
||||
myCurrentRequestor = logMode ? requestor : null;
|
||||
boolean logMode = myInfoPanel.updateText(!hasProgressIndicators(), text);
|
||||
myCurrentRequestor = logMode ? null : requestor;
|
||||
return Pair.create(text, requestor);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.wm.impl.status;
|
||||
|
||||
import com.intellij.notification.impl.NotificationsManagerImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -38,6 +39,7 @@ import java.util.Date;
|
||||
* @author peter
|
||||
*/
|
||||
class StatusPanel extends JPanel {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.status.StatusPanel");
|
||||
private static final Icon ourShowLogIcon = IconLoader.getIcon("/general/hideSideUp.png");
|
||||
private static final Icon ourHideLogIcon = IconLoader.getIcon("/general/hideSideDown.png");
|
||||
private boolean myLogMode;
|
||||
@@ -53,6 +55,8 @@ class StatusPanel extends JPanel {
|
||||
|
||||
setOpaque(isOpaque() && !SystemInfo.isMac);
|
||||
|
||||
myShowLog.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
|
||||
|
||||
myShowLog.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -89,17 +93,18 @@ class StatusPanel extends JPanel {
|
||||
myDirty = false;
|
||||
}
|
||||
|
||||
public void updateText(boolean logMode, @Nullable String nonLogText) {
|
||||
myLogMode = logMode;
|
||||
public boolean updateText(boolean logAllowed, @Nullable String nonLogText) {
|
||||
myLogMode = logAllowed && StringUtil.isEmpty(nonLogText) && myLogMessage != null;
|
||||
|
||||
myShowLog.setVisible(logMode);
|
||||
myShowLog.setVisible(myLogMode);
|
||||
|
||||
if (logMode) {
|
||||
if (myLogMode) {
|
||||
LOG.assertTrue(myLogTime != null);
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String text = myLogMessage;
|
||||
if (myLogTime != null && (myDirty || System.currentTimeMillis() - myLogTime.getTime() >= DateFormatUtil.MINUTE)) {
|
||||
if (myDirty || System.currentTimeMillis() - myLogTime.getTime() >= DateFormatUtil.MINUTE) {
|
||||
text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(myLogTime)) + ")";
|
||||
}
|
||||
myTextPanel.setText(text);
|
||||
@@ -127,7 +132,7 @@ class StatusPanel extends JPanel {
|
||||
myTextPanel.setText(nonLogText);
|
||||
myLogAlarm.cancelAllRequests();
|
||||
}
|
||||
|
||||
return myLogMode;
|
||||
}
|
||||
|
||||
public void hideLog() {
|
||||
|
||||
@@ -63,6 +63,7 @@ ide.tree.autoExpandMaxDepth=5
|
||||
ide.tree.expandRecursionDepth=50
|
||||
ide.tree.checkStructure=false
|
||||
ide.tree.uiLockAttempt=250
|
||||
ide.tree.deferredicon.invalidates.cache=true
|
||||
|
||||
ide.splitter.mouseZone=6
|
||||
ide.smart.horizontal.scrolling=true
|
||||
|
||||
@@ -194,7 +194,14 @@ public class LeakHunter {
|
||||
String place = leaked instanceof Project ? PlatformTestCase.getCreationPlace((Project)leaked) : "";
|
||||
System.out.println("LEAK: hash: "+System.identityHashCode(leaked) + "; place: "+ place);
|
||||
while (backLink != null) {
|
||||
System.out.println("-->"+backLink.field+"; Value: "+backLink.value+"; "+backLink.aClass);
|
||||
String valueStr;
|
||||
try {
|
||||
valueStr = String.valueOf(leaked);
|
||||
}
|
||||
catch (Exception e) {
|
||||
valueStr = "("+e.getMessage()+" while computing .toString())";
|
||||
}
|
||||
System.out.println("-->"+backLink.field+"; Value: "+ valueStr +"; "+backLink.aClass);
|
||||
backLink = backLink.backLink;
|
||||
}
|
||||
System.out.println(";-----");
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBLoadingPanel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.diff.FilesTooBigForDiffException;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -94,14 +95,16 @@ public class DirDiffPanel implements Disposable {
|
||||
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
final DirDiffElement last = myModel.getElementAt(e.getLastIndex());
|
||||
final DirDiffElement first = myModel.getElementAt(e.getFirstIndex());
|
||||
final int lastIndex = e.getLastIndex();
|
||||
final int firstIndex = e.getFirstIndex();
|
||||
final DirDiffElement last = myModel.getElementAt(lastIndex);
|
||||
final DirDiffElement first = myModel.getElementAt(firstIndex);
|
||||
if (last == null || first == null) return;
|
||||
if (last.isSeparator()) {
|
||||
myTable.getSelectionModel().setLeadSelectionIndex(e.getFirstIndex());
|
||||
myTable.getSelectionModel().setLeadSelectionIndex(lastIndex + ((lastIndex < firstIndex) ? 1 : -1));
|
||||
}
|
||||
else if (first.isSeparator()) {
|
||||
myTable.getSelectionModel().setLeadSelectionIndex(e.getLastIndex());
|
||||
myTable.getSelectionModel().setLeadSelectionIndex(firstIndex + ((firstIndex < lastIndex) ? 1 : -1));
|
||||
}
|
||||
else {
|
||||
update(false);
|
||||
@@ -284,8 +287,6 @@ public class DirDiffPanel implements Disposable {
|
||||
myCurrentElement = element.getSource();
|
||||
} else {
|
||||
myDiffPanel.add(getErrorLabel(), BorderLayout.CENTER);
|
||||
myDiffPanel.revalidate();
|
||||
myDiffPanel.repaint();
|
||||
}
|
||||
} else {
|
||||
final DiffElement object;
|
||||
@@ -300,14 +301,12 @@ public class DirDiffPanel implements Disposable {
|
||||
myCurrentElement = object;
|
||||
myDiffPanel.add(myViewComponent, BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(myDiffPanel, myCurrentElement.getDataProvider(project));
|
||||
myDiffPanel.revalidate();
|
||||
myDiffPanel.repaint();
|
||||
} else {
|
||||
myDiffPanel.add(getErrorLabel(), BorderLayout.CENTER);
|
||||
myDiffPanel.revalidate();
|
||||
myDiffPanel.repaint();
|
||||
}
|
||||
}
|
||||
myDiffPanel.revalidate();
|
||||
myDiffPanel.repaint();
|
||||
}
|
||||
|
||||
private void registerCustomShortcuts(DirDiffToolbarActions actions, JPanel rootPanel) {
|
||||
|
||||
@@ -113,6 +113,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
myUpdating.set(false);
|
||||
selectFirstRow();
|
||||
myPanel.focusTable();
|
||||
myPanel.update(true);
|
||||
}
|
||||
|
||||
private void selectFirstRow() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class MutablyNamedIntention extends Intention{
|
||||
@Override
|
||||
@NotNull
|
||||
public final String getText(){
|
||||
return m_text;
|
||||
return m_text == null ? "" : m_text;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,11 +128,11 @@
|
||||
<annotator language="XML" implementationClass="org.jetbrains.android.AndroidColorAnnotator" order="first"/>
|
||||
<xml.elementDescriptorProvider implementation="org.jetbrains.android.dom.AndroidDomElementDescriptorProvider" order="first"/>
|
||||
|
||||
<toolWindow id="Android Logcat"
|
||||
anchor="bottom"
|
||||
icon="/icons/android.png"
|
||||
factoryClass="org.jetbrains.android.logcat.AndroidLogcatToolWindowFactory"
|
||||
conditionClass="org.jetbrains.android.logcat.AndroidLogcatToolWindowFactory"/>
|
||||
<facet.toolWindow id="Android Logcat"
|
||||
facetIdList="android"
|
||||
anchor="bottom"
|
||||
icon="/icons/android.png"
|
||||
factoryClass="org.jetbrains.android.logcat.AndroidLogcatToolWindowFactory"/>
|
||||
<projectService serviceInterface="org.jetbrains.android.logcat.AndroidLogcatFiltersPreferences"
|
||||
serviceImplementation="org.jetbrains.android.logcat.AndroidLogcatFiltersPreferences"/>
|
||||
<xml.xmlExtension implementation="org.jetbrains.android.dom.AndroidXmlExtension" order="first"/>
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
package org.jetbrains.android;
|
||||
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import org.jetbrains.android.logcat.AndroidLogcatToolWindowFactory;
|
||||
import org.jetbrains.android.sdk.AndroidSdk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -28,7 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author coyote
|
||||
*/
|
||||
public class AndroidPlugin implements ApplicationComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.AndroidPlugin");
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
@@ -36,12 +30,6 @@ public class AndroidPlugin implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectOpened(final Project project) {
|
||||
new AndroidLogcatToolWindowFactory().configureToolWindow(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
|
||||
+4
-46
@@ -18,21 +18,13 @@ package org.jetbrains.android.logcat;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.facet.ProjectWideFacetAdapter;
|
||||
import com.intellij.facet.ProjectWideFacetListenersRegistry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
@@ -46,10 +38,11 @@ import java.util.List;
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class AndroidLogcatToolWindowFactory implements ToolWindowFactory, Condition<Project> {
|
||||
public class AndroidLogcatToolWindowFactory implements ToolWindowFactory {
|
||||
public static final String TOOL_WINDOW_ID = AndroidBundle.message("android.logcat.title");
|
||||
|
||||
public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
|
||||
toolWindow.setSplitMode(true, null);
|
||||
toolWindow.setIcon(AndroidUtils.ANDROID_ICON);
|
||||
toolWindow.setAvailable(true, null);
|
||||
toolWindow.setToHideOnEmptyContent(true);
|
||||
@@ -108,39 +101,4 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory, Condit
|
||||
Messages.showErrorDialog(project, AndroidBundle.message("specify.platform.error"), CommonBundle.getErrorTitle());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean value(Project project) {
|
||||
ModuleManager manager = ModuleManager.getInstance(project);
|
||||
for (Module module : manager.getModules()) {
|
||||
AndroidFacet facet = AndroidFacet.getInstance(module);
|
||||
if (facet != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void configureToolWindow(final Project project) {
|
||||
ProjectWideFacetListenersRegistry.getInstance(project)
|
||||
.registerListener(AndroidFacet.ID, new ProjectWideFacetAdapter<AndroidFacet>() {
|
||||
@Override
|
||||
public void firstFacetAdded() {
|
||||
final ToolWindowManager manager = ToolWindowManager.getInstance(project);
|
||||
final ToolWindow toolWindow = manager.getToolWindow(AndroidLogcatToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (toolWindow == null) {
|
||||
final ToolWindow window =
|
||||
manager.registerToolWindow(AndroidLogcatToolWindowFactory.TOOL_WINDOW_ID, false, ToolWindowAnchor.BOTTOM, project);
|
||||
window.setSplitMode(true, null);
|
||||
createToolWindowContent(project, window);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allFacetsRemoved() {
|
||||
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(AndroidLogcatToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (toolWindow != null) {
|
||||
ToolWindowManager.getInstance(project).unregisterToolWindow(AndroidLogcatToolWindowFactory.TOOL_WINDOW_ID);
|
||||
Disposer.dispose(toolWindow.getContentManager());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user