org.eclipse.team.core.TeamException Java Examples

The following examples show how to use org.eclipse.team.core.TeamException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SVNPristineCopyQuickDiffProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Determine if the file represented by this quickdiff provider has changed with
 * respect to it's remote state. Return true if the remote contents should be
 * refreshed, and false if not.
 */
private boolean computeChange(IProgressMonitor monitor) throws TeamException {
	boolean needToUpdateReferenceDocument = false;
	if(isReferenceInitialized) {
		SyncInfo info = getSyncState(getFileFromEditor());	
		if(info == null && fLastSyncState != null) {
			return true;
		} else if(info == null) {
			return false;
		}
		
		if(fLastSyncState == null) {
			needToUpdateReferenceDocument = true;
		} else if(! fLastSyncState.equals(info)) {
			needToUpdateReferenceDocument = true; 
		}
		if(DEBUG) debug(fLastSyncState, info);
		fLastSyncState = info;
	}		
	return needToUpdateReferenceDocument;		
}
 
Example #2
Source File: CommentsManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * save the comments history
 */ 
public void saveCommentHistory() throws TeamException {
    IPath pluginStateLocation = SVNUIPlugin.getPlugin().getStateLocation();
    File tempFile = pluginStateLocation.append(COMMENT_HIST_FILE + ".tmp").toFile(); //$NON-NLS-1$
    File histFile = pluginStateLocation.append(COMMENT_HIST_FILE).toFile();
    try {
             XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile)));
             try {
                 writer.startTag(ELEMENT_COMMIT_HISTORY, null, false);
                 for (int i=0; i<previousComments.length && i<maxComments; i++)
                     writer.printSimpleTag(ELEMENT_COMMIT_COMMENT, previousComments[i]);
                 writer.endTag(ELEMENT_COMMIT_HISTORY);
             } finally {
                     writer.close();
             }
             if (histFile.exists()) {
                     histFile.delete();
             }
             boolean renamed = tempFile.renameTo(histFile);
             if (!renamed) {
                     throw new TeamException(new Status(IStatus.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$
             }
     } catch (IOException e) {
             throw new TeamException(new Status(IStatus.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.save",histFile.getAbsolutePath()), e)); //$NON-NLS-1$
     }
}
 
Example #3
Source File: RemoteResource.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNLogMessage[] getLogMessages(SVNRevision pegRevision,
		SVNRevision revisionStart, SVNRevision revisionEnd,
		boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions)
		throws TeamException {
   	ISVNClientAdapter svnClient = repository.getSVNClient();
	try {
		return svnClient.getLogMessages(getUrl(),
				pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath,
				limit, includeMergedRevisions);
	} catch (SVNClientException e) {
		throw new TeamException("Failed in RemoteResource.getLogMessages()",
				e);
	}
	finally {
		repository.returnSVNClient(svnClient);
	}
}
 
Example #4
Source File: CommentTemplatesPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean performOk() {
	int numTemplates = viewer.getList().getItemCount();
	String[] templates = new String[numTemplates];
	for (int i = 0; i < numTemplates; i++) {
		templates[i] = (String) viewer.getElementAt(i);
	}
	try {
		SVNUIPlugin.getPlugin().getRepositoryManager().getCommentsManager().replaceAndSaveCommentTemplates(templates);
	} catch (TeamException e) {
		SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_OTHER_EXCEPTIONS);
	}
	
	SVNUIPlugin.getPlugin().getPreferenceStore().setValue(ISVNUIConstants.PREF_COMMENTS_TO_SAVE, getCommentsToSave());
	
	return super.performOk();
}
 
Example #5
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public SyncInfo getSyncInfo(IResource resource) throws TeamException {
    if (resource == null)
    	return null;
	if( ! isSupervised( resource ) )
        return null;
	
	if (ignoreHiddenChanges && Util.isHidden(resource)) {
		return null;
	}
	
    //LocalResourceStatus localStatus = SVNWorkspaceRoot.getSVNResourceFor( resource );
    LocalResourceStatus localStatus = SVNProviderPlugin.getPlugin().getStatusCacheManager().getStatus(resource);

    RemoteResourceStatus remoteStatusInfo = null;
    byte[] remoteBytes = remoteSyncStateStore.getBytes( resource );
    if ((remoteBytes != null) && (remoteBytes != DUMMY_SYNC_BYTES)) {
        remoteStatusInfo = RemoteResourceStatus.fromBytes(remoteBytes);
    }

    SyncInfo syncInfo = new SVNStatusSyncInfo(resource, localStatus, remoteStatusInfo, comparator);
    syncInfo.init();

    return syncInfo;
}
 
Example #6
Source File: SVNSynchronizeParticipant.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public String decorateText(String text, Object element) {
	try {
		if (element instanceof ISynchronizeModelElement) {
			IResource resource = ((ISynchronizeModelElement) element).getResource();
			if (resource != null) {
				SVNStatusSyncInfo info = (SVNStatusSyncInfo) SVNWorkspaceSubscriber.getInstance().getSyncInfo(resource);
				if (info != null)
				{
					return text + info.getLabel(); //$NON-NLS-1$ //$NON-NLS-2$
				}
			}
		}
	} catch (TeamException e) {
	}
	return null;
}
 
Example #7
Source File: SVNProjectSetCapability.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Imports a existing SVN Project to the workbench
 * 
 * @param monitor
 *            project monitor
 * @return true if loaded, else false
 * @throws TeamException
 */

boolean importExistingProject(IProgressMonitor monitor)
        throws TeamException {
    if (directory == null) {
        return false;
    }
    try {
        monitor.beginTask("Importing", 3 * 1000);

        createExistingProject(new SubProgressMonitor(monitor, 1000));

        monitor.subTask("Refreshing " + project.getName());
        RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
        monitor.worked(1000);
        SVNWorkspaceRoot.setSharing(project, new SubProgressMonitor(
                monitor, 1000));

        return true;
    } catch (CoreException ce) {
        throw new SVNException("Failed to import External SVN Project"
                + ce, ce);
    } finally {
        monitor.done();
    }
}
 
Example #8
Source File: SVNProjectSetCapability.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
   * Override superclass implementation to load the referenced projects into
   * the workspace.
   * 
   * @see org.eclipse.team.core.ProjectSetSerializer#addToWorkspace(java.lang.String[],
   *      org.eclipse.team.core.ProjectSetSerializationContext,
   *      org.eclipse.core.runtime.IProgressMonitor)
   */
  public IProject[] addToWorkspace(String[] referenceStrings,
          ProjectSetSerializationContext context, IProgressMonitor monitor)
          throws TeamException {

      monitor = Policy.monitorFor(monitor);
      Policy.checkCanceled(monitor);

      // Confirm the projects to be loaded
      Map<IProject, LoadInfo> infoMap = new HashMap<IProject, SVNProjectSetCapability.LoadInfo>(referenceStrings.length);
      IProject[] projects = asProjects(context, referenceStrings, infoMap);
      projects = confirmOverwrite(context, projects);
      if (projects == null) {
          return new IProject[0];
      }
      // Load the projects
      try {
	return checkout(projects, infoMap, monitor);
} catch (MalformedURLException e) {
	throw SVNException.wrapException(e);
}
  }
 
