use of easik.EasikSettings in project fql by CategoricalData.
the class ProgramSettingsUI method addGeneralOptions.
/**
* Adds the options for the General tab to the passed-in OptionTab
*
* @param general
*/
protected void addGeneralOptions(OptionTab general) {
EasikSettings s = Easik.getInstance().getSettings();
general.addOption(new JLabel("Default folder"), folderPanel(s));
JPanel settings = new JPanel();
settings.setLayout(new BoxLayout(settings, BoxLayout.Y_AXIS));
_showAttsAndUniqueKeys = new JCheckBox("Show attributes & unique keys", s.getProperty("attrib_display", "show").equals("show"));
// _showWarnings = new JCheckBox("Show warnings",
// s.getProperty("warning_display", "show").equals("show"));
settings.add(_showAttsAndUniqueKeys);
// settings.add(_showWarnings);
general.addOption(new JLabel("Startup settings"), settings);
float currentScale = s.getFloat("thumb_scale_factor", 0.25f);
thumbScaleSlider = new JSlider(1, 100, (int) (100 * currentScale));
Dimension d = thumbScaleSlider.getPreferredSize();
thumbScaleSlider.setPreferredSize(new Dimension(200, d.height));
final JLabel thumbScaleIndicator = new JLabel((currentScale + "").replaceAll("\\.?0+$", ""));
thumbScaleSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JSlider s = (JSlider) e.getSource();
@SuppressWarnings("unused") JPanel p = (JPanel) s.getParent();
thumbScaleIndicator.setText(((s.getValue() / 100.0) + "").replaceAll("\\.?0+$", ""));
}
});
String scaleTT = JUtils.tooltip("The scale affects how large the thumbnail of sketches and views shows in the overview will be. A value of 0.25 (the default) means 1/4 size; 0.5 would mean 1/2 size.");
JLabel scaleLabel = new JLabel("Thumbnail scale");
scaleLabel.setToolTipText(scaleTT);
thumbScaleSlider.setToolTipText(scaleTT);
general.addOption(new Option(scaleLabel, thumbScaleSlider, thumbScaleIndicator));
}
use of easik.EasikSettings in project fql by CategoricalData.
the class FileChooser method chooseFileSwing.
/**
* @param title
* @param mode
* @param filter
*
* @return
*/
private static File chooseFileSwing(String title, Mode mode, FileFilter filter, String defaultName) {
Easik e = Easik.getInstance();
EasikSettings s = e.getSettings();
JFileChooser dialog = new JFileChooser(s.getDefaultFolder());
if (filter != null) {
dialog.setFileFilter(filter);
}
int result;
if (mode == Mode.DIRECTORY) {
dialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
result = dialog.showDialog(e.getFrame(), "Select folder");
} else if (mode == Mode.SAVE) {
if (defaultName != null) {
dialog.setSelectedFile(new File(defaultName));
}
result = dialog.showSaveDialog(e.getFrame());
} else {
result = dialog.showOpenDialog(e.getFrame());
}
if (result != JFileChooser.APPROVE_OPTION) {
return null;
}
File selFile = dialog.getSelectedFile();
if (mode != Mode.DIRECTORY) {
s.setProperty("folder_last", selFile.getParentFile().getAbsolutePath());
}
return selFile;
}
Aggregations