[Jiemamy-notify:1445] commit [2674] 少しずつダイアログ作り始め。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 16日 (月) 03:57:32 JST


Revision: 2674
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2674
Author:   daisuke_m
Date:     2009-02-16 03:57:32 +0900 (Mon, 16 Feb 2009)

Log Message:
-----------
少しずつダイアログ作り始め。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java
    vesta/trunk/org.jiemamy.eclipse.dialect.mysql/.classpath
    vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF
    vesta/trunk/org.jiemamy.eclipse.dialect.mysql/build.properties

Added Paths:
-----------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DomainUtil.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialog.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialogDomainTab.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/AbstractTableViewerEditArea.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/ControlArea.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/TextSelectionAdapter.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/
    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/TextEditTab.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java	2009-02-15 17:03:03 UTC (rev 2673)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -28,6 +28,14 @@
  */
 public class ListUtils {
 	
+	public static void moveDown(List<?> list, int index) {
+		Collections.swap(list, index, index + 1);
+	}
+	
+	public static void moveUp(List<?> list, int index) {
+		Collections.swap(list, index, index - 1);
+	}
+	
 	/**
 	 * リストの順序を反転させる。
 	 * 

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DomainUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DomainUtil.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DomainUtil.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/16
+ *
+ * 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.utils.model;
+
+import java.util.List;
+
+import org.jiemamy.model.attribute.constraint.ConstraintModel;
+import org.jiemamy.model.attribute.constraint.ValueConstraintModel;
+import org.jiemamy.model.datatype.DomainModel;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class DomainUtil {
+	
+	/**
+	 * TODO for daisuke
+	 * @param domainModel 
+	 * 
+	 * @param clazz
+	 * @return 
+	 */
+	public static boolean hasConstraint(DomainModel domainModel, Class<? extends ConstraintModel> clazz) {
+		List<ValueConstraintModel> constraints = domainModel.getConstraints();
+		for (ValueConstraintModel constraint : constraints) {
+			if (clazz.isAssignableFrom(constraint.getClass())) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private DomainUtil() {
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DomainUtil.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java	2009-02-15 17:03:03 UTC (rev 2673)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -24,6 +24,7 @@
 
 import org.apache.commons.lang.Validate;
 
+import org.jiemamy.Jiemamy;
 import org.jiemamy.dialect.Dialect;
 import org.jiemamy.exception.ElementNotFoundException;
 import org.jiemamy.exception.TooManyElementsException;
@@ -127,6 +128,18 @@
 	}
 	
 	/**
+	 * TODO for daisuke
+	 * 
+	 * @param rootModel
+	 * @return 
+	 * @throws ClassNotFoundException 
+	 */
+	public static Dialect getDialect(RootModel rootModel) throws ClassNotFoundException {
+		Jiemamy jiemamy = rootModel.getJiemamy();
+		return jiemamy.getDialect(rootModel);
+	}
+	
+	/**
 	 * 特定の種類のノードのリストを取得する。
 	 * @param <T> 取得したいノードのクラス
 	 * @param rootModel 

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialog.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialog.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialog.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,133 @@
+package org.jiemamy.eclipse.editor.dialog.root;
+
+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;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Text;
+
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.eclipse.JiemamyPlugin;
+import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter;
+import org.jiemamy.eclipse.ui.tab.AbstractTab;
+import org.jiemamy.eclipse.ui.tab.TextEditTab;
+import org.jiemamy.model.RootModel;
+
+/**
+ * Database設定ダイアログ
+ * 
+ * @author daisuke
+ */
+public class DatabaseEditDialog extends Dialog {
+	
+	private RootModel rootModel;
+	
+	private Text txtSchema;
+	
+	private Combo cmbDialect;
+	
+	private Text txtBeginScript;
+	
+	private Text txtEndScript;
+	
+	private Text txtDescription;
+	
+
+	/**
+	 * コンストラクタ。
+	 * 
+	 * @param shell
+	 * @param dbModel
+	 */
+	public DatabaseEditDialog(Shell shell, RootModel dbModel) {
+		super(shell);
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+		rootModel = dbModel;
+	}
+	
+	@Override
+	protected void constrainShellSize() {
+		Shell shell = getShell();
+		shell.pack();
+		int height = 400;
+		shell.setSize((int) (height * 1.618), height);
+	}
+	
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		getShell().setText("dialog.db.title"); // RESOURCE
+		
+		Composite composite = new Composite(parent, SWT.NULL);
+		composite.setLayout(new GridLayout(4, false));
+		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		Label label;
+		
+		// ---- A-1. スキーマ名
+		label = new Label(composite, SWT.NULL);
+		label.setText("dialog.db.label.schema"); // RESOURCE
+		
+		txtSchema = new Text(composite, SWT.BORDER);
+		txtSchema.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		txtSchema.setText(StringUtils.defaultIfEmpty(rootModel.getSchemaName(), ""));
+		txtSchema.addFocusListener(new TextSelectionAdapter(txtSchema));
+		
+		// ---- A-2. RDBMS
+		label = new Label(composite, SWT.NULL);
+		label.setText("dialog.db.label.rdbms"); // RESOURCE
+		
+		cmbDialect = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+		cmbDialect.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		for (Dialect dialect : JiemamyPlugin.getDialectResolver().getAllInstance()) {
+			cmbDialect.add(dialect.toString());
+		}
+		cmbDialect.setText(rootModel.getDialectClassName());
+		cmbDialect.setVisibleItemCount(20);
+		
+		// ---- B. タブ
+		TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
+		GridData gd = new GridData(GridData.FILL_BOTH);
+		gd.horizontalSpan = 4;
+		tabFolder.setLayoutData(gd);
+		
+		// ---- B-1. Domains
+		AbstractTab domainTab = new DatabaseEditDialogDomainTab(rootModel);
+		domainTab.createControlArea(tabFolder);
+		
+		// ---- B-2. BeginScript
+		AbstractTab beginScriptTab = new TextEditTab(rootModel.getBeginScript(), "dialog.common.tab.beginScript"); // RESOURCE
+		txtBeginScript = (Text) beginScriptTab.createControlArea(tabFolder);
+		
+		// ---- B-3. EndScript
+		AbstractTab endScriptTab = new TextEditTab(rootModel.getEndScript(), "dialog.common.tab.endScript"); // RESOURCE
+		txtEndScript = (Text) endScriptTab.createControlArea(tabFolder);
+		
+		// ---- B-4. Description
+		AbstractTab descriptionTab = new TextEditTab(rootModel.getDescription(), "dialog.common.tab.description"); // RESOURCE
+		txtDescription = (Text) descriptionTab.createControlArea(tabFolder);
+		
+		return composite;
+	}
+	
+	/**
+	 * Override method.
+	 * 
+	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+	 */
+	@Override
+	protected void okPressed() {
+		rootModel.setDialectClassName(cmbDialect.getText());
+		rootModel.setSchemaName(txtSchema.getText());
+		rootModel.setBeginScript(txtBeginScript.getText());
+		rootModel.setEndScript(txtEndScript.getText());
+		rootModel.setDescription(txtDescription.getText());
+		super.okPressed();
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialog.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialogDomainTab.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialogDomainTab.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialogDomainTab.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,668 @@
+package org.jiemamy.eclipse.editor.dialog.root;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+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.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+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.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+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.JiemamyFactory;
+import org.jiemamy.eclipse.Images;
+import org.jiemamy.eclipse.JiemamyPlugin;
+import org.jiemamy.eclipse.editor.DisplayPlace;
+import org.jiemamy.eclipse.editor.DisplayTarget;
+import org.jiemamy.eclipse.editor.utils.LabelStringUtil;
+import org.jiemamy.eclipse.ui.AbstractTableViewerEditArea;
+import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter;
+import org.jiemamy.eclipse.ui.tab.AbstractTab;
+import org.jiemamy.model.JiemamyElement;
+import org.jiemamy.model.RootModel;
+import org.jiemamy.model.attribute.constraint.NotNullConstraintModel;
+import org.jiemamy.model.attribute.constraint.UniqueKeyModel;
+import org.jiemamy.model.datatype.BuiltinDataType;
+import org.jiemamy.model.datatype.DataType;
+import org.jiemamy.model.datatype.DataTypeCategory;
+import org.jiemamy.model.datatype.DomainModel;
+import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter;
+import org.jiemamy.utils.ListUtils;
+import org.jiemamy.utils.model.DomainUtil;
+
+/**
+ * データベース編集ダイアログの「ドメイン」タブ
+ * 
+ * @author daisuke
+ */
+public class DatabaseEditDialogDomainTab extends AbstractTab {
+	
+	private RootModel rootModel;
+	
+	private AbstractTableViewerEditArea domainEditArea;
+	
+	private DomainContentProvider contentProvider;
+	
+	private Text txtDomainName;
+	
+	private Combo cmbColumnType;
+	
+	private Text txtColumnSize;
+	
+	private Text txtDefaultValue;
+	
+	private Text txtDescription;
+	
+	private Button chkIsNotNull;
+	
+	private Button chkIsUnique;
+	
+
+	/**
+	 * コンストラクタ。
+	 * 
+	 * @param rootModel
+	 */
+	public DatabaseEditDialogDomainTab(RootModel rootModel) {
+		super();
+		this.rootModel = rootModel;
+	}
+	
+	public Composite createControlArea(TabFolder parentTabFolder) {
+		Composite composite = new Composite(parentTabFolder, SWT.NULL);
+		composite.setLayout(new GridLayout(1, false));
+		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		TabItem tabDomain = new TabItem(parentTabFolder, SWT.NONE);
+		tabDomain.setText("dialog.db.tab.domain"); // RESOURCE
+		tabDomain.setControl(composite);
+		
+		createDomainTab(composite);
+		domainEditArea.disableEditControls();
+		
+		return composite;
+	}
+	
+	private void createDomainTab(Composite parent) {
+		domainEditArea = new DomainEditTableArea(rootModel);
+		domainEditArea.setAddLabel("dialog.db.domain.btn.add"); // RESOURCE
+		domainEditArea.setInsertLabel("dialog.db.domain.btn.insert"); // RESOURCE
+		domainEditArea.setRemoveLabel("dialog.db.domain.btn.remove"); // RESOURCE
+		domainEditArea.createControlArea(parent);
+	}
+	
+
+	/**
+	 * Domain用ContentProvider
+	 * 
+	 * @author daisuke
+	 */
+	private class DomainContentProvider extends ArrayContentProvider implements PropertyChangeListener {
+		
+		@SuppressWarnings("unused")
+		private Viewer viewer;
+		
+
+		@Override
+		public void dispose() {
+//			rootModel.removePropertyChangeListener(this);
+//			for (DomainModel domain : rootModel.getDomains()) {
+//				domain.removePropertyChangeListener(this);
+//			}
+			super.dispose();
+		}
+		
+		@Override
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			this.viewer = viewer;
+			if (oldInput != null) {
+//				rootModel.removePropertyChangeListener(this);
+//				for (DomainModel domain : rootModel.getDomains()) {
+//					domain.removePropertyChangeListener(this);
+//				}
+			}
+			if (newInput != null) {
+//				rootModel.addPropertyChangeListener(this);
+//				for (DomainModel domain : rootModel.getDomains()) {
+//					domain.addPropertyChangeListener(this);
+//				}
+			}
+			
+			super.inputChanged(viewer, oldInput, newInput);
+		}
+		
+		public void propertyChange(PropertyChangeEvent evt) {
+//			if (evt.getPropertyName().equals(RootModel.P_DB_DOMAINS)) {
+//				domainEditArea.refreshTable(); // レコードの変更を反映させる。
+//			} else if (evt.getSource() instanceof DefinitionModel) {
+//				domainEditArea.refreshTable(); // レコードの変更を反映させる。
+//				if (evt.getPropertyName().equals(DefinitionModel.P_CREATE)) {
+//					// nothing to do
+//				} else if (evt.getPropertyName().equals(DefinitionModel.P_DELETE)) {
+//					((DefinitionModel) evt.getSource()).removePropertyChangeListener(this);
+//				} else if (evt.getPropertyName().equals(DefinitionModel.P_REVERT)) {
+//					((DefinitionModel) evt.getSource()).addPropertyChangeListener(this);
+//				}
+//			}
+		}
+		
+	}
+	
+	private class DomainEditTableArea extends AbstractTableViewerEditArea {
+		
+		private RootModel rootModel;
+		
+		private Table table;
+		
+
+		/**
+		 * コンストラクタ。
+		 * 
+		 * @param targetModel
+		 */
+		public DomainEditTableArea(RootModel targetModel) {
+			super();
+			rootModel = targetModel;
+		}
+		
+		@Override
+		protected JiemamyElement addItem() {
+			JiemamyFactory factory = rootModel.getJiemamy().getFactory();
+			DomainModel domainModel = factory.newModel(DomainModel.class);
+			domainModel.setName("DOMAIN_" + (rootModel.getDomains().size() + 1));
+			
+			BuiltinDataType builtinDataType = factory.newModel(BuiltinDataType.class);
+			builtinDataType.setCategory(DataTypeCategory.INTEGER);
+			domainModel.setDataType(builtinDataType);
+			
+			rootModel.getDomains().add(domainModel);
+			
+			int addedIndex = rootModel.getDomains().indexOf(domainModel);
+			table.setSelection(addedIndex);
+			enableEditControls(addedIndex);
+			txtDomainName.setFocus();
+			
+			return domainModel;
+		}
+		
+		@Override
+		protected void configureDetailEditControls() {
+			txtDomainName.addFocusListener(new TextSelectionAdapter(txtDomainName));
+			txtDomainName.addKeyListener(new KeyAdapter() {
+				
+				@Override
+				public void keyReleased(KeyEvent e) {
+					updateModel();
+				}
+			});
+			cmbColumnType.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int domainEditIndex = getTableViewer().getTable().getSelectionIndex();
+					updateModel();
+					enableEditDetailControls(domainEditIndex);
+				}
+			});
+			txtColumnSize.addKeyListener(new KeyAdapter() {
+				
+				@Override
+				public void keyReleased(KeyEvent e) {
+					updateModel();
+				}
+			});
+			txtDefaultValue.addFocusListener(new TextSelectionAdapter(txtDefaultValue));
+			txtDefaultValue.addKeyListener(new KeyAdapter() {
+				
+				@Override
+				public void keyReleased(KeyEvent e) {
+					updateModel();
+				}
+			});
+			txtDescription.addFocusListener(new TextSelectionAdapter(txtDefaultValue));
+			txtDescription.addKeyListener(new KeyAdapter() {
+				
+				@Override
+				public void keyReleased(KeyEvent e) {
+					updateModel();
+				}
+			});
+			chkIsUnique.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int domainEditIndex = getTableViewer().getTable().getSelectionIndex();
+					updateModel();
+					enableEditDetailControls(domainEditIndex);
+				}
+			});
+			chkIsNotNull.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int domainEditIndex = getTableViewer().getTable().getSelectionIndex();
+					updateModel();
+					enableEditDetailControls(domainEditIndex);
+				}
+			});
+		}
+		
+		@Override
+		protected void configureTable() {
+			super.configureTable();
+			table = getTableViewer().getTable();
+			
+			table.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int index = table.getSelectionIndex();
+					if (index >= 0) {
+						enableEditDetailControls(index);
+					} else {
+						disableEditDetailControls();
+					}
+				}
+			});
+			
+			final Menu menu = new Menu(table);
+			table.setMenu(menu);
+			menu.addMenuListener(new MenuAdapter() {
+				
+				@Override
+				public void menuShown(MenuEvent evt) {
+					for (MenuItem item : menu.getItems()) {
+						item.dispose();
+					}
+					int index = table.getSelectionIndex();
+					if (index == -1) {
+						return;
+					}
+					
+					MenuItem removeItem = new MenuItem(menu, SWT.PUSH);
+					removeItem.setText("&Remove"); // TODO 外部化せよ。
+					removeItem.addSelectionListener(new SelectionAdapter() {
+						
+						@Override
+						public void widgetSelected(SelectionEvent evt) {
+							removeTableSelectionItem();
+						}
+					});
+				}
+			});
+		}
+		
+		@Override
+		protected void configureTableViewer() {
+			TableViewer tableViewer = getTableViewer();
+// tableViewer.setCellModifier(new RecordCellModifier(tableViewer));
+			tableViewer.setLabelProvider(new DomainLabelProvider());
+			contentProvider = new DomainContentProvider();
+			tableViewer.setContentProvider(contentProvider);
+// tableViewer.setSorter(new ViewerSorter());
+			tableViewer.setInput(rootModel.getDomains());
+		}
+		
+		@Override
+		protected Composite createEditDetailControls(Composite parent) {
+			GridData gd;
+			Label label;
+			
+			Group group = new Group(parent, SWT.NULL);
+			group.setText("dialog.db.domain.title"); // RESOURCE
+			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));
+			GridLayout layout = new GridLayout(2, false);
+			layout.marginHeight = 0;
+			layout.marginWidth = 0;
+			cmpNames.setLayout(layout);
+			
+			label = new Label(cmpNames, SWT.NULL);
+			label.setText("dialog.db.domain.label.name"); // RESOURCE
+			
+			txtDomainName = new Text(cmpNames, SWT.BORDER);
+			txtDomainName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			
+			Composite cmpTypes = new Composite(group, SWT.NULL);
+			cmpTypes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			layout = new GridLayout(6, false);
+			layout.marginHeight = 0;
+			layout.marginWidth = 0;
+			cmpTypes.setLayout(layout);
+			
+			label = new Label(cmpTypes, SWT.NULL);
+			label.setText("dialog.db.domain.label.type"); // RESOURCE
+			
+			cmbColumnType = new Combo(cmpTypes, SWT.READ_ONLY);
+			cmbColumnType.setVisibleItemCount(20);
+//			for (PrimitiveDataType primitiveType : rootModel.getDialect().getTypeMappings().values()) {
+//				cmbColumnType.add(primitiveType.getName());
+//			}
+			cmbColumnType.add("TODO1"); // TODO
+			cmbColumnType.add("TODO2");
+			
+			label = new Label(cmpTypes, SWT.NULL);
+			label.setText("dialog.db.domain.label.size"); // RESOURCE
+			
+			txtColumnSize = new Text(cmpTypes, SWT.BORDER);
+			gd = new GridData();
+			gd.widthHint = 60;
+			txtColumnSize.setLayoutData(gd);
+			txtColumnSize.addFocusListener(new TextSelectionAdapter(txtColumnSize));
+			
+			label = new Label(cmpTypes, SWT.NULL);
+			label.setText("dialog.db.domain.label.defaultValue"); // RESOURCE
+			
+			txtDefaultValue = new Text(cmpTypes, SWT.BORDER);
+			txtDefaultValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			
+			Composite cmpDesc = new Composite(group, SWT.NULL);
+			cmpDesc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			layout = new GridLayout(2, false);
+			layout.marginHeight = 0;
+			layout.marginWidth = 0;
+			cmpDesc.setLayout(layout);
+			label = new Label(cmpDesc, SWT.NULL);
+			label.setText("dialog.db.domain.label.description"); // RESOURCE
+			txtDescription = new Text(cmpDesc, SWT.MULTI | SWT.BORDER);
+			txtDescription.setLayoutData(new GridData(GridData.FILL_BOTH));
+			
+			Composite cmpChecks = new Composite(group, SWT.NULL);
+			RowLayout rowLayout = new RowLayout();
+			layout.marginHeight = 0;
+			layout.marginWidth = 0;
+			cmpChecks.setLayout(rowLayout);
+			cmpChecks.setLayoutData(new GridData());
+			
+			chkIsUnique = new Button(cmpChecks, SWT.CHECK);
+			chkIsUnique.setText("dialog.db.domain.label.unique"); // RESOURCE
+			
+			chkIsNotNull = new Button(cmpChecks, SWT.CHECK);
+			chkIsNotNull.setText("dialog.db.domain.label.notNull"); // RESOURCE
+			
+//			if (!rootModel.getDialect().getColumnOptions().isEmpty()) {
+//				createColumnOptionControls(cmpChecks);
+//			}
+			
+			return group;
+		}
+		
+		@Override
+		protected void createTableColumns() {
+			
+			TableColumn colName = new TableColumn(table, SWT.LEFT);
+			colName.setText("dialog.db.domain.tbl.header.domainName"); // RESOURCE
+			colName.setWidth(100);
+			
+			TableColumn colType = new TableColumn(table, SWT.LEFT);
+			colType.setText("dialog.db.domain.tbl.header.type"); // RESOURCE
+			colType.setWidth(150);
+			
+			TableColumn colDefaultValue = new TableColumn(table, SWT.LEFT);
+			colDefaultValue.setText("dialog.db.domain.tbl.header.defaultValue"); // RESOURCE
+			colDefaultValue.setWidth(100);
+			
+			TableColumn colNotNull = new TableColumn(table, SWT.LEFT);
+			colNotNull.setText("dialog.db.domain.tbl.header.notNull"); // RESOURCE
+			colNotNull.setWidth(50);
+			
+			TableColumn colUnique = new TableColumn(table, SWT.LEFT);
+			colUnique.setText("dialog.db.domain.tbl.header.unique"); // RESOURCE
+			colUnique.setWidth(50);
+		}
+		
+		@Override
+		protected void disableEditDetailControls() {
+			txtDomainName.setText("");
+			
+			cmbColumnType.setText("");
+			txtColumnSize.setText("");
+			txtDefaultValue.setText("");
+			txtDescription.setText("");
+			chkIsNotNull.setSelection(false);
+			chkIsUnique.setSelection(false);
+			
+			txtDomainName.setEnabled(false);
+			cmbColumnType.setEnabled(false);
+			txtColumnSize.setEnabled(false);
+			txtDefaultValue.setEnabled(false);
+			txtDescription.setEnabled(false);
+			chkIsNotNull.setEnabled(false);
+			chkIsUnique.setEnabled(false);
+			
+//			for (Map.Entry<DialectOption, DialectOptionUI> entry : domainOptionUIs.entrySet()) {
+//				entry.getValue().setEnabled(false);
+//				entry.getValue().setModel(null);
+//			}
+		}
+		
+		@Override
+		protected void enableEditDetailControls(int index) {
+			DomainModel domain = rootModel.getDomains().get(index);
+			DataType columnType = domain.getDataType();
+			
+			txtDomainName.setText(domain.getName());
+//			cmbColumnType.setText(rootModel.getDialect().convertToPrimitiveType(columnType).getIdentifier());
+			txtColumnSize
+				.setText(String.valueOf(domain.getDataType().getAdapter(SizedDataTypeAdapter.class).getSize()));
+			txtDefaultValue.setText(domain.getDefaultValue());
+			txtDescription.setText(domain.getDescription());
+			chkIsNotNull.setSelection(DomainUtil.hasConstraint(domain, NotNullConstraintModel.class));
+			chkIsUnique.setSelection(DomainUtil.hasConstraint(domain, UniqueKeyModel.class));
+			
+			txtDomainName.setEnabled(true);
+			cmbColumnType.setEnabled(true);
+			txtColumnSize.setEnabled(true);
+			txtDefaultValue.setEnabled(true);
+			txtDescription.setEnabled(true);
+			chkIsNotNull.setEnabled(true);
+			chkIsUnique.setEnabled(true);
+			
+//			if (domainOptions != null) {
+//				for (DialectOption columnOption : domainOptions) {
+//					DialectOptionUI ui = domainOptionUIs.get(columnOption);
+//					if (index > -1) {
+//						ui.setModel(rootModel.getDomain(index));
+//					}
+//					ui.setEnabled(true);
+//				}
+//			}
+		}
+		
+		@Override
+		protected JiemamyElement insertTableSelectionItem() {
+			int index = table.getSelectionIndex();
+			
+			JiemamyFactory factory = rootModel.getJiemamy().getFactory();
+			DomainModel domainModel = factory.newModel(DomainModel.class);
+			
+			domainModel.setName("DOMAIN_" + (rootModel.getDomains().size() + 1));
+			
+			if (index < 0 || index > table.getItemCount()) {
+				rootModel.getDomains().add(domainModel);
+			} else {
+				rootModel.getDomains().add(index, domainModel);
+			}
+			
+			int addedIndex = rootModel.getDomains().indexOf(domainModel);
+			table.setSelection(addedIndex);
+			enableEditControls(addedIndex);
+			txtDomainName.setFocus();
+			
+			return domainModel;
+		}
+		
+		@Override
+		protected void moveDownTableSelectionItem() {
+			int index = table.getSelectionIndex();
+			if (index < 0 || index >= table.getItemCount()) {
+				return;
+			}
+			
+			ListUtils.moveUp(rootModel.getDomains(), index);
+			
+			table.setSelection(index + 1);
+			enableEditControls(index + 1);
+		}
+		
+		@Override
+		protected void moveUpTableSelectionItem() {
+			int index = table.getSelectionIndex();
+			if (index <= 0 || index > table.getItemCount()) {
+				return;
+			}
+			
+			ListUtils.moveUp(rootModel.getDomains(), index);
+			
+			table.setSelection(index - 1);
+			enableEditControls(index - 1);
+		}
+		
+		@Override
+		protected JiemamyElement removeTableSelectionItem() {
+			int index = table.getSelectionIndex();
+			if (index < 0 || index > table.getItemCount()) {
+				return null;
+			}
+			DomainModel domainToRemove = rootModel.getDomains().remove(table.getSelectionIndex());
+			TableViewer tableViewer = getTableViewer();
+			tableViewer.remove(domainToRemove);
+			
+			disableEditControls();
+			
+			return domainToRemove;
+		}
+		
+		private void createColumnOptionControls(Composite parent) {
+			int domainEditIndex = getTableViewer().getTable().getSelectionIndex();
+//			domainOptions = rootModel.getDialect().getColumnOptions();
+//			if (domainOptions != null) {
+//				for (DialectOption columnOption : domainOptions) {
+//					DialectOptionUI ui = new DialectOptionUI(columnOption);
+//					if (domainEditIndex > -1) {
+//						ui.setModel(rootModel.getDomain(domainEditIndex));
+//					}
+//					ui.createControl(parent);
+//					domainOptionUIs.put(columnOption, ui);
+//				}
+//			}
+		}
+		
+		private void updateModel() {
+			int domainEditIndex = getTableViewer().getTable().getSelectionIndex();
+			int selectionInedx = cmbColumnType.getSelectionIndex();
+			
+			if (domainEditIndex != -1 && selectionInedx != -1) {
+				DomainModel domain = rootModel.getDomains().get(domainEditIndex);
+				domain.setName(txtDomainName.getText());
+				
+//				Dialect dialect = RootModelUtil.getDialect(rootModel);
+//				domain.setDataType(dialect.getDataTypeResolver().resolveDataType(cmbColumnType.getText()));
+//				// THINK ↑ cmbColumnType.getItem(selectionInedx)?
+//				if (dialect.convertToPrimitiveType(domain.getDataType()).getSizeSupportLevel() == DataType.SIZE.NOT_SUPPORTED) {
+//					domain.setSize("");
+//				} else {
+//					domain.setSize(txtColumnSize.getText());
+//				}
+				domain.setDefaultValue(txtDefaultValue.getText());
+				domain.setDescription(txtDescription.getText());
+				
+//				domain.setConstraint(DefinitionModel.CONSTRAINT_UNIQUE, chkIsUnique.getSelection());
+//				domain.setConstraint(DefinitionModel.CONSTRAINT_NOT_NULL, chkIsNotNull.getSelection());
+				
+//				for (Map.Entry<DialectOption, DialectOptionUI> entry : domainOptionUIs.entrySet()) {
+//					entry.getValue().setDataControlToModel();
+//				}
+			}
+		}
+	}
+	
+	/**
+	 * Domain用LabelProvider
+	 * 
+	 * @author daisuke
+	 */
+	private class DomainLabelProvider implements ITableLabelProvider {
+		
+		/**
+		 * Override method.
+		 * 
+		 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(
+		 *      org.eclipse.jface.viewers.ILabelProviderListener)
+		 */
+		public void addListener(ILabelProviderListener listener) {
+			// nothing to do
+		}
+		
+		public void dispose() {
+			// nothing to do
+		}
+		
+		public Image getColumnImage(Object element, int columnIndex) {
+			ImageRegistry ir = JiemamyPlugin.getDefault().getImageRegistry();
+			DomainModel domain = (DomainModel) element;
+			
+			switch (columnIndex) {
+				case 3:
+					return DomainUtil.hasConstraint(domain, NotNullConstraintModel.class) ? ir.get(Images.CHECK_ON)
+							: ir.get(Images.CHECK_OFF);
+					
+				case 4:
+					// THINK Domainにuniqueはあるか?
+					
+				default:
+					return null;
+			}
+		}
+		
+		public String getColumnText(Object element, int columnIndex) {
+			DomainModel domain = (DomainModel) element;
+			switch (columnIndex) {
+				case 0:
+					return LabelStringUtil.getString(rootModel, domain, DisplayTarget.NAME, DisplayPlace.FIGURE);
+				case 1:
+					return LabelStringUtil.getString(rootModel, domain, DisplayTarget.TYPE, DisplayPlace.FIGURE);
+				case 2:
+					return domain.getDefaultValue();
+					
+				default:
+					return "";
+			}
+		}
+		
+		public boolean isLabelProperty(Object element, String property) {
+			return false;
+		}
+		
+		public void removeListener(ILabelProviderListener listener) {
+			// nothing to do
+		}
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/DatabaseEditDialogDomainTab.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java	2009-02-15 17:03:03 UTC (rev 2673)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -28,6 +28,7 @@
 import org.eclipse.gef.EditPolicy;
 import org.eclipse.gef.LayerConstants;
 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.slf4j.Logger;
@@ -35,6 +36,7 @@
 
 import org.jiemamy.Migration;
 import org.jiemamy.eclipse.JiemamyPlugin;
+import org.jiemamy.eclipse.editor.dialog.root.DatabaseEditDialog;
 import org.jiemamy.eclipse.editor.editpart.EditDialogSupport;
 import org.jiemamy.eclipse.editor.editpolicy.JmXYLayoutEditPolicy;
 import org.jiemamy.eclipse.preference.JiemamyPreference;
@@ -127,22 +129,22 @@
 		logger.debug("openEditDialog");
 		RootModel rootModel = getModel();
 		
-//		DatabaseEditDialog dialog = new DatabaseEditDialog(getViewer().getControl().getShell(), rootModel);
+		DatabaseEditDialog dialog = new DatabaseEditDialog(getViewer().getControl().getShell(), rootModel);
 //		
 //		// 編集前のスナップショットを保存
 //		Memento beforeEditMemento = dialog.createMemento();
 //		
-//		if (dialog.open() == Dialog.OK) {
+		if (dialog.open() == Dialog.OK) {
 //			// 編集後のスナップショットを保存
 //			Memento afterEditMemento = dialog.createMemento();
 //			
 //			GraphicalViewer viewer = (GraphicalViewer) getViewer();
 //			viewer.getEditDomain().getCommandStack().execute(
 //					new EditDatabaseModelCommand(rootModel, beforeEditMemento, afterEditMemento));
-//		} else {
+		} else {
 //			// 編集前にロールバック
 //			dialog.setMemento(beforeEditMemento);
-//		}
+		}
 	}
 	
 	/**

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/AbstractTableViewerEditArea.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/AbstractTableViewerEditArea.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/AbstractTableViewerEditArea.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,404 @@
+package org.jiemamy.eclipse.ui;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+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.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * 「テーブル」「追加・削除・上・下ボタン」「詳細」形式の編集エリアクラス。
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractTableViewerEditArea implements ControlArea<Composite> {
+	
+	private TableViewer tableViewer;
+	
+	/** 追加ボタンに表示するラベルテキスト */
+	private String addLabel = null;
+	
+	/** 挿入ボタンに表示するラベルテキスト */
+	private String insertLabel = null;
+	
+	/** 削除ボタンに表示するラベルテキスト */
+	private String removeLabel = null;
+	
+	/** 追加ボタン */
+	private Button btnAdd;
+	
+	/** 挿入ボタン */
+	private Button btnInsert;
+	
+	/** 削除ボタン */
+	private Button btnRemove;
+	
+	/** 上ボタン */
+	private Button btnMoveUp;
+	
+	/** 下ボタン */
+	private Button btnMoveDown;
+	
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Composite createControlArea(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NULL);
+		composite.setLayout(new GridLayout(1, false));
+		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		createTableViewer(composite);
+		createEditControls(composite);
+		
+		return composite;
+	}
+	
+	/**
+	 * 編集コントロールを無効にする。
+	 */
+	public void disableEditControls() {
+		disableEditButtons();
+		disableEditDetailControls();
+	}
+	
+	/**
+	 * 編集コントロールを有効にする。
+	 * 
+	 * @param index 選択されたindex
+	 */
+	public void enableEditControls(int index) {
+		enableEditButtons(index);
+		enableEditDetailControls(index);
+	}
+	
+	/**
+	 * tableViewerを取得する。
+	 * 
+	 * @return tableViewer
+	 */
+	public TableViewer getTableViewer() {
+		return tableViewer;
+	}
+	
+	/**
+	 * Tableをリフレッシュする。
+	 */
+	public void refreshTable() {
+		tableViewer.refresh();
+	}
+	
+	/**
+	 * カラムをリフレッシュする。
+	 */
+	public void refreshTableColumns() {
+		removeTableColumns();
+		createTableColumns();
+		refreshTable();
+	}
+	
+	/**
+	 * 追加ボタンに表示するラベルテキストを設定する。
+	 * 
+	 * @param addLabel 追加ボタンに表示するラベルテキスト
+	 */
+	public void setAddLabel(String addLabel) {
+		this.addLabel = addLabel;
+	}
+	
+	/**
+	 * 挿入ボタンに表示するラベルテキストを設定する。
+	 * 
+	 * @param insertLabel 挿入ボタンに表示するラベルテキスト
+	 */
+	public void setInsertLabel(String insertLabel) {
+		this.insertLabel = insertLabel;
+	}
+	
+	/**
+	 * 削除ボタンに表示するラベルテキストを設定する。
+	 * 
+	 * @param removeLabel 削除ボタンに表示するラベルテキスト
+	 */
+	public void setRemoveLabel(String removeLabel) {
+		this.removeLabel = removeLabel;
+	}
+	
+	/**
+	 * 追加ボタンが押された時の処理を行う。
+	 * 
+	 * @return 追加されたモデル
+	 */
+	protected abstract Object addItem();
+	
+	/**
+	 * CellEditorの設定を行う。
+	 */
+	protected void configureCellEditor() {
+		// nothing to do
+	}
+	
+	/**
+	 * 詳細編集コントロールの設定を行う。
+	 */
+	protected void configureDetailEditControls() {
+		// nothing to do
+	}
+	
+	/**
+	 * 編集ボタンの設定を行う。
+	 */
+	protected void configureEditButtons() {
+		if (addLabel != null) {
+			btnAdd.setText(addLabel);
+			btnAdd.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					addItem();
+				}
+			});
+		}
+		
+		if (insertLabel != null) {
+			btnInsert.setText(insertLabel);
+			btnInsert.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					insertTableSelectionItem();
+				}
+			});
+		}
+		
+		if (removeLabel != null) {
+			btnRemove.setText(removeLabel);
+			btnRemove.addSelectionListener(new SelectionAdapter() {
+				
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					removeTableSelectionItem();
+				}
+			});
+		}
+		
+		btnMoveUp.addSelectionListener(new SelectionAdapter() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				moveUpTableSelectionItem();
+			}
+		});
+		
+		btnMoveDown.addSelectionListener(new SelectionAdapter() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				moveDownTableSelectionItem();
+			}
+		});
+	}
+	
+	/**
+	 * Tableの設定を行う。
+	 */
+	protected void configureTable() {
+		final Table table = tableViewer.getTable();
+		table.setLayoutData(new GridData(GridData.FILL_BOTH));
+		table.setHeaderVisible(true);
+		table.setLinesVisible(true);
+		table.addSelectionListener(new SelectionAdapter() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int index = table.getSelectionIndex();
+				if (index >= 0) {
+					enableEditControls(index);
+				} else {
+					disableEditControls();
+				}
+			}
+		});
+	}
+	
+	/**
+	 * TableViewerの設定を行う。
+	 */
+	protected abstract void configureTableViewer();
+	
+	/**
+	 * 編集ボタンを生成する。
+	 * 
+	 * @param parent 親
+	 * @return 生成した編集ボタン
+	 */
+	protected Composite createEditButtons(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NULL);
+		composite.setLayout(new RowLayout());
+		composite.setLayoutData(new GridData());
+		
+		if (addLabel != null) {
+			btnAdd = new Button(composite, SWT.PUSH);
+		}
+		if (insertLabel != null) {
+			btnInsert = new Button(composite, SWT.PUSH);
+		}
+		if (removeLabel != null) {
+			btnRemove = new Button(composite, SWT.PUSH);
+		}
+		
+		createOptionalEditButtons(composite);
+		
+		btnMoveUp = new Button(composite, SWT.ARROW | SWT.UP);
+		btnMoveDown = new Button(composite, SWT.ARROW | SWT.DOWN);
+		
+		return composite;
+	}
+	
+	/**
+	 * 編集コントロールを生成する。
+	 * 
+	 * @param parent 親
+	 */
+	protected void createEditControls(Composite parent) {
+		createEditButtons(parent);
+		configureEditButtons();
+		createEditDetailControls(parent);
+		configureDetailEditControls();
+	}
+	
+	/**
+	 * 詳細編集コントロールを生成する。
+	 * 
+	 * @param parent 親
+	 * @return 生成したコントロール
+	 */
+	protected Composite createEditDetailControls(Composite parent) {
+		// nothing to do
+		return null;
+	}
+	
+	/**
+	 * 編集ボタン領域にオプションのコントロールを生成する。 デフォルトでは何も行わない。必要であればオーバーライドする。
+	 * 
+	 * @param parent
+	 */
+	protected void createOptionalEditButtons(Composite parent) {
+		// noting to do
+	}
+	
+	/**
+	 * TableのColumnを生成する。
+	 */
+	protected abstract void createTableColumns();
+	
+	/**
+	 * 編集ボタンを無効にする。 編集ボタン領域にオプションのコントロールについては関知しない。
+	 */
+	protected void disableEditButtons() {
+		if (insertLabel != null) {
+			btnInsert.setEnabled(false);
+		}
+		if (removeLabel != null) {
+			btnRemove.setEnabled(false);
+		}
+		btnMoveUp.setEnabled(false);
+		btnMoveDown.setEnabled(false);
+	}
+	
+	/**
+	 * 詳細編集コントロールを無効化する。
+	 */
+	protected void disableEditDetailControls() {
+		// nothing to do
+	}
+	
+	/**
+	 * 編集ボタンを有効にする。 編集ボタン領域にオプションのコントロールについては関知しない。
+	 * 
+	 * @param index 選択されたindex
+	 */
+	protected void enableEditButtons(int index) {
+		if (insertLabel != null) {
+			btnInsert.setEnabled(true);
+		}
+		if (removeLabel != null) {
+			btnRemove.setEnabled(true);
+		}
+		btnMoveUp.setEnabled(true);
+		btnMoveDown.setEnabled(true);
+		
+		// 選択が一番上だった場合
+		if (index <= 0) {
+			btnMoveUp.setEnabled(false);
+		}
+		// 選択が一番下だった場合
+		if (index >= tableViewer.getTable().getItemCount() - 1) {
+			btnMoveDown.setEnabled(false);
+		}
+	}
+	
+	/**
+	 * 詳細編集コントロールを有効化する。
+	 * 
+	 * @param index
+	 */
+	protected void enableEditDetailControls(int index) {
+		// nothing to do
+	}
+	
+	/**
+	 * 挿入ボタンが押された時の処理を行う。
+	 * 
+	 * @return 追加されたモデル
+	 */
+	protected abstract Object insertTableSelectionItem();
+	
+	/**
+	 * 下ボタンが押された時の処理を行う。
+	 */
+	protected abstract void moveDownTableSelectionItem();
+	
+	/**
+	 * 上ボタンが押された時の処理を行う。
+	 */
+	protected abstract void moveUpTableSelectionItem();
+	
+	/**
+	 * 削除ボタンが押された時の処理を行う。
+	 * 
+	 * @return 削除されたモデル
+	 */
+	protected abstract Object removeTableSelectionItem();
+	
+	/**
+	 * TableViewerを生成し、各種設定を行う。
+	 * 
+	 * @param parent
+	 */
+	private void createTableViewer(Composite parent) {
+		tableViewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
+		
+		configureTable();
+		createTableColumns();
+		configureTableViewer();
+		configureCellEditor();
+		refreshTable();
+	}
+	
+	/**
+	 * TableからColumnを全て削除する。
+	 */
+	private void removeTableColumns() {
+		Table table = tableViewer.getTable();
+		for (TableColumn col : table.getColumns()) {
+			col.dispose();
+		}
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/AbstractTableViewerEditArea.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/ControlArea.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/ControlArea.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/ControlArea.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,22 @@
+package org.jiemamy.eclipse.ui;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * ダイアログ用コントロールエリアインターフェイス。
+ * 
+ * @param <T> 
+ * @author daisuke
+ */
+public interface ControlArea<T extends Composite> {
+	
+	/**
+	 * コントロールエリアを生成します。
+	 * 
+	 * @param parent 親
+	 * @return 生成されたコントロールエリア
+	 */
+	Control createControlArea(T parent);
+	
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/ControlArea.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/TextSelectionAdapter.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/TextSelectionAdapter.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/TextSelectionAdapter.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,33 @@
+package org.jiemamy.eclipse.ui.helper;
+
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Textフォーカス時にテキストを選択状態にするアダプタ。
+ * 
+ * @author daisuke
+ */
+public class TextSelectionAdapter implements FocusListener {
+	
+	private Text text;
+	
+
+	/**
+	 * コンストラクタ。
+	 * 
+	 * @param target
+	 */
+	public TextSelectionAdapter(Text target) {
+		text = target;
+	}
+	
+	public void focusGained(FocusEvent e) {
+		text.selectAll();
+	}
+	
+	public void focusLost(FocusEvent e) {
+		// nothing to do
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/helper/TextSelectionAdapter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,14 @@
+package org.jiemamy.eclipse.ui.tab;
+
+import org.eclipse.swt.widgets.TabFolder;
+
+import org.jiemamy.eclipse.ui.ControlArea;
+
+/**
+ * タブエリアの抽象クラス
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractTab implements ControlArea<TabFolder> {
+	
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java	2009-02-15 18:57:32 UTC (rev 2674)
@@ -0,0 +1,46 @@
+package org.jiemamy.eclipse.ui.tab;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * テキスト編集タブ。
+ * 
+ * @author daisuke
+ */
+public class TextEditTab extends AbstractTab {
+	
+	/** 編集するテキスト */
+	private String strText;
+	
+	/** タブのタイトル */
+	private String tabTitle;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param text 編集するテキスト
+	 * @param tabTitle タブのタイトル
+	 */
+	public TextEditTab(String text, String tabTitle) {
+		strText = text;
+		this.tabTitle = tabTitle;
+	}
+	
+	public Control createControlArea(TabFolder parentTabFolder) {
+		Text text = new Text(parentTabFolder, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+		
+		TabItem tabBeginScript = new TabItem(parentTabFolder, SWT.NONE);
+		tabBeginScript.setText(tabTitle);
+		tabBeginScript.setControl(text);
+		
+		text.setLayoutData(new GridData(GridData.FILL_BOTH));
+		text.setText(strText);
+		return text;
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/.classpath
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/.classpath	2009-02-15 17:03:03 UTC (rev 2673)
+++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/.classpath	2009-02-15 18:57:32 UTC (rev 2674)
@@ -4,6 +4,23 @@
 	<classpathentry kind="src" path="src/main/resources"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry exported="true" kind="lib" path="lib/collections-generic-4.01.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.8.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/commons-io-1.3.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/commons-lang-2.3.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/eclipse-common-0.0.4.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/factory-enhancer-0.1.0-SNAPSHOT.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/generic-tree-0.1.0-SNAPSHOT.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/javassist-3.8.0.GA.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/jcl-over-slf4j-1.5.5.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/jiemamy-core-0.2.0-SNAPSHOT.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/jiemamy-spec-core-0.2.0-SNAPSHOT.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/logback-classic-0.9.9.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/logback-core-0.9.9.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.5.5.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/stax-1.2.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/stax-api-1.0.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="con" path="org.devzuz.q.maven.jdt.core.mavenClasspathContainer"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>

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-15 17:03:03 UTC (rev 2673)
+++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/META-INF/MANIFEST.MF	2009-02-15 18:57:32 UTC (rev 2674)
@@ -4,7 +4,24 @@
 Bundle-SymbolicName: org.jiemamy.eclipse.dialect.mysql;singleton:=true
 Bundle-Version: 0.2.0.SNAPSHOT
 Bundle-ClassPath: .,
- lib/jiemamy-dialect-mysql-0.2.0-SNAPSHOT.jar
+ lib/jiemamy-dialect-mysql-0.2.0-SNAPSHOT.jar,
+ lib/collections-generic-4.01.jar,
+ lib/commons-beanutils-1.8.0.jar,
+ lib/commons-io-1.3.2.jar,
+ lib/commons-lang-2.3.jar,
+ lib/eclipse-common-0.0.4.jar,
+ lib/factory-enhancer-0.1.0-SNAPSHOT.jar,
+ lib/generic-tree-0.1.0-SNAPSHOT.jar,
+ lib/javassist-3.8.0.GA.jar,
+ lib/jcl-over-slf4j-1.5.5.jar,
+ lib/jiemamy-core-0.2.0-SNAPSHOT.jar,
+ lib/jiemamy-spec-core-0.2.0-SNAPSHOT.jar,
+ lib/logback-classic-0.9.9.jar,
+ lib/logback-core-0.9.9.jar,
+ lib/slf4j-api-1.5.5.jar,
+ lib/stax-1.2.0.jar,
+ lib/stax-api-1.0.1.jar,
+ lib/wstx-asl-3.2.7.jar
 Bundle-Vendor: Jiemamy Project
 Require-Bundle: org.jiemamy.eclipse
 Eclipse-BuddyPolicy: registered

Modified: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/build.properties
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/build.properties	2009-02-15 17:03:03 UTC (rev 2673)
+++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/build.properties	2009-02-15 18:57:32 UTC (rev 2674)
@@ -5,7 +5,24 @@
                plugin.properties,\
                plugin_ja.properties,\
                LICENSE.txt,\
-               lib/jiemamy-dialect-mysql-0.2.0-SNAPSHOT.jar
+               lib/jiemamy-dialect-mysql-0.2.0-SNAPSHOT.jar,\
+               lib/collections-generic-4.01.jar,\
+               lib/commons-beanutils-1.8.0.jar,\
+               lib/commons-io-1.3.2.jar,\
+               lib/commons-lang-2.3.jar,\
+               lib/eclipse-common-0.0.4.jar,\
+               lib/factory-enhancer-0.1.0-SNAPSHOT.jar,\
+               lib/generic-tree-0.1.0-SNAPSHOT.jar,\
+               lib/javassist-3.8.0.GA.jar,\
+               lib/jcl-over-slf4j-1.5.5.jar,\
+               lib/jiemamy-core-0.2.0-SNAPSHOT.jar,\
+               lib/jiemamy-spec-core-0.2.0-SNAPSHOT.jar,\
+               lib/logback-classic-0.9.9.jar,\
+               lib/logback-core-0.9.9.jar,\
+               lib/slf4j-api-1.5.5.jar,\
+               lib/stax-1.2.0.jar,\
+               lib/stax-api-1.0.1.jar,\
+               lib/wstx-asl-3.2.7.jar
 output..=target/classes/
 source..=src/main/java/,src/main/resources/,src/test/java/,src/test/resources/
 bin.excludes=lib/sources/



Jiemamy-notify メーリングリストの案内
Back to archive index