[Jiemamy-notify:1881] commit [3051] エラーマーカーの表示。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 1日 (水) 18:34:01 JST


Revision: 3051
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3051
Author:   daisuke_m
Date:     2009-04-01 18:34:01 +0900 (Wed, 01 Apr 2009)

Log Message:
-----------
エラーマーカーの表示。

Modified Paths:
--------------
    hestia/trunk/org.jiemamy.eclipse.ui/plugin.xml
    hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java

Added Paths:
-----------
    hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/utils/MarkerUtil.java


-------------- next part --------------
Modified: hestia/trunk/org.jiemamy.eclipse.ui/plugin.xml
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/plugin.xml	2009-04-01 09:33:23 UTC (rev 3050)
+++ hestia/trunk/org.jiemamy.eclipse.ui/plugin.xml	2009-04-01 09:34:01 UTC (rev 3051)
@@ -70,6 +70,17 @@
             name="%plugin.erd.editor"/>
    </extension>
 
+   <extension
+         id="problem"
+         point="org.eclipse.core.resources.markers">
+      <super type="org.eclipse.core.resources.problemmarker"/>
+      <persistent value="true"/>
+      <attribute name="id"/>
+      <attribute name="flags"/>
+      <attribute name="arguments"/>
+      <attribute name="categoryId"/>
+   </extension>
+
 <!--
 
    <extension
@@ -93,17 +104,6 @@
             id="org.jiemamy.eclipse.view.record"
             name="%plugin.view.record"/>
    </extension>
-   <extension
-         id="problem"
-         point="org.eclipse.core.resources.markers">
-      <super type="org.eclipse.core.resources.problemmarker"/>
-      <persistent value="true"/>
-      <attribute name="id"/>
-      <attribute name="flags"/>
-      <attribute name="arguments"/>
-      <attribute name="categoryId"/>
-   </extension>
-
 -->
 
 </plugin>

Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java	2009-04-01 09:33:23 UTC (rev 3050)
+++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java	2009-04-01 09:34:01 UTC (rev 3051)
@@ -27,6 +27,8 @@
 
 import org.apache.commons.io.IOUtils;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -94,34 +96,42 @@
 import org.jiemamy.DispatchStrategy;
 import org.jiemamy.Jiemamy;
 import org.jiemamy.JiemamyFactory;
+import org.jiemamy.dialect.Dialect;
 import org.jiemamy.eclipse.EclipseDialectProvider;
+import org.jiemamy.eclipse.JiemamyCorePlugin;
 import org.jiemamy.eclipse.editor.editpart.DiagramEditPartFactory;
 import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory;
 import org.jiemamy.eclipse.utils.ExceptionHandler;
+import org.jiemamy.eclipse.utils.MarkerUtil;
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandListener;
 import org.jiemamy.internal.EventBrokerImpl;
 import org.jiemamy.model.DiagramPresentationModel;
 import org.jiemamy.model.DiagramPresentations;
+import org.jiemamy.model.JiemamyElement;
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.entity.EntityModel;
 import org.jiemamy.serializer.SerializationException;
 import org.jiemamy.utils.CollectionsUtil;
 import org.jiemamy.utils.LogMarker;
 import org.jiemamy.utils.model.RootModelUtil;
+import org.jiemamy.validator.Problem;
+import org.jiemamy.validator.Validator;
+import org.jiemamy.validator.Problem.Severity;
 
 /**
  * ERダイアグラムエディタ。
  * 
  * @author daisuke
  */
