Project

General

Profile

Bug #4112

make kepler use OSX dialog boxes

Added by Chad Berkley over 9 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
Category:
core
Target version:
Start date:
05/27/2009
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
4112

Description

Add configuration to the mac extensions to make kepler use the OSX file open/save dialog boxes instead of the default java ones.


Related issues

Blocked by Kepler - Bug #4286: Changes to the GUI before 2.0Resolved2009-08-07

History

#1 Updated by Chad Berkley over 9 years ago

In order to do this, we need to not use JFileChooser and instead use java.awt.FileDialog. This is the only way to get the JDK to use the native mac dialogs according to Apple.

http://developer.apple.com/documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html

#2 Updated by Timothy McPhillips over 9 years ago

This would be great because it apparently would allow me to quickly save or load workflows in my home directory, etc. In other apps I really appreciate having immediate access to those shortcuts in the "Devices/Shared/Places" pane on the left side of the Finder open/save dialog.

#3 Updated by David Welker over 9 years ago

I think we should consider requiring users to upgrade to Java 1.6 Update 12 or higher for Kepler 2.0.

Before then, it was definitely a heavily discouraged practice to mix AWT and Swing since they do not respect their Z-order. I think that this is an important enough issue that we should require users to upgrade. I also think it would be sensible for an upgrade of Java to occur with the release of 2.0.

#4 Updated by Christopher Brooks over 9 years ago

The easiest way to use java.awt.FileDialog for File =>Open etc. would be
to modify ptolemy.gui.Top. Modifyig ptolemy.gui.Query would solve the
problem for FileParameter. I'm not sure where to fix "Open Archive (KAR)".
See also
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3801

The way I'd fix this is to look at creating a class called PtFileDialog
that would work either on a JFileDialog or a java.awt.FileDialog depending
on whether ptolemy.gui.PtGUIUtilities.macOSXLookAndFeel returned true.
I'm not sure if it would be easy to write PtFileDialog.

One issue is that ptolemy.gui should not depend on Mac specific classes or
on anything other than ptolemy.util.

#5 Updated by Daniel Crawl over 6 years ago

Christopher, did you finish this? The file dialogs on mac appear to be using java.awt.FileDialog.

#6 Updated by Christopher Brooks over 6 years ago

Ptolemy II now uses java.awt.FileDialog for file open etc.
ptolemy.gui.PtFileChooser is a FileDialog or a FileChooser.
See ./ptolemy/src/ptolemy/vergil/basic/BasicGraphFrame.java for example code

There are a few places in Ptolemy that still need to be fixed.

Below are the files that need to be reviewed.
I can handle the ptolemy/ files, can someone else handle the kepler files?

