001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio;
016:
017: import java.util.ArrayList;
018:
019: import javax.swing.JPanel;
020:
021: import com.metaboss.applications.designstudio.Application.OptionsChangedEvent;
022: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
023: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
024:
025: /* Base Child Panel class */
026:
027: public class BaseChildPanel extends JPanel {
028: protected ModelElement mObject = null;
029: protected boolean mChanged = false;
030: protected Application.OptionsChangedListener mOptionsChangedListener = null;
031:
032: public BaseChildPanel(ModelElement pObject) {
033: super ();
034:
035: mObject = pObject;
036: mOptionsChangedListener = new Application.OptionsChangedListener() {
037: public void optionsChanged(OptionsChangedEvent event) {
038: updateComponents();
039: }
040: };
041:
042: Application.addOptionsEventListener(mOptionsChangedListener);
043: }
044:
045: public void setVisible(boolean aFlag) {
046: if (!aFlag && getChanged())
047: saveContent();
048: super .setVisible(aFlag);
049: }
050:
051: public ModelElement getBOObject() {
052: return mObject;
053: }
054:
055: // get element package
056: public MetaBossModelPackage getPackage() {
057: if (mObject != null)
058: return BaseUserObject.getObjectPackage(mObject);
059: else
060: return null;
061: }
062:
063: // return Actions array
064: public Object[] getActions() {
065: ArrayList lActionsList = new ArrayList();
066: fillActions(lActionsList);
067: return lActionsList.toArray();
068: }
069:
070: // fill actions list
071: protected void fillActions(ArrayList pActionList) {
072: //???
073: }
074:
075: public String toString() {
076: return getName();
077: //return super.toString();
078: }
079:
080: // remove events listeners
081: public void removeEventsListeners() {
082: if (mOptionsChangedListener != null)
083: Application
084: .removeOptionsEventListener(mOptionsChangedListener);
085: }
086:
087: // called when properties were changed
088: protected void updateComponents() {
089: //???
090: }
091:
092: // get content changed flag
093: public boolean getChanged() {
094: return mChanged;
095: }
096:
097: public void setChanged(boolean pValue) {
098: if (pValue != mChanged) {
099: mChanged = pValue;
100: if (mChanged)
101: Application.fireOnContainerChanged(this );
102: }
103: }
104:
105: // save content
106: public void saveContent() {
107: setChanged(false);
108: }
109:
110: // method called when panel activated in the container window
111: public void containerActivate() {
112: //???
113: }
114: }
|