Example #9
Source File: UpdateSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	IResource[] resourceArray = extractResources(resources, set);
	Map<ISVNRepositoryLocation, List<IResource>> items = groupByRepository(resourceArray, set);
	Set<ISVNRepositoryLocation> keys = items.keySet();
	for (Iterator<ISVNRepositoryLocation> iterator = keys.iterator(); iterator.hasNext();) {
		ISVNRepositoryLocation repos = iterator.next();
		List<IResource> resourceList = items.get(repos);
		resourceArray = new IResource[resourceList.size()];
		resourceList.toArray(resourceArray);
		SVNRevision revision = getRevisionForUpdate(resourceArray, set);
		IResource[] trimmedResources = trimResources(resourceArray);
		doUpdate(provider, monitor, trimmedResources, revision);
		if (SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_SHOW_OUT_OF_DATE_FOLDERS) && trimmedResources.length != resourceArray.length) {
			try {
				SVNWorkspaceSubscriber.getInstance().refresh(resourceArray, IResource.DEPTH_INFINITE, monitor);
			} catch (TeamException e) {}
		}
	}
}
 
Example #10
Source File: DirectorySelectionPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void initializeSelection() {
	String lastParent = null;
	
	try {
		lastParent = settings.get(LAST_PARENT + repositoryLocationProvider.getLocation().getLocation());
		if (lastParent != null && lastParent.length() > 0) {
			useSpecifiedNameButton.setSelection(true);
			useProjectNameButton.setSelection(false);
			text.setEnabled(true);
			text.setFocus();
			browseButton.setEnabled(true);
			text.setText(lastParent + "/" + repositoryLocationProvider.getProject().getName());
			text.setSelection(text.getText().indexOf(repositoryLocationProvider.getProject().getName()), text.getText().length());
		}
	} catch (TeamException e1) {}
	
	if (lastParent == null) {
		useSpecifiedNameButton.setSelection(false);
		text.setText("");
		text.setEnabled(false);
		browseButton.setEnabled(false);
		useProjectNameButton.setSelection(true);			
	}
}
 