bash-3.2$ cd ~/src/kepler
bash-3.2$ find . -name "*.java" >& /tmp/kj
bash-3.2$ cat /tmp/kj | xargs grep JFileChooser | grep new | grep -v BugFix
./actors/src/org/cipres/kepler/NexusFileReader.java: JFileChooser fileChooser = new JFileChooser();
./data-handling/src/org/ecoinformatics/seek/querybuilder/QBApp.java: JFileChooser chooser = new JFileChooser("Save " + aTitle);
./data-handling/src/org/ecoinformatics/seek/querybuilder/QBApp.java: JFileChooser chooser = new JFileChooser("Open " + aTitle);
./gui/src/org/kepler/gui/ComponentLibraryPreferencesTab.java: JFileChooser jfc = new JFileChooser(saveRepo);
./gui/src/org/kepler/gui/kar/DeleteArchiveAction.java: JFileChooser chooser = new JFileChooser();
./gui/src/org/kepler/gui/kar/ExportArchiveAction.java: JFileChooser chooser = new JFileChooser();
./gui/src/org/kepler/gui/kar/OpenArchiveAction.java: JFileChooser chooser = new JFileChooser();
./gui/src/org/kepler/gui/kar/RefreshFolderAction.java: JFileChooser chooser = new JFileChooser();
./gui/src/org/kepler/gui/kar/ViewManifestAction.java: JFileChooser chooser = new JFileChooser();
./module-manager-gui/src/org/kepler/modulemanager/gui/CurrentSuitePanel.java: JFileChooser fc = new JFileChooser();
./module-manager-gui/src/org/kepler/modulemanager/gui/CurrentSuitePanel.java: JFileChooser fc = new JFileChooser();
./ptolemy/src/diva/gui/BasicStoragePolicy.java: JFileChooser fc = new JFileChooser(dir);
./ptolemy/src/diva/gui/BasicStoragePolicy.java: JFileChooser fc = new JFileChooser(dir);
./ptolemy/src/diva/gui/DefaultStoragePolicy.java: private JFileChooser _openFileChooser = new JFileChooser();
./ptolemy/src/diva/gui/DefaultStoragePolicy.java: private JFileChooser _saveFileChooser = new JFileChooser();
./ptolemy/src/diva/gui/ExtensionFileFilter.java: * JFileChooser chooser = new JFileChooser();
./ptolemy/src/org/mlc/swing/layout/LayoutFrame.java: final JFileChooser fileChooser = new JFileChooser();
./ptolemy/src/ptdb/gui/DatabaseSetupFrame.java: JFileChooser fileChooser = new JFileChooser();
./ptolemy/src/ptdb/gui/ModelMigrationFrame.java: JFileChooser fileChooser = new JFileChooser();
./ptolemy/src/ptdb/gui/SimpleSearchFrame.java: JFileChooser chooser = new JFileChooser();
./ptolemy/src/ptdb/gui/SimpleSearchFrame.java: JFileChooser chooser = new JFileChooser();
./ptolemy/src/ptolemy/actor/gui/PlotTableauFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/actor/gui/PlotTableauFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/domains/giotto/cgc/GiottoCEmachineFrameworkGenerator.java: JFileChooser dirDialog = new JFileChooser();
./ptolemy/src/ptolemy/gui/ExtensionFilenameFilter.java: * JFileChooser chooser = new JFileChooser();
./ptolemy/src/ptolemy/gui/PtFileChooser.java: _jFileChooser = new JFileChooser();
./ptolemy/src/ptolemy/gui/Query.java: JFileChooser fileChooser = new JFileChooser(_startingDirectory) {
./ptolemy/src/ptolemy/gui/Top.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/gui/Top.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/homer/gui/HomerMenu.java: _fileChooser = new JFileChooser();
./ptolemy/src/ptolemy/plot/PlotFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/plot/PlotFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/plot/PlotFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/fsm/fmv/FmvAutomatonGraphFrame.java: JFileChooser fileSaveDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/fsm/fmv/FmvAutomatonGraphFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/fsm/ia/InterfaceAutomatonGraphController.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/kernel/attributes/DocumentationAttribute.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/modal/fmv/FmvAutomatonGraphFrame.java: JFileChooser fileSaveDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/modal/fmv/FmvAutomatonGraphFrame.java: JFileChooser fileDialog = new JFileChooser();
./ptolemy/src/ptolemy/vergil/modal/ia/InterfaceAutomatonGraphController.java: JFileChooser fileDialog = new JFileChooser();

#7 Updated by Daniel Crawl over 6 years ago

OpenArchiveAction.java and ExportArchiveAction.java were already fixed and use PtGUIUtilities.useFileDialog(). I fixed the rest in Kepler.

#8 Updated by Daniel Crawl over 6 years ago

When saving, JFileChooser does not ask to overwrite existing files, but FileDialog does. It would be nice if PtFileChooser.showDialog would ask when using JFileChooser.

#9 Updated by Christopher Brooks over 6 years ago

Dan writes:

When saving, JFileChooser does not ask to overwrite existing files, but
FileDialog does. It would be nice if PtFileChooser.showDialog would ask when
using JFileChooser.

I'm a little nervous about modifying PtFileChooser.showDialog() to check
to see if the file exists because showDialog() can be called to open
a file as well as save a file.

Also, we would need to update the places where we call showDialog() so that
they would not then check again to see if we want to overwrite a file.

Note that BasicGraphFrame has convoluted code like:

// The Mac OS X FileDialog will ask if we want to save before this point.
if (imageFile.exists() && !PtGUIUtilities.useFileDialog()) {
if (!MessageHandler.yesNoQuestion("Overwrite \""
+ imageFile.getName() + "\"?")) {
return;
}
}

Adding new method that did the check could be useful though.
Perhaps the method could be called
PtFileChooser.showDialog(boolean askAboutOverwrite)
or something.

Dan, do you want to give it a shot?

#10 Updated by Redmine Admin over 5 years ago

Original Bugzilla ID was 4112

Also available in: Atom PDF