Search in sources :

Example 1 with EditImplementAttribute

use of org.tmdmaker.ui.dialogs.model.EditImplementAttribute in project tmdmaker by tmdmaker.

the class IndexEditDialog method createKeyName.

private String createKeyName(String implementEntityName, List<EditImplementAttribute> editAttributeList) {
    String modelName = null;
    int keyCount = 0;
    if (editAttributeList != null && editAttributeList.size() > 0) {
        EditImplementAttribute a = editAttributeList.get(0);
        modelName = implementEntityName;
        keyCount = a.getKeyCount();
    } else {
        // この処理は行われないはず
        // $NON-NLS-1$
        modelName = "";
    }
    // $NON-NLS-1$
    return modelName + "_IDX" + (keyCount + 1);
}
Also used : EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute)

Example 2 with EditImplementAttribute

use of org.tmdmaker.ui.dialogs.model.EditImplementAttribute in project tmdmaker by tmdmaker.

the class ImplementInfoEditAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    ImplementInfoEditDialog dialog = new ImplementInfoEditDialog(getPart().getViewer().getControl().getShell(), getModel());
    if (dialog.open() == Dialog.OK) {
        CompoundCommand ccommand = new CompoundCommand();
        ccommand.add(new ModelEditCommand(getModel(), dialog.getEditedValueEntity()));
        for (EditImplementAttribute ea : dialog.getEditedValueAttributes()) {
            IAttribute original = ea.getOriginalAttribute();
            IAttribute newAttribute = original.getCopy();
            ea.copyTo(newAttribute);
            ccommand.add(new AttributeEditCommand(original, newAttribute, ea.getContainerModel()));
        }
        SurrogateKey newSurrogateKey = new SurrogateKey();
        EditSurrogateKey edited = dialog.getEditedSurrogateKey();
        edited.copyTo(newSurrogateKey);
        ImplementRule.setSurrogateKeyDefaultValue(newSurrogateKey);
        SurrogateKey original = (SurrogateKey) edited.getOriginalAttribute();
        ccommand.add(new AttributeEditCommand(original, newSurrogateKey, edited.getContainerModel()));
        execute(ccommand);
    }
}
Also used : EditSurrogateKey(org.tmdmaker.ui.dialogs.model.EditSurrogateKey) EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute) ImplementInfoEditDialog(org.tmdmaker.ui.dialogs.ImplementInfoEditDialog) IAttribute(org.tmdmaker.core.model.IAttribute) AttributeEditCommand(org.tmdmaker.ui.editor.gef3.commands.AttributeEditCommand) ModelEditCommand(org.tmdmaker.ui.editor.gef3.commands.ModelEditCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EditSurrogateKey(org.tmdmaker.ui.dialogs.model.EditSurrogateKey) SurrogateKey(org.tmdmaker.core.model.SurrogateKey)

Example 3 with EditImplementAttribute

use of org.tmdmaker.ui.dialogs.model.EditImplementAttribute in project tmdmaker by tmdmaker.

the class ImplementInfoEditDialog method createDialogArea.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(Messages.EditImplementInformation);
    TabFolder tabFolder = new TabFolder(parent, SWT.NULL);
    // 1つめのタブを作成
    TabItem item1 = new TabItem(tabFolder, SWT.NULL);
    item1.setText(Messages.TableDesign);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Composite composite = new Composite(tabFolder, SWT.NULL);
    composite.setLayout(gridLayout);
    panel1 = new ImplementInfoEditPanel(composite, SWT.NULL, implementModel);
    panel1.setLayoutData(gridData);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    panel2 = new ModelSelectPanel(composite, SWT.NULL);
    List<AbstractEntityModel> selectModels = model.getImplementDerivationModels();
    List<AbstractEntityModel> notSelectModels = ImplementRule.findNotImplementModel(model);
    notSelectModels.removeAll(selectModels);
    panel2.initializeValue(selectModels, notSelectModels);
    panel2.setLayoutData(gridData);
    item1.setControl(composite);
    updateButton = new Button(composite, SWT.NULL);
    updateButton.setText(Messages.ReflectAttribute);
    updateButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            for (Map.Entry<AbstractEntityModel, List<EditImplementAttribute>> entry : otherModelAttributesMap.entrySet()) {
                editAttributeList.removeAll(entry.getValue());
            }
            for (AbstractEntityModel m : panel2.getSelectModels()) {
                List<EditImplementAttribute> list = otherModelAttributesMap.get(m);
                if (list != null) {
                    editAttributeList.addAll(list);
                }
            }
            panel1.updateTable();
        }
    });
    // 2つめのタブを作成
    TabItem item2 = new TabItem(tabFolder, SWT.NULL);
    item2.setText(Messages.KeyDefinitions);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    composite = new Composite(tabFolder, SWT.NULL);
    composite.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    panel3 = new IndexSettingPanel(composite, SWT.NULL, implementModel);
    panel3.setLayoutData(gridData);
    panel3.updateTable();
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    panel4 = new SurrogateKeyPanel(composite, SWT.NULL, implementModel);
    panel4.setLayoutData(gridData);
    panel4.refreshVisual();
    item2.setControl(composite);
    composite.pack();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ImplementInfoEditPanel(org.tmdmaker.ui.dialogs.components.ImplementInfoEditPanel) TabFolder(org.eclipse.swt.widgets.TabFolder) TabItem(org.eclipse.swt.widgets.TabItem) ModelSelectPanel(org.tmdmaker.ui.dialogs.components.ModelSelectPanel) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute) SurrogateKeyPanel(org.tmdmaker.ui.dialogs.components.SurrogateKeyPanel) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) IndexSettingPanel(org.tmdmaker.ui.dialogs.components.IndexSettingPanel) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel)