Example #11
Source File: DirectorySelectionPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void setVisible(boolean visible) {
	super.setVisible(visible);
	if (visible) {
		if (useSpecifiedNameButton.getSelection()) {
			useSpecifiedNameButton.setFocus();
		}
		else {
			useProjectNameButton.setFocus();
		}
		try {
			String location = repositoryLocationProvider.getLocation().getLocation();
			if (lastLocation == null || !lastLocation.equals(location)) {
				initializeSelection();
			}
			lastLocation = location;
		} catch (TeamException e) {}
		setUrlText();
	}
}
 
Example #12
Source File: ResourceWithStatusUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static String getPropertyStatus(IResource resource) {
  ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
     String result = null;
     try {
          LocalResourceStatus status = svnResource.getStatus();
          if (status.isPropConflicted())
              result = Policy.bind("CommitDialog.conflicted"); //$NON-NLS-1$		            
          else if ((svnResource.getStatus() != null) &&
              (svnResource.getStatus().getPropStatus() != null) &&
              (svnResource.getStatus().getPropStatus().equals(SVNStatusKind.MODIFIED)))
              result = Policy.bind("CommitDialog.modified"); //$NON-NLS-1$		
             else
                 result = ""; //$NON-NLS-1$
} catch (TeamException e) {
    result = ""; //$NON-NLS-1$
}                   
  return result;
 }
 
Example #13
Source File: CheckoutCommand.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void refreshProject(IProject project, IProgressMonitor monitor)
		throws SVNException {
    if (monitor != null)
    {
    	monitor.beginTask("", 100); //$NON-NLS-1$
    	monitor.subTask(Policy.bind("SVNProvider.Creating_project_1", project.getName()));
    }
	try {
		// Register the project with Team
		RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
		RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
	} catch (TeamException e) {
		throw new SVNException("Cannot map the project with svn provider",e);
	} finally {
		if (monitor != null)
		{
			monitor.subTask(" ");
			monitor.done();
		}
	}
}
 
