Search in sources :

Example 1 with EditAttribute

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

the class AttributeComponentEditPolicy method createEditCommand.

@Override
protected Command createEditCommand() {
    EditAttribute edited = ((AttributeDialog) dialog).getEditedValue();
    if (!edited.isEdited()) {
        return null;
    }
    Attribute editedValueAttribute = new Attribute();
    edited.copyTo(editedValueAttribute);
    IAttribute original = edited.getOriginalAttribute();
    EditPart part = getHost();
    if (!(part instanceof IAttributeEditPart)) {
        return null;
    }
    AbstractEntityModel entity = ((IAttributeEditPart) part).getParentModel();
    return new AttributeEditCommand(original, editedValueAttribute, entity);
}
Also used : EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) IAttributeEditPart(org.tmdmaker.ui.editor.gef3.editparts.IAttributeEditPart) Attribute(org.tmdmaker.core.model.Attribute) EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) IAttribute(org.tmdmaker.core.model.IAttribute) IAttribute(org.tmdmaker.core.model.IAttribute) EditPart(org.eclipse.gef.EditPart) IAttributeEditPart(org.tmdmaker.ui.editor.gef3.editparts.IAttributeEditPart) AttributeDialog(org.tmdmaker.ui.dialogs.AttributeDialog) AttributeEditCommand(org.tmdmaker.ui.editor.gef3.commands.AttributeEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel)

Example 2 with EditAttribute

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

the class EditEntityTest method testUpdateTypeAttribute.

@Test
public void testUpdateTypeAttribute() {
    Entity entity = Entity.ofResource(new Identifier("テスト番号")).withDefaultAttribute();
    target = new EditEntity(entity);
    target.updateTypeAttribute("テスト", "テスト1");
    EditAttribute ea = target.getAttributes().get(0);
    assertEquals("テスト1名称", ea.getName());
    entity = Entity.ofEvent(new Identifier("テスト番号")).withDefaultAttribute();
    target = new EditEntity(entity);
    target.updateTypeAttribute("テスト", "テスト1");
    ea = target.getAttributes().get(0);
    assertEquals("テスト1日", ea.getName());
}
Also used : Entity(org.tmdmaker.core.model.Entity) EditEntity(org.tmdmaker.ui.dialogs.model.EditEntity) EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) Identifier(org.tmdmaker.core.model.Identifier) EditEntity(org.tmdmaker.ui.dialogs.model.EditEntity) Test(org.junit.Test)

Example 3 with EditAttribute

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

the class AttributeSettingPanel method updateAttributeTable.

public void updateAttributeTable() {
    attributeTable.removeAll();
    for (EditAttribute ea : entity.getAttributes()) {
        TableItem item = new TableItem(attributeTable, SWT.NULL);
        item.setText(0, ea.getName());
    }
}
Also used : EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) TableItem(org.eclipse.swt.widgets.TableItem)

Example 4 with EditAttribute

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

the class AttributeSettingPanel method createControlComposite.

/**
 * This method initializes controlComposite
 */
