svnno****@sourc*****
svnno****@sourc*****
2009年 2月 21日 (土) 12:26:42 JST
Revision: 2696 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2696 Author: daisuke_m Date: 2009-02-21 12:26:42 +0900 (Sat, 21 Feb 2009) Log Message: ----------- テーブル編集ダイアログ・インデックスタブの表示。 Modified Paths: -------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialog.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogLocalKeyTab.java Added Paths: ----------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java Removed Paths: ------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab2.java -------------- next part -------------- Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialog.java 2009-02-20 10:13:56 UTC (rev 2695) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialog.java 2009-02-21 03:26:42 UTC (rev 2696) @@ -74,7 +74,7 @@ private TableEditDialogCheckTab tabChecks; -// private TableEditDialogIndexTab tabIndexes; + private TableEditDialogIndexTab tabIndexes; // private TableEditDialogRecordTab tabRecords; @@ -181,7 +181,7 @@ tabChecks = new TableEditDialogCheckTab(tabFolder, SWT.NULL, tableModel); // ---- B-4. インデックス -// tabIndexes = new TableEditDialogIndexTab(tabFolder, SWT.NULL, tableModel); + tabIndexes = new TableEditDialogIndexTab(tabFolder, SWT.NULL, tableModel); // ---- B-5. BeginScript // tabRecords = new TableEditDialogRecordTab(tabFolder, SWT.NULL, tableModel); Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-02-20 10:13:56 UTC (rev 2695) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-02-21 03:26:42 UTC (rev 2696) @@ -1,571 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.editor.dialog.table; - -// -//import java.util.Collections; -// -//import org.eclipse.jface.dialogs.Dialog; -//import org.eclipse.swt.SWT; -//import org.eclipse.swt.events.KeyAdapter; -//import org.eclipse.swt.events.KeyEvent; -//import org.eclipse.swt.events.SelectionAdapter; -//import org.eclipse.swt.events.SelectionEvent; -//import org.eclipse.swt.layout.GridData; -//import org.eclipse.swt.layout.GridLayout; -//import org.eclipse.swt.widgets.Button; -//import org.eclipse.swt.widgets.Composite; -//import org.eclipse.swt.widgets.Group; -//import org.eclipse.swt.widgets.Label; -//import org.eclipse.swt.widgets.TabFolder; -//import org.eclipse.swt.widgets.TabItem; -//import org.eclipse.swt.widgets.Table; -//import org.eclipse.swt.widgets.TableColumn; -//import org.eclipse.swt.widgets.TableItem; -//import org.eclipse.swt.widgets.Text; -// -//import org.jiemamy.eclipse.JiemamyPlugin; -//import org.jiemamy.eclipse.ui.AbstractTableEditor; -//import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; -//import org.jiemamy.eclipse.ui.tab.AbstractTab; -//import org.jiemamy.model.RootModel; -//import org.jiemamy.model.entity.TableModel; -//import org.jiemamy.model.index.IndexColumnModel; -//import org.jiemamy.model.index.IndexModel; -// -///** -// * テーブル編集ダイアログの「インデックス」タブ -// * -// * @author daisuke -// */ -//public class TableEditDialogIndexTab extends AbstractTab { -// -// private RootModel rootModel; -// -// private TableModel tableModel; -// -// private int indexEditIndex = -1; -// -// private int indexColumnEditIndex = -1; -// -// private AbstractTableEditor indexesEditArea; -// -// private AbstractTableEditor indexColumnsEditArea; -// -// private Text txtIndexName; -// -// private Button chkIsUniqueIndex; -// -// private Button radSortNone; -// -// private Button radSortAsc; -// -// private Button radSortDesc; -// -// -// /** -// * インスタンスを生成する。 -// * -// * @param parentTabFolder -// * @param style -// * @param tableModel -// */ -// public TableEditDialogIndexTab(TabFolder parentTabFolder, int style, TableModel tableModel) { -// super(parentTabFolder, style, "インデックス"); // RESOURCE -// this.tableModel = tableModel; -// } -// -// @Override -// public Composite createTabArea(TabFolder parentTabFolder) { -// Composite composite = new Composite(parentTabFolder, SWT.NULL); -// composite.setLayout(new GridLayout(2, false)); -// composite.setLayoutData(new GridData(GridData.FILL_BOTH)); -// -// TabItem tabIndex = new TabItem(parentTabFolder, SWT.NONE); -// tabIndex.setText(JiemamyPlugin.getResourceString("dialog.table.tab.index")); -// tabIndex.setControl(composite); -// -// createIndexTab(composite); -// -// disableIndexForm(); -// disableIndexColumnForm(); -// -// return composite; -// } -// -// private void createIndexTab(Composite parent) { -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.index.group")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); -// group.setLayout(new GridLayout(1, false)); -// -// indexesEditArea = new IndexTableEditor(); -// indexesEditArea.createControlArea(group); -// -// group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.group")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); -// group.setLayout(new GridLayout(1, false)); -// -// indexColumnsEditArea = new IndexColumnTableEditor(); -// indexColumnsEditArea.createControlArea(group); -// } -// -// private void disableIndexColumnForm() { -// indexColumnEditIndex = -1; -// -// radSortNone.setEnabled(false); -// radSortAsc.setEnabled(false); -// radSortDesc.setEnabled(false); -// -// radSortNone.setSelection(false); -// radSortAsc.setSelection(false); -// radSortDesc.setSelection(false); -// -// indexColumnsEditArea.getBtnRemove().setEnabled(false); -// indexColumnsEditArea.getBtnMoveUp().setEnabled(false); -// indexColumnsEditArea.getBtnMoveDown().setEnabled(false); -// } -// -// private void disableIndexForm() { -// indexEditIndex = -1; -// -// txtIndexName.setEnabled(false); -//// txtIndexLogicalName.setEnabled(false); -// chkIsUniqueIndex.setEnabled(false); -// -// txtIndexName.setText(""); -//// txtIndexLogicalName.setText(""); -// chkIsUniqueIndex.setSelection(false); -// -// indexesEditArea.getBtnRemove().setEnabled(false); -// indexesEditArea.getBtnMoveUp().setEnabled(false); -// indexesEditArea.getBtnMoveDown().setEnabled(false); -// -// indexColumnsEditArea.getBtnAdd().setEnabled(false); -// } -// -// private void enableIndexColumnForm(int index) { -// if (indexEditIndex >= 0) { -// IndexModel indexModel = tableModel.getIndex(indexEditIndex); -// IndexColumnModel indexColumnModel = indexModel.getColumn(index); -// -// indexColumnEditIndex = index; -// -// radSortNone.setEnabled(true); -// radSortAsc.setEnabled(true); -// radSortDesc.setEnabled(true); -// -// radSortNone.setSelection(false); -// radSortAsc.setSelection(false); -// radSortDesc.setSelection(false); -// if (indexColumnModel.getSort().equals(IndexColumnModel.SORT_ASC)) { -// radSortAsc.setSelection(true); -// } else if (indexColumnModel.getSort().equals(IndexColumnModel.SORT_DESC)) { -// radSortDesc.setSelection(true); -// } else { -// radSortNone.setSelection(true); -// } -// -// indexColumnsEditArea.getBtnRemove().setEnabled(true); -// // 選択が一番上だった場合 -// indexColumnsEditArea.getBtnMoveUp().setEnabled(index > 0); -// // 選択が一番下だった場合 -// indexColumnsEditArea.getBtnMoveDown().setEnabled(index + 1 < indexesEditArea.getTable().getItemCount()); -// } -// } -// -// private void enableIndexForm(int index) { -// IndexModel indexModel = tableModel.getIndex(index); -// -// indexEditIndex = index; -// -// txtIndexName.setEnabled(true); -//// txtIndexLogicalName.setEnabled(true); -// chkIsUniqueIndex.setEnabled(true); -// -// txtIndexName.setText(indexModel.getName()); -//// txtIndexLogicalName.setText(indexModel.getLogicalName()); -// chkIsUniqueIndex.setSelection(indexModel.isUnique()); -// -// indexesEditArea.getBtnRemove().setEnabled(true); -// // 選択が一番上だった場合 -// indexesEditArea.getBtnMoveUp().setEnabled(index > 0); -// // 選択が一番下だった場合 -// indexesEditArea.getBtnMoveDown().setEnabled(index + 1 < indexesEditArea.getTable().getItemCount()); -// -// indexColumnsEditArea.getBtnAdd().setEnabled(true); -// indexColumnsEditArea.refreshTable(); -// } -// -// private void updateIndexColumnTableItem(TableItem item, IndexColumnModel indexColumnModel) { -// item.setText(0, indexColumnModel.createTableDisplayString()); -// item.setText(1, indexColumnModel.getSort().trim()); -// } -// -// private void updateIndexTableItem(TableItem item, IndexModel indexModel) { -// item.setText(0, indexModel.createTableDisplayString()); -// item.setText(1, String.valueOf(indexModel.isUnique())); -// } -// -// private void updateModel() { -// if (indexEditIndex != -1) { -// IndexModel indexModel = tableModel.getIndex(indexEditIndex); -// indexModel.setName(txtIndexName.getText()); -//// model.setLogicalName(txtIndexLogicalName.getText()); -// indexModel.setUnique(chkIsUniqueIndex.getSelection()); -// -// TableItem indexItem = indexesEditArea.getTable().getItem(indexEditIndex); -// updateIndexTableItem(indexItem, indexModel); -// -// if (indexColumnEditIndex != -1) { -// IndexColumnModel indexColumnModel = indexModel.getColumn(indexColumnEditIndex); -//// indexColumnModel.getColumn(). addとかremoveとか -// if (radSortAsc.getSelection()) { -// indexColumnModel.setSort(IndexColumnModel.SORT_ASC); -// } else if (radSortDesc.getSelection()) { -// indexColumnModel.setSort(IndexColumnModel.SORT_DESC); -// } else { -// indexColumnModel.setSort(IndexColumnModel.SORT_NONE); -// } -// -// TableItem indexColumnItem = indexColumnsEditArea.getTable().getItem(indexColumnEditIndex); -// updateIndexColumnTableItem(indexColumnItem, indexColumnModel); -// } -// } -// } -// -// -// private class IndexColumnTableEditor extends AbstractTableEditor { -// -// public IndexColumnTableEditor() { -// super(); -// } -// -// @Override -// public void refreshTable() { -// getTable().removeAll(); -// if (indexEditIndex > -1) { -// IndexModel indexModel = tableModel.getIndex(indexEditIndex); -// for (IndexColumnModel indexColumnModel : indexModel.getColumns()) { -// TableItem item = new TableItem(getTable(), SWT.NULL); -// updateIndexColumnTableItem(item, indexColumnModel); -// } -// } -// } -// -// @Override -// protected void configureEditButtons() { -// getBtnAdd().setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.btn.add")); -// getBtnAdd().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// ColumnSelectDialog dialog = -// new ColumnSelectDialog(getBtnAdd().getParent().getShell(), tableModel.getColumns(), -// rootModel.getDialect()); -// -// if (dialog.open() == Dialog.OK && dialog.getResult() != null && indexEditIndex > -1) { -// IndexColumnModel indexColumnModel = new IndexColumnModel(); -// -// indexColumnModel.setColumn(dialog.getResult()); -// -// tableModel.getIndex(indexEditIndex).addColumn(indexColumnModel); -// -// TableItem item = new TableItem(getTable(), SWT.NULL); -// updateIndexColumnTableItem(item, indexColumnModel); -// } -// } -// }); -// -// getBtnRemove().setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.btn.remove")); -// getBtnRemove().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index < 0 || index > getTable().getItemCount()) { -// return; -// } -// -// tableModel.getIndex(indexEditIndex).removeColumn(index); -// getTable().remove(index); -// disableIndexColumnForm(); -// } -// }); -// -// getBtnMoveUp().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index <= 0 || index > getTable().getItemCount()) { -// return; -// } -// -// Collections.swap(tableModel.getIndex(indexEditIndex).getColumns(), index, index - 1); -// -// refreshTable(); -// getTable().setSelection(index - 1); -// enableIndexColumnForm(index - 1); -// } -// }); -// -// getBtnMoveDown().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index < 0 || index >= getTable().getItemCount()) { -// return; -// } -// -// Collections.swap(tableModel.getIndex(indexEditIndex).getColumns(), index, index + 1); -// -// refreshTable(); -// getTable().setSelection(index + 1); -// enableIndexColumnForm(index + 1); -// } -// }); -// } -// -// @Override -// protected void createEditorControls(Composite parent) { -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.title")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// group.setLayout(new GridLayout(3, false)); -// -// radSortNone = new Button(group, SWT.RADIO); -// radSortNone.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.none")); -// radSortNone.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// -// radSortAsc = new Button(group, SWT.RADIO); -// radSortAsc.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.asc")); -// radSortAsc.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// -// radSortDesc = new Button(group, SWT.RADIO); -// radSortDesc.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.desc")); -// radSortDesc.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// -// return group; -// } -// -// @Override -// protected void createTableColumns() { -// TableColumn colColumn = new TableColumn(getTable(), SWT.LEFT); -// colColumn.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.tbl.header.column")); -// colColumn.setWidth(180); -// -// TableColumn colSort = new TableColumn(getTable(), SWT.LEFT); -// colSort.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.tbl.header.sort")); -// colSort.setWidth(50); -// -// refreshTable(); -// -// getTable().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index >= 0) { -// enableIndexColumnForm(index); -// } else { -// disableIndexColumnForm(); -// } -// } -// }); -// } -// } -// -// private class IndexTableEditor extends AbstractTableEditor { -// -// public IndexTableEditor() { -// super(); -// } -// -// @Override -// public void refreshTable() { -// getTable().removeAll(); -// for (IndexModel model : tableModel.getIndexes()) { -// TableItem item = new TableItem(getTable(), SWT.NULL); -// updateIndexTableItem(item, model); -// } -// } -// -// @Override -// protected void configureEditButtons() { -// getBtnAdd().setText(JiemamyPlugin.getResourceString("dialog.table.index.btn.add")); -// getBtnAdd().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// IndexModel index = new IndexModel(); -// index.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); -// tableModel.addIndex(index); -// -// TableItem item = new TableItem(getTable(), SWT.NULL); -// updateIndexTableItem(item, index); -// } -// }); -// -// getBtnRemove().setText(JiemamyPlugin.getResourceString("dialog.table.index.btn.remove")); -// getBtnRemove().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index < 0 || index > getTable().getItemCount()) { -// return; -// } -// -// tableModel.removeIndex(getTable().getSelectionIndex()); -// getTable().remove(getTable().getSelectionIndex()); -// disableIndexForm(); -// disableIndexColumnForm(); -// indexColumnsEditArea.getTable().clearAll(); -// } -// }); -// -// getBtnMoveUp().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index <= 0 || index > getTable().getItemCount()) { -// return; -// } -// -// tableModel.moveUpIndex(index); -// -// refreshTable(); -// getTable().setSelection(index - 1); -// enableIndexForm(index - 1); -// } -// }); -// -// getBtnMoveDown().addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = getTable().getSelectionIndex(); -// if (index < 0 || index >= getTable().getItemCount()) { -// return; -// } -// -// tableModel.moveDownIndex(index); -// -// refreshTable(); -// getTable().setSelection(index + 1); -// enableIndexForm(index + 1); -// } -// }); -// } -// -// @Override -// protected Composite createDetailEditControls(Composite parent) { -// Label label; -// -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.index.title")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// group.setLayout(new GridLayout(1, false)); -// -// Composite cmpNames = new Composite(group, SWT.NULL); -// cmpNames.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// // 論理名つける場合は 2→4 -// GridLayout layout = new GridLayout(2, false); -// layout.marginHeight = 0; -// layout.marginWidth = 0; -// cmpNames.setLayout(layout); -// -// label = new Label(cmpNames, SWT.NULL); -// label.setText(JiemamyPlugin.getResourceString("dialog.table.index.label.name")); -// -// txtIndexName = new Text(cmpNames, SWT.BORDER); -// txtIndexName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// txtIndexName.addFocusListener(new TextSelectionAdapter(txtIndexName)); -// txtIndexName.addKeyListener(new KeyAdapter() { -// -// @Override -// public void keyReleased(KeyEvent e) { -// updateModel(); -// } -// }); -// -// chkIsUniqueIndex = new Button(group, SWT.CHECK); -// chkIsUniqueIndex.setText(JiemamyPlugin.getResourceString("dialog.table.index.label.unique")); -// chkIsUniqueIndex.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// -// return group; -// } -// -// @Override -// protected void createTableColumns(final Table table) { -// TableColumn colName = new TableColumn(table, SWT.LEFT); -// colName.setText(JiemamyPlugin.getResourceString("dialog.table.index.tbl.header.indexName")); -// colName.setWidth(180); -// -// TableColumn colUnique = new TableColumn(table, SWT.LEFT); -// colUnique.setText(JiemamyPlugin.getResourceString("dialog.table.index.tbl.header.unique")); -// colUnique.setWidth(50); -// -// refreshTable(); -// -// table.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = table.getSelectionIndex(); -// if (index >= 0) { -// enableIndexForm(index); -// disableIndexColumnForm(); -// } else { -// disableIndexForm(); -// disableIndexColumnForm(); -// } -// } -// }); -// } -// } -//} Copied: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java (from rev 2695, vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab2.java) =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-02-21 03:26:42 UTC (rev 2696) @@ -0,0 +1,800 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.eclipse.editor.dialog.table; + +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.BaseLabelProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.EventBroker; +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.Migration; +import org.jiemamy.eclipse.ui.AbstractTableEditor; +import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; +import org.jiemamy.eclipse.ui.tab.AbstractTab; +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexColumnModel; +import org.jiemamy.model.index.IndexModel; +import org.jiemamy.model.index.IndexColumnModel.SortType; +import org.jiemamy.utils.ListUtils; +import org.jiemamy.utils.model.TableUtil; + +/** + * テーブル編集ダイアログの「インデックス」タブ + * + * @author daisuke + */ +public class TableEditDialogIndexTab extends AbstractTab { + + private static Logger logger = LoggerFactory.getLogger(TableEditDialogIndexTab.class); + + private TableModel tableModel; + + private IndexTableEditor indexesTableEditor; + + private IndexColumnTableEditor indexColumnsTableEditor; + + + /** + * インスタンスを生成する。 + * + * @param parentTabFolder + * @param style + * @param tableModel + */ + public TableEditDialogIndexTab(TabFolder parentTabFolder, int style, TableModel tableModel) { + super(parentTabFolder, style, "インデックス"); // RESOURCE + + this.tableModel = tableModel; + + Composite composite = new Composite(parentTabFolder, SWT.NULL); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + indexesTableEditor = new IndexTableEditor(composite, SWT.NULL); + indexesTableEditor.configure(); + indexesTableEditor.disableEditControls(); + + indexColumnsTableEditor = new IndexColumnTableEditor(composite, SWT.NULL); + indexColumnsTableEditor.configure(); + indexColumnsTableEditor.disableEditControls(); + } + + + /** + * インデックスカラム用ContentProvider + * + * @author daisuke + */ + private class IndexColumnContentProvider extends ArrayContentProvider implements CommandListener { + + private Viewer viewer; + + + public void commandExecuted(Command command) { + logger.debug("IndexColumnContentProvider: commandExecuted"); +// if (evt.getPropertyName().equals(IndexModel.P_INDEX_COLUMNS)) { + indexColumnsTableEditor.refreshTable(); // インデックスカラムの変更を反映させる。 +// } else if (evt.getSource() instanceof DefinitionModel) { +// indexColumnsEditArea.refreshTable(); // インデックスカラムの変更を反映させる。 +// if (evt.getPropertyName().equals(IndexColumnModel.P_CREATE)) { +// // nothing to do +// } else if (evt.getPropertyName().equals(IndexColumnModel.P_DELETE)) { +// ((AbstractModel) evt.getSource()).removePropertyChangeListener(this); +// } else if (evt.getPropertyName().equals(IndexColumnModel.P_REVERT)) { +// ((AbstractModel) evt.getSource()).addPropertyChangeListener(this); +// } +// } + } + + @Override + public void dispose() { + logger.debug("IndexColumnContentProvider: dispose"); +/// tableModel.removePropertyChangeListener(this); +// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); +// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { +// ((AbstractModel) column).removePropertyChangeListener(this); +// } + super.dispose(); + } + + public JiemamyElement getTargetModel() { + return (JiemamyElement) viewer.getInput(); + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + logger.debug("IndexColumnContentProvider: input changed"); + logger.trace("oldInput: " + oldInput); + logger.trace("newInput: " + newInput); + + this.viewer = viewer; + +// if (oldInput != null) { +// tableModel.removePropertyChangeListener(this); +// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { +// ((AbstractModel) column).removePropertyChangeListener(this); +// } +// } +// if (newInput != null) { +// tableModel.addPropertyChangeListener(this); +// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { +// ((AbstractModel) column).addPropertyChangeListener(this); +// } +// } + + super.inputChanged(viewer, oldInput, newInput); + } + + } + + private class IndexColumnLabelProvider extends BaseLabelProvider implements ITableLabelProvider { + + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + public String getColumnText(Object element, int columnIndex) { + IndexColumnModel indexColumnModel = (IndexColumnModel) element; + switch (columnIndex) { + case 0: + return indexColumnModel.toString(); // TODO + case 1: + return indexColumnModel.getSortType().toString(); // TODO ? + + default: + return ""; + } + } + } + + private class IndexColumnTableEditor extends AbstractTableEditor { + + private final Jiemamy jiemamy; + + private final List<IndexColumnModel> indexColumns; + + private Button radSortNone; + + private Button radSortAsc; + + private Button radSortDesc; + + + public IndexColumnTableEditor(Composite parent, int style) { + super(parent, style, new TableEditorConfigurator() { + + public String getAddLabel() { + return "追加"; // RESOURCE + } + + public String getEditorTitle() { + return "インデックスカラム情報"; // RESOURCE + } + + public String getInsertLabel() { + return "挿入"; // RESOURCE + } + + public String getRemoveLabel() { + return "削除"; // RESOURCE + } + }); + + jiemamy = tableModel.getJiemamy(); + indexColumns = tableModel.getIndexes().get(Migration.DIAGRAM_INDEX/*TODO*/).getColumns(); + } + + public void updateInput() { + TableViewer tableViewer = getTableViewer(); + int index = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + if (index >= 0) { + tableViewer.setInput(tableModel.getIndexes().get(index)); + } else { + tableViewer.setInput(null); + } + } + + @Override + protected JiemamyElement addItem() { + Table table = getTableViewer().getTable(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + + List<ColumnModel> columns = TableUtil.getColumns(tableModel); + ColumnSelectDialog dialog = new ColumnSelectDialog(table.getShell(), columns); + + if (dialog.open() == Dialog.OK && dialog.getResult() != null && indexIndex != -1) { + JiemamyFactory factory = jiemamy.getFactory(); + IndexColumnModel indexColumnModel = factory.newModel(IndexColumnModel.class); + + indexColumnModel.setColumn(factory.newReference(dialog.getResult())); + + tableModel.getIndexes().get(indexIndex).getColumns().add(indexColumnModel); + + int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); + table.setSelection(addedIndex); + enableEditControls(addedIndex); + + return indexColumnModel; + } + return null; + } + + @Override + protected void configureEditorControls() { + radSortNone.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + updateModel(); + } + }); + radSortAsc.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + updateModel(); + } + }); + radSortDesc.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + updateModel(); + } + }); + } + + @Override + protected void configureTable(Table table) { + super.configureTable(table); + } + + @Override + protected void configureTableViewer(TableViewer tableViewer) { + tableViewer.setLabelProvider(new IndexColumnLabelProvider()); + final IndexColumnContentProvider contentProvider = new IndexColumnContentProvider(); + tableViewer.setContentProvider(contentProvider); + + int index = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + if (index >= 0) { + tableViewer.setInput(tableModel.getIndexes().get(index)); + } else { + tableViewer.setInput(null); + } + + final EventBroker eventBroker = jiemamy.getEventBroker(); + eventBroker.addListener(contentProvider); + + // THINK んーーー?? このタイミングか? + tableViewer.getTable().addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + eventBroker.removeListener(contentProvider); + } + + }); + } + + @Override + protected void createEditorControls(Composite parent) { + + radSortNone = new Button(parent, SWT.RADIO); + radSortNone.setText("なし"); // RESOURCE + + radSortAsc = new Button(parent, SWT.RADIO); + radSortAsc.setText("ASC"); // RESOURCE + + radSortDesc = new Button(parent, SWT.RADIO); + radSortDesc.setText("DESC"); // RESOURCE + } + + @Override + protected void createTableColumns(Table table) { + TableColumn colColumn = new TableColumn(table, SWT.LEFT); + colColumn.setText("カラム名"); + colColumn.setWidth(180); + + TableColumn colSort = new TableColumn(table, SWT.LEFT); + colSort.setText("ソート順"); + colSort.setWidth(50); + } + + @Override + protected void disableEditDetailControls() { + radSortNone.setEnabled(false); + radSortAsc.setEnabled(false); + radSortDesc.setEnabled(false); + + radSortNone.setSelection(false); + radSortAsc.setSelection(false); + radSortDesc.setSelection(false); + } + + @Override + protected void enableEditDetailControls(int index) { + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + + IndexModel indexModel = tableModel.getIndexes().get(indexIndex); + IndexColumnModel indexColumnModel = indexModel.getColumns().get(index); + + radSortNone.setEnabled(true); + radSortAsc.setEnabled(true); + radSortDesc.setEnabled(true); + + radSortNone.setSelection(false); + radSortAsc.setSelection(false); + radSortDesc.setSelection(false); + if (indexColumnModel.getSortType().equals(SortType.ASC)) { + radSortAsc.setSelection(true); + } else if (indexColumnModel.getSortType().equals(SortType.DESC)) { + radSortDesc.setSelection(true); + } else { + radSortNone.setSelection(true); + } + } + + @Override + protected JiemamyElement insertTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + List<ColumnModel> columns = TableUtil.getColumns(tableModel); + ColumnSelectDialog dialog = new ColumnSelectDialog(table.getShell(), columns); + + if (dialog.open() == Dialog.OK && dialog.getResult() != null && indexIndex != -1) { + JiemamyFactory factory = jiemamy.getFactory(); + IndexColumnModel indexColumnModel = factory.newModel(IndexColumnModel.class); + + indexColumnModel.setColumn(factory.newReference(dialog.getResult())); + + if (index < 0 || index > table.getItemCount()) { + tableModel.getIndexes().get(indexIndex).getColumns().add(indexColumnModel); + } else { + tableModel.getIndexes().get(indexIndex).getColumns().add(index, indexColumnModel); + } + + int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); + table.setSelection(addedIndex); + enableEditControls(addedIndex); + + return indexColumnModel; + } + return null; + } + + @Override + protected void moveDownTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + if (index < 0 || index >= table.getItemCount()) { + return; + } + + ListUtils.moveDown(indexColumns, indexIndex); + + table.setSelection(index + 1); + enableEditControls(index + 1); + } + + @Override + protected void moveUpTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + if (index <= 0 || index > table.getItemCount()) { + return; + } + + ListUtils.moveUp(indexColumns, indexIndex); + + table.setSelection(index - 1); + enableEditControls(index - 1); + } + + @Override + protected JiemamyElement removeTableSelectionItem() { + TableViewer tableViewer = getTableViewer(); + Table table = tableViewer.getTable(); + int index = table.getSelectionIndex(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + if (index < 0 || index > table.getItemCount()) { + return null; + } + IndexColumnModel removed = tableModel.getIndexes().get(indexIndex).getColumns().remove(index); + + tableViewer.remove(index); + + disableEditControls(); + + return removed; + } + + private void updateModel() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + int indexIndex = indexesTableEditor.getTableViewer().getTable().getSelectionIndex(); + + if (indexIndex != -1 && index != -1) { + IndexColumnModel indexColumnModel = tableModel.getIndexes().get(indexIndex).getColumns().get(index); + // indexColumnModel.getColumn(). addとかremoveとか + if (radSortAsc.getSelection()) { + indexColumnModel.setSortType(SortType.ASC); + } else if (radSortDesc.getSelection()) { + indexColumnModel.setSortType(SortType.DESC); + } else { + indexColumnModel.setSortType(SortType.NONE); + } + } + } + } + + private class IndexContentProvider extends ArrayContentProvider implements CommandListener { + + @SuppressWarnings("unused") + private Viewer viewer; + + + public void commandExecuted(Command command) { +// if (evt.getPropertyName().equals(TableModel.P_ENTITY_TABLE_INDEXES)) { + indexesTableEditor.refreshTable(); // インデックスの変更を反映させる。 +// } else if (evt.getSource() instanceof DefinitionModel) { +// indexesEditArea.refreshTable(); // インデックスの変更を反映させる。 +// if (evt.getPropertyName().equals(IndexModel.P_CREATE)) { +// // nothing to do +// } else if (evt.getPropertyName().equals(IndexModel.P_DELETE)) { +// ((JiemamyElement) evt.getSource()).removePropertyChangeListener(this); +// } else if (evt.getPropertyName().equals(IndexModel.P_REVERT)) { +// ((JiemamyElement) evt.getSource()).addPropertyChangeListener(this); +// } +// } + } + + @Override + public void dispose() { +// tableModel.removePropertyChangeListener(this); +// for (IndexModel column : tableModel.getIndexes().get()) { +// ((JiemamyElement) column).removePropertyChangeListener(this); +// } + super.dispose(); + } + + public JiemamyElement getTargetModel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + this.viewer = viewer; +// if (oldInput != null) { +// tableModel.removePropertyChangeListener(this); +// for (IndexModel indexModel : tableModel.getIndexes().get()) { +// ((JiemamyElement) indexModel).removePropertyChangeListener(this); +// } +// } +// if (newInput != null) { +// tableModel.addPropertyChangeListener(this); +// for (IndexModel indexModel : tableModel.getIndexes().get()) { +// ((JiemamyElement) indexModel).addPropertyChangeListener(this); +// } +// } + + super.inputChanged(viewer, oldInput, newInput); + } + } + + private class IndexLabelProvider extends BaseLabelProvider implements ITableLabelProvider { + + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + public String getColumnText(Object element, int columnIndex) { + IndexModel indexModel = (IndexModel) element; + switch (columnIndex) { + case 0: + return indexModel.getName(); + case 1: + return String.valueOf(indexModel.isUnique()); + + default: + return ""; + } + } + } + + private class IndexTableEditor extends AbstractTableEditor { + + private final Jiemamy jiemamy; + + private final List<IndexModel> indexes; + + private Text txtIndexName; + + private Button chkIsUniqueIndex; + + + public IndexTableEditor(Composite parent, int style) { + super(parent, style, new TableEditorConfigurator() { + + public String getAddLabel() { + return "追加"; // RESOURCE + } + + public String getEditorTitle() { + return "ローカルキー情報"; // RESOURCE + } + + public String getInsertLabel() { + return "挿入"; // RESOURCE + } + + public String getRemoveLabel() { + return "削除"; // RESOURCE + } + }); + + jiemamy = tableModel.getJiemamy(); + indexes = tableModel.getIndexes(); + + assert jiemamy != null; + assert indexes != null; + } + + @Override + protected JiemamyElement addItem() { + Table table = getTableViewer().getTable(); + JiemamyFactory factory = jiemamy.getFactory(); + IndexModel indexModel = factory.newModel(IndexModel.class); + indexModel.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); + + tableModel.getIndexes().add(indexModel); + + int addedIndex = tableModel.getIndexes().indexOf(indexModel); + table.setSelection(addedIndex); + enableEditControls(addedIndex); + txtIndexName.setFocus(); + + return indexModel; + } + + @Override + protected void configureEditorControls() { + txtIndexName.addFocusListener(new TextSelectionAdapter(txtIndexName)); + txtIndexName.addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + updateModel(); + } + }); + chkIsUniqueIndex.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + updateModel(); + } + }); + } + + @Override + protected void configureTable(final Table table) { + super.configureTable(table); + + table.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + int index = table.getSelectionIndex(); + if (index >= 0) { + (indexColumnsTableEditor).updateInput(); + } else { + indexColumnsTableEditor.disableEditControls(); + } + } + }); + } + + @Override + protected void configureTableViewer(TableViewer tableViewer) { + tableViewer.setLabelProvider(new IndexLabelProvider()); + final IndexContentProvider contentProvider = new IndexContentProvider(); + tableViewer.setContentProvider(contentProvider); + tableViewer.setInput(tableModel.getIndexes()); + + final EventBroker eventBroker = jiemamy.getEventBroker(); + eventBroker.addListener(contentProvider); + + // THINK んーーー?? このタイミングか? + tableViewer.getTable().addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + eventBroker.removeListener(contentProvider); + } + + }); + } + + @Override + protected void createEditorControls(Composite parent) { + Label label; + + Composite cmpNames = new Composite(parent, SWT.NULL); + cmpNames.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // 論理名つける場合は 2→4 + GridLayout layout = new GridLayout(2, false); + layout.marginHeight = 0; + layout.marginWidth = 0; + cmpNames.setLayout(layout); + + label = new Label(cmpNames, SWT.NULL); + label.setText("インデックス名"); // RESOURCE + + txtIndexName = new Text(cmpNames, SWT.BORDER); + txtIndexName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + chkIsUniqueIndex = new Button(parent, SWT.CHECK); + chkIsUniqueIndex.setText("一意"); // RESOURCE + } + + @Override + protected void createTableColumns(Table table) { + TableColumn colName = new TableColumn(table, SWT.LEFT); + colName.setText("インデックス名"); // RESOURCE + colName.setWidth(180); + + TableColumn colUnique = new TableColumn(table, SWT.LEFT); + colUnique.setText("一意"); // RESOURCE + colUnique.setWidth(50); + } + + @Override + protected void disableEditDetailControls() { + txtIndexName.setEnabled(false); + chkIsUniqueIndex.setEnabled(false); + + txtIndexName.setText(""); + chkIsUniqueIndex.setSelection(false); + } + + @Override + protected void enableEditDetailControls(int index) { + IndexModel indexModel = tableModel.getIndexes().get(index); + + txtIndexName.setEnabled(true); + chkIsUniqueIndex.setEnabled(true); + + txtIndexName.setText(indexModel.getName()); + chkIsUniqueIndex.setSelection(indexModel.isUnique()); + + // 現在値の設定 + // TODO + } + + @Override + protected JiemamyElement insertTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + + JiemamyFactory factory = jiemamy.getFactory(); + IndexModel indexModel = factory.newModel(IndexModel.class); + indexModel.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); + + if (index < 0 || index > table.getItemCount()) { + tableModel.getIndexes().add(indexModel); + } else { + tableModel.getIndexes().add(index, indexModel); + } + + int addedIndex = tableModel.getIndexes().indexOf(indexModel); + table.setSelection(addedIndex); + enableEditControls(addedIndex); + txtIndexName.setFocus(); + + return indexModel; + } + + @Override + protected void moveDownTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + if (index < 0 || index >= table.getItemCount()) { + return; + } + + ListUtils.moveDown(indexes, index); + + table.setSelection(index + 1); + enableEditControls(index + 1); + } + + @Override + protected void moveUpTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + if (index <= 0 || index > table.getItemCount()) { + return; + } + + ListUtils.moveUp(indexes, index); + + table.setSelection(index - 1); + enableEditControls(index - 1); + } + + @Override + protected JiemamyElement removeTableSelectionItem() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + if (index < 0 || index > table.getItemCount()) { + return null; + } + IndexModel indexToRemove = tableModel.getIndexes().remove(table.getSelectionIndex()); + + TableViewer tableViewer = getTableViewer(); + tableViewer.remove(indexToRemove); + + disableEditControls(); + + return indexToRemove; + } + + private void updateModel() { + Table table = getTableViewer().getTable(); + int index = table.getSelectionIndex(); + if (index != -1) { + IndexModel indexModel = tableModel.getIndexes().get(index); + indexModel.setName(txtIndexName.getText()); + indexModel.setUnique(chkIsUniqueIndex.getSelection()); + } + } + } +} Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab2.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab2.java 2009-02-20 10:13:56 UTC (rev 2695) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab2.java 2009-02-21 03:26:42 UTC (rev 2696) @@ -1,752 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.editor.dialog.table; - -// -//import org.eclipse.jface.dialogs.Dialog; -//import org.eclipse.jface.viewers.ArrayContentProvider; -//import org.eclipse.jface.viewers.BaseLabelProvider; -//import org.eclipse.jface.viewers.ITableLabelProvider; -//import org.eclipse.jface.viewers.TableViewer; -//import org.eclipse.jface.viewers.Viewer; -//import org.eclipse.swt.SWT; -//import org.eclipse.swt.events.KeyAdapter; -//import org.eclipse.swt.events.KeyEvent; -//import org.eclipse.swt.events.SelectionAdapter; -//import org.eclipse.swt.events.SelectionEvent; -//import org.eclipse.swt.graphics.Image; -//import org.eclipse.swt.layout.GridData; -//import org.eclipse.swt.layout.GridLayout; -//import org.eclipse.swt.widgets.Button; -//import org.eclipse.swt.widgets.Composite; -//import org.eclipse.swt.widgets.Group; -//import org.eclipse.swt.widgets.Label; -//import org.eclipse.swt.widgets.TabFolder; -//import org.eclipse.swt.widgets.TabItem; -//import org.eclipse.swt.widgets.Table; -//import org.eclipse.swt.widgets.TableColumn; -//import org.eclipse.swt.widgets.Text; -// -//import org.jiemamy.eclipse.JiemamyPlugin; -//import org.jiemamy.eclipse.ui.AbstractTableEditor; -//import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; -//import org.jiemamy.eclipse.ui.tab.AbstractTab; -//import org.jiemamy.editcommand.Command; -//import org.jiemamy.editcommand.CommandListener; -//import org.jiemamy.model.JiemamyElement; -//import org.jiemamy.model.RootModel; -//import org.jiemamy.model.entity.TableModel; -//import org.jiemamy.model.index.IndexColumnModel; -//import org.jiemamy.model.index.IndexModel; -// -///** -// * テーブル編集ダイアログの「インデックス」タブ -// * -// * @author daisuke -// */ -//public class TableEditDialogIndexTab2 extends AbstractTab { -// -// private TableModel tableModel; -// -// private RootModel rootModel; -// -//// private int indexEditIndex = -1; -//// private int indexColumnEditIndex = -1; -// -// private AbstractTableEditor indexesEditArea; -// -// private IndexContentProvider indexContentProvider; -// -// private AbstractTableEditor indexColumnsEditArea; -// -// private IndexColumnContentProvider indexColumnContentProvider; -// -// private Text txtIndexName; -// -// private Button chkIsUniqueIndex; -// -// private Button radSortNone; -// -// private Button radSortAsc; -// -// private Button radSortDesc; -// -// -// public TableEditDialogIndexTab2(TabFolder parentTabFolder, int style, TableModel tableModel) { -// super(parentTabFolder, style, "インデックス"); // RESOURCE -// this.tableModel = tableModel; -// } -// -// @Override -// public Composite createTabArea(TabFolder parentTabFolder) { -// Composite composite = new Composite(parentTabFolder, SWT.NULL); -// composite.setLayout(new GridLayout(2, false)); -// composite.setLayoutData(new GridData(GridData.FILL_BOTH)); -// -// TabItem tabIndex = new TabItem(parentTabFolder, SWT.NONE); -// tabIndex.setText(JiemamyPlugin.getResourceString("dialog.table.tab.index")); -// tabIndex.setControl(composite); -// -// createIndexTab(composite); -// indexesEditArea.disableEditControls(); -// indexColumnsEditArea.disableEditControls(); -// -// return composite; -// } -// -// private void createIndexTab(Composite parent) { -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.index.group")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); -// group.setLayout(new GridLayout(1, false)); -// -// indexesEditArea = new IndexTableEditor(tableModel); -// indexesEditArea.setAddLabel(JiemamyPlugin.getResourceString("dialog.table.index.btn.add")); -// indexesEditArea.setInsertLabel(JiemamyPlugin.getResourceString("dialog.table.index.btn.insert")); -// indexesEditArea.setRemoveLabel(JiemamyPlugin.getResourceString("dialog.table.index.btn.remove")); -// indexesEditArea.createControlArea(group); -// -// group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.group")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); -// group.setLayout(new GridLayout(1, false)); -// -// indexColumnsEditArea = new IndexColumnEditTableArea(tableModel); -// indexColumnsEditArea.setAddLabel(JiemamyPlugin.getResourceString("dialog.table.indexColumn.btn.add")); -// indexColumnsEditArea.setInsertLabel(JiemamyPlugin.getResourceString("dialog.table.indexColumn.btn.insert")); -// indexColumnsEditArea.setRemoveLabel(JiemamyPlugin.getResourceString("dialog.table.indexColumn.btn.remove")); -// indexColumnsEditArea.createControlArea(group); -// } -// -// -// private class IndexColumnContentProvider extends ArrayContentProvider implements CommandListener { -// -// private Viewer viewer; -// -// -// public void commandExecuted(Command command) { -//// if (evt.getPropertyName().equals(IndexModel.P_INDEX_COLUMNS)) { -// indexColumnsEditArea.refreshTable(); // インデックスカラムの変更を反映させる。 -//// } else if (evt.getSource() instanceof DefinitionModel) { -//// indexColumnsEditArea.refreshTable(); // インデックスカラムの変更を反映させる。 -//// if (evt.getPropertyName().equals(IndexColumnModel.P_CREATE)) { -//// // nothing to do -//// } else if (evt.getPropertyName().equals(IndexColumnModel.P_DELETE)) { -//// ((AbstractModel) evt.getSource()).removePropertyChangeListener(this); -//// } else if (evt.getPropertyName().equals(IndexColumnModel.P_REVERT)) { -//// ((AbstractModel) evt.getSource()).addPropertyChangeListener(this); -//// } -//// } -// } -// -// @Override -// public void dispose() { -//// tableModel.removePropertyChangeListener(this); -//// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -//// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { -//// ((AbstractModel) column).removePropertyChangeListener(this); -//// } -// super.dispose(); -// } -// -// public JiemamyElement getTargetModel() { -// return (JiemamyElement) viewer.getInput(); -// } -// -// @Override -// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { -// this.viewer = viewer; -//// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -//// if (oldInput != null) { -//// tableModel.removePropertyChangeListener(this); -//// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { -//// ((AbstractModel) column).removePropertyChangeListener(this); -//// } -//// } -//// if (newInput != null) { -//// tableModel.addPropertyChangeListener(this); -//// for (IndexColumnModel column : tableModel.getIndexes().get(indexIndex).getColumns()) { -//// ((AbstractModel) column).addPropertyChangeListener(this); -//// } -//// } -// -// super.inputChanged(viewer, oldInput, newInput); -// } -// -// } -// -// private class IndexColumnEditTableArea extends AbstractTableEditor { -// -// private TableModel tableModel; -// -// -// public IndexColumnEditTableArea(TableModel targetModel) { -// super(); -// tableModel = targetModel; -// } -// -// public void updateInput() { -// TableViewer tableViewer = getTableViewer(); -// int index = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// if (index >= 0) { -// tableViewer.setInput(tableModel.getIndexes().get(index)); -// } else { -// tableViewer.setInput(null); -// } -// } -// -// @Override -// protected JiemamyElement addItem() { -// Table table = getTableViewer().getTable(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// ColumnSelectDialog dialog = -// new ColumnSelectDialog(table.getShell(), tableModel.getColumns(), rootModel.getDialect()); -// -// if (dialog.open() == Dialog.OK && dialog.getResult() != null && indexIndex != -1) { -// IndexColumnModel indexColumnModel = new IndexColumnModel(); -// -// indexColumnModel.setColumn(dialog.getResult()); -// -// indexColumnModel.firePropertyChange(DefinitionModel.P_CREATE, null, indexColumnModel); -// indexColumnModel.addPropertyChangeListener(indexColumnContentProvider); -// -// tableModel.getIndexes().get(indexIndex).addColumn(indexColumnModel); -// -// int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); -// table.setSelection(addedIndex); -// enableEditControls(addedIndex); -// -// return indexColumnModel; -// } -// return null; -// } -// -// @Override -// protected void configureEditorControls() { -// radSortNone.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// radSortAsc.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// radSortDesc.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// } -// -// @Override -// protected void configureTable(Table table) { -// super.configureTable(table); -// } -// -// @Override -// protected void configureTableViewer(TableViewer tableViewer) { -// tableViewer.setLabelProvider(new IndexColumnLabelProvider()); -// indexColumnContentProvider = new IndexColumnContentProvider(); -// tableViewer.setContentProvider(indexColumnContentProvider); -// -// int index = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// if (index >= 0) { -// tableViewer.setInput(tableModel.getIndexes().get(index)); -// } else { -// tableViewer.setInput(null); -// } -// } -// -// @Override -// protected Composite createEditDetailControls(Composite parent) { -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.title")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// group.setLayout(new GridLayout(3, false)); -// -// radSortNone = new Button(group, SWT.RADIO); -// radSortNone.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.none")); -// -// radSortAsc = new Button(group, SWT.RADIO); -// radSortAsc.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.asc")); -// -// radSortDesc = new Button(group, SWT.RADIO); -// radSortDesc.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.label.desc")); -// -// return group; -// } -// -// @Override -// protected void createTableColumns(Table table) { -// TableColumn colColumn = new TableColumn(table, SWT.LEFT); -// colColumn.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.tbl.header.column")); -// colColumn.setWidth(180); -// -// TableColumn colSort = new TableColumn(table, SWT.LEFT); -// colSort.setText(JiemamyPlugin.getResourceString("dialog.table.indexColumn.tbl.header.sort")); -// colSort.setWidth(50); -// } -// -// @Override -// protected void disableEditDetailControls() { -// radSortNone.setEnabled(false); -// radSortAsc.setEnabled(false); -// radSortDesc.setEnabled(false); -// -// radSortNone.setSelection(false); -// radSortAsc.setSelection(false); -// radSortDesc.setSelection(false); -// } -// -// @Override -// protected void enableEditDetailControls(int index) { -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// -// IndexModel indexModel = tableModel.getIndexes().get(indexIndex); -// IndexColumnModel indexColumnModel = indexModel.getColumn(index); -// -// radSortNone.setEnabled(true); -// radSortAsc.setEnabled(true); -// radSortDesc.setEnabled(true); -// -// radSortNone.setSelection(false); -// radSortAsc.setSelection(false); -// radSortDesc.setSelection(false); -// if (indexColumnModel.getSort().equals(IndexColumnModel.SORT_ASC)) { -// radSortAsc.setSelection(true); -// } else if (indexColumnModel.getSort().equals(IndexColumnModel.SORT_DESC)) { -// radSortDesc.setSelection(true); -// } else { -// radSortNone.setSelection(true); -// } -// } -// -// @Override -// protected JiemamyElement insertTableSelectionItem() { -// Table table = getTableViewer().getTable(); -// int index = table.getSelectionIndex(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// ColumnSelectDialog dialog = -// new ColumnSelectDialog(table.getShell(), tableModel.getColumns(), rootModel.getDialect()); -// -// if (dialog.open() == Dialog.OK && dialog.getResult() != null && indexIndex != -1) { -// IndexColumnModel indexColumnModel = new IndexColumnModel(); -// -// indexColumnModel.setColumn(dialog.getResult()); -// -// if (index < 0 || index > table.getItemCount()) { -// tableModel.getIndexes().get(indexIndex).addColumn(indexColumnModel); -// } else { -// tableModel.getIndexes().get(indexIndex).addColumn(index, indexColumnModel); -// } -// -// int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); -// table.setSelection(addedIndex); -// enableEditControls(addedIndex); -// -// return indexColumnModel; -// } -// return null; -// } -// -// @Override -// protected void moveDownTableSelectionItem() { -// Table table = getTableViewer().getTable(); -// int index = table.getSelectionIndex(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// if (index < 0 || index >= table.getItemCount()) { -// return; -// } -// -// tableModel.getIndexes().get(indexIndex).moveDownColumn(index); -// -// table.setSelection(index + 1); -// enableEditControls(index + 1); -// } -// -// @Override -// protected void moveUpTableSelectionItem() { -// Table table = getTableViewer().getTable(); -// int index = table.getSelectionIndex(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// if (index <= 0 || index > table.getItemCount()) { -// return; -// } -// -// tableModel.getIndexes().get(indexIndex).moveUpColumn(index); -// -// table.setSelection(index - 1); -// enableEditControls(index - 1); -// } -// -// @Override -// protected JiemamyElement removeTableSelectionItem() { -// TableViewer tableViewer = getTableViewer(); -// Table table = tableViewer.getTable(); -// int index = table.getSelectionIndex(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// if (index < 0 || index > table.getItemCount()) { -// return null; -// } -// IndexColumnModel removed = tableModel.getIndexes().get(indexIndex).removeColumn(index); -// -// tableViewer.remove(index); -// -// disableEditControls(); -// -// return removed; -// } -// -// private void updateModel() { -// Table table = getTableViewer().getTable(); -// int index = table.getSelectionIndex(); -// int indexIndex = ((IndexTableEditor) indexesEditArea).getTable().getSelectionIndex(); -// -// if (indexIndex != -1 && index != -1) { -// IndexColumnModel indexColumnModel = tableModel.getIndexes().get(indexIndex).getColumn(index); -// // indexColumnModel.getColumn(). addとかremoveとか -// if (radSortAsc.getSelection()) { -// indexColumnModel.setSort(IndexColumnModel.SORT_ASC); -// } else if (radSortDesc.getSelection()) { -// indexColumnModel.setSort(IndexColumnModel.SORT_DESC); -// } else { -// indexColumnModel.setSort(IndexColumnModel.SORT_NONE); -// } -// } -// } -// } -// -// private class IndexColumnLabelProvider extends BaseLabelProvider implements ITableLabelProvider { -// -// public Image getColumnImage(Object element, int columnIndex) { -// return null; -// } -// -// public String getColumnText(Object element, int columnIndex) { -// IndexColumnModel indexColumnModel = (IndexColumnModel) element; -// switch (columnIndex) { -// case 0: -// return indexColumnModel.createTableDisplayString(); -// case 1: -// return indexColumnModel.getSort().trim(); -// -// default: -// return ""; -// } -// } -// } -// -// private class IndexContentProvider extends ArrayContentProvider implements CommandListener { -// -// @SuppressWarnings("unused") -// private Viewer viewer; -// -// -// public void commandExecuted(Command command) { -//// if (evt.getPropertyName().equals(TableModel.P_ENTITY_TABLE_INDEXES)) { -// indexesEditArea.refreshTable(); // インデックスの変更を反映させる。 -//// } else if (evt.getSource() instanceof DefinitionModel) { -//// indexesEditArea.refreshTable(); // インデックスの変更を反映させる。 -//// if (evt.getPropertyName().equals(IndexModel.P_CREATE)) { -//// // nothing to do -//// } else if (evt.getPropertyName().equals(IndexModel.P_DELETE)) { -//// ((JiemamyElement) evt.getSource()).removePropertyChangeListener(this); -//// } else if (evt.getPropertyName().equals(IndexModel.P_REVERT)) { -//// ((JiemamyElement) evt.getSource()).addPropertyChangeListener(this); -//// } -//// } -// } -// -// @Override -// public void dispose() { -//// tableModel.removePropertyChangeListener(this); -//// for (IndexModel column : tableModel.getIndexes().get()) { -//// ((JiemamyElement) column).removePropertyChangeListener(this); -//// } -// super.dispose(); -// } -// -// public JiemamyElement getTargetModel() { -// // TODO Auto-generated method stub -// return null; -// } -// -// @Override -// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { -// this.viewer = viewer; -//// if (oldInput != null) { -//// tableModel.removePropertyChangeListener(this); -//// for (IndexModel indexModel : tableModel.getIndexes().get()) { -//// ((JiemamyElement) indexModel).removePropertyChangeListener(this); -//// } -//// } -//// if (newInput != null) { -//// tableModel.addPropertyChangeListener(this); -//// for (IndexModel indexModel : tableModel.getIndexes().get()) { -//// ((JiemamyElement) indexModel).addPropertyChangeListener(this); -//// } -//// } -// -// super.inputChanged(viewer, oldInput, newInput); -// } -// } -// -// private class IndexLabelProvider extends BaseLabelProvider implements ITableLabelProvider { -// -// public Image getColumnImage(Object element, int columnIndex) { -// return null; -// } -// -// public String getColumnText(Object element, int columnIndex) { -// IndexModel indexModel = (IndexModel) element; -// switch (columnIndex) { -// case 0: -// return indexModel.createTableDisplayString(); -// case 1: -// return String.valueOf(indexModel.isUnique()); -// -// default: -// return ""; -// } -// } -// } -// -// private class IndexTableEditor extends AbstractTableEditor { -// -// private TableModel tableModel; -// -// private Table table; -// -// -// public IndexTableEditor(TableModel targetModel) { -// super(); -// tableModel = targetModel; -// } -// -// public Table getTable() { -// return table; -// } -// -// @Override -// protected JiemamyElement addItem() { -// IndexModel indexModel = new IndexModel(); -// indexModel.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); -// -// tableModel.getIndexes().add(indexModel); -// -// int addedIndex = tableModel.getIndexes().indexOf(indexModel); -// table.setSelection(addedIndex); -// enableEditControls(addedIndex); -// txtIndexName.setFocus(); -// -// return indexModel; -// } -// -// @Override -// protected void configureEditorControls() { -// txtIndexName.addFocusListener(new TextSelectionAdapter(txtIndexName)); -// txtIndexName.addKeyListener(new KeyAdapter() { -// -// @Override -// public void keyReleased(KeyEvent e) { -// updateModel(); -// } -// }); -// chkIsUniqueIndex.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// updateModel(); -// } -// }); -// } -// -// @Override -// protected void configureTable(final Table table) { -// super.configureTable(table); -// -// table.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// int index = table.getSelectionIndex(); -// if (index >= 0) { -// ((IndexColumnEditTableArea) indexColumnsEditArea).updateInput(); -// } else { -// indexColumnsEditArea.disableEditControls(); -// } -// } -// }); -// } -// -// @Override -// protected void configureTableViewer(TableViewer tableViewer) { -// tableViewer.setLabelProvider(new IndexLabelProvider()); -// indexContentProvider = new IndexContentProvider(); -// tableViewer.setContentProvider(indexContentProvider); -// tableViewer.setInput(tableModel.getIndexes()); -// } -// -// @Override -// protected void createEditorControls(Composite parent) { -// Label label; -// -// Group group = new Group(parent, SWT.NULL); -// group.setText(JiemamyPlugin.getResourceString("dialog.table.index.title")); -// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// group.setLayout(new GridLayout(1, false)); -// -// Composite cmpNames = new Composite(group, SWT.NULL); -// cmpNames.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// // 論理名つける場合は 2→4 -// GridLayout layout = new GridLayout(2, false); -// layout.marginHeight = 0; -// layout.marginWidth = 0; -// cmpNames.setLayout(layout); -// -// label = new Label(cmpNames, SWT.NULL); -// label.setText(JiemamyPlugin.getResourceString("dialog.table.index.label.name")); -// -// txtIndexName = new Text(cmpNames, SWT.BORDER); -// txtIndexName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// -//// label = new Label(cmpNames, SWT.NULL); -//// label.setText(JiemamyPlugin.getDefault(). -//// getResourceString("dialog.table.index.label.logicalname")); -//// -//// txtIndexLogicalName = new Text(cmpNames, SWT.BORDER); -//// txtIndexLogicalName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// -// chkIsUniqueIndex = new Button(group, SWT.CHECK); -// chkIsUniqueIndex.setText(JiemamyPlugin.getResourceString("dialog.table.index.label.unique")); -// -// return group; -// } -// -// @Override -// protected void createTableColumns(Table table) { -// TableColumn colName = new TableColumn(table, SWT.LEFT); -// colName.setText(JiemamyPlugin.getResourceString("dialog.table.index.tbl.header.indexName")); -// colName.setWidth(180); -// -// TableColumn colUnique = new TableColumn(table, SWT.LEFT); -// colUnique.setText(JiemamyPlugin.getResourceString("dialog.table.index.tbl.header.unique")); -// colUnique.setWidth(50); -// } -// -// @Override -// protected void disableEditDetailControls() { -// txtIndexName.setEnabled(false); -// chkIsUniqueIndex.setEnabled(false); -// -// txtIndexName.setText(""); -// chkIsUniqueIndex.setSelection(false); -// } -// -// @Override -// protected void enableEditDetailControls(int index) { -// IndexModel indexModel = tableModel.getIndexes().get(index); -// -// txtIndexName.setEnabled(true); -// chkIsUniqueIndex.setEnabled(true); -// -// txtIndexName.setText(indexModel.getName()); -// chkIsUniqueIndex.setSelection(indexModel.isUnique()); -// } -// -// @Override -// protected JiemamyElement insertTableSelectionItem() { -// int index = table.getSelectionIndex(); -// IndexModel indexModel = new IndexModel(); -// indexModel.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); -// -// if (index < 0 || index > table.getItemCount()) { -// tableModel.addIndex(indexModel); -// } else { -// tableModel.addIndex(index, indexModel); -// } -// -// int addedIndex = tableModel.getColumns().indexOf(indexModel); -// table.setSelection(addedIndex); -// enableEditControls(addedIndex); -// txtIndexName.setFocus(); -// -// return indexModel; -// } -// -// @Override -// protected void moveDownTableSelectionItem() { -// int index = table.getSelectionIndex(); -// if (index < 0 || index >= table.getItemCount()) { -// return; -// } -// -// tableModel.moveDownIndex(index); -// -// table.setSelection(index + 1); -// enableEditControls(index + 1); -// } -// -// @Override -// protected void moveUpTableSelectionItem() { -// int index = table.getSelectionIndex(); -// if (index <= 0 || index > table.getItemCount()) { -// return; -// } -// -// tableModel.moveUpIndex(index); -// -// table.setSelection(index - 1); -// enableEditControls(index - 1); -// } -// -// @Override -// protected JiemamyElement removeTableSelectionItem() { -// int index = table.getSelectionIndex(); -// if (index < 0 || index > table.getItemCount()) { -// return null; -// } -// IndexModel indexToRemove = tableModel.getIndexes().remove(table.getSelectionIndex()); -// -// TableViewer tableViewer = getTableViewer(); -// tableViewer.remove(indexToRemove); -// -// disableEditControls(); -// -// return indexToRemove; -// } -// -// private void updateModel() { -// int index = table.getSelectionIndex(); -// if (index != -1) { -// IndexModel indexModel = tableModel.getIndexes().get(index); -// indexModel.setName(txtIndexName.getText()); -// indexModel.setUnique(chkIsUniqueIndex.getSelection()); -// } -// } -// } -//} Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogLocalKeyTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogLocalKeyTab.java 2009-02-20 10:13:56 UTC (rev 2695) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogLocalKeyTab.java 2009-02-21 03:26:42 UTC (rev 2696) @@ -103,7 +103,6 @@ localKeyEditor = new LocalKeyTableEditor(composite, SWT.NULL); localKeyEditor.configure(); localKeyEditor.disableEditControls(); - localKeyEditor.disableEditControls(); getTabItem().setControl(composite); } @@ -214,7 +213,7 @@ for (ColumnRef columnRef : unique.getKeyColumns()) { columnNames.add(resolver.resolve(columnRef).getName()); } - return StringUtils.join(columnNames, ","); + return StringUtils.join(columnNames, ", "); default: return StringUtils.EMPTY;