You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2010/07/22 17:19:02 UTC
svn commit: r966705 - in /directory/studio/trunk: common.core/
common.core/src/main/java/org/ common.core/src/main/java/org/apache/
common.core/src/main/java/org/apache/directory/
common.core/src/main/java/org/apache/directory/studio/ common.core/src/m...
Author: pamarcelot
Date: Thu Jul 22 15:19:00 2010
New Revision: 966705
URL: http://svn.apache.org/viewvc?rev=966705&view=rev
Log:
Added classes related to Jobs and Runnables.
Used these classes in the LDAP Servers plugins.
Added:
directory/studio/trunk/common.core/src/main/java/org/
directory/studio/trunk/common.core/src/main/java/org/apache/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/CommonCoreConstants.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/Messages.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioBulkRunnableWithProgress.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioJob.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioProgressMonitor.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgress.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgressAdapter.java
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages.properties
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_de.properties
directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_fr.properties
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerRunnable.java
- copied, changed from r966259, directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerJob.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerRunnable.java
- copied, changed from r966259, directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerJob.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StudioLdapServerJob.java
Removed:
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerJob.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerJob.java
Modified:
directory/studio/trunk/common.core/pom.xml
directory/studio/trunk/ldapservers.apacheds.v156/pom.xml
directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
directory/studio/trunk/ldapservers/pom.xml
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StopAction.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerWatchDogThread.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages.properties
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_de.properties
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_fr.properties
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java
directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
Modified: directory/studio/trunk/common.core/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/pom.xml?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/common.core/pom.xml (original)
+++ directory/studio/trunk/common.core/pom.xml Thu Jul 22 15:19:00 2010
@@ -100,7 +100,8 @@
<Bundle-SymbolicName>${groupId}.${artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Localization>plugin</Bundle-Localization>
<Eclipse-LazyStart>true</Eclipse-LazyStart>
- <Require-Bundle>org.eclipse.core.runtime
+ <Require-Bundle>org.eclipse.core.runtime,
+org.apache.directory.studio.jars
</Require-Bundle>
<Export-Package>org.apache.directory.studio.*</Export-Package>
<Import-Package>!</Import-Package>
@@ -129,6 +130,13 @@
</build>
<dependencies>
+ <!-- Apache Directory Studio plugins dependencies -->
+ <dependency>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>jars</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Eclipse plugins dependencies -->
<dependency>
<groupId>org.eclipse.core</groupId>
@@ -140,6 +148,16 @@
<artifactId>osgi</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>jobs</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>common</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/CommonCoreConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/CommonCoreConstants.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/CommonCoreConstants.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/CommonCoreConstants.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+/**
+ * Constants used in the Apache Directory Studio Common Core plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface CommonCoreConstants
+{
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.apache.directory.studio.common.core";
+
+ /** The Job family ID */
+ public static final String JOB_FAMILY_ID = "org.apache.directory.studio.common.core.jobs.family";
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/Messages.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/Messages.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/Messages.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.apache.directory.studio.common.core.jobs.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+ private Messages()
+ {
+ }
+
+
+ public static String getString( String key )
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString( key );
+ }
+ catch ( MissingResourceException e )
+ {
+ return '!' + key + '!';
+ }
+ }
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioBulkRunnableWithProgress.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioBulkRunnableWithProgress.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioBulkRunnableWithProgress.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioBulkRunnableWithProgress.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+/**
+ * A runnable with a progess monitor. When invoked by the {@link StudioJob}
+ * during the run() method all event notifications are blocked and the runNotification()
+ * method is called afterwards to fire event notifications.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface StudioBulkRunnableWithProgress extends StudioRunnableWithProgress
+{
+ /**
+ * Runs notification, called by {@link StudioJob} after the run() method.
+ *
+ * @param monitor the monitor
+ */
+ public void runNotification( StudioProgressMonitor monitor );
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioJob.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioJob.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioJob.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+
+/**
+ * Job to run {@link StudioRunnableWithProgress} runnables.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioJob extends Job
+{
+ /** The runnables. */
+ private StudioRunnableWithProgress[] runnables;
+
+
+ /**
+ * Creates a new instance of StudioJob.
+ *
+ * @param runnables the runnables to run
+ */
+ public StudioJob( StudioRunnableWithProgress... runnables )
+ {
+ super( runnables[0].getName() );
+ this.runnables = runnables;
+ }
+
+
+ /**
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected final IStatus run( IProgressMonitor ipm )
+ {
+ StudioProgressMonitor monitor = new StudioProgressMonitor( ipm );
+
+ // Execute job
+ if ( !monitor.errorsReported() )
+ {
+ try
+ {
+ for ( StudioRunnableWithProgress runnable : runnables )
+ {
+ if ( runnable instanceof StudioBulkRunnableWithProgress )
+ {
+ StudioBulkRunnableWithProgress bulkRunnable = ( StudioBulkRunnableWithProgress ) runnable;
+ suspendEventFiringInCurrentThread();
+ try
+ {
+ bulkRunnable.run( monitor );
+ }
+ finally
+ {
+ resumeEventFiringInCurrentThread();
+ }
+ bulkRunnable.runNotification( monitor );
+ }
+ else
+ {
+ runnable.run( monitor );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+ // always set done, even if errors were reported
+ monitor.done();
+ ipm.done();
+
+ // error handling
+ if ( monitor.isCanceled() )
+ {
+ return Status.CANCEL_STATUS;
+ }
+ else if ( monitor.errorsReported() )
+ {
+ return monitor.getErrorStatus( runnables[0].getErrorMessage() );
+ }
+ else
+ {
+ return Status.OK_STATUS;
+ }
+
+ }
+
+
+ /**
+ * Suspends event firing in current thread.
+ */
+ protected void suspendEventFiringInCurrentThread()
+ {
+ // Default implementation does nothing.
+ }
+
+
+ /**
+ * Resumes event firing in current thread.
+ */
+ protected void resumeEventFiringInCurrentThread()
+ {
+ // Default implementation does nothing.
+ }
+
+
+ /**
+ * Executes the job.
+ */
+ public final void execute()
+ {
+ setUser( true );
+ schedule();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean shouldSchedule()
+ {
+ // We don't schedule a job if the same type of runnable should run
+ // that works on the same entry as the current runnable.
+
+ for ( StudioRunnableWithProgress runnable : runnables )
+ {
+ Object[] myLockedObjects = runnable.getLockedObjects();
+ String[] myLockedObjectsIdentifiers = getLockIdentifiers( myLockedObjects );
+
+ Job[] jobs = getJobManager().find( null );
+ for ( int i = 0; i < jobs.length; i++ )
+ {
+ Job job = jobs[i];
+ if ( job instanceof StudioJob )
+ {
+ StudioJob otherJob = ( StudioJob ) job;
+ for ( StudioRunnableWithProgress otherRunnable : otherJob.runnables )
+ {
+ if ( runnable.getClass() == otherRunnable.getClass() && runnable != otherRunnable )
+ {
+ Object[] otherLockedObjects = otherRunnable.getLockedObjects();
+ String[] otherLockedObjectIdentifiers = getLockIdentifiers( otherLockedObjects );
+
+ for ( int j = 0; j < otherLockedObjectIdentifiers.length; j++ )
+ {
+ String other = otherLockedObjectIdentifiers[j];
+ for ( int k = 0; k < myLockedObjectsIdentifiers.length; k++ )
+ {
+ String my = myLockedObjectsIdentifiers[k];
+ if ( other.startsWith( my ) || my.startsWith( other ) )
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return super.shouldSchedule();
+ }
+
+
+ /**
+ * Gets the string identifiers for the given objects.
+ *
+ * @param objects
+ * the objects
+ * @return
+ * the string identifiers associated with the objects
+ */
+ protected String[] getLockIdentifiers( Object[] objects )
+ {
+ String[] identifiers = new String[objects.length];
+ for ( int i = 0; i < identifiers.length; i++ )
+ {
+ identifiers[i] = getLockIdentifier( objects[i] );
+ }
+ return identifiers;
+ }
+
+
+ /**
+ * Gets the generic lock identifier for an object.
+ *
+ * @param object
+ * the object
+ * @return
+ * the lock identifier for the object
+ */
+ private String getLockIdentifier( Object object )
+ {
+ return ( object != null ? object.toString() : "null" ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean belongsTo( Object family )
+ {
+ return getFamily().equals( family );
+ }
+
+
+ /**
+ * Get the object corresponding to the family of the Job.
+ *
+ * @return
+ * the object corresponding to the family of the Job
+ */
+ public Object getFamily()
+ {
+ return CommonCoreConstants.JOB_FAMILY_ID;
+ }
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioProgressMonitor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioProgressMonitor.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioProgressMonitor.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioProgressMonitor.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,458 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+
+/**
+ * The StudioProgressMonitor extends the the Eclipse
+ * Progress Monitor with active cancellation capabilities.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioProgressMonitor extends ProgressMonitorWrapper
+{
+ /** The job reports progress and checks for cancellation. */
+ protected static Job reportProgressAndCheckCancellationJob = new Job(
+ Messages.getString( "StudioProgressMonitor.CheckCancellation" ) )
+ {
+ protected IStatus run( IProgressMonitor monitor )
+ {
+ while ( true )
+ {
+ synchronized ( monitors )
+ {
+ for ( Iterator<StudioProgressMonitor> it = monitors.iterator(); it.hasNext(); )
+ {
+ StudioProgressMonitor next = it.next();
+ StudioProgressMonitor spm = next;
+
+ do
+ {
+ // check report progress message
+ if ( !spm.isCanceled() && !spm.done && spm.reportProgressMessage != null )
+ {
+ spm.subTask( spm.reportProgressMessage );
+ spm.reportProgressMessage = null;
+ }
+
+ // check if canceled
+ if ( spm.isCanceled() )
+ {
+ spm.fireCancelRequested();
+ }
+ if ( spm.isCanceled() || spm.done )
+ {
+ it.remove();
+ break;
+ }
+
+ if ( spm.getWrappedProgressMonitor() != null
+ && spm.getWrappedProgressMonitor() instanceof StudioProgressMonitor )
+ {
+ spm = ( StudioProgressMonitor ) spm.getWrappedProgressMonitor();
+ }
+ else
+ {
+ spm = null;
+ }
+ }
+ while ( spm != null );
+ }
+ }
+
+ try
+ {
+ Thread.sleep( 1000 );
+ }
+ catch ( InterruptedException e )
+ {
+ }
+ }
+ }
+ };
+ static
+ {
+ reportProgressAndCheckCancellationJob.setSystem( true );
+ reportProgressAndCheckCancellationJob.schedule();
+ }
+
+ /** The list of monitors */
+ protected static List<StudioProgressMonitor> monitors = Collections
+ .synchronizedList( new ArrayList<StudioProgressMonitor>() );
+
+ /** The plugin ID */
+ protected String pluginId;
+
+ /** The flag indicating if the work is done */
+ protected boolean done;
+
+ /** The list of error statuses */
+ protected List<Status> errorStatusList;
+
+ /** The list of cancel listeners */
+ protected List<CancelListener> cancelListenerList;
+
+ /** The progress message to report */
+ protected String reportProgressMessage = null;
+
+
+ /**
+ * Creates a new instance of ExtendedProgressMonitor.
+ *
+ * @param monitor the progress monitor to forward to
+ */
+ public StudioProgressMonitor( IProgressMonitor monitor )
+ {
+ super( monitor );
+ this.pluginId = CommonCoreConstants.PLUGIN_ID;
+ done = false;
+ monitors.add( this );
+ }
+
+
+ /**
+ * Creates a new instance of ExtendedProgressMonitor.
+ *
+ * @param monitor the progress monitor to forward to
+ */
+ public StudioProgressMonitor( String pluginId, IProgressMonitor monitor )
+ {
+ super( monitor );
+ this.pluginId = pluginId;
+ done = false;
+ monitors.add( this );
+ }
+
+
+ /**
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setCanceled(boolean)
+ */
+ public void setCanceled( boolean b )
+ {
+ super.setCanceled( b );
+ if ( b )
+ {
+ fireCancelRequested();
+ }
+ }
+
+
+ /**
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#done()
+ */
+ public void done()
+ {
+ synchronized ( this )
+ {
+ done = true;
+ super.done();
+ }
+ }
+
+
+ /**
+ * Adds the cancel listener.
+ *
+ * @param listener the listener
+ */
+ public void addCancelListener( CancelListener listener )
+ {
+ if ( cancelListenerList == null )
+ {
+ cancelListenerList = new ArrayList<CancelListener>();
+ }
+ if ( !cancelListenerList.contains( listener ) )
+ {
+ cancelListenerList.add( listener );
+ }
+ }
+
+
+ /**
+ * Removes the cancel listener.
+ *
+ * @param listener the listener
+ */
+ public void removeCancelListener( CancelListener listener )
+ {
+ if ( cancelListenerList != null && cancelListenerList.contains( listener ) )
+ {
+ cancelListenerList.remove( listener );
+ }
+ }
+
+
+ private void fireCancelRequested()
+ {
+ CancelEvent event = new CancelEvent( this );
+ if ( cancelListenerList != null )
+ {
+ for ( int i = 0; i < cancelListenerList.size(); i++ )
+ {
+ CancelListener listener = cancelListenerList.get( i );
+ listener.cancelRequested( event );
+ }
+ }
+ }
+
+
+ /**
+ * Report progress.
+ *
+ * @param message the message
+ */
+ public void reportProgress( String message )
+ {
+ reportProgressMessage = message;
+ }
+
+
+ /**
+ * Report error.
+ *
+ * @param message the message
+ */
+ public void reportError( String message )
+ {
+ this.reportError( message, null );
+ }
+
+
+ /**
+ * Report error.
+ *
+ * @param exception the exception
+ */
+ public void reportError( Exception exception )
+ {
+ reportError( null, exception );
+ }
+
+
+ /**
+ * Report error.
+ *
+ * @param message the message
+ * @param exception the exception
+ */
+ public void reportError( String message, Exception exception )
+ {
+ if ( errorStatusList == null )
+ {
+ errorStatusList = new ArrayList<Status>( 3 );
+ }
+
+ if ( message == null )
+ {
+ message = ""; //$NON-NLS-1$
+ }
+
+ Status errorStatus = new Status( IStatus.ERROR, pluginId, IStatus.ERROR, message, exception );
+ errorStatusList.add( errorStatus );
+ }
+
+
+ /**
+ * Errors reported.
+ *
+ * @return true, if errors reported
+ */
+ public boolean errorsReported()
+ {
+ return errorStatusList != null;
+ }
+
+
+ /**
+ * Gets the error status.
+ *
+ * @param message the message
+ * @param TODO: context message, e.g. search parameters or mod-ldif
+ *
+ * @return the error status
+ */
+ public IStatus getErrorStatus( String message )
+ {
+ if ( errorStatusList != null && !errorStatusList.isEmpty() )
+ {
+ // append status messages to message
+ for ( Status status : errorStatusList )
+ {
+ String statusMessage = status.getMessage();
+ Throwable exception = status.getException();
+ String exceptionMessage = exception != null ? exception.getMessage() : null;
+
+ // TODO Check if this commented code could be removed
+ // // Tweak exception message for some well-know exceptions
+ // Throwable e = exception;
+ // while ( e != null )
+ // {
+ // if ( e instanceof UnknownHostException )
+ // {
+ // exceptionMessage = "Unknown Host: " + e.getMessage(); //$NON-NLS-1$
+ // }
+ // else if ( e instanceof SocketException )
+ // {
+ // exceptionMessage = e.getMessage() + " (" + exceptionMessage + ")";; //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ //
+ // // next cause
+ // e = e.getCause();
+ // }
+
+ // append explicit status message
+ if ( !StringUtils.isEmpty( statusMessage ) )
+ {
+ message += "\n - " + statusMessage;
+ }
+ // append exception message if different to status message
+ if ( exception != null && exceptionMessage != null && !exceptionMessage.equals( statusMessage ) )
+ {
+ // strip control characters
+ int indexOfAny = StringUtils.indexOfAny( exceptionMessage, "\n\r\t" );
+ if ( indexOfAny > -1 )
+ {
+ exceptionMessage = exceptionMessage.substring( 0, indexOfAny - 1 );
+ }
+ message += "\n - " + exceptionMessage;
+ }
+ }
+
+ // create main status
+ MultiStatus multiStatus = new MultiStatus( pluginId, IStatus.ERROR, message, null );
+
+ // append child status
+ for ( Status status : errorStatusList )
+ {
+ String statusMessage = status.getMessage();
+ if ( status.getException() != null )
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter( sw );
+ status.getException().printStackTrace( pw );
+ statusMessage = sw.toString();
+ }
+ multiStatus.add( new Status( status.getSeverity(), status.getPlugin(), status.getCode(), statusMessage,
+ status.getException() ) );
+ }
+
+ return multiStatus;
+ }
+ else if ( isCanceled() )
+ {
+ return Status.CANCEL_STATUS;
+ }
+ else
+ {
+ return Status.OK_STATUS;
+ }
+ }
+
+
+ /**
+ * Gets the exception.
+ *
+ * @return the exception
+ */
+ public Exception getException()
+ {
+ if ( errorStatusList != null )
+ {
+ return ( Exception ) errorStatusList.get( 0 ).getException();
+ }
+ return null;
+ }
+
+
+ /**
+ * Resets this status.
+ */
+ public void reset()
+ {
+ this.done = false;
+ this.errorStatusList = null;
+ }
+
+ /**
+ * CancelEvent.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+ public static class CancelEvent
+ {
+ private IProgressMonitor monitor;
+
+
+ /**
+ * Creates a new instance of CancelEvent.
+ *
+ * @param monitor the progress monitor
+ */
+ public CancelEvent( IProgressMonitor monitor )
+ {
+ this.monitor = monitor;
+ }
+
+
+ /**
+ * Gets the monitor.
+ *
+ * @return the progress monitor
+ */
+ public IProgressMonitor getMonitor()
+ {
+ return monitor;
+ }
+ }
+
+ /**
+ * CancelListener.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+ public interface CancelListener
+ {
+
+ /**
+ * Cancel requested.
+ *
+ * @param event the event
+ */
+ public void cancelRequested( CancelEvent event );
+ }
+
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgress.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgress.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgress.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgress.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+/**
+ * A runnable with a progress monitor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface StudioRunnableWithProgress
+{
+ /**
+ * Runs the runnable.
+ *
+ * @param monitor the monitor
+ */
+ public void run( StudioProgressMonitor monitor );
+
+
+ /**
+ * Gets the locked objects.
+ *
+ * @return the locked objects
+ */
+ public Object[] getLockedObjects();
+
+
+ /**
+ * Gets the error message.
+ *
+ * @return the error message
+ */
+ public String getErrorMessage();
+
+
+ /**
+ * Gets the name that is used when reporting progress.
+ *
+ * @return the name
+ */
+ public String getName();
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgressAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgressAdapter.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgressAdapter.java (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/StudioRunnableWithProgressAdapter.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.common.core.jobs;
+
+
+/**
+ * An adapter class for StudioRunnableWithProgress.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class StudioRunnableWithProgressAdapter implements StudioRunnableWithProgress
+{
+ /** The locked objects */
+ private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+
+
+ /**
+ * @return an empty array
+ */
+ public Object[] getLockedObjects()
+ {
+ return EMPTY_OBJECT_ARRAY;
+ }
+
+
+ /**
+ * @return empty string
+ */
+ public String getErrorMessage()
+ {
+ return "";
+ }
+}
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages.properties?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages.properties (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages.properties Thu Jul 22 15:19:00 2010
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+AbstractStudioJob.ErrorMessage=An error occurred
+
+StudioProgressMonitor.CheckCancellation=Check Cancellation
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_de.properties?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_de.properties (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_de.properties Thu Jul 22 15:19:00 2010
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+AbstractStudioJob.ErrorMessage=TODO:An error occurred
+
+StudioProgressMonitor.CheckCancellation=TODO:Check Cancellation
Added: directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_fr.properties?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_fr.properties (added)
+++ directory/studio/trunk/common.core/src/main/java/org/apache/directory/studio/common/core/jobs/messages_fr.properties Thu Jul 22 15:19:00 2010
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+AbstractStudioJob.ErrorMessage=Une erreur est survenue
+
+StudioProgressMonitor.CheckCancellation=Verifier l'annulation
Modified: directory/studio/trunk/ldapservers.apacheds.v156/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers.apacheds.v156/pom.xml?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers.apacheds.v156/pom.xml (original)
+++ directory/studio/trunk/ldapservers.apacheds.v156/pom.xml Thu Jul 22 15:19:00 2010
@@ -115,14 +115,15 @@
<Eclipse-LazyStart>true</Eclipse-LazyStart>
<Bundle-Activator>org.apache.directory.studio.ldapserver.apacheds.v156.ApacheDS156Plugin</Bundle-Activator>
<Require-Bundle>org.eclipse.core.runtime,
- org.eclipse.ui,
- org.eclipse.jface.text,
- org.eclipse.ui.ide,
- org.eclipse.jdt.launching,
org.eclipse.debug.core,
org.eclipse.debug.ui,
- org.apache.directory.studio.jars,
+ org.eclipse.jdt.launching,
+ org.eclipse.jface.text,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.apache.directory.studio.common.core,
org.apache.directory.studio.common.ui,
+ org.apache.directory.studio.jars,
org.apache.directory.studio.ldapservers
</Require-Bundle>
<Export-Package>org.apache.directory.studio.*</Export-Package>
@@ -524,7 +525,7 @@
<!-- Apache Directory Studio plugins dependencies -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
- <artifactId>jars</artifactId>
+ <artifactId>common.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@@ -534,6 +535,11 @@
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
+ <artifactId>jars</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.studio</groupId>
<artifactId>ldapservers</artifactId>
<scope>provided</scope>
</dependency>
Modified: directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java (original)
+++ directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java Thu Jul 22 15:19:00 2010
@@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.directory.studio.common.CommonUiUtils;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.ldapservers.LdapServersManager;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
@@ -38,7 +39,6 @@ import org.apache.directory.studio.ldaps
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
@@ -100,7 +100,7 @@ public class ApacheDS156LdapServerAdapte
/**
* {@inheritDoc}
*/
- public void add( LdapServer server, IProgressMonitor monitor ) throws Exception
+ public void add( LdapServer server, StudioProgressMonitor monitor ) throws Exception
{
// Verifying and copying ApacheDS 1.5.6 libraries
monitor.subTask( "verifying and copying ApacheDS 1.5.6 libraries" );
@@ -123,7 +123,7 @@ public class ApacheDS156LdapServerAdapte
IPath resourceConfFolderPath = new Path( RESOURCES ).append( CONF );
copyResource( resourceConfFolderPath.append( SERVER_XML ), new File( confFolder, SERVER_XML ) );
copyResource( resourceConfFolderPath.append( LOG4J_PROPERTIES ), new File( confFolder, LOG4J_PROPERTIES ) );
-
+
}
@@ -139,7 +139,7 @@ public class ApacheDS156LdapServerAdapte
/**
* {@inheritDoc}
*/
- public void start( LdapServer server, IProgressMonitor monitor ) throws Exception
+ public void start( LdapServer server, StudioProgressMonitor monitor ) throws Exception
{
launchApacheDS( server );
@@ -239,7 +239,7 @@ public class ApacheDS156LdapServerAdapte
/**
* {@inheritDoc}
*/
- public void stop( LdapServer server, IProgressMonitor monitor ) throws Exception
+ public void stop( LdapServer server, StudioProgressMonitor monitor ) throws Exception
{
// Getting the launch
ILaunch launch = ( ILaunch ) server.getCustomObject( "launchConfiguration" );
Modified: directory/studio/trunk/ldapservers/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/pom.xml?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/pom.xml (original)
+++ directory/studio/trunk/ldapservers/pom.xml Thu Jul 22 15:19:00 2010
@@ -115,12 +115,12 @@
<Eclipse-LazyStart>true</Eclipse-LazyStart>
<Bundle-Activator>org.apache.directory.studio.ldapservers.LdapServersPlugin</Bundle-Activator>
<Require-Bundle>org.eclipse.core.runtime,
- org.eclipse.ui,
org.eclipse.jface.text,
+ org.eclipse.ui,
org.eclipse.ui.ide,
- org.apache.directory.studio.jars,
+ org.apache.directory.studio.common.core,
org.apache.directory.studio.common.ui,
- org.apache.directory.studio.ldapbrowser.ui
+ org.apache.directory.studio.jars
</Require-Bundle>
<Export-Package>org.apache.directory.studio.*</Export-Package>
<Import-Package>!</Import-Package>
@@ -152,7 +152,7 @@
<!-- Apache Directory Studio plugins dependencies -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
- <artifactId>jars</artifactId>
+ <artifactId>common.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@@ -162,7 +162,7 @@
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
- <artifactId>ldapbrowser.ui</artifactId>
+ <artifactId>jars</artifactId>
<scope>provided</scope>
</dependency>
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java Thu Jul 22 15:19:00 2010
@@ -110,7 +110,7 @@ public class DeleteAction extends Action
// server.setStatus( LdapServerStatus.STOPPING ); // TODO
// Getting the launch job // TODO
- // StartLdapServerJob launchJob = server.getLaunchJob();
+ // StartLdapServerRunnable launchJob = server.getLaunchJob();
// if ( launchJob != null )
// {
// // Getting the launch
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java Thu Jul 22 15:19:00 2010
@@ -22,7 +22,8 @@ package org.apache.directory.studio.ldap
import org.apache.directory.studio.ldapservers.LdapServersPlugin;
import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
-import org.apache.directory.studio.ldapservers.jobs.StartLdapServerJob;
+import org.apache.directory.studio.ldapservers.jobs.StartLdapServerRunnable;
+import org.apache.directory.studio.ldapservers.jobs.StudioLdapServerJob;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.views.ServersView;
import org.eclipse.jface.action.Action;
@@ -95,7 +96,7 @@ public class StartAction extends Action
LdapServer server = ( LdapServer ) selection.getFirstElement();
// Creating and scheduling the job to start the server
- StartLdapServerJob job = new StartLdapServerJob( server );
+ StudioLdapServerJob job = new StudioLdapServerJob( new StartLdapServerRunnable( server ) );
job.schedule();
}
}
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StopAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StopAction.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StopAction.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StopAction.java Thu Jul 22 15:19:00 2010
@@ -20,19 +20,16 @@
package org.apache.directory.studio.ldapservers.actions;
-import java.io.IOException;
-
import org.apache.directory.studio.ldapservers.LdapServersPlugin;
import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
-import org.apache.directory.studio.ldapservers.jobs.StartLdapServerJob;
-import org.apache.directory.studio.ldapservers.jobs.StopLdapServerJob;
+import org.apache.directory.studio.ldapservers.jobs.StopLdapServerRunnable;
+import org.apache.directory.studio.ldapservers.jobs.StudioLdapServerJob;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.views.ServersView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
@@ -99,7 +96,7 @@ public class StopAction extends Action i
LdapServer server = ( LdapServer ) selection.getFirstElement();
// Creating and scheduling the job to stop the server
- StopLdapServerJob job = new StopLdapServerJob( server );
+ StudioLdapServerJob job = new StudioLdapServerJob( new StopLdapServerRunnable( server ) );
job.schedule();
}
}
Copied: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerRunnable.java (from r966259, directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerJob.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerRunnable.java?p2=directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerRunnable.java&p1=directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerJob.java&r1=966259&r2=966705&rev=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerJob.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerRunnable.java Thu Jul 22 15:19:00 2010
@@ -21,13 +21,12 @@
package org.apache.directory.studio.ldapservers.jobs;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
import org.apache.directory.studio.ldapservers.model.LdapServerStatus;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osgi.util.NLS;
@@ -37,21 +36,21 @@ import org.eclipse.osgi.util.NLS;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StartLdapServerJob extends Job
+public class StartLdapServerRunnable implements StudioRunnableWithProgress
{
/** The server */
private LdapServer server;
/**
- * Creates a new instance of StartLdapServerJob.
+ * Creates a new instance of StartLdapServerRunnable.
*
* @param server
* the LDAP Server
*/
- public StartLdapServerJob( LdapServer server )
+ public StartLdapServerRunnable( LdapServer server )
{
- super( "" ); //$NON-NLS-1$
+ super();
this.server = server;
}
@@ -59,10 +58,40 @@ public class StartLdapServerJob extends
/**
* {@inheritDoc}
*/
- protected IStatus run( IProgressMonitor monitor )
+ public String getErrorMessage()
{
- // Setting the name of the Job
- setName( NLS.bind( Messages.getString( "StartLdapServerJob.Starting" ), new String[] { server.getName() } ) ); //$NON-NLS-1$
+ return NLS.bind( "Unable to start server ''{0}''", new String[]
+ { server.getName() } );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getLockedObjects()
+ {
+ return new Object[]
+ { server };
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return NLS.bind( Messages.getString( "StartLdapServerRunnable.StartServer" ), new String[] { server.getName() } ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run( StudioProgressMonitor monitor )
+ {
+ // Creating a Studio Progress Monitor
+ // StudioProgressMonitor studioConnectionProgressMonitor = new StudioProgressMonitor(
+ // LdapServersPluginConstants.PLUGIN_ID, monitor ); // TODO remove this?
// Setting the status on the server to 'starting'
server.setStatus( LdapServerStatus.STARTING );
@@ -88,7 +117,5 @@ public class StartLdapServerJob extends
}
}
}
-
- return Status.OK_STATUS;
}
}
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerWatchDogThread.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerWatchDogThread.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerWatchDogThread.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StartLdapServerWatchDogThread.java Thu Jul 22 15:19:00 2010
@@ -37,7 +37,7 @@ public class StartLdapServerWatchDogThre
/**
- * Creates a new instance of StartLdapServerJob.
+ * Creates a new instance of StartLdapServerWatchDogThread.
*
* @param server
* the LDAP Server
Copied: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerRunnable.java (from r966259, directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerJob.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerRunnable.java?p2=directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerRunnable.java&p1=directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerJob.java&r1=966259&r2=966705&rev=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerJob.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StopLdapServerRunnable.java Thu Jul 22 15:19:00 2010
@@ -21,13 +21,13 @@
package org.apache.directory.studio.ldapservers.jobs;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
+import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
import org.apache.directory.studio.ldapservers.model.LdapServerStatus;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osgi.util.NLS;
@@ -37,21 +37,20 @@ import org.eclipse.osgi.util.NLS;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StopLdapServerJob extends Job
+public class StopLdapServerRunnable implements StudioRunnableWithProgress
{
/** The server */
private LdapServer server;
/**
- * Creates a new instance of StartLdapServerJob.
+ * Creates a new instance of StartLdapServerRunnable.
*
* @param server
* the LDAP Server
*/
- public StopLdapServerJob( LdapServer server )
+ public StopLdapServerRunnable( LdapServer server )
{
- super( "" ); //$NON-NLS-1$
this.server = server;
}
@@ -59,11 +58,37 @@ public class StopLdapServerJob extends J
/**
* {@inheritDoc}
*/
- protected IStatus run( IProgressMonitor monitor )
+ public String getErrorMessage()
{
- // Setting the name of the Job
- setName( NLS.bind( Messages.getString( "StopLdapServerJob.Stopping" ), new String[] { server.getName() } ) ); //$NON-NLS-1$
+ return NLS.bind( "Unable to stop server ''{0}''", new String[]
+ { server.getName() } );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getLockedObjects()
+ {
+ return new Object[]
+ { server };
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return NLS.bind( Messages.getString( "StopLdapServerRunnable.StopServer" ), new String[] { server.getName() } ); //$NON-NLS-1$;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run( StudioProgressMonitor monitor )
+ {
// Setting the status on the server to 'stopping'
server.setStatus( LdapServerStatus.STOPPING );
@@ -79,7 +104,8 @@ public class StopLdapServerJob extends J
{
try
{
- ldapServerAdapter.stop( server, monitor );
+ ldapServerAdapter.stop( server, new StudioProgressMonitor( LdapServersPluginConstants.PLUGIN_ID,
+ monitor ) ); // TODO
}
catch ( Exception e )
{
@@ -88,7 +114,5 @@ public class StopLdapServerJob extends J
}
}
}
-
- return Status.OK_STATUS;
}
}
Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StudioLdapServerJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StudioLdapServerJob.java?rev=966705&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StudioLdapServerJob.java (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/StudioLdapServerJob.java Thu Jul 22 15:19:00 2010
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldapservers.jobs;
+
+
+import org.apache.directory.studio.common.core.jobs.StudioJob;
+import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
+import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.eclipse.core.runtime.jobs.Job;
+
+
+/**
+ * This class implements a {@link Job} that is used for {@link StudioRunnableWithProgress} runnables on LDAP Servers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioLdapServerJob extends StudioJob
+{
+ /**
+ * Creates a new instance of StudioLdapServerJob.
+ *
+ * @param runnables the runnables to run
+ */
+ public StudioLdapServerJob( StudioRunnableWithProgress... runnables )
+ {
+ super( runnables );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String[] getLockIdentifiers( Object[] objects )
+ {
+ String[] identifiers = new String[objects.length];
+ for ( int i = 0; i < identifiers.length; i++ )
+ {
+ Object o = objects[i];
+ if ( o instanceof LdapServer )
+ {
+ identifiers[i] = getLockIdentifier( ( LdapServer ) o );
+ }
+ else
+ {
+ identifiers[i] = getLockIdentifier( objects[i] );
+ }
+ }
+ return identifiers;
+ }
+
+
+ /**
+ * Gets the lock identifier for an {@link LdapServer} object.
+ *
+ * @param server
+ * the server
+ * @return
+ * the lock identifier for the server object
+ */
+ private String getLockIdentifier( LdapServer server )
+ {
+ return server.getId();
+ }
+
+
+ /**
+ * Gets the generic lock identifier for an object.
+ *
+ * @param object
+ * the object
+ * @return
+ * the lock identifier for the object
+ */
+ private String getLockIdentifier( Object object )
+ {
+ return ( object != null ? object.toString() : "null" ); //$NON-NLS-1$
+ }
+}
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages.properties?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages.properties (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages.properties Thu Jul 22 15:19:00 2010
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-StartLdapServerJob.Starting=Starting Server "{0}" ...
-StopLdapServerJob.Stopping=Stopping Server "{0}" ...
+StartLdapServerRunnable.StartServer=Start Server ''{0}''
+StopLdapServerRunnable.StopServer=Stop Server ''{0}''
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_de.properties?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_de.properties (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_de.properties Thu Jul 22 15:19:00 2010
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-StartLdapServerJob.Starting=TODO:Starting Server "{0}" ...
-StopLdapServerJob.Stopping=TODO:Stopping Server "{0}" ...
+StartLdapServerRunnable.StartServer=TODO:Start Server ''{0}''
+StopLdapServerRunnable.StopServer=TODO:Stop Server ''{0}''
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_fr.properties?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_fr.properties (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/jobs/messages_fr.properties Thu Jul 22 15:19:00 2010
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-StartLdapServerJob.Starting=D\u00E9marrage du serveur "{0}" ...
-StopLdapServerJob.Stopping=ArrĂȘt du serveur "{0}" ...
+StartLdapServerRunnable.StartServer=D\u00E9marrer le serveur ''{0}''
+StopLdapServerRunnable.StopServer=ArrĂȘter le serveur ''{0}''
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java Thu Jul 22 15:19:00 2010
@@ -21,6 +21,7 @@
package org.apache.directory.studio.ldapservers.model;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -39,7 +40,7 @@ public interface LdapServerAdapter
* the server
* @throws Exception
*/
- public void add( LdapServer server, IProgressMonitor monitor ) throws Exception;
+ public void add( LdapServer server, StudioProgressMonitor monitor ) throws Exception;
/**
@@ -62,7 +63,7 @@ public interface LdapServerAdapter
* @throws Exception
* if an error occurs when restarting the server
*/
- public void start( LdapServer server, IProgressMonitor monitor ) throws Exception;
+ public void start( LdapServer server, StudioProgressMonitor monitor ) throws Exception;
/**
@@ -75,5 +76,5 @@ public interface LdapServerAdapter
* @throws Exception
* if an error occurs when restarting the server
*/
- public void stop( LdapServer server, IProgressMonitor monitor ) throws Exception;
+ public void stop( LdapServer server, StudioProgressMonitor monitor ) throws Exception;
}
Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java?rev=966705&r1=966704&r2=966705&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java Thu Jul 22 15:19:00 2010
@@ -20,7 +20,9 @@
package org.apache.directory.studio.ldapservers.wizards;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.ldapservers.LdapServersManager;
+import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -85,7 +87,8 @@ public class NewServerWizard extends Wiz
// Letting the LDAP Server Adapter finish the creation of the server
try
{
- adapterExtension.getInstance().add( server, monitor );
+ adapterExtension.getInstance().add( server,
+ new StudioProgressMonitor( LdapServersPluginConstants.PLUGIN_ID, monitor ) ); // TODO
}
catch ( Exception e )
{