private static String getLastSyncConnection(IContainer container) {
    if (container == null) {
      return null;
    }
    // only shows the decorator when user chooses to
    // remember the decision
    boolean remember = ResourceSynchronizationUtils.isRememberDecision(container);
    if (!remember) {
      return null;
    }

    String lastConnection = ResourceSynchronizationUtils.getLastSyncConnection(container);
    if (lastConnection == null) {
      return null;
    }

    ISiteConnection[] sites = SiteConnectionUtils.findSitesForSource(container, true);
    String target;
    for (ISiteConnection site : sites) {
      target = site.getDestination().getName();
      if (target.equals(lastConnection)) {
        return target;
      }
    }
    return null;
  }
Example #2
0
 private void deployWithFTP() {
   SynchronizeProjectAction action = new SynchronizeProjectAction();
   action.setActivePart(
       null, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
   action.setSelection(
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection());
   ISiteConnection[] sites = SiteConnectionUtils.findSitesForSource(selectedProject, true);
   if (sites.length > 1) {
     String lastConnection = ResourceSynchronizationUtils.getLastSyncConnection(selectedProject);
     if (lastConnection == null) {
       lastConnection = DeployPreferenceUtil.getDeployEndpoint(selectedProject);
     }
     if (lastConnection != null) {
       action.setSelectedSite(SiteConnectionUtils.getSiteWithDestination(lastConnection, sites));
     }
   }
   action.run(null);
 }