001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.structure;
034:
035: import java.io.Serializable;
036:
037: /**
038: * Editable FxTypeRelation
039: *
040: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
041: * @see FxTypeRelation
042: */
043: public class FxTypeRelationEdit extends FxTypeRelation implements
044: Serializable {
045: private static final long serialVersionUID = -8795200059643946635L;
046: private FxTypeRelation original;
047:
048: /**
049: * Constructor
050: *
051: * @param relation the FxTypeRelation to make editable
052: */
053: public FxTypeRelationEdit(FxTypeRelation relation) {
054: super (relation.getSource(), relation.getDestination(), relation
055: .getMaxSource(), relation.getMaxDestination());
056: this .original = relation;
057: }
058:
059: public void setMaxSource(int maxSource) {
060: if (maxSource < 0)
061: maxSource = 0;
062: if (maxSource != this .maxSource)
063: this .maxSource = maxSource;
064: }
065:
066: public void setMaxDestination(int maxDestination) {
067: if (maxDestination < 0)
068: maxDestination = 0;
069: if (maxDestination != this .maxDestination)
070: this .maxDestination = maxDestination;
071: }
072:
073: public boolean isChanged() {
074: return this .maxSource != original.maxSource
075: || this .maxDestination != original.maxDestination;
076: }
077:
078: /**
079: * Create a new FxTypeEdit with unlimited source and destination instances
080: *
081: * @param source source type
082: * @param destination destination type
083: * @return FxTypeRelationEdit
084: */
085: public static FxTypeRelationEdit createNew(FxType source,
086: FxType destination) {
087: return new FxTypeRelationEdit(new FxTypeRelation(source,
088: destination, 0, 0));
089: }
090:
091: /**
092: * Create a new FxTypeEdit
093: *
094: * @param source source type
095: * @param destination destination type
096: * @param maxSource maximum number of allowed source instances, unlimited if 0
097: * @param maxDestination maximum number of allowed destination instances, unlimited if 0
098: * @return FxTypeRelationEdit
099: */
100: public static FxTypeRelationEdit createNew(FxType source,
101: FxType destination, int maxSource, int maxDestination) {
102: return new FxTypeRelationEdit(new FxTypeRelation(source,
103: destination, maxSource, maxDestination));
104: }
105: }
|