RelationalEntityTableAttributeColumnPropertiesDialog.java :  » UML » MetaBoss » com » metaboss » applications » designstudio » propertiesdialogs » Java Open Source

Java Open Source » UML » MetaBoss 
MetaBoss » com » metaboss » applications » designstudio » propertiesdialogs » RelationalEntityTableAttributeColumnPropertiesDialog.java
// THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
// OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Copyright 2000-2005  Softaris Pty.Ltd. All Rights Reserved.
package com.metaboss.applications.designstudio.propertiesdialogs;

import java.awt.Dimension;

import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.metaboss.applications.designstudio.userobjects.AttributeItem;
import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableAttributeColumn;

/*    RelationalEntityTableAttributeColumn properties dialog    */

public class RelationalEntityTableAttributeColumnPropertiesDialog extends ModelElementPropertiesDialog
{
  private JPanel      mOverridePanel = new JPanel();
  //properties
  private JComboBox    mAttributeField = new JComboBox(); 
  private JTextArea     mDescriptionField = new JTextArea(8, 40);  
  //override
  private JTextField     mColumnNameOverrideField = new JTextField(); 
  private JTextField     mReferentialConstraintNameOverrideField = new JTextField(); 
  
  
  public RelationalEntityTableAttributeColumnPropertiesDialog() 
  {
    super("Relational Entity Table Attribute Column", new Dimension(400, 280));

    mOverridePanel.setLayout(mClientGridBagLayout);

    addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
    addComboBox(mPropertiesPanel, "Attribute: ", mAttributeField, 2, true);
    addTextArea(mPropertiesPanel, "Description: ", mDescriptionField, 3, false);

    addTextField(mOverridePanel, "Column Name: ", mColumnNameOverrideField, 1, false);
    addTextField(mOverridePanel, "Referential Constraint Name: ", mReferentialConstraintNameOverrideField, 2, false);
  
    mTabControl.insertTab("Override", null, mOverridePanel, null, 1);  
    mAttributeField.addItemListener(new NameElementChangeListener());
  }
  
  // load entity table properties
  public void loadProperties(ModelElement pObject) throws Exception
  {
    if (pObject!=null && pObject instanceof RelationalEntityTableAttributeColumn)
    {
      RelationalEntityTableAttributeColumn lColumn = (RelationalEntityTableAttributeColumn)pObject; 

      AttributeItem.loadBoxWithAttributes(mAttributeField, lColumn.getTable().getEntity(), false);

      mNameField.setText(lColumn.getName());
      mAttributeField.setSelectedIndex(AttributeItem.findAttributeItemIndex(mAttributeField, lColumn.getAttribute()));
      mColumnNameOverrideField.setText(lColumn.getColumnNameOverride()); 
      mReferentialConstraintNameOverrideField.setText(lColumn.getReferentialConstraintNameOverride()); 
      mDescriptionField.setText(lColumn.getDescription());
    }
    super.loadProperties(pObject);
  }

  // save entity table proeprties
  public void saveProperties(ModelElement pObject) throws Exception
  {
    super.saveProperties(pObject);
    if (pObject!=null && pObject instanceof RelationalEntityTableAttributeColumn)
    {
      RelationalEntityTableAttributeColumn lColumn = (RelationalEntityTableAttributeColumn)pObject; 

      lColumn.setName(mNameField.getText());
      lColumn.setColumnNameOverride(mColumnNameOverrideField.getText()); 
      lColumn.setReferentialConstraintNameOverride(mReferentialConstraintNameOverrideField.getText()); 
      lColumn.setDescription(mDescriptionField.getText());  

      AttributeItem lItem = (AttributeItem)mAttributeField.getSelectedItem();
      if (lItem!=null)
        lColumn.setAttribute(lItem.mAttribute);
      else
        lColumn.setAttribute(null);
    }
  }
  
  protected ModelElement getNameElement()
  {
    ModelElement lResult = null;
    try
    {
      lResult = ((AttributeItem)mAttributeField.getSelectedItem()).mAttribute;
    }
    catch (Exception e)
    {
      lResult = null;
    }
    return lResult;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.