Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Fiji_Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Fiji_Plugin
Commits
452db7f7
Commit
452db7f7
authored
Aug 1, 2014
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
use JFileChooser or FileDialog depending on ij.Prefs.useJFileChooser
parent
04813980
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/bdv/ij/BigDataViewerPlugIn.java
+57
-22
57 additions, 22 deletions
src/main/java/bdv/ij/BigDataViewerPlugIn.java
src/main/java/bdv/ij/util/PluginHelper.java
+70
-28
70 additions, 28 deletions
src/main/java/bdv/ij/util/PluginHelper.java
with
127 additions
and
50 deletions
src/main/java/bdv/ij/BigDataViewerPlugIn.java
+
57
−
22
View file @
452db7f7
package
bdv.ij
;
import
ij.Prefs
;
import
ij.plugin.PlugIn
;
import
java.awt.FileDialog
;
import
java.awt.Frame
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
javax.swing.JFileChooser
;
import
javax.swing.filechooser.FileFilter
;
...
...
@@ -14,6 +18,10 @@ public class BigDataViewerPlugIn implements PlugIn
{
@Override
public
void
run
(
final
String
arg
)
{
File
file
=
null
;
if
(
Prefs
.
useJFileChooser
)
{
final
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setFileFilter
(
new
FileFilter
()
...
...
@@ -44,8 +52,35 @@ public class BigDataViewerPlugIn implements PlugIn
final
int
returnVal
=
fileChooser
.
showOpenDialog
(
null
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
file
=
fileChooser
.
getSelectedFile
();
}
else
// use FileDialog
{
final
FileDialog
fd
=
new
FileDialog
(
(
Frame
)
null
,
"Open"
,
FileDialog
.
LOAD
);
fd
.
setFilenameFilter
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
final
File
dir
,
final
String
name
)
{
final
int
i
=
name
.
lastIndexOf
(
'.'
);
if
(
i
>
0
&&
i
<
name
.
length
()
-
1
)
{
final
String
ext
=
name
.
substring
(
i
+
1
).
toLowerCase
();
return
ext
.
equals
(
"xml"
);
}
return
false
;
}
}
);
fd
.
setVisible
(
true
);
final
String
filename
=
fd
.
getFile
();
if
(
filename
!=
null
)
{
file
=
new
File
(
fd
.
getDirectory
()
+
filename
);
}
}
if
(
file
!=
null
)
{
final
File
file
=
fileChooser
.
getSelectedFile
();
try
{
BigDataViewer
.
view
(
file
.
getAbsolutePath
(),
new
ProgressWriterIJ
()
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/bdv/ij/util/PluginHelper.java
+
70
−
28
View file @
452db7f7
package
bdv.ij.util
;
import
ij.Prefs
;
import
java.awt.Button
;
import
java.awt.FileDialog
;
import
java.awt.FlowLayout
;
import
java.awt.Frame
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagLayout
;
import
java.awt.Panel
;
...
...
@@ -9,6 +13,7 @@ import java.awt.TextField;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.regex.Matcher
;
...
...
@@ -42,6 +47,8 @@ public class PluginHelper
dialog
.
add
(
panel
);
}
public
static
boolean
useFileDialog
=
true
;
public
static
class
ChooseXmlFileListener
implements
ActionListener
{
TextField
text
;
...
...
@@ -55,10 +62,14 @@ public class PluginHelper
public
void
actionPerformed
(
final
ActionEvent
e
)
{
File
directory
=
new
File
(
text
.
getText
()
);
final
String
fn
=
directory
.
getName
();
while
(
directory
!=
null
&&
!
directory
.
exists
()
)
directory
=
directory
.
getParentFile
();
if
(
Prefs
.
useJFileChooser
)
{
final
JFileChooser
fc
=
new
JFileChooser
(
directory
);
fc
.
setSelectedFile
(
new
File
(
fn
)
);
fc
.
setFileFilter
(
new
FileFilter
()
{
@Override
...
...
@@ -76,7 +87,8 @@ public class PluginHelper
{
final
String
s
=
f
.
getName
();
final
int
i
=
s
.
lastIndexOf
(
'.'
);
if
(
i
>
0
&&
i
<
s
.
length
()
-
1
)
{
if
(
i
>
0
&&
i
<
s
.
length
()
-
1
)
{
final
String
ext
=
s
.
substring
(
i
+
1
).
toLowerCase
();
return
ext
.
equals
(
"xml"
);
}
...
...
@@ -96,6 +108,36 @@ public class PluginHelper
text
.
setText
(
f
);
}
}
else
// use FileDialog
{
final
FileDialog
fd
=
new
FileDialog
(
(
Frame
)
null
,
"Save"
,
FileDialog
.
SAVE
);
fd
.
setDirectory
(
directory
.
getAbsolutePath
()
);
fd
.
setFile
(
fn
);
fd
.
setFilenameFilter
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
final
File
dir
,
final
String
name
)
{
final
int
i
=
name
.
lastIndexOf
(
'.'
);
if
(
i
>
0
&&
i
<
name
.
length
()
-
1
)
{
final
String
ext
=
name
.
substring
(
i
+
1
).
toLowerCase
();
return
ext
.
equals
(
"xml"
);
}
return
false
;
}
}
);
fd
.
setVisible
(
true
);
final
String
filename
=
fd
.
getFile
();
if
(
filename
!=
null
)
{
String
f
=
new
File
(
fd
.
getDirectory
()
+
filename
).
getAbsolutePath
();
if
(
!
f
.
endsWith
(
".xml"
)
)
f
+=
".xml"
;
text
.
setText
(
f
);
}
}
}
}
public
static
int
[][]
parseResolutionsString
(
final
String
s
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment