org.eclipse.compare.ITypedElement Java Examples
The following examples show how to use
org.eclipse.compare.ITypedElement.
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: JavaHistoryActionImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
final ITypedElement[] buildEditions(ITypedElement target, IFile file) { // setup array of editions IFileState[] states= null; // add available editions try { states= file.getHistory(null); } catch (CoreException ex) { JavaPlugin.log(ex); } int count= 1; if (states != null) count+= states.length; ITypedElement[] editions= new ITypedElement[count]; editions[0]= new ResourceNode(file); if (states != null) for (int i= 0; i < states.length; i++) editions[i+1]= new HistoryItem(target, states[i]); return editions; }
Example #2
Source File: CompareAction.java From ADT_Frontend with MIT License | 6 votes |
/** * Returns the file extension registered in SFS for the given abap object * for opening the right compare editor. For properties file the default * extension (txt) is returned for opening the text compare editor. </br> * </br> * eg: If the selection is on an abap class file, the method returns the the * SFS file extension registered for the abap class in ADT to open the abap * compare editor. If the selection is on an xml file, the methods returns * the text editor extension (txt) to open a text compare editor. * * @param file * File to compare * @param abapObject * Parent abap object of the selected file * @return File extension for the compare editor */ private String getFileExtension(IAbapGitFile file, IAbapGitObject abapObject) { if (isSourceCodeFile(file)) { IFile objectFile = (IFile) AdtUriMappingServiceFactory.createUriMappingService().getPlatformResource( new UriMappingContext(this.view.getProject()), URI.create(abapObject.getUri())); if (objectFile != null) { IAdtObjectLoader adtObjectLoader = AbapSource.getInstance().getAdtObjectLoader(objectFile); if (adtObjectLoader != null) { final IFile propsFile = adtObjectLoader.getLifecycleInfoFile(objectFile); if (propsFile != null) { final IFile sourceFile = adtObjectLoader.getSourceFile(propsFile); if (sourceFile != null) { return sourceFile.getFileExtension(); } } } } } return ITypedElement.TEXT_TYPE; }
Example #3
Source File: SVNCompareEditorInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Returns the label for the given input element. (which is a ResourceEditionNode) */ private String getVersionLabel(ITypedElement element) { if (element instanceof ResourceEditionNode) { ISVNRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource(); SVNRevision revision = edition.getLastChangedRevision(); if (revision == null) { revision = edition.getRevision(); } if (edition.isContainer()) { return Policy.bind("SVNCompareEditorInput.headLabel"); //$NON-NLS-1$ } else { return revision.toString(); } } return element.getName(); }
Example #4
Source File: SVNCompareEditorInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Returns the label for the given input element (which is a ResourceEditionNode). */ private String getLabel(ITypedElement element) { if (element instanceof ResourceEditionNode) { ISVNRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource(); SVNRevision revision = edition.getLastChangedRevision(); if (revision == null) { revision = edition.getRevision(); } if (edition instanceof ISVNRemoteFile) { return Policy.bind("nameAndRevision", edition.getName(), revision.toString()); //$NON-NLS-1$ } if (edition.isContainer()) { return Policy.bind("SVNCompareEditorInput.inHead", edition.getName()); //$NON-NLS-1$ } else { return Policy.bind("SVNCompareEditorInput.repository", new Object[] {edition.getName(), revision.toString()}); //$NON-NLS-1$ } } return element.getName(); }
Example #5
Source File: JavaTextBufferNode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
static final ITypedElement[] buildEditions(ITypedElement target, IFile file) { // setup array of editions IFileState[] states= null; // add available editions try { states= file.getHistory(null); } catch (CoreException ex) { JavaPlugin.log(ex); } int count= 1; if (states != null) count+= states.length; ITypedElement[] editions= new ITypedElement[count]; editions[0]= new ResourceNode(file); if (states != null) for (int i= 0; i < states.length; i++) editions[i+1]= new HistoryItem(target, states[i]); return editions; }
Example #6
Source File: ModulaMergeViewer.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private File saveAsTempFile(ITypedElement el) throws CoreException { if ( el instanceof IEncodedStreamContentAccessor) { IEncodedStreamContentAccessor acc = (IEncodedStreamContentAccessor) el; File temp; try { temp = File.createTempFile("mod", ".mod"); try(FileOutputStream fos = new FileOutputStream(temp)){ ByteStreams.copy(acc.getContents(), fos); } return temp; } catch (IOException e) { ExceptionHelper.rethrowAsCoreException(e); } } return null; }
Example #7
Source File: SVNCompareRevisionsInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Runs the compare operation and returns the compare result. */ protected Object prepareInput(IProgressMonitor monitor){ initLabels(); DiffNode diffRoot = new DiffNode(Differencer.NO_CHANGE); String localCharset = Utilities.getCharset(resource); for (int i = 0; i < logEntries.length; i++) { ITypedElement left = new TypedBufferedContent(resource); ResourceRevisionNode right = new ResourceRevisionNode(logEntries[i]); try { right.setCharset(localCharset); } catch (CoreException e) { } diffRoot.add(new VersionCompareDiffNode(left, right)); } return diffRoot; }
Example #8
Source File: SVNLocalCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { ITypedElement left= node.getLeft(); if (left instanceof BufferedResourceNode) ((BufferedResourceNode) left).commit(pm); ITypedElement right= node.getRight(); if (right instanceof BufferedResourceNode) ((BufferedResourceNode) right).commit(pm); IDiffElement[] children= node.getChildren(); if (children != null) { for (int i= 0; i < children.length; i++) { IDiffElement element= children[i]; if (element instanceof DiffNode) commit(pm, (DiffNode) element); } } }
Example #9
Source File: SVNLocalCompareSummaryInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { ITypedElement left= node.getLeft(); if (left instanceof BufferedResourceNode) ((BufferedResourceNode) left).commit(pm); ITypedElement right= node.getRight(); if (right instanceof BufferedResourceNode) ((BufferedResourceNode) right).commit(pm); IDiffElement[] children= node.getChildren(); if (children != null) { for (int i= 0; i < children.length; i++) { IDiffElement element= children[i]; if (element instanceof DiffNode) commit(pm, (DiffNode) element); } } }
Example #10
Source File: SVNLocalBaseCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { ITypedElement left= node.getLeft(); if (left instanceof BufferedResourceNode) ((BufferedResourceNode) left).commit(pm); ITypedElement right= node.getRight(); if (right instanceof BufferedResourceNode) ((BufferedResourceNode) right).commit(pm); IDiffElement[] children= node.getChildren(); if (children != null) { for (int i= 0; i < children.length; i++) { IDiffElement element= children[i]; if (element instanceof DiffNode) commit(pm, (DiffNode) element); } } }
Example #11
Source File: JavaTextBufferNode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the corresponding place holder type for the given element. * @return a place holder type (see ASTRewrite) or -1 if there is no corresponding placeholder */ static final int getPlaceHolderType(ITypedElement element) { if (element instanceof DocumentRangeNode) { JavaNode jn= (JavaNode) element; switch (jn.getTypeCode()) { case JavaNode.PACKAGE: return ASTNode.PACKAGE_DECLARATION; case JavaNode.CLASS: case JavaNode.INTERFACE: return ASTNode.TYPE_DECLARATION; case JavaNode.ENUM: return ASTNode.ENUM_DECLARATION; case JavaNode.ANNOTATION: return ASTNode.ANNOTATION_TYPE_DECLARATION; case JavaNode.CONSTRUCTOR: case JavaNode.METHOD: return ASTNode.METHOD_DECLARATION; case JavaNode.FIELD: return ASTNode.FIELD_DECLARATION; case JavaNode.INIT: return ASTNode.INITIALIZER; case JavaNode.IMPORT: case JavaNode.IMPORT_CONTAINER: return ASTNode.IMPORT_DECLARATION; case JavaNode.CU: return ASTNode.COMPILATION_UNIT; } } return -1; }
Example #12
Source File: RevisionAwareDifferencer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Called for every leaf or node compare to update progress information. */ protected void updateProgress(IProgressMonitor progressMonitor, Object node) { if (node instanceof ITypedElement) { ITypedElement element = (ITypedElement)node; progressMonitor.subTask(Policy.bind("CompareEditorInput.fileProgress", new String[] {element.getName()})); //$NON-NLS-1$ progressMonitor.worked(1); } }
Example #13
Source File: SVNFolderCompareEditorInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private String getLabel(ITypedElement element) { if (element instanceof SummaryEditionNode) { ISVNRemoteResource edition = ((SummaryEditionNode)element).getRemoteResource(); return Policy.bind("nameAndRevision", edition.getName(), edition.getRevision().toString()); //$NON-NLS-1$ } return element.getName(); }
Example #14
Source File: SVNFolderCompareEditorInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private String getVersionLabel(ITypedElement element) { if (element instanceof SummaryEditionNode) { ISVNRemoteResource edition = ((SummaryEditionNode)element).getRemoteResource(); return edition.getRevision().toString(); } return element.getName(); }
Example #15
Source File: SVNFolderCompareEditorInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void initLabels() { CompareConfiguration cc = getCompareConfiguration(); ITypedElement left = this.left; ITypedElement right = this.right; ITypedElement ancestor = this.ancestor; if (left != null) { cc.setLeftLabel(getLabel(left)); cc.setLeftImage(leftImage); } if (right != null) { cc.setRightLabel(getLabel(right)); cc.setRightImage(rightImage); } if (ancestor != null) { cc.setAncestorLabel(getLabel(ancestor)); cc.setAncestorImage(ancestorImage); } String title; if (ancestor != null) { title = Policy.bind("SVNCompareEditorInput.titleAncestor", new Object[] {guessResourceName(), getVersionLabel(ancestor), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ } else { String leftName = null; if (left != null) leftName = left.getName(); String rightName = null; if (right != null) rightName = right.getName(); if (leftName != null && !leftName.equals(rightName)) { title = Policy.bind("SVNCompareEditorInput.titleNoAncestorDifferent", new Object[] {leftName, getVersionLabel(left), rightName, getVersionLabel(right)} ); //$NON-NLS-1$ } else { title = Policy.bind("SVNCompareEditorInput.titleNoAncestor", new Object[] {guessResourceName(), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ } } setTitle(title); }
Example #16
Source File: PropertyCompareLocalResourceNode.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public boolean equals(Object other) { if (!recursive) { return true; } if (other instanceof ITypedElement) { String otherName = ((ITypedElement) other).getName(); return getName().equals(otherName); } return super.equals(other); }
Example #17
Source File: BuiltInConflictsCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private String getType() { FileNode node = new FileNode(fMineFile); String s = node.getType(); if (s != null) return s; return ITypedElement.UNKNOWN_TYPE; }
Example #18
Source File: FileNode.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public String getType() { int index = getName().indexOf("."); //$NON-NLS-1$ if (index != -1 && getName().length() > index + 1) { return getName().substring(index + 1); } return ITypedElement.TEXT_TYPE; }
Example #19
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tells which elements of the comparison are affected by the change. * * @param event element changed event * @return array of typed elements affected by the event. May return an empty array. * @since 3.5 */ private ITypedElement[] findAffectedElement(ElementChangedEvent event) { Object input= getInput(); if (!(input instanceof ICompareInput)) return new ITypedElement[0]; Set<ITypedElement> affectedElements= new HashSet<ITypedElement>(); ICompareInput ci= (ICompareInput)input; IJavaElementDelta delta= event.getDelta(); addAffectedElement(ci.getAncestor(), delta, affectedElements); addAffectedElement(ci.getLeft(), delta, affectedElements); addAffectedElement(ci.getRight(), delta, affectedElements); return affectedElements.toArray(new ITypedElement[affectedElements.size()]); }
Example #20
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Overridden to find and expand the first class. */ @Override protected void initialSelection() { Object firstClass= null; Object o= getRoot(); if (o != null) { Object[] children= getSortedChildren(o); if (children != null && children.length > 0) { for (int i= 0; i < children.length; i++) { o= children[i]; Object[] sortedChildren= getSortedChildren(o); if (sortedChildren != null && sortedChildren.length > 0) { for (int j= 0; j < sortedChildren.length; j++) { o= sortedChildren[j]; if (o instanceof DiffNode) { DiffNode dn= (DiffNode) o; ITypedElement e= dn.getId(); if (e instanceof JavaNode) { JavaNode jn= (JavaNode) e; int tc= jn.getTypeCode(); if (tc == JavaNode.CLASS || tc == JavaNode.INTERFACE) { firstClass= dn; } } } } } } } } if (firstClass != null) expandToLevel(firstClass, 1); else expandToLevel(2); }
Example #21
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Map<String, String> getCompilerOptions(ITypedElement input) { IJavaElement element= findJavaElement(input); if (element != null) { IJavaProject javaProject= element.getJavaProject(); if (javaProject != null) return javaProject.getOptions(true); } return null; }
Example #22
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IJavaElement findJavaElement(ITypedElement element) { if (element instanceof IResourceProvider) { IResource resource= ((IResourceProvider)element).getResource(); if (resource != null) { return JavaCore.create(resource); } } return null; }
Example #23
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void elementChanged(ElementChangedEvent event) { ITypedElement[] elements= findAffectedElement(event); for (int i= 0; i < elements.length; i++) { ITypedElement e= elements[i]; if (e == null || !(e instanceof IContentChangeNotifier)) continue; contentChanged((IContentChangeNotifier)e); } }
Example #24
Source File: PropertyCompareRemoteResourceNode.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public boolean equals(Object other) { if (!recursive) { return true; } if (other instanceof ITypedElement) { String otherName = ((ITypedElement) other).getName(); return getName().equals(otherName); } return super.equals(other); }
Example #25
Source File: DatastoreIndexesUpdatedStatusHandler.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected ICompareInput prepareCompareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { CompareConfiguration cc = getCompareConfiguration(); cc.setLeftEditable(true); cc.setRightEditable(false); cc.setLeftLabel(source.getName()); cc.setLeftImage(CompareUI.getImage(source)); cc.setRightLabel(generatedUpdate.getName()); cc.setRightImage(CompareUI.getImage(source)); // same type ITypedElement left = SaveableCompareEditorInput.createFileElement(source); ITypedElement right = new LocalDiskContent(generatedUpdate); return new DiffNode(left, right); }
Example #26
Source File: CompareInputResourceProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IResource getResource() { IResource resource = getResource(typedElement); if (resource == null) { if (typedElement == compareInput.getLeft()) { resource = getResource(compareInput.getRight()); } else { resource = getResource(compareInput.getLeft()); } } if (resource == null && compareInput instanceof ITypedElement) { resource = getResource((ITypedElement) compareInput); } return resource; }
Example #27
Source File: CompareInputResourceProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IResource getResource(ITypedElement typedElement) { if (typedElement == null) { return null; } IResource result = null; if (typedElement instanceof IResourceProvider) { IResourceProvider resourceProvider = (IResourceProvider) typedElement; result = resourceProvider.getResource(); } else if (typedElement instanceof org.eclipse.team.internal.ui.StorageTypedElement) { org.eclipse.team.internal.ui.StorageTypedElement storageTypedElement = (org.eclipse.team.internal.ui.StorageTypedElement) typedElement; IStorage bufferedStorage = storageTypedElement.getBufferedStorage(); result = getExistingFile(bufferedStorage != null ? bufferedStorage.getFullPath() : Path.EMPTY); } if (result == null) { IProject projectFromInput = getProjectFromInput(); List<String> path = getPath(typedElement); for (int i = 0; i < path.size() && result == null; i++) { IProject project = getWorkspaceRoot().getProject(path.get(i)); String subPath = IPath.SEPARATOR + Joiner.on(IPath.SEPARATOR).join(path.subList(i, path.size())); if (project.exists()) { result = getExistingFile(new Path(subPath)); } else if (projectFromInput != null) { String pathInProject = IPath.SEPARATOR + projectFromInput.getName() + subPath; result = getExistingFile(new Path(pathInProject)); } } } return result; }
Example #28
Source File: CompareInputResourceProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private List<String> getPath(ITypedElement typedElement) { List<String> names = Lists.newArrayList(typedElement.getName()); ITypedElement current = typedElement; while (current instanceof IDiffContainer) { names.add(current.getName()); current = ((IDiffContainer) current).getParent(); } Collections.reverse(names); List<String> segments = Lists.newArrayList(); for (String name : names) if (!Strings.isEmpty(name)) for (String seg : name.split("/")) segments.add(seg); return segments; }
Example #29
Source File: JavaAddElementFromHistoryImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the corresponding place holder type for the given element. * @return a place holder type (see ASTRewrite) or -1 if there is no corresponding placeholder */ private int getPlaceHolderType(ITypedElement element) { if (element instanceof DocumentRangeNode) { JavaNode jn= (JavaNode) element; switch (jn.getTypeCode()) { case JavaNode.PACKAGE: return ASTNode.PACKAGE_DECLARATION; case JavaNode.CLASS: case JavaNode.INTERFACE: return ASTNode.TYPE_DECLARATION; case JavaNode.ENUM: return ASTNode.ENUM_DECLARATION; case JavaNode.ANNOTATION: return ASTNode.ANNOTATION_TYPE_DECLARATION; case JavaNode.CONSTRUCTOR: case JavaNode.METHOD: return ASTNode.METHOD_DECLARATION; case JavaNode.FIELD: return ASTNode.FIELD_DECLARATION; case JavaNode.INIT: return ASTNode.INITIALIZER; case JavaNode.IMPORT: case JavaNode.IMPORT_CONTAINER: return ASTNode.IMPORT_DECLARATION; case JavaNode.CU: return ASTNode.COMPILATION_UNIT; } } return -1; }
Example #30
Source File: ModulaMergeViewer.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private BuildSettings getBuildSettings(ITypedElement left) { if (left instanceof IResourceProvider) { IResourceProvider resourceProvider = (IResourceProvider) left; IResource resource = resourceProvider.getResource(); if (resource instanceof IFile) { return BuildSettingsCache.createBuildSettings((IFile) resource); } } return null; }