org.efaps.ui.wicket.models.objects.UIFieldStructurBrowser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of efaps-webapp Show documentation
Show all versions of efaps-webapp Show documentation
eFaps WebApp provides a web interface as the User Interface for eFaps
which can be easily expanded and altered.
/*
* Copyright 2003 - 2012 The eFaps Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Revision: $Rev: 8387 $
* Last Changed: $Date: 2012-12-14 17:23:39 -0500 (Fri, 14 Dec 2012) $
* Last Changed By: $Author: [email protected] $
*/
package org.efaps.ui.wicket.models.objects;
import java.util.UUID;
import org.efaps.admin.AbstractAdminObject;
import org.efaps.admin.ui.AbstractCommand.SortDirection;
import org.efaps.admin.ui.AbstractUserInterfaceObject.TargetMode;
import org.efaps.admin.ui.field.Field.Display;
import org.efaps.admin.ui.field.FieldTable;
import org.efaps.db.Instance;
import org.efaps.util.EFapsException;
/**
* Object used for a StructurBrowser nested in a Form.
*
* @author The eFaps Team
* @version $Id: UIFieldStructurBrowser.java 8387 2012-12-14 22:23:39Z [email protected] $
*/
public class UIFieldStructurBrowser
extends UIStructurBrowser
implements IFormElement
{
/**
* Needed for serialization.
*/
private static final long serialVersionUID = 1L;
/**
* Id of the Field this Field Structur Browser belongs to.
*/
private final Long fieldTabelId;
/**
* @param _commandUUID uuid of the calling command
* @param _instanceKey key to the instance
* @param _field Field
* @throws EFapsException on error
*/
public UIFieldStructurBrowser(final UUID _commandUUID,
final String _instanceKey,
final FieldTable _field)
throws EFapsException
{
super(_commandUUID, _instanceKey);
setTableUUID(_field.getTargetTable().getUUID());
setBrowserFieldName(_field.getTargetStructurBrowserField());
this.fieldTabelId = _field.getId();
setShowCheckBoxes(_field.isTargetShowCheckBoxes());
setForceExpanded(_field.isTargetStructurBrowserForceExpand());
}
/**
* @param _commandUUID uuid of the calling command
* @param _instanceKey key to the instance
* @param _sortdirection sort direction
* @param _field Field
* @throws EFapsException on error
*/
private UIFieldStructurBrowser(final UUID _commandUUID,
final String _instanceKey,
final SortDirection _sortdirection,
final FieldTable _field)
throws EFapsException
{
super(_commandUUID, _instanceKey, false, _sortdirection);
setTableUUID(_field.getTargetTable().getUUID());
setBrowserFieldName(_field.getTargetStructurBrowserField());
this.fieldTabelId = _field.getId();
setShowCheckBoxes(_field.isTargetShowCheckBoxes());
setForceExpanded(_field.isTargetStructurBrowserForceExpand());
}
/**
* {@inheritDoc}
*/
@Override
protected UIStructurBrowser getNewStructurBrowser(final Instance _instance,
final UIStructurBrowser _parent)
throws EFapsException
{
final FieldTable field = FieldTable.get(((UIFieldStructurBrowser) _parent).fieldTabelId);
final UIFieldStructurBrowser ret = new UIFieldStructurBrowser(_parent.getCommandUUID(), _instance == null
? null : _instance.getKey(), _parent.getSortDirection(), field);
ret.setParentBrws(this);
ret.setLevel(getLevel() + 1);
return ret;
}
/**
* {@inheritDoc}
*/
@Override
protected void initialise()
throws EFapsException
{
if (getCommand() == null) {
super.initialise();
}
}
/**
* {@inheritDoc}
*/
@Override
protected AbstractAdminObject getObject4Event()
{
return FieldTable.get(this.fieldTabelId);
}
/**
* Get the Display of the Field this StructurBrowser is bedded in.
* @param _mode target mode the display will be evaluate for
* @return Display
*/
public Display getFieldDisplay(final TargetMode _mode)
{
return FieldTable.get(this.fieldTabelId).getDisplay(_mode);
}
/**
* In create or edit mode this StructurBrowser is editable,
* if the Field this StructurBroeser is bedded in is editable also.
*
* @return is this StructurBrowser editable.
*/
@Override
public boolean isEditable()
{
return getFieldDisplay(getMode()).equals(Display.EDITABLE) && (isCreateMode() || isEditMode());
}
}