KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WorkingSetFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui.internal;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.ui.IElementFactory;
15 import org.eclipse.ui.IMemento;
16
17 /**
18  * A WorkingSetFactory is used to recreate a persisted WorkingSet
19  * object.
20  */

21 public class WorkingSetFactory implements IElementFactory {
22
23     /* (non-Javadoc)
24      * @see org.eclipse.ui.IElementFactory
25      */

26     public IAdaptable createElement(IMemento memento) {
27         String JavaDoc workingSetName = memento.getString(IWorkbenchConstants.TAG_NAME);
28         String JavaDoc label = memento.getString(IWorkbenchConstants.TAG_LABEL);
29         if (label == null) {
30             label = workingSetName;
31         }
32         String JavaDoc workingSetEditPageId = memento
33                 .getString(IWorkbenchConstants.TAG_EDIT_PAGE_ID);
34         String JavaDoc aggregateString = memento
35                 .getString(AbstractWorkingSet.TAG_AGGREGATE);
36         boolean isAggregate = aggregateString != null
37                 && Boolean.valueOf(aggregateString).booleanValue();
38
39         if (workingSetName == null) {
40             return null;
41         }
42
43         AbstractWorkingSet workingSet = null;
44         
45         if (isAggregate) {
46             workingSet = new AggregateWorkingSet(workingSetName, label, memento);
47         } else {
48             workingSet = new WorkingSet(workingSetName, label, memento);
49         }
50         
51         if (workingSetEditPageId != null) {
52             workingSet.setId(workingSetEditPageId);
53         } else if (!isAggregate) {
54             // working sets created with builds 20020418 and 20020419 will not
55
// have an edit page id. fix this automatically.
56
workingSet.setId("org.eclipse.ui.resourceWorkingSetPage"); //$NON-NLS-1$
57
}
58         return workingSet;
59     }
60 }
61
Popular Tags