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);
}
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());
}
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());
}
}
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();
}
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());
}
Aggregations