use of gaiasky.util.datadesc.DatasetDesc in project gaiasky by langurmonkey.
the class WelcomeGui method numStarCatalogsEnabled.
private int numStarCatalogsEnabled() {
int matches = 0;
if (serverDatasets == null && localDatasets == null) {
return 0;
}
for (String f : Settings.settings.data.dataFiles) {
// File name with no extension
Path path = Settings.settings.data.dataPath(f);
String filenameExt = path.getFileName().toString();
try {
DatasetDesc dataset = null;
// Try with server description
if (serverDatasets != null) {
dataset = serverDatasets.findDatasetByDescriptor(path);
}
// Try local description
if (dataset == null && localDatasets != null) {
dataset = localDatasets.findDatasetByDescriptor(path);
}
if ((dataset != null && dataset.isStarDataset()) || isGaiaDRCatalogFile(filenameExt)) {
matches++;
}
} catch (Exception e) {
logger.error(e);
}
}
return matches;
}
use of gaiasky.util.datadesc.DatasetDesc in project gaiasky by langurmonkey.
the class WelcomeGui method buildWelcomeUI.
private void buildWelcomeUI() {
serverDatasets = !downloadError ? DataDescriptorUtils.instance().buildServerDatasets(dataDescriptor) : null;
reloadLocalDatasets();
// Center table
Table center = new Table(skin);
center.setFillParent(true);
center.center();
if (bgTex == null)
bgTex = new Texture(Gdx.files.internal("img/splash/splash.jpg"));
Drawable bg = new SpriteDrawable(new Sprite(bgTex));
center.setBackground(bg);
float pad16 = 16f;
float pad18 = 18f;
float pad32 = 32f;
float pad28 = 28f;
float bw = 540f;
float bh = 110f;
Set<String> removed = removeNonExistent();
if (removed.size() > 0) {
logger.warn(I18n.txt("gui.welcome.warn.nonexistent", removed.size()));
logger.warn(TextUtils.setToStr(removed));
}
int numCatalogsAvailable = numCatalogsAvailable();
int numGaiaDRCatalogsEnabled = numGaiaDRCatalogsEnabled();
int numStarCatalogsEnabled = numStarCatalogsEnabled();
int numTotalCatalogsEnabled = numTotalDatasetsEnabled();
boolean baseDataPresent = baseDataPresent();
// Title
HorizontalGroup titleGroup = new HorizontalGroup();
titleGroup.space(pad32 * 2f);
OwnLabel gaiaSky = new OwnLabel(Settings.getApplicationTitle(Settings.settings.runtime.openVr), skin, "main-title");
OwnLabel version = new OwnLabel(Settings.settings.version.version, skin, "main-title");
version.setColor(skin.getColor("theme"));
titleGroup.addActor(gaiaSky);
titleGroup.addActor(version);
String textStyle = "main-title-s";
// Start Gaia Sky button
OwnTextIconButton startButton = new OwnTextIconButton(I18n.txt("gui.welcome.start", Settings.APPLICATION_NAME), skin, "start");
startButton.setSpace(pad18);
startButton.setContentAlign(Align.center);
startButton.align(Align.center);
startButton.setSize(bw, bh);
startButton.addListener((event) -> {
if (event instanceof ChangeEvent) {
// Check base data is enabled
gaiaSky();
}
return true;
});
Table startGroup = new Table(skin);
OwnLabel startLabel = new OwnLabel(I18n.txt("gui.welcome.start.desc", Settings.APPLICATION_NAME), skin, textStyle);
startGroup.add(startLabel).top().left().padBottom(pad16).row();
if (!baseDataPresent) {
// No basic data, can't start!
startButton.setDisabled(true);
OwnLabel noBaseData = new OwnLabel(I18n.txt("gui.welcome.start.nobasedata"), skin, textStyle);
noBaseData.setColor(ColorUtils.gRedC);
startGroup.add(noBaseData).bottom().left();
} else if (numCatalogsAvailable > 0 && numTotalCatalogsEnabled == 0) {
OwnLabel noCatsSelected = new OwnLabel(I18n.txt("gui.welcome.start.nocatalogs"), skin, textStyle);
noCatsSelected.setColor(ColorUtils.gRedC);
startGroup.add(noCatsSelected).bottom().left();
} else if (numGaiaDRCatalogsEnabled > 1 || numStarCatalogsEnabled == 0) {
OwnLabel tooManyDR = new OwnLabel(I18n.txt("gui.welcome.start.check"), skin, textStyle);
tooManyDR.setColor(ColorUtils.gRedC);
startGroup.add(tooManyDR).bottom().left();
} else {
OwnLabel ready = new OwnLabel(I18n.txt("gui.welcome.start.ready"), skin, textStyle);
ready.setColor(ColorUtils.gGreenC);
startGroup.add(ready).bottom().left();
}
// Dataset manager button
OwnTextIconButton datasetManagerButton = new OwnTextIconButton(I18n.txt("gui.welcome.dsmanager"), skin, "cloud-download");
datasetManagerButton.setSpace(pad18);
datasetManagerButton.setContentAlign(Align.center);
datasetManagerButton.align(Align.center);
datasetManagerButton.setSize(bw * 0.8f, bh * 0.8f);
datasetManagerButton.addListener((event) -> {
if (event instanceof ChangeEvent) {
addDatasetManagerWindow(serverDatasets);
}
return true;
});
Table datasetManagerInfo = new Table(skin);
OwnLabel downloadLabel = new OwnLabel(I18n.txt("gui.welcome.dsmanager.desc"), skin, textStyle);
datasetManagerInfo.add(downloadLabel).top().left().padBottom(pad16);
if (serverDatasets != null && serverDatasets.updatesAvailable) {
datasetManagerInfo.row();
OwnLabel updates = new OwnLabel(I18n.txt("gui.welcome.dsmanager.updates", serverDatasets.numUpdates), skin, textStyle);
updates.setColor(ColorUtils.gYellowC);
datasetManagerInfo.add(updates).bottom().left();
} else if (!baseDataPresent) {
datasetManagerInfo.row();
OwnLabel getBasedata = new OwnLabel(I18n.txt("gui.welcome.dsmanager.info"), skin, textStyle);
getBasedata.setColor(ColorUtils.gGreenC);
datasetManagerInfo.add(getBasedata).bottom().left();
} else {
// Number selected
OwnLabel numCatalogsEnabled = new OwnLabel(I18n.txt("gui.welcome.enabled", numTotalCatalogsEnabled, numCatalogsAvailable), skin, textStyle);
numCatalogsEnabled.setColor(ColorUtils.gBlueC);
datasetManagerInfo.row().padBottom(pad16);
datasetManagerInfo.add(numCatalogsEnabled).left().padBottom(pad18);
}
// Selection problems/issues
Table selectionInfo = new Table(skin);
if (numCatalogsAvailable == 0) {
// No catalog files, disable and add notice
OwnLabel noCatalogs = new OwnLabel(I18n.txt("gui.welcome.catalogsel.nocatalogs"), skin, textStyle);
noCatalogs.setColor(ColorUtils.aOrangeC);
selectionInfo.add(noCatalogs);
} else if (numGaiaDRCatalogsEnabled > 1) {
OwnLabel tooManyDR = new OwnLabel(I18n.txt("gui.welcome.catalogsel.manydrcatalogs"), skin, textStyle);
tooManyDR.setColor(ColorUtils.gRedC);
selectionInfo.add(tooManyDR);
} else if (numStarCatalogsEnabled > 1) {
OwnLabel warn2Star = new OwnLabel(I18n.txt("gui.welcome.catalogsel.manystarcatalogs"), skin, textStyle);
warn2Star.setColor(ColorUtils.aOrangeC);
selectionInfo.add(warn2Star);
} else if (numStarCatalogsEnabled == 0) {
OwnLabel noStarCatalogs = new OwnLabel(I18n.txt("gui.welcome.catalogsel.nostarcatalogs"), skin, textStyle);
noStarCatalogs.setColor(ColorUtils.aOrangeC);
selectionInfo.add(noStarCatalogs);
}
// Exit button
OwnTextIconButton quitButton = new OwnTextIconButton(I18n.txt("gui.exit"), skin, "quit");
quitButton.setSpace(pad16);
quitButton.align(Align.center);
quitButton.setSize(bw * 0.5f, bh * 0.6f);
quitButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
// Title
center.add(titleGroup).center().padBottom(pad18 * 6f).colspan(2).row();
// Start button
center.add(startButton).right().top().padBottom(pad18 * 10f).padRight(pad28 * 2f);
center.add(startGroup).top().left().padBottom(pad18 * 10f).row();
// Dataset manager
center.add(datasetManagerButton).right().top().padBottom(pad32).padRight(pad28 * 2f);
center.add(datasetManagerInfo).left().top().padBottom(pad32).row();
center.add(selectionInfo).colspan(2).center().top().padBottom(pad32 * 4f).row();
// Quit
center.add(quitButton).center().top().colspan(2);
// Version line table
Table topLeft = new VersionLineTable(skin);
ui.addActor(center);
ui.addActor(topLeft);
ui.addActor(popupInterface);
if (!baseDataPresent) {
// Open dataset manager if base data is not there
addDatasetManagerWindow(serverDatasets);
} else {
// Check if there is an update for the base data, and show a notice if so
if (serverDatasets != null && serverDatasets.updatesAvailable) {
DatasetDesc baseData = serverDatasets.findDataset("default-data");
if (baseData != null && baseData.myVersion < baseData.serverVersion) {
// We have a base data update, show notice
GenericDialog baseDataNotice = new GenericDialog(I18n.txt("gui.basedata.title"), skin, ui) {
@Override
protected void build() {
content.clear();
content.pad(pad20, pad28 * 2f, pad20, pad28 * 2f);
content.add(new OwnLabel(I18n.txt("gui.basedata.default", baseData.name, I18n.txt("gui.welcome.dsmanager")), skin, "msg-24")).left().colspan(3).padBottom(pad20 * 2f).row();
content.add(new OwnLabel(I18n.txt("gui.basedata.version", baseData.myVersion), skin, "header-large")).center().padRight(pad20);
content.add(new OwnLabel("->", skin, "main-title-s")).center().padRight(pad20);
content.add(new OwnLabel(I18n.txt("gui.basedata.version", baseData.serverVersion), skin, "header-large")).center().padRight(pad20);
}
@Override
protected void accept() {
// Nothing
}
@Override
protected void cancel() {
// Nothing
}
@Override
public void dispose() {
// Nothing
}
};
baseDataNotice.setAcceptText(I18n.txt("gui.ok"));
baseDataNotice.buildSuper();
baseDataNotice.show(ui);
}
}
}
}
Aggregations