-public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener, JiemamyEditor {
-
+public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener,
+		CommandListener, JiemamyEditor {
+	
 	private static Logger logger = LoggerFactory.getLogger(DiagramEditor.class);
-
+	
 	/** Palette component, holding the tools and shapes. */
 	private static PaletteRoot paletteModel;
-
+	
 	/** zoom level */
 	private static final double[] ZOOM_LEVELS = new double[] {
 		0.1,
@@ -142,21 +152,34 @@
 		7.0,
 		10.0
 	};
+	
 
+	private static int findSeverity(Severity severity) {
+		if (severity == Severity.ERROR || severity == Severity.FATAL) {
+			return IMarker.SEVERITY_ERROR;
+		} else if (severity == Severity.WARN) {
+			return IMarker.SEVERITY_WARNING;
+		} else if (severity == Severity.INFO || severity == Severity.NOTICE) {
+			return IMarker.SEVERITY_INFO;
+		}
+		return -1;
+	}
+	
+
 	/** ルートEditPart(コントローラ) */
 	private ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
-
+	
 	/** エディタのルートモデル */
 	private RootModel rootModel;
-
+	
 	private boolean savePreviouslyNeeded = false;
-
+	
 	private Jiemamy jiemamy;
-
+	
 	/** このエディタのタブインデックス */
 	private int tabIndex;
+	
 
-
 	/**
 	 * インスタンスを生成する。
 	 */
@@ -165,7 +188,7 @@
 		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
 		logger.debug(LogMarker.LIFECYCLE, "constructed - single");
 	}
-
+	
 	/**
 	 * インスタンスを生成する。
 	 * 
@@ -176,7 +199,24 @@
 		this.tabIndex = tabIndex;
 		logger.debug(LogMarker.LIFECYCLE, "constructed - multi");
 	}
-
+	
+	public void commandExecuted(Command command) {
+		Dialect dialect;
+		try {
+			dialect = jiemamy.getDialect(rootModel);
+		} catch (ClassNotFoundException e) {
+			dialect = JiemamyCorePlugin.getDialectResolver().getAllInstance().get(0);
+		}
+		Validator validator = dialect.getValidator();
+		IResource resource = (IResource) getEditorInput().getAdapter(IResource.class);
+		MarkerUtil.deleteAllMarkers();
+		for (Problem problem : validator.validate(rootModel)) {
+			Severity severity = problem.getSeverity();
+			String message = problem.getMessage();
+			MarkerUtil.createMarker(resource, IMarker.PRIORITY_NORMAL, findSeverity(severity), message);
+		}
+	}
+	
 	@Override
 	public void commandStackChanged(EventObject event) {
 		if (isDirty()) {
@@ -190,20 +230,21 @@
 		}
 		super.commandStackChanged(event);
 	}
-
+	
 	@Override
 	public void dispose() {
+		jiemamy.getEventBroker().removeListener(this);
 		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
 		super.dispose();
 		logger.debug(LogMarker.LIFECYCLE, "disposed");
-
+		
 		// FIXME 以下debugコード
 		List<CommandListener> listeners = ((EventBrokerImpl) jiemamy.getEventBroker()).getListeners();
 		for (CommandListener listener : listeners) {
 			logger.warn(listener + " is not removed from EventBroker.");
 		}
 	}
-
+	
 	@Override
 	public void doSave(IProgressMonitor monitor) {
 		ByteArrayOutputStream out = null;
@@ -211,7 +252,7 @@
 		try {
 			out = new ByteArrayOutputStream();
 			jiemamy.getSerializer().serialize(rootModel, out);
-
+			
 			in = new ByteArrayInputStream(out.toByteArray());
 			IFile file = ((IFileEditorInput) getEditorInput()).getFile();
 			file.setContents(in, true, true, monitor);
@@ -223,44 +264,44 @@
 			IOUtils.closeQuietly(out);
 		}
 	}
-
+	
 	@Override
 	public void doSaveAs() {
 		Shell shell = getSite().getWorkbenchWindow().getShell();
 		SaveAsDialog dialog = new SaveAsDialog(shell);
 		dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
 		dialog.open();
-
+		
 		IPath path = dialog.getResult();
 		if (path == null) {
 			return;
 		}
-
+		
 		// try to save the editor's contents under a different file name
 		final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
 		try {
 			new ProgressMonitorDialog(shell).run(false, // don't fork
 					false, // not cancelable
 					new WorkspaceModifyOperation() { // run this operation
-
-				@Override
-				public void execute(IProgressMonitor monitor) {
-					ByteArrayOutputStream out = null;
-					ByteArrayInputStream in = null;
-					try {
-						out = new ByteArrayOutputStream();
-						jiemamy.getSerializer().serialize(rootModel, out);
-
-						in = new ByteArrayInputStream(out.toByteArray());
-						file.create(in, true, monitor);
-					} catch (Exception e) {
-						ExceptionHandler.handleException(e);
-					} finally {
-						IOUtils.closeQuietly(in);
-						IOUtils.closeQuietly(out);
-					}
-				}
-			});
+					
+						@Override
+						public void execute(IProgressMonitor monitor) {
+							ByteArrayOutputStream out = null;
+							ByteArrayInputStream in = null;
+							try {
+								out = new ByteArrayOutputStream();
+								jiemamy.getSerializer().serialize(rootModel, out);
+								
+								in = new ByteArrayInputStream(out.toByteArray());
+								file.create(in, true, monitor);
+							} catch (Exception e) {
+								ExceptionHandler.handleException(e);
+							} finally {
+								IOUtils.closeQuietly(in);
+								IOUtils.closeQuietly(out);
+							}
+						}
+					});
 			setInput(new FileEditorInput(file));
 			getCommandStack().markSaveLocation();
 		} catch (InterruptedException e) {
@@ -270,7 +311,7 @@
 			ExceptionHandler.handleException(e);
 		}
 	}
-
+	
 	@Override
 	@SuppressWarnings("unchecked")
 	// Java1.4対応APIのため、Classに型パラメータをつけることができない
@@ -282,7 +323,7 @@
 		}
 		return super.getAdapter(adapter);
 	}
-
+	
 	/**
 	 * {@link RootModel}を取得する。
 	 * 
@@ -291,7 +332,7 @@
 	public RootModel getRootModel() {
 		return rootModel;
 	}
-
+	
 	/**
 	 * このエディタのタブインデックスを取得する。
 	 * 
@@ -300,30 +341,35 @@
 	public int getTabIndex() {
 		return tabIndex;
 	}
-
+	
+	public JiemamyElement getTargetModel() {
+		return rootModel;
+	}
+	
 	@Override
 	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
 		super.init(site, input);
-
+		
 		jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new EclipseDialectProvider());
-
+		
 		// FIXME 無差別ディスパッチになってる。
 		jiemamy.getEventBroker().setStrategy(new DispatchStrategy() {
-
+			
 			public boolean needToDispatch(CommandListener listener, Command command) {
 				return true;
 			}
-
+			
 		});
-
+		jiemamy.getEventBroker().addListener(this);
+		
 		logger.debug(LogMarker.LIFECYCLE, "initialized");
 	}
-
+	
 	@Override
 	public boolean isSaveAsAllowed() {
 		return true;
 	}
-
+	
 	/**
 	 * エディタ外などからの、リソースの変更を検知する。
 	 * {@inheritDoc}
@@ -333,7 +379,7 @@
 			final IEditorInput input = getEditorInput();
 			if (input instanceof IFileEditorInput) {
 				Display.getDefault().asyncExec(new Runnable() {
-
+					
 					public void run() {
 						IFile file = ((IFileEditorInput) input).getFile();
 						if (!file.exists()) {
@@ -347,7 +393,7 @@
 			}
 		}
 	}
-
+	
 	@Override
 	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
 		if (part.getSite().getWorkbenchWindow().getActivePage() == null) {
@@ -355,17 +401,17 @@
 		}
 		super.selectionChanged(part, selection);
 	}
-
+	
 	@Override
 	public void setFocus() {
 		super.setFocus();
-
+		
 		JmContributor contributor = (JmContributor) getEditorSite().getActionBarContributor();
 		contributor.selectCombo(rootModel);
 		// Thanks to Naokiさん
 		logger.debug(LogMarker.LIFECYCLE, "setFocus");
 	}
-
+	
 	/**
 	 * このエディタのタブインデックスを設定する。
 	 * 
@@ -374,125 +420,125 @@
 	public void setTabIndex(int tabIndex) {
 		this.tabIndex = tabIndex;
 	}
-
+	
 	@Override
 	protected void configureGraphicalViewer() {
 		super.configureGraphicalViewer();
-
+		
 		// EditPartFactoryの作成と設定
 		GraphicalViewer viewer = getGraphicalViewer();
 		viewer.setEditPartFactory(new DiagramEditPartFactory());
 		viewer.setRootEditPart(rootEditPart);
-
+		
 		ActionRegistry actionRegistry = getActionRegistry();
-
+		
 		// 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, actionRegistry));
 		getSite().setSelectionProvider(viewer);
 	}
-
+	
 	@Override
 	protected void createActions() {
 		super.createActions();
-
+		
 		IAction action;
 		ActionRegistry actionRegistry = getActionRegistry();
 		IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
-
+		
 		// ZoomManager
 		ZoomManager zoomManager = rootEditPart.getZoomManager();
-
+		
 		// zoom contribution
 		List<String> zoomContributions = CollectionsUtil.newArrayList(3);
 		zoomContributions.add(ZoomManager.FIT_ALL);
 		zoomContributions.add(ZoomManager.FIT_HEIGHT);
 		zoomContributions.add(ZoomManager.FIT_WIDTH);
 		zoomManager.setZoomLevelContributions(zoomContributions);
-
+		
 		zoomManager.setZoomLevels(ZOOM_LEVELS);
-
+		
 		// このメソッドはString型のリストを返すことが保証されている
 		@SuppressWarnings("unchecked")
 		List<String> selectionActions = getSelectionActions();
-
+		
 		// zoom level contribution
 		action = new ZoomInAction(zoomManager);
 		actionRegistry.registerAction(action);
 		handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
 		selectionActions.add(action.getId());
-
+		
 		action = new ZoomOutAction(zoomManager);
 		actionRegistry.registerAction(action);
 		handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
 		selectionActions.add(action.getId());
-
+		
 		// select action
 		action = new SelectAllAction(this);
 		actionRegistry.registerAction(action);
-
+		
 		// match size contribution
 		action = new MatchWidthAction(this);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new MatchHeightAction(this);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		// direct edit contribution
 		action = new DirectEditAction((IWorkbenchPart) this);
 		actionRegistry.registerAction(action);
 		// 選択オブジェクトによってアクションを更新する必要がある場合には
 		// 以下のようにして、そのアクションのIDを登録しておく
 		selectionActions.add(action.getId());
-
+		
 		// alignment contribution
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
-
+		
 		action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
 		actionRegistry.registerAction(action);
 		selectionActions.add(action.getId());
 	}
-
+	
 	@Override
 	protected PaletteRoot getPaletteRoot() {
 		if (paletteModel == null) {
 			paletteModel = DiagramEditorPaletteFactory.createPalette();
 		}
-
+		
 		return paletteModel;
 	}
-
+	
 	@Override
 	protected void initializeGraphicalViewer() {
 		super.initializeGraphicalViewer();
-
+		
 		GraphicalViewer viewer = getGraphicalViewer();
-
+		
 		// 最上位モデルの設定
 		IFile file = ((IFileEditorInput) getEditorInput()).getFile();
 		try {
@@ -502,7 +548,7 @@
 			ExceptionHandler.handleException(e, "Data file is broken.");
 		} catch (CoreException e) {
 			ExceptionHandler.handleException(e, ExceptionHandler.DIALOG,
-			"May be, resource is not synchronized.  Try to hit F5 to refresh workspace.");
+					"May be, resource is not synchronized.  Try to hit F5 to refresh workspace.");
 		} catch (Exception e) {
 			ExceptionHandler.handleException(e);
 		} finally {
@@ -517,47 +563,50 @@
 				diagramPresentations.add(presentationModel);
 			}
 		}
-
+		
+		// 初回のバリデータ起動
+		commandExecuted(null);
+		
 		SortedSet<EntityModel> entities = rootModel.getEntities();
 		for (EntityModel entityModel : entities) {
 			entityModel.registerAdapter(new EntityPropertySource(entityModel));
-			//			if (entityModel instanceof TableModel) {
-			//				entityModel.registerAdapter(new RepresentationAdapter());
-			//			}
+//			if (entityModel instanceof TableModel) {
+//				entityModel.registerAdapter(new RepresentationAdapter());
+//			}
 		}
-
+		
 		viewer.setContents(rootModel);
 	}
-
+	
 	@Override
 	protected void setInput(IEditorInput input) {
 		super.setInput(input);
-
+		
 		// タブにファイル名をセット
 		setPartName(input.getName());
 	}
+	
 
-
 	/**
 	 * アウトラインビューのページクラス。
 	 * @author daisuke
 	 */
 	private class DiagramOutlinePage extends org.eclipse.gef.ui.parts.ContentOutlinePage {
-
+		
 		/** ページをアウトラインとサムネイルに分離するコンポーネント */
 		private SashForm sash;
-
+		
 		/** サムネイル */
 		private Canvas overview;
-
+		
 		/** サムネイルを表示する為のフィギュア */
 		private ScrollableThumbnail thumbnail;
-
+		
 		private DisposeListener disposeListener;
-
+		
 		private final EditPartViewer viewer;
+		
 
-
 		/**
 		 * インスタンスを生成する。
 		 * 
@@ -567,32 +616,32 @@
 			super(viewer);
 			this.viewer = viewer;
 		}
-
+		
 		@Override
 		public void createControl(Composite parent) {
 			sash = new SashForm(parent, SWT.VERTICAL);
-
+			
 			// sash上にコンストラクタで指定したビューワの作成
 			viewer.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) {
@@ -604,26 +653,26 @@
 			// グラフィカル・ビューワが破棄されるときにサムネイルも破棄する
 			getGraphicalViewer().getControl().addDisposeListener(disposeListener);
 		}
-
+		
 		@Override
 		public void dispose() {
 			SelectionSynchronizer selectionSynchronizer = getSelectionSynchronizer();
 			// SelectionSynchronizer からTreeViewerを削除
 			selectionSynchronizer.removeViewer(viewer);
-
+			
 			Control control = getGraphicalViewer().getControl();
 			if (control != null && control.isDisposed() == false) {
 				control.removeDisposeListener(disposeListener);
 			}
-
+			
 			super.dispose();
 		}
-
+		
 		@Override
 		public Control getControl() {
 			return sash;
 		}
-
+		
 		@Override
 		public void init(IPageSite pageSite) {
 			super.init(pageSite);
@@ -631,20 +680,20 @@
 			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 設定するコンテンツ
@@ -652,21 +701,21 @@
 		public void setContents(Object contents) {
 			viewer.setContents(contents);
 		}
-
+		
 		/**
 		 * アウトラインビュアーの設定を行う。
 		 */
 		protected void configureOutlineViewer() {
 			// エディット・ドメインの設定
 			viewer.setEditDomain(getEditDomain());
-
+			
 			// EditPartFactory の設定
 			viewer.setEditPartFactory(new OutlineTreeEditPartFactory());
-
+			
 			// THINK ContextMenuの設定
 			// THINK ToolBarManagerの設定
 		}
-
+		
 		/**
 		 * アウトラインビュアー設定用のフックメソッド。
 		 */
@@ -675,7 +724,7 @@
 			SelectionSynchronizer selectionSynchronizer = getSelectionSynchronizer();
 			selectionSynchronizer.addViewer(getViewer());
 		}
-
+		
 		/**
 		 * アウトラインビュアーを初期化する。
 		 */

Added: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/utils/MarkerUtil.java
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/utils/MarkerUtil.java	                        (rev 0)
+++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/utils/MarkerUtil.java	2009-04-01 09:34:01 UTC (rev 3051)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/01
+ *
+ * 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.utils;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+import org.jiemamy.eclipse.JiemamyUIPlugin;
+
+/**
+ * TODO describe
+ * 
+ * @author daisuke
+ */
+public final class MarkerUtil {
+	
+	/** TODO for daisuke */
+	public static final String MARKER_ID = JiemamyUIPlugin.PLUGIN_ID + ".problem";
+	
+
+//	public static final String MARKER_ATTR_TARGET = "targetModel";
+//	
+//	public static final String MARKER_ATTR_CATEGORY = "category";
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param resource
+	 * @param priority
+	 * @param severity
+	 * @param message
+	 */
+	public static void createMarker(IResource resource, int priority, int severity, String message) {
+		if (resource == null) {
+			return;
+		}
+		try {
+			IMarker marker = resource.createMarker(MARKER_ID);
+			Map<String, Object> attributes = new HashMap<String, Object>(3);
+			attributes.put(IMarker.PRIORITY, priority);
+			attributes.put(IMarker.SEVERITY, severity);
+//				attributes.put(IMarker.LINE_NUMBER, line);
+//				attributes.put(MARKER_ATTR_TARGET, target);
+//				attributes.put(MARKER_ATTR_CATEGORY, category);
+			attributes.put(IMarker.MESSAGE, message);
+			marker.setAttributes(attributes);
+		} catch (CoreException e) {
+			ExceptionHandler.handleException(e, ExceptionHandler.ALL);
+		}
+	}
+	
+	/**
+	 * TODO for daisuke
+	 */
+	public static void deleteAllMarkers() {
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		deleteMarker(root);
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param resource
+	 */
+	public static void deleteMarker(IResource resource) {
+		if (resource == null) {
+			return;
+		}
+		try {
+			resource.deleteMarkers(MARKER_ID, true, IResource.DEPTH_INFINITE);
+		} catch (CoreException e) {
+			ExceptionHandler.handleException(e, ExceptionHandler.ALL);
+		}
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param resource
+	 */
+	public static void deleteMarkers(IResource resource) {
+		for (IMarker marker : findMarker(resource)) {
+			try {
+				marker.delete();
+			} catch (CoreException e) {
+				ExceptionHandler.handleException(e, ExceptionHandler.ALL);
+			}
+		}
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param resource
+	 * @return
+	 */
+	public static IMarker[] findMarker(IResource resource) {
+		if (resource == null) {
+			return new IMarker[0];
+		}
+		try {
+			return resource.findMarkers(MARKER_ID, true, IResource.DEPTH_INFINITE);
+		} catch (CoreException e) {
+			ExceptionHandler.handleException(e, ExceptionHandler.ALL);
+		}
+		return new IMarker[0];
+	}
+	
+	private MarkerUtil() {
+	}
+	
+}


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



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