Example 4 with EditImplementAttribute

use of org.tmdmaker.ui.dialogs.model.EditImplementAttribute 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)

Example 5 with EditImplementAttribute

use of org.tmdmaker.ui.dialogs.model.EditImplementAttribute in project tmdmaker by tmdmaker.

the class IndexSettingPanel method updateTable.

public void updateTable() {
    setupTableColumns();
    indexTable.removeAll();
    int size = implementModel.getKeyModels().size();
    if (size < selectColumnIndex) {
        selectColumnIndex = size;
    }
    for (int i = 0; i < size; i++) {
        TableColumn column = indexTable.getColumn(i + 1);
        if (implementModel.getKeyModel(i).isMasterKey()) {
            // $NON-NLS-1$
            column.setText("M");
        } else {
            column.setText(String.valueOf(i + 1));
        }
    }
    for (EditImplementAttribute attribute : implementModel.getAttributes()) {
        TableItem item = new TableItem(indexTable, SWT.NONE);
        item.setText(0, attribute.getName());
        java.util.List<String> keyOrders = attribute.getKeyOrders();
        int orderSize = keyOrders.size();
        for (int i = 0; i < orderSize; i++) {
            item.setText(i + 1, keyOrders.get(i));
        }
    }
}
Also used : EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute) TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Aggregations

EditImplementAttribute (org.tmdmaker.ui.dialogs.model.EditImplementAttribute)7 Point (org.eclipse.swt.graphics.Point)3 ArrayList (java.util.ArrayList)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 TableItem (org.eclipse.swt.widgets.TableItem)2 IAttribute (org.tmdmaker.core.model.IAttribute)2 List (java.util.List)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 Composite (org.eclipse.swt.widgets.Composite)1 TabFolder (org.eclipse.swt.widgets.TabFolder)1 TabItem (org.eclipse.swt.widgets.TabItem)1 Table (org.eclipse.swt.widgets.Table)1 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)1 KeyModel (org.tmdmaker.core.model.KeyModel)1 StandardSQLDataType (org.tmdmaker.core.model.StandardSQLDataType)1