Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
164c4f68
Commit
164c4f68
authored
12 years ago
by
Vassiliy Kudryashov
Committed by
Kirill Safonov
12 years ago
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-101196 Find: can't exclude
parent
2ca55f8e
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/usageView/src/com/intellij/usages/impl/Node.java
+15
-55
platform/usageView/src/com/intellij/usages/impl/Node.java
platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
+15
-38
...usageView/src/com/intellij/usages/impl/UsageViewImpl.java
with
30 additions
and
93 deletions
+30
-93
platform/usageView/src/com/intellij/usages/impl/Node.java
+
15
-
55
View file @
164c4f68
...
...
@@ -17,7 +17,6 @@ package com.intellij.usages.impl;
import
com.intellij.openapi.util.Comparing
;
import
com.intellij.usages.UsageView
;
import
org.intellij.lang.annotations.MagicConstant
;
import
org.jetbrains.annotations.NotNull
;
import
javax.swing.tree.DefaultMutableTreeNode
;
...
...
@@ -27,28 +26,11 @@ import javax.swing.tree.DefaultTreeModel;
* @author max
*/
public
abstract
class
Node
extends
DefaultMutableTreeNode
{
private
boolean
myIsValid
=
true
;
protected
final
DefaultTreeModel
myTreeModel
;
private
String
myText
;
private
byte
flags
;
private
static
final
int
INVALID_FLAG
=
0
;
private
static
final
int
READ_ONLY_FLAG
=
1
;
private
static
final
int
READ_ONLY_COMPUTED_FLAG
=
2
;
private
static
final
int
EXCLUDED_FLAG
=
3
;
private
static
final
int
UPDATED_FLAG
=
4
;
@MagicConstant
(
intValues
=
{
INVALID_FLAG
,
READ_ONLY_FLAG
,
READ_ONLY_COMPUTED_FLAG
,
EXCLUDED_FLAG
,
UPDATED_FLAG
})
@interface
FlagConstant
{}
private
boolean
isFlagSet
(
@FlagConstant
int
flag
)
{
int
state
=
flags
>>
flag
;
return
(
state
&
1
)
!=
0
;
}
private
void
setFlag
(
@FlagConstant
int
flag
,
boolean
value
)
{
int
state
=
value
?
1
:
0
;
flags
=
(
byte
)(
flags
&
~(
1
<<
flag
)
|
state
<<
flag
);
}
private
Boolean
myIsReadOnly
=
null
;
private
boolean
myExcluded
=
false
;
private
String
myText
=
null
;
protected
Node
(
@NotNull
DefaultTreeModel
model
)
{
myTreeModel
=
model
;
...
...
@@ -62,57 +44,35 @@ public abstract class Node extends DefaultMutableTreeNode {
protected
abstract
boolean
isDataValid
();
protected
abstract
boolean
isDataReadOnly
();
protected
abstract
boolean
isDataExcluded
();
protected
abstract
String
getText
(
@NotNull
UsageView
view
);
protected
abstract
String
getText
(
UsageView
view
);
public
final
boolean
isValid
()
{
return
!
isFlagSet
(
INVALID_FLAG
)
;
return
myIsValid
;
}
public
final
boolean
isReadOnly
()
{
boolean
result
;
boolean
computed
=
isFlagSet
(
READ_ONLY_COMPUTED_FLAG
);
if
(
computed
)
{
result
=
isFlagSet
(
READ_ONLY_FLAG
);
}
else
{
result
=
isDataReadOnly
();
setFlag
(
READ_ONLY_COMPUTED_FLAG
,
true
);
setFlag
(
READ_ONLY_FLAG
,
result
);
}
return
result
;
if
(
myIsReadOnly
==
null
)
myIsReadOnly
=
Boolean
.
valueOf
(
isDataReadOnly
());
return
myIsReadOnly
.
booleanValue
();
}
public
final
boolean
isExcluded
()
{
return
isFlagSet
(
EXCLUDED_FLAG
)
;
return
myExcluded
;
}
public
final
void
update
(
@NotNull
UsageView
view
)
{
public
final
void
update
(
UsageView
view
)
{
boolean
isDataValid
=
isDataValid
();
boolean
isReadOnly
=
isDataReadOnly
();
boolean
isExcluded
=
isDataExcluded
();
String
text
=
getText
(
view
);
boolean
cachedValid
=
isValid
();
boolean
cachedExcluded
=
isFlagSet
(
EXCLUDED_FLAG
);
boolean
cachedReadOnly
=
isFlagSet
(
READ_ONLY_FLAG
);
if
(
isDataValid
!=
cachedValid
||
isReadOnly
!=
cachedReadOnly
||
isExcluded
!=
cachedExcluded
||
!
Comparing
.
equal
(
myText
,
text
))
{
setFlag
(
INVALID_FLAG
,
!
isDataValid
);
setFlag
(
READ_ONLY_FLAG
,
isReadOnly
);
setFlag
(
EXCLUDED_FLAG
,
isExcluded
);
if
(
isDataValid
!=
myIsValid
||
myIsReadOnly
==
null
||
isReadOnly
!=
myIsReadOnly
.
booleanValue
()
||
isExcluded
!=
myExcluded
||
!
Comparing
.
equal
(
myText
,
text
))
{
myIsValid
=
isDataValid
;
myExcluded
=
isExcluded
;
myIsReadOnly
=
Boolean
.
valueOf
(
isReadOnly
);
myText
=
text
;
updateNotify
();
myTreeModel
.
nodeChanged
(
this
);
}
setFlag
(
UPDATED_FLAG
,
true
);
}
public
void
markNeedUpdate
()
{
setFlag
(
UPDATED_FLAG
,
false
);
}
public
boolean
needsUpdate
()
{
return
!
isFlagSet
(
UPDATED_FLAG
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
+
15
-
38
View file @
164c4f68
...
...
@@ -65,7 +65,10 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
import
javax.swing.event.TreeSelectionEvent
;
import
javax.swing.event.TreeSelectionListener
;
import
javax.swing.tree.*
;
import
java.awt.*
;
import
java.awt.datatransfer.StringSelection
;
...
...
@@ -140,10 +143,10 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
private
final
Object
lock
=
new
Object
();
private
Splitter
myPreviewSplitter
;
UsageViewImpl
(
@NotNull
final
Project
project
,
@NotNull
UsageViewPresentation
presentation
,
@NotNull
UsageTarget
[]
targets
,
Factory
<
UsageSearcher
>
usageSearcherFactory
)
{
public
UsageViewImpl
(
@NotNull
final
Project
project
,
@NotNull
UsageViewPresentation
presentation
,
@NotNull
UsageTarget
[]
targets
,
Factory
<
UsageSearcher
>
usageSearcherFactory
)
{
myPresentation
=
presentation
;
myTargets
=
targets
;
myUsageSearcherFactory
=
usageSearcherFactory
;
...
...
@@ -413,24 +416,6 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
TreeUtil
.
selectFirstNode
(
myTree
);
PopupHandler
.
installPopupHandler
(
myTree
,
IdeActions
.
GROUP_USAGE_VIEW_POPUP
,
ActionPlaces
.
USAGE_VIEW_POPUP
);
myTree
.
addTreeExpansionListener
(
new
TreeExpansionListener
()
{
@Override
public
void
treeExpanded
(
TreeExpansionEvent
event
)
{
TreePath
path
=
event
.
getPath
();
Object
component
=
path
.
getLastPathComponent
();
if
(!(
component
instanceof
Node
))
return
;
Node
node
=
(
Node
)
component
;
if
(
node
.
needsUpdate
())
{
checkNodeValidity
(
node
,
path
);
}
}
@Override
public
void
treeCollapsed
(
TreeExpansionEvent
event
)
{
}
});
//TODO: install speed search. Not in openapi though. It makes sense to create a common TreeEnchancer service.
}
...
...
@@ -556,6 +541,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
actionsManager
.
createPrevOccurenceAction
(
myRootPanel
),
actionsManager
.
createNextOccurenceAction
(
myRootPanel
),
actionsManager
.
installAutoscrollToSourceHandler
(
myProject
,
myTree
,
new
MyAutoScrollToSourceOptionProvider
()),
//createImportToFavorites(),
actionsManager
.
createExportToTextFileAction
(
myTextFileExporter
),
actionsManager
.
createHelpAction
(
HELP_ID
)
};
...
...
@@ -920,8 +906,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
private
void
updateImmediately
()
{
if
(
myProject
.
isDisposed
())
return
;
TreeNode
root
=
(
TreeNode
)
myTree
.
getModel
().
getRoot
();
checkNodeValidity
(
root
,
new
TreePath
(
root
));
checkNodeValidity
((
DefaultMutableTreeNode
)
myTree
.
getModel
().
getRoot
());
updateOnSelectionChanged
();
}
...
...
@@ -932,20 +917,12 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
}
}
private
void
checkNodeValidity
(
@NotNull
TreeNode
node
,
@NotNull
TreePath
path
)
{
if
(
node
instanceof
Node
&&
node
!=
getModelRoot
())
{
((
Node
)
node
).
update
(
this
);
}
if
(
myTree
.
isCollapsed
(
path
))
{
if
(
node
instanceof
Node
)
{
((
Node
)
node
).
markNeedUpdate
();
}
return
;
// optimization: do not call expensive update() on invisible node
}
for
(
int
i
=
0
;
i
<
node
.
getChildCount
();
i
++)
{
TreeNode
child
=
node
.
getChildAt
(
i
);
checkNodeValidity
(
child
,
path
.
pathByAddingChild
(
child
));
private
void
checkNodeValidity
(
@NotNull
DefaultMutableTreeNode
node
)
{
Enumeration
enumeration
=
node
.
children
();
while
(
enumeration
.
hasMoreElements
())
{
checkNodeValidity
((
DefaultMutableTreeNode
)
enumeration
.
nextElement
());
}
if
(
node
instanceof
Node
&&
node
!=
getModelRoot
())
((
Node
)
node
).
update
(
this
);
}
private
void
updateLater
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help