private void xmlReadRefactoring(JarPackageData jarPackage, Element element) throws java.io.IOException { if (element.getNodeName().equals("storedRefactorings")) { // $NON-NLS-1$ jarPackage.setExportStructuralOnly( getBooleanAttribute( element, "structuralOnly", jarPackage.isExportStructuralOnly())); // $NON-NLS-1$ jarPackage.setDeprecationAware( getBooleanAttribute( element, "deprecationInfo", jarPackage.isDeprecationAware())); // $NON-NLS-1$ List<IAdaptable> elements = new ArrayList<IAdaptable>(); int count = 1; String value = element.getAttribute("project" + count); // $NON-NLS-1$ while (value != null && !"".equals(value)) { // $NON-NLS-1$ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(value); if (project.exists()) elements.add(project); count++; value = element.getAttribute("project" + count); // $NON-NLS-1$ } jarPackage.setRefactoringProjects(elements.toArray(new IProject[elements.size()])); elements.clear(); count = 1; IRefactoringHistoryService service = RefactoringCore.getHistoryService(); try { service.connect(); value = element.getAttribute("refactoring" + count); // $NON-NLS-1$ while (value != null && !"".equals(value)) { // $NON-NLS-1$ final ByteArrayInputStream stream = new ByteArrayInputStream(value.getBytes("UTF-8")); // $NON-NLS-1$ try { final RefactoringHistory history = service.readRefactoringHistory(stream, RefactoringDescriptor.NONE); if (history != null) { final RefactoringDescriptorProxy[] descriptors = history.getDescriptors(); if (descriptors.length > 0) { for (int index = 0; index < descriptors.length; index++) { elements.add(descriptors[index]); } } } } catch (CoreException exception) { JavaPlugin.log(exception); } count++; value = element.getAttribute("refactoring" + count); // $NON-NLS-1$ } } finally { service.disconnect(); } jarPackage.setRefactoringDescriptors( elements.toArray(new RefactoringDescriptorProxy[elements.size()])); } }
/** {@inheritDoc} */ protected void buttonPressed(final int buttonId) { if (buttonId == IDialogConstants.OK_ID) { fData.setRefactoringAware(true); final RefactoringDescriptorProxy[] descriptors = fHistoryControl.getCheckedDescriptors(); Set set = new HashSet(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (int index = 0; index < descriptors.length; index++) { final String project = descriptors[index].getProject(); if (project != null && !"".equals(project)) // $NON-NLS-1$ set.add(root.getProject(project)); } fData.setRefactoringProjects((IProject[]) set.toArray(new IProject[set.size()])); fData.setRefactoringDescriptors(descriptors); fData.setExportStructuralOnly(fExportStructural.getSelection()); final IDialogSettings settings = fSettings; if (settings != null) settings.put(SETTING_SORT, fHistoryControl.isSortByProjects()); } super.buttonPressed(buttonId); }