diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java index e4e18412dd..6ee1373e46 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/refactoring/JpaRenameMappingFileParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. + * Copyright (c) 2010, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,6 +12,7 @@ package org.eclipse.jpt.jpa.core.internal.refactoring; import java.util.HashMap; import java.util.Map; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -90,16 +91,17 @@ public class JpaRenameMappingFileParticipant //since the progress bar will hang if a large JPA project is being loaded, //we can at least set the subtask and report no progress. Only happens first time getJpaProjectManager() is called. monitor.subTask(JpaCoreRefactoringMessages.JPA_REFACORING_PARTICIPANT_LOADING_JPA_PROJECTS_SUB_TASK_NAME); - JpaProjectManager jpaProjectManager = JptJpaCorePlugin.getJpaProjectManager(); - if (jpaProjectManager.getJpaProjectsSize() == 0) { + Iterable<JpaProject> jpaProjects = this.getJpaProjects(); + int size = CollectionTools.size(jpaProjects); + if (size == 0) { return null; } - SubMonitor sm = SubMonitor.convert(monitor, jpaProjectManager.getJpaProjectsSize()*10 + 1); + SubMonitor sm = SubMonitor.convert(monitor, size*10 + 1); sm.subTask(JpaCoreRefactoringMessages.JPA_RENAME_MAPPING_FILE_REFACTORING_SUB_TASK_NAME); ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory(); - for (JpaProject jpaProject : JptJpaCorePlugin.getJpaProjectManager().getJpaProjects()) { + for (JpaProject jpaProject : jpaProjects) { this.createReplaceEdits(jpaProject); sm.worked(10); } @@ -114,6 +116,18 @@ public class JpaRenameMappingFileParticipant return null; } + protected Iterable<JpaProject> getJpaProjects() throws OperationCanceledException { + try { + return this.getJpaProjectManager().waitToGetJpaProjects(); + } catch (InterruptedException ex) { + throw new OperationCanceledException(ex.getMessage()); + } + } + + protected JpaProjectManager getJpaProjectManager() { + return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class); + } + protected void createReplaceEdits(JpaProject jpaProject) throws OperationCanceledException { PersistenceUnit persistenceUnit = getPersistenceUnit(jpaProject); if (persistenceUnit == null) { |