use of com.ray3k.skincomposer.data.ProjectData.RecentFile in project skin-composer by raeleus.
the class DialogFactory method recentFiles.
public void recentFiles() {
SelectBox<RecentFile> selectBox = new SelectBox(main.getSkin());
Dialog dialog = new Dialog("Recent Files...", main.getSkin(), "bg") {
@Override
protected void result(Object object) {
super.result(object);
if ((boolean) object) {
if (selectBox.getSelected() != null) {
FileHandle file = selectBox.getSelected().getFileHandle();
if (file.exists()) {
main.getProjectData().load(file);
Array<DrawableData> drawableErrors = main.getProjectData().verifyDrawablePaths();
Array<FontData> fontErrors = main.getProjectData().verifyFontPaths();
if (drawableErrors.size > 0 || fontErrors.size > 0) {
main.getDialogFactory().showDialogPathErrors(drawableErrors, fontErrors);
}
}
}
}
}
};
dialog.getTitleTable().getCells().first().padLeft(5.0f);
Array<RecentFile> recentFiles = main.getProjectData().getRecentFiles();
recentFiles.reverse();
selectBox.setItems(recentFiles);
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
dialog.text("Select a file to open");
dialog.getContentTable().row();
dialog.getContentTable().add(selectBox).padLeft(10.0f).padRight(10.0f).growX();
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true).key(Input.Keys.ENTER, true);
dialog.button("Cancel", false).key(Input.Keys.ESCAPE, false);
dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
dialog.show(main.getStage());
}
Aggregations