Java Code Examples for org.eclipse.emf.workspace.util.WorkspaceSynchronizer#getFile()
The following examples show how to use
org.eclipse.emf.workspace.util.WorkspaceSynchronizer#getFile() .
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: ProcessNavigatorActionProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @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; }
Example 2
Source File: NavigatorActionProvider.java From statecharts with Eclipse Public License 1.0 | 6 votes |
private IEditorInput getEditorInput() { for (EObject nextEObject : myDiagram.eResource().getContents()) { if (nextEObject == myDiagram) { return new FileEditorInput( WorkspaceSynchronizer.getFile(myDiagram.eResource())); } if (nextEObject instanceof Diagram) { break; } } URI uri = EcoreUtil.getURI(myDiagram); String editorName = uri.lastSegment() + "#" + myDiagram.eResource().getContents().indexOf(myDiagram); //$NON-NLS-1$ IEditorInput editorInput = new URIEditorInput(uri, editorName); return editorInput; }
Example 3
Source File: DiagramPartitioningUtil.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * Opens a subdiagram for a given {@link Diagram} */ public static IEditorPart openEditor(Diagram diagramToOpen) { IFile file = WorkspaceSynchronizer.getFile(diagramToOpen.eResource()); try { IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName()); final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (diagramToOpen.getElement() instanceof Statechart) { return wbPage.openEditor(new FileEditorInput(file), desc.getId()); } else if (diagramToOpen.getElement() instanceof State) { return wbPage.openEditor(new DiagramEditorInput(diagramToOpen), desc.getId()); } } catch (PartInitException e) { e.printStackTrace(); } return null; }
Example 4
Source File: SexecLaunchConfigurationDelegate.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override protected ISimulationEngine createExecutionContainer(final ILaunch launch, Statechart statechart) { try { Injector injector = getInjector(statechart, launch); IFile file = WorkspaceSynchronizer.getFile(statechart.eResource()); injector.injectMembers(this); for (IOperationExecutor mockup : mockups) { if (mockup instanceof JavaOperationMockup) { IProject project = file.getProject(); String classes = launch.getLaunchConfiguration().getAttribute(ISCTLaunchParameters.OPERATION_CLASS, ""); String[] split = classes.split(","); ((JavaOperationMockup) mockup).initOperationCallbacks(project, split); } } return factory.createExecutionContainer(statechart, launch); } catch (CoreException e) { e.printStackTrace(); return null; } }
Example 5
Source File: CrossflowNavigatorActionProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @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; }
Example 6
Source File: CrossflowNavigatorLinkHelper.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = CrossflowDiagramEditorPlugin.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) { CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
Example 7
Source File: CrossflowNavigatorLinkHelper.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @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; }
Example 8
Source File: ProcessDocumentProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @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; }
Example 9
Source File: ExtendendResourceLinkHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = ProcessDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return super.findSelection(anInput); } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { return new StructuredSelection(file); } return StructuredSelection.EMPTY; }
Example 10
Source File: ProcessDocumentProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @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; }
Example 11
Source File: CrossflowDocumentProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @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; }
Example 12
Source File: CrossflowDocumentProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @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; } }
Example 13
Source File: ValidateAction.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ private static void validate(DiagramEditPart diagramEditPart, View view) { IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null; if (target != null) { ProcessMarkerNavigationProvider.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); } }
Example 14
Source File: CrossflowDocumentProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) { IFile file = WorkspaceSynchronizer.getFile(changedResource); if (file != null) { try { file.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (CoreException ex) { CrossflowDiagramEditorPlugin.getInstance() .logError(Messages.CrossflowDocumentProvider_handleElementContentChanged, ex); // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged } } changedResource.unload(); fireElementContentAboutToBeReplaced(info.getEditorInput()); removeUnchangedElementListeners(info.getEditorInput(), info); info.fStatus = null; try { setDocumentContent(info.fDocument, info.getEditorInput()); } catch (CoreException e) { info.fStatus = e.getStatus(); } if (!info.fCanBeSaved) { info.setModificationStamp(computeModificationStamp(info)); } addUnchangedElementListeners(info.getEditorInput(), info); fireElementContentReplaced(info.getEditorInput()); }
Example 15
Source File: ProcessDocumentProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ public boolean isDeleted(Object element) { IDiagramDocument document = getDiagramDocument(element); if (document != null) { Resource diagramResource = document.getDiagram().eResource(); if (diagramResource != null) { IFile file = WorkspaceSynchronizer.getFile(diagramResource); return file == null || file.getLocation() == null || !file.getLocation().toFile().exists(); } } return super.isDeleted(element); }
Example 16
Source File: DiagramEditorInput.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (adapter == IStorage.class) { return WorkspaceSynchronizer.getFile(diagram.eResource()); } return super.getAdapter(adapter); }
Example 17
Source File: AbstractPackageImportUriMapper.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected Optional<IFile> getImportedFile(Resource context, String packageImport) { IFile file = WorkspaceSynchronizer.getFile(getContextResource(context)); if (file == null) return Optional.empty(); IPath importPath = file.getFullPath().removeLastSegments(1).append(packageImport); IFile wsFile = ResourcesPlugin.getWorkspace().getRoot().getFile(importPath); if (wsFile.exists()) { return Optional.of(wsFile); } return Optional.empty(); }
Example 18
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void validate(final DiagramEditPart diagramEditPart, final View view, final IProgressMonitor monitor) { final IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null; final Diagnostic diagnostic = validationMarkerProvider.runEMFValidator(view); validationMarkerProvider.createMarkers(target, diagnostic, diagramEditPart); final IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator( EvaluationMode.BATCH); validator.setIncludeLiveConstraints(true); if (view.isSetElement() && view.getElement() != null && view.getElement().eResource() != null) { final IStatus status = validator.validate(view.getElement(), monitor); validationMarkerProvider.createMarkers(target, status, diagramEditPart); } }
Example 19
Source File: DefaultValidationIssueStore.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void connect(Resource resource) { if (connected) { throw new IllegalStateException("Issue store is already connected to a resource"); } connectedResource = resource; IFile file = WorkspaceSynchronizer.getFile(resource); if ((file != null) && file.isAccessible()) { ResourcesPlugin.getWorkspace().addResourceChangeListener(this); connected = true; } initFromPersistentMarkers(); }
Example 20
Source File: ToggleSubRegionLayoutCommand.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public List getAffectedFiles() { if (view != null) { List result = new ArrayList(); IFile file = WorkspaceSynchronizer.getFile(view.eResource()); if (file != null) { result.add(file); } return result; } return super.getAffectedFiles(); }