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