Package org.sintef.umt.hutntree

Source Code of org.sintef.umt.hutntree.HutnEditor

// UML Model Transformation Tool (UMT)
// Copyright (C) 2003, 2004, 2005 SINTEF
// Authors:  jon.oldevik at sintef.no | roy.gronmo at sintef.no | tor.neple at sintef.no | fredrik.vraalsen at sintef.no
// Webpage: http://umt.sourceforge.net
// Deloped in the projects:  ACEGIS (EU project - IST-2002-37724),
//    CAFE (EUREKA/ITEA - ip00004), FAMILIES (ITEA project ip02009)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1
// 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307 USA
package org.sintef.umt.hutntree;

/**
* @author    Jon Oldevik, (jon.oldevik@sintef.no)
* @copyright (c) SINTEF 2002 (www.sintef.no)
*/



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;

import java.io.*;
import java.util.Collection;


import org.sintef.umt.systemfamily.SystemFamilyTreeView;
import org.sintef.umt.systemfamily.VariabilityManager;
import org.sintef.umt.umtmain.UMTMain;
import org.sintef.umt.umtmain.WorkContext;
import org.w3c.dom.Element;

public class HutnEditor extends JPanel implements ActionListener
{
  private volatile HutnTreeView view = null;
  private HutnReaderWriter xmi = null;
  private Reader reader = null;
  private HutnModelListener _modellistener;
  private UMTMain _umtmain;
  private String _project_context = "";
 
  public HutnEditor (HutnModelListener listener)
  {
    super (new BorderLayout ());
    _modellistener = listener;   
    setBorder (new TitledBorder(new EtchedBorder(), "Model Viewer"));
    setTreeView();
  }

  private void setTreeView () {
    if (UMTMain.getUmtType() == UMTMain.UMT_STANDARD)
        view = new HutnTreeView (_modellistener);
    else if (UMTMain.getUmtType() == UMTMain.UMT_SYSTEM_FAMILY) {
        view = new SystemFamilyTreeView (_modellistener);
    }     
    // view.setUMTMain(_umtmain);
    view.setName("The Hutn Tree");
    add (view);
  }
 
  public void repaint() {
      super.repaint();
      if (view != null) {
          view.repaint();
          view.validate();
      }
  }
  public void setUMTMain (UMTMain umtmain) {
      view.setUMTMain(umtmain);
    _umtmain = umtmain;
  }
 
  /**
   * Reads XML DOM Elements from the XMI Light and sets the elements of the view.
   * @param r - the reader
   */
  public void openHutnReader (Reader r, String type)
  {
    try{
      reader = r;
      HutnReaderWriter hutn = new HutnReaderWriter ();   
      // hutn.addResolveLocation(cur_file);   
      Collection c = hutn.read (reader);
     
      int umttype = UMTMain.getUmtType();
      // System.out.println (" TYPE : " + type);
      if (umttype == UMTMain.UMT_SYSTEM_FAMILY) {
          if (type.equalsIgnoreCase("system-family")) {
              ((SystemFamilyTreeView)view).addSystemFamilyElements(c);
              /*
              VariabilityManager varMgr = new VariabilityManager ();
              varMgr.storeVariabilityHtml(c);             
              varMgr.variabilityPanel(c);
              */
             
              WorkContext wc = _umtmain.getWorkContext();
              wc.setState(WorkContext.STATE_OPENED_FILE);
          }
          else
              ((SystemFamilyTreeView)view).addSystemFamilyElements(c);
      } else {
        view.addModelElements(c);
      }
      validate ();
    } catch (Exception ex){
      ex.printStackTrace ();
    }
  }
 
  /**
   * Returns the root 'userobject' of the contained treeview
   * @return
   */
  public Element getModelRoot () {
      return view.getModelRoot();
  }
 
  public void setLoading (boolean loading) {
    view.setLoading(loading);
  }
 
  public void setTransforming (boolean transforming) {
    view.setTransforming(transforming);
  }
 
  public String getTreeBuffer () {
    return view.getTreeBuffer();
  }
 
  public void closeView () {
      view.clear();
    validate ();
  }
 
  public void actionPerformed (ActionEvent ae)
  { 
  } 
}
TOP

Related Classes of org.sintef.umt.hutntree.HutnEditor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.