Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 128108 Details for
Bug 257273
[Patch] Create patch from "Compare With" group
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch v1
patch_v1.txt (text/plain), 8.84 KB, created by
Krzysztof Pog這dzi雟ki
on 2009-03-09 17:09:21 EDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
Krzysztof Pog這dzi雟ki
Created:
2009-03-09 17:09:21 EDT
Size:
8.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties,v >retrieving revision 1.93.2.1 >diff -u -r1.93.2.1 plugin.properties >--- plugin.properties 4 Mar 2009 09:15:40 -0000 1.93.2.1 >+++ plugin.properties 8 Mar 2009 22:14:59 -0000 >@@ -91,6 +91,9 @@ > CompareWithHistoryAction.label= &Local History... > CompareWithHistoryAction.tooltip= Compare the Selected Resource with Local History > >+CreateLocalPatch.label= &Create Patch... >+CreateLocalPatch.tooltip= Create Patch from the Selected Resource >+ > ReplaceWithMenu.label= Rep&lace With > > ReplaceFromHistoryAction.label= &Local History... >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml,v >retrieving revision 1.68.2.1 >diff -u -r1.68.2.1 plugin.xml >--- plugin.xml 4 Mar 2009 09:15:40 -0000 1.68.2.1 >+++ plugin.xml 8 Mar 2009 22:14:59 -0000 >@@ -192,6 +192,9 @@ > id="compareWithMenu"> > <separator > name="compareWithGroup"> >+ </separator> >+ <separator >+ name="localPatchGroup"> > </separator> > </menu> > </objectContribution> >@@ -280,6 +283,26 @@ > id="addFromHistoryAction"> > </action> > </objectContribution> >+ <objectContribution >+ adaptable="true" >+ id="org.eclipse.compare.GenerateDiffAction" >+ objectClass="org.eclipse.core.resources.IResource"> >+ <action >+ label="%CreateLocalPatch.label" >+ tooltip="%CreateLocalPatch.tooltip" >+ class="org.eclipse.compare.internal.GenerateDiffAction" >+ enablesFor="2" >+ id="generateDiff" >+ menubarPath="compareWithMenu/localPatchGroup"> >+ </action> >+ <menu >+ id="creatLocalPatch" >+ label="%CreateLocalPatch.label"> >+ <separator >+ name="org.eclipse.compare.generateDiffSeparator"> >+ </separator> >+ </menu> >+ </objectContribution> > </extension> > > <extension >Index: compare/org/eclipse/compare/internal/GenerateDiffAction.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/GenerateDiffAction.java >diff -N compare/org/eclipse/compare/internal/GenerateDiffAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/internal/GenerateDiffAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,178 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Krzysztof Poglodzinski (intuicje@gmail.com) - initial API and implementation >+ * Mariusz Tanski (mariusztanski@gmail.com) - initial API and implementation >+ * Kacper Zdanowicz (kacper.zdanowicz@gmail.com) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.compare.internal; >+ >+ >+import java.io.InputStream; >+ >+import org.eclipse.compare.CompareConfiguration; >+import org.eclipse.compare.contentmergeviewer.ITokenComparator; >+import org.eclipse.compare.contentmergeviewer.TokenComparator; >+import org.eclipse.compare.internal.merge.DocumentMerger; >+import org.eclipse.compare.internal.merge.DocumentMerger.IDocumentMergerInput; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.Document; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.Position; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+ >+ >+/* >+ * The "Generate diff" action >+ */ >+public class GenerateDiffAction extends BaseCompareAction implements IObjectActionDelegate { >+ >+ protected ResourceCompareInput fInput; >+ protected IWorkbenchPage fWorkbenchPage; >+ protected boolean showSelectAncestorDialog = true; >+ >+ public void run(ISelection selection) { >+ >+ IResource[] ir = Utilities.getResources(selection); >+ Shell shell = fWorkbenchPage.getWorkbenchWindow().getShell(); >+ boolean ok = fInput.setSelection(selection,shell, showSelectAncestorDialog); >+ if (!ok) return; >+ >+ DocumentMerger merger = null; >+ if(ir[0] instanceof IFile && ir[1] instanceof IFile) { >+ merger = createDocumentMerger((IFile)ir[0], (IFile)ir[1]); >+ merger.getCompareConfiguration().setLeftLabel(ir[0].getFullPath().toString()); >+ merger.getCompareConfiguration().setRightLabel(ir[1].getFullPath().toString()); >+ GenerateDiffFileWizard.run(merger, shell, true); >+ } >+ >+ >+ } >+ >+ protected boolean isEnabled(ISelection selection) { >+ if (fInput == null) { >+ CompareConfiguration cc= new CompareConfiguration(); >+ cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false)); >+ fInput= new ResourceCompareInput(cc); >+ } >+ return fInput.isEnabled(selection); >+ } >+ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ fWorkbenchPage= targetPart.getSite().getPage(); >+ } >+ >+ private DocumentMerger createDocumentMerger(IFile leftFile, IFile rightFile){ >+ IDocument leftDoc = convertFileToDocument(leftFile); >+ IDocument rightDoc = convertFileToDocument(rightFile); >+ if (leftDoc == null) { >+ leftDoc = new Document(); >+ } >+ if (rightDoc == null) { >+ rightDoc = new Document(); >+ } >+ DocumentMerger docMerger; >+ docMerger = new DocumentMerger(new LocalDiffMergerInput(leftDoc, rightDoc)); >+ try { >+ docMerger.doDiff(); >+ } catch (Exception e) { >+ throw new RuntimeException(e); >+ } >+ return docMerger; >+ } >+ >+ private IDocument convertFileToDocument(IFile file) { >+ if(file == null) >+ return null; >+ StringBuffer str = new StringBuffer(); >+ int c; >+ try{ >+ InputStream inputStream = file.getContents(); >+ while ((c = inputStream.read())!=-1){ >+ str.append((char)c); >+ } >+ inputStream.close(); >+ return new Document(str.toString()); >+ }catch(Exception ex){ >+ CompareUIPlugin.log(ex); >+ } >+ >+ return null; >+ } >+ >+ private class LocalDiffMergerInput implements IDocumentMergerInput { >+ >+ private IDocument leftDoc; >+ private IDocument rightDoc; >+ >+ public LocalDiffMergerInput(IDocument leftDoc, IDocument rightDoc) { >+ this.leftDoc = leftDoc ; >+ this.rightDoc= rightDoc; >+ } >+ >+ public ITokenComparator createTokenComparator(String line) { >+ return new TokenComparator(line); >+ } >+ public CompareConfiguration getCompareConfiguration() { >+ return fInput.getCompareConfiguration(); >+ } >+ public IDocument getDocument(char contributor) { >+ switch (contributor) { >+ case MergeViewerContentProvider.LEFT_CONTRIBUTOR: >+ return leftDoc; >+ case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: >+ return rightDoc; >+ case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: >+ return null; >+ } >+ return null; >+ } >+ public int getHunkStart() { >+ return 0; >+ } >+ public Position getRegion(char contributor) { >+ switch (contributor) { >+ case MergeViewerContentProvider.LEFT_CONTRIBUTOR: >+ return new Position(0, leftDoc.getLength()); >+ case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: >+ return new Position(0, rightDoc.getLength()); >+ case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: >+ return new Position(0, 0); >+ } >+ return null; >+ } >+ public boolean isHunkOnLeft() { >+ return false; >+ } >+ public boolean isIgnoreAncestor() { >+ return true; >+ } >+ public boolean isPatchHunk() { >+ return false; >+ } >+ >+ public boolean isShowPseudoConflicts() { >+ return false; >+ } >+ public boolean isThreeWay() { >+ return false; >+ } >+ public boolean isPatchHunkOk() { >+ return false; >+ } >+ >+ } >+ >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 257273
: 128108