1 20 21 package org.apache.directory.ldapstudio.actions; 22 23 24 import java.net.MalformedURLException ; 25 import java.net.URL ; 26 27 import org.apache.directory.ldapstudio.Messages; 28 import org.eclipse.jface.action.Action; 29 import org.eclipse.jface.action.IAction; 30 import org.eclipse.swt.custom.BusyIndicator; 31 import org.eclipse.ui.IWorkbenchWindow; 32 import org.eclipse.update.search.BackLevelFilter; 33 import org.eclipse.update.search.EnvironmentFilter; 34 import org.eclipse.update.search.UpdateSearchRequest; 35 import org.eclipse.update.search.UpdateSearchScope; 36 import org.eclipse.update.ui.UpdateJob; 37 import org.eclipse.update.ui.UpdateManagerUI; 38 39 40 48 public class AddExtensionAction extends Action implements IAction 49 { 50 private IWorkbenchWindow window; 51 52 53 58 public AddExtensionAction( IWorkbenchWindow window ) 59 { 60 this.window = window; 61 setId( "org.apache.directory.ldapstudio.newExtensions" ); setText( Messages.getString( "AddExtensionAction.Add_Extensions" ) ); setToolTipText( Messages.getString( "AddExtensionAction.Search_for_new_extensions" ) ); } 65 66 67 70 public void run() 71 { 72 BusyIndicator.showWhile( window.getShell().getDisplay(), new Runnable () 73 { 74 public void run() 75 { 76 UpdateJob job = new UpdateJob( 77 Messages.getString( "AddExtensionAction.Searching_new_extensions" ), getSearchRequest() ); UpdateManagerUI.openInstaller( window.getShell(), job ); 79 } 80 81 82 private UpdateSearchRequest getSearchRequest() 83 { 84 UpdateSearchRequest result = new UpdateSearchRequest( UpdateSearchRequest 85 .createDefaultSiteSearchCategory(), new UpdateSearchScope() ); 86 result.addFilter( new BackLevelFilter() ); 87 result.addFilter( new EnvironmentFilter() ); 88 UpdateSearchScope scope = new UpdateSearchScope(); 89 try 90 { 91 String homeBase = System.getProperty( 92 "ldapstudio.homebase", Messages.getString( "AddExtensionAction.LDAP_Studio_Home_Base" ) ); URL url = new URL ( homeBase ); 94 scope.addSearchSite( Messages.getString( "AddExtensionAction.LDAP_Studio_Site" ), url, null ); } 96 catch ( MalformedURLException e ) 97 { 98 } 100 result.setScope( scope ); 101 return result; 102 } 103 } ); 104 } 105 } | Popular Tags |