org.eclipse.core.resources.IResourceStatus Java Examples

The following examples show how to use org.eclipse.core.resources.IResourceStatus. 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: BatchOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void executeOperation() throws JavaModelException {
	try {
		this.runnable.run(this.progressMonitor);
	} catch (CoreException ce) {
		if (ce instanceof JavaModelException) {
			throw (JavaModelException)ce;
		} else {
			if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
				Throwable e= ce.getStatus().getException();
				if (e instanceof JavaModelException) {
					throw (JavaModelException) e;
				}
			}
			throw new JavaModelException(ce);
		}
	}
}
 
Example #2
Source File: Resources.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static IStatus addOutOfSync(IStatus status, IResource resource) {
	IStatus entry= new Status(
		IStatus.ERROR,
		ResourcesPlugin.PI_RESOURCES,
		IResourceStatus.OUT_OF_SYNC_LOCAL,
		Messages.format(CorextMessages.Resources_outOfSync, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
		null);
	if (status == null) {
		return entry;
	} else if (status.isMultiStatus()) {
		((MultiStatus)status).add(entry);
		return status;
	} else {
		MultiStatus result= new MultiStatus(
			ResourcesPlugin.PI_RESOURCES,
			IResourceStatus.OUT_OF_SYNC_LOCAL,
			CorextMessages.Resources_outOfSyncResources, null);
		result.add(status);
		result.add(entry);
		return result;
	}
}
 
Example #3
Source File: BuildscriptGenerator.java    From cmake4eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Recursively creates the folder hierarchy needed for the build output, if
 * necessary. If the folder is created, its derived bit is set to true so the
 * CM system ignores the contents. If the resource exists, respect the
 * existing derived setting.
 *
 * @param folder
 *        a folder, somewhere below the project root
 */
private void createFolder(IFolder folder) throws CoreException {
  if (!folder.exists()) {
    // Make sure that parent folders exist
    IContainer parent = folder.getParent();
    if (parent instanceof IFolder && !parent.exists()) {
      createFolder((IFolder) parent);
    }

    // Now make the requested folder
    try {
      folder.create(IResource.DERIVED, true, monitor);
    } catch (CoreException e) {
      if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
        folder.refreshLocal(IResource.DEPTH_ZERO, monitor);
      else
        throw e;
    }
  }
}
 
Example #4
Source File: ProblemsLabelDecorator.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Compute the flags that were set on the give object. We expect an IResource for this computation, and we return
 * the flags according to the warnings or errors set on the resource.
 * 
 * @param obj
 *            A IResource (expected)
 * @return An integer representing an ERROR or a WARNING; -1 if the give object was not an IResource or when we got
 *         an exception retrieving the {@link IMarker}s from the resource.
 */
protected int computeAdornmentFlags(Object obj)
{
	try
	{
		if (obj instanceof IResource)
		{
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE);
		}
	}
	catch (CoreException e)
	{
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND)
		{
			return -1;
		}
		IdeLog.logWarning(EditorEplPlugin.getDefault(),
				"Error computing label-decoration adornment flags", e, EditorEplPlugin.DEBUG_SCOPE); //$NON-NLS-1$
	}
	return -1;
}
 
Example #5
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean isSupervised(IResource resource) throws TeamException {
try {
	if (resource.isTeamPrivateMember() || SVNWorkspaceRoot.isLinkedResource(resource)) return false;
	RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
	if (provider == null) return false;
	// TODO: what happens for resources that don't exist?
	// TODO: is it proper to use ignored here?
	ISVNLocalResource svnThing = SVNWorkspaceRoot.getSVNResourceFor(resource);
	if (svnThing.isIgnored()) {
		// An ignored resource could have an incoming addition (conflict)
		return (remoteSyncStateStore.getBytes(resource) != null) || 
				((remoteSyncStateStore.members(resource) != null) && (remoteSyncStateStore.members(resource).length > 0));
	}
	return true;
} catch (TeamException e) {
	// If there is no resource in coe this measn there is no local and no remote
	// so the resource is not supervised.
	if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
		return false;
	}
	throw e;
}
  }
 
Example #6
Source File: SynchronizerSyncInfoCache.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void purgeCache(IContainer root, boolean deep) throws SVNException {
	int depth = deep ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO;
	try {
		if (root.exists() || root.isPhantom()) {
			ResourcesPlugin.getWorkspace().getSynchronizer().flushSyncInfo(StatusCacheManager.SVN_BC_SYNC_KEY, root, depth);
		}
		if (deep) {
			accessor.removeRecursiveFromPendingCache(root);
		} else {
			accessor.removeFromPendingCache(root);
		}
	} catch (CoreException e) {
		if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
			// Must have been deleted since we checked
			return;
		}
		throw SVNException.wrapException(e);
	}		
}
 
