Java Code Examples for org.eclipse.emf.common.util.URI#decode()
The following examples show how to use
org.eclipse.emf.common.util.URI#decode() .
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: GamlSyntacticConverter.java From gama with GNU General Public License v3.0 | 6 votes |
public static String getAbsoluteContainerFolderPathOf(final Resource r) { URI uri = r.getURI(); if (uri.isFile()) { uri = uri.trimSegments(1); return uri.toFileString(); } else if (uri.isPlatform()) { final IPath path = GamlResourceServices.getPathOf(r); final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); final IContainer folder = file.getParent(); return folder.getLocation().toString(); } return URI.decode(uri.toString()); // final IPath fullPath = file.getLocation(); // path = fullPath; // toOSString ? // if (path == null) { return null; } // return path.uptoSegment(path.segmentCount() - 1); }
Example 2
Source File: CheckPreferencesHelper.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Internal operation to unmarshal a single string into a string array. * * @param marshaled * as read from preferences * @param typeId * of expected element type. * @return array of individual string representations of the elements. */ private static String[] unmarshalArray(final String marshaled, final char typeId) { if (marshaled == null) { return new String[0]; } String[] values = marshaled.split(SEPARATOR); if (values.length == 0) { return values; } if (values[0] == null || values[0].length() < 1) { return new String[0]; } // Remove the type indicator from the first element, and type check: if (typeId != values[0].charAt(0)) { throw new IllegalStateException(); } for (int i = 0; i < values.length; i++) { values[i] = URI.decode(i == 0 ? values[i].substring(1) : values[i]); } return values; }
Example 3
Source File: Category.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Method getNavigatorChildren() * * @see ummisco.gama.ui.navigator.contents.VirtualContent#getNavigatorChildren() */ @Override public Object[] getNavigatorChildren() { if (fileNames.isEmpty()) { return EMPTY; } final List<LinkedFile> files = new ArrayList<>(); final IFile file = getParent().getResource(); final String filePath = file.getFullPath().toString(); final URI uri = URI.createURI(filePath, false); for (final String fn : fileNames) { final String s = URI.decode(fn); if (s.startsWith("http")) { continue; } final IFile newFile = FileUtils.getFile(s, uri, true); if (newFile != null) { final LinkedFile proxy = new LinkedFile(this, newFile, s); files.add(proxy); } } return files.toArray(); }
Example 4
Source File: ProcessDocumentProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated BonitaSoft */ protected IDocument createDocument(Object element) throws CoreException { if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { throw new CoreException(new Status(IStatus.ERROR, org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditorPlugin.ID, 0, NLS.bind(Messages.ProcessDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$ "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ null)); } String id = null; if (element instanceof FileEditorInput) { FileEditorInput fInput = (FileEditorInput) element; id = fInput.getName(); } else if (element instanceof URIEditorInput) { id = URI.decode(((URIEditorInput) element).getURI().lastSegment()); } IDocument document = createEmptyDocument(id); setDocumentContent(document, (IEditorInput) element); setupDocument(element, document); return document; }
Example 5
Source File: AbstractDefaultFeatureValueProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected String getProjectName(EObject contextElement) { URI uri = EcoreUtil.getURI(contextElement); if (uri.isPlatformResource() && uri.segmentCount() > 1) { return URI.decode(uri.segment(1)); // 0 is resource } return "ProjectName"; }
Example 6
Source File: Index.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ @Override public String getSourceName() { final URI uri = delegate.getEObjectURI().trimFragment(); final String name = uri.lastSegment(); if (name != null) { final String extension = uri.fileExtension(); final String result = URI.decode(extension != null ? name + '.' + extension : name); return result.toUpperCase(Locale.getDefault()); } return null; }
Example 7
Source File: XtendUIResourceDescriptionManager.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private boolean isProjectDependency(URI deltaURI, URI candidateURI, Map<String, Boolean> checkedProjects) { if (deltaURI.isPlatformResource() && candidateURI.isPlatformResource()) { // replace escape sequence e.g. %20 by a proper char, e.g. ' ' (blank) String deltaProjectName = URI.decode(deltaURI.segment(1)); // avoid checking the same project again Boolean prev = checkedProjects.get(deltaProjectName); if (prev == null) { IProject deltaProject = workspaceRoot.getProject(deltaProjectName); // check if the delta is for a resource from an IJavaProject if (deltaProject.isAccessible() && JavaCore.create(deltaProject).exists()) { // same here, replace escape sequences by proper chars String candidateProjectName = URI.decode(candidateURI.segment(1)); IProject candidateProject = workspaceRoot.getProject(candidateProjectName); if (candidateProject.isAccessible() && JavaCore.create(deltaProject).exists()) { if (candidateProject.equals(deltaProject)) { return checked(checkedProjects, deltaProjectName, true); } try { if (Arrays.asList(candidateProject.getReferencedProjects()).contains(deltaProject)) { return checked(checkedProjects, deltaProjectName, true); } } catch (CoreException e) { return checked(checkedProjects, deltaProjectName, false); } } } return checked(checkedProjects, deltaProjectName, false); } return prev; } return false; }
Example 8
Source File: BosArchiveProcessor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public File createDiagram(final URL sourceFileURL, final IProgressMonitor progressMonitor) throws Exception { final File archiveFile = new File(URI.decode(sourceFileURL.getFile())); operation = createOperation(archiveFile); operation.run(progressMonitor); return null; }
Example 9
Source File: StorageAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected AbsoluteURI resolvePath(IProject project, SourceRelativeURI path) { String decodedPath = URI.decode(path.getURI().toString()); IResource candidate = project.findMember(decodedPath); if (candidate != null && candidate.exists()) return new AbsoluteURI(URI.createPlatformResourceURI(project.getFullPath() + "/" + decodedPath, true)); return null; }
Example 10
Source File: DiagramFileStoreBOSArchiveProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Set<IRepositoryFileStore> getFileStoreForConfiguration(final AbstractProcess process, final Configuration configuration) { final Set<IRepositoryFileStore> files = new HashSet<IRepositoryFileStore>(); final DiagramRepositoryStore diagramSotre = repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class); final String diagramFileName = URI.decode(process.eResource().getURI().lastSegment()); final IRepositoryFileStore diagram = diagramSotre.getChild(diagramFileName, true); if (diagram != null) { files.add(diagram); } return files; }
Example 11
Source File: DefinitionResourceProvider.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public ResourceBundle getResourceBundle(final ConnectorDefinition definition, final Locale locale) { if (definition == null || definition.eResource() == null) { return null; } final String cacheKey = getCacheKey(definition, locale); final ResourceBundle resourceBundle = resourceBundleCache.get(cacheKey); if (resourceBundle != null) { return resourceBundle; } final IRepositoryFileStore fileStore = store.getChild(URI.decode(definition.eResource().getURI().lastSegment()), true); if (fileStore == null) { return null; } ConnectorDefinition def = null; try { def = (ConnectorDefinition) fileStore.getContent(); } catch (final ReadFileStoreException e2) { BonitaStudioLog.error("Failed to retrieve connector definition", e2); } if (def == null) { return null; } final Resource emfResource = def.eResource(); if (emfResource == null) { return null; } String baseName = URI.decode(emfResource.getURI().lastSegment()); if (baseName.lastIndexOf(".") != -1) { baseName = baseName.substring(0, baseName.lastIndexOf(".")); } ResourceBundle bundle = null; try { if (fileStore.canBeShared()) { ResourceBundle.clearCache(); } bundle = ResourceBundle.getBundle(baseName, locale, pluginControl); } catch (final MissingResourceException e) { try { ResourceBundle.clearCache(); //Clear the cache to always have updated i18n for custom connectors bundle = ResourceBundle.getBundle(baseName, locale, storeControl); } catch (final MissingResourceException e1) { return null; } } resourceBundleCache.put(cacheKey, bundle); return bundle; }
Example 12
Source File: DefinitionResourceProvider.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public Set<Locale> getExistingLocale(final ConnectorDefinition definition) { final Set<Locale> result = new HashSet<>(); String defId = null; if (definition == null) { return result; } if (definition.eResource() == null) { defId = NamingUtils.toConnectorDefinitionFilename(definition.getId(), definition.getVersion(), false); } else { defId = URI.decode(definition.eResource().getURI().trimFileExtension().lastSegment()); } try { for (final IResource r : store.getResource().members()) { if (r.getFileExtension() != null && r.getFileExtension().equals("properties")) { final String resourceName = r.getName(); if (resourceName.length() >= defId.length()) { final String baseName = resourceName.substring(0, defId.length()); if (baseName.equals(defId)) { if (resourceName.substring(baseName.length()) .indexOf("_") != -1 && resourceName .substring(baseName.length()) .indexOf(".") != -1) { String language = resourceName .substring(baseName.length()); language = language.substring(1, language.lastIndexOf(".")); String country = null; String variant = null; if (language.indexOf("_") != -1) { final String[] split = language.split("_"); language = split[0]; country = split[1]; if (split.length == 3) { variant = split[2]; } } result.add(new Locale(language, country == null ? "" : country, variant == null ? "" : variant)); } } } } } } catch (final CoreException e) { BonitaStudioLog.error(e); } return result; }
Example 13
Source File: SaveCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void doSaveDiagram(final DiagramEditor editorPart) { boolean changed = false; final DiagramRepositoryStore diagramStore = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class); final MainProcess proc = findProc(editorPart); DiagramFileStore oldArtifact = null; final List<DiagramDocumentEditor> editorsWithSameResourceSet = new ArrayList<DiagramDocumentEditor>(); if (nameOrVersionChanged(proc, editorPart)) { IEditorReference[] editorReferences; editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); final IEditorInput editorInput = editorPart.getEditorInput(); final ResourceSet resourceSet = proc.eResource().getResourceSet(); maintainListOfEditorsWithSameResourceSet(editorsWithSameResourceSet, editorReferences, editorInput, resourceSet); oldArtifact = diagramStore.getChild(NamingUtils.toDiagramFilename(getOldProcess(proc)), true); changed = true; } try { final IEditorPart editorToSave = editorPart; if (changed && oldArtifact != null) { editorToSave.doSave(Repository.NULL_PROGRESS_MONITOR); ((DiagramDocumentEditor) editorToSave).close(true); final Set<String> formIds = new HashSet<String>(); for (final DiagramDocumentEditor diagramDocumentEditor : editorsWithSameResourceSet) { formIds.add(ModelHelper.getEObjectID(diagramDocumentEditor.getDiagramEditPart().resolveSemanticElement())); diagramDocumentEditor.close(true); } oldArtifact.renameLegacy(NamingUtils.toDiagramFilename(proc)); oldArtifact.open(); } else { final EObject root = editorPart.getDiagramEditPart().resolveSemanticElement(); final Resource res = root.eResource(); if (res != null) { final String procFile = URI.decode(res.getURI().lastSegment()); final DiagramFileStore fileStore = diagramStore.getChild(procFile, true); if (fileStore != null) { fileStore.save(editorPart); } } else { editorPart.doSave(Repository.NULL_PROGRESS_MONITOR); } } } catch (final Exception ex) { BonitaStudioLog.error(ex); } }
Example 14
Source File: ImportTemplateWizard.java From M2Doc with Eclipse Public License 1.0 | 2 votes |
/** * Constructor. * * @param containerFullPath * the container full path * @param fileName * the file name */ private ImportTemplateJob(IPath containerFullPath, String fileName) { super("Importing template " + URI.decode(importPage.getSelectedTemplateURI().toString())); this.containerFullPath = containerFullPath; this.fileName = fileName; }
Example 15
Source File: SelectTemplatePage.java From M2Doc with Eclipse Public License 1.0 | 2 votes |
/** * Sets the given {@link URI} to the given {@link Text}. * * @param text * the {@link Text} * @param uri * the {@link URI} */ private void setURI(final Text text, URI uri) { final String relativeTemplatePath = URI.decode(uri.deresolve(getBaseURI(page)).toString()); text.setText(relativeTemplatePath); }
Example 16
Source File: ValidateHandler.java From M2Doc with Eclipse Public License 1.0 | 2 votes |
/** * Consturctor. * * @param generation * the {@link Generation} to validate * @param shell * the {@link Shell} for error reporting */ private ValidateJob(Generation generation, Shell shell) { super("Validating " + URI.decode(generation.eResource().getURI().toString())); this.generation = generation; this.shell = shell; }
Example 17
Source File: EmfResourceUtil.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Gets the file name from the given URI. * * @param uri * the uri, may not be null * @return the the file name including file extension */ public static String getFileName(final URI uri) { return URI.decode(uri.lastSegment()); }
Example 18
Source File: EmfResourceUtil.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Gets the file name without file extension from the given URI. * * @param uri * the uri, may not be null * @return the file name <em>excluding</em> file extension */ public static String getFileNameWithoutExtension(final URI uri) { String fileName = uri.lastSegment(); int dotIdx = fileName.lastIndexOf('.'); return URI.decode(dotIdx == -1 ? fileName : fileName.substring(0, dotIdx)); }
Example 19
Source File: NewGenerationWizard.java From M2Doc with Eclipse Public License 1.0 | 2 votes |
/** * Gets the validation file name from the given genconf {@link URI}. * * @param genconfURI * the genconf {@link URI} * @return the validation file name from the given genconf {@link URI} */ private String getValidationFileName(URI genconfURI) { final String lastSegment = genconfURI.lastSegment(); return URI.decode(lastSegment.substring(0, lastSegment.length() - GenconfUtils.GENCONF_EXTENSION_FILE.length()) + "validation." + M2DocUtils.DOCX_EXTENSION_FILE); }
Example 20
Source File: NewGenerationWizard.java From M2Doc with Eclipse Public License 1.0 | 2 votes |
/** * Gets the template file name from the given genconf {@link URI}. * * @param genconfURI * the template {@link URI} * @return the validation file name from the given genconf {@link URI} */ private String getTemplateFileName(URI genconfURI) { final String lastSegment = genconfURI.lastSegment(); return URI.decode(lastSegment.substring(0, lastSegment.length() - GenconfUtils.GENCONF_EXTENSION_FILE.length()) + M2DocUtils.DOCX_EXTENSION_FILE); }