KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > preferences > WorkingSetSettingsTransfer


1 /*******************************************************************************
2  * Copyright (c) 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
12 package org.eclipse.ui.internal.preferences;
13
14 import java.io.File JavaDoc;
15 import java.io.IOException JavaDoc;
16
17 import org.eclipse.core.runtime.IPath;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.Status;
20 import org.eclipse.ui.IWorkingSetManager;
21 import org.eclipse.ui.PlatformUI;
22 import org.eclipse.ui.internal.AbstractWorkingSetManager;
23 import org.eclipse.ui.internal.WorkbenchMessages;
24 import org.eclipse.ui.internal.WorkbenchPlugin;
25 import org.eclipse.ui.internal.WorkingSetManager;
26
27 /**
28  * The WorkingSetSettingsTransfer is the settings transfer for the workbench
29  * working sets.
30  *
31  * @since 3.3
32  *
33  */

34 public class WorkingSetSettingsTransfer extends WorkbenchSettingsTransfer {
35
36     /*
37      * (non-Javadoc)
38      *
39      * @see org.eclipse.ui.preferences.SettingsTransfer#getName()
40      */

41     public String JavaDoc getName() {
42         return WorkbenchMessages.WorkingSets_Name;
43     }
44
45     /*
46      * (non-Javadoc)
47      *
48      * @see org.eclipse.ui.preferences.SettingsTransfer#transferSettings(org.eclipse.core.runtime.IPath)
49      */

50     public IStatus transferSettings(IPath newWorkspaceRoot) {
51         IPath dataLocation = getNewWorkbenchStateLocation(newWorkspaceRoot);
52
53         if (dataLocation == null)
54             return noWorkingSettingsStatus();
55
56         dataLocation = dataLocation
57                 .append(WorkingSetManager.WORKING_SET_STATE_FILENAME);
58
59         File JavaDoc stateFile = new File JavaDoc(dataLocation.toOSString());
60
61         try {
62             IWorkingSetManager manager = PlatformUI.getWorkbench()
63                     .getWorkingSetManager();
64             if (manager instanceof AbstractWorkingSetManager)
65                 ((AbstractWorkingSetManager) manager).saveState(stateFile);
66             else
67                 return new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH,
68                         WorkbenchMessages.WorkingSets_CannotSave);
69         } catch (IOException JavaDoc e) {
70             new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH,
71                     WorkbenchMessages.ProblemSavingWorkingSetState_message, e);
72         }
73         return Status.OK_STATUS;
74
75     }
76 }
77
Popular Tags