Example #7
Source File: ProblemsLabelDecorator.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Computes the adornment flags for the given element.
 *
 * @param obj the element to compute the flags for
 *
 * @return the adornment flags
 */
protected ImageDescriptor computeAdornmentFlags(Object obj) {
	try {
		if (obj instanceof IResource) {
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE);
		}
	} catch (CoreException e) {
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
			return null;
		}

		EclipseCore.logStatus(e);
	}
	return null;
}
 
Example #8
Source File: ExceptionHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param e
 * @return
 */
@SuppressWarnings("unused")
private boolean isInvalidResouceName(CoreException e)
{
	IStatus status = e.getStatus();
	if (status == null)
	{
		return false;
	}
	if (!ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin()))
	{
		return false;
	}
	if (status.isMultiStatus())
	{
		final IStatus[] children = status.getChildren();
		for (int i = 0; i < children.length; ++i)
		{
			final IStatus child = children[i];
			if (!(ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin()) && child.getCode() == IResourceStatus.INVALID_RESOURCE_NAME))
			{
				return false;
			}
		}
		return true;
	}
	else
	{
		if (status.getCode() == IResourceStatus.INVALID_RESOURCE_NAME)
		{
			return true;
		}
	}
	return false;
}
 
Example #9
Source File: RemoteAnnotationStorage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public String getCharset() throws CoreException {
	InputStream contents = getContents();
	try {
		String charSet = SVNUIPlugin.getCharset(getName(), contents);
		return charSet;
	} catch (IOException e) {
		throw new SVNException(new Status(IStatus.ERROR, SVNUIPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, Policy.bind("RemoteAnnotationStorage.1", getFullPath().toString()), e)); //$NON-NLS-1$
	} finally {
		try {
			contents.close();
		} catch (IOException e1) {
			// Ignore
		}
	}
}
 
Example #10
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);
		}
	}
}
 
Example #11
Source File: SVNFileModificationValidator.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private IStatus getDefaultStatus(IFile file) {
	return 
	    isReadOnly(file)
		? new Status(IStatus.ERROR, SVNProviderPlugin.ID, IResourceStatus.READ_ONLY_LOCAL, Policy.bind("FileModificationValidator.fileIsReadOnly", new String[] { file.getFullPath().toString() }), null) 
			: Status.OK_STATUS;
}
 
Example #12
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Convenience method for showing an error dialog 
 * @param shell a valid shell or null
 * @param exception the exception to be report
 * @param title the title to be displayed
 * @param flags customizing attributes for the error handling
 * @return IStatus the status that was displayed to the user
 */
public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) {
	// Unwrap InvocationTargetExceptions
	if (exception instanceof InvocationTargetException) {
		Throwable target = ((InvocationTargetException)exception).getTargetException();
		// re-throw any runtime exceptions or errors so they can be handled by the workbench
		if (target instanceof RuntimeException) {
			throw (RuntimeException)target;
		}
		if (target instanceof Error) {
			throw (Error)target;
		} 
		return openError(providedShell, title, message, target, flags);
	}
	
	// Determine the status to be displayed (and possibly logged)
	IStatus status = null;
	boolean log = false;
	if (exception instanceof CoreException) {
		status = ((CoreException)exception).getStatus();
		log = ((flags & LOG_CORE_EXCEPTIONS) > 0);
	} else if (exception instanceof TeamException) {
		status = ((TeamException)exception).getStatus();
		log = ((flags & LOG_TEAM_EXCEPTIONS) > 0);
	} else if (exception instanceof InterruptedException) {
		return new SVNStatus(IStatus.OK, Policy.bind("ok")); //$NON-NLS-1$
	} else if (exception != null) {
		status = new SVNStatus(IStatus.ERROR, Policy.bind("internal"), exception); //$NON-NLS-1$
		log = ((flags & LOG_OTHER_EXCEPTIONS) > 0);
		if (title == null) title = Policy.bind("SimpleInternal"); //$NON-NLS-1$
	}
	
	// Check for a build error and report it differently
	if (status.getCode() == IResourceStatus.BUILD_FAILED) {
		message = Policy.bind("buildError"); //$NON-NLS-1$
		log = true;
	}
	
	// Check for multi-status with only one child
	if (status.isMultiStatus() && status.getChildren().length == 1) {
		status = status.getChildren()[0];
	}
	if (status.isOK()) return status;
	
	// Log if the user requested it
	if (log) SVNUIPlugin.log(status);
	// Create a runnable that will display the error status
	
	String svnInterface = SVNUIPlugin.getPlugin().getPreferenceStore().getString(ISVNUIConstants.PREF_SVNINTERFACE);
	boolean loadError = svnInterface.equals("javahl") && status != null && status.getMessage() != null && status.getMessage().equals(SVNClientManager.UNABLE_TO_LOAD_DEFAULT_CLIENT);
	
	if (!loadError || loadErrorHandled) {
		final String displayTitle = title;
		final String displayMessage = message;
		final IStatus displayStatus = status;
		final IOpenableInShell openable = new IOpenableInShell() {
			public void open(Shell shell) {
				if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) {
					MessageDialog.openInformation(shell, Policy.bind("information"), displayStatus.getMessage()); //$NON-NLS-1$
				} else {
					ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus);
				}
			}
		};
		openDialog(providedShell, openable, flags);
	}
	
	if (loadError) loadErrorHandled = true;
	
	// return the status we display
	return status;
}
 
