jadex.bpmn.editor.model.legacy.MultiColumnTableEx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-editor-bpmn Show documentation
Show all versions of jadex-editor-bpmn Show documentation
Editor for Business Process Model and Notation (BPMN).
/**
*
*/
package jadex.bpmn.editor.model.legacy;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jadex.bpmn.model.MAnnotation;
import jadex.bpmn.model.MAnnotationDetail;
/**
* ADAPTED !!! Copy of editor table version
* @author Claas
*
*/
public class MultiColumnTableEx extends MultiColumnTable
{
// ---- attributes ----
boolean[] isComplexColumn;
Map> complexValues;
// ---- constructors ----
/**
* @param rowCount
* @param uniqueColumn
*/
public MultiColumnTableEx(int rowCount, boolean[] complexColumnMarker)
{
super(rowCount);
this.isComplexColumn = complexColumnMarker;
this.complexValues = new HashMap>();
}
/**
* @param rowCount
* @param uniqueColumn
*/
public MultiColumnTableEx(MultiColumnTable table)
{
this(table.getRowList().size(), null);
// add rows from table
for (MultiColumnTableRow row : table.getRowList())
{
super.add(row);
}
}
// ---- getter / setter ----
/**
* @return the complexColumnMarker[]
*/
public boolean[] getComplexColumnsMarker()
{
return isComplexColumn;
}
/**
* Add a complex value to this table
* @param identifier
* @param value map
*/
public void setComplexValue(String identifier, Map value)
{
this.complexValues.put(identifier, value);
}
/**
* Get a complex value from this table
* @param identifier
* @return value map
*/
public Map getComplexValue(String identifier)
{
return this.complexValues.get(identifier);
}
// ---- methods ----
/**
* Get the cell value.
* @param row The row.
* @param i The column.
*/
public String getCellValue(int row, int i)
{
// MultiColumnTableRow multiColumnTableRow = get(row);
// if (isComplexColumn(i))
// {
// return getComplexValue((String)multiColumnTableRow.getColumnValueAt(i));
// }
return (String)get(row).getColumnValueAt(i);
}
/**
* If this method returns true for a column index, the value
* of this column is only a indirection key for a other value
* annotation.
*
* @param coulumnIndex
* @return true, if the column contains a complex value reference
*/
public boolean isComplexColumn(int coulumnIndex)
{
if (isComplexColumn != null && coulumnIndex < isComplexColumn.length)
return isComplexColumn[coulumnIndex];
return false;
}
// ---- overrides ----
// /**
// * @see jadex.editor.common.model.properties.table.MultiColumnTable#add(int, jadex.editor.common.model.properties.table.MultiColumnTable.MultiColumnTableRow)
// */
// public void add(int index, MultiColumnTableRow row)
// {
// // no complex type in table
// if (isComplexColumn == null)
// {
// super.add(index, row);
// return;
// }
//
// // ensure unique reference identifier for complex types
// for (int column = 0; column < isComplexColumn.length; column++)
// {
// if (isComplexColumn[column])
// {
// row.setColumnValueAt(column, createUniqueValue(row.getColumnValueAt(column)));
// }
// }
//
// super.add(index, row);
//
// }
/**
*
* @param string
* @return string as boolean[] marker
*/
public static boolean[] decodeComplexColumnMarker(String markerString)
{
boolean[] marker = null;
if (markerString != null && !(markerString.trim().length() == 0))
{
String[] split = markerString
.split(":");
marker = new boolean[split.length];
for (int i = 0; i < split.length; i++)
{
marker[i] = Boolean.parseBoolean(split[i]);
}
}
return marker;
}
/**
*
* @param marker
* @return boolean[] marker as String
*/
public static String encodeComplexColumnMarker(boolean[] marker)
{
if (marker != null)
{
StringBuffer b = new StringBuffer();
for (int i = 0; i < marker.length; i++)
{
b.append(marker[i]);
if (i + 1 < marker.length)
{
b.append(":");
}
}
return b.toString();
}
return "";
}
/**
* Convert the List of MAnnotationDetail to a Map.
* @param details
* @return Map with key value pairs of annptation Detail
*/
public static Map convertDetailsToMap(List details)
{
if (details == null)
return null;
Map returnMap = new HashMap();
for(int j=0; j