/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* 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:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.models;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.java.dev.genesis.annotation.DataProvider;
import net.java.dev.genesis.annotation.NotBound;
import de.innovationgate.eclipse.editors.design.dialogs.AddContentTypeMetaDefinitionDialog;
import de.innovationgate.eclipse.utils.ui.AbstractGenesisBoundObject;
import de.innovationgate.eclipse.utils.ui.model.WGASchemaDefinitionModel;
import de.innovationgate.utils.WGUtils;
import de.innovationgate.webgate.api.WGContentType;
import de.innovationgate.webgate.api.schemadef.WGContentTypeDefinition;
import de.innovationgate.webgate.api.schemadef.WGMetaFieldDefinition;
import de.innovationgate.wga.model.KeyValueBean;
public class WGEditorsMetaFieldDefinitionModel extends WGContentTypeDefinitionMetaDataModel {
public WGEditorsMetaFieldDefinitionModel(WGASchemaDefinitionModel model) {
super(model);
}
public String getName() {
return AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(_bean.getName());
}
public void setName(String name) {
// noop
}
@SuppressWarnings("unchecked")
@NotBound
public List<String> getEditors(WGContentTypeDefinition ctDef) {
Iterator<WGMetaFieldDefinition> ctDefMetas = ctDef.getMetadata().iterator();
WGMetaFieldDefinition editorsDef = null;
while (ctDefMetas.hasNext()) {
WGMetaFieldDefinition metaFieldDef = ctDefMetas.next();
if (metaFieldDef.getName().equals(WGContentType.META_EDITORS)) {
editorsDef = metaFieldDef;
break;
}
}
if (editorsDef == null) {
editorsDef = new WGMetaFieldDefinition(WGContentType.META_EDITORS, new ArrayList<String>());
ctDef.addMetadata(editorsDef);
}
return (List<String>)editorsDef.getValues();
}
}