private void createControlComposite() {
    GridData gridData6 = new GridData();
    gridData6.horizontalAlignment = GridData.FILL;
    gridData6.verticalAlignment = GridData.CENTER;
    GridData gridData5 = new GridData();
    gridData5.horizontalAlignment = GridData.FILL;
    gridData5.verticalAlignment = GridData.CENTER;
    GridData gridData4 = new GridData();
    gridData4.widthHint = -1;
    gridData4.verticalAlignment = GridData.CENTER;
    gridData4.horizontalAlignment = GridData.FILL;
    GridData gridData3 = new GridData();
    gridData3.widthHint = 60;
    gridData3.verticalAlignment = GridData.CENTER;
    gridData3.horizontalAlignment = GridData.FILL;
    GridData gridData2 = new GridData();
    gridData2.widthHint = 60;
    gridData2.verticalAlignment = GridData.CENTER;
    gridData2.horizontalAlignment = GridData.FILL;
    GridData gridData1 = new GridData();
    gridData1.widthHint = 60;
    gridData1.verticalAlignment = GridData.CENTER;
    gridData1.horizontalAlignment = GridData.FILL;
    controlComposite = new Composite(this, SWT.NONE);
    controlComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    controlComposite.setLayout(new GridLayout());
    newButton = new Button(controlComposite, SWT.NONE);
    newButton.setText(Messages.AddButton);
    newButton.setLayoutData(gridData1);
    newButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            disposeTableEditorIfNeed();
            entity.addAttribute();
            selectedIndex = entity.getMaxAttributeIndex();
            updateSelection();
        }
    });
    upButton = new Button(controlComposite, SWT.NONE);
    upButton.setText(Messages.UpButton);
    upButton.setLayoutData(gridData2);
    upButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            if (selectedIndex == -1 || selectedIndex == 0) {
                return;
            }
            disposeTableEditorIfNeed();
            entity.upAttribute(selectedIndex);
            selectedIndex--;
            updateSelection();
        }
    });
    downButton = new Button(controlComposite, SWT.NONE);
    downButton.setText(Messages.DownButton);
    downButton.setLayoutData(gridData3);
    downButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            if (selectedIndex == -1 || selectedIndex == entity.getMaxAttributeIndex()) {
                return;
            }
            disposeTableEditorIfNeed();
            entity.downAttribute(selectedIndex);
            selectedIndex++;
            updateSelection();
        }
    });
    descButton = new Button(controlComposite, SWT.NONE);
    descButton.setText(Messages.DescriptionButton);
    descButton.setLayoutData(gridData5);
    descButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            if (selectedIndex == -1) {
                return;
            }
            disposeTableEditorIfNeed();
            EditAttribute edit = entity.getEditAttribute(selectedIndex);
            AttributeDialog dialog = new AttributeDialog(getShell(), edit);
            if (dialog.open() == Dialog.OK) {
                EditAttribute edited = dialog.getEditedValue();
                entity.editAttribute(selectedIndex, edited);
                updateSelection();
            }
        }
    });
    deleteButton = new Button(controlComposite, SWT.NONE);
    deleteButton.setText(Messages.RemoveButton);
    deleteButton.setLayoutData(gridData4);
    deleteButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            if (selectedIndex == -1) {
                return;
            }
            disposeTableEditorIfNeed();
            entity.deleteAttribute(selectedIndex);
            if (entity.getMaxAttributeIndex() <= selectedIndex) {
                selectedIndex--;
            }
            updateSelection();
        }
    });
    identifierChangeButton = new Button(controlComposite, SWT.NONE);
    identifierChangeButton.setText(Messages.ToIdentifier);
    identifierChangeButton.setLayoutData(gridData6);
    identifierChangeButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            if (selectedIndex == -1) {
                return;
            }
            disposeTableEditorIfNeed();
            entity.uptoIdentifier(selectedIndex);
            updateSelection();
        }
    });
    identifierChangeButton.setVisible(entity.canUpToIdentifier());
    updateAttributeTable();
}
Also used : EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) AttributeDialog(org.tmdmaker.ui.dialogs.AttributeDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 5 with EditAttribute

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

the class DetailIdentifierSettingPanel method initialize.

private void initialize() {
    GridData gridData1 = new GridData();
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.horizontalAlignment = GridData.FILL;
    gridData1.widthHint = 60;
    gridData1.verticalAlignment = GridData.CENTER;
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = -1;
    gridData.verticalAlignment = GridData.CENTER;
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    identifierLabel = new Label(this, SWT.NONE);
    identifierLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    identifierLabel.setText(Messages.Identifier);
    identifierText = new Text(this, SWT.BORDER);
    identifierText.setLayoutData(gridData);
    identifierText.addModifyListener(new org.eclipse.swt.events.ModifyListener() {

        public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            detail.setIdentifierName(((Text) e.widget).getText());
        }
    });
    descButton = new Button(this, SWT.NONE);
    descButton.setText(Messages.DescriptionButton);
    descButton.setLayoutData(gridData1);
    descButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            AttributeDialog dialog = new AttributeDialog(getShell(), detail.getEditIdentifier());
            if (dialog.open() == Dialog.OK) {
                EditAttribute edited = dialog.getEditedValue();
                if (edited.isEdited()) {
                    detail.updateEditIdentifier(edited);
                    identifierText.setText(edited.getName());
                }
            }
        }
    });
    this.setLayout(gridLayout);
    updateValue();
    setSize(new Point(355, 66));
    isDetailIdentifierEnabledCheckBox = new Button(this, SWT.CHECK);
    isDetailIdentifierEnabledCheckBox.setSelection(detail.isDetailIdentifierEnabled());
    isDetailIdentifierEnabledCheckBox.setEnabled(detail.canDisableDetailIdentifierEnabled());
    isDetailIdentifierEnabledCheckBox.setText(Messages.IsDetailIdentifierEnabled);
    isDetailIdentifierEnabledCheckBox.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            boolean enabled = isDetailIdentifierEnabledCheckBox.getSelection();
            detail.setDetailIdentifierEnabled(enabled);
            identifierText.setEnabled(enabled);
            descButton.setEnabled(enabled);
        }
    });
    identifierText.setEnabled(detail.isDetailIdentifierEnabled());
    descButton.setEnabled(detail.isDetailIdentifierEnabled());
}
Also used : Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) EditAttribute(org.tmdmaker.ui.dialogs.model.EditAttribute) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) AttributeDialog(org.tmdmaker.ui.dialogs.AttributeDialog)

Aggregations

EditAttribute (org.tmdmaker.ui.dialogs.model.EditAttribute)9 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 AttributeDialog (org.tmdmaker.ui.dialogs.AttributeDialog)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Point (org.eclipse.swt.graphics.Point)4 Button (org.eclipse.swt.widgets.Button)4 Text (org.eclipse.swt.widgets.Text)4 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 TableItem (org.eclipse.swt.widgets.TableItem)2 Attribute (org.tmdmaker.core.model.Attribute)2 IAttribute (org.tmdmaker.core.model.IAttribute)2 AttributeEditCommand (org.tmdmaker.ui.editor.gef3.commands.AttributeEditCommand)2 EditPart (org.eclipse.gef.EditPart)1 TableEditor (org.eclipse.swt.custom.TableEditor)1 FocusAdapter (org.eclipse.swt.events.FocusAdapter)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1