Example #13
Source File: XtextDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void handleCoreException(CoreException exception, String message) {
	if(exception.getStatus() == null || exception.getStatus().getCode() != IResourceStatus.RESOURCE_NOT_FOUND)
		super.handleCoreException(exception, message);
}
 
Example #14
Source File: ProblemsLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Computes the adornment flags for the given element.
 *
 * @param obj the element to compute the flags for
 *
 * @return the adornment flags
 */
protected int computeAdornmentFlags(Object obj) {
	try {
		if (obj instanceof IJavaElement) {
			IJavaElement element= (IJavaElement) obj;
			int type= element.getElementType();
			switch (type) {
				case IJavaElement.JAVA_MODEL:
				case IJavaElement.JAVA_PROJECT:
				case IJavaElement.PACKAGE_FRAGMENT_ROOT:
					int flags= getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
					switch (type) {
						case IJavaElement.PACKAGE_FRAGMENT_ROOT:
							IPackageFragmentRoot root= (IPackageFragmentRoot) element;
							if (flags != ERRORTICK_ERROR && root.getKind() == IPackageFragmentRoot.K_SOURCE && isIgnoringOptionalProblems(root.getRawClasspathEntry())) {
								flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS;
							}
							break;
						case IJavaElement.JAVA_PROJECT:
							IJavaProject project= (IJavaProject) element;
							if (flags != ERRORTICK_ERROR && flags != ERRORTICK_BUILDPATH_ERROR && isIgnoringOptionalProblems(project)) {
								flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS;
							}
							break;
					}
					return flags;
				case IJavaElement.PACKAGE_FRAGMENT:
					return getPackageErrorTicksFromMarkers((IPackageFragment) element);
				case IJavaElement.COMPILATION_UNIT:
				case IJavaElement.CLASS_FILE:
					return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
				case IJavaElement.PACKAGE_DECLARATION:
				case IJavaElement.IMPORT_DECLARATION:
				case IJavaElement.IMPORT_CONTAINER:
				case IJavaElement.TYPE:
				case IJavaElement.INITIALIZER:
				case IJavaElement.METHOD:
				case IJavaElement.FIELD:
				case IJavaElement.LOCAL_VARIABLE:
					ICompilationUnit cu= (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
					if (cu != null) {
						ISourceReference ref= (type == IJavaElement.COMPILATION_UNIT) ? null : (ISourceReference) element;
						// The assumption is that only source elements in compilation unit can have markers
						IAnnotationModel model= isInJavaAnnotationModel(cu);
						int result= 0;
						if (model != null) {
							// open in Java editor: look at annotation model
							result= getErrorTicksFromAnnotationModel(model, ref);
						} else {
							result= getErrorTicksFromMarkers(cu.getResource(), IResource.DEPTH_ONE, ref);
						}
						fCachedRange= null;
						return result;
					}
					break;
				default:
			}
		} else if (obj instanceof IResource) {
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null);
		}
	} catch (CoreException e) {
		if (e instanceof JavaModelException) {
			if (((JavaModelException) e).isDoesNotExist()) {
				return 0;
			}
		}
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
			return 0;
		}

		JavaPlugin.log(e);
	}
	return 0;
}
 
Example #15
Source File: N4JSResource.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 *
 * Discards the current content of the resource, sets the parser result as first slot, installs derived state (this
 * will build up the second slot again) and sends notifications that proxies have been resolved. The resource will
 * be even loaded if its already marked as loaded.
 *
 * If the second slot, that is the TModule, was already loaded and we just resolved the AST, then the existing
 * TModule is kept in the resource and rewired to the resolved AST.
 *
 * @param object
 *            the object which resource should be loaded
 * @return the loaded/resolved object
 */