Example #14
Source File: SVNTeamProviderType.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void autoconnectSVNProject(IProject project, IProgressMonitor monitor) {
     try {
 		PeekStatusCommand command = new PeekStatusCommand(project);
 		try {
	command.execute();
} catch (SVNException e1) {
	if (e1.getMessage() != null && e1.getMessage().contains(SVNProviderPlugin.UPGRADE_NEEDED)) {
		if (!SVNProviderPlugin.handleQuestion("Upgrade Working Copy", project.getName() + " appears to be managed by Subversion, but the working copy needs to be upgraded.  Do you want to upgrade the working copy now?\n\nWarning:  This operation cannot be undone.")) {
			return;			
		}
	}
	 SVNWorkspaceRoot.upgradeWorkingCopy(project, monitor);
}
         SVNWorkspaceRoot.setSharing(project, monitor);
     } catch (TeamException e) {
         SVNProviderPlugin.log(IStatus.ERROR, "Could not auto-share project " + project.getName(), e); //$NON-NLS-1$
     }
 }
 
Example #15
Source File: KeyFilesManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void saveKeyFilesHistory() throws TeamException {
    IPath pluginStateLocation = SVNUIPlugin.getPlugin().getStateLocation();
    File tempFile = pluginStateLocation.append(KEYFILE_HIST_FILE + ".tmp").toFile(); //$NON-NLS-1$
    File histFile = pluginStateLocation.append(KEYFILE_HIST_FILE).toFile();
    try {
             XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile)));
             try {
                 writer.startTag(ELEMENT_KEYFILE_HISTORY, null, false);
                 for (int i=0; i<previousKeyFiles.length && i<MAX_FILES; i++)
                     writer.printSimpleTag(ELEMENT_KEYFILE, previousKeyFiles[i]);
                 writer.endTag(ELEMENT_KEYFILE_HISTORY);
             } finally {
                     writer.close();
             }
             if (histFile.exists()) {
                     histFile.delete();
             }
             boolean renamed = tempFile.renameTo(histFile);
             if (!renamed) {
                     throw new TeamException(new Status(Status.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$
             }
     } catch (IOException e) {
             throw new TeamException(new Status(Status.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.save",histFile.getAbsolutePath()), e)); //$NON-NLS-1$
     }
}
 
Example #16
Source File: BaseFile.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNAnnotations getAnnotations(SVNRevision fromRevision,
		SVNRevision toRevision, boolean includeMergedRevisions, boolean ignoreMimeType) throws TeamException {
	ISVNClientAdapter svnClient = getRepository().getSVNClient();
	try {
		SVNRevision pegRevision = null;
		ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
		if (localResource != null) {
			pegRevision = localResource.getRevision();
		}			
		return svnClient.annotate(
				localResourceStatus.getFile(), fromRevision, toRevision, pegRevision, ignoreMimeType, includeMergedRevisions);
	} catch (SVNClientException e) {
		throw new TeamException("Failed in BaseFile.getAnnotations()", e);
	}
	finally {
		getRepository().returnSVNClient(svnClient);
	}
}
 
Example #17
Source File: ResourceWithStatusUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static SVNStatusKind getStatusKind(IResource resource) {
	ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
	SVNStatusKind statusKind = null;
       try {
           LocalResourceStatus status = svnResource.getStatus();
	       if (status.isTextConflicted())
	    	   statusKind = SVNStatusKind.CONFLICTED;
	       else	            
            if (status.isAdded())
               statusKind = SVNStatusKind.ADDED;
              else
              if (status.isDeleted())
           	   statusKind = SVNStatusKind.DELETED;
              else
       	   if (status.isMissing())
       		   statusKind = SVNStatusKind.MISSING;
       	   else
       	   if (status.isReplaced())
       		   statusKind = SVNStatusKind.REPLACED;
       	   else
              if (status.isTextModified())
           	   statusKind = SVNStatusKind.MODIFIED;			           
              else
              if (!status.isManaged())
           	   statusKind = SVNStatusKind.UNVERSIONED;
       } catch (TeamException e) {}
	return statusKind;
}
 
Example #18
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void upgradeWorkingCopy(IProject project, IProgressMonitor monitor) throws TeamException {
	ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClient();
	try {
		client.upgrade(project.getLocation().toFile());
	} catch (SVNClientException e) {
		throw new TeamException(e.getMessage(), e);
	}
	finally {
		 SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
	}
}
 
Example #19
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ILogEntry[] getLogEntries(IProgressMonitor monitor, ISVNRemoteResource remoteResource, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, long limit, AliasManager tagManager, boolean includeMergedRevisions) throws TeamException
{
	// If filtering by revision range, pass upper/lower revisions to API and override limit.
	SVNRevision start = revisionStart;
	SVNRevision end = revisionEnd;
	long fetchLimit = limit;
       if (historySearchDialog != null && !historySearchDialog.getSearchAllLogs()) {
       	if (historySearchDialog.getStartRevision() != null || historySearchDialog.getEndRevision() != null) {
       		if (getClearSearchAction().isEnabled()) {
       			if (historySearchDialog.getStartRevision() != null) end = historySearchDialog.getStartRevision();
       			if (historySearchDialog.getEndRevision() != null) start = historySearchDialog.getEndRevision();
       			fetchLimit = 0;
       			getGetNextAction().setEnabled(false);
       		}
       	}
       }		
       ISVNClientAdapter svnClient = remoteResource.getRepository().getSVNClient();
       try {
        CancelableSVNLogMessageCallback callback = new CancelableSVNLogMessageCallback(monitor, svnClient);
		GetLogsCommand logCmd = new GetLogsCommand(remoteResource, pegRevision, start, end, stopOnCopy, fetchLimit, tagManager, includeMergedRevisions);
		logCmd.setCallback(callback);
		logCmd.run(monitor);
		return logCmd.getLogEntries(); 	
       }
       finally {
       	remoteResource.getRepository().returnSVNClient(svnClient);
       }
}
 
Example #20
Source File: AddIgnoredPatternCommand.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws SVNException {
	monitor = Policy.monitorFor(monitor);
       monitor.beginTask(null, 100); //$NON-NLS-1$
       if (!folder.getStatus().isManaged())
           throw new SVNException(IStatus.ERROR, TeamException.UNABLE,
               Policy.bind("SVNTeamProvider.ErrorSettingIgnorePattern", folder.getIResource().getFullPath().toString())); //$NON-NLS-1$
       ISVNClientAdapter svnClient = folder.getRepository().getSVNClient();
       try {
           OperationManager.getInstance().beginOperation(svnClient);
           
           try {
               svnClient.addToIgnoredPatterns(folder.getFile(), pattern);
               
               // broadcast changes to unmanaged children - they are the only candidates for being ignored
               ISVNResource[] members = folder.members(null, ISVNFolder.UNMANAGED_MEMBERS);
               IResource[] possiblesIgnores = new IResource[members.length];
               for (int i = 0; i < members.length;i++) {
                   possiblesIgnores[i] = ((ISVNLocalResource)members[i]).getIResource();
               }
               folder.refreshStatus(false);
               SVNProviderPlugin.broadcastSyncInfoChanges(possiblesIgnores, false);
               broadcastNestedFolders(possiblesIgnores);
           }
           catch (SVNClientException e) {
               throw SVNException.wrapException(e);
           }

       } finally {
           OperationManager.getInstance().endOperation();
           monitor.done();
           folder.getRepository().returnSVNClient(svnClient);
       }
}
 
Example #21
Source File: GetAnnotationsCommand.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor aMonitor) throws SVNException {
IProgressMonitor monitor = Policy.monitorFor(aMonitor);
monitor.beginTask(Policy.bind("RemoteFile.getAnnotations"), 100);//$NON-NLS-1$
      try {        	
          annotations = remoteFile.getAnnotations(fromRevision, toRevision, includeMergedRevisions, ignoreMimeType);
          monitor.worked(100);
      } catch (TeamException e) {
          throw SVNException.wrapException(e);
      } finally {
          monitor.done();
      }
  }
 
Example #22
Source File: SubclipseSubscriberChangeSetManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException {
         if (dispatchEvents.isEmpty()) {
             return false;
         }
         if (isShutdown())
             throw new OperationCanceledException();
         ResourceDiffTree[] locked = null;
         try {
             locked = beginDispath();
             for (Iterator iter = dispatchEvents.iterator(); iter.hasNext();) {
                 Event event = (Event) iter.next();
              switch (event.getType()) {
              case RESOURCE_REMOVAL:
                  handleRemove(event.getResource());
                  break;
              case RESOURCE_CHANGE:
                  handleChange(event.getResource(), ((ResourceEvent)event).getDepth());
                  break;
              default:
                  break;
              }
                 if (isShutdown())
                     throw new OperationCanceledException();
             }
         } catch (CoreException e) {
	throw TeamException.asTeamException(e);
} finally {
             try {
                 endDispatch(locked, monitor);
             } finally {
                 dispatchEvents.clear();
             }
         }
         return true;
     }
 
Example #23
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the sharing for a project to enable it to be used with the SVNTeamProvider.
    * This is used when a project has .svn directory but is not shared in Eclipse.
 * An exception is thrown if project does not have a remote directory counterpart
 */
public static void setSharing(IProject project, IProgressMonitor monitor) throws TeamException {

	// Ensure provided info matches that of the project
	LocalResourceStatus status = peekResourceStatusFor(project);

       // this folder needs to be managed but also to have a remote counter-part
       // because we need to know its url
       // we will change this exception !
       if (!status.hasRemote())
           throw new SVNException(new SVNStatus(IStatus.ERROR, Policy.bind("SVNProvider.infoMismatch", project.getName())));//$NON-NLS-1$

       String repositoryURL = null;
       ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClient();
       try {
           SVNProviderPlugin.disableConsoleLogging();
		ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
		if (info.getRepository() != null)
			repositoryURL = info.getRepository().toString();
	} catch (SVNClientException e) {
	} finally {
        SVNProviderPlugin.enableConsoleLogging();
           SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
	}
	if (repositoryURL == null)
		repositoryURL = status.getUrlString();

	// Ensure that the provided location is managed
	SVNProviderPlugin.getPlugin().getRepositories().getRepository(repositoryURL, false);

	// Register the project with Team
	RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
}
 
Example #24
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
	 * @see Plugin#shutdown()
	 */
	public void stop(BundleContext ctxt) throws Exception {
		super.stop(ctxt);
//		TeamUI.removePropertyChangeListener(listener);
		try {
			if (repositoryManager != null)
				repositoryManager.shutdown();
		} catch (TeamException e) {
			throw new CoreException(e.getStatus());
		}

        console.shutdown();
	}
 
Example #25
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * SessionResourceVariantByteStore of remoteSyncStateStore used to store (and flush) sync changes
 * register only direct parents of the changed resources.
 * If we want to be able to flush arbitrary subtree from the remoteSyncStateStore (event subtree which root
 * is unchanged resource), we have to cache all parent of the changed resources up to the top.
 * These sync DUMMY_SYNC_BYTES are stored as synch info, so upon this dummy bytes we then filter out
 * the actually unchanged sync data from the cache 
 * @param changedResource
 */
private void registerChangedResourceParent(IResource changedResource) throws TeamException
{
	IContainer parent = changedResource.getParent();
	if (parent == null) return;
	if (remoteSyncStateStore.getBytes(parent) == null)
	{
		remoteSyncStateStore.setBytes(parent, DUMMY_SYNC_BYTES);
		registerChangedResourceParent(parent);
	}    	
}
 
Example #26
Source File: OpenBugUrlAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected boolean isEnabled() throws TeamException {
	Object[] selectedObjects = selection.toArray();
	for (int i = 0; i < selectedObjects.length; i++) {
		if (selectedObjects[i] instanceof ILogEntry)
		{
			ILogEntry logEntry = (ILogEntry)selectedObjects[i];
			ProjectProperties projectProperties = ProjectProperties.getProjectProperties(logEntry.getResource().getResource());
			if (projectProperties == null) return false;
			LinkList linkList = projectProperties.getLinkList(logEntry.getComment());
			return linkList.getUrls().length != 0;
		}
	}
	return false;
}
 
Example #27
Source File: SyncSVNPathActionDelegate.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void updateSVNPath(String url) {
	Properties properties = new Properties();
	properties.setProperty("url", url);
	final ISVNRepositoryLocation[] root = new ISVNRepositoryLocation[1];
	SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
	try {
		root[0] = provider.getRepositories().createRepository(properties);
		// Validate the connection info.  This process also determines the rootURL
		provider.getRepositories().addOrUpdateRepository(root[0]);
	} catch (TeamException e) {
		e.printStackTrace();
	}
}
 
Example #28
Source File: HistoryDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void getLogEntries() {
   BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
        public void run() {
            try {
	            if (remoteResource == null) {
	                ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
					if ( localResource != null
					        && !localResource.getStatus().isAdded()
					        && localResource.getStatus().isManaged() ) {
					    remoteResource = localResource.getBaseResource();
					}
	            }
	            if (remoteResource != null) {
	            	if (SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_TAGS_IN_REMOTE))
	            		tagManager = new AliasManager(remoteResource.getUrl());
					SVNRevision pegRevision = remoteResource.getRevision();
					SVNRevision revisionEnd = new SVNRevision.Number(0);
					boolean stopOnCopy = store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY);
					int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH);
					long limit = entriesToFetch;
					entries = getLogEntries(remoteResource, pegRevision, revisionStart, revisionEnd, stopOnCopy, limit + 1, tagManager);
					long entriesLength = entries.length;
					if (entriesLength > limit) {
						ILogEntry[] fetchedEntries = new ILogEntry[entries.length - 1];
						for (int i = 0; i < entries.length - 1; i++)
							fetchedEntries[i] = entries[i];
						entries = fetchedEntries;
					} else getNextEnabled = false;
					if (entries.length > 0) {
						ILogEntry lastEntry = entries[entries.length - 1];
						long lastEntryNumber = lastEntry.getRevision().getNumber();
						revisionStart = new SVNRevision.Number(lastEntryNumber - 1);
					}		
	            }
			} catch (TeamException e) {
				SVNUIPlugin.openError(Display.getCurrent().getActiveShell(), null, null, e);
			}	
        }       
   });
}
 
