From 4751e8fbf032cb40b4c085d2effdb8338b9a0682 Mon Sep 17 00:00:00 2001 From: Brian Vosburgh Date: Wed, 13 Jan 2016 14:11:17 -0500 Subject: [466421] pass IProgressMonitor to JpaFactory.buildJpaProject(...) so user can cancel "Build JPA Project" job --- .../NotifyingRepeatingJobCommandWrapper.java | 30 ++++++-- .../command/RepeatingJobCommandWrapper.java | 21 ++++-- .../command/NotifyingRepeatingJobCommand.java | 21 ++++-- .../internal/command/RepeatingCommandState.java | 4 +- .../internal/command/RepeatingCommandWrapper.java | 14 ++-- .../src/org/eclipse/jpt/jpa/core/JpaFactory.java | 7 +- .../jpt/jpa/core/internal/AbstractJpaFactory.java | 7 +- .../jpt/jpa/core/internal/AbstractJpaProject.java | 84 +++++++++++++++++++--- .../core/internal/InternalJpaProjectManager.java | 54 +++++++------- .../persistence/AbstractMappingFileRef.java | 6 +- .../jpa/core/internal/jpa1/GenericJpaProject.java | 7 +- .../internal/jpa1/context/GenericContextRoot.java | 6 +- .../internal/jpa1/context/orm/GenericOrmXml.java | 6 +- .../context/persistence/GenericPersistenceXml.java | 6 +- .../core/internal/jpa2/GenericJpaFactory2_0.java | 7 +- .../core/internal/EclipseLinkJpaFactory.java | 7 +- .../core/internal/EclipseLinkJpaFactory2_0.java | 7 +- .../core/internal/EclipseLinkJpaProjectImpl.java | 7 +- 18 files changed, 202 insertions(+), 99 deletions(-) diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java index 6bad23cc21..37d93fb688 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Oracle. All rights reserved. + * Copyright (c) 2012, 2016 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. @@ -67,8 +67,10 @@ public class NotifyingRepeatingJobCommandWrapper @Override /* private protected */ IStatus executeCommand(IProgressMonitor monitor) { IStatus status = super.executeCommand(monitor); - if (this.state.isQuiesced()) { - // hmmm - we will notify listeners even when we are "stopped"; that seems OK... + if (status.getSeverity() == IStatus.CANCEL) { + this.executionCanceled(); + } + else if (this.state.isQuiesced()) { this.executionQuiesced(); } return status; @@ -80,15 +82,33 @@ public class NotifyingRepeatingJobCommandWrapper */ private void executionQuiesced() { for (Listener listener : this.listenerList) { - this.notifyListener(listener); + this.notifyListenerQuiesced(listener); } } - private void notifyListener(Listener listener) { + private void notifyListenerQuiesced(Listener listener) { try { listener.executionQuiesced(this); } catch (Throwable ex) { this.exceptionHandler.handleException(ex); } } + + /** + * Notify our listeners. All listeners are notified. There is no way to + * cancel the notifications (e.g. via a monitor or exception). + */ + private void executionCanceled() { + for (Listener listener : this.listenerList) { + this.notifyListenerCanceled(listener); + } + } + + private void notifyListenerCanceled(Listener listener) { + try { + listener.executionCanceled(this); + } catch (Throwable ex) { + this.exceptionHandler.handleException(ex); + } + } } diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java index 6362a3de06..ae50a2a992 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Oracle. All rights reserved. + * Copyright (c) 2012, 2016 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. @@ -82,7 +82,7 @@ public class RepeatingJobCommandWrapper * starting with the initial invocation. The list is cleared with each * initial invocation of the command. */ - private final ArrayList stackTraces = debug() ? new ArrayList() : null; + private final ArrayList stackTraces = debug() ? new ArrayList<>() : null; private static boolean debug() { return JptCommonCorePlugin.instance().isDebugEnabled(); @@ -184,17 +184,21 @@ public class RepeatingJobCommandWrapper * causing the command to execute again. */ /* CU private */ IStatus execute_(IProgressMonitor monitor) { + IStatus status = Status.OK_STATUS; if (this.state.wasStoppedBeforeFirstExecutionCouldStart()) { - return Status.OK_STATUS; + return status; } + // if the command is canceled, suppress further executions + // (this will include any concurrent, unrelated invocations that might have slipped in); + // but keep looping, so we can leave 'state' in a consistent state + // (i.e. 'state' assumes we will call 'isRepeat()' until it returns false...) do { - IStatus status = this.executeCommand(monitor); - if (status.getSeverity() == IStatus.CANCEL) { - return status; // seems reasonable... + if (status.getSeverity() != IStatus.CANCEL) { + status = this.executeCommand(monitor); } } while (this.state.isRepeat()); - return Status.OK_STATUS; + return status; } /** @@ -206,6 +210,9 @@ public class RepeatingJobCommandWrapper try { return this.command.execute(monitor); } catch (OperationCanceledException ex) { + // capture where the cancel occurred; + // if we have an infinite loop, the stack trace may give us a hint of what is going on... + this.exceptionHandler.handleException(ex); return Status.CANCEL_STATUS; // seems reasonable... } catch (Throwable ex) { this.exceptionHandler.handleException(ex); diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java index fd4fb11243..0cd402eb04 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Oracle. All rights reserved. + * Copyright (c) 2012, 2016 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. @@ -13,11 +13,15 @@ import java.util.EventListener; /** * Extend the repeating job command to support listeners that are notified - * when an execution "cycle" is complete; i.e. the job command has, - * for the moment, handled every execution request and quiesced. - * This notification is not guaranteed to occur with every - * execution "cycle"; since other, unrelated, executions can be triggered - * concurrently, causing the "cycle" to continue. + * when: + *
    + *
  • an execution "cycle" is complete; i.e. the job command has, + * for the moment, handled every execution request and quiesced + * (This notification is not guaranteed to occur with every + * execution "cycle"; since other, unrelated, executions can be triggered + * concurrently, causing the "cycle" to continue.) + *
  • the job command has been canceled (typically by a user) + *
*

* Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -54,5 +58,10 @@ public interface NotifyingRepeatingJobCommand * The specified job command has quiesced. */ void executionQuiesced(JobCommand command); + + /** + * The specified job command has been canceled. + */ + void executionCanceled(JobCommand command); } } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java index db557ac179..db32c6e7a0 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Oracle. All rights reserved. + * Copyright (c) 2012, 2016 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. @@ -44,7 +44,7 @@ public class RepeatingCommandState { public RepeatingCommandState() { super(); // use the command wrapper as the mutex so it is freed up by the wait in #stop() - this.state = new SynchronizedObject(State.STOPPED, this); + this.state = new SynchronizedObject<>(State.STOPPED, this); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java index 6ddc8feb73..48441b4659 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Oracle. All rights reserved. + * Copyright (c) 2012, 2016 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. @@ -64,7 +64,7 @@ public class RepeatingCommandWrapper * starting with the initial invocation. The list is cleared with each * initial invocation of the command. */ - private final ArrayList stackTraces = DEBUG ? new ArrayList() : null; + private final ArrayList stackTraces = DEBUG ? new ArrayList<>() : null; // see RepeatingCommandWrapperTests.testDEBUG() private static final boolean DEBUG = false; @@ -163,13 +163,11 @@ public class RepeatingCommandWrapper * causing the command to execute again. */ /* CU private */ void execute_() { - if (this.state.wasStoppedBeforeFirstExecutionCouldStart()) { - return; + if ( ! this.state.wasStoppedBeforeFirstExecutionCouldStart()) { + do { + this.executeCommand(); + } while (this.state.isRepeat()); } - - do { - this.executeCommand(); - } while (this.state.isRepeat()); } /** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java index e11054ca35..11999367a8 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -10,6 +10,7 @@ package org.eclipse.jpt.jpa.core; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.common.core.JptResourceModel; import org.eclipse.jpt.common.core.resource.java.JavaResourceField; @@ -141,10 +142,10 @@ public interface JpaFactory { /** * Construct a JpaProject for the specified config, to be - * added to the specified JPA project. Return null if unable to create + * added to the specified JPA project. Return null if unable to create * the JPA file (e.g. the content type is unrecognized). */ - JpaProject buildJpaProject(JpaProject.Config config); + JpaProject buildJpaProject(JpaProject.Config config, IProgressMonitor monitor); JpaDataSource buildJpaDataSource(JpaProject jpaProject, String connectionProfileName); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java index 65f5bcf6ce..85c46737c5 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -10,6 +10,7 @@ package org.eclipse.jpt.jpa.core.internal; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.common.core.JptResourceModel; import org.eclipse.jpt.common.core.resource.java.JavaResourceField; @@ -172,8 +173,8 @@ public abstract class AbstractJpaFactory // ********** Core Model ********** - public JpaProject buildJpaProject(JpaProject.Config config) { - return new GenericJpaProject(config); + public JpaProject buildJpaProject(JpaProject.Config config, IProgressMonitor monitor) { + return new GenericJpaProject(config, monitor); } public JpaDataSource buildJpaDataSource(JpaProject jpaProject, String connectionProfileName) { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java index d9359fb869..23cb1f4319 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Oracle. All rights reserved. + * Copyright (c) 2006, 2016 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. @@ -154,12 +154,12 @@ public abstract class AbstractJpaProject * orm.xml * java */ - protected final Hashtable jpaFiles = new Hashtable(); + protected final Hashtable jpaFiles = new Hashtable<>(); /** * The "external" Java resource compilation units (source). Populated upon demand. */ - protected final Vector externalJavaResourceCompilationUnits = new Vector(); + protected final Vector externalJavaResourceCompilationUnits = new Vector<>(); /** * The "external" Java resource types (binary). Populated upon demand. @@ -228,7 +228,7 @@ public abstract class AbstractJpaProject // ********** constructor/initialization ********** - protected AbstractJpaProject(JpaProject.Config config) { + protected AbstractJpaProject(JpaProject.Config config, IProgressMonitor monitor) { super(null); // JPA project is the root of the containment tree if ((config.getJpaProjectManager() == null) || (config.getProject() == null) || (config.getJpaPlatform() == null)) { throw new NullPointerException(); @@ -237,7 +237,7 @@ public abstract class AbstractJpaProject this.project = config.getProject(); this.projectResourceLocator = this.buildProjectResourceLocator(); this.synchronizeContextModelCommand = this.buildSynchronizeContextModelCommand(); - this.updateCommand = this.buildTempUpdateCommand(); // temporary command + this.updateCommand = this.buildTempUpdateCommand(monitor); // temporary command this.jpaPlatform = config.getJpaPlatform(); this.dataSource = this.getJpaFactory().buildJpaDataSource(this, config.getConnectionProfileName()); this.userOverrideDefaultCatalog = config.getUserOverrideDefaultCatalog(); @@ -279,7 +279,7 @@ public abstract class AbstractJpaProject } protected ProjectResourceLocator buildProjectResourceLocator() { - return (ProjectResourceLocator) this.project.getAdapter(ProjectResourceLocator.class); + return this.project.getAdapter(ProjectResourceLocator.class); } protected JavaResourceTypeCache buildExternalJavaResourceTypeCache() { @@ -1445,7 +1445,7 @@ public abstract class AbstractJpaProject // ********** validation ********** public Iterable getValidationMessages(IReporter reporter) { - ArrayList messages = new ArrayList(); + ArrayList messages = new ArrayList<>(); this.validate(messages, reporter); return messages; } @@ -1470,7 +1470,7 @@ public abstract class AbstractJpaProject } protected void validateLibraryProvider_(List messages) throws CoreException { - Map enablementVariables = new HashMap(); + Map enablementVariables = new HashMap<>(); enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, this.getJpaPlatform().getId()); enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, this.getJpaPlatform().getConfig()); @@ -1931,8 +1931,16 @@ public abstract class AbstractJpaProject * The first update is executed synchronously during construction. * Once that is complete, we delegate to the JPA project manager. */ - protected NotifyingRepeatingJobCommand buildTempUpdateCommand() { - return new NotifyingRepeatingJobCommandWrapper(this.buildUpdateJobCommand(), JptJpaCorePlugin.instance().getExceptionHandler()); + protected NotifyingRepeatingJobCommand buildTempUpdateCommand(IProgressMonitor monitor) { + return new NotifyingRepeatingJobCommandWrapper( + this.buildUpdateJobCommand(), + this.buildTempStartUpdateJobCommandContext(monitor), + JptJpaCorePlugin.instance().getExceptionHandler() + ); + } + + protected JobCommandContext buildTempStartUpdateJobCommandContext(IProgressMonitor monitor) { + return new TempUpdateJobCommandContext(monitor); } protected NotifyingRepeatingJobCommand buildUpdateCommand() { @@ -2035,6 +2043,9 @@ public abstract class AbstractJpaProject public void executionQuiesced(JobCommand command) { AbstractJpaProject.this.updateQuiesced(); } + public void executionCanceled(JobCommand command) { + AbstractJpaProject.this.updateCanceled(); + } @Override public String toString() { return ObjectTools.toString(this, AbstractJpaProject.this); @@ -2051,6 +2062,15 @@ public abstract class AbstractJpaProject this.synchronizeMetamodel(); } + /** + * This is the callback used by the update command to notify the JPA + * project that the "update" has been canceled (typically by the user). + * Called by {@link UpdateCommandListener#executionCanceled(JobCommand)}. + */ + protected void updateCanceled() { + // NOP + } + // ********** job command context ********** @@ -2090,4 +2110,48 @@ public abstract class AbstractJpaProject return ObjectTools.toString(this, this.defaultJobName); } } + + + // ********** temp update job command context ********** + + /** + * Pass through a progress monitor. + *
+ * NB: One-time use only. + * + * @see #buildTempStartUpdateJobCommandContext(IProgressMonitor) + */ + protected class TempUpdateJobCommandContext + implements JobCommandContext + { + protected IProgressMonitor monitor; + protected TempUpdateJobCommandContext(IProgressMonitor monitor) { + super(); + if (monitor == null) { + throw new NullPointerException(); + } + this.monitor = monitor; + } + public void execute(JobCommand command) { + IProgressMonitor m = null; + synchronized (this) { + if (this.monitor == null) { + throw new NullPointerException(); + } + m = this.monitor; + this.monitor = null; // one-time use... + } + command.execute(m); + } + public void execute(JobCommand command, String jobName) { + this.execute(command); + } + public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) { + this.execute(command); + } + @Override + public String toString() { + return ObjectTools.toString(this, this.monitor); + } + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java index 548a8db7a9..1e816b2ca9 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 Oracle. All rights reserved. + * Copyright (c) 2006, 2016 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. @@ -171,7 +171,7 @@ class InternalJpaProjectManager /** * All the JPA projects in the workspace. */ - private final Vector jpaProjects = new Vector(); + private final Vector jpaProjects = new Vector<>(); /** * Listen for

    @@ -235,7 +235,7 @@ class InternalJpaProjectManager * validation job. Once the Java source file is saved, the Dali composite * re-takes the focus and this listener is once again inactive. */ - private final HashSet javaEventListenerFlags = new HashSet(); + private final HashSet javaEventListenerFlags = new HashSet<>(); /** * Support for modifying documents shared with the UI. @@ -292,7 +292,7 @@ class InternalJpaProjectManager } /* CU private */ class BuildJpaProjectCommand - extends CommandAdapter + extends JobCommandAdapter { private final IProject project; @@ -302,14 +302,15 @@ class InternalJpaProjectManager } @Override - public void execute() { - InternalJpaProjectManager.this.buildJpaProject_(this.project); + public IStatus execute(IProgressMonitor monitor) { + InternalJpaProjectManager.this.buildJpaProject_(this.project, monitor); + return Status.OK_STATUS; } } - /* CU private */ void buildJpaProject_(IProject project) { + /* CU private */ void buildJpaProject_(IProject project, IProgressMonitor monitor) { JptJpaCorePlugin.instance().trace(TRACE_OPTION, "execute: build JPA project: {0}", project.getName()); //$NON-NLS-1$ - this.addJpaProject(project); + this.addJpaProject(project, monitor); } @@ -538,7 +539,7 @@ class InternalJpaProjectManager JptJpaCorePlugin.instance().trace(TRACE_OPTION, "CANCEL: rebuild JPA project: {0}", project.getName()); //$NON-NLS-1$ throw new OperationCanceledException(); } - return this.addJpaProject(project); + return this.addJpaProject(project, monitor); } @@ -589,7 +590,7 @@ class InternalJpaProjectManager } private Iterable buildNoJpaProjectMessages(IProject project) { - return new SingleElementIterable(this.buildNoJpaProjectMessage(project)); + return new SingleElementIterable<>(this.buildNoJpaProjectMessage(project)); } private IMessage buildNoJpaProjectMessage(IProject project) { @@ -605,8 +606,8 @@ class InternalJpaProjectManager * log the exception and do not add anything to the manager. * Return the newly-created JPA project. */ - /* CU private */ JpaProject addJpaProject(IProject project) { - JpaProject jpaProject = this.buildJpaProject(project); + /* CU private */ JpaProject addJpaProject(IProject project, IProgressMonitor monitor) { + JpaProject jpaProject = this.buildJpaProject(project, monitor); // dump a stack trace so we can determine what triggers this if (jpaProject == null) { JptJpaCorePlugin.instance().dumpStackTrace(TRACE_OPTION, "add JPA project fail: {0}", project); //$NON-NLS-1$ @@ -624,27 +625,27 @@ class InternalJpaProjectManager /** * Return null if we have any problems.... */ - private JpaProject buildJpaProject(IProject project) { - return this.buildJpaProject(this.buildJpaProjectConfig(project)); + private JpaProject buildJpaProject(IProject project, IProgressMonitor monitor) { + return this.buildJpaProject(this.buildJpaProjectConfig(project), monitor); } /** * Return null if we have any problems.... */ - private JpaProject buildJpaProject(JpaProject.Config config) { - return this.buildJpaProject(config.getJpaPlatform(), config); + private JpaProject buildJpaProject(JpaProject.Config config, IProgressMonitor monitor) { + return this.buildJpaProject(config.getJpaPlatform(), config, monitor); } /** * Return null if we have any problems.... */ - private JpaProject buildJpaProject(JpaPlatform jpaPlatform, JpaProject.Config config) { + private JpaProject buildJpaProject(JpaPlatform jpaPlatform, JpaProject.Config config, IProgressMonitor monitor) { if (jpaPlatform == null) { JptJpaCorePlugin.instance().logError(new IllegalArgumentException(), "null JPA platform: {0}", config.getProject()); //$NON-NLS-1$ return null; } try { - return jpaPlatform.getJpaFactory().buildJpaProject(config); + return jpaPlatform.getJpaFactory().buildJpaProject(config, monitor); } catch (RuntimeException ex) { JptJpaCorePlugin.instance().logError(ex); return null; @@ -803,7 +804,7 @@ class InternalJpaProjectManager JptJpaCorePlugin.instance().trace(TRACE_OPTION, "CANCEL: post clean build: {0}", project.getName()); //$NON-NLS-1$ throw new OperationCanceledException(); } - this.addJpaProject(project); + this.addJpaProject(project, monitor); } } @@ -822,7 +823,7 @@ class InternalJpaProjectManager } /* CU private */ class FacetFileChangeEventHandlerCommand - extends CommandAdapter + extends JobCommandAdapter { private final IProject project; @@ -832,18 +833,19 @@ class InternalJpaProjectManager } @Override - public void execute() { - InternalJpaProjectManager.this.checkForJpaFacetTransition_(this.project); + public IStatus execute(IProgressMonitor monitor) { + InternalJpaProjectManager.this.checkForJpaFacetTransition_(this.project, monitor); + return Status.OK_STATUS; } } - /* CU private */ void checkForJpaFacetTransition_(IProject project) { + /* CU private */ void checkForJpaFacetTransition_(IProject project, IProgressMonitor monitor) { JptJpaCorePlugin.instance().trace(TRACE_OPTION, "execute: project facet file changed: {0}", project.getName()); //$NON-NLS-1$ JpaProject jpaProject = this.getJpaProject_(project); if (ProjectTools.hasFacet(project, JpaProject.FACET)) { if (jpaProject == null) { // JPA facet added - this.addJpaProject(project); + this.addJpaProject(project, monitor); } } else { if (jpaProject != null) { // JPA facet removed @@ -1060,10 +1062,6 @@ class InternalJpaProjectManager this.execute(new ClientJobCommandWrapper(command, jpaProject), jobName, jpaProject.getProject()); } - private void execute(Command command, String jobName, ISchedulingRule schedulingRule) { - this.execute(new CommandJobCommandAdapter(command), jobName, schedulingRule); - } - private void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) { this.commandContext.execute(command, jobName, schedulingRule); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java index db2debbd64..c93f1be922 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -117,8 +117,8 @@ public abstract class AbstractMappingFileRef } /** - * We call this method from both {@link #syncMappingFile()} and - * {@link #updateMappingFile()} because
      + * We call this method from both {@link #syncMappingFile(IProgressMonitor)} and + * {@link #updateMappingFile(IProgressMonitor)} because
        *
      • a sync will occur when the file is edited directly; * and the user could modify something (e.g. the version number) that * triggers the file being "resolved" or not; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java index 2502f19457..d213846858 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. + * Copyright (c) 2006, 2016 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. @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.core.internal.jpa1; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.core.internal.AbstractJpaProject; @@ -21,8 +22,8 @@ public class GenericJpaProject // ********** constructor/initialization ********** - public GenericJpaProject(JpaProject.Config config) { - super(config); + public GenericJpaProject(JpaProject.Config config, IProgressMonitor monitor) { + super(config, monitor); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericContextRoot.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericContextRoot.java index ee4a9d3ecc..8fb2ae86c6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericContextRoot.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericContextRoot.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -101,8 +101,8 @@ public class GenericContextRoot } /** - * We call this method from both {@link #syncPersistenceXml()} and - * {@link #updatePersistenceXml()} because
          + * We call this method from both {@link #syncPersistenceXml(IProgressMonitor)} and + * {@link #updatePersistenceXml(IProgressMonitor)} because
            *
          • a sync will occur when the file is edited directly; * and the user could modify something (e.g. the version number) that * triggers the file being "resolved" or not; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java index 79d23c579c..8f510d2a1a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -119,8 +119,8 @@ public class GenericOrmXml } /** - * We call this method from both {@link #syncEntityMappings()} and - * {@link #updateEntityMappings()} because
              + * We call this method from both {@link #syncEntityMappings(IProgressMonitor)} and + * {@link #updateEntityMappings(IProgressMonitor)} because
                *
              • a sync will occur when the file is edited directly; * the user could modify something (e.g. the version number) that * causes the XML entity mappings to be rebuilt. diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java index 0fa636848c..a5a3a16e7d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Oracle. All rights reserved. + * Copyright (c) 2007, 2016 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. @@ -98,8 +98,8 @@ public class GenericPersistenceXml } /** - * We call this method from both {@link #syncPersistence()} and - * {@link #updatePersistence()} because
                  + * We call this method from both {@link #syncPersistence(IProgressMonitor)} and + * {@link #updatePersistence(IProgressMonitor)} because
                    *
                  • a sync will occur when the file is edited directly; * the user could modify something (e.g. the version number) that * causes the XML entity mappings to be rebuilt. diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaFactory2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaFactory2_0.java index 384dadf294..1ae4bdc5ea 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaFactory2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaFactory2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 Oracle. All rights reserved. + * Copyright (c) 2009, 2016 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. @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.core.internal.jpa2; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.jpa.core.JpaDataSource; import org.eclipse.jpt.jpa.core.JpaProject; @@ -68,11 +69,11 @@ public class GenericJpaFactory2_0 // ********** Core Model ********** @Override - public JpaProject buildJpaProject(Config config) { + public JpaProject buildJpaProject(Config config, IProgressMonitor monitor) { if ( ! (config instanceof JpaProject2_0.Config)) { throw new IllegalArgumentException("config must be 2.0-compatible: " + config); //$NON-NLS-1$ } - return super.buildJpaProject(config); + return super.buildJpaProject(config, monitor); } public MetamodelSourceType2_0.Synchronizer buildMetamodelSynchronizer(MetamodelSourceType2_0 sourceType) { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory.java index 37b6a4e0ea..3f6a7bd10f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Oracle. All rights reserved. + * Copyright (c) 2008, 2016 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. @@ -9,6 +9,7 @@ *******************************************************************************/ package org.eclipse.jpt.jpa.eclipselink.core.internal; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.common.core.resource.java.JavaResourceField; import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod; import org.eclipse.jpt.jpa.core.JpaProject; @@ -58,8 +59,8 @@ public class EclipseLinkJpaFactory // ********** Core Model ********** @Override - public EclipseLinkJpaProject buildJpaProject(JpaProject.Config config) { - return new EclipseLinkJpaProjectImpl(config); + public EclipseLinkJpaProject buildJpaProject(JpaProject.Config config, IProgressMonitor monitor) { + return new EclipseLinkJpaProjectImpl(config, monitor); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory2_0.java index 6182bb1f2b..f65ef8fc32 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaFactory2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 Oracle. All rights reserved. + * Copyright (c) 2009, 2016 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. @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.eclipselink.core.internal; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.jpa.core.JpaDataSource; import org.eclipse.jpt.jpa.core.JpaProject.Config; @@ -64,11 +65,11 @@ public class EclipseLinkJpaFactory2_0 // ********** Core Model ********** @Override - public EclipseLinkJpaProject buildJpaProject(Config config) { + public EclipseLinkJpaProject buildJpaProject(Config config, IProgressMonitor monitor) { if ( ! (config instanceof JpaProject2_0.Config)) { throw new IllegalArgumentException("config must be 2.0-compatible: " + config); //$NON-NLS-1$ } - return super.buildJpaProject(config); + return super.buildJpaProject(config, monitor); } public MetamodelSourceType2_0.Synchronizer buildMetamodelSynchronizer(MetamodelSourceType2_0 sourceType) { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaProjectImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaProjectImpl.java index 34b0b6dbf2..cf999bdea0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaProjectImpl.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaProjectImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. All rights reserved. + * Copyright (c) 2009, 2016 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. @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.eclipselink.core.internal; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.common.core.resource.xml.JptXmlResource; import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.core.internal.AbstractJpaProject; @@ -22,8 +23,8 @@ public class EclipseLinkJpaProjectImpl extends AbstractJpaProject implements EclipseLinkJpaProject { - public EclipseLinkJpaProjectImpl(JpaProject.Config config) { - super(config); + public EclipseLinkJpaProjectImpl(JpaProject.Config config, IProgressMonitor monitor) { + super(config, monitor); } public JptXmlResource getDefaultEclipseLinkOrmXmlResource() { -- cgit v1.2.3