Search in sources :

Example 1 with KeyModel

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;
}
Also used : ModelElement(org.tmdmaker.core.model.ModelElement) KeyModel(org.tmdmaker.core.model.KeyModel) Identifier(org.tmdmaker.core.model.Identifier) Attribute(org.tmdmaker.core.model.Attribute) EditPart(org.eclipse.gef.EditPart) List(java.util.List)

Example 2 with KeyModel

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);
}
Also used : KeyModel(org.tmdmaker.core.model.KeyModel)

Example 3 with KeyModel

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;
    }
}
Also used : KeyModel(org.tmdmaker.core.model.KeyModel) ArrayList(java.util.ArrayList)

Example 4 with KeyModel

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;
}
Also used : KeyModel(org.tmdmaker.core.model.KeyModel) IAttribute(org.tmdmaker.core.model.IAttribute) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with KeyModel

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));
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Table(org.eclipse.swt.widgets.Table) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) IndexEditDialog(org.tmdmaker.ui.dialogs.IndexEditDialog) GridLayout(org.eclipse.swt.layout.GridLayout) KeyModel(org.tmdmaker.core.model.KeyModel) Button(org.eclipse.swt.widgets.Button) EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute) GridData(org.eclipse.swt.layout.GridData) IAttribute(org.tmdmaker.core.model.IAttribute) ArrayList(java.util.ArrayList) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

KeyModel (org.tmdmaker.core.model.KeyModel)6 ArrayList (java.util.ArrayList)3 List (java.util.List)2 IAttribute (org.tmdmaker.core.model.IAttribute)2 LinkedHashMap (java.util.LinkedHashMap)1 EditPart (org.eclipse.gef.EditPart)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 Attribute (org.tmdmaker.core.model.Attribute)1 Identifier (org.tmdmaker.core.model.Identifier)1 ModelElement (org.tmdmaker.core.model.ModelElement)1 IndexEditDialog (org.tmdmaker.ui.dialogs.IndexEditDialog)1 EditImplementAttribute (org.tmdmaker.ui.dialogs.model.EditImplementAttribute)1