fr.ird.observe.client.tree.navigation.nodes.referential.ReferentialNavigationTreeNode Maven / Gradle / Ivy
package fr.ird.observe.client.tree.navigation.nodes.referential;
/*-
* #%L
* ObServe Toolkit :: Common Client
* %%
* Copyright (C) 2008 - 2017 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import fr.ird.observe.client.ObserveClientTechnicalException;
import fr.ird.observe.client.form.FormUI;
import fr.ird.observe.client.tree.navigation.nodes.ClassNavigationTreeNode;
import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
import fr.ird.observe.dto.referential.ReferentialDto;
import org.apache.commons.lang3.StringUtils;
import static org.nuiton.i18n.I18n.t;
/**
* Created on 16/11/16.
*
* @author Tony Chemit - [email protected]
* @since 6.0
*/
public class ReferentialNavigationTreeNode extends ClassNavigationTreeNode {
private static final long serialVersionUID = -7999804150305536506L;
ReferentialNavigationTreeNode(Class data) {
super(data, true, t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(data)));
}
@Override
public Class extends FormUI> getContentClass() {
String packageName = getData().getPackage().getName();
String packagePrefix;
if (packageName.endsWith("longline")) {
packagePrefix = "longline.";
} else if (packageName.endsWith("seine")) {
packagePrefix = "seine.";
} else {
packagePrefix = "common.";
}
//FIXME Use a ClassMaping
String className = String.format("fr.ird.observe.client.ui.content.referential.%s%sUI", packagePrefix, StringUtils.removeEnd(getData().getSimpleName(), "Dto"));
try {
return (Class) Class.forName(className);
} catch (ClassNotFoundException e) {
throw new ObserveClientTechnicalException("Can't get ui class for: " + className, e);
}
}
@Override
public String getIconPath() {
return "navigation.sub.referentiel";
}
@Override
public boolean isLeaf() {
return true;
}
@Override
public boolean isOpen() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy