svnno****@sourc*****
svnno****@sourc*****
2009年 2月 24日 (火) 20:13:52 JST
Revision: 2725 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2725 Author: daisuke_m Date: 2009-02-24 20:13:51 +0900 (Tue, 24 Feb 2009) Log Message: ----------- Dialectによる追加タブに対応。 / UIリファクタリング。 Modified Paths: -------------- vesta/trunk/org.jiemamy.eclipse/schema/dialects.exsd vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/Messages.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialog.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDataSetTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 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/TableEditDialogCheckTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 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/TableEditDialogLocalKeyTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/view/ViewEditDialog.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages.properties vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages_ja.properties vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF vesta/trunk/org.jiemamy.eclipse.dialect.mysql/plugin.xml Added Paths: ----------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/DefaultTableEditorConfigurator.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/JiemamyEditDialog.java vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/TableEditDialogOptionTab.java -------------- next part -------------- Modified: vesta/trunk/org.jiemamy.eclipse/schema/dialects.exsd =================================================================== --- vesta/trunk/org.jiemamy.eclipse/schema/dialects.exsd 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/schema/dialects.exsd 2009-02-24 11:13:51 UTC (rev 2725) @@ -1,10 +1,10 @@ <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> -<schema targetNamespace="org.jiemamy.core"> +<schema targetNamespace="org.jiemamy.core" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> - <appInfo> + <appinfo> <meta.schema plugin="org.jiemamy.core" id="dialects" name="%plugin.extension.dialects"/> - </appInfo> + </appinfo> <documentation> This extension point is used to plug in additional SQL dialects. An SQL dialect is an object that knows about the restrictions and data types of a Relational Database Management System (RDBMS). Also, a dialect knows how to generate SQL for a given RDBMS. <p> @@ -15,6 +15,11 @@ </annotation> <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> <complexType> <sequence> <element ref="dialect" minOccurs="1" maxOccurs="unbounded"/> @@ -38,9 +43,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute translatable="true"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -48,32 +53,60 @@ <element name="dialect"> <complexType> + <sequence> + <element ref="additionalTab" minOccurs="0" maxOccurs="unbounded"/> + </sequence> <attribute name="class" type="string" use="required"> <annotation> <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java" basedOn="org.jiemamy.core.extension.dialect.Dialect"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> </element> + <element name="additionalTab"> + <complexType> + <attribute name="target" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn="org.eclipse.jface.dialogs.Dialog"/> + </appinfo> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn="org.jiemamy.eclipse.ui.tab.AbstractTab"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + <annotation> - <appInfo> + <appinfo> <meta.section type="since"/> - </appInfo> + </appinfo> <documentation> 0.0.1 </documentation> </annotation> <annotation> - <appInfo> + <appinfo> <meta.section type="examples"/> - </appInfo> + </appinfo> <documentation> The following is an example of the extension point usage: <p> @@ -102,18 +135,18 @@ </annotation> <annotation> - <appInfo> + <appinfo> <meta.section type="apiInfo"/> - </appInfo> + </appinfo> <documentation> Plug-ins that want to extend this extension point must implement the <samp>org.jiemamy.core.extension.dialect.Dialect</samp> interface. </documentation> </annotation> <annotation> - <appInfo> + <appinfo> <meta.section type="implementation"/> - </appInfo> + </appinfo> <documentation> The Jiemamy Database Modelling Plugin provides several default SQL dialect implementations: (In alphabetic order:) @@ -128,9 +161,9 @@ </annotation> <annotation> - <appInfo> + <appinfo> <meta.section type="copyright"/> - </appInfo> + </appinfo> <documentation> Copyright (c) 2007-2008, Jiemamy Project. All rights reserved. </documentation> Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -96,6 +96,7 @@ import org.jiemamy.ArtemisView; import org.jiemamy.DispatchStrategy; import org.jiemamy.Jiemamy; +import org.jiemamy.eclipse.EclipseDialectProvider; import org.jiemamy.eclipse.editor.editpart.DiagramEditPartFactory; import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory; @@ -298,7 +299,7 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); - jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new EclipseDialectProvider()); // FIXME 無差別ディスパッチになってる。 jiemamy.getEventBroker().setStrategy(new DispatchStrategy() { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -22,7 +22,6 @@ import java.util.List; import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory; import org.jiemamy.Jiemamy; +import org.jiemamy.eclipse.ui.JiemamyEditDialog; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.Deferrability; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; @@ -59,12 +59,10 @@ * * @author daisuke */ -public class ForeignKeyEditDialog extends Dialog { +public class ForeignKeyEditDialog extends JiemamyEditDialog<ForeignKeyModel> { private static Logger logger = LoggerFactory.getLogger(ForeignKeyEditDialog.class); - private ForeignKeyModel foreignKeyModel; - private List<ColumnModel> sourceColumns; private List<LocalKeyModel> referenceKeys; @@ -99,12 +97,11 @@ * @param foreignKeyModel */ public ForeignKeyEditDialog(Shell shell, ForeignKeyModel foreignKeyModel) { - super(shell); + super(shell, foreignKeyModel, ForeignKeyModel.class); setShellStyle(getShellStyle() | SWT.RESIZE); - this.foreignKeyModel = foreignKeyModel; jiemamy = foreignKeyModel.getJiemamy(); TableModel sourceTableModel = AttributeUtil.getDefinedTable(foreignKeyModel); - TableModel targetTableModel = (TableModel) ForeignKeyUtil.getReferenceEntity(this.foreignKeyModel); + TableModel targetTableModel = (TableModel) ForeignKeyUtil.getReferenceEntity(foreignKeyModel); sourceColumns = TableUtil.getColumns(sourceTableModel); referenceKeys = TableUtil.getAttributes(targetTableModel, LocalKeyModel.class); @@ -114,6 +111,7 @@ @Override public int open() { + ForeignKeyModel foreignKeyModel = getTargetModel(); int result = super.open(); txtKeyName.setText(StringUtils.defaultIfEmpty(foreignKeyModel.getName(), "")); @@ -157,9 +155,8 @@ protected Control createDialogArea(Composite parent) { getShell().setText(Messages.Dialog_Title); - Composite composite = new Composite(parent, SWT.NULL); + Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(5, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label; GridData gd; @@ -303,7 +300,8 @@ } @Override - protected void okPressed() { + protected boolean performOk() { + ForeignKeyModel foreignKeyModel = getTargetModel(); foreignKeyModel.setName(StringUtils.defaultIfEmpty(txtKeyName.getText(), null)); // TODO @@ -352,7 +350,6 @@ } } - - super.okPressed(); + return true; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/Messages.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/Messages.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/Messages.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -48,15 +48,6 @@ /** 説明タブ */ public static String Tab_Description; - /** 追加ボタンラベル */ - public static String Label_Add; - - /** 挿入ボタンラベル */ - public static String Label_Insert; - - /** 削除ボタンラベル */ - public static String Label_Remove; - /** ドメイン編集コントロールグループタイトル */ public static String Label_GroupTitle_Domain; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialog.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialog.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -21,7 +21,6 @@ import java.util.List; import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -37,6 +36,7 @@ import org.jiemamy.dialect.Dialect; import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.ui.JiemamyEditDialog; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.TextEditTab; import org.jiemamy.model.RootModel; @@ -46,25 +46,16 @@ * * @author daisuke */ -public class RootEditDialog extends Dialog { +public class RootEditDialog extends JiemamyEditDialog<RootModel> { private static Logger logger = LoggerFactory.getLogger(RootEditDialog.class); - /** 編集対象 */ - private RootModel rootModel; - /** スキーマ名入力欄 */ private Text txtSchema; /** Dialect選択 */ private Combo cmbDialect; - @SuppressWarnings("unused") - private RootEditDialogDomainTab tabDomain; - - @SuppressWarnings("unused") - private RootEditDialogDataSetTab tabDataSet; - /** 開始スクリプト入力欄 */ private TextEditTab tabBeginScript; @@ -82,12 +73,16 @@ * @param rootModel */ public RootEditDialog(Shell shell, RootModel rootModel) { - super(shell); + super(shell, rootModel, RootModel.class); setShellStyle(getShellStyle() | SWT.RESIZE); - this.rootModel = rootModel; } @Override + protected boolean canExecuteOk() { + return super.canExecuteOk() && StringUtils.isEmpty(cmbDialect.getText()) == false; + } + + @Override protected void constrainShellSize() { Shell shell = getShell(); shell.pack(); @@ -97,11 +92,11 @@ @Override protected Control createDialogArea(Composite parent) { + RootModel rootModel = getTargetModel(); getShell().setText(Messages.Dialog_Title); - Composite composite = new Composite(parent, SWT.NULL); + Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(4, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label; @@ -136,39 +131,39 @@ tabFolder.setLayoutData(gd); // ---- B-1. Domains - tabDomain = new RootEditDialogDomainTab(tabFolder, SWT.NONE, rootModel); + addTab(new RootEditDialogDomainTab(tabFolder, SWT.NONE, rootModel)); // ---- B-2. DataSets - tabDataSet = new RootEditDialogDataSetTab(tabFolder, SWT.NONE, rootModel); + addTab(new RootEditDialogDataSetTab(tabFolder, SWT.NONE, rootModel)); // ---- B-3. BeginScript String beginScript = StringUtils.defaultIfEmpty(rootModel.getBeginScript(), ""); tabBeginScript = new TextEditTab(tabFolder, Messages.Tab_BeginScript, beginScript); + addTab(tabBeginScript); // ---- B-4. EndScript String endScript = StringUtils.defaultIfEmpty(rootModel.getEndScript(), ""); tabEndScript = new TextEditTab(tabFolder, Messages.Tab_EndScript, endScript); + addTab(tabEndScript); // ---- B-5. Description String description = StringUtils.defaultIfEmpty(rootModel.getDescription(), ""); tabDescription = new TextEditTab(tabFolder, Messages.Tab_Description, description); + addTab(tabDescription); + createAdditionalTabs(tabFolder); + return composite; } @Override - protected void okPressed() { - if (canExecuteOk()) { - rootModel.setDialectClassName(cmbDialect.getText()); - rootModel.setSchemaName(StringUtils.defaultIfEmpty(txtSchema.getText(), null)); - rootModel.setBeginScript(StringUtils.defaultIfEmpty(tabBeginScript.getTextWidget().getText(), null)); - rootModel.setEndScript(StringUtils.defaultIfEmpty(tabEndScript.getTextWidget().getText(), null)); - rootModel.setDescription(StringUtils.defaultIfEmpty(tabDescription.getTextWidget().getText(), null)); - super.okPressed(); - } + protected boolean performOk() { + RootModel rootModel = getTargetModel(); + rootModel.setDialectClassName(cmbDialect.getText()); + rootModel.setSchemaName(StringUtils.defaultIfEmpty(txtSchema.getText(), null)); + rootModel.setBeginScript(StringUtils.defaultIfEmpty(tabBeginScript.getTextWidget().getText(), null)); + rootModel.setEndScript(StringUtils.defaultIfEmpty(tabEndScript.getTextWidget().getText(), null)); + rootModel.setDescription(StringUtils.defaultIfEmpty(tabDescription.getTextWidget().getText(), null)); + return true; } - - private boolean canExecuteOk() { - return StringUtils.isEmpty(cmbDialect.getText()) == false; - } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDataSetTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDataSetTab.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDataSetTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -50,7 +50,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -204,24 +204,7 @@ public DataSetTableEditor(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 - } - }); + super(parent, style, new DefaultTableEditorConfigurator("データセット情報")); // RESOURCE jiemamy = rootModel.getJiemamy(); dataSets = rootModel.getDataSets(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -60,7 +60,7 @@ import org.jiemamy.eclipse.editor.DisplayTarget; import org.jiemamy.eclipse.editor.utils.LabelStringUtil; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -259,24 +259,7 @@ * @param rootModel */ public DomainTableEditor(Composite parent, int style, final RootModel rootModel) { - super(parent, style, new TableEditorConfigurator() { - - public String getAddLabel() { - return Messages.Label_Add; - } - - public String getEditorTitle() { - return Messages.Label_GroupTitle_Domain; - } - - public String getInsertLabel() { - return Messages.Label_Insert; - } - - public String getRemoveLabel() { - return Messages.Label_Remove; - } - }); + super(parent, style, new DefaultTableEditorConfigurator(Messages.Label_GroupTitle_Domain)); jiemamy = rootModel.getJiemamy(); domains = rootModel.getDomains(); 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-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialog.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -23,7 +23,6 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.SWT; @@ -43,6 +42,7 @@ import org.jiemamy.eclipse.Images; import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.ui.JiemamyEditDialog; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.TextEditTab; import org.jiemamy.model.RootModel; @@ -52,34 +52,17 @@ import org.jiemamy.utils.model.TableUtil; /** - * テーブルの詳細編集ダイアログ + * テーブルの詳細編集ダイアログ。 * - * @author takezoe * @author daisuke */ -public class TableEditDialog extends Dialog { +public class TableEditDialog extends JiemamyEditDialog<TableModel> { - private TableModel tableModel; - - private RootModel rootModel; - // 共通 private Text txtTableName; private Text txtLogicalName; - @SuppressWarnings("unused") - private TableEditDialogColumnTab tabColumns; - - @SuppressWarnings("unused") - private TableEditDialogLocalKeyTab tabLocalKeys; - - @SuppressWarnings("unused") - private TableEditDialogCheckTab tabChecks; - - @SuppressWarnings("unused") - private TableEditDialogIndexTab tabIndexes; - private TextEditTab tabBeginScript; private TextEditTab tabEndScript; @@ -90,16 +73,48 @@ /** * コンストラクタ。 * - * @param parentShell 親shell + * @param parentShell 親シェル * @param tableModel 編集対象モデル - * @param rootModel ルートモデル */ - public TableEditDialog(Shell parentShell, TableModel tableModel, RootModel rootModel) { - super(parentShell); + public TableEditDialog(Shell parentShell, TableModel tableModel) { + super(parentShell, tableModel, TableModel.class); setShellStyle(getShellStyle() | SWT.RESIZE); + } + + @Override + protected boolean canExecuteOk() { + if (StringUtils.isEmpty(txtTableName.getText())) { + return false; + } + TableModel tableModel = getTargetModel(); + RootModel rootModel = tableModel.getJiemamy().getFactory().getRootModel(); - this.tableModel = tableModel; - this.rootModel = rootModel; + Set<EntityModel> entities = rootModel.getEntities(); + Set<String> entityNames = new HashSet<String>(entities.size()); + for (EntityModel entity : entities) { + if (entity != tableModel) { + entityNames.add(entity.getName()); + } + } + + List<ColumnModel> columns = TableUtil.getColumns(tableModel); + Set<String> columnNames = new HashSet<String>(columns.size()); + for (ColumnModel column : columns) { + columnNames.add(column.getName()); + } + + boolean entityCheckOk = true; + boolean columnCheckOk = true; + + if (entityNames.contains(txtTableName.getText())) { + entityCheckOk = MessageDialog.openQuestion(getParentShell(), "Confirm", "エンティティ名が重複しますが、よろしいですか?"); // RESOURCE + } + + if (columnNames.size() != columns.size()) { + columnCheckOk = MessageDialog.openQuestion(getParentShell(), "Confirm", "カラム名が重複しますが、よろしいですか?"); // RESOURCE + } + + return entityCheckOk && columnCheckOk && super.canExecuteOk(); } @Override @@ -112,12 +127,12 @@ @Override protected Control createDialogArea(Composite parent) { + TableModel tableModel = getTargetModel(); getShell().setText("テーブル情報編集"); // RESOURCE // ---- A. 最上段名称欄 - Composite composite = new Composite(parent, SWT.NULL); + Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(6, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); // ---- A-1. テーブル名 Label label = new Label(composite, SWT.NONE); @@ -173,76 +188,45 @@ tabFolder.setLayoutData(gd); // ---- B-1. カラム - tabColumns = new TableEditDialogColumnTab(tabFolder, SWT.NULL, tableModel); + addTab(new TableEditDialogColumnTab(tabFolder, SWT.NULL, tableModel)); // ---- B-2. 内部キー - tabLocalKeys = new TableEditDialogLocalKeyTab(tabFolder, SWT.NULL, tableModel); + addTab(new TableEditDialogLocalKeyTab(tabFolder, SWT.NULL, tableModel)); // ---- B-3. チェック制約 - tabChecks = new TableEditDialogCheckTab(tabFolder, SWT.NULL, tableModel); + addTab(new TableEditDialogCheckTab(tabFolder, SWT.NULL, tableModel)); // ---- B-4. インデックス - tabIndexes = new TableEditDialogIndexTab(tabFolder, SWT.NULL, tableModel); + addTab(new TableEditDialogIndexTab(tabFolder, SWT.NULL, tableModel)); // ---- B-6. BeginScript String beginScript = StringUtils.defaultIfEmpty(tableModel.getBeginScript(), ""); tabBeginScript = new TextEditTab(tabFolder, Messages.Tab_Table_BeginScript, beginScript); + addTab(tabBeginScript); // ---- B-7. EndScript String endScript = StringUtils.defaultIfEmpty(tableModel.getEndScript(), ""); tabEndScript = new TextEditTab(tabFolder, Messages.Tab_Table_EndScript, endScript); + addTab(tabEndScript); // ---- B-8. Description String description = StringUtils.defaultIfEmpty(tableModel.getDescription(), ""); tabDescription = new TextEditTab(tabFolder, Messages.Tab_Table_Description, description); + addTab(tabDescription); + createAdditionalTabs(tabFolder); + return composite; } @Override - protected void okPressed() { - if (canExecuteOk() == false) { - return; - - } + protected boolean performOk() { + TableModel tableModel = getTargetModel(); tableModel.setName(txtTableName.getText()); tableModel.setLogicalName(StringUtils.defaultIfEmpty(txtLogicalName.getText(), null)); tableModel.setBeginScript(StringUtils.defaultIfEmpty(tabBeginScript.getTextWidget().getText(), null)); tableModel.setEndScript(StringUtils.defaultIfEmpty(tabEndScript.getTextWidget().getText(), null)); tableModel.setDescription(StringUtils.defaultIfEmpty(tabDescription.getTextWidget().getText(), null)); - super.okPressed(); + return true; } - - private boolean canExecuteOk() { - if (StringUtils.isEmpty(txtTableName.getText())) { - return false; - } - - Set<EntityModel> entities = rootModel.getEntities(); - Set<String> entityNames = new HashSet<String>(entities.size()); - for (EntityModel entity : entities) { - if (entity != tableModel) { - entityNames.add(entity.getName()); - } - } - - List<ColumnModel> columns = TableUtil.getColumns(tableModel); - Set<String> columnNames = new HashSet<String>(columns.size()); - for (ColumnModel column : columns) { - columnNames.add(column.getName()); - } - - boolean entityCheckOk = true; - boolean columnCheckOk = true; - - if (entityNames.contains(txtTableName.getText())) { - entityCheckOk = MessageDialog.openQuestion(getParentShell(), "Confirm", "エンティティ名が重複しますが、よろしいですか?"); // RESOURCE - } - - if (columnNames.size() != columns.size()) { - columnCheckOk = MessageDialog.openQuestion(getParentShell(), "Confirm", "カラム名が重複しますが、よろしいですか?"); // RESOURCE - } - - return entityCheckOk && columnCheckOk; - } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogCheckTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogCheckTab.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogCheckTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -47,7 +47,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -61,7 +61,7 @@ import org.jiemamy.utils.model.TableUtil; /** - * テーブル編集ダイアログの「CHECK制約」タブ。 + * テーブル編集ダイアログの「チェック制約」タブ。 * * @author daisuke */ @@ -206,24 +206,7 @@ public CheckTableEditor(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 - } - }); + super(parent, style, new DefaultTableEditorConfigurator("チェック制約情報")); // RESOURCE jiemamy = tableModel.getJiemamy(); checks = TableUtil.getAttributes(tableModel, TableCheckModel.class); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -61,7 +61,7 @@ import org.jiemamy.eclipse.editor.DisplayTarget; import org.jiemamy.eclipse.editor.utils.LabelStringUtil; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -299,24 +299,7 @@ * @param style */ public ColumnTableEditor(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 - } - }); + super(parent, style, new DefaultTableEditorConfigurator("カラム情報")); // RESOURCE jiemamy = tableModel.getJiemamy(); columns = TableUtil.getColumns(tableModel); Modified: 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-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -50,7 +50,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -210,25 +210,7 @@ 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 - } - }); - + super(parent, style, new DefaultTableEditorConfigurator("インデックスカラム情報")); // RESOURCE jiemamy = tableModel.getJiemamy(); } @@ -570,24 +552,7 @@ 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 - } - }); + super(parent, style, new DefaultTableEditorConfigurator("インデックス情報")); // RESOURCE jiemamy = tableModel.getJiemamy(); indexes = tableModel.getIndexes(); 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-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogLocalKeyTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -54,7 +54,7 @@ import org.jiemamy.eclipse.Images; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.ui.AbstractTableEditor; -import org.jiemamy.eclipse.ui.TableEditorConfigurator; +import org.jiemamy.eclipse.ui.DefaultTableEditorConfigurator; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.AbstractTab; import org.jiemamy.editcommand.Command; @@ -234,24 +234,7 @@ public LocalKeyTableEditor(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 - } - }); + super(parent, style, new DefaultTableEditorConfigurator("ローカルキー情報")); // RESOURCE jiemamy = tableModel.getJiemamy(); localKeys = TableUtil.getAttributes(tableModel, LocalKeyModel.class); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/view/ViewEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/view/ViewEditDialog.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/view/ViewEditDialog.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -19,7 +19,6 @@ package org.jiemamy.eclipse.editor.dialog.view; import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -38,6 +37,7 @@ import org.jiemamy.eclipse.Images; import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.ui.JiemamyEditDialog; import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.ui.tab.TextEditTab; import org.jiemamy.model.entity.ViewModel; @@ -47,10 +47,8 @@ * * @author daisuke */ -public class ViewEditDialog extends Dialog { +public class ViewEditDialog extends JiemamyEditDialog<ViewModel> { - private ViewModel viewModel; - private Text txtName; private Text txtLogicalName; @@ -71,13 +69,17 @@ * @param viewModel */ public ViewEditDialog(Shell shell, ViewModel viewModel) { - super(shell); + super(shell, viewModel, ViewModel.class); setShellStyle(getShellStyle() | SWT.RESIZE); - - this.viewModel = viewModel; } @Override + protected boolean canExecuteOk() { + return StringUtils.isEmpty(tabDefinition.getTextWidget().getText()) == false + && StringUtils.isEmpty(txtName.getText()) == false && super.canExecuteOk(); + } + + @Override protected void constrainShellSize() { Shell shell = getShell(); shell.pack(); @@ -87,11 +89,11 @@ @Override protected Control createDialogArea(Composite parent) { + ViewModel viewModel = getTargetModel(); getShell().setText(Messages.Dialog_Title); - Composite composite = new Composite(parent, SWT.NULL); + Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(6, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); // ---- A-1. ビュー名 Label label = new Label(composite, SWT.NULL); @@ -157,40 +159,40 @@ tabDefinition = new TextEditTab(tabFolder, Messages.Tab_View_Definition, StringUtils.defaultIfEmpty(viewModel .getDefinition(), "")); + addTab(tabDefinition); // ---- B-2. BeginScript tabBeginScript = new TextEditTab(tabFolder, Messages.Tab_View_BeginScript, StringUtils.defaultIfEmpty(viewModel .getBeginScript(), "")); + addTab(tabBeginScript); // ---- B-3. EndScript tabEndScript = new TextEditTab(tabFolder, Messages.Tab_View_EndScript, StringUtils.defaultIfEmpty(viewModel .getEndScript(), "")); + addTab(tabEndScript); // ---- B-4. Description tabDescription = new TextEditTab(tabFolder, Messages.Tab_View_Description, StringUtils.defaultIfEmpty(viewModel .getDescription(), "")); + addTab(tabDescription); + createAdditionalTabs(tabFolder); + return composite; } @Override - protected void okPressed() { - if (canExecuteOk()) { - viewModel.setName(txtName.getText()); - viewModel.setLogicalName(StringUtils.defaultIfEmpty(txtLogicalName.getText(), null)); - viewModel.setDefinition(tabDefinition.getTextWidget().getText()); - viewModel.setBeginScript(StringUtils.defaultIfEmpty(tabBeginScript.getTextWidget().getText(), null)); - viewModel.setEndScript(StringUtils.defaultIfEmpty(tabEndScript.getTextWidget().getText(), null)); - viewModel.setDescription(StringUtils.defaultIfEmpty(tabDescription.getTextWidget().getText(), null)); - super.okPressed(); - } + protected boolean performOk() { + ViewModel viewModel = getTargetModel(); + viewModel.setName(txtName.getText()); + viewModel.setLogicalName(StringUtils.defaultIfEmpty(txtLogicalName.getText(), null)); + viewModel.setDefinition(tabDefinition.getTextWidget().getText()); + viewModel.setBeginScript(StringUtils.defaultIfEmpty(tabBeginScript.getTextWidget().getText(), null)); + viewModel.setEndScript(StringUtils.defaultIfEmpty(tabEndScript.getTextWidget().getText(), null)); + viewModel.setDescription(StringUtils.defaultIfEmpty(tabDescription.getTextWidget().getText(), null)); + return true; } - - private boolean canExecuteOk() { - return StringUtils.isEmpty(tabDefinition.getTextWidget().getText()) == false - && StringUtils.isEmpty(txtName.getText()) == false; - } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -76,11 +76,10 @@ public void openEditDialog() { logger.debug(LogMarker.LIFECYCLE, "openEditDialog"); - RootModel rootModel = (RootModel) getParent().getModel(); NodeAdapter node = getModel(); TableModel tableModel = (TableModel) node.unwrap(); - TableEditDialog dialog = new TableEditDialog(getViewer().getControl().getShell(), tableModel, rootModel); + TableEditDialog dialog = new TableEditDialog(getViewer().getControl().getShell(), tableModel); // // // 編集前のスナップショットを保存 // Memento beforeEditMemento = dialog.createMemento(); Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/DefaultTableEditorConfigurator.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/DefaultTableEditorConfigurator.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/DefaultTableEditorConfigurator.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -0,0 +1,57 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/24 + * + * 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.ui; + +/** + * {@link TableEditorConfigurator}のデフォルト実装。 + * + * @author daisuke + */ +public class DefaultTableEditorConfigurator implements TableEditorConfigurator { + + private final String editorTitle; + + + /** + * インスタンスを生成する。 + * + * @param editorTitle + */ + public DefaultTableEditorConfigurator(String editorTitle) { + this.editorTitle = editorTitle; + + } + + public String getAddLabel() { + return "追加"; // RESOURCE + } + + public String getEditorTitle() { + return editorTitle; + } + + public String getInsertLabel() { + return "挿入"; // RESOURCE + } + + public String getRemoveLabel() { + return "削除"; // RESOURCE + } + +} Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/DefaultTableEditorConfigurator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/JiemamyEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/JiemamyEditDialog.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/JiemamyEditDialog.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -0,0 +1,167 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/24 + * + * 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.ui; + +import java.lang.reflect.Constructor; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; + +import org.jiemamy.dialect.Dialect; +import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.extension.ExtensionResolver; +import org.jiemamy.eclipse.ui.tab.AbstractTab; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.CollectionsUtil; + +/** + * Jiemamyのモデル編集ダイアログ抽象クラス。 + * + * @param <T> 編集対象モデルの型 + * @author daisuke + */ +public abstract class JiemamyEditDialog<T extends JiemamyElement> extends Dialog { + + /** 編集対象モデル */ + private T targetModel; + + /** 保持するタブのリスト */ + private List<AbstractTab> tabs = CollectionsUtil.newArrayList(); + + /** 編集対象モデルの型 */ + private final Class<? extends JiemamyElement> type; + + + /** + * インスタンスを生成する。 + * + * @param parentShell 親シェル + * @param targetModel 編集対象モデルの型 + */ + protected JiemamyEditDialog(Shell parentShell, T targetModel, Class<? extends JiemamyElement> type) { + super(parentShell); + this.targetModel = targetModel; + this.type = type; + + getButton(IDialogConstants.OK_ID); + } + + /** + * タブを追加登録する。 + * + * @param tab + */ + protected void addTab(AbstractTab tab) { + tabs.add(tab); + } + + /** + * TODO for daisuke + * + * @return + */ + protected boolean canExecuteOk() { + // Default implementation is to check if all tabs are complete. + for (AbstractTab tab : tabs) { + if (tab.isTabComplete() == false) { + return false; + } + } + return true; + } + + /** + * TODO for daisuke + * + * @param tabFolder + * @param tabClassName + * @return + */ + protected AbstractTab createAdditionalTab(TabFolder tabFolder, String tabClassName) { + AbstractTab tab = null; + try { + Class<? extends AbstractTab> tabClass = (Class<? extends AbstractTab>) Class.forName(tabClassName); + Constructor<? extends AbstractTab> constructor = tabClass.getConstructor(TabFolder.class, int.class, type); + tab = constructor.newInstance(tabFolder, SWT.NULL, targetModel); + } catch (Exception e) { + JiemamyPlugin.log(e); + } + return tab; + } + + /** + * TODO for daisuke + * + * @param tabFolder + * @return + */ + protected List<AbstractTab> createAdditionalTabs(TabFolder tabFolder) { + List<AbstractTab> result = CollectionsUtil.newArrayList(); + ExtensionResolver<Dialect> dialectResolver = JiemamyPlugin.getDialectResolver(); + + RootModel rootModel = targetModel.getJiemamy().getFactory().getRootModel(); + + IConfigurationElement dialectElement = + dialectResolver.getExtensionConfigurationElements().get(rootModel.getDialectClassName()); + + for (IConfigurationElement additionalTabElement : dialectElement.getChildren("additionalTab")) { + if (additionalTabElement.getAttribute("target").equals(this.getClass().getName())) { + String tabClassName = additionalTabElement.getAttribute("class"); + AbstractTab tab = createAdditionalTab(tabFolder, tabClassName); + if (tab != null) { + result.add(tab); + addTab(tab); + } + } + } + return result; + } + + /** + * 編集対象モデルを取得する。 + * + * @return 編集対象モデル + */ + protected T getTargetModel() { + return targetModel; + } + + @Override + protected void okPressed() { + if (canExecuteOk() == false) { + return; + } + if (performOk()) { + super.okPressed(); + } + } + + /** + * TODO for daisuke + * + * @return + */ + protected abstract boolean performOk(); +} Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/JiemamyEditDialog.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -56,4 +56,14 @@ return tabItem; } + /** + * TODO for daisuke + * + * @return + */ + public boolean isTabComplete() { + // TODO abstractにせよ + return true; + } + } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages.properties =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages.properties 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages.properties 2009-02-24 11:13:51 UTC (rev 2725) @@ -5,9 +5,6 @@ Tab_BeginScript = Begin Script Tab_EndScript = End Script Tab_Description = Description -Label_Add = Add -Label_Insert = Insert -Label_Remove = Remove Label_GroupTitle_Domain = Domain Information Label_Domain_Name = Domain Name Label_Domain_DataType = Data Type Modified: vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages_ja.properties =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages_ja.properties 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse/src/main/resources/org/jiemamy/eclipse/editor/dialog/root/messages_ja.properties 2009-02-24 11:13:51 UTC (rev 2725) @@ -5,9 +5,6 @@ Tab_BeginScript = \u958b\u59cb\u30b9\u30af\u30ea\u30d7\u30c8 Tab_EndScript = \u7d42\u4e86\u30b9\u30af\u30ea\u30d7\u30c8 Tab_Description = \u8aac\u660e -Label_Add = \u8ffd\u52a0 -Label_Insert = \u633f\u5165 -Label_Remove = \u524a\u9664 Label_GroupTitle_Domain = \u30c9\u30e1\u30a4\u30f3\u60c5\u5831 Label_Domain_Name = \u30c9\u30e1\u30a4\u30f3\u540d Label_Domain_DataType = \u30c7\u30fc\u30bf\u578b Modified: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF =================================================================== --- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF 2009-02-24 11:13:51 UTC (rev 2725) @@ -25,6 +25,7 @@ lib/stax-1.2.0.jar, lib/stax-api-1.0.1.jar, lib/wstx-asl-3.2.7.jar -Require-Bundle: org.jiemamy.eclipse +Require-Bundle: org.jiemamy.eclipse, + org.eclipse.ui Eclipse-BuddyPolicy: registered Eclipse-RegisterBuddy: org.jiemamy.eclipse Modified: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/plugin.xml =================================================================== --- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/plugin.xml 2009-02-24 10:59:15 UTC (rev 2724) +++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/plugin.xml 2009-02-24 11:13:51 UTC (rev 2725) @@ -5,7 +5,11 @@ <extension point="org.jiemamy.eclipse.dialects"> <dialect - class="org.jiemamy.dialect.mysql.MySqlDialect"/> + class="org.jiemamy.dialect.mysql.MySqlDialect"> + <additionalTab + target="org.jiemamy.eclipse.editor.dialog.table.TableEditDialog" + class="org.jiemamy.eclipse.dialect.mysql.TableEditDialogOptionTab" /> + </dialect> </extension> </plugin> Added: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/TableEditDialogOptionTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/TableEditDialogOptionTab.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/TableEditDialogOptionTab.java 2009-02-24 11:13:51 UTC (rev 2725) @@ -0,0 +1,80 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/24 + * + * 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.dialect.mysql; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabFolder; + +import org.jiemamy.dialect.mysql.adapter.StandardEngine; +import org.jiemamy.dialect.mysql.adapter.StorageEngine; +import org.jiemamy.dialect.mysql.adapter.StorageEngineType; +import org.jiemamy.eclipse.ui.tab.AbstractTab; +import org.jiemamy.model.entity.TableModel; + +/** + * テーブル編集ダイアログの「MySQL」タブ。 + * + * @author daisuke + */ +public class TableEditDialogOptionTab extends AbstractTab { + + private final TableModel tableModel; + + private Combo cmbEngine; + + + /** + * インスタンスを生成する。 + * + * @param parentTabFolder + * @param style + * @param tableModel + */ + public TableEditDialogOptionTab(TabFolder parentTabFolder, int style, TableModel tableModel) { + super(parentTabFolder, style, "MySQL"); + this.tableModel = tableModel; + + Composite composite = new Composite(parentTabFolder, SWT.NULL); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Label label = new Label(composite, SWT.NULL); + label.setText("エンジン"); // RESOURCE + + cmbEngine = new Combo(composite, SWT.READ_ONLY); + cmbEngine.add(""); + for (StandardEngine type : StandardEngine.values()) { + cmbEngine.add(type.toString()); + } + + StorageEngine storageEngine = tableModel.getAdapter(StorageEngine.class); + if (storageEngine != null && storageEngine.getType() != null) { + StorageEngineType type = storageEngine.getType(); + cmbEngine.setText(type.toString()); + } + + getTabItem().setControl(composite); + } + +} Property changes on: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/TableEditDialogOptionTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain