本文整理汇总了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;
}
示例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;
}
示例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
}
}
}
示例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()));
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}