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
86363acd
Commit
86363acd
authored
18 years ago
by
Alexey Kudravtsev
Browse files
Options
Download
Email Patches
Plain Diff
IDEADEV-10238
parent
a4b742a5
Branches unavailable
Tags unavailable
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
source/com/intellij/find/FindSettings.java
+1
-1
source/com/intellij/find/FindSettings.java
source/com/intellij/find/impl/FindSettingsImpl.java
+8
-6
source/com/intellij/find/impl/FindSettingsImpl.java
util/src/com/intellij/openapi/util/DefaultJDOMExternalizer.java
+100
-78
...rc/com/intellij/openapi/util/DefaultJDOMExternalizer.java
util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java
+1
-1
...m/intellij/openapi/util/JDOMExternalizableStringList.java
util/src/com/intellij/openapi/util/JDOMUtil.java
+8
-3
util/src/com/intellij/openapi/util/JDOMUtil.java
with
118 additions
and
89 deletions
+118
-89
source/com/intellij/find/FindSettings.java
+
1
-
1
View file @
86363acd
...
...
@@ -73,7 +73,7 @@ public abstract class FindSettings{
*/
public
abstract
String
[]
getRecentFileMasks
();
public
abstract
ArrayList
getRecentDirectories
();
public
abstract
ArrayList
<
String
>
getRecentDirectories
();
public
abstract
void
setWithSubdirectories
(
boolean
b
);
...
...
This diff is collapsed.
Click to expand it.
source/com/intellij/find/impl/FindSettingsImpl.java
+
8
-
6
View file @
86363acd
...
...
@@ -12,6 +12,7 @@ import com.intellij.ide.highlighter.JavaFileType;
import
com.intellij.lang.properties.PropertiesFileType
;
import
org.jdom.Element
;
import
org.jetbrains.annotations.NonNls
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -25,7 +26,7 @@ public class FindSettingsImpl extends FindSettings implements ApplicationCompone
@NonNls
public
static
final
String
FIND_SCOPE_SELECTED
=
"selected"
;
public
static
final
String
DEFAULT_SEARCH_SCOPE
=
FindBundle
.
message
(
"find.scope.all.project.classes"
);
p
ublic
static
final
int
MAX_RECENT_SIZE
=
30
;
p
rivate
static
final
int
MAX_RECENT_SIZE
=
30
;
public
boolean
isSearchOverloadedMethods
()
{
...
...
@@ -59,6 +60,7 @@ public class FindSettingsImpl extends FindSettings implements ApplicationCompone
public
JDOMExternalizableStringList
RECENT_DIR_STRINGS
=
new
JDOMExternalizableStringList
();
public
JDOMExternalizableStringList
RECENT_FILE_MASKS
=
new
JDOMExternalizableStringList
();
@NotNull
public
String
getComponentName
(){
return
"FindSettings"
;
}
...
...
@@ -70,7 +72,7 @@ public class FindSettingsImpl extends FindSettings implements ApplicationCompone
public
void
readExternal
(
Element
element
)
throws
InvalidDataException
{
DefaultJDOMExternalizer
.
readExternal
(
this
,
element
);
if
(
RECENT_FILE_MASKS
.
size
()
==
0
)
{
if
(
RECENT_FILE_MASKS
.
isEmpty
()
)
{
RECENT_FILE_MASKS
.
add
(
"*"
+
PropertiesFileType
.
DOT_DEFAULT_EXTENSION
);
RECENT_FILE_MASKS
.
add
(
"*"
+
HtmlFileType
.
DOT_DEFAULT_EXTENSION
);
RECENT_FILE_MASKS
.
add
(
"*"
+
NewJspFileType
.
DOT_DEFAULT_EXTENSION
);
...
...
@@ -193,14 +195,14 @@ public class FindSettingsImpl extends FindSettings implements ApplicationCompone
}
public
void
addStringToFind
(
String
s
){
if
(
(
s
==
null
)
||
(
s
.
indexOf
(
'\r'
)
>=
0
)
||
(
s
.
indexOf
(
'\n'
)
>=
0
)
)
{
if
(
s
==
null
||
s
.
indexOf
(
'\r'
)
>=
0
||
s
.
indexOf
(
'\n'
)
>=
0
){
return
;
}
addStringToList
(
s
,
RECENT_FIND_STRINGS
,
MAX_RECENT_SIZE
);
}
public
void
addStringToReplace
(
String
s
)
{
if
(
(
s
==
null
)
||
(
s
.
indexOf
(
'\r'
)
>=
0
)
||
(
s
.
indexOf
(
'\n'
)
>=
0
)
)
{
if
(
s
==
null
||
s
.
indexOf
(
'\r'
)
>=
0
||
s
.
indexOf
(
'\n'
)
>=
0
){
return
;
}
addStringToList
(
s
,
RECENT_REPLACE_STRINGS
,
MAX_RECENT_SIZE
);
...
...
@@ -225,8 +227,8 @@ public class FindSettingsImpl extends FindSettings implements ApplicationCompone
return
RECENT_FILE_MASKS
.
toArray
(
new
String
[
RECENT_FILE_MASKS
.
size
()]);
}
public
ArrayList
getRecentDirectories
(){
return
new
ArrayList
(
RECENT_DIR_STRINGS
);
public
ArrayList
<
String
>
getRecentDirectories
(){
return
new
ArrayList
<
String
>
(
RECENT_DIR_STRINGS
);
}
public
String
getFileMask
()
{
...
...
This diff is collapsed.
Click to expand it.
util/src/com/intellij/openapi/util/DefaultJDOMExternalizer.java
+
100
-
78
View file @
86363acd
...
...
@@ -17,11 +17,11 @@ package com.intellij.openapi.util;
import
com.intellij.openapi.diagnostic.Logger
;
import
org.jdom.Element
;
import
org.jdom.Verifier
;
import
java.awt.*
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.util.Iterator
;
/**
* @author mike
...
...
@@ -40,214 +40,236 @@ public class DefaultJDOMExternalizer {
public
static
void
writeExternal
(
Object
data
,
Element
parentNode
,
JDOMFilter
filter
)
throws
WriteExternalException
{
Field
[]
fields
=
data
.
getClass
().
getFields
();
for
(
int
i
=
0
;
i
<
fields
.
length
;
i
++){
Field
field
=
fields
[
i
];
for
(
Field
field
:
fields
)
{
if
(
field
.
getName
().
indexOf
(
'$'
)
>=
0
)
continue
;
int
modifiers
=
field
.
getModifiers
();
String
value
=
null
;
if
((
modifiers
&
Modifier
.
PUBLIC
)
==
0
||
(
modifiers
&
Modifier
.
STATIC
)
!=
0
)
continue
;
field
.
setAccessible
(
true
);
// class might be non-public
Class
type
=
field
.
getType
();
if
(
filter
!=
null
&&
!
filter
.
isAccept
(
field
)){
if
(
filter
!=
null
&&
!
filter
.
isAccept
(
field
))
{
continue
;
}
try
{
if
(
type
.
isPrimitive
()){
if
(
type
.
equals
(
byte
.
class
)){
try
{
if
(
type
.
isPrimitive
())
{
if
(
type
.
equals
(
byte
.
class
))
{
value
=
Byte
.
toString
(
field
.
getByte
(
data
));
}
else
if
(
type
.
equals
(
short
.
class
)){
else
if
(
type
.
equals
(
short
.
class
))
{
value
=
Short
.
toString
(
field
.
getShort
(
data
));
}
else
if
(
type
.
equals
(
int
.
class
)){
else
if
(
type
.
equals
(
int
.
class
))
{
value
=
Integer
.
toString
(
field
.
getInt
(
data
));
}
else
if
(
type
.
equals
(
long
.
class
)){
else
if
(
type
.
equals
(
long
.
class
))
{
value
=
Long
.
toString
(
field
.
getLong
(
data
));
}
else
if
(
type
.
equals
(
float
.
class
)){
else
if
(
type
.
equals
(
float
.
class
))
{
value
=
Float
.
toString
(
field
.
getFloat
(
data
));
}
else
if
(
type
.
equals
(
double
.
class
)){
else
if
(
type
.
equals
(
double
.
class
))
{
value
=
Double
.
toString
(
field
.
getDouble
(
data
));
}
else
if
(
type
.
equals
(
char
.
class
)){
value
=
""
+
field
.
getChar
(
data
);
else
if
(
type
.
equals
(
char
.
class
))
{
value
=
String
.
valueOf
(
field
.
getChar
(
data
)
)
;
}
else
if
(
type
.
equals
(
boolean
.
class
)){
else
if
(
type
.
equals
(
boolean
.
class
))
{
value
=
Boolean
.
toString
(
field
.
getBoolean
(
data
));
}
else
{
else
{
continue
;
}
}
else
if
(
type
.
equals
(
String
.
class
)){
value
=
(
String
)
field
.
get
(
data
);
else
if
(
type
.
equals
(
String
.
class
))
{
value
=
filterXMLCharacters
(
(
String
)
field
.
get
(
data
)
)
;
}
else
if
(
type
.
equals
(
Color
.
class
)){
else
if
(
type
.
equals
(
Color
.
class
))
{
Color
color
=
(
Color
)
field
.
get
(
data
);
if
(
color
!=
null
)
{
value
=
Integer
.
toString
(
color
.
getRGB
()
&
0xFFFFFF
,
16
);
}
}
else
if
(
JDOMExternalizable
.
class
.
isAssignableFrom
(
type
)){
Element
element
=
new
Element
(
"option"
);
parentNode
.
addContent
(
element
);
element
.
setAttribute
(
"name"
,
field
.
getName
());
JDOMExternalizable
domValue
=
(
JDOMExternalizable
)
field
.
get
(
data
);
if
(
domValue
!=
null
){
Element
valueElement
=
new
Element
(
"value"
);
element
.
addContent
(
valueElement
);
domValue
.
writeExternal
(
valueElement
);
}
continue
;
}
else
{
else
if
(
JDOMExternalizable
.
class
.
isAssignableFrom
(
type
))
{
Element
element
=
new
Element
(
"option"
);
parentNode
.
addContent
(
element
);
element
.
setAttribute
(
"name"
,
field
.
getName
());
JDOMExternalizable
domValue
=
(
JDOMExternalizable
)
field
.
get
(
data
);
if
(
domValue
!=
null
)
{
Element
valueElement
=
new
Element
(
"value"
);
element
.
addContent
(
valueElement
);
domValue
.
writeExternal
(
valueElement
);
}
continue
;
}
else
{
LOG
.
debug
(
"Wrong field type: "
+
type
);
continue
;
}
}
catch
(
IllegalAccessException
e
){
catch
(
IllegalAccessException
e
)
{
continue
;
}
Element
element
=
new
Element
(
"option"
);
parentNode
.
addContent
(
element
);
element
.
setAttribute
(
"name"
,
field
.
getName
());
if
(
value
!=
null
){
if
(
value
!=
null
)
{
element
.
setAttribute
(
"value"
,
value
);
}
}
}
public
static
String
filterXMLCharacters
(
String
value
)
{
if
(
value
!=
null
)
{
StringBuilder
builder
=
null
;
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
char
c
=
value
.
charAt
(
i
);
if
(
Verifier
.
isXMLCharacter
(
c
))
{
if
(
builder
!=
null
)
{
builder
.
append
(
c
);
}
}
else
{
if
(
builder
==
null
)
{
builder
=
new
StringBuilder
(
value
.
length
()+
5
);
builder
.
append
(
value
,
0
,
i
);
}
}
}
if
(
builder
!=
null
)
{
value
=
builder
.
toString
();
}
}
return
value
;
}
public
static
void
readExternal
(
Object
data
,
Element
parentNode
)
throws
InvalidDataException
{
if
(
parentNode
==
null
)
return
;
for
(
Iterator
i
=
parentNode
.
getChildren
(
"option"
)
.
iterator
();
i
.
hasNext
();
)
{
Element
e
=
(
Element
)
i
.
next
()
;
for
(
final
Object
o
:
parentNode
.
getChildren
(
"option"
))
{
Element
e
=
(
Element
)
o
;
String
fieldName
=
e
.
getAttributeValue
(
"name"
);
if
(
fieldName
==
null
){
if
(
fieldName
==
null
)
{
throw
new
InvalidDataException
();
}
try
{
try
{
Field
field
=
data
.
getClass
().
getField
(
fieldName
);
Class
type
=
field
.
getType
();
int
modifiers
=
field
.
getModifiers
();
if
((
modifiers
&
Modifier
.
PUBLIC
)
==
0
||
(
modifiers
&
Modifier
.
STATIC
)
!=
0
||
(
modifiers
&
Modifier
.
FINAL
)
!=
0
)
continue
;
field
.
setAccessible
(
true
);
// class might be non-public
String
value
=
e
.
getAttributeValue
(
"value"
);
if
(
type
.
isPrimitive
()){
if
(
type
.
isPrimitive
())
{
if
(
value
!=
null
)
{
if
(
type
.
equals
(
byte
.
class
)){
try
{
if
(
type
.
equals
(
byte
.
class
))
{
try
{
field
.
setByte
(
data
,
Byte
.
parseByte
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
short
.
class
)){
try
{
else
if
(
type
.
equals
(
short
.
class
))
{
try
{
field
.
setShort
(
data
,
Short
.
parseShort
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
int
.
class
)){
try
{
else
if
(
type
.
equals
(
int
.
class
))
{
try
{
field
.
setInt
(
data
,
Integer
.
parseInt
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
long
.
class
)){
try
{
else
if
(
type
.
equals
(
long
.
class
))
{
try
{
field
.
setLong
(
data
,
Long
.
parseLong
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
float
.
class
)){
try
{
else
if
(
type
.
equals
(
float
.
class
))
{
try
{
field
.
setFloat
(
data
,
Float
.
parseFloat
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
double
.
class
)){
try
{
else
if
(
type
.
equals
(
double
.
class
))
{
try
{
field
.
setDouble
(
data
,
Double
.
parseDouble
(
value
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
throw
new
InvalidDataException
();
}
}
else
if
(
type
.
equals
(
char
.
class
)){
if
(
value
.
length
()
!=
1
){
else
if
(
type
.
equals
(
char
.
class
))
{
if
(
value
.
length
()
!=
1
)
{
throw
new
InvalidDataException
();
}
field
.
setChar
(
data
,
value
.
charAt
(
0
));
}
else
if
(
type
.
equals
(
boolean
.
class
)){
if
(
value
.
equals
(
"true"
)){
else
if
(
type
.
equals
(
boolean
.
class
))
{
if
(
value
.
equals
(
"true"
))
{
field
.
setBoolean
(
data
,
true
);
}
else
if
(
value
.
equals
(
"false"
)){
else
if
(
value
.
equals
(
"false"
))
{
field
.
setBoolean
(
data
,
false
);
}
else
{
else
{
throw
new
InvalidDataException
();
}
}
else
{
else
{
throw
new
InvalidDataException
();
}
}
}
else
if
(
type
.
equals
(
String
.
class
)){
else
if
(
type
.
equals
(
String
.
class
))
{
field
.
set
(
data
,
value
);
}
else
if
(
type
.
equals
(
Color
.
class
)){
if
(
value
!=
null
){
try
{
else
if
(
type
.
equals
(
Color
.
class
))
{
if
(
value
!=
null
)
{
try
{
int
rgb
=
Integer
.
parseInt
(
value
,
16
);
field
.
set
(
data
,
new
Color
(
rgb
));
}
catch
(
NumberFormatException
ex
){
catch
(
NumberFormatException
ex
)
{
System
.
out
.
println
(
"value="
+
value
);
throw
new
InvalidDataException
();
}
}
else
{
else
{
field
.
set
(
data
,
null
);
}
}
else
if
(
JDOMExternalizable
.
class
.
isAssignableFrom
(
type
)){
else
if
(
JDOMExternalizable
.
class
.
isAssignableFrom
(
type
))
{
JDOMExternalizable
object
=
null
;
for
(
Iterator
j
=
e
.
getChildren
(
"value"
)
.
iterator
();
j
.
hasNext
();
)
{
Element
el
=
(
Element
)
j
.
next
()
;
for
(
final
Object
o1
:
e
.
getChildren
(
"value"
))
{
Element
el
=
(
Element
)
o1
;
object
=
(
JDOMExternalizable
)
type
.
newInstance
();
object
.
readExternal
(
el
);
}
field
.
set
(
data
,
object
);
}
else
{
else
{
throw
new
InvalidDataException
(
"wrong type: "
+
type
);
}
}
catch
(
NoSuchFieldException
ex
){
continue
;
catch
(
NoSuchFieldException
ex
)
{
}
catch
(
SecurityException
ex
){
catch
(
SecurityException
ex
)
{
throw
new
InvalidDataException
();
}
catch
(
IllegalAccessException
ex
){
catch
(
IllegalAccessException
ex
)
{
ex
.
printStackTrace
();
throw
new
InvalidDataException
();
}
...
...
This diff is collapsed.
Click to expand it.
util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java
+
1
-
1
View file @
86363acd
...
...
@@ -88,7 +88,7 @@ public class JDOMExternalizableStringList extends ArrayList<String> implements J
Element
itemElement
=
new
Element
(
ATTR_ITEM
);
itemElement
.
setAttribute
(
ATTR_INDEX
,
Integer
.
toString
(
i
));
itemElement
.
setAttribute
(
ATTR_CLASS
,
listItem
.
getClass
().
getName
());
itemElement
.
setAttribute
(
ATTR_VALUE
,
listItem
);
itemElement
.
setAttribute
(
ATTR_VALUE
,
DefaultJDOMExternalizer
.
filterXMLCharacters
(
listItem
)
)
;
listElement
.
addContent
(
itemElement
);
}
}
...
...
This diff is collapsed.
Click to expand it.
util/src/com/intellij/openapi/util/JDOMUtil.java
+
8
-
3
View file @
86363acd
...
...
@@ -181,13 +181,18 @@ public class JDOMUtil {
}
public
static
Document
loadDocument
(
File
file
)
throws
JDOMException
,
IOException
{
SAXBuilder
saxBuilder
=
createBuilder
();
return
saxBuilder
.
build
(
new
InputStreamReader
(
new
BufferedInputStream
(
new
FileInputStream
(
file
)),
ENCODING
));
return
loadDocument
(
new
BufferedInputStream
(
new
FileInputStream
(
file
)));
}
public
static
Document
loadDocument
(
@NotNull
InputStream
stream
)
throws
JDOMException
,
IOException
{
SAXBuilder
saxBuilder
=
createBuilder
();
return
saxBuilder
.
build
(
new
InputStreamReader
(
stream
,
ENCODING
));
InputStreamReader
reader
=
new
InputStreamReader
(
stream
,
ENCODING
);
try
{
return
saxBuilder
.
build
(
reader
);
}
finally
{
reader
.
close
();
}
}
public
static
Document
loadDocument
(
URL
url
)
throws
JDOMException
,
IOException
{
...
...
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