当前位置: 首页>>代码示例>>Java>>正文


Java WorkspaceSynchronizer类代码示例

本文整理汇总了Java中org.eclipse.emf.workspace.util.WorkspaceSynchronizer的典型用法代码示例。如果您正苦于以下问题:Java WorkspaceSynchronizer类的具体用法?Java WorkspaceSynchronizer怎么用?Java WorkspaceSynchronizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WorkspaceSynchronizer类属于org.eclipse.emf.workspace.util包,在下文中一共展示了WorkspaceSynchronizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValid

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @see nexcore.tool.uml.ui.core.project.ITreeNode#isValid()
 */
public boolean isValid() {
    IFile file = WorkspaceSynchronizer.getFile(eobject.eResource());
    try {
        file.deleteMarkers(IMarker.PROBLEM, true, 0);
        IStatus valid = ModelUpdater.isValid(file);
        if (valid.getSeverity() != IStatus.OK) {
            if (valid.isMultiStatus()) {
                MultiStatus status = (MultiStatus) valid;
                IStatus[] children = status.getChildren();
                for (IStatus s : children) {
                    IMarker createMarker = file.createMarker(IMarker.PROBLEM);
                    createMarker.setAttribute(IMarker.MESSAGE, s.getMessage());
                    createMarker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
                }
            }
        }
        return valid.getSeverity() == IStatus.OK;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:26,代码来源:UMLFileTreeNode.java

示例2: createGlossary

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * Create glossary file
 * 
 * @param uri
 * @param monitor
 * @return Resource
 */
public static Resource createGlossary(URI uri, IProgressMonitor monitor) {
    monitor.beginTask("CreateGlossary", 3); //$NON-NLS-1$

    // UMLDomain umlDomain = DomainRegistry.getUMLDomain();
    IDomainModelHandler umlDomain = DomainRegistry.getUMLDomain();
    if (umlDomain == null) {
        umlDomain = ProjectUtil.createDomain(true);
    }

    IFile file = null;
    Resource resource = null;
    try {
        resource = DomainModelHandlerUtil.createUMLGlossary(uri);
        resource.save(DomainUtil.getSaveOptions());
        file = WorkspaceSynchronizer.getFile(resource);
        file.setCharset(UICoreConstant.PROJECT_CONSTANTS__ENCODING_UTF8, new NullProgressMonitor());
    } catch (Exception e) {
        Log.error(e);
        ALMLogger.getLog(UiCorePlugin.PLUGIN_ID).error(e.getMessage(), e);
    }

    return resource;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:31,代码来源:ProjectUtil.java

示例3: clearUnusedResource

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
     * 
     * 
     *   void
     */
    public void clearUnusedResource() {
        Resource nextResource;
        ResourceSet resourceSet = DomainRegistry.getUMLDomain().getResourceSet();

        EList<Resource> list = resourceSet.getResources();
        List<Resource> hostList = new ArrayList<Resource>();

        for (int i = 0; i < list.size(); i++) {
            nextResource = list.get(i);
            try {
                if (ProjectUtil.isModelFile(nextResource)) {
                    hostList.add(nextResource);

                    IFile file = WorkspaceSynchronizer.getFile(nextResource);
                    if (file != null && !file.exists()) {
//                        removeResource(nextResource);
                        ResourceUnloader.getInstance().put(nextResource);
                    }
                }
            } catch (Exception e) {
                // ignore
            }
        }
    }
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:30,代码来源:ResourceManager.java

示例4: initializeSection

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * 섹션 초기화
 * 
 * void
 */
private void initializeSection() {
    model = ((ModelMultiPageEditor) getPage().getEditor()).getModel();

    modelNameText.setText(model.getName());

    IFile modelFile = WorkspaceSynchronizer.getFile(model.eResource());
    modelLocationText.setText(modelFile.getFullPath().toPortableString());

    IPath rootLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation();
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(rootLocation.toString());
    stringBuilder.append(modelFile.getFullPath().toString());
    File file = new File(stringBuilder.toString());
    stringBuilder = new StringBuilder();
    stringBuilder.append(String.valueOf(file.length()));
    stringBuilder.append(BLANK_TEXT);
    stringBuilder.append(UMLMessage.getMessage(UMLMessage.LABEL_BYTE));
    modelSizeText.setText(stringBuilder.toString());
    modelLastModifiedDateText.setText(DateUtil.convertLongTimeStampToString(modelFile.getLocalTimeStamp()));
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:26,代码来源:OverviewGeneralSection.java

示例5: computeModificationStamp

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
private long computeModificationStamp(ResourceSetInfo info) {
	int result = 0;
	for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
			.hasNext();) {
		Resource nextResource = it.next();
		IFile file = WorkspaceSynchronizer.getFile(nextResource);
		if (file != null) {
			if (file.getLocation() != null) {
				result += file.getLocation().toFile().lastModified();
			} else {
				result += file.getModificationStamp();
			}
		}
	}
	return result;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:20,代码来源:StatemachineDocumentProvider.java

示例6: doValidateState

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected void doValidateState(Object element, Object computationContext)
		throws CoreException {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<IFile> files2Validate = new LinkedList<IFile>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null && file.isReadOnly()) {
				files2Validate.add(file);
			}
		}
		ResourcesPlugin.getWorkspace().validateEdit(
				(IFile[]) files2Validate.toArray(new IFile[files2Validate
						.size()]), computationContext);
	}

	super.doValidateState(element, computationContext);
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:24,代码来源:StatemachineDocumentProvider.java

示例7: updateCache

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected void updateCache(Object element) throws CoreException {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null && file.isReadOnly()) {
				info.setReadOnly(true);
				info.setModifiable(false);
				return;
			}
		}
		info.setReadOnly(false);
		info.setModifiable(true);
		return;
	}
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:22,代码来源:StatemachineDocumentProvider.java

