1 11 12 package org.eclipse.ui.internal.preferences; 13 14 import java.io.File ; 15 import java.io.IOException ; 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 34 public class WorkingSetSettingsTransfer extends WorkbenchSettingsTransfer { 35 36 41 public String getName() { 42 return WorkbenchMessages.WorkingSets_Name; 43 } 44 45 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 stateFile = new File (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 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 |