Example #29
Source File: OverrideAndUpdateSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private IResource[] getIncoming(IResource[] resources) throws TeamException {
	List<IResource> incomingResources = new ArrayList<IResource>();
	for (int i = 0; i < resources.length; i++) {
		IResource resource = resources[i];
		SVNStatusSyncInfo info = (SVNStatusSyncInfo) SVNWorkspaceSubscriber.getInstance().getSyncInfo(resource);	
		if (info != null) {
			if (SyncInfo.getDirection(info.getKind()) == SyncInfo.INCOMING || SyncInfo.getDirection(info.getKind()) == SyncInfo.CONFLICTING)
				incomingResources.add(resource);
		}
	}
	IResource[] incomingArray = new IResource[incomingResources.size()];
	incomingResources.toArray(incomingArray);
	return incomingArray;
}
 
Example #30
Source File: TeamAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method invoked from <code>selectionChanged(IAction, ISelection)</code> 
 * to set the enablement status of the action. The instance variable 
 * <code>selection</code> will contain the latest selection so the methods
 * <code>getSelectedResources()</code> and <code>getSelectedProjects()</code>
 * will provide the proper objects.
 * 
 * This method can be overridden by subclasses but should not be invoked by them.
 */
protected void setActionEnablement(IAction action) {
	try {
		action.setEnabled(isEnabled());
	} catch (TeamException e) {
		if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) {
			// Enable the action to allow the user to discover the problem
			action.setEnabled(true);
		} else {
			action.setEnabled(false);
			// We should not open a dialog when determining menu enablements so log it instead
			SVNUIPlugin.log(e);
		}
	}
}