KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > breakpoints > BreakpointPersistableElementAdapter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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.debug.core.model.IBreakpoint;
16 import org.eclipse.ui.IMemento;
17 import org.eclipse.ui.IPersistableElement;
18
19 /**
20  * Adapter to save and restore breakpoints for a working set.
21  */

22 public class BreakpointPersistableElementAdapter implements IPersistableElement {
23     
24     private IBreakpoint fBreakpoint;
25     
26     public static final String JavaDoc TAG_MARKER_ID = "TAG_MARKER_ID"; //$NON-NLS-1$
27
public static final String JavaDoc TAG_RESOURCE_FACTORY_ID = "TAG_RESOURCE_FACTORY_ID"; //$NON-NLS-1$
28

29     /**
30      * Constructs a new persitable element adapter for the given breakpoint.
31      *
32      * @param breakpoint
33      */

34     public BreakpointPersistableElementAdapter(IBreakpoint breakpoint) {
35         fBreakpoint = breakpoint;
36     }
37
38     /* (non-Javadoc)
39      * @see org.eclipse.ui.IPersistableElement#getFactoryId()
40      */

41     public String JavaDoc getFactoryId() {
42         return "org.eclipse.debug.ui.elementFactory.breakpoints"; //$NON-NLS-1$
43
}
44
45     /* (non-Javadoc)
46      * @see org.eclipse.ui.IPersistableElement#saveState(org.eclipse.ui.IMemento)
47      */

48     public void saveState(IMemento memento) {
49         IMarker marker = fBreakpoint.getMarker();
50         if (marker != null) {
51             IResource resource = marker.getResource();
52             IPersistableElement pe = (IPersistableElement) resource.getAdapter(IPersistableElement.class);
53             if (pe != null) {
54                 long id = marker.getId();
55                 String JavaDoc longString = Long.toString(id);
56                 memento.putString(TAG_MARKER_ID, longString);
57                 memento.putString(TAG_RESOURCE_FACTORY_ID, pe.getFactoryId());
58                 pe.saveState(memento);
59             }
60         }
61     }
62
63 }
64
Popular Tags