svnno****@sourc*****
svnno****@sourc*****
2009年 2月 16日 (月) 02:03:03 JST
Revision: 2673 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2673 Author: daisuke_m Date: 2009-02-16 02:03:03 +0900 (Mon, 16 Feb 2009) Log Message: ----------- コンテキストメニューが表示されるようになった。/ refactor Modified Paths: -------------- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/StickyModelImpl.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ExportAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ImportAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java 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/DiagramEditorContextMenuProvider.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/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/AbstractJmNodeEditPart.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/AttributeTreeEditPart.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/TableTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/extraprocessor/IsDisplayedProcessor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/utils/LabelStringUtil.java Removed Paths: ------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor2.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/StickyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/StickyModelImpl.java 2009-02-15 16:00:11 UTC (rev 2672) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/StickyModelImpl.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -21,6 +21,8 @@ import java.util.List; import java.util.UUID; +import org.apache.commons.collections15.ListUtils; + import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; import org.jiemamy.model.connection.ConnectionAdapter; @@ -31,7 +33,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class StickyModelImpl extends AbstractJiemamyElement implements StickyModel { /** 内容文 */ @@ -64,12 +65,12 @@ public List<ConnectionAdapter> getSourceConnections() { // TODO - return null; + return ListUtils.EMPTY_LIST; } public List<ConnectionAdapter> getTargetConnections() { // TODO - return null; + return ListUtils.EMPTY_LIST; } /** @@ -83,7 +84,6 @@ * {@inheritDoc} */ public EntityModel unwrap() { - // TODO Auto-generated method stub return null; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ExportAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ExportAction.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ExportAction.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -33,7 +33,7 @@ import org.jiemamy.composer.ExportContext; import org.jiemamy.composer.ExportException; import org.jiemamy.composer.Exporter; -import org.jiemamy.eclipse.editor.DiagramEditor2; +import org.jiemamy.eclipse.editor.DiagramEditor; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.model.RootModel; @@ -47,7 +47,7 @@ private Exporter exporter; - private DiagramEditor2 editor; + private DiagramEditor editor; /** @@ -56,7 +56,7 @@ * @param viewer * @param editor */ - public ExportAction(Exporter exporter, GraphicalViewer viewer, DiagramEditor2 editor) { + public ExportAction(Exporter exporter, GraphicalViewer viewer, DiagramEditor editor) { super(exporter.getName(), viewer); // paramCreator = porterDto.getParamCreator(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ImportAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ImportAction.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ImportAction.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -33,7 +33,7 @@ import org.jiemamy.composer.ImportContext; import org.jiemamy.composer.ImportException; import org.jiemamy.composer.Importer; -import org.jiemamy.eclipse.editor.DiagramEditor2; +import org.jiemamy.eclipse.editor.DiagramEditor; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.model.RootModel; @@ -47,7 +47,7 @@ private Importer importer; - private DiagramEditor2 editor; + private DiagramEditor editor; /** @@ -56,7 +56,7 @@ * @param viewer * @param editor */ - public ImportAction(Importer importer, GraphicalViewer viewer, DiagramEditor2 editor) { + public ImportAction(Importer importer, GraphicalViewer viewer, DiagramEditor editor) { super(importer.getName(), viewer); // paramCreator = porterDto.getParamCreator(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -55,7 +55,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IFileEditorInput; -import org.jiemamy.eclipse.editor.DiagramEditor2; +import org.jiemamy.eclipse.editor.DiagramEditor; import org.jiemamy.eclipse.ui.FolderSelectWizardPage; import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.eclipse.utils.ExceptionHandler; @@ -69,7 +69,7 @@ private static final int MARGIN = 50; - private DiagramEditor2 editor; + private DiagramEditor editor; private IPath path; @@ -85,7 +85,7 @@ * @param viewer * @param editor */ - public SaveDiagramImageAction(GraphicalViewer viewer, DiagramEditor2 editor) { + public SaveDiagramImageAction(GraphicalViewer viewer, DiagramEditor editor) { super("menu.saveImage", viewer); // RESOURCE this.editor = editor; } 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -37,6 +37,7 @@ import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.Viewport; import org.eclipse.draw2d.parts.ScrollableThumbnail; +import org.eclipse.gef.ContextMenuProvider; import org.eclipse.gef.DefaultEditDomain; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.GraphicalViewer; @@ -148,6 +149,8 @@ private Jiemamy jiemamy; + private int tabIndex; + /** * インスタンスを生成する。 @@ -159,6 +162,15 @@ } /** + * インスタンスを生成する。 + * + * @param rootModel2 + */ + public DiagramEditor(RootModel rootModel) { + // TODO Auto-generated constructor stub + } + + /** * {@inheritDoc} */ @Override @@ -357,6 +369,15 @@ } /** + * TODO for daisuke + * + * @param tabIndex + */ + public void setTabIndex(int tabIndex) { + this.tabIndex = tabIndex; + } + + /** * {@inheritDoc} */ @Override @@ -378,10 +399,9 @@ viewer.setKeyHandler(keyHandler); // configure the context menu provider - // TODO context menu の設定 -// ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry()); -// viewer.setContextMenu(cmProvider); -// getSite().setSelectionProvider(viewer); + ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry()); + viewer.setContextMenu(cmProvider); + getSite().setSelectionProvider(viewer); } /** Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor2.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor2.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor2.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -1,579 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/29 - * - * 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 java.util.ArrayList; -import java.util.EventObject; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.LightweightSystem; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.KeyStroke; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.AlignmentAction; -import org.eclipse.gef.ui.actions.DirectEditAction; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.MatchHeightAction; -import org.eclipse.gef.ui.actions.MatchWidthAction; -import org.eclipse.gef.ui.actions.SelectAllAction; -import org.eclipse.gef.ui.actions.ZoomInAction; -import org.eclipse.gef.ui.actions.ZoomOutAction; -import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; -import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.commands.ActionHandler; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.eclipse.editor.editpart.DiagramEditPartFactory; -import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; -import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory; -import org.jiemamy.model.RootModel; - -/** - * ERダイアグラムエディタ。 - * @author daisuke - */ -public class DiagramEditor2 extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener { - - private static Logger logger = LoggerFactory.getLogger(DiagramEditor2.class); - - /** Palette component, holding the tools and shapes. */ - private static PaletteRoot paletteModel; - - private static final double[] ZOOM_LEVELS = new double[] { - 0.1, - 0.3, - 0.4, - 0.5, - 0.6, - 0.7, - 0.8, - 0.9, - 1.0, - 1.2, - 1.5, - 2.0, - 2.5, - 3.0, - 5.0, - 7.0, - 10.0 - }; - - /** ルートEditPart(コントローラ) */ - private ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); - - /** エディタのルートモデル */ - private final RootModel rootModel; - - private boolean savePreviouslyNeeded = false; - - private int tabIndex; - - - /** - * インスタンスを生成する。 - * @param rootModel - */ - public DiagramEditor2(RootModel rootModel) { - setEditDomain(new DefaultEditDomain(this)); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - this.rootModel = rootModel; - } - - /** - * {@inheritDoc} - */ - @Override - public void commandStackChanged(EventObject event) { - if (isDirty()) { - if (savePreviouslyNeeded == false) { - savePreviouslyNeeded = true; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - } else { - savePreviouslyNeeded = false; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - super.commandStackChanged(event); - } - - /** - * {@inheritDoc} - */ - @Override - public void dispose() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - super.dispose(); - } - - /** - * {@inheritDoc} - */ - @Override - public void doSave(IProgressMonitor monitor) { - getCommandStack().markSaveLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - public void doSaveAs() { - getCommandStack().markSaveLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("unchecked") - // TODO キャスト安全性の根拠提示 - public Object getAdapter(Class adapter) { - if (adapter == ZoomManager.class) { - return ((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); - } else if (adapter == IContentOutlinePage.class) { - return new DiagramOutlinePage(new org.eclipse.gef.ui.parts.TreeViewer()); // GEFツリービューワを使用 - } - return super.getAdapter(adapter); - } - - /** - * {@link RootModel}を取得する。 - * @return エディタのルートモデル - */ - public RootModel getRootModel() { - return rootModel; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * エディタ外などからの、リソースの変更を検知する。 - * {@inheritDoc} - */ - public void resourceChanged(final IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.POST_CHANGE) { - final IEditorInput input = getEditorInput(); - if (input instanceof IFileEditorInput) { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - IFile file = ((IFileEditorInput) input).getFile(); - if (!file.exists()) { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - page.closeEditor(DiagramEditor2.this, true); - } else if (!getPartName().equals(file.getName())) { - setPartName(file.getName()); - } - } - }); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (part.getSite().getWorkbenchWindow().getActivePage() == null) { - return; - } - super.selectionChanged(part, selection); - } - - /** - * {@inheritDoc} - */ - @Override - public void setFocus() { - // Thanks to Naokiさん - super.setFocus(); - IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); - if (contributor != null) { - ((JmContributor) contributor).selectCombo(rootModel); - } else { - logger.warn("contributor is null."); - // THINK bacchusではnullになる事はなかったんだけどな。 - } - } - - /** - * TODO for daisuke - * @param tabIndex - */ - public void setTabIndex(int tabIndex) { - this.tabIndex = tabIndex; - } - - /** - * {@inheritDoc} - */ - @Override - protected void configureGraphicalViewer() { - super.configureGraphicalViewer(); - - // EditPartFactoryの作成と設定 - GraphicalViewer viewer = getGraphicalViewer(); - viewer.setEditPartFactory(new DiagramEditPartFactory()); - viewer.setRootEditPart(rootEditPart); - - // to make 'del' key work - GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer); - keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction( - ActionFactory.DELETE.getId())); - - keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT)); - - viewer.setKeyHandler(keyHandler); - - // configure the context menu provider - ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry()); - viewer.setContextMenu(cmProvider); - getSite().setSelectionProvider(viewer); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("unchecked") - // TODO キャスト安全性の根拠提示 - protected void createActions() { - super.createActions(); - - ActionRegistry registry = getActionRegistry(); - IAction action; - IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); - - // ZoomManager - ZoomManager zoomManager = rootEditPart.getZoomManager(); - - // zoom contribution - List<String> zoomContributions = new ArrayList<String>(3); - zoomContributions.add(ZoomManager.FIT_ALL); - zoomContributions.add(ZoomManager.FIT_HEIGHT); - zoomContributions.add(ZoomManager.FIT_WIDTH); - zoomManager.setZoomLevelContributions(zoomContributions); - - zoomManager.setZoomLevels(ZOOM_LEVELS); - - // zoom level contribution - action = new ZoomInAction(zoomManager); - registry.registerAction(action); - handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action)); - getSelectionActions().add(action.getId()); - - action = new ZoomOutAction(zoomManager); - registry.registerAction(action); - handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action)); - getSelectionActions().add(action.getId()); - - // select action - action = new SelectAllAction(this); - registry.registerAction(action); - - // match size contribution - action = new MatchWidthAction(this); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new MatchHeightAction(this); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - // direct edit contribution - action = new DirectEditAction((IWorkbenchPart) this); - registry.registerAction(action); - // 選択オブジェクトによってアクションを更新する必要がある場合には - // 以下のようにして、そのアクションのIDを登録しておく - getSelectionActions().add(action.getId()); - - // alignment contribution - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - - action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE); - registry.registerAction(action); - getSelectionActions().add(action.getId()); - } - - /** - * {@inheritDoc} - */ - @Override - protected PaletteRoot getPaletteRoot() { - if (paletteModel == null) { - paletteModel = DiagramEditorPaletteFactory.createPalette(); - } - - return paletteModel; - } - - /** - * {@inheritDoc} - */ - @Override - protected void initializeGraphicalViewer() { - super.initializeGraphicalViewer(); - - GraphicalViewer viewer = getGraphicalViewer(); - viewer.setContents(rootModel); - viewer.getControl().addMouseListener(new MouseAdapter() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection(); - Object obj = selection.getFirstElement(); - if (obj instanceof DoubleClickSupport) { - ((DoubleClickSupport) obj).doubleClicked(); - } - } - }); - } - - - /** - * アウトラインビューのページクラス。 - * @author daisuke - */ - private class DiagramOutlinePage extends org.eclipse.gef.ui.parts.ContentOutlinePage { - - /** ページをアウトラインとサムネイルに分離するコンポーネント */ - private SashForm sash; - - private Control outline; - - private Canvas overview; - - /** サムネイルを表示する為のフィギュア */ - private ScrollableThumbnail thumbnail; - - private DisposeListener disposeListener; - - - /** - * インスタンスを生成する。 - * @param viewer - */ - public DiagramOutlinePage(EditPartViewer viewer) { - super(viewer); - } - - /** - * {@inheritDoc} - */ - @Override - public void createControl(Composite parent) { - sash = new SashForm(parent, SWT.VERTICAL); - - // sash上にコンストラクタで指定したビューワの作成 - outline = getViewer().createControl(sash); - - configureOutlineViewer(); - hookOutlineViewer(); - initializeOutlineViewer(); - - // sash上にサムネイル用のCanvasビューワの作成 - overview = new Canvas(sash, SWT.BORDER); - // サムネイル・フィギュアを配置する為の LightweightSystem - LightweightSystem lws = new LightweightSystem(overview); - - // RootEditPartのビューをソースとしてサムネイルを作成 - ScalableRootEditPart rep = (ScalableRootEditPart) getGraphicalViewer().getRootEditPart(); - thumbnail = new ScrollableThumbnail((Viewport) rep.getFigure()); - thumbnail.setSource(rep.getLayer(LayerConstants.PRINTABLE_LAYERS)); - - lws.setContents(thumbnail); - - disposeListener = new DisposeListener() { - - public void widgetDisposed(DisposeEvent e) { - // サムネイル・イメージの破棄 - if (thumbnail != null) { - thumbnail.deactivate(); - thumbnail = null; - } - } - }; - // グラフィカル・ビューワが破棄されるときにサムネイルも破棄する - getGraphicalViewer().getControl().addDisposeListener(disposeListener); - } - - /** - * {@inheritDoc} - */ - @Override - public void dispose() { - // SelectionSynchronizer からTreeViewerを削除 - getSelectionSynchronizer().removeViewer(getViewer()); - - if (getGraphicalViewer().getControl() != null && !getGraphicalViewer().getControl().isDisposed()) { - getGraphicalViewer().getControl().removeDisposeListener(disposeListener); - } - - super.dispose(); - } - - /** - * {@inheritDoc} - */ - @Override - public Control getControl() { - return sash; - } - - /** - * {@inheritDoc} - */ - @Override - public void init(IPageSite pageSite) { - super.init(pageSite); - // グラフィカル・エディタに登録されているアクションを取得 - ActionRegistry registry = getActionRegistry(); - // アウトライン・ページで有効にするアクション - IActionBars bars = pageSite.getActionBars(); - - // Eclipse 3.0以前では以下のようにしてIDを取得します - // String id = IWorkbenchActionConstants.UNDO; - String id = ActionFactory.UNDO.getId(); - bars.setGlobalActionHandler(id, registry.getAction(id)); - - id = ActionFactory.REDO.getId(); - bars.setGlobalActionHandler(id, registry.getAction(id)); - - id = ActionFactory.DELETE.getId(); - bars.setGlobalActionHandler(id, registry.getAction(id)); - bars.updateActionBars(); - } - - /** - * ビュアーにコンテンツを設定する。 - * @param contents 設定するコンテンツ - */ - public void setContents(Object contents) { - getViewer().setContents(contents); - } - - /** - * アウトラインビュアーの設定を行う。 - */ - protected void configureOutlineViewer() { - // エディット・ドメインの設定 - getViewer().setEditDomain(getEditDomain()); - // EditPartFactory の設定 - getViewer().setEditPartFactory(new OutlineTreeEditPartFactory()); - - // THINK ContextMenuの設定 - // THINK ToolBarManagerの設定 - - outline.addMouseListener(new MouseAdapter() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection(); - Object obj = selection.getFirstElement(); - if (obj instanceof DoubleClickSupport) { - ((DoubleClickSupport) obj).doubleClicked(); - } - } - }); - } - - /** - * THINK アウトラインビュアーをhookします(?) - */ - protected void hookOutlineViewer() { - // グラフィカル・エディタとツリー・ビューワとの間で選択を同期させる - getSelectionSynchronizer().addViewer(getViewer()); - } - - /** - * アウトラインビュアーを初期化する。 - */ - protected void initializeOutlineViewer() { - // グラフィカル・エディタのルート・モデルをツリー・ビューワにも設定 - setContents(getRootModel()); - } - } -} Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -48,7 +48,7 @@ */ public class DiagramEditorContextMenuProvider extends ContextMenuProvider { - private DiagramEditor2 editorPart; + private DiagramEditor editorPart; /** The editor's action registry. */ private ActionRegistry actionRegistry; @@ -62,7 +62,7 @@ * @param editor the editor * @param registry the editor's action registry */ - public DiagramEditorContextMenuProvider(EditPartViewer viewer, DiagramEditor2 editor, ActionRegistry registry) { + public DiagramEditorContextMenuProvider(EditPartViewer viewer, DiagramEditor editor, ActionRegistry registry) { super(viewer); if (registry == null) { 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -62,7 +62,7 @@ private static Logger logger = LoggerFactory.getLogger(MultiDiagramEditor.class); - private List<DiagramEditor2> editors = CollectionsUtil.newArrayList(); + private List<DiagramEditor> editors = CollectionsUtil.newArrayList(); /** エディタのルートモデル */ private RootModel rootModel; @@ -101,7 +101,7 @@ IFile file = ((IFileEditorInput) getEditorInput()).getFile(); file.setContents(in, true, true, monitor); - for (DiagramEditor2 editor : editors) { + for (DiagramEditor editor : editors) { editor.doSave(monitor); } } catch (Exception e) { @@ -151,7 +151,7 @@ }); // タブに新しいファイル名をセット setInput(new FileEditorInput(file)); - for (DiagramEditor2 editor : editors) { + for (DiagramEditor editor : editors) { editor.doSaveAs(); } } catch (InterruptedException e) { @@ -242,7 +242,7 @@ for (DiagramPresentationModel presentation : rootModel.getAdapter(DiagramPresentations.class)) { // 各タブを生成 try { - DiagramEditor2 editor = new DiagramEditor2(rootModel); + DiagramEditor editor = new DiagramEditor(rootModel); int tabIndex = addPage(editor, getEditorInput()); editor.setTabIndex(tabIndex); setPageText(tabIndex, presentation.getName()); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -18,6 +18,7 @@ */ package org.jiemamy.eclipse.editor.editpart; +import org.apache.commons.lang.Validate; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; @@ -45,27 +46,31 @@ * {@inheritDoc} */ public EditPart createEditPart(EditPart context, Object model) { + Validate.notNull(model); EditPart part; if (model instanceof RootModel) { - part = new RootTreeEditPart((RootModel) model); + RootModel rootModel = (RootModel) model; + part = new RootTreeEditPart(rootModel); } else if (model instanceof ModelContainer) { - part = new ModelContainerEditPart((ModelContainer) model); + ModelContainer modelContainer = (ModelContainer) model; + part = new ModelContainerEditPart(modelContainer); } else if (model instanceof DomainModel) { - part = new DomainTreeEditPart((DomainModel) model); + DomainModel domainModel = (DomainModel) model; + part = new DomainTreeEditPart(domainModel); } else if (model instanceof TableModel) { - part = new TableTreeEditPart(); + TableModel tableModel = (TableModel) model; + part = new TableTreeEditPart(tableModel); } else if (model instanceof AttributeModel) { - part = new AttributeTreeEditPart((AttributeModel) model); + AttributeModel attributeModel = (AttributeModel) model; + part = new AttributeTreeEditPart(attributeModel); } else if (model instanceof ViewModel) { - part = new ViewTreeEditPart((ViewModel) model); + ViewModel viewModel = (ViewModel) model; + part = new ViewTreeEditPart(viewModel); } else { - - throw new UnexpectedConditionError("OutlineTreeEditPartFactory: unknown model: " - + model.getClass().getName()); + throw new UnexpectedConditionError("unknown model: " + model.getClass().getName()); } - part.setModel(model); return part; } } 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -43,7 +43,7 @@ * {@inheritDoc} */ public JiemamyElement getTargetModel() { - NodeAdapter node = (NodeAdapter) getModel(); + NodeAdapter node = getModel(); EntityModel entity = node.unwrap(); return entity; } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractJmNodeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractJmNodeEditPart.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractJmNodeEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -22,7 +22,6 @@ import java.util.List; import org.apache.commons.collections15.IteratorUtils; -import org.eclipse.core.resources.IResource; import org.eclipse.draw2d.ChopboxAnchor; import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.IFigure; @@ -33,15 +32,14 @@ import org.eclipse.gef.RequestConstants; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmComponentEditPolicy; 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; @@ -55,6 +53,8 @@ public abstract class AbstractJmNodeEditPart extends AbstractGraphicalEditPart implements EditDialogSupport, DoubleClickSupport, NodeEditPart, CommandListener { + private static Logger logger = LoggerFactory.getLogger(AbstractJmNodeEditPart.class); + private DirectEditManager directManager = null; @@ -99,6 +99,7 @@ * {@inheritDoc} */ public void doubleClicked() { + logger.info("doubleClicked"); openEditDialog(); } @@ -186,7 +187,7 @@ @SuppressWarnings("unchecked") // TODO キャスト安全性の根拠提示 protected List getModelSourceConnections() { - Collection<ConnectionAdapter> connections = (getModel()).getSourceConnections(); + Collection<ConnectionAdapter> connections = getModel().getSourceConnections(); return IteratorUtils.toList(connections.iterator()); } @@ -204,17 +205,6 @@ /** * 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); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -26,6 +26,8 @@ import org.eclipse.draw2d.PositionConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.jiemamy.eclipse.editor.DisplayPlace; import org.jiemamy.eclipse.editor.DisplayTarget; @@ -43,6 +45,8 @@ */ public class ForeignKeyEditPart extends AbstractJmConnectionEditPart implements EditDialogSupport, DoubleClickSupport { + private static Logger logger = LoggerFactory.getLogger(ForeignKeyEditPart.class); + private Label label; @@ -75,6 +79,8 @@ * {@inheritDoc} */ public void openEditDialog() { + logger.debug("openEditDialog"); + ConnectionAdapter connection = getModel(); ForeignKeyModel fkModel = connection.unwrap(); 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 16:00:11 UTC (rev 2672) +++ 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) @@ -20,7 +20,6 @@ import java.util.List; -import org.eclipse.core.resources.IResource; import org.eclipse.draw2d.ConnectionLayer; import org.eclipse.draw2d.ConnectionRouter; import org.eclipse.draw2d.IFigure; @@ -31,8 +30,6 @@ import org.eclipse.gef.editparts.AbstractGraphicalEditPart; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +38,6 @@ import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmXYLayoutEditPolicy; import org.jiemamy.eclipse.preference.JiemamyPreference; -import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.editcommand.Command; import org.jiemamy.editcommand.CommandListener; import org.jiemamy.model.DiagramPresentationModel; @@ -62,17 +58,6 @@ /** - * TODO for daisuke - * - * @return - */ - protected static IResource getResource() { - IEditorPart editorPart = EditorUtil.getActiveEditor(); - IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput(); - return input.getFile(); - } - - /** * インスタンスを生成する。 * * @param rootModel @@ -139,6 +124,7 @@ * {@inheritDoc} */ public void openEditDialog() { + logger.debug("openEditDialog"); RootModel rootModel = getModel(); // DatabaseEditDialog dialog = new DatabaseEditDialog(getViewer().getControl().getShell(), rootModel); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -70,8 +70,8 @@ * {@inheritDoc} */ public void openEditDialog() { + logger.debug("openEditDialog"); // TODO Dialog open! - logger.debug("Dialog open!"); // StickyModel stickyModel = (StickyModel) getModel(); // 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -24,8 +24,9 @@ import org.eclipse.draw2d.Panel; import org.eclipse.draw2d.StackLayout; import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.NodeEditPart; import org.seasar.eclipse.common.util.LogUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.jiemamy.Migration; import org.jiemamy.eclipse.JiemamyPlugin; @@ -53,8 +54,11 @@ * テーブルモデルに対するDiagram用EditPart(コントローラ)。 * @author daisuke */ -public class TableEditPart extends AbstractEntityEditPart implements NodeEditPart { +public class TableEditPart extends AbstractEntityEditPart { + private static Logger logger = LoggerFactory.getLogger(TableEditPart.class); + + /** * インスタンスを生成する。 * @@ -68,6 +72,8 @@ * {@inheritDoc} */ public void openEditDialog() { + logger.debug("openEditDialog"); + RootModel rootModel = (RootModel) getParent().getModel(); NodeAdapter node = getModel(); TableModel tableModel = (TableModel) node.unwrap(); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -24,7 +24,8 @@ import org.eclipse.draw2d.Panel; import org.eclipse.draw2d.StackLayout; import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.NodeEditPart; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.jiemamy.Migration; import org.jiemamy.eclipse.editor.DisplayPlace; @@ -45,8 +46,11 @@ * * @author daisuke */ -public class ViewEditPart extends AbstractEntityEditPart implements NodeEditPart { +public class ViewEditPart extends AbstractEntityEditPart { + private static Logger logger = LoggerFactory.getLogger(ViewEditPart.class); + + /** * インスタンスを生成する。 * @@ -60,6 +64,8 @@ * {@inheritDoc} */ public void openEditDialog() { + logger.debug("openEditDialog"); + RootModel rootModel = (RootModel) getParent().getModel(); NodeAdapter node = getModel(); ViewModel viewModel = (ViewModel) node.unwrap(); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -18,12 +18,22 @@ */ package org.jiemamy.eclipse.editor.editpart.outlinetree; +import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; +import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.model.entity.EntityModel; /** * {@link EntityModel}に対するTree用EditPart(コントローラ)の抽象クラス。 * @author daisuke */ -public abstract class AbstractEntityTreeEditPart extends AbstractModelTreeEditPart { +public abstract class AbstractEntityTreeEditPart extends AbstractModelTreeEditPart implements EditDialogSupport, + DoubleClickSupport { + /** + * {@inheritDoc} + */ + public void doubleClicked() { + openEditDialog(); + } + } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AttributeTreeEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -23,7 +23,10 @@ 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.editpolicy.JmTreeComponentEditPolicy; +import org.jiemamy.eclipse.editor.utils.LabelStringUtil; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; @@ -87,7 +90,7 @@ RootModel rootModel = (RootModel) getRoot().getContents().getModel(); // ツリー・アイテムのテキストとしてモデルのテキストを設定 -// setWidgetText(rootModel.getDialect().createStringOfDefinitionForTree((DefinitionModel) getModel())); + setWidgetText(LabelStringUtil.getString(rootModel, getModel(), DisplayTarget.NAME, DisplayPlace.OUTLINE_TREE)); 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/ModelContainerEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ModelContainerEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -86,6 +86,7 @@ @Override protected void refreshVisuals() { ModelContainer model = getModel(); + // ツリー・アイテムのテキストとしてモデルのテキストを設定 setWidgetText(model.getName()); 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-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/TableTreeEditPart.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -27,8 +27,6 @@ import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.DisplayPlace; import org.jiemamy.eclipse.editor.DisplayTarget; -import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; -import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; import org.jiemamy.eclipse.editor.editpolicy.JmTreeComponentEditPolicy; import org.jiemamy.eclipse.editor.utils.LabelStringUtil; import org.jiemamy.model.JiemamyElement; @@ -40,20 +38,30 @@ * {@link TableModel}に対するTree用EditPart(コントローラ)。 * @author daisuke */ -public class TableTreeEditPart extends AbstractEntityTreeEditPart implements EditDialogSupport, DoubleClickSupport { +public class TableTreeEditPart extends AbstractEntityTreeEditPart { /** + * インスタンスを生成する。 + * + * @param tableModel + */ + public TableTreeEditPart(TableModel tableModel) { + setModel(tableModel); + } + + /** * {@inheritDoc} */ - public void doubleClicked() { - openEditDialog(); + @Override + public TableModel getModel() { + return (TableModel) super.getModel(); } /** * {@inheritDoc} */ public JiemamyElement getTargetModel() { - TableModel model = (TableModel) getModel(); + TableModel model = getModel(); return model; } @@ -61,7 +69,7 @@ * {@inheritDoc} */ public void openEditDialog() { - TableModel tableModel = (TableModel) getModel(); + TableModel tableModel = getModel(); RootModel rootModel = (RootModel) getRoot().getContents().getModel(); // TableEditDialog dialog = new TableEditDialog(getViewer().getControl().getShell(), tableModel, rootModel); @@ -84,6 +92,18 @@ * {@inheritDoc} */ @Override + public void setModel(Object model) { + if (model instanceof TableModel) { + super.setModel(model); + } else { + throw new IllegalArgumentException(); + } + } + + /** + * {@inheritDoc} + */ + @Override protected void createEditPolicies() { installEditPolicy(EditPolicy.COMPONENT_ROLE, new JmTreeComponentEditPolicy()); } @@ -94,7 +114,7 @@ @Override protected List<AttributeModel> getModelChildren() { // ここで返された子モデルがツリーの子アイテムになる - TableModel tableModel = (TableModel) getModel(); + TableModel tableModel = getModel(); return tableModel.getAttributes(); } @@ -104,7 +124,7 @@ @Override protected void refreshVisuals() { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); - TableModel model = (TableModel) getModel(); + TableModel model = getModel(); // ツリー・アイテムのテキストとしてモデルのテキストを設定 setWidgetText(LabelStringUtil.getString(rootModel, model, DisplayTarget.NAME, DisplayPlace.OUTLINE_TREE)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -27,7 +27,7 @@ import org.jiemamy.model.connection.ConnectionAdapter; /** - * {@link AbstractRelationModel}のEditPolicy。 + * {@link ConnectionAdapter}のEditPolicy。 * @author daisuke */ public class JmRelationEditPolicy extends ConnectionEditPolicy { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/extraprocessor/IsDisplayedProcessor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/extraprocessor/IsDisplayedProcessor.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/extraprocessor/IsDisplayedProcessor.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -18,6 +18,8 @@ */ package org.jiemamy.eclipse.editor.extraprocessor; +import java.util.Set; + import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; import org.jiemamy.model.DiagramPresentationModel.DisplayItem; @@ -48,6 +50,8 @@ * {@inheritDoc} */ public Boolean process(RootModel rootModel) { - return rootModel.getAdapter(DiagramPresentations.class).get(index).getDisplayTargetSet().contains(target); + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + Set<DisplayItem> displayTargetSet = diagramPresentations.get(index).getDisplayTargetSet(); + return displayTargetSet.contains(target); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/utils/LabelStringUtil.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/utils/LabelStringUtil.java 2009-02-15 16:00:11 UTC (rev 2672) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/utils/LabelStringUtil.java 2009-02-15 17:03:03 UTC (rev 2673) @@ -22,7 +22,9 @@ import org.jiemamy.eclipse.editor.DisplayTarget; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; @@ -37,13 +39,28 @@ * TODO for daisuke * * @param rootModel + * @param dataType + * @param displayTarget + * @param place + * @return + */ + public static String getString(RootModel rootModel, DataType dataType, DisplayTarget displayTarget, + DisplayPlace place) { + // TODO Auto-generated method stub + return null; + } + + /** + * TODO for daisuke + * + * @param rootModel * @param targetElement * @param displayTarget - * @param figure + * @param place * @return */ public static String getString(RootModel rootModel, JiemamyElement targetElement, DisplayTarget displayTarget, - DisplayPlace figure) { + DisplayPlace place) { if (targetElement instanceof DomainModel) { DomainModel domainModel = (DomainModel) targetElement; @@ -51,9 +68,22 @@ } else if (targetElement instanceof EntityModel) { EntityModel entityModel = (EntityModel) targetElement; return entityModel.getName(); - } else if (targetElement instanceof AttributeModel) { - AttributeModel attributeModel = (AttributeModel) targetElement; - return attributeModel.getName(); + } else if (targetElement instanceof ColumnModel) { + ColumnModel columnModel = (ColumnModel) targetElement; + if (displayTarget == DisplayTarget.NAME) { + return columnModel.getName(); + } else if (displayTarget == DisplayTarget.TYPE) { + return getString(rootModel, columnModel.getDataType(), displayTarget, place); + } + } else if (targetElement instanceof ForeignKeyModel) { + ForeignKeyModel foreignKeyModel = (ForeignKeyModel) targetElement; + StringBuilder sb = new StringBuilder("FK"); + if (foreignKeyModel.getName() != null) { + sb.append(" ("); + sb.append(foreignKeyModel.getName()); + sb.append(")"); + } + return sb.toString(); } return "unknown"; }