private EObject demandLoadResource(EObject object) {
	TModule oldModule = null;
	EObject oldScript = null;
	ModuleAwareContentsList myContents = ((ModuleAwareContentsList) contents);
	try {
		oldModule = discardStateFromDescription(false);
		if (!myContents.isEmpty()) {
			oldScript = myContents.basicGet(0);
			myContents.sneakyClear();
		}
		// now everything is removed from the resource and contents is empty
		// stop sending notifications
		eSetDeliver(false);

		if (isLoaded) {
			// Loads the resource even its marked as being already loaded
			isLoaded = false;
		}
		superLoad(null);

		// manually send the notification
		eSetDeliver(true);
		EObject result = getParseResult().getRootASTElement();
		if (myContents.isEmpty()) {
			myContents.sneakyAdd(0, result);
			if (oldModule != null) {
				myContents.sneakyAdd(oldModule);
			}
			forceInstallDerivedState(false);
		} else {
			if (myContents.size() == 1) {
				if (oldModule != null) {
					myContents.sneakyAdd(oldModule);
				}
			}
			installDerivedState(false);
		}
		if (oldScript != null) {
			notifyProxyResolved(0, oldScript);
		}
		fullyPostProcessed = false;
		return result;
	} catch (IOException | IllegalStateException ioe) {
		if (myContents.isEmpty()) {
			myContents.sneakyAdd(oldScript);
			myContents.sneakyAdd(oldModule);
		}
		Throwable cause = ioe.getCause();
		if (cause instanceof CoreException) {
			IStatus status = ((CoreException) cause).getStatus();
			if (IResourceStatus.RESOURCE_NOT_FOUND == status.getCode()) {
				return object;
			}
		}
		logger.error("Error in demandLoadResource for " + getURI(), ioe);
		return object;
	}
}
 
Example #16
Source File: ExternalFoldersManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void openExternalFoldersProject(IProject project, IProgressMonitor monitor) throws CoreException {
	try {
		project.open(monitor);
	} catch (CoreException e1) {
		if (e1.getStatus().getCode() == IResourceStatus.FAILED_READ_METADATA) {
			// workspace was moved 
			// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=241400 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=252571 )
			project.delete(false/*don't delete content*/, true/*force*/, monitor);
			createExternalFoldersProject(project, monitor);
		} else {
			// .project or folder on disk have been deleted, recreate them
			IPath stateLocation = JavaCore.getPlugin().getStateLocation();
			IPath projectPath = stateLocation.append(EXTERNAL_PROJECT_NAME);
			projectPath.toFile().mkdirs();
			try {
			    FileOutputStream output = new FileOutputStream(projectPath.append(".project").toOSString()); //$NON-NLS-1$
			    try {
			        output.write((
			        		"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
			        		"<projectDescription>\n" + //$NON-NLS-1$
			        		"	<name>" + EXTERNAL_PROJECT_NAME + "</name>\n" + //$NON-NLS-1$ //$NON-NLS-2$
			        		"	<comment></comment>\n" + //$NON-NLS-1$
			        		"	<projects>\n" + //$NON-NLS-1$
			        		"	</projects>\n" + //$NON-NLS-1$
			        		"	<buildSpec>\n" + //$NON-NLS-1$
			        		"	</buildSpec>\n" + //$NON-NLS-1$
			        		"	<natures>\n" + //$NON-NLS-1$
			        		"	</natures>\n" + //$NON-NLS-1$
			        		"</projectDescription>").getBytes()); //$NON-NLS-1$
			    } finally {
			        output.close();
			    }
			} catch (IOException e) {
				// fallback to re-creating the project
				project.delete(false/*don't delete content*/, true/*force*/, monitor);
				createExternalFoldersProject(project, monitor);
			}
		}
		project.open(monitor);
	}
}
 
Example #17
Source File: UIUtil.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a folder resource given the folder handle.
 * 
 * @param folderHandle
 *            the folder handle to create a folder resource for
 * @param monitor
 *            the progress monitor to show visual progress with
 * @exception CoreException
 *                if the operation fails
 * @exception OperationCanceledException
 *                if the operation is canceled
 */
