use of org.tmdmaker.core.model.KeyModel in project tmdmaker by tmdmaker.
the class TMDEditorOutlineTreePartFactory method createEditPart.
/**
* @param context
* コンテキスト
* @param model
* TMのモデル
* @return EditPart modelに対応したEditPart
*/
@Override
public final EditPart createEditPart(final EditPart context, final Object model) {
EditPart part = null;
if (model instanceof ModelElement) {
ModelElement element = (ModelElement) model;
TMDOutlineTreeEditPartVisitor visitor = new TMDOutlineTreeEditPartVisitor();
element.accept(visitor);
return visitor.getEditPart();
} else if (model instanceof KeyModel) {
logger.debug("KeyModel用の EditPart を返しました");
logger.debug(((KeyModel) model).getName());
part = new KeyModelTreeEditPart();
} else if (model instanceof List<?>) {
logger.debug("フォルダー用EditPartを準備します。");
List<?> list = (List<?>) model;
if (list.size() > 0) {
if (list.get(0) instanceof Identifier) {
logger.debug("個体指定子のフォルダー用EditPartを返しました。");
part = new FolderTreeEditPart<Identifier>(Messages.Identifier);
} else if (list.get(0) instanceof Attribute) {
logger.debug("属性のフォルダー用EditPartを返しました。");
part = new FolderTreeEditPart<Attribute>(Messages.Attribute);
} else if (list.get(0) instanceof KeyModel) {
logger.debug("キーのフォルダー用EditPartを返しました。");
part = new FolderTreeEditPart<KeyModel>(Messages.KeyDefinitions);
}
}
}
if (part != null) {
part.setModel(model);
}
return part;
}
use of org.tmdmaker.core.model.KeyModel in project tmdmaker by tmdmaker.
the class EditImplementEntity method addAttribute.
/**
* アトリビュートを追加する
*
* @param attribute
* 追加するアトリビュート
*/
public void addAttribute(EditImplementAttribute attribute) {
attributes.add(attribute);
for (KeyModel ek : keyModels) {
attribute.addKeyModel(ek);
}
firePropertyChange(PROPERTY_ATTRIBUTES, null, attribute);
}
use of org.tmdmaker.core.model.KeyModel in project tmdmaker by tmdmaker.
the class EditImplementEntity method removeAttribute.
/**
* アトリビュートを削除する
*
* @param attribute
* 削除するアトリビュート
* @return 削除したアトリビュート。アトリビュートが存在しなかった場合はnullを返す。
*/
public EditImplementAttribute removeAttribute(EditImplementAttribute attribute) {
int index = attributes.indexOf(attribute);
if (index >= 0) {
EditImplementAttribute removed = attributes.remove(index);
List<KeyModel> toBeRemoved = new ArrayList<KeyModel>();
for (KeyModel ek : keyModels) {
ek.getAttributes().remove(removed.getOriginalAttribute());
// アトリビュートが存在しないキーモデルは削除対象とする
if (ek.getAttributes().isEmpty()) {
toBeRemoved.add(ek);
}
}
for (KeyModel ek : toBeRemoved) {
keyModels.remove(ek);
for (EditImplementAttribute a : attributes) {
a.removeKeyModel(ek);
}
}
return removed;
} else {
return null;
}
}
use of org.tmdmaker.core.model.KeyModel in project tmdmaker by tmdmaker.
the class KeyDefinitionListHtmlGenerator method createData.
private Map<IAttribute, List<KeyDefinitionMapping>> createData(AbstractEntityModel model) {
List<IAttribute> attributes = ImplementRule.findAllImplementAttributes(model);
Map<IAttribute, List<KeyDefinitionMapping>> data = new LinkedHashMap<IAttribute, List<KeyDefinitionMapping>>();
for (IAttribute a : attributes) {
List<KeyDefinitionMapping> list = new ArrayList<KeyDefinitionMapping>();
for (KeyModel k : model.getKeyModels()) {
list.add(new KeyDefinitionMapping(a, k));
}
data.put(a, list);
}
return data;
}
use of org.tmdmaker.core.model.KeyModel in project tmdmaker by tmdmaker.
the class IndexSettingPanel method initialize.
private void initialize() {
GridData gridData1 = new GridData();
gridData1.horizontalAlignment = SWT.FILL;
gridData1.verticalAlignment = GridData.BEGINNING;
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalSpan = 3;
gridData.grabExcessVerticalSpace = false;
gridData.heightHint = 150;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = GridData.FILL;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
indexTable = new Table(this, SWT.MULTI);
indexTable.setHeaderVisible(true);
indexTable.setLayoutData(gridData);
indexTable.setLinesVisible(true);
addButton = new Button(this, SWT.NONE);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
addButton.setText(Messages.AddButton);
updateButton = new Button(this, SWT.NONE);
updateButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
updateButton.setText(Messages.UpdateButton);
updateButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (selectColumnIndex == -1) {
return;
}
KeyModel model = implementModel.getKeyModel(selectColumnIndex);
java.util.List<IAttribute> notSelectedAttributes = new ArrayList<IAttribute>();
for (EditImplementAttribute ea : implementModel.getAttributes()) {
notSelectedAttributes.add(ea.getOriginalAttribute());
}
IndexEditDialog dialog = new IndexEditDialog(getShell(), model, implementModel.getAttributes());
if (dialog.open() == Dialog.OK) {
KeyModel keyModel = dialog.getKeyModel();
implementModel.replaceKeyModel(selectColumnIndex, keyModel);
}
}
});
deleteButton = new Button(this, SWT.NONE);
deleteButton.setText(Messages.RemoveButton);
deleteButton.setLayoutData(gridData1);
deleteButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (selectColumnIndex == -1) {
return;
}
implementModel.removeKeyModel(selectColumnIndex);
}
});
addButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
java.util.List<IAttribute> notSelectedAttributes = new ArrayList<IAttribute>();
for (EditImplementAttribute ea : implementModel.getAttributes()) {
notSelectedAttributes.add(ea.getOriginalAttribute());
}
IndexEditDialog dialog = new IndexEditDialog(getShell(), implementModel.getImplementName(), implementModel.getAttributes());
if (dialog.open() == Dialog.OK) {
KeyModel keyModel = dialog.getKeyModel();
implementModel.addKeyModel(keyModel);
}
}
});
TableColumn tableColumn = new TableColumn(indexTable, SWT.NONE);
tableColumn.setWidth(150);
tableColumn.setText(Messages.AttributeName);
this.setLayout(gridLayout);
this.setSize(new Point(318, 176));
}
Aggregations