blob: defb11f1bb748230731c082779b8b94dea12a5c2 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Zoltan Ujhelyi and Daniel Varro.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Zoltan Ujhelyi - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.visualisation.patterns.viewmodel;
import java.util.ArrayList;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTPatternBody;
/**
* View model element representing a pattern body. A pattern body consists of a
* pattern graph represented by a list of view model elements (instead the root
* of the model as in {link {@link GTPatternBody}, and called positive and
* negative patterns.
* @author Zoltan Ujhelyi
*/
public class ViewPatternBody extends AbstractViewModelElement{
// GTPatternBody body;
ArrayList<ViewPattern> calledPatterns = new ArrayList<ViewPattern>();
ArrayList<ViewPatternModelElement> elements = new ArrayList<ViewPatternModelElement>();
int id;
/**
* Adds a pattern model element to the pattern body model.
* @param entity
*/
public void addEntity(ViewPatternModelElement entity) {
elements.add(entity);
}
/**
* Adds a called pattern to the pattern body.
* @param pattern
*/
public void addCalledPattern(ViewPattern pattern) {
calledPatterns.add(pattern);
}
/**
* @param body
* the body to set
*/
public void setBody(GTPatternBody body) {
// this.body = body;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* Return the children of the body node. The children are the elements of
* the pattern graph and the called positive and negative patterns.
* @return the children of the body node
*/
public Object[] getChildren() {
ArrayList<Object> children = new ArrayList<Object>();
children.addAll(elements);
children.addAll(calledPatterns);
return children.toArray();
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Body #" + Integer.toString(id);
}
@Override
public String getName() {
return toString();
}
@Override
public String getTypeString() {
return "Pattern Body";
}
}