示例8: getResetRule

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getResetRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(ResourcesPlugin.getWorkspace().getRuleFactory()
						.modifyRule(file));
			}
		}
		return new MultiRule(
				(ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
						.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:23,代码来源:StatemachineDocumentProvider.java

示例9: getSaveRule

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getSaveRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(computeSchedulingRule(file));
			}
		}
		return new MultiRule(
				(ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
						.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:22,代码来源:StatemachineDocumentProvider.java

示例10: getSynchronizeRule

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getSynchronizeRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(ResourcesPlugin.getWorkspace().getRuleFactory()
						.refreshRule(file));
			}
		}
		return new MultiRule(
				(ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
						.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:23,代码来源:StatemachineDocumentProvider.java

示例11: getValidateStateRule

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getValidateStateRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				files.add(file);
			}
		}
		return ResourcesPlugin
				.getWorkspace()
				.getRuleFactory()
				.validateEditRule(
						(IFile[]) files.toArray(new IFile[files.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:24,代码来源:StatemachineDocumentProvider.java

示例12: getNavigatorSelection

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
private ISelection getNavigatorSelection() {
	IDiagramDocument document = getDiagramDocument();
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		StatemachineNavigatorItem item = new StatemachineNavigatorItem(
				diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:21,代码来源:StatemachineDiagramEditor.java

示例13: validate

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
private static void validate(DiagramEditPart diagramEditPart, View view) {
	IFile target = view.eResource() != null ? WorkspaceSynchronizer
			.getFile(view.eResource()) : null;
	if (target != null) {
		StatemachineMarkerNavigationProvider.deleteMarkers(target);
	}
	Diagnostic diagnostic = runEMFValidator(view);
	createMarkers(target, diagnostic, diagramEditPart);
	IBatchValidator validator = (IBatchValidator) ModelValidationService
			.getInstance().newValidator(EvaluationMode.BATCH);
	validator.setIncludeLiveConstraints(true);
	if (view.isSetElement() && view.getElement() != null) {
		IStatus status = validator.validate(view.getElement());
		createMarkers(target, status, diagramEditPart);
	}
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:20,代码来源:ValidateAction.java

示例14: getEditorInput

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(
					WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#'
			+ diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:21,代码来源:StatemachineNavigatorLinkHelper.java

示例15: findSelection

import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; //导入依赖的package包/类
/**
 * @generated
 */
public IStructuredSelection findSelection(IEditorInput anInput) {
	IDiagramDocument document = StatemachineDiagramEditorPlugin
			.getInstance().getDocumentProvider()
			.getDiagramDocument(anInput);
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		StatemachineNavigatorItem item = new StatemachineNavigatorItem(
				diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:23,代码来源:StatemachineNavigatorLinkHelper.java


注:本文中的org.eclipse.emf.workspace.util.WorkspaceSynchronizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。