svnno****@sourc*****
svnno****@sourc*****
2009年 3月 2日 (月) 01:44:02 JST
Revision: 2770 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2770 Author: daisuke_m Date: 2009-03-02 01:44:01 +0900 (Mon, 02 Mar 2009) Log Message: ----------- save, rollbackメカニズムのガワだけ作った。 / refactor Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.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/JiemamyEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/SavePointImpl.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-01 16:41:22 UTC (rev 2769) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -74,6 +74,7 @@ AddEntityToRootCommand command = new AddEntityToRootCommand(jiemamy.getFactory().getRootModel(), entity); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); + redoStack.clear(); } /** @@ -86,10 +87,11 @@ AddForeignKeyCommand command = new AddForeignKeyCommand(table, foreignKey); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); + redoStack.clear(); } /** - * TODO for daisuke + * @deprecated use {@link #rollback(SavePointImpl)} */ @Deprecated public void redo() { @@ -111,6 +113,7 @@ new DeleteEntityFromRootCommand(jiemamy.getFactory().getRootModel(), entity); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); + redoStack.clear(); } /** @@ -123,11 +126,31 @@ DeleteForeignKeyCommand command = new DeleteForeignKeyCommand(table, foreignKey); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); + redoStack.clear(); } /** - * TODO for daisuke + * モデルの状態をセーブポイントまでロールバックする。 + * + * @param savePoint セーブポイント */ + public void rollback(SavePointImpl savePoint) { + // TODO Auto-generated method stub + } + + /** + * 現在のモデルの状態にロールバックするためのセーブポイントを取得する。 + * + * @return セーブポイント + */ + public SavePointImpl save() { + // TODO Auto-generated method stub + return null; + } + + /** + * @deprecated use {@link #rollback(SavePointImpl)} + */ @Deprecated public void undo() { if (undoStack.isEmpty()) { Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/SavePointImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/SavePointImpl.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/SavePointImpl.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -0,0 +1,29 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/02 + * + * 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.facade; + +/** + * セーブポイント情報を保持するクラス。 + * + * @see JiemamyFacadeImpl#rollback(SavePointImpl) + * @author daisuke + */ +public class SavePointImpl { + // UNDONE +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/SavePointImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java 2009-03-01 16:41:22 UTC (rev 2769) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -75,7 +75,7 @@ Command command = new AddConnectionViewCommand(rootModel, diagramIndex, connectionAdapter, connectionProfile); command.execute(commandProcessor); undoStack.push(command.getNegateCommand()); - redoStack.push(command); + redoStack.clear(); } /** @@ -90,7 +90,7 @@ Command command = new AddNodeViewCommand(rootModel, diagramIndex, nodeAdapter, nodeProfile); command.execute(commandProcessor); undoStack.push(command.getNegateCommand()); - redoStack.push(command); + redoStack.clear(); } /** @@ -114,7 +114,7 @@ new ModifyModelPropertyCommand<NodeProfile>(nodeProfile, NodeProfileProperty.boundary, boundary); redoCommand.execute(commandProcessor); undoStack.push(redoCommand.getNegateCommand()); - redoStack.push(redoCommand); + redoStack.clear(); } /** @@ -128,7 +128,7 @@ Command command = new DeleteConnectionViewCommand(rootModel, diagramIndex, connectionAdapter); command.execute(commandProcessor); undoStack.push(command.getNegateCommand()); - redoStack.push(command); + redoStack.clear(); } /** @@ -142,7 +142,7 @@ Command command = new DeleteNodeViewCommand(rootModel, diagramIndex, nodeAdapter); command.execute(commandProcessor); undoStack.push(command.getNegateCommand()); - redoStack.push(command); + redoStack.clear(); } @Override Modified: artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java =================================================================== --- artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java 2009-03-01 16:41:22 UTC (rev 2769) +++ artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -106,10 +106,10 @@ assertThat(nodeProfile.getBoundary(), is(rectangle)); viewFacade.undo(); - assertThat(nodeProfile.getBoundary(), nullValue()); + assertThat(nodeProfile.getBoundary(), is(nullValue())); viewFacade.undo(); - assertThat(diagramPresentationModel.getFigureProfiles().get(nodeAdapter), nullValue()); + assertThat(diagramPresentationModel.getFigureProfiles().get(nodeAdapter), is(nullValue())); viewFacade.undo(); assertThat(rootModel.getEntities().contains(tableModel), is(false)); 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-03-01 16:41:22 UTC (rev 2769) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -21,7 +21,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import java.util.EventObject; import java.util.List; @@ -85,6 +84,7 @@ import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.IPageSite; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,6 +92,7 @@ import org.jiemamy.ArtemisView; import org.jiemamy.DispatchStrategy; import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; import org.jiemamy.eclipse.EclipseDialectProvider; import org.jiemamy.eclipse.editor.editpart.DiagramEditPartFactory; import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory; @@ -101,6 +102,7 @@ import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; +import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.LogMarker; import org.jiemamy.utils.model.RootModelUtil; @@ -167,7 +169,6 @@ * @param tabIndex */ public DiagramEditor(RootModel rootModel, int tabIndex) { - // TODO Auto-generated constructor stub this.tabIndex = tabIndex; logger.debug(LogMarker.LIFECYCLE, "constructed - multi"); } @@ -221,7 +222,7 @@ dialog.open(); IPath path = dialog.getResult(); - if (path != null) { + if (path == null) { return; } @@ -266,8 +267,8 @@ 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ツリービューワを使用 + } else if (adapter == IContentOutlinePage.class) { + return new DiagramOutlinePage(new org.eclipse.gef.ui.parts.TreeViewer()); // GEFツリービューワを使用 } return super.getAdapter(adapter); } @@ -373,17 +374,16 @@ 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())); + ActionRegistry actionRegistry = getActionRegistry(); - keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT)); - + // to make 'del' and 'f2' key work + GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer); + keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), actionRegistry.getAction(ActionFactory.DELETE.getId())); + keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), actionRegistry.getAction(GEFActionConstants.DIRECT_EDIT)); viewer.setKeyHandler(keyHandler); // configure the context menu provider - viewer.setContextMenu(new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry())); + viewer.setContextMenu(new DiagramEditorContextMenuProvider(viewer, this, actionRegistry)); getSite().setSelectionProvider(viewer); } @@ -391,15 +391,15 @@ protected void createActions() { super.createActions(); - ActionRegistry registry = getActionRegistry(); IAction action; + ActionRegistry actionRegistry = getActionRegistry(); IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); // ZoomManager ZoomManager zoomManager = rootEditPart.getZoomManager(); // zoom contribution - List<String> zoomContributions = new ArrayList<String>(3); + List<String> zoomContributions = CollectionsUtil.newArrayList(3); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); @@ -407,64 +407,64 @@ zoomManager.setZoomLevels(ZOOM_LEVELS); + // このメソッドはString型のリストを返すことが保証されている @SuppressWarnings("unchecked") - // TODO キャスト安全性の根拠提示 List<String> selectionActions = getSelectionActions(); // zoom level contribution action = new ZoomInAction(zoomManager); - registry.registerAction(action); + actionRegistry.registerAction(action); handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action)); selectionActions.add(action.getId()); action = new ZoomOutAction(zoomManager); - registry.registerAction(action); + actionRegistry.registerAction(action); handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action)); selectionActions.add(action.getId()); // select action action = new SelectAllAction(this); - registry.registerAction(action); + actionRegistry.registerAction(action); // match size contribution action = new MatchWidthAction(this); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new MatchHeightAction(this); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); // direct edit contribution action = new DirectEditAction((IWorkbenchPart) this); - registry.registerAction(action); + actionRegistry.registerAction(action); // 選択オブジェクトによってアクションを更新する必要がある場合には // 以下のようにして、そのアクションのIDを登録しておく selectionActions.add(action.getId()); // alignment contribution action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE); - registry.registerAction(action); + actionRegistry.registerAction(action); selectionActions.add(action.getId()); } @@ -493,16 +493,15 @@ } catch (Exception e) { ExceptionHandler.handleException(e); } finally { + JiemamyFactory factory = jiemamy.getFactory(); if (rootModel == null) { - rootModel = jiemamy.getFactory().getRootModel(); + rootModel = factory.getRootModel(); } DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); - if (diagramPresentations.size() == 0) { - DiagramPresentationModel presentationModel = - rootModel.getJiemamy().getFactory().newModel(DiagramPresentationModel.class); + if (diagramPresentations.size() < 1) { + DiagramPresentationModel presentationModel = factory.newModel(DiagramPresentationModel.class); presentationModel.setName("default"); diagramPresentations.add(presentationModel); - } } viewer.setContents(rootModel); @@ -551,7 +550,7 @@ sash = new SashForm(parent, SWT.VERTICAL); // sash上にコンストラクタで指定したビューワの作成 - Control outline = viewer.createControl(sash); + viewer.createControl(sash); configureOutlineViewer(); hookOutlineViewer(); Modified: 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 2009-03-01 16:41:22 UTC (rev 2769) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JiemamyEditor.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -31,6 +31,7 @@ /** * {@link RootModel}を取得する。 + * * @return エディタのルートモデル */ RootModel getRootModel(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2009-03-01 16:41:22 UTC (rev 2769) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2009-03-01 16:44:01 UTC (rev 2770) @@ -24,7 +24,6 @@ import org.apache.commons.io.IOUtils; import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.INewWizard; @@ -50,7 +49,7 @@ private IWorkbench workbench; - private ISelection selection; + private IStructuredSelection selection; /** @@ -63,7 +62,7 @@ @Override public void addPages() { - page = new NewDiagramWizardPage((IStructuredSelection) selection); + page = new NewDiagramWizardPage(selection); addPage(page); } @@ -144,6 +143,9 @@ if (getFileExtension() == null) { setFileExtension("jer"); } + if (getFileExtension().equals("jer") == false) { + return false; + } return super.validatePage(); } }