1 11 package org.eclipse.debug.internal.ui.views.breakpoints; 12 13 import org.eclipse.core.resources.IMarker; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.debug.core.DebugPlugin; 18 import org.eclipse.ui.IElementFactory; 19 import org.eclipse.ui.IMemento; 20 import org.eclipse.ui.PlatformUI; 21 22 25 public class BreakpointFactory implements IElementFactory { 26 27 30 public IAdaptable createElement(IMemento memento) { 31 String longString = memento.getString(BreakpointPersistableElementAdapter.TAG_MARKER_ID); 32 String factoryId = memento.getString(BreakpointPersistableElementAdapter.TAG_RESOURCE_FACTORY_ID); 33 if (factoryId != null && longString != null) { 34 IElementFactory elementFactory = PlatformUI.getWorkbench().getElementFactory(factoryId); 35 if (elementFactory != null) { 36 IAdaptable adaptable = elementFactory.createElement(memento); 37 if (adaptable instanceof IResource) { 38 IResource resource = (IResource) adaptable; 39 try { 40 long id = Long.parseLong(longString); 41 IMarker marker = resource.findMarker(id); 42 if (marker != null) { 43 return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); 44 } 45 } catch (NumberFormatException e) { 46 } catch (CoreException e) { 47 } 48 } 49 } 50 } 51 return null; 52 } 53 54 } 55 | Popular Tags |