public static void createFolder( IFolder folderHandle,
		IProgressMonitor monitor ) throws CoreException
{
	try
	{
		// Create the folder resource in the workspace
		// Update: Recursive to create any folders which do not exist
		// already
		if ( !folderHandle.exists( ) )
		{
			IPath path = folderHandle.getFullPath( );
			IWorkspaceRoot root = ResourcesPlugin.getWorkspace( ).getRoot( );
			int numSegments = path.segmentCount( );
			if ( numSegments > 2
					&& !root.getFolder( path.removeLastSegments( 1 ) )
							.exists( ) )
			{
				// If the direct parent of the path doesn't exist, try
				// to create the
				// necessary directories.
				for ( int i = numSegments - 2; i > 0; i-- )
				{
					IFolder folder = root.getFolder( path.removeLastSegments( i ) );
					if ( !folder.exists( ) )
					{
						folder.create( false, true, monitor );
					}
				}
			}
			folderHandle.create( false, true, monitor );
		}
	}
	catch ( CoreException e )
	{
		// If the folder already existed locally, just refresh to get
		// contents
		if ( e.getStatus( ).getCode( ) == IResourceStatus.PATH_OCCUPIED )
			folderHandle.refreshLocal( IResource.DEPTH_INFINITE,
					new SubProgressMonitor( monitor, 500 ) );
		else
			throw e;
	}

	if ( monitor.isCanceled( ) )
		throw new OperationCanceledException( );
}
 
Example #18
Source File: DoUpdateImplementation.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private int doUpdateCluster() {
	int clusterIndex = 0;

	final List<Delta> changedDeltas = Lists.newArrayList();
	while (!queue.isEmpty()) {
		checkCancelled();
		if (!continueProcessing(clusterIndex)) {
			break;
		}
		URI changedURI = null;
		Resource resource = null;
		Delta newDelta = null;

		try {
			// Load the resource and create a new resource description
			LoadResult loadResult = loadOperation.next();
			changedURI = loadResult.getUri();
			progress.subTask("Linking " + changedURI.lastSegment() + " and dependencies");
			URI actualResourceURI = loadResult.getResource().getURI();
			resource = state.addResource(loadResult.getResource(), resourceSet);
			reportProgress();

			if (!removeFromQueue(changedURI)) {
				break;
			}

			buildLogger.log("Linking " + changedURI);
			newDelta = resolveLinks(actualResourceURI, resource);
		} catch (final WrappedException ex) {
			if (ex instanceof LoadOperationException) {
				changedURI = ((LoadOperationException) ex).getUri();
			}
			Throwable cause = ex.getCause();
			boolean wasResourceNotFound = false;
			if (cause instanceof CoreException) {
				if (IResourceStatus.RESOURCE_NOT_FOUND == ((CoreException) cause).getStatus()
						.getCode()) {
					wasResourceNotFound = true;
				}
			}
			if (changedURI == null) {
				LOGGER.error("Error loading resource", ex); //$NON-NLS-1$
			} else {
				if (!removeFromQueue(changedURI)) {
					break;
				}
				if (!wasResourceNotFound)
					LOGGER.error("Error loading resource from: " + changedURI.toString(), ex); //$NON-NLS-1$
				if (resource != null) {
					resourceSet.getResources().remove(resource);
				}
				newDelta = createRemoveDelta(changedURI);
			}
		}

		if (newDelta != null) {
			clusterIndex++;
			if (processNewDelta(newDelta)) {
				changedDeltas.add(newDelta);
			}
		}
	}
	loadOperation.cancel();
	queueAffectedResources(changedDeltas);
	return clusterIndex;
}
 
Example #19
Source File: NewFolderDialogOfHs.java    From translationstudio8 with GNU General Public License v2.0 votes vote down vote up
/**
		 * Checks if the folder name is valid.
		 *
		 * @return null if the new folder name is valid.
		 * 	a message that indicates the problem otherwise.
		 */
		@SuppressWarnings("restriction")
		private boolean validateFolderName() {
			String name = folderNameField.getText();
			IWorkspace workspace = container.getWorkspace();
			IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);

			if ("".equals(name)) { //$NON-NLS-1$
				updateStatus(IStatus.ERROR,
						IDEWorkbenchMessages.NewFolderDialog_folderNameEmpty);
				return false;
			}
			if (nameStatus.isOK() == false) {
				updateStatus(nameStatus);
				return false;
			}
			// 修改创建文件夹时,所进行的文件名特殊字符验证	--robert	2013-07-01
			String result = null;
			if ((result = CommonFunction.validResourceName(name)) != null) {
				updateStatus(new ResourceStatus(IResourceStatus.INVALID_VALUE, null, result));
				return false;
			}
			
			IPath path = new Path(name);
			if (container.getFolder(path).exists()
					|| container.getFile(path).exists()) {
				updateStatus(IStatus.ERROR, NLS.bind(
						IDEWorkbenchMessages.NewFolderDialog_alreadyExists, name));
				return false;
			}
			updateStatus(IStatus.OK, ""); //$NON-NLS-1$
			return true;
		}