svnno****@sourc*****
svnno****@sourc*****
2009年 2月 12日 (木) 22:25:47 JST
Revision: 2656 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2656 Author: daisuke_m Date: 2009-02-12 22:25:47 +0900 (Thu, 12 Feb 2009) Log Message: ----------- 現状にあわせて、vesta側をいっぱい修正。 Modified Paths: -------------- vesta/trunk/org.jiemamy.eclipse/plugin.xml 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/DiagramEditorPaletteFactory.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/ModelContainer.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/MovePositionCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractNodeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRootEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 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/StickyEditPart.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/editor/editpart/diagram/ViewEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractModelTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RootTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TableTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmTreeComponentEditPolicy.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java Added Paths: ----------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java Removed Paths: ------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractRelationTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TypeDefTreeEditPart.java -------------- next part -------------- Modified: vesta/trunk/org.jiemamy.eclipse/plugin.xml =================================================================== --- vesta/trunk/org.jiemamy.eclipse/plugin.xml 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/plugin.xml 2009-02-12 13:25:47 UTC (rev 2656) @@ -39,22 +39,22 @@ <extension point="org.eclipse.ui.editors"> - <editor + <!--<editor class="org.jiemamy.eclipse.editor.MultiDiagramEditor" contributorClass="org.jiemamy.eclipse.editor.JmContributor" default="true" extensions="jer" icon="/icons/database.gif" id="org.jiemamy.eclipse.editor.multi.diagram" - name="%plugin.erd.editor"/> - <!--<editor + name="%plugin.erd.editor"/>--> + <editor class="org.jiemamy.eclipse.editor.DiagramEditor" contributorClass="org.jiemamy.eclipse.editor.JmContributor" default="true" extensions="jer" icon="/icons/database.gif" id="org.jiemamy.eclipse.editor.diagram" - name="%plugin.erd.editor"/>--> + name="%plugin.erd.editor"/> </extension> <!-- 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-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -18,6 +18,8 @@ */ package org.jiemamy.eclipse.editor; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.lang.reflect.InvocationTargetException; @@ -25,6 +27,7 @@ import java.util.EventObject; import java.util.List; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang.SerializationException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResourceChangeEvent; @@ -101,7 +104,7 @@ * ERダイアグラムエディタ。 * @author daisuke */ -public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener { +public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener, JiemamyEditor { /** Palette component, holding the tools and shapes. */ private static PaletteRoot paletteModel; @@ -178,21 +181,23 @@ */ @Override public void doSave(IProgressMonitor monitor) { + ByteArrayOutputStream out = null; + ByteArrayInputStream in = null; try { - PipedInputStream in = new PipedInputStream(); - PipedOutputStream out = new PipedOutputStream(in); + out = new ByteArrayOutputStream(); IFile file = ((IFileEditorInput) getEditorInput()).getFile(); serializer.serialize(rootModel, out); - out.close(); + in = new ByteArrayInputStream(out.toByteArray()); file.setContents(in, true, true, monitor); getCommandStack().markSaveLocation(); - - in.close(); } catch (Exception e) { ExceptionHandler.handleException(e); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -201,7 +201,8 @@ * {@inheritDoc} */ public Object getNewObject() { - RootModel rootModel = ((MultiDiagramEditor) EditorUtil.getActiveEditor()).getRootModel(); + JiemamyEditor activeEditor = (JiemamyEditor) EditorUtil.getActiveEditor(); + RootModel rootModel = activeEditor.getRootModel(); return rootModel.getJiemamy().getFactory().newModel(type); } Added: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -0,0 +1,35 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/12 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.eclipse.editor; + +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public interface JiemamyEditor { + + /** + * {@link RootModel}を取得する。 + * @return エディタのルートモデル + */ + RootModel getRootModel(); +} Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -159,8 +159,8 @@ int index = combo.getSelectionIndex(); if (index != -1) { IEditorPart editor = EditorUtil.getActiveEditor(); - if (editor instanceof DiagramEditor) { - RootModel rootModel = ((DiagramEditor) editor).getRootModel(); + if (editor instanceof JiemamyEditor) { + RootModel rootModel = ((JiemamyEditor) editor).getRootModel(); DiagramPresentations presentations = rootModel.getAdapter(DiagramPresentations.class); // FIXME display mode設定 // rootModel.setDisplayMode(modeNumber.get(index)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/ModelContainer.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/ModelContainer.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/ModelContainer.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -19,7 +19,10 @@ package org.jiemamy.eclipse.editor; import java.util.List; +import java.util.UUID; +import org.jiemamy.Jiemamy; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.utils.Adaptable; import org.jiemamy.utils.CollectionsUtil; @@ -29,7 +32,7 @@ * @author daisuke */ @SuppressWarnings("serial") -public class ModelContainer implements Adaptable { +public class ModelContainer implements JiemamyElement, Adaptable { /** コンテナ名 */ private String name; @@ -75,6 +78,20 @@ } /** + * {@inheritDoc} + */ + public UUID getId() { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public Jiemamy getJiemamy() { + throw new UnsupportedOperationException(); + } + + /** * コンテナ名を取得する。 * @return コンテナ名 */ Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -56,7 +56,7 @@ * マルチページ構成のダイアグラムエディタクラス。 * @author daisuke */ -public class MultiDiagramEditor extends MultiPageEditorPart implements IResourceChangeListener { +public class MultiDiagramEditor extends MultiPageEditorPart implements IResourceChangeListener, JiemamyEditor { private static Logger logger = LoggerFactory.getLogger(MultiDiagramEditor.class); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -18,14 +18,20 @@ */ package org.jiemamy.eclipse.editor.command; +import java.util.Map; + import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.commands.Command; +import org.jiemamy.JiemamyFactory; import org.jiemamy.Migration; import org.jiemamy.eclipse.utils.ConvertUtil; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.NodeProfile; import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.node.NodeAdapter; /** @@ -35,20 +41,20 @@ private RootModel rootModel; - private NodeAdapter nodeAdapter; + private JiemamyElement model; private Rectangle rectangle; /** * インスタンスを生成する。 - * @param rootModel 作成エンティティの親モデル - * @param nodeAdapter 作成するエンティティ + * @param rootModel 作成ノードの親モデル + * @param model 作成するノード * @param rectangle */ - public CreateNodeCommand(RootModel rootModel, NodeAdapter nodeAdapter, Rectangle rectangle) { + public CreateNodeCommand(RootModel rootModel, JiemamyElement model, Rectangle rectangle) { this.rootModel = rootModel; - this.nodeAdapter = nodeAdapter; + this.model = model; this.rectangle = rectangle; } @@ -57,11 +63,21 @@ */ @Override public void execute() { + NodeAdapter nodeAdapter; DiagramPresentationModel diagramPresentationModel = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - if (nodeAdapter.unwrap() != null) { - rootModel.getEntities().add(nodeAdapter.unwrap()); + if (model instanceof EntityModel) { + rootModel.getEntities().add((EntityModel) model); + nodeAdapter = model.getAdapter(NodeAdapter.class); + } else { + nodeAdapter = (NodeAdapter) model; } + Map<NodeAdapter, NodeProfile> figureProfiles = diagramPresentationModel.getFigureProfiles(); + if (figureProfiles.containsKey(nodeAdapter) == false) { + JiemamyFactory factory = model.getJiemamy().getFactory(); + NodeProfile profile = factory.newModel(NodeProfile.class); + figureProfiles.put(nodeAdapter, profile); + } diagramPresentationModel.getFigureProfiles().get(nodeAdapter).setLayout(ConvertUtil.convert(rectangle)); } @@ -72,9 +88,9 @@ public void undo() { DiagramPresentationModel diagramPresentationModel = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - if (nodeAdapter.unwrap() != null) { - rootModel.getEntities().remove(nodeAdapter.unwrap()); + if (model instanceof EntityModel) { + rootModel.getEntities().remove(model); } - diagramPresentationModel.getFigureProfiles().get(nodeAdapter).setLayout(ConvertUtil.convert(rectangle)); + diagramPresentationModel.getFigureProfiles().get(model).setLayout(ConvertUtil.convert(rectangle)); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/MovePositionCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/MovePositionCommand.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/MovePositionCommand.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -24,7 +24,7 @@ import org.eclipse.gef.commands.Command; import org.jiemamy.Migration; -import org.jiemamy.eclipse.editor.MultiDiagramEditor; +import org.jiemamy.eclipse.editor.JiemamyEditor; import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; @@ -64,7 +64,7 @@ * @param negative 正方向に移動させる場合{@code true}、負方向の場合{@code false} */ protected void shiftPosition(boolean negative) { - MultiDiagramEditor editor = (MultiDiagramEditor) EditorUtil.getActiveEditor(); + JiemamyEditor editor = (JiemamyEditor) EditorUtil.getActiveEditor(); RootModel rootModel = editor.getRootModel(); DiagramPresentationModel diagramPresentationModel = Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -30,8 +30,11 @@ import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.connection.ConnectionAdapter; +import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.model.node.StickyModel; /** @@ -49,14 +52,26 @@ if (model instanceof RootModel) { part = new RootEditPart(); - } else if (model instanceof TableModel) { - part = new TableEditPart(); - } else if (model instanceof ViewModel) { - part = new ViewEditPart(); - } else if (model instanceof StickyModel) { - part = new StickyEditPart(); - } else if (model instanceof ForeignKeyModel) { - part = new ForeignKeyEditPart(); + } else if (model instanceof NodeAdapter) { + NodeAdapter nodeAdapter = (NodeAdapter) model; + EntityModel entityModel = nodeAdapter.unwrap(); + if (entityModel instanceof TableModel) { + part = new TableEditPart(); + } else if (entityModel instanceof ViewModel) { + part = new ViewEditPart(); + } else if (nodeAdapter instanceof StickyModel) { + part = new StickyEditPart(); + } else { + throw new UnexpectedConditionError("unknown node: " + model.getClass().getName()); + } + } else if (model instanceof ConnectionAdapter) { + ConnectionAdapter connectionAdapter = (ConnectionAdapter) model; + ForeignKeyModel foreignKeyModel = connectionAdapter.unwrap(); + if (foreignKeyModel != null) { + part = new ForeignKeyEditPart(); + } else { + throw new UnexpectedConditionError("unknown connection: " + model.getClass().getName()); + } } if (part == null) { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -22,16 +22,14 @@ import org.eclipse.gef.EditPartFactory; import org.jiemamy.eclipse.editor.ModelContainer; +import org.jiemamy.eclipse.editor.editpart.outlinetree.AttributeTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.ModelContainerEditPart; -import org.jiemamy.eclipse.editor.editpart.outlinetree.RelationTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.RootTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.TableTreeEditPart; -import org.jiemamy.eclipse.editor.editpart.outlinetree.TypeDefTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.ViewTreeEditPart; import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.connection.ConnectionAdapter; +import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; @@ -50,18 +48,16 @@ if (model instanceof RootModel) { part = new RootTreeEditPart(); + } else if (model instanceof ModelContainer) { + part = new ModelContainerEditPart(); + } else if (model instanceof DomainModel) { + part = new AttributeTreeEditPart(); } else if (model instanceof TableModel) { part = new TableTreeEditPart(); - } else if (model instanceof ColumnModel) { - part = new TypeDefTreeEditPart(); - } else if (model instanceof DomainModel) { - part = new TypeDefTreeEditPart(); + } else if (model instanceof AttributeModel) { + part = new AttributeTreeEditPart(); } else if (model instanceof ViewModel) { part = new ViewTreeEditPart(); - } else if (model instanceof ConnectionAdapter) { - part = new RelationTreeEditPart(); - } else if (model instanceof ModelContainer) { - part = new ModelContainerEditPart(); } if (part == null) { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -20,7 +20,9 @@ import org.eclipse.gef.tools.DirectEditManager; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.node.NodeAdapter; /** * {@link EntityModel}に対するDiagram用EditPart(コントローラ)の抽象クラス。 @@ -31,50 +33,16 @@ /** * {@inheritDoc} */ - @Override - public void activate() { - super.activate(); - EntityModel entityModel = (EntityModel) getModel(); -// entityModel.getAdapter(ModelChangeSupport.class).addModelChangeListener(this); + public JiemamyElement getTargetModel() { + NodeAdapter node = (NodeAdapter) getModel(); + EntityModel entity = node.unwrap(); + return entity; } /** * {@inheritDoc} */ @Override - public void deactivate() { - EntityModel entityModel = (EntityModel) getModel(); -// entityModel.getAdapter(ModelChangeSupport.class).removeModelChangeListener(this); - super.deactivate(); - } - - /** - // * {@inheritDoc} - // */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(AbstractEntityModel.P_CREATE)) { -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getParent().getModel()); -// } else if (evt.getField().equals(AbstractEntityModel.P_DELETE)) { -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getParent().getModel()); -// } else if (evt.getField().equals(AbstractEntityModel.P_REVERT)) { -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getParent().getModel()); -// } else if (evt.getField().equals(AbstractEntityModel.P_NODE_ENTITY_NAME)) { -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getParent().getModel()); -// } -// } else { -// if (evt.getField().equals(DatabaseModel.P_DB_DISPLAY_MODE)) { -// refreshVisuals(); -// } -// } -// } - /** - * {@inheritDoc} - */ - @Override protected DirectEditManager getDirectEditManager() { // EntityFigure figure = (EntityFigure) getFigure(); // CellEditorLocator locator = new NodeCellEditorLocator(figure.getEntityNameLabel()); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractNodeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractNodeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractNodeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -42,6 +42,8 @@ import org.jiemamy.eclipse.editor.editpolicy.JmDirectEditPolicy; import org.jiemamy.eclipse.editor.editpolicy.JmGraphicalNodeEditPolicy; import org.jiemamy.eclipse.utils.EditorUtil; +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; import org.jiemamy.model.RootModel; import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.model.node.NodeAdapter; @@ -51,7 +53,7 @@ * @author daisuke */ public abstract class AbstractNodeEditPart extends AbstractGraphicalEditPart implements EditDialogSupport, - DoubleClickSupport, NodeEditPart /*, ModelChangeListener */{ + DoubleClickSupport, NodeEditPart, CommandListener { private DirectEditManager directManager = null; @@ -63,36 +65,16 @@ public void activate() { super.activate(); RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - NodeAdapter nodeAdapter = (NodeAdapter) getModel(); - -// // ルートモデルを監視開始(DisplayModeが変わった時用) -// rootModel.getAdapter(Observable.class).addModelChangeListener(this); -// -// // DiagramPresentationが変わった時用 -// rootModel.getDiagramPresentations().get(Migration.DIAGRAM_INDEX).getNodeLayouts().addListener(this); -// -// // 自モデルを監視開始 -// nodeAdapter.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// -// // 自モデルから出るコネクションを監視開始 -// for (ConnectionAdapter connection : nodeAdapter.getSourceConnections()) { -// connection.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// } -// -// // 自モデルを指すコネクションを監視開始 -// for (ConnectionAdapter connection : nodeAdapter.getTargetConnections()) { -// connection.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// } + rootModel.getJiemamy().getEventBroker().addListener(this); +// NodeAdapter nodeAdapter = (NodeAdapter) getModel(); } -// /** -// * {@inheritDoc} -// */ -// public void collectionChanged(ObservableCollectionChangeEvent<Map<NodeAdapter, JmRectangle>, JmRectangle> event) { -// if (event.getTiming() == Timing.AFTER_ADD) { -// refreshVisuals(); -// } -// } + /** + * {@inheritDoc} + */ + public void commandProcess(Command command) { + refreshVisuals(); + } /** * {@inheritDoc} @@ -100,28 +82,21 @@ @Override public void deactivate() { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - NodeAdapter entityModel = (NodeAdapter) getModel(); - -// // 自モデルを指すコネクションを監視終了 -// for (ConnectionAdapter connection : entityModel.getTargetConnections()) { -// connection.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// } -// // 自モデルから出るコネクションを監視終了 -// for (ConnectionAdapter connection : entityModel.getSourceConnections()) { -// connection.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// } -// // 自モデルを監視終了 -// entityModel.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// -// // ルートモデルを監視終了 -// rootModel.getAdapter(Observable.class).removeModelChangeListener(this); - + rootModel.getJiemamy().getEventBroker().removeListener(this); +// NodeAdapter entityModel = (NodeAdapter) getModel(); super.deactivate(); } /** * {@inheritDoc} */ + public void doubleClicked() { + openEditDialog(); + } + + /** + * {@inheritDoc} + */ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { return new ChopboxAnchor(getFigure()); } @@ -147,29 +122,6 @@ return new ChopboxAnchor(getFigure()); } -// /** -// * {@inheritDoc} -// */ -// public void modelChanged(ModelChangeEvent evt) { -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(AbstractNodeModel.P_CREATE)) { -// openEditDialog(); -// } else if (evt.getField().equals(StickyModel.P_NODE_BG_COLOR)) { -// updateFigure(getFigure()); -// } else if (evt.getField().equals(AbstractNodeModel.P_NODE_CONSTRAINT)) { -// refreshVisuals(); -// } else if (evt.getField().equals(AbstractNodeModel.P_NODE_SOURCE_CONNECTION)) { -// // HACK リスナー更新、こんな方法でいいのか? -// deactivate(); -// activate(); -// } -// } else { -// if (evt.getField().equals(DatabaseModel.P_DB_DISPLAY_MODE)) { -// refreshVisuals(); -// } -// } -// } - /** * {@inheritDoc} */ @@ -221,12 +173,22 @@ return IteratorUtils.toList(connections.iterator()); } + /** + * TODO for daisuke + * + * @return + */ protected IResource getResource() { IEditorPart editorPart = EditorUtil.getActiveEditor(); IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput(); return input.getFile(); } + /** + * TODO for daisuke + * + * @param figure + */ protected abstract void updateFigure(IFigure figure); private void performDirectEdit() { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -30,8 +30,12 @@ import org.jiemamy.Migration; import org.jiemamy.eclipse.editor.editpolicy.JmBendpointEditPolicy; import org.jiemamy.eclipse.editor.editpolicy.JmRelationEditPolicy; +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; +import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; +import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.model.geometory.JmPoint; /** @@ -39,7 +43,7 @@ * * @author daisuke */ -public abstract class AbstractRelationEditPart extends AbstractConnectionEditPart /*implements ModelChangeListener*/{ +public abstract class AbstractRelationEditPart extends AbstractConnectionEditPart implements CommandListener { /** * {@inheritDoc} @@ -47,52 +51,34 @@ @Override public void activate() { super.activate(); - -// // ルートモデルを監視開始 -// RootModel rootModel = (RootModel) getRoot().getContents().getModel(); -// rootModel.getAdapter(Observable.class).addModelChangeListener(this); -// -// // 自モデル・ソース・ターゲットを監視開始 -// ConnectionAdapter model = (ConnectionAdapter) getModel(); -// model.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// model.getSource().unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// model.getTarget().unwrap().getAdapter(Observable.class).addModelChangeListener(this); + // 自モデル・ソース・ターゲットを監視開始 + ConnectionAdapter model = (ConnectionAdapter) getModel(); + model.unwrap().getJiemamy().getEventBroker().addListener(this); } /** * {@inheritDoc} */ + public void commandProcess(Command command) { + refreshVisuals(); + } + + /** + * {@inheritDoc} + */ @Override public void deactivate() { -// // 自モデル・ソース・ターゲットを監視終了 -// ConnectionAdapter model = (ConnectionAdapter) getModel(); -// model.getTarget().unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// model.getSource().unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// model.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// -// // ルートモデルを監視終了 -// RootModel rootModel = (RootModel) getRoot().getContents().getModel(); -// rootModel.getAdapter(Observable.class).removeModelChangeListener(this); - + ConnectionAdapter model = (ConnectionAdapter) getModel(); + model.unwrap().getJiemamy().getEventBroker().removeListener(this); super.deactivate(); } -// /** -// * {@inheritDoc} -// */ -// public void modelChanged(ModelChangeEvent evt) { -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(AbstractRelationModel.P_RELATION_BEND_POINT)) { -// refreshBendpoints(); -// } -// } -// } - /** * {@inheritDoc} */ @Override public void refreshVisuals() { + super.refreshVisuals(); refreshBendpoints(); } @@ -108,9 +94,10 @@ private void refreshBendpoints() { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - List<JmPoint> bendpoints = - rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX).getConnectionLayouts() - .get(getModel()); + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(Migration.DIAGRAM_INDEX); + + List<JmPoint> bendpoints = diagramPresentationModel.getConnectionLayouts().get(getModel()); List<AbsoluteBendpoint> constraint = new ArrayList<AbsoluteBendpoint>(bendpoints.size()); for (JmPoint bendpoint : bendpoints) { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRootEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRootEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRootEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -24,6 +24,7 @@ import org.eclipse.ui.IFileEditorInput; import org.jiemamy.eclipse.utils.EditorUtil; +import org.jiemamy.editcommand.CommandListener; import org.jiemamy.model.RootModel; /** @@ -31,7 +32,7 @@ * * @author daisuke */ -public abstract class AbstractRootEditPart extends AbstractGraphicalEditPart /*implements ModelChangeListener*/{ +public abstract class AbstractRootEditPart extends AbstractGraphicalEditPart implements CommandListener { /** * {@inheritDoc} @@ -39,11 +40,9 @@ @Override public void activate() { super.activate(); + RootModel rootModel = (RootModel) getModel(); - -// // ルートモデルを監視開始 -// rootModel.getAdapter(Observable.class).addModelChangeListener(this); -// rootModel.getNodes().getAdapter(Observable.class).addListener(this); + rootModel.getJiemamy().getEventBroker().addListener(this); } /** @@ -52,14 +51,16 @@ @Override public void deactivate() { RootModel rootModel = (RootModel) getModel(); + rootModel.getJiemamy().getEventBroker().removeListener(this); -// // ルートモデルを監視終了 -// rootModel.getNodes().getAdapter(Observable.class).removeListener(this); -// rootModel.getAdapter(Observable.class).removeModelChangeListener(this); - super.deactivate(); } + /** + * TODO for daisuke + * + * @return + */ protected IResource getResource() { IEditorPart editorPart = EditorUtil.getActiveEditor(); IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -30,8 +30,10 @@ import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.extraprocessor.LabelStringProcessor; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.utils.ProcessorUtil; /** @@ -50,28 +52,14 @@ openEditDialog(); } -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(ForeignKeyModel.P_CREATE)) { -// openEditDialog(); -// updateLabel(); -// } else if (evt.getField().equals(ForeignKeyModel.P_RELATION_FK_MAPPING)) { -// updateLabel(); -// } -// } else { -// if (evt.getField().equals(TableModel.P_ENTITY_TABLE_COLUMNS)) { -// updateLabel(); -// } else if (evt.getField().equals(DatabaseModel.P_DB_DISPLAY_MODE)) { -// updateLabel(); -// } -// } -// } + /** + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + ConnectionAdapter connection = (ConnectionAdapter) getModel(); + ForeignKeyModel fkModel = connection.unwrap(); + return fkModel; + } /** * {@inheritDoc} 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-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -37,7 +37,11 @@ import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmXYLayoutEditPolicy; import org.jiemamy.eclipse.preference.JiemamyPreference; +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; +import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.utils.CollectionsUtil; @@ -46,7 +50,8 @@ * {@link RootModel}に対するDiagram用EditPart。 * @author daisuke */ -public class RootEditPart extends AbstractRootEditPart implements EditDialogSupport, IPropertyChangeListener /*, ModelChangeListener */{ +public class RootEditPart extends AbstractRootEditPart implements EditDialogSupport, IPropertyChangeListener, + CommandListener { private static Logger logger = LoggerFactory.getLogger(RootEditPart.class); @@ -57,50 +62,43 @@ @Override public void activate() { super.activate(); + IPreferenceStore ps = JiemamyPlugin.getDefault().getPreferenceStore(); ps.addPropertyChangeListener(this); -// RootModel rootModel = (RootModel) getModel(); -// rootModel.getAdapter(Observable.class).addModelChangeListener(this); + RootModel rootModel = (RootModel) getModel(); + rootModel.getJiemamy().getEventBroker().addListener(this); } -// /** -// * {@inheritDoc} -// */ -// public void collectionChanged(ObservableCollectionChangeEvent<List<NodeAdapter>, NodeAdapter> event) { -// if (event.getTiming() == Timing.AFTER_ADD) { -// refreshChildren(); -// } -// } + /** + * {@inheritDoc} + */ + public void commandProcess(Command command) { + refreshChildren(); +// JiemamyValidatorUtil.validate(getResource(), (RootModel) getModel()); + } /** * {@inheritDoc} */ @Override public void deactivate() { -// RootModel rootModel = (RootModel) getModel(); -// rootModel.getAdapter(Observable.class).removeModelChangeListener(this); + RootModel rootModel = (RootModel) getModel(); + rootModel.getJiemamy().getEventBroker().removeListener(this); IPreferenceStore ps = JiemamyPlugin.getDefault().getPreferenceStore(); ps.removePropertyChangeListener(this); + super.deactivate(); } -// /** -// * {@inheritDoc} -// */ -// public void modelChanged(ModelChangeEvent e) { -// if (e.getField() == ReflectionUtil.getField(getModel().getClass(), "dialectClassName")) { -// refreshChildren(); -// } -// if (e.getField() == RootModel.class.getField("nodes")) { -// refreshChildren(); -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getModel()); -// } else if (e.getField() == RootModel.class.getField("dialectClassName")) { // データベースが変更された時 -// // 既存ドメインの型を新しいデータベースの型に変更する。 -// refreshChildren(); -// } -// } + /** + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + RootModel rootModel = (RootModel) getModel(); + return rootModel; + } /** * {@inheritDoc} @@ -159,9 +157,10 @@ */ @Override protected List<NodeAdapter> getModelChildren() { - // THINK 詰め替えしていいのかなぁ。 - return CollectionsUtil.newArrayList(((RootModel) getModel()).getAdapter(DiagramPresentations.class).get( - Migration.DIAGRAM_INDEX).getFigureProfiles().keySet()); + RootModel rootModel = (RootModel) getModel(); + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(Migration.DIAGRAM_INDEX); + return CollectionsUtil.newArrayList(diagramPresentationModel.getFigureProfiles().keySet()); } private void setConnectionRouter(IFigure figure) { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -33,6 +33,7 @@ import org.jiemamy.eclipse.utils.ConvertUtil; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.geometory.JmColor; import org.jiemamy.model.geometory.JmRectangle; @@ -51,24 +52,11 @@ /** * {@inheritDoc} */ - public void doubleClicked() { - openEditDialog(); + public JiemamyElement getTargetModel() { + StickyModel stickyModel = (StickyModel) getModel(); + return stickyModel; } -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(StickyModel.P_ENTITY_STICKY_CONTENTS)) { -// refreshVisuals(); -// } -// } -// } - /** * {@inheritDoc} */ 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-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -46,6 +46,7 @@ import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.geometory.JmColor; import org.jiemamy.model.geometory.JmRectangle; +import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.utils.ProcessorUtil; import org.jiemamy.utils.model.TableUtil; @@ -58,56 +59,10 @@ /** * {@inheritDoc} */ - public void doubleClicked() { - openEditDialog(); - } - -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// -// if (getModel().equals(evt.getSource())) { // 自分自身の発火 -// if (evt.getField().equals(TableModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(TableModel.P_NODE_ENTITY_LOGICAL_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(TableModel.P_NODE_BG_COLOR)) { -// updateFigure(getFigure()); -// } else if (evt.getField().equals(TableModel.P_ENTITY_TABLE_COLUMNS)) { -// updateFigure(getFigure()); -// JiemamyValidatorUtil.validate(getResource(), (RootModel) getParent().getModel()); -// } else if (evt.getField().equals(TableModel.P_NODE_SOURCE_CONNECTION)) { -// refreshSourceConnections(); -// updateFigure(getFigure()); -// } else if (evt.getField().equals(TableModel.P_NODE_TARGET_CONNECTION)) { -// refreshTargetConnections(); -// updateFigure(getFigure()); -// } -// } else if (((TableModel) getModel()).getSourceConnections().contains(evt.getSource())) { // source関連の発火 -// if (evt.getField().equals(ForeignKeyModel.P_RELATION_FK_MAPPING)) { // マッピングが編集された時 -// updateFigure(getFigure()); -// } -// } else { -// if (evt.getField().equals(DatabaseModel.P_DB_DOMAINS)) { -// updateFigure(getFigure()); -// } else if (evt.getField().equals(DatabaseModel.P_DB_DISPLAY_MODE)) { -// updateFigure(getFigure()); -// } else if (evt.getField().equals(DatabaseModel.P_DB_RDBMS)) { // データベースが変更された時 -// // 既存カラムの型を新しいデータベースの型に変更する。 -// updateFigure(getFigure()); -// } -// } -// } - - /** - * {@inheritDoc} - */ public void openEditDialog() { RootModel rootModel = (RootModel) getParent().getModel(); - TableModel tableModel = (TableModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + TableModel tableModel = (TableModel) node.unwrap(); // TableEditDialog dialog = new TableEditDialog(getViewer().getControl().getShell(), tableModel, rootModel); // @@ -133,7 +88,8 @@ @Override protected IFigure createFigure() { TableFigure figure = new TableFigure(); - String description = ((TableModel) getModel()).getDescription(); + NodeAdapter node = (NodeAdapter) getModel(); + String description = ((TableModel) node.unwrap()).getDescription(); if (description != null && description.length() > 0) { Panel tooltip = new Panel(); @@ -155,12 +111,13 @@ protected void refreshVisuals() { super.refreshVisuals(); RootModel rootModel = (RootModel) getParent().getModel(); - EntityModel entityModel = (EntityModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + EntityModel entityModel = node.unwrap(); GraphicalEditPart editPart = (GraphicalEditPart) getParent(); DiagramPresentationModel presentation = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - JmRectangle constraint = presentation.getFigureProfiles().get(entityModel).getLayout(); + JmRectangle constraint = presentation.getFigureProfiles().get(node).getLayout(); editPart.setLayoutConstraint(this, getFigure(), ConvertUtil.convert(constraint)); updateFigure(getFigure()); @@ -172,7 +129,8 @@ @Override protected void updateFigure(IFigure figure) { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - TableModel tableModel = (TableModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + TableModel tableModel = (TableModel) node.unwrap(); TableFigure tableFigure = (TableFigure) figure; String labelString = @@ -180,7 +138,7 @@ DisplayPlace.FIGURE)); DiagramPresentationModel presentation = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - JmColor color = presentation.getFigureProfiles().get(tableModel).getColor(); + JmColor color = presentation.getFigureProfiles().get(node).getColor(); tableFigure.setTableName(labelString); tableFigure.setBgColor(ConvertUtil.convert(color)); @@ -197,7 +155,8 @@ private ColumnFigure[] createColumnFigure(ColumnModel column) { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - TableModel tableModel = (TableModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + TableModel tableModel = (TableModel) node.unwrap(); boolean pkColumn = false; try { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -35,10 +35,10 @@ import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; -import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.ViewModel; import org.jiemamy.model.geometory.JmColor; import org.jiemamy.model.geometory.JmRectangle; +import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.utils.ProcessorUtil; /** @@ -51,34 +51,10 @@ /** * {@inheritDoc} */ - public void doubleClicked() { - openEditDialog(); - } - -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(ViewModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(ViewModel.P_NODE_BG_COLOR)) { -// updateFigure(getFigure()); -// } else if (evt.getField().equals(ViewModel.P_ENTITY_VIEW_DEFINITION)) { -// refreshVisuals(); -// } -// } -// } - - /** - * {@inheritDoc} - */ public void openEditDialog() { RootModel rootModel = (RootModel) getParent().getModel(); - ViewModel viewModel = (ViewModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + ViewModel viewModel = (ViewModel) node.unwrap(); // ViewEditDialog dialog = new ViewEditDialog(getViewer().getControl().getShell(), viewModel); // @@ -104,7 +80,9 @@ @Override protected IFigure createFigure() { ViewFigure figure = new ViewFigure(); - String definition = ((ViewModel) getModel()).getDefinition(); + NodeAdapter node = (NodeAdapter) getModel(); + ViewModel viewModel = (ViewModel) node.unwrap(); + String definition = viewModel.getDefinition(); if (definition.length() > 0) { Panel tooltip = new Panel(); @@ -125,12 +103,12 @@ @Override protected void refreshVisuals() { RootModel rootModel = (RootModel) getParent().getModel(); - EntityModel entityModel = (EntityModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); GraphicalEditPart editPart = (GraphicalEditPart) getParent(); DiagramPresentationModel presentation = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - JmRectangle constraint = presentation.getFigureProfiles().get(entityModel).getLayout(); + JmRectangle constraint = presentation.getFigureProfiles().get(node).getLayout(); editPart.setLayoutConstraint(this, getFigure(), ConvertUtil.convert(constraint)); updateFigure(getFigure()); @@ -142,7 +120,8 @@ @Override protected void updateFigure(IFigure figure) { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - ViewModel viewModel = (ViewModel) getModel(); + NodeAdapter node = (NodeAdapter) getModel(); + ViewModel viewModel = (ViewModel) node.unwrap(); ViewFigure viewFigure = (ViewFigure) figure; String labelString = @@ -150,7 +129,7 @@ DisplayPlace.FIGURE)); DiagramPresentationModel presentation = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - JmColor color = presentation.getFigureProfiles().get(viewModel).getColor(); + JmColor color = presentation.getFigureProfiles().get(node).getColor(); viewFigure.setEntityName(labelString); viewFigure.setBgColor(ConvertUtil.convert(color)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -26,57 +26,4 @@ */ public abstract class AbstractEntityTreeEditPart extends AbstractModelTreeEditPart { - /** - * {@inheritDoc} - */ - @Override - public void activate() { - super.activate(); - -// // 自モデルの監視 -// EntityModel entity = (EntityModel) getModel(); -// entity.getAdapter(Observable.class).addModelChangeListener(this); -// -// // 自モデル発の関連監視 -// for (ConnectionAdapter connection : entity.getAdapter(NodeAdapter.class).getSourceConnections()) { -// connection.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// } -// -// // 自モデル着の関連監視 -// for (ConnectionAdapter connection : entity.getAdapter(NodeAdapter.class).getTargetConnections()) { -// connection.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// } - } - - /** - * {@inheritDoc} - */ - @Override - public void deactivate() { -// EntityModel entity = (EntityModel) getModel(); -// for (ConnectionAdapter connection : entity.getAdapter(NodeAdapter.class).getTargetConnections()) { -// connection.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// } -// for (ConnectionAdapter connection : entity.getAdapter(NodeAdapter.class).getSourceConnections()) { -// connection.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// } -// entity.getAdapter(Observable.class).removeModelChangeListener(this); - - super.deactivate(); - } - -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(AbstractEntityModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } else if (evt.getPropertyName().equals(AbstractEntityModel.P_NODE_ENTITY_LOGICAL_NAME)) { -// refreshVisuals(); -// } -// } -// } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractModelTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractModelTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractModelTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -20,11 +20,15 @@ import org.eclipse.gef.editparts.AbstractTreeEditPart; +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; +import org.jiemamy.model.RootModel; + /** * モデルに対するTree用EditPart(コントローラ)の抽象クラス。 * @author daisuke */ -public abstract class AbstractModelTreeEditPart extends AbstractTreeEditPart /*implements ModelChangeListener*/{ +public abstract class AbstractModelTreeEditPart extends AbstractTreeEditPart implements CommandListener { /** * {@inheritDoc} @@ -33,35 +37,25 @@ public void activate() { super.activate(); -// RootModel rootModel = (RootModel) getRoot().getContents().getModel(); -// rootModel.getAdapter(Observable.class).addModelChangeListener(this); -// -// if (getModel() instanceof Adaptable) { -// Adaptable adaptable = (Adaptable) getModel(); -// adaptable.getAdapter(Observable.class).addModelChangeListener(this); -// } + RootModel rootModel = (RootModel) getRoot().getContents().getModel(); + rootModel.getJiemamy().getEventBroker().addListener(this); } /** * {@inheritDoc} */ + public void commandProcess(Command command) { + refreshChildren(); + } + + /** + * {@inheritDoc} + */ @Override public void deactivate() { -// if (getModel() instanceof Adaptable) { -// Adaptable adaptable = (Adaptable) getModel(); -// adaptable.getAdapter(Observable.class).removeModelChangeListener(this); -// } -// -// RootModel rootModel = (RootModel) getRoot().getContents().getModel(); -// rootModel.getAdapter(Observable.class).removeModelChangeListener(this); + RootModel rootModel = (RootModel) getRoot().getContents().getModel(); + rootModel.getJiemamy().getEventBroker().addListener(this); super.deactivate(); } - -// /** -// * {@inheritDoc} -// */ -// public void modelChanged(ModelChangeEvent evt) { -// // nothing to do -// } } Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractRelationTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractRelationTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractRelationTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -1,60 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/08/03 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.editor.editpart.outlinetree; - -import org.jiemamy.model.connection.ConnectionAdapter; - -/** - * {@link AbstractRelationModel}に対するTree用EditPart(コントローラ)の抽象クラス。 - * @author daisuke - */ -public abstract class AbstractRelationTreeEditPart extends AbstractModelTreeEditPart { - - /** - * {@inheritDoc} - */ - @Override - public void activate() { - super.activate(); - - ConnectionAdapter model = (ConnectionAdapter) getModel(); - -// // 自モデルの監視 -// model.unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// -// // ソースエンティティの監視 -// model.getSource().unwrap().getAdapter(Observable.class).addModelChangeListener(this); -// -// // ターゲットエンティティの監視 -// model.getTarget().unwrap().getAdapter(Observable.class).addModelChangeListener(this); - } - - /** - * {@inheritDoc} - */ - @Override - public void deactivate() { -// ConnectionAdapter model = (ConnectionAdapter) getModel(); -// model.getTarget().unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// model.getSource().unwrap().getAdapter(Observable.class).removeModelChangeListener(this); -// model.unwrap().getAdapter(Observable.class).removeModelChangeListener(this); - - super.deactivate(); - } -} Copied: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java (from rev 2654, vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TypeDefTreeEditPart.java) =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -0,0 +1,66 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/08/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.eclipse.editor.editpart.outlinetree; + +import org.eclipse.gef.EditPolicy; +import org.eclipse.jface.resource.ImageRegistry; + +import org.jiemamy.eclipse.Images; +import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.editor.editpolicy.JmTreeComponentEditPolicy; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; + +/** + * DefinitionModelに対するTree用EditPart + * @author daisuke + */ +public class AttributeTreeEditPart extends AbstractModelTreeEditPart { + + /** + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + AttributeModel model = (AttributeModel) getModel(); + return model; + } + + /** + * {@inheritDoc} + */ + @Override + protected void createEditPolicies() { + installEditPolicy(EditPolicy.COMPONENT_ROLE, new JmTreeComponentEditPolicy()); + } + + /** + * {@inheritDoc} + */ + @Override + protected void refreshVisuals() { + RootModel rootModel = (RootModel) getRoot().getContents().getModel(); + + // ツリー・アイテムのテキストとしてモデルのテキストを設定 +// setWidgetText(rootModel.getDialect().createStringOfDefinitionForTree((DefinitionModel) getModel())); + + ImageRegistry ir = JiemamyPlugin.getDefault().getImageRegistry(); + setWidgetImage(ir.get(Images.ICON_COLUMN)); + } +} Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -25,6 +25,7 @@ import org.jiemamy.eclipse.Images; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.ModelContainer; +import org.jiemamy.model.JiemamyElement; /** * {@link ModelContainer}に対するTree用EditPart(コントローラ)。 @@ -35,10 +36,19 @@ /** * {@inheritDoc} */ + public JiemamyElement getTargetModel() { + ModelContainer container = (ModelContainer) getModel(); + return container; + } + + /** + * {@inheritDoc} + */ @Override protected List<Object> getModelChildren() { // ここで返された子モデルがツリーの子アイテムになる - return ((ModelContainer) getModel()).getChildren(); + ModelContainer container = (ModelContainer) getModel(); + return container.getChildren(); } /** Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -1,101 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/08/03 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.editor.editpart.outlinetree; - -import org.eclipse.jface.resource.ImageRegistry; - -import org.jiemamy.ReferenceResolver; -import org.jiemamy.eclipse.Images; -import org.jiemamy.eclipse.JiemamyPlugin; -import org.jiemamy.exception.TooManyElementsException; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel; -import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; -import org.jiemamy.model.connection.ConnectionAdapter; -import org.jiemamy.model.entity.EntityModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.utils.model.TableUtil; - -/** - * {@link ForeignKeyModel}に対するTree用EditPart(コントローラ)。 - * @author daisuke - */ -public class RelationTreeEditPart extends AbstractRelationTreeEditPart { - -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(ForeignKeyModel.P_RELATION_FK_NAME)) { -// refreshVisuals(); -// } -// } else if (evt.getField().equals(AbstractEntityModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } -// } - - /** - * {@inheritDoc} - */ - @Override - protected void refreshVisuals() { - ImageRegistry ir = JiemamyPlugin.getDefault().getImageRegistry(); - - ConnectionAdapter model = (ConnectionAdapter) getModel(); - StringBuilder sb = new StringBuilder(); - - ForeignKeyModel fkModel = model.unwrap(); - if (fkModel != null) { - ReferenceResolver resolver = fkModel.getJiemamy().getReferenceResolver(); - TableModel table = (TableModel) fkModel.getAdapter(ConnectionAdapter.class).getTarget(); - PrimaryKeyModel primaryKey; - try { - primaryKey = TableUtil.getPrimaryKey(table); - if (primaryKey.getKeyColumns().size() > 1 || fkModel.getReferenceColumns().size() == 0) { - // 複合キー時 or マッピング未定義時 - sb.append(fkModel.getName()).append(" (").append( - ((EntityModel) fkModel.getAdapter(ConnectionAdapter.class).getSource()).getName()).append( - " => ").append( - ((EntityModel) fkModel.getAdapter(ConnectionAdapter.class).getTarget()).getName()).append( - ")"); - } else if (fkModel.getAdapter(ConnectionAdapter.class).isSelfConnection()) { - ColumnModel fkColumn = resolver.resolve(fkModel.getKeyColumns().get(0)); - ColumnModel keyColumn = resolver.resolve(fkModel.getReferenceColumns().get(0)); - sb.append(fkModel.getName()).append(" (").append(fkColumn.getName()).append(" => ").append( - keyColumn.getName()).append(")"); - } else { - ColumnModel fkColumn = resolver.resolve(fkModel.getKeyColumns().get(0)); - ColumnModel keyColumn = resolver.resolve(fkModel.getReferenceColumns().get(0)); - sb.append(fkModel.getName()).append(" (").append(fkColumn.getName()).append(" => ").append( - keyColumn.getName()).append("@").append( - ((EntityModel) fkModel.getAdapter(ConnectionAdapter.class).getTarget()).getName()).append( - ")"); - } - } catch (TooManyElementsException e) { - sb.append("too many PKs"); - } - setWidgetImage(ir.get(Images.BUTTON_FK)); - } - setWidgetText(sb.toString()); - - } -} Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RootTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RootTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RootTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -21,15 +21,13 @@ import java.util.Arrays; import java.util.List; -import org.jiemamy.Migration; import org.jiemamy.eclipse.editor.ModelContainer; -import org.jiemamy.model.DiagramPresentationModel; -import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.model.node.NodeAdapter; /** * RootModelに対するTree用EditPart @@ -38,18 +36,13 @@ */ public class RootTreeEditPart extends AbstractModelTreeEditPart { -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getField().equals(DatabaseModel.P_DB_ENTITIES)) { -// refreshChildren(); -// } else if (evt.getField().equals(DatabaseModel.P_DB_DOMAINS)) { -// refreshChildren(); -// } -// } + /** + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + RootModel rootModel = (RootModel) getModel(); + return rootModel; + } /** * {@inheritDoc} @@ -61,29 +54,21 @@ // ここで返された子モデルがツリーの子アイテムになる RootModel rootModel = (RootModel) getModel(); - ModelContainer tableContainer = new ModelContainer("outline.tables"); - ModelContainer viewContainer = new ModelContainer("outline.views"); ModelContainer domainContainer = new ModelContainer("outline.domains"); - - DiagramPresentationModel presentation = - rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); - for (NodeAdapter node : presentation.getFigureProfiles().keySet()) { - if (node instanceof TableModel) { - tableContainer.getChildren().add(node); - } else if (node instanceof ViewModel) { - viewContainer.getChildren().add(node); - } - } - for (DomainModel domain : rootModel.getDomains()) { domainContainer.getChildren().add(domain); } - ModelContainer[] containers = { - tableContainer, - viewContainer, - domainContainer - }; - return Arrays.asList(containers); + ModelContainer tableContainer = new ModelContainer("outline.tables"); + ModelContainer viewContainer = new ModelContainer("outline.views"); + for (EntityModel entity : rootModel.getEntities()) { + if (entity instanceof TableModel) { + tableContainer.getChildren().add(entity); + } else if (entity instanceof ViewModel) { + viewContainer.getChildren().add(entity); + } + } + + return Arrays.asList(tableContainer, viewContainer, domainContainer); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TableTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TableTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TableTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -18,7 +18,6 @@ */ package org.jiemamy.eclipse.editor.editpart.outlinetree; -import java.util.ArrayList; import java.util.List; import org.eclipse.gef.EditPolicy; @@ -32,9 +31,10 @@ import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmTreeComponentEditPolicy; import org.jiemamy.eclipse.editor.extraprocessor.LabelStringProcessor; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.utils.ProcessorUtil; /** @@ -50,22 +50,13 @@ openEditDialog(); } -// /** -// * {@inheritDoc} -// */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(TableModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(TableModel.P_NODE_ENTITY_LOGICAL_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(TableModel.P_ENTITY_TABLE_COLUMNS)) { -// refreshChildren(); -// } -// } -// } + /** + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + TableModel model = (TableModel) getModel(); + return model; + } /** * {@inheritDoc} @@ -102,13 +93,10 @@ * {@inheritDoc} */ @Override - protected List<Object> getModelChildren() { + protected List<AttributeModel> getModelChildren() { // ここで返された子モデルがツリーの子アイテムになる - List<Object> children = new ArrayList<Object>(); - children.addAll(((TableModel) getModel()).getAttributes()); - children.addAll(((TableModel) getModel()).getAdapter(NodeAdapter.class).getSourceConnections()); - - return children; + TableModel tableModel = (TableModel) getModel(); + return tableModel.getAttributes(); } /** Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TypeDefTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TypeDefTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TypeDefTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -1,74 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/08/03 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.editor.editpart.outlinetree; - -import org.eclipse.gef.EditPolicy; -import org.eclipse.jface.resource.ImageRegistry; - -import org.jiemamy.eclipse.Images; -import org.jiemamy.eclipse.JiemamyPlugin; -import org.jiemamy.eclipse.editor.editpolicy.JmTreeComponentEditPolicy; -import org.jiemamy.model.RootModel; - -/** - * DefinitionModelに対するTree用EditPart - * @author daisuke - */ -public class TypeDefTreeEditPart extends AbstractModelTreeEditPart { - - /** - // * {@inheritDoc} - // */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getSource().equals(getModel())) { -// if (evt.getField().equals(DefinitionModel.P_DEF_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(DefinitionModel.P_DEF_LOGICAL_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(DefinitionModel.P_DEF_TYPE)) { -// refreshVisuals(); -// } else if (evt.getField().equals(DefinitionModel.P_DEF_SIZE)) { -// refreshVisuals(); -// } -// } -// } - /** - * {@inheritDoc} - */ - @Override - protected void createEditPolicies() { - installEditPolicy(EditPolicy.COMPONENT_ROLE, new JmTreeComponentEditPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - protected void refreshVisuals() { - RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - - // ツリー・アイテムのテキストとしてモデルのテキストを設定 -// setWidgetText(rootModel.getDialect().createStringOfDefinitionForTree((DefinitionModel) getModel())); - - ImageRegistry ir = JiemamyPlugin.getDefault().getImageRegistry(); - setWidgetImage(ir.get(Images.ICON_COLUMN)); - } -} Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -29,6 +29,7 @@ import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmTreeComponentEditPolicy; import org.jiemamy.eclipse.editor.extraprocessor.LabelStringProcessor; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.ViewModel; import org.jiemamy.utils.ProcessorUtil; @@ -48,17 +49,13 @@ } /** - // * {@inheritDoc} - // */ -// @Override -// public void modelChanged(ModelChangeEvent evt) { -// super.modelChanged(evt); -// if (evt.getField().equals(ViewModel.P_NODE_ENTITY_NAME)) { -// refreshVisuals(); -// } else if (evt.getField().equals(ViewModel.P_NODE_ENTITY_LOGICAL_NAME)) { -// refreshVisuals(); -// } -// } + * {@inheritDoc} + */ + public JiemamyElement getTargetModel() { + ViewModel model = (ViewModel) getModel(); + return model; + } + /** * {@inheritDoc} */ Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmTreeComponentEditPolicy.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmTreeComponentEditPolicy.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmTreeComponentEditPolicy.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -22,7 +22,7 @@ import org.eclipse.gef.editpolicies.ComponentEditPolicy; import org.eclipse.gef.requests.GroupRequest; -import org.jiemamy.eclipse.editor.DiagramEditor; +import org.jiemamy.eclipse.editor.JiemamyEditor; import org.jiemamy.eclipse.editor.command.DeleteNodeCommand; import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.model.RootModel; @@ -40,7 +40,7 @@ protected Command createDeleteCommand(GroupRequest deleteRequest) { if (getHost().getModel() instanceof EntityModel) { // THINK ActiveEditorは必ずDiagramEditorか? - DiagramEditor editor = (DiagramEditor) EditorUtil.getActiveEditor(); + JiemamyEditor editor = (JiemamyEditor) EditorUtil.getActiveEditor(); RootModel rootModel = editor.getRootModel(); NodeAdapter nodeAdapter = (NodeAdapter) getHost().getModel(); DeleteNodeCommand command = new DeleteNodeCommand(rootModel, nodeAdapter); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java 2009-02-12 13:25:12 UTC (rev 2655) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java 2009-02-12 13:25:47 UTC (rev 2656) @@ -27,6 +27,7 @@ import org.jiemamy.eclipse.editor.command.ChangeNodeConstraintCommand; import org.jiemamy.eclipse.editor.command.CreateNodeCommand; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.node.NodeAdapter; @@ -64,18 +65,18 @@ */ @Override protected Command getCreateCommand(CreateRequest request) { - NodeAdapter nodeAdapter = (NodeAdapter) request.getNewObject(); + JiemamyElement model = (JiemamyElement) request.getNewObject(); RootModel rootModel = (RootModel) getHost().getModel(); - if (nodeAdapter instanceof EntityModel) { - EntityModel entityModel = (EntityModel) nodeAdapter; + if (model instanceof EntityModel) { + EntityModel entityModel = (EntityModel) model; EntityUtil.autoDenominate(entityModel, rootModel); - } else if (nodeAdapter instanceof StickyModel) { - StickyModel stickyModel = (StickyModel) nodeAdapter; + } else if (model instanceof StickyModel) { + StickyModel stickyModel = (StickyModel) model; stickyModel.setContents("default contents"); } - return new CreateNodeCommand(rootModel, nodeAdapter, (Rectangle) getConstraintFor(request)); + return new CreateNodeCommand(rootModel, model, (Rectangle) getConstraintFor(request)); } /**