return getString("preferences.settings").toString();
}
@Override
public void execute() throws Exception {
final Stage stage = Stage.createStage();
//tracking checkbox
boolean trackingEnabled = "true".equals(manager.settings.getProperty(Settings.TRACKING_PERMISSIONS));
Checkbox trackingCheckbox = new Checkbox(getString("preferences.enable.analytics.tracking"));
trackingCheckbox.setSelected(trackingEnabled);
trackingCheckbox.onClicked(new Callback<ActionEvent>(){
public void call(ActionEvent actionEvent) throws Exception {
Checkbox checkbox = (Checkbox) actionEvent.getSource();
Main.settings.setProperty(Settings.TRACKING_PERMISSIONS,""+checkbox.isSelected());
}
});
//starting on translations
//debug menu
Checkbox debugMenuCheckbox = new Checkbox(getString("preferences.enable.debug.menu"));
boolean debugMenuEnabled = "true".equals(manager.settings.getProperty(Settings.DEBUG_MENU));
debugMenuCheckbox.setSelected(debugMenuEnabled);
debugMenuCheckbox.onClicked(new Callback<ActionEvent>(){
public void call(ActionEvent actionEvent) throws Exception {
Checkbox checkbox = (Checkbox) actionEvent.getSource();
Main.settings.setProperty(Settings.DEBUG_MENU,""+checkbox.isSelected());
}
});
ArrayListModel<String> locale = new ArrayListModel<String>();
locale.addAll(Localization.getSupportedLocales());
Collections.sort(locale);
final PopupMenuButton<String> localeChoice = new PopupMenuButton<String>();
localeChoice.setModel(locale);
if(Main.settings.containsKey(Settings.DEFAULT_LOCALE)) {
int n = locale.indexOf(Main.settings.getProperty(Settings.DEFAULT_LOCALE));
if(n >= 0) {
localeChoice.setSelectedIndex(n);
}
}
localeChoice.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
}
});
Callback<ActionEvent> closeAction = new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
stage.hide();
String l = localeChoice.getModel().get(localeChoice.getSelectedIndex());
Main.settings.setProperty(Settings.DEFAULT_LOCALE, l);
Main.saveSettings();
Localization.setCurrentLocale(l);
Core.getShared().reloadSkins();
}
};
TabPanel tab = new TabPanel();
tab.add(getString("preferences.generalTab"),new VFlexBox().setBoxAlign(VFlexBox.Align.Left)
.add(new HFlexBox()
.setBoxAlign(HFlexBox.Align.Baseline)
.add(trackingCheckbox)
.add(new Linkbutton(getString("misc.whatsthis")).onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
OSUtil.openBrowser("http://code.google.com/p/leonardosketch/wiki/Tracking");
}
})))
.add(new Label(getString("preferences.flickrCache")))
.add(new Label(Main.FlickrSearchCache.getCacheDir().getAbsolutePath()).setColor(new FlatColor(0x606060)))
.add(new Button(getString("preferences.deleteFlickrCache")).onClicked(clearFlickrCache))
);
tab.add(getString("preferences.advancedTab"), new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch)
.add(debugMenuCheckbox)
.add(new Label(getString("preferences.preferredLocale")))
.add(localeChoice)
.add(new Label(getString("misc.changesAppliedLater").toString()))
);
stage.setContent(new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch)
.add(tab,1)
.add(new HFlexBox().add(new Spacer(),1).add(new Button(getString("misc.close")).onClicked(closeAction)))
);
}