Commit a210a677 authored by PECQUOT's avatar PECQUOT
Browse files

git-svn-id: https://scmforge.ifremer.fr/authscm/lp1ee9d/svn/reefdb/trunk@1295 cd918a83-917d-4a2a-92d7-bc1d03929fc5
parent fc379b78
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
#closeButton {
actionIcon: cancel;
text: "reefdb.config.boutonFermer.label";
_applicationAction: {fr.ifremer.reefdb.ui.swing.content.manage.contexts.actions.CloseAction.class};
}
#saveButton {
actionIcon: save;
text: "reefdb.config.boutonSave.label";
_applicationAction: {fr.ifremer.reefdb.ui.swing.content.manage.contexts.actions.SaveAction.class};
}
#filters {
border: {BorderFactory.createTitledBorder(t("reefdb.ui.swing.content.manage.contexts.contextslist.filters.title"))};
}
<!--
#%L
Reef DB :: UI
$Id:$
$HeadURL:$
%%
Copyright (C) 2014 - 2015 Ifremer
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
<Table decorator='help' implements='fr.ifremer.reefdb.ui.swing.util.ReefDbUI&lt;ManageContextsUIModel, ManageContextsUIHandler&gt;'>
<import>
fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker
fr.ifremer.reefdb.ui.swing.ReefDbUIContext
fr.ifremer.reefdb.ui.swing.util.ReefDbUI
fr.ifremer.reefdb.ui.swing.util.ReefDbUIUtil
fr.ifremer.reefdb.ui.swing.content.manage.contexts.contextslist.menu.ManageContextsListMenuUI
fr.ifremer.reefdb.ui.swing.content.manage.contexts.contextslist.ManageContextsListUI
fr.ifremer.reefdb.ui.swing.content.manage.contexts.filterslist.ManageFiltersListUI
fr.ifremer.reefdb.ui.swing.content.manage.contexts.filtercontent.ManageFilterContentUI
java.awt.FlowLayout
javax.swing.Box
javax.swing.BoxLayout
java.awt.BorderLayout
static org.nuiton.i18n.I18n.*
static org.nuiton.i18n.I18n.t;
</import>
<!--getContextValue est une méthode interne JAXX-->
<ManageContextsUIModel id='model' initializer='getContextValue(ManageContextsUIModel.class)'/>
<ReefDbHelpBroker id='broker' constructorParams='"reefdb.home.help"'/>
<script><![CDATA[
//Le parent est très utile pour intervenir sur les frères
public ManageContextsUI(ReefDbUI parentUI) {
ReefDbUIUtil.setParentUI(this, parentUI);
}
]]></script>
<row>
<cell weightx='1' weighty='1' fill='both'>
<JScrollPane id="scrollPane">
<Table fill='both'>
<row>
<cell weightx='1' weighty='1' fill='both' columns='3'>
<Table>
<row>
<cell weightx='0' weighty='0' fill='both'>
<ManageContextsListMenuUI id="manageContextsListMenuUI" constructorParams='this'/>
</cell>
<cell weightx='1' weighty='1' fill='both' columns='3'>
<Table>
<row>
<cell weightx='1' weighty='0.5' fill='both'>
<ManageContextsListUI id="manageContextsListUI" constructorParams='this'/>
</cell>
</row>
<row>
<cell weightx='1' weighty='0.5' fill='both'>
<Table id="filters">
<row>
<cell weightx='1' weighty='0.3' fill='both'>
<ManageFiltersListUI id="manageFiltersListUI" constructorParams='this'/>
</cell>
</row>
<row>
<cell weightx='1' weighty='0.3' fill='both'>
<ManageFilterContentUI id="manageFilterContentUI" constructorParams='this'/>
</cell>
</row>
</Table>
</cell>
</row>
</Table>
</cell>
</row>
</Table>
</cell>
</row>
<row>
<cell weightx='1' weighty='0' fill='horizontal'>
<JLabel/>
</cell>
<cell weightx='0' weighty='0' fill='horizontal'>
<JPanel layout='{new FlowLayout()}'>
<JButton id='closeButton' alignmentX='{Component.CENTER_ALIGNMENT}'/>
<JLabel/>
<JButton id='saveButton' alignmentX='{Component.CENTER_ALIGNMENT}'/>
</JPanel>
</cell>
<cell weightx='1' weighty='0' fill='horizontal'>
<JLabel/>
</cell>
</row>
</Table>
</JScrollPane>
</cell>
</row>
</Table>
\ No newline at end of file
package fr.ifremer.reefdb.ui.swing.content.manage.contexts;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import fr.ifremer.reefdb.dto.configuration.context.ContextDTO;
import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbUIHandler;
public class ManageContextsUIHandler extends AbstractReefDbUIHandler<ManageContextsUIModel, ManageContextsUI> {
/**
* Logger.
*/
private static final Log LOG = LogFactory.getLog(ManageContextsUIHandler.class);
@Override
public void beforeInit(final ManageContextsUI ui) {
super.beforeInit(ui);
// create model and register to the JAXX context
final ManageContextsUIModel model = new ManageContextsUIModel();
ui.setContextValue(model);
}
@Override
public void afterInit(final ManageContextsUI ui) {
initUI(ui);
// Adjust scrollpane speed
initSpeedScrollPane(getUI().getScrollPane());
// Initialiser les parametres des ecrans Observation et prelevemnts
getContext().clearObservationPrelevementsIds();
listenModelModify(getUI().getManageContextsListUI().getModel());
listenModelValid(getUI().getManageContextsListUI().getModel());
}
@Override
public void onCloseUI() {
if (LOG.isDebugEnabled()) {
LOG.debug("closing: " + getUI());
}
final PropertyChangeListener[] listeners = getModel().getPropertyChangeListeners();
for (final PropertyChangeListener listener : listeners) {
getModel().removePropertyChangeListener(listener);
}
clearValidators();
}
@Override
public SwingValidator<ManageContextsUIModel> getValidator() {
return null;
}
@Override
protected JComponent getComponentToFocus() {
return null;
}
/**
* Load contexts.
* @param idContext Context
*/
public void loadContexts(final Integer idContext) {
getUI().getManageContextsListUI().getManageContextsListTable().getHandler().loadContexteLocal(idContext);
getUI().getManageFiltersListUI().getHandler().setEnabledElements();
getUI().getManageFilterContentUI().getHandler().clearTable();
getUI().getManageFiltersListUI().getHandler().clearTable();
}
public void loadLocalContext(final ContextDTO context) {
getUI().getManageFilterContentUI().getHandler().clearTable();
getUI().getManageFiltersListUI().getHandler().loadContext(context);
}
public void loadFilterElements( Integer filterId) {
getUI().getManageFilterContentUI().getHandler().loadFilterElements(filterId);
}
}
package fr.ifremer.reefdb.ui.swing.content.manage.contexts;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import fr.ifremer.reefdb.dto.VirtualDTO;
import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbBeanUIModel;
public class ManageContextsUIModel extends AbstractReefDbBeanUIModel<VirtualDTO, ManageContextsUIModel> {
private static Binder<ManageContextsUIModel, VirtualDTO> TO_BEAN_BINDER =
BinderFactory.newBinder(ManageContextsUIModel.class, VirtualDTO.class);
private static Binder<VirtualDTO, ManageContextsUIModel> FROM_BEAN_BINDER =
BinderFactory.newBinder(VirtualDTO.class, ManageContextsUIModel.class);
protected ManageContextsUIModel() {
super(FROM_BEAN_BINDER, TO_BEAN_BINDER);
}
@Override
protected VirtualDTO newBean() {
return new VirtualDTO();
}
}
package fr.ifremer.reefdb.ui.swing.content.manage.contexts.actions;
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler;
import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbChangeScreenAction;
import fr.ifremer.reefdb.ui.swing.action.GoToHomeAction;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUI;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUIHandler;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUIModel;
/**
* Action close a configuration screen
*/
public class CloseAction extends AbstractReefDbChangeScreenAction<ManageContextsUIModel, ManageContextsUI, ManageContextsUIHandler> {
/**
* Constructor.
* @param handler Controller
*/
public CloseAction(final ManageContextsUIHandler handler) {
super(handler, true);
}
@Override
protected Class<SaveAction> getSaveActionClass() {
return SaveAction.class;
}
@Override
protected AbstractApplicationUIHandler<?, ?> getSaveHandler() {
return getHandler();
}
@Override
protected Class<GoToHomeAction> getGotoActionClass() {
return GoToHomeAction.class;
}
@Override
protected boolean isModelModify() {
return getModel().isModify();
}
@Override
protected boolean isModelValid() {
return getModel().isValid();
}
@Override
protected void setModelModify(boolean modelModify) {
getModel().setModify(modelModify);
}
}
package fr.ifremer.reefdb.ui.swing.content.manage.contexts.actions;
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import static org.nuiton.i18n.I18n.t;
import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbAction;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUI;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUIHandler;
import fr.ifremer.reefdb.ui.swing.content.manage.contexts.ManageContextsUIModel;
/**
* Action fermer une observation.
*/
public class SaveAction extends AbstractReefDbAction<ManageContextsUIModel, ManageContextsUI, ManageContextsUIHandler> {
/**
* Constructor.
* @param handler Controller
*/
public SaveAction(final ManageContextsUIHandler handler) {
super(handler, true);
}
@Override
public boolean prepareAction() throws Exception {
if (!super.prepareAction()) {
return false;
}
// if the screen can be saved and the screen is valid
boolean isSave = getModel().isModify();
if (isSave && !getModel().isValid()) {
return false;
}
return true;
}
@Override
public void doAction() throws Exception {
// display building warning
displayWarningMessage(t("reefdb.action.enconstruction.titre"), t("reefdb.action.enconstruction.message"));
}
}
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
#manageContextsListTable {
border: {BorderFactory.createTitledBorder(t("reefdb.ui.swing.content.manage.contexts.contextslist.table.title"))};
}
<!--
#%L
Reef DB :: UI
$Id:$
$HeadURL:$
%%
Copyright (C) 2014 - 2015 Ifremer
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
<JPanel layout="{new BorderLayout()}" implements='fr.ifremer.reefdb.ui.swing.util.ReefDbUI&lt;ManageContextsListUIModel, ManageContextsListUIHandler&gt;'>
<import>
fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker
fr.ifremer.reefdb.ui.swing.ReefDbUIContext
fr.ifremer.reefdb.ui.swing.util.ReefDbUI
fr.ifremer.reefdb.ui.swing.util.ReefDbUIUtil
fr.ifremer.reefdb.ui.swing.content.manage.contexts.contextslist.table.ManageContextsListTableUI
java.awt.FlowLayout
javax.swing.Box
javax.swing.BoxLayout
java.awt.BorderLayout
static org.nuiton.i18n.I18n.*
static org.nuiton.i18n.I18n.t;
</import>
<!--getContextValue est une méthode interne JAXX-->
<ManageContextsListUIModel id='model' initializer='getContextValue(ManageContextsListUIModel.class)'/>
<ReefDbHelpBroker id='broker' constructorParams='"reefdb.home.help"'/>
<script><![CDATA[
//Le parent est très utile pour intervenir sur les frères
public ManageContextsListUI(ReefDbUI parentUI) {
ReefDbUIUtil.setParentUI(this, parentUI);
}
]]></script>
<ManageContextsListTableUI id='manageContextsListTable' constructorParams='this' constraints='BorderLayout.CENTER'/>
</JPanel>
\ No newline at end of file
package fr.ifremer.reefdb.ui.swing.content.manage.contexts.contextslist;
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbUIHandler;
/**
* Controlleur pour la gestion des lieux au niveau national
*/
public class ManageContextsListUIHandler extends AbstractReefDbUIHandler<ManageContextsListUIModel, ManageContextsListUI> {
/**
* Logger.
*/
private static final Log LOG = LogFactory.getLog(ManageContextsListUIHandler.class);
@Override
public void beforeInit(ManageContextsListUI ui) {
super.beforeInit(ui);
// create model and register to the JAXX context
ManageContextsListUIModel model = new ManageContextsListUIModel();
ui.setContextValue(model);
}
@Override
public void afterInit(ManageContextsListUI ui) {
initUI(ui);
listenModelModify(getUI().getManageContextsListTable().getModel());
listenModelValid(getUI().getManageContextsListTable().getModel());
}
@Override
public void onCloseUI() {
if (LOG.isDebugEnabled()) {