1 20 21 package org.apache.directory.ldapstudio.browser.core.jobs; 22 23 24 import java.util.ArrayList ; 25 import java.util.Arrays ; 26 import java.util.List ; 27 28 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages; 29 import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent; 30 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry; 31 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 32 33 34 public class ReloadSchemasJob extends AbstractAsyncBulkJob 35 { 36 37 private IConnection[] connections; 38 39 40 public ReloadSchemasJob( IConnection[] connections ) 41 { 42 this.connections = connections; 43 setName( connections.length == 1 ? BrowserCoreMessages.jobs__reload_schemas_name_1 44 : BrowserCoreMessages.jobs__reload_schemas_name_n ); 45 } 46 47 48 protected IConnection[] getConnections() 49 { 50 return connections; 51 } 52 53 54 protected Object [] getLockedObjects() 55 { 56 List l = new ArrayList (); 57 l.addAll( Arrays.asList( connections ) ); 58 return l.toArray(); 59 } 60 61 62 protected void executeBulkJob( ExtendedProgressMonitor monitor ) 63 { 64 65 monitor.beginTask( " ", connections.length + 1 ); monitor.reportProgress( " " ); 68 for ( int i = 0; i < connections.length; i++ ) 69 { 70 71 monitor.setTaskName( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__reload_schemas_task, new String [] 72 { connections[i].getName() } ) ); 73 monitor.worked( 1 ); 74 75 if ( connections[i].isOpened() ) 76 { 77 connections[i].reloadSchema( monitor ); 78 } 79 } 80 } 81 82 83 protected void runNotification() 84 { 85 for ( int i = 0; i < connections.length; i++ ) 86 { 87 EventRegistry.fireConnectionUpdated( new ConnectionUpdateEvent( connections[i], 88 ConnectionUpdateEvent.EventDetail.SCHEMA_LOADED ), this ); 89 } 90 } 91 92 93 protected String getErrorMessage() 94 { 95 return connections.length == 1 ? BrowserCoreMessages.jobs__reload_schemas_error_1 96 : BrowserCoreMessages.jobs__reload_schemas_error_n; 97 } 98 } 99 | Popular Tags |