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 128111 Details for
Bug 265032
While creating patch, possibility to choose which files should be included
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch v1
patch_v1.txt (text/plain), 69.86 KB, created by
Krzysztof Pog這dzi雟ki
on 2009-03-09 17:20:37 EDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
Krzysztof Pog這dzi雟ki
Created:
2009-03-09 17:20:37 EDT
Size:
69.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java >=================================================================== >--- compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java (revision 5) >+++ compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java (revision 6) >@@ -34,7 +34,6 @@ > import org.eclipse.compare.structuremergeviewer.DiffNode; > import org.eclipse.compare.structuremergeviewer.Differencer; > import org.eclipse.compare.structuremergeviewer.ICompareInput; >-import org.eclipse.compare.structuremergeviewer.IDiffElement; > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; >@@ -56,7 +55,10 @@ > import org.eclipse.jface.text.Document; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.Position; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTreeViewer; > import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.ICheckStateListener; > import org.eclipse.jface.viewers.IDoubleClickListener; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionChangedListener; >@@ -86,7 +88,9 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.TreeItem; > import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; > import org.eclipse.ui.model.BaseWorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; > import org.eclipse.ui.views.navigator.ResourceComparator; >@@ -97,50 +101,53 @@ > */ > public class GenerateDiffFileWizard extends Wizard { > >- //The initial size of this wizard. >+ // The initial size of this wizard. > protected final static int INITIAL_WIDTH = 300; > protected final static int INITIAL_HEIGHT = 350; > >- public static void run(DocumentMerger merger, Shell shell, boolean rightToLeft) { >+ public static void run(DocumentMerger merger, Shell shell, >+ boolean rightToLeft) { > final String title = CompareMessages.GenerateLocalDiff_title; >- final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(merger, rightToLeft); >+ final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard( >+ merger, rightToLeft); > wizard.setWindowTitle(title); > WizardDialog dialog = new WizardDialog(shell, wizard); >- >+ > dialog.addPageChangingListener(new IPageChangingListener() { > > public void handlePageChanging(PageChangingEvent event) { >- if(event.getTargetPage() instanceof LocationPage) { >+ if (event.getTargetPage() instanceof LocationPage) { > LocationPage page = (LocationPage) event.getTargetPage(); >- page.updateAssociatedResources(); >+ page.updateChangesControl(); > } > } >- >+ > }); >- >+ > dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); > dialog.open(); > } >+ > public static void run(IResource[] input, Shell shell) { > final String title = CompareMessages.GenerateLocalDiff_title; > final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(input); > wizard.setWindowTitle(title); > WizardDialog dialog = new WizardDialog(shell, wizard); >- >+ > dialog.addPageChangingListener(new IPageChangingListener() { > > public void handlePageChanging(PageChangingEvent event) { >- if(event.getTargetPage() instanceof LocationPage) { >+ if (event.getTargetPage() instanceof LocationPage) { > LocationPage page = (LocationPage) event.getTargetPage(); >- page.updateAssociatedResources(); >+ page.updateChangesControl(); > } > } >- >+ > }); >- >+ > dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); > dialog.open(); >- >+ > } > > protected class DirectionSelectionPage extends WizardPage { >@@ -169,33 +176,36 @@ > > layout.marginHeight = IDialogConstants.VERTICAL_MARGIN; > layout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN; >- layout.verticalSpacing = IDialogConstants.VERTICAL_SPACING*2; >- layout.horizontalSpacing = IDialogConstants.HORIZONTAL_SPACING*2; >+ layout.verticalSpacing = IDialogConstants.VERTICAL_SPACING * 2; >+ layout.horizontalSpacing = IDialogConstants.HORIZONTAL_SPACING * 2; > layout.numColumns = 2; > > composite.setLayout(layout); > composite.setLayoutData(new GridData()); > setControl(composite); > >- fromLeftLabel = new Label(composite, SWT.HORIZONTAL|SWT.SHADOW_OUT); >+ fromLeftLabel = new Label(composite, SWT.HORIZONTAL >+ | SWT.SHADOW_OUT); > fromLeftLabel.setText(CompareMessages.GenerateDiffFileWizard_Left); >- fromLeftLabel.setLayoutData(new GridData( >- SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ fromLeftLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, >+ false, false, 1, 1)); > > fromLeftOption = new Button(composite, SWT.RADIO); > fromLeftOption.setText(leftPath); >- fromLeftOption.setLayoutData(new GridData( >- SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ fromLeftOption.setLayoutData(new GridData(SWT.BEGINNING, >+ SWT.CENTER, false, false, 1, 1)); > >- fromRightLabel = new Label(composite, SWT.HORIZONTAL|SWT.SHADOW_OUT); >- fromRightLabel.setText(CompareMessages.GenerateDiffFileWizard_Right); >- fromRightLabel.setLayoutData(new GridData( >- SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ fromRightLabel = new Label(composite, SWT.HORIZONTAL >+ | SWT.SHADOW_OUT); >+ fromRightLabel >+ .setText(CompareMessages.GenerateDiffFileWizard_Right); >+ fromRightLabel.setLayoutData(new GridData(SWT.BEGINNING, >+ SWT.CENTER, false, false, 1, 1)); > > fromRightOption = new Button(composite, SWT.RADIO); > fromRightOption.setText(rightPath); >- fromRightOption.setLayoutData(new GridData( >- SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ fromRightOption.setLayoutData(new GridData(SWT.BEGINNING, >+ SWT.CENTER, false, false, 1, 1)); > > fromRadioGroup.add(LEFT_OPTION, fromLeftOption); > fromRadioGroup.add(RIGHT_OPTION, fromRightOption); >@@ -260,19 +270,24 @@ > protected IPath[] foldersToCreate; > protected int selectedLocation; > >+ private ContainerCheckedTreeViewer viewer; >+ private LocalChangesContentProvider provider; > /** > * The default values store used to initialize the selections. > */ > private final DefaultValuesStore store; >+ private Button chgSelectAll; >+ private Button chgDeselectAll; > > class LocationPageContentProvider extends BaseWorkbenchContentProvider { >- //Never show closed projects >- boolean showClosedProjects=false; >+ // Never show closed projects >+ boolean showClosedProjects = false; > > public Object[] getChildren(Object element) { > if (element instanceof IWorkspace) { > // check if closed projects should be shown >- IProject[] allProjects = ((IWorkspace) element).getRoot().getProjects(); >+ IProject[] allProjects = ((IWorkspace) element).getRoot() >+ .getProjects(); > if (showClosedProjects) > return allProjects; > >@@ -305,15 +320,17 @@ > Control control = super.createContents(parent); > setTitle(CompareMessages.WorkspacePatchDialogTitle); > setMessage(CompareMessages.WorkspacePatchDialogDescription); >- //create title image >- dlgTitleImage = CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF).createImage(); >+ // create title image >+ dlgTitleImage = CompareUIPlugin.getImageDescriptor( >+ ICompareUIConstants.IMG_WIZBAN_DIFF).createImage(); > setTitleImage(dlgTitleImage); > > return control; > } > > protected Control createDialogArea(Composite parent) { >- Composite parentComposite = (Composite) super.createDialogArea(parent); >+ Composite parentComposite = (Composite) super >+ .createDialogArea(parent); > > // create a composite with standard margins and spacing > Composite composite = new Composite(parentComposite, SWT.NONE); >@@ -329,24 +346,28 @@ > getShell().setText(CompareMessages.GenerateDiffFileWizard_9); > > wsTreeViewer = new TreeViewer(composite, SWT.BORDER); >- final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.widthHint= 550; >- gd.heightHint= 250; >+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.widthHint = 550; >+ gd.heightHint = 250; > wsTreeViewer.getTree().setLayoutData(gd); > >- wsTreeViewer.setContentProvider(new LocationPageContentProvider()); >- wsTreeViewer.setComparator(new ResourceComparator(ResourceComparator.NAME)); >+ wsTreeViewer >+ .setContentProvider(new LocationPageContentProvider()); >+ wsTreeViewer.setComparator(new ResourceComparator( >+ ResourceComparator.NAME)); > wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); > wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); > >- //Open to whatever is selected in the workspace field >+ // Open to whatever is selected in the workspace field > IPath existingWorkspacePath = new Path(wsPathText.getText()); >- if (existingWorkspacePath != null){ >- //Ensure that this workspace path is valid >- IResource selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(existingWorkspacePath); >+ if (existingWorkspacePath != null) { >+ // Ensure that this workspace path is valid >+ IResource selectedResource = ResourcesPlugin.getWorkspace() >+ .getRoot().findMember(existingWorkspacePath); > if (selectedResource != null) { > wsTreeViewer.expandToLevel(selectedResource, 0); >- wsTreeViewer.setSelection(new StructuredSelection(selectedResource)); >+ wsTreeViewer.setSelection(new StructuredSelection( >+ selectedResource)); > } > } > >@@ -354,14 +375,16 @@ > layout = new GridLayout(2, false); > layout.marginWidth = 0; > group.setLayout(layout); >- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, >+ false)); > > final Label label = new Label(group, SWT.NONE); > label.setLayoutData(new GridData()); > label.setText(CompareMessages.Fi_le_name__9); > >- wsFilenameText = new Text(group,SWT.BORDER); >- wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >+ wsFilenameText = new Text(group, SWT.BORDER); >+ wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, >+ true, false)); > > setupListeners(); > >@@ -394,7 +417,8 @@ > } > // make sure that the filename is valid > if (!(ResourcesPlugin.getWorkspace().validateName(fileName, >- IResource.FILE)).isOK() && modified) { >+ IResource.FILE)).isOK() >+ && modified) { > setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); > getButton(IDialogConstants.OK_ID).setEnabled(false); > return; >@@ -431,7 +455,8 @@ > } > > private IContainer getSelectedContainer() { >- Object obj = ((IStructuredSelection)wsTreeViewer.getSelection()).getFirstElement(); >+ Object obj = ((IStructuredSelection) wsTreeViewer >+ .getSelection()).getFirstElement(); > if (obj instanceof IContainer) { > wsSelectedContainer = (IContainer) obj; > } else if (obj instanceof IFile) { >@@ -451,15 +476,17 @@ > return super.close(); > } > >- void setupListeners(){ >- wsTreeViewer.addSelectionChangedListener( >- new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- IStructuredSelection s = (IStructuredSelection)event.getSelection(); >- Object obj=s.getFirstElement(); >+ void setupListeners() { >+ wsTreeViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged( >+ SelectionChangedEvent event) { >+ IStructuredSelection s = (IStructuredSelection) event >+ .getSelection(); >+ Object obj = s.getFirstElement(); > if (obj instanceof IContainer) > wsSelectedContainer = (IContainer) obj; >- else if (obj instanceof IFile){ >+ else if (obj instanceof IFile) { > IFile tempFile = (IFile) obj; > wsSelectedContainer = tempFile.getParent(); > wsFilenameText.setText(tempFile.getName()); >@@ -468,20 +495,20 @@ > } > }); > >- wsTreeViewer.addDoubleClickListener( >- new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- ISelection s= event.getSelection(); >- if (s instanceof IStructuredSelection) { >- Object item = ((IStructuredSelection)s).getFirstElement(); >- if (wsTreeViewer.getExpandedState(item)) >- wsTreeViewer.collapseToLevel(item, 1); >- else >- wsTreeViewer.expandToLevel(item, 1); >- } >- validateDialog(); >- } >- }); >+ wsTreeViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ ISelection s = event.getSelection(); >+ if (s instanceof IStructuredSelection) { >+ Object item = ((IStructuredSelection) s) >+ .getFirstElement(); >+ if (wsTreeViewer.getExpandedState(item)) >+ wsTreeViewer.collapseToLevel(item, 1); >+ else >+ wsTreeViewer.expandToLevel(item, 1); >+ } >+ validateDialog(); >+ } >+ }); > > wsFilenameText.addModifyListener(new ModifyListener() { > public void modifyText(ModifyEvent e) { >@@ -492,23 +519,27 @@ > } > } > >- LocationPage(String pageName, String title, ImageDescriptor image, DefaultValuesStore store) { >+ LocationPage(String pageName, String title, ImageDescriptor image, >+ DefaultValuesStore store) { > super(pageName, title, image); > setPageComplete(false); >- this.store= store; >+ this.store = store; > } > >- public void updateAssociatedResources() { >+ public void updateChangesControl() { > Differencer dif = new Differencer(); >- if(directionSelectionPage.isRightToLeft()) >- startNode = (DiffNode) dif.findDifferences(false, null, null, null, >- new FilteredBufferedResourceNode(rightResource), >- new FilteredBufferedResourceNode(leftResource)); >- else if(!directionSelectionPage.isRightToLeft()) >- startNode = (DiffNode) dif.findDifferences(false, null, null, null, >- new FilteredBufferedResourceNode(leftResource), >- new FilteredBufferedResourceNode(rightResource)); >- associatedResources = buildMap(startNode); >+ if (directionSelectionPage.isRightToLeft()) >+ startNode = (DiffNode) dif.findDifferences(false, null, null, >+ null, new FilteredBufferedResourceNode(rightResource), >+ new FilteredBufferedResourceNode(leftResource)); >+ else if (!directionSelectionPage.isRightToLeft()) >+ startNode = (DiffNode) dif.findDifferences(false, null, null, >+ null, new FilteredBufferedResourceNode(leftResource), >+ new FilteredBufferedResourceNode(rightResource)); >+ provider.setNode(startNode); >+ viewer.refresh(); >+ initCheckedItems(); >+ associatedResources = getSelectedAssociatedFiles(); > } > > /** >@@ -517,19 +548,23 @@ > protected boolean validatePage() { > switch (selectedLocation) { > case WORKSPACE: >- pageValid= validateWorkspaceLocation(); >+ pageValid = validateWorkspaceLocation(); > break; > case FILESYSTEM: >- pageValid= validateFilesystemLocation(); >+ pageValid = validateFilesystemLocation(); > break; > case CLIPBOARD: >- pageValid= true; >+ pageValid = true; > break; > } >- >+ >+ if ((associatedResources = getSelectedAssociatedFiles()).size() == 0) { >+ pageValid = false; >+ setErrorMessage(CompareMessages.GenerateDiffFileWizard_noChangesSelected); >+ } >+ > /** >- * Avoid draw flicker by clearing error message >- * if all is valid. >+ * Avoid draw flicker by clearing error message if all is valid. > */ > if (pageValid) { > setMessage(null); >@@ -540,16 +575,15 @@ > } > > /** >- * The following conditions must hold for the file system location >- * to be valid: >- * - the path must be valid and non-empty >- * - the path must be absolute >- * - the specified file must be of type file >- * - the parent must exist (new folders can be created via the browse button) >+ * The following conditions must hold for the file system location to be >+ * valid: - the path must be valid and non-empty - the path must be >+ * absolute - the specified file must be of type file - the parent must >+ * exist (new folders can be created via the browse button) > */ > private boolean validateFilesystemLocation() { >- final String pathString= fsPathText.getText().trim(); >- if (pathString.length() == 0 || !new Path("").isValidPath(pathString)) { //$NON-NLS-1$ >+ final String pathString = fsPathText.getText().trim(); >+ if (pathString.length() == 0 >+ || !new Path("").isValidPath(pathString)) { //$NON-NLS-1$ > if (fsBrowsed) > setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); > else >@@ -557,7 +591,7 @@ > return false; > } > >- final File file= new File(pathString); >+ final File file = new File(pathString); > if (!file.isAbsolute()) { > setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); > return false; >@@ -568,12 +602,12 @@ > return false; > } > >- if (pathString.endsWith("/") || pathString.endsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ >+ if (pathString.endsWith("/") || pathString.endsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ > setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); > return false; > } > >- final File parent= file.getParentFile(); >+ final File parent = file.getParentFile(); > if (!(parent.exists() && parent.isDirectory())) { > setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); > return false; >@@ -582,36 +616,40 @@ > } > > /** >- * The following conditions must hold for the file system location to be valid: >- * - a parent must be selected in the workspace tree view >- * - the resource name must be valid >+ * The following conditions must hold for the file system location to be >+ * valid: - a parent must be selected in the workspace tree view - the >+ * resource name must be valid > */ > private boolean validateWorkspaceLocation() { >- //make sure that the field actually has a filename in it - making >- //sure that the user has had a chance to browse the workspace first >- if (wsPathText.getText().equals("")){ //$NON-NLS-1$ >- if (selectedLocation ==WORKSPACE && wsBrowsed) >+ // make sure that the field actually has a filename in it - making >+ // sure that the user has had a chance to browse the workspace first >+ if (wsPathText.getText().equals("")) { //$NON-NLS-1$ >+ if (selectedLocation == WORKSPACE && wsBrowsed) > setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); > else > setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); > return false; > } > >- //Make sure that all the segments but the last one (i.e. project + all >- //folders) exist - file doesn't have to exist. It may have happened that >- //some folder refactoring has been done since this path was last saved. >+ // Make sure that all the segments but the last one (i.e. project + >+ // all >+ // folders) exist - file doesn't have to exist. It may have happened >+ // that >+ // some folder refactoring has been done since this path was last >+ // saved. > // > // The path will always be in format project/{folders}*/file - this > // is controlled by the workspace location dialog and by > // validatePath method when path has been entered manually. > >- > IPath pathToWorkspaceFile = new Path(wsPathText.getText()); >- IStatus status = ResourcesPlugin.getWorkspace().validatePath(wsPathText.getText(), IResource.FILE); >+ IStatus status = ResourcesPlugin.getWorkspace().validatePath( >+ wsPathText.getText(), IResource.FILE); > if (status.isOK()) { >- //Trim file name from path >+ // Trim file name from path > IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); >- IResource container =ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); >+ IResource container = ResourcesPlugin.getWorkspace().getRoot() >+ .findMember(containerPath); > if (container == null) { > if (selectedLocation == WORKSPACE) > setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); >@@ -636,45 +674,48 @@ > } > > /** >- * Answers a full path to a file system file or <code>null</code> if the user >- * selected to save the patch in the clipboard. >+ * Answers a full path to a file system file or <code>null</code> if the >+ * user selected to save the patch in the clipboard. > */ > public File getFile() { > if (pageValid && selectedLocation == FILESYSTEM) { > return new File(fsPathText.getText().trim()); > } > if (pageValid && selectedLocation == WORKSPACE) { >- final String filename= wsPathText.getText().trim(); >+ final String filename = wsPathText.getText().trim(); > IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- final IFile file= root.getFile(new Path(filename)); >+ final IFile file = root.getFile(new Path(filename)); > return file.getLocation().toFile(); > } > return null; > } > > /** >- * Answers the workspace string entered in the dialog or <code>null</code> if the user >- * selected to save the patch in the clipboard or file system. >+ * Answers the workspace string entered in the dialog or >+ * <code>null</code> if the user selected to save the patch in the >+ * clipboard or file system. > */ > public String getWorkspaceLocation() { > > if (pageValid && selectedLocation == WORKSPACE) { >- final String filename= wsPathText.getText().trim(); >+ final String filename = wsPathText.getText().trim(); > return filename; > } > return null; > } > > /** >- * Get the selected workspace resource if the patch is to be saved in the >- * workspace, or null otherwise. >+ * Get the selected workspace resource if the patch is to be saved in >+ * the workspace, or null otherwise. > */ > public IResource getResource() { > if (pageValid && selectedLocation == WORKSPACE) { >- IPath pathToWorkspaceFile = new Path(wsPathText.getText().trim()); >- //Trim file name from path >+ IPath pathToWorkspaceFile = new Path(wsPathText.getText() >+ .trim()); >+ // Trim file name from path > IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); >- return ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); >+ return ResourcesPlugin.getWorkspace().getRoot().findMember( >+ containerPath); > } > return null; > } >@@ -685,7 +726,7 @@ > */ > public void createControl(Composite parent) { > >- final Composite composite= new Composite(parent, SWT.NULL); >+ final Composite composite = new Composite(parent, SWT.NULL); > GridLayout lay = new GridLayout(); > lay.verticalSpacing = 15; > composite.setLayout(lay); >@@ -693,13 +734,30 @@ > initializeDialogUnits(composite); > > // set F1 help >- // TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_SELECTION_PAGE); >+ // TODO: >+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, >+ // IHelpContextIds.PATCH_SELECTION_PAGE); > >- //Create a location group >+ // Create a location group > setupLocationControls(composite); >- >+ > initializeDefaultValues(); >- >+ >+ Label changesLabel = new Label(composite, SWT.HORIZONTAL); >+ changesLabel.setText("Changes"); >+ >+ viewer = new ContainerCheckedTreeViewer(composite, SWT.CHECK >+ | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HORIZONTAL); >+ >+ viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ provider = new LocalChangesContentProvider(startNode); >+ viewer.setContentProvider(provider); >+ viewer.setLabelProvider(new LocalChangesLabelProvider()); >+ viewer.setInput(leftResource.getWorkspace().getRoot()); >+ initCheckedItems(); >+ >+ createSelectionButtons(composite); >+ > Dialog.applyDialogFont(parent); > > validatePage(); >@@ -708,7 +766,39 @@ > setupListeners(); > } > >- >+ private void createSelectionButtons(Composite composite) { >+ final Composite buttonGroup = new Composite(composite, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ layout.marginWidth = 0; >+ layout.marginHeight = 0; >+ layout.horizontalSpacing = 0; >+ layout.verticalSpacing = 0; >+ buttonGroup.setLayout(layout); >+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END >+ | GridData.VERTICAL_ALIGN_CENTER); >+ buttonGroup.setLayoutData(data); >+ >+ chgSelectAll = createSelectionButton( >+ CompareMessages.GenerateDiffFileWizard_SelectAll, >+ buttonGroup); >+ chgDeselectAll = createSelectionButton( >+ CompareMessages.GenerateDiffFileWizard_DeselectAll, >+ buttonGroup); >+ } >+ >+ private Button createSelectionButton(String buttonName, >+ Composite buttonGroup) { >+ Button button = new Button(buttonGroup, SWT.PUSH); >+ button.setText(buttonName); >+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); >+ Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); >+ data.widthHint = Math.max(widthHint, minSize.x); >+ button.setLayoutData(data); >+ return button; >+ } >+ > /** > * Setup the controls for the location. > */ >@@ -756,12 +846,13 @@ > data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); > widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); > minSize = fsBrowseButton >- .computeSize(SWT.DEFAULT, SWT.DEFAULT, true); >+ .computeSize(SWT.DEFAULT, SWT.DEFAULT, true); > data.widthHint = Math.max(widthHint, minSize.x); > wsBrowseButton.setLayoutData(data); > >- // change the cpRadio layout to be of the same height as other rows' layout >- ((GridData)cpRadio.getLayoutData()).heightHint = minSize.y; >+ // change the cpRadio layout to be of the same height as other rows' >+ // layout >+ ((GridData) cpRadio.getLayoutData()).heightHint = minSize.y; > } > > /** >@@ -770,7 +861,7 @@ > */ > private void initializeDefaultValues() { > >- selectedLocation= store.getLocationSelection(); >+ selectedLocation = store.getLocationSelection(); > > updateRadioButtons(); > >@@ -778,18 +869,19 @@ > * Text fields. > */ > // We need to ensure that we have a valid workspace path - user >- //could have altered workspace since last time this was saved >+ // could have altered workspace since last time this was saved > wsPathText.setText(store.getWorkspacePath()); >- if(!validateWorkspaceLocation()) { >+ if (!validateWorkspaceLocation()) { > wsPathText.setText(""); //$NON-NLS-1$ > >- //Don't open wizard with an error - instead change selection >- //to clipboard >- if (selectedLocation == WORKSPACE){ >- //clear the error message caused by the workspace not having >- //any workspace path entered >+ // Don't open wizard with an error - instead change selection >+ // to clipboard >+ if (selectedLocation == WORKSPACE) { >+ // clear the error message caused by the workspace not >+ // having >+ // any workspace path entered > setErrorMessage(null); >- selectedLocation=CLIPBOARD; >+ selectedLocation = CLIPBOARD; > updateRadioButtons(); > } > } >@@ -822,14 +914,14 @@ > > cpRadio.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event event) { >- selectedLocation= CLIPBOARD; >+ selectedLocation = CLIPBOARD; > validatePage(); > updateEnablements(); > } > }); > fsRadio.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event event) { >- selectedLocation= FILESYSTEM; >+ selectedLocation = FILESYSTEM; > validatePage(); > updateEnablements(); > } >@@ -837,7 +929,7 @@ > > wsRadio.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event event) { >- selectedLocation= WORKSPACE; >+ selectedLocation = WORKSPACE; > validatePage(); > updateEnablements(); > } >@@ -853,9 +945,10 @@ > > fsBrowseButton.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event event) { >- final FileDialog dialog = new FileDialog(getShell(), SWT.PRIMARY_MODAL | SWT.SAVE); >+ final FileDialog dialog = new FileDialog(getShell(), >+ SWT.PRIMARY_MODAL | SWT.SAVE); > if (pageValid) { >- final File file= new File(fsPathText.getText()); >+ final File file = new File(fsPathText.getText()); > dialog.setFilterPath(file.getParent()); > } > dialog.setText(CompareMessages.Save_Patch_As_5); >@@ -869,19 +962,70 @@ > } > }); > >- >- > wsBrowseButton.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event event) { >- final WorkspaceDialog dialog = new WorkspaceDialog(getShell()); >+ final WorkspaceDialog dialog = new WorkspaceDialog( >+ getShell()); > wsBrowsed = true; > dialog.open(); > validatePage(); > } > }); > >+ chgSelectAll.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ initCheckedItems(); >+ // Only bother changing isPageComplete state if the current >+ // state >+ // is not enabled >+ if (!isPageComplete()) >+ setPageComplete(validatePage()); >+ } >+ }); >+ >+ chgDeselectAll.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ viewer.setCheckedElements(new Object[0]); >+ // Only bother changing isPageComplete state if the current >+ // state >+ // is enabled >+ if (isPageComplete()) >+ setPageComplete(validatePage()); >+ } >+ }); >+ >+ viewer.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ setPageComplete(validatePage()); >+ } >+ }); >+ > } >- >+ >+ protected void initCheckedItems() { >+ TreeItem[] items = ((CheckboxTreeViewer) viewer).getTree() >+ .getItems(); >+ for (int i = 0; i < items.length; i++) { >+ ((CheckboxTreeViewer) viewer).setChecked(items[i].getData(), >+ true); >+ } >+ } >+ >+ protected ArrayList getSelectedAssociatedFiles() { >+ Object[] elements = viewer.getCheckedElements(); >+ ArrayList result = new ArrayList(); >+ for (int i = 0; i < elements.length; i++) { >+ if (!(elements[i] instanceof IProject)) { >+ DiffNode node = (DiffNode) elements[i]; >+ IResource lr = Utilities.getResource(node.getLeft()); >+ IResource rr = Utilities.getResource(node.getRight()); >+ if (lr instanceof IFile || rr instanceof IFile) >+ result.add(new Object[] { lr, rr }); >+ } >+ } >+ return result; >+ } >+ > /** > * Enable and disable controls based on the selected radio button. > */ >@@ -889,11 +1033,11 @@ > fsBrowseButton.setEnabled(selectedLocation == FILESYSTEM); > fsPathText.setEnabled(selectedLocation == FILESYSTEM); > if (selectedLocation == FILESYSTEM) >- fsBrowsed=false; >+ fsBrowsed = false; > wsPathText.setEnabled(selectedLocation == WORKSPACE); > wsBrowseButton.setEnabled(selectedLocation == WORKSPACE); > if (selectedLocation == WORKSPACE) >- wsBrowsed=false; >+ wsBrowsed = false; > } > > public int getSelectedLocation() { >@@ -915,7 +1059,7 @@ > public final static int FORMAT_STANDARD = 3; > > /** >- The possible root of the patch >+ * The possible root of the patch > */ > public final static int ROOT_WORKSPACE = 1; > public final static int ROOT_PROJECT = 2; >@@ -925,9 +1069,11 @@ > protected boolean initialized = false; > > protected Button unifiedDiffOption; >- protected Button unified_workspaceRelativeOption; //multi-patch format >- protected Button unified_projectRelativeOption; //full project path >- protected Button unified_selectionRelativeOption; //use path of whatever is selected >+ protected Button unified_workspaceRelativeOption; // multi-patch format >+ protected Button unified_projectRelativeOption; // full project path >+ protected Button unified_selectionRelativeOption; // use path of >+ // whatever is >+ // selected > protected Button contextDiffOption; > protected Button regularDiffOption; > >@@ -942,7 +1088,8 @@ > /** > * Constructor for PatchFileCreationOptionsPage. > */ >- protected OptionsPage(String pageName, String title, ImageDescriptor titleImage, DefaultValuesStore store) { >+ protected OptionsPage(String pageName, String title, >+ ImageDescriptor titleImage, DefaultValuesStore store) { > super(pageName, title, titleImage); > this.store = store; > } >@@ -951,25 +1098,29 @@ > * @see IDialogPage#createControl(Composite) > */ > public void createControl(Composite parent) { >- Composite composite= new Composite(parent, SWT.NULL); >- GridLayout layout= new GridLayout(); >+ Composite composite = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(); > composite.setLayout(layout); > composite.setLayoutData(new GridData()); > setControl(composite); > > // set F1 help >- // TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_OPTIONS_PAGE); >+ // TODO: >+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, >+ // IHelpContextIds.PATCH_OPTIONS_PAGE); > > diffTypeGroup = new Group(composite, SWT.NONE); > layout = new GridLayout(); > layout.marginHeight = 0; > diffTypeGroup.setLayout(layout); >- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); >+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL >+ | GridData.GRAB_HORIZONTAL); > diffTypeGroup.setLayoutData(data); > diffTypeGroup.setText(CompareMessages.Diff_output_format_12); > > unifiedDiffOption = new Button(diffTypeGroup, SWT.RADIO); >- unifiedDiffOption.setText(CompareMessages.Unified__format_required_by_Compare_With_Patch_feature__13); >+ unifiedDiffOption >+ .setText(CompareMessages.Unified__format_required_by_Compare_With_Patch_feature__13); > > contextDiffOption = new Button(diffTypeGroup, SWT.RADIO); > contextDiffOption.setText(CompareMessages.Context_14); >@@ -985,34 +1136,42 @@ > layout = new GridLayout(); > layout.numColumns = 2; > unifiedGroup.setLayout(layout); >- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); >+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL >+ | GridData.GRAB_HORIZONTAL); > unifiedGroup.setLayoutData(data); > unifiedGroup.setText(CompareMessages.GenerateDiffFileWizard_10); > >- unified_workspaceRelativeOption = new Button(unifiedGroup, SWT.RADIO); >- unified_workspaceRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_6); >+ unified_workspaceRelativeOption = new Button(unifiedGroup, >+ SWT.RADIO); >+ unified_workspaceRelativeOption >+ .setText(CompareMessages.GenerateDiffFileWizard_6); > unified_workspaceRelativeOption.setLayoutData(new GridData( > SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); > > unified_projectRelativeOption = new Button(unifiedGroup, SWT.RADIO); >- unified_projectRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_7); >+ unified_projectRelativeOption >+ .setText(CompareMessages.GenerateDiffFileWizard_7); > unified_projectRelativeOption.setLayoutData(new GridData( > SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); > >- unified_selectionRelativeOption = new Button(unifiedGroup, SWT.RADIO); >- unified_selectionRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_8); >+ unified_selectionRelativeOption = new Button(unifiedGroup, >+ SWT.RADIO); >+ unified_selectionRelativeOption >+ .setText(CompareMessages.GenerateDiffFileWizard_8); > unified_selectionRelativeOption.setLayoutData(new GridData( > SWT.BEGINNING, SWT.CENTER, false, true, 2, 1)); > >- unifiedRadioGroup.add(ROOT_WORKSPACE, unified_workspaceRelativeOption); >+ unifiedRadioGroup.add(ROOT_WORKSPACE, >+ unified_workspaceRelativeOption); > unifiedRadioGroup.add(ROOT_PROJECT, unified_projectRelativeOption); >- unifiedRadioGroup.add(ROOT_SELECTION, unified_selectionRelativeOption); >+ unifiedRadioGroup.add(ROOT_SELECTION, >+ unified_selectionRelativeOption); > > Dialog.applyDialogFont(parent); > > initializeDefaultValues(); > >- //add listeners >+ // add listeners > unifiedDiffOption.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > setEnableUnifiedGroup(true); >@@ -1038,25 +1197,27 @@ > }); > > unified_workspaceRelativeOption >- .addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- unifiedRadioGroup.setSelection(ROOT_WORKSPACE, false); >- } >- }); >+ .addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ unifiedRadioGroup.setSelection(ROOT_WORKSPACE, >+ false); >+ } >+ }); > > unified_projectRelativeOption >- .addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- unifiedRadioGroup.setSelection(ROOT_PROJECT, false); >- } >- }); >+ .addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ unifiedRadioGroup.setSelection(ROOT_PROJECT, false); >+ } >+ }); > > unified_selectionRelativeOption >- .addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- unifiedRadioGroup.setSelection(ROOT_SELECTION, false); >- } >- }); >+ .addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ unifiedRadioGroup.setSelection(ROOT_SELECTION, >+ false); >+ } >+ }); > > updateEnablements(); > >@@ -1099,7 +1260,7 @@ > } > > protected void updateEnablements() { >- if(diffTypeRadioGroup.selected != FORMAT_UNIFIED) >+ if (diffTypeRadioGroup.selected != FORMAT_UNIFIED) > setEnableUnifiedGroup(false); > } > >@@ -1132,13 +1293,13 @@ > private final IDialogSettings dialogSettings; > > public DefaultValuesStore() { >- dialogSettings= CompareUIPlugin.getDefault().getDialogSettings(); >+ dialogSettings = CompareUIPlugin.getDefault().getDialogSettings(); > } > > public int getLocationSelection() { >- int value= LocationPage.CLIPBOARD; >+ int value = LocationPage.CLIPBOARD; > try { >- value= dialogSettings.getInt(PREF_LAST_SELECTION); >+ value = dialogSettings.getInt(PREF_LAST_SELECTION); > } catch (NumberFormatException e) { > } > >@@ -1153,16 +1314,15 @@ > } > > public String getFilesystemPath() { >- final String path= dialogSettings.get(PREF_LAST_FS_PATH); >- return path != null ? path : ""; //$NON-NLS-1$ >+ final String path = dialogSettings.get(PREF_LAST_FS_PATH); >+ return path != null ? path : ""; //$NON-NLS-1$ > } > > public String getWorkspacePath() { >- final String path= dialogSettings.get(PREF_LAST_WS_PATH); >+ final String path = dialogSettings.get(PREF_LAST_WS_PATH); > return path != null ? path : ""; //$NON-NLS-1$ > } > >- > public int getFormatSelection() { > int value = OptionsPage.FORMAT_UNIFIED; > try { >@@ -1237,9 +1397,9 @@ > > private IResource rightResource; > private IResource leftResource; >- >+ > private ArrayList associatedResources; >- >+ > public GenerateDiffFileWizard() { > super(); > setWindowTitle(CompareMessages.GenerateLocalDiff_title); >@@ -1249,106 +1409,69 @@ > } > > private DiffNode startNode; >- >+ > public GenerateDiffFileWizard(IResource[] input) { > this(); >- >+ > this.leftDoc = new Document(); >- this.rightDoc = new Document(); >- >+ this.rightDoc = new Document(); >+ > leftResource = input[0]; > rightResource = input[1]; >- >+ > leftPath = leftResource.getFullPath().toString(); > rightPath = rightResource.getFullPath().toString(); > > Differencer dif = new Differencer(); >- startNode = (DiffNode) dif.findDifferences(false, null, null, null, >- new FilteredBufferedResourceNode(leftResource), >- new FilteredBufferedResourceNode(rightResource)); >- associatedResources = buildMap(startNode); >- >+ startNode = (DiffNode) dif.findDifferences(false, null, null, null, >+ new FilteredBufferedResourceNode(leftResource), >+ new FilteredBufferedResourceNode(rightResource)); >+ > } >- >+ > public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) { > this(); >- this.leftDoc = merger.getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); >- this.rightDoc = merger.getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); >+ this.leftDoc = merger >+ .getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); >+ this.rightDoc = merger >+ .getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); > this.leftPath = merger.getCompareConfiguration().getLeftLabel(leftDoc); >- this.rightPath = merger.getCompareConfiguration().getRightLabel(rightDoc); >+ this.rightPath = merger.getCompareConfiguration().getRightLabel( >+ rightDoc); > this.rightToLeft = rightToLeft; >- IWorkbenchPart workbenchPart = merger.getCompareConfiguration().getContainer().getWorkbenchPart(); >- >- if(workbenchPart instanceof CompareEditor) { >- >- CompareEditor editor = (CompareEditor)workbenchPart; >- >- CompareEditorInput input = (CompareEditorInput)editor.getEditorInput(); >+ IWorkbenchPart workbenchPart = merger.getCompareConfiguration() >+ .getContainer().getWorkbenchPart(); >+ >+ if (workbenchPart instanceof CompareEditor) { >+ >+ CompareEditor editor = (CompareEditor) workbenchPart; >+ >+ CompareEditorInput input = (CompareEditorInput) editor >+ .getEditorInput(); > input.getCompareResult(); >- if(input.getCompareResult() instanceof ICompareInput) { >- ICompareInput node = (ICompareInput)input.getCompareResult(); >- >- leftResource = ((ResourceNode)node.getLeft()).getResource(); >- rightResource = ((ResourceNode)node.getRight()).getResource(); >- Differencer dif = new Differencer(); >- startNode = (DiffNode) dif.findDifferences(false, null, null, null, >- new FilteredBufferedResourceNode(leftResource), >- new FilteredBufferedResourceNode(rightResource)); >- >- if(leftResource instanceof IFile && rightResource instanceof IFile) >- associatedResources.add(new Object[] {leftResource, rightResource}); >- >- } >- >- } >- } >- >- private ArrayList buildMap(DiffNode diff) { >- ArrayList res = new ArrayList(); >- IResource lresource = null; >- IResource rresource = null; >- IDiffElement[] children = diff.getChildren(); >- if (children != null) { >- for (int i = 0; i < children.length; i++) { >- if (children[i] instanceof DiffNode) { >- DiffNode o = (DiffNode) children[i]; >- if (o != null && o.getKind() != Differencer.NO_CHANGE) { >- DiffNode node = o; >+ if (input.getCompareResult() instanceof ICompareInput) { >+ ICompareInput node = (ICompareInput) input.getCompareResult(); > >- ITypedElement left = node.getLeft(); >- if (left instanceof BufferedResourceNode) { >- BufferedResourceNode bn = (BufferedResourceNode) left; >- IResource resource = bn.getResource(); >- if (resource instanceof IFile) { >- lresource = resource; >- } >+ ITypedElement leftElem = node.getLeft(); >+ ITypedElement rightElem = node.getRight(); > >- } >+ leftResource = ((ResourceNode) node.getLeft()).getResource(); >+ rightResource = ((ResourceNode) node.getRight()).getResource(); >+ Differencer dif = new Differencer(); >+ startNode = (DiffNode) dif.findDifferences(false, null, null, >+ null, new FilteredBufferedResourceNode(leftResource), >+ new FilteredBufferedResourceNode(rightResource)); > >- ITypedElement right = node.getRight(); >- if (right instanceof BufferedResourceNode) { >- BufferedResourceNode bn = (BufferedResourceNode) right; >- IResource resource = bn.getResource(); >- if (resource instanceof IFile) { >- rresource = resource; >- } >- } >- >- if(rresource != null || lresource != null) >- res.add(new Object[] {lresource, rresource}); >- lresource = null; >- rresource = null; >- } >+ if (leftResource instanceof IFile >+ && rightResource instanceof IFile) >+ associatedResources.add(new Object[] { leftResource, >+ rightResource }); > >- res.addAll(buildMap((DiffNode) children[i])); >- } > } >- return res; >+ > } >- return res; > } > >- > public void addPages() { > String pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; > String pageDescription = CompareMessages.GenerateLocalDiff_Specify_the_file_which_contributes_the_changes; >@@ -1356,13 +1479,15 @@ > pageTitle, > pageTitle, > CompareUIPlugin >- .getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF)); >+ .getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF)); > directionSelectionPage.setDescription(pageDescription); > addPage(directionSelectionPage); > > pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; > pageDescription = CompareMessages.GenerateLocalDiff_pageDescription; >- locationPage = new LocationPage(pageTitle, pageTitle, CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF), defaultValuesStore); >+ locationPage = new LocationPage(pageTitle, pageTitle, CompareUIPlugin >+ .getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF), >+ defaultValuesStore); > locationPage.setDescription(pageDescription); > addPage(locationPage); > >@@ -1389,10 +1514,10 @@ > } > > protected void updateEnablements() { >- diffTypeRadioGroup.setEnablement(false, new int[] { FORMAT_CONTEXT, >- FORMAT_STANDARD }, FORMAT_UNIFIED); >+ diffTypeRadioGroup.setEnablement(false, new int[] { >+ FORMAT_CONTEXT, FORMAT_STANDARD }, FORMAT_UNIFIED); > unifiedRadioGroup.setEnablement(false, new int[] { >- ROOT_PROJECT, ROOT_SELECTION, ROOT_WORKSPACE } ); >+ ROOT_PROJECT, ROOT_SELECTION, ROOT_WORKSPACE }); > } > > protected void setEnableUnifiedGroup(boolean enabled) { >@@ -1406,81 +1531,95 @@ > > private void createCustomRelativeControl() { > Group unifiedGroup = optionsPage.getUnifiedGroup(); >- final RadioButtonGroup unifiedRadioGroup = optionsPage.getUnifiedRadioGroup(); >+ final RadioButtonGroup unifiedRadioGroup = optionsPage >+ .getUnifiedRadioGroup(); > unified_customRelativeOption = new Button(unifiedGroup, SWT.RADIO); >- unified_customRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_13); >+ unified_customRelativeOption >+ .setText(CompareMessages.GenerateDiffFileWizard_13); > unified_customRelativeOption.setSelection(true); >- unified_customRelativeOption.setLayoutData(new GridData( >- SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ unified_customRelativeOption.setLayoutData(new GridData(SWT.BEGINNING, >+ SWT.CENTER, false, false, 1, 1)); > > unified_customRelativeText = new Text(unifiedGroup, SWT.BORDER); >- unified_customRelativeText.setLayoutData(new GridData( >- SWT.FILL, SWT.CENTER, true, false, 1, 1)); >+ unified_customRelativeText.setLayoutData(new GridData(SWT.FILL, >+ SWT.CENTER, true, false, 1, 1)); > >- optionsPage.getUnifiedRadioGroup().add(OptionsPage.ROOT_CUSTOM, unified_customRelativeOption); >- unified_customRelativeOption.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- unifiedRadioGroup.setSelection(OptionsPage.ROOT_CUSTOM, false); >- } >- }); >- optionsPage.updateDiffTypeEnablements(new int[] {OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD}, OptionsPage.FORMAT_UNIFIED); >- optionsPage.updateUnifiedEnablements(new int[] {OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, OptionsPage.ROOT_SELECTION}, OptionsPage.ROOT_CUSTOM); >+ optionsPage.getUnifiedRadioGroup().add(OptionsPage.ROOT_CUSTOM, >+ unified_customRelativeOption); >+ unified_customRelativeOption >+ .addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ unifiedRadioGroup.setSelection(OptionsPage.ROOT_CUSTOM, >+ false); >+ } >+ }); >+ optionsPage.updateDiffTypeEnablements(new int[] { >+ OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD }, >+ OptionsPage.FORMAT_UNIFIED); >+ optionsPage.updateUnifiedEnablements(new int[] { >+ OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, >+ OptionsPage.ROOT_SELECTION }, OptionsPage.ROOT_CUSTOM); > } > > /** > * Declares the wizard banner iamge descriptor > */ > protected void initializeDefaultPageImageDescriptor() { >- final String iconPath= "icons/full/"; //$NON-NLS-1$ >+ final String iconPath = "icons/full/"; //$NON-NLS-1$ > try { >- final URL installURL = CompareUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ >- final URL url = new URL(installURL, iconPath + "wizards/newconnect_wiz.gif"); //$NON-NLS-1$ >+ final URL installURL = CompareUIPlugin.getDefault().getBundle() >+ .getEntry("/"); //$NON-NLS-1$ >+ final URL url = new URL(installURL, iconPath >+ + "wizards/newconnect_wiz.gif"); //$NON-NLS-1$ > ImageDescriptor desc = ImageDescriptor.createFromURL(url); > setDefaultPageImageDescriptor(desc); > } catch (MalformedURLException e) { >- // Should not happen. Ignore. >+ // Should not happen. Ignore. > } > } > >- /* (Non-javadoc) >- * Method declared on IWizard. >+ /* >+ * (Non-javadoc) Method declared on IWizard. > */ > public boolean needsProgressMonitor() { > return true; > } >- >+ > /** > * Completes processing of the wizard. If this method returns <code> >- * true</code>, the wizard will close; otherwise, it will stay active. >+ * true</code>, >+ * the wizard will close; otherwise, it will stay active. > */ > public boolean performFinish() { > final int location = locationPage.getSelectedLocation(); > >- final File file= location != LocationPage.CLIPBOARD? locationPage.getFile() : null; >+ final File file = location != LocationPage.CLIPBOARD ? locationPage >+ .getFile() : null; > > if (!(file == null || validateFile(file))) { > return false; > } > >- //Validation of patch root >-// if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) { >-// String path = optionsPage.getPath(); >-// IFile file2; >-// try { >-// file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); >-// } catch(IllegalArgumentException e) { >-// final String title = CompareMessages.GenerateLocalDiff_3; >-// final String msg = CompareMessages.GenerateLocalDiff_4; >-// final MessageDialog dialog = new MessageDialog(getShell(), title, >-// null, msg, MessageDialog.ERROR, >-// new String[] { IDialogConstants.OK_LABEL }, 0); >-// dialog.open(); >-// return false; >-// } >-// if(!validateFile2(file2)) { >-// return false; >-// } >-// } >+ // Validation of patch root >+ // if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) { >+ // String path = optionsPage.getPath(); >+ // IFile file2; >+ // try { >+ // file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new >+ // Path(path)); >+ // } catch(IllegalArgumentException e) { >+ // final String title = CompareMessages.GenerateLocalDiff_3; >+ // final String msg = CompareMessages.GenerateLocalDiff_4; >+ // final MessageDialog dialog = new MessageDialog(getShell(), title, >+ // null, msg, MessageDialog.ERROR, >+ // new String[] { IDialogConstants.OK_LABEL }, 0); >+ // dialog.open(); >+ // return false; >+ // } >+ // if(!validateFile2(file2)) { >+ // return false; >+ // } >+ // } > > // Create the patch > generateDiffFile(file); >@@ -1491,19 +1630,25 @@ > switch (location) { > > case LocationPage.WORKSPACE: >- final String workspaceResource= locationPage.getWorkspaceLocation(); >- if (workspaceResource != null){ >- defaultValuesStore.storeLocationSelection(LocationPage.WORKSPACE); >+ final String workspaceResource = locationPage >+ .getWorkspaceLocation(); >+ if (workspaceResource != null) { >+ defaultValuesStore >+ .storeLocationSelection(LocationPage.WORKSPACE); > defaultValuesStore.storeWorkspacePath(workspaceResource); >- /* try { >- workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); >- } catch(CoreException e) { >- CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); >- return false; >- } */ >+ /* >+ * try { >+ * workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE >+ * , null); } catch(CoreException e) { >+ * CVSUIPlugin.openError(getShell(), >+ * CVSUIMessages.GenerateCVSDiff_error, null, e); return false; >+ * } >+ */ > } else { >- //Problem with workspace location, open with clipboard next time >- defaultValuesStore.storeLocationSelection(LocationPage.CLIPBOARD); >+ // Problem with workspace location, open with clipboard next >+ // time >+ defaultValuesStore >+ .storeLocationSelection(LocationPage.CLIPBOARD); > } > break; > >@@ -1520,7 +1665,6 @@ > return false; > } > >- > /** > * Save default selections of Options Page > */ >@@ -1536,20 +1680,21 @@ > if (targetFileEdited) { > toPath = optionsPage.getPath(); > } else { >- if(directionSelectionPage.isRightToLeft()){ >+ if (directionSelectionPage.isRightToLeft()) { > toPath = this.rightPath; > } else { > toPath = this.leftPath; > } > } >- if(directionSelectionPage.isRightToLeft()){ >+ if (directionSelectionPage.isRightToLeft()) { > oldPath = this.leftPath; > } else { > oldPath = this.rightPath; > } >- >- //TODO extend formatter to use list of mergers. >- UnifiedDiffFormatter formatter = new UnifiedDiffFormatter(createFormatterInput()); >+ >+ // TODO extend formatter to use list of mergers. >+ UnifiedDiffFormatter formatter = new UnifiedDiffFormatter( >+ createFormatterInput()); > try { > if (file == null) { > formatter.generateDiff(); >@@ -1560,124 +1705,134 @@ > throw new RuntimeException(e); > } > } >- >+ > private Object[][] createFormatterInput() { > Object[] resArr = associatedResources.toArray(); > int size = resArr.length; > Object[][] result = new Object[size][3]; > DocumentMerger merg = null; > for (int j = 0; j < size; j++) { >- IFile sourceRes = (IFile) ((Object[])resArr[j])[0]; >- IFile targetRes = (IFile) ((Object[])resArr[j])[1]; >+ IFile sourceRes = (IFile) ((Object[]) resArr[j])[0]; >+ IFile targetRes = (IFile) ((Object[]) resArr[j])[1]; > merg = createDocumentMerger(sourceRes, targetRes); > result[j][0] = merg; >- result[j][1] = targetRes ; >- result[j][2] = sourceRes ; >+ result[j][1] = targetRes; >+ result[j][2] = sourceRes; > } > return result; > } >- >- 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 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) >+ if (file == null) > return null; > StringBuffer str = new StringBuffer(); > int c; >- try{ >+ try { > InputStream inputStream = file.getContents(); >- while ((c = inputStream.read())!=-1){ >- str.append((char)c); >+ while ((c = inputStream.read()) != -1) { >+ str.append((char) c); > } > inputStream.close(); > return new Document(str.toString()); >- }catch(Exception ex){ >+ } 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; >+ >+ 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 new CompareConfiguration(); >+ } >+ >+ 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; > } >- >- public ITokenComparator createTokenComparator(String line) { >- return new TokenComparator(line); >- } >- public CompareConfiguration getCompareConfiguration() { >- return new CompareConfiguration(); >- } >- 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; >- } >- >+ 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; >+ } >+ >+ } >+ > public boolean validateFile(File file) { > > if (file == null) >@@ -1693,16 +1848,21 @@ > * The file exists. > */ > if (!file.canWrite()) { >- final String title= CompareMessages.GenerateLocalDiff_1; >- final String msg= CompareMessages.GenerateLocalDiff_2; >- final MessageDialog dialog= new MessageDialog(getShell(), title, null, msg, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); >+ final String title = CompareMessages.GenerateLocalDiff_1; >+ final String msg = CompareMessages.GenerateLocalDiff_2; >+ final MessageDialog dialog = new MessageDialog(getShell(), title, >+ null, msg, MessageDialog.ERROR, >+ new String[] { IDialogConstants.OK_LABEL }, 0); > dialog.open(); > return false; > } > > final String title = CompareMessages.GenerateLocalDiff_overwriteTitle; > final String msg = CompareMessages.GenerateLocalDiff_overwriteMsg; >- final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); >+ final MessageDialog dialog = new MessageDialog(getShell(), title, null, >+ msg, MessageDialog.QUESTION, new String[] { >+ IDialogConstants.YES_LABEL, >+ IDialogConstants.CANCEL_LABEL }, 0); > dialog.open(); > if (dialog.getReturnCode() != 0) > return false; >@@ -1736,11 +1896,11 @@ > * The class maintain proper selection of radio button within the group: > * <ul> > * <li>Only one button can be selected at the time.</li> >- * <li>Disabled button can't be selected unless all buttons in the group >- * are disabled.</li> >+ * <li>Disabled button can't be selected unless all buttons in the group are >+ * disabled.</li> > * </ul> > */ >- /*private*/ class RadioButtonGroup { >+ /* private */class RadioButtonGroup { > > /** > * List of buttons in the group. Both radio groups contain 3 elements. >@@ -1848,7 +2008,7 @@ > // enable (or disable) given buttons > for (int i = 0; i < buttonsToChange.length; i++) { > ((Button) this.buttons.get(buttonsToChange[i] - 1)) >- .setEnabled(enabled); >+ .setEnabled(enabled); > } > // check whether the selected button is enabled > if (!((Button) this.buttons.get(selected)).isEnabled()) { >@@ -1862,11 +2022,14 @@ > } > > /** >- * Enable or disable given buttons with no default selection. The selection >- * will be set to an enabled button using the <code>selectEnabledOnly</code> method. >+ * Enable or disable given buttons with no default selection. The >+ * selection will be set to an enabled button using the >+ * <code>selectEnabledOnly</code> method. > * >- * @param enabled Indicates whether to enable or disable the buttons. >- * @param buttonsToChange Buttons to enable/disable. >+ * @param enabled >+ * Indicates whether to enable or disable the buttons. >+ * @param buttonsToChange >+ * Buttons to enable/disable. > */ > public void setEnablement(boolean enabled, int[] buttonsToChange) { > // -1 means that no default selection is given >Index: compare/org/eclipse/compare/internal/LocalChangesContentProvider.java >=================================================================== >--- compare/org/eclipse/compare/internal/LocalChangesContentProvider.java (revision 0) >+++ compare/org/eclipse/compare/internal/LocalChangesContentProvider.java (revision 6) >@@ -0,0 +1,83 @@ >+package org.eclipse.compare.internal; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.compare.ITypedElement; >+import org.eclipse.compare.structuremergeviewer.DiffNode; >+import org.eclipse.compare.structuremergeviewer.Differencer; >+import org.eclipse.compare.structuremergeviewer.IDiffElement; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class LocalChangesContentProvider implements ITreeContentProvider { >+ >+ private DiffNode node; >+ >+ public static String LEFT = "LEFT"; >+ public static String RIGHT = "RIGHT"; >+ >+ public LocalChangesContentProvider(DiffNode node) { >+ super(); >+ this.node = node; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ IResource r = getResource(node.getLeft()); >+ return new Object[] {r.getProject()}; >+ } >+ >+ public void dispose() { >+ // >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ if(parentElement instanceof IProject) { >+ return new Object[] {node}; >+ } >+ >+ IDiffElement[] elems = ((DiffNode)parentElement).getChildren(); >+ ArrayList result = new ArrayList(); >+ for (int i = 0; i < elems.length; i++) { >+ DiffNode diffNode = (DiffNode)elems[i]; >+ if(diffNode.getKind() != Differencer.NO_CHANGE) { >+ result.add(elems[i]); >+ } >+ } >+ return result.toArray(); >+ } >+ >+ public Object getParent(Object element) { >+ return ((DiffNode)element).getParent(); >+ } >+ >+ public boolean hasChildren(Object element) { >+ if(element instanceof IProject) { >+ return true; >+ } >+ return ((DiffNode)element).hasChildren(); >+ } >+ >+ >+ private IResource getResource(ITypedElement element) { >+ if (element instanceof BufferedResourceNode) { >+ BufferedResourceNode bn= (BufferedResourceNode) element; >+ return bn.getResource(); >+ } >+ return null; >+ } >+ >+ public void setNode(DiffNode node) { >+ this.node = node; >+ } >+ >+ public DiffNode getNode() { >+ return node; >+ } >+ >+} >Index: compare/org/eclipse/compare/internal/LocalChangesLabelProvider.java >=================================================================== >--- compare/org/eclipse/compare/internal/LocalChangesLabelProvider.java (revision 0) >+++ compare/org/eclipse/compare/internal/LocalChangesLabelProvider.java (revision 6) >@@ -0,0 +1,104 @@ >+package org.eclipse.compare.internal; >+ >+import org.eclipse.compare.CompareConfiguration; >+import org.eclipse.compare.ITypedElement; >+import org.eclipse.compare.structuremergeviewer.DiffNode; >+import org.eclipse.compare.structuremergeviewer.Differencer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+ >+public class LocalChangesLabelProvider implements ILabelProvider { >+ >+ public static String LEFT = "LEFT"; >+ public static String RIGHT = "RIGHT"; >+ private CompareConfiguration config; >+ >+ public LocalChangesLabelProvider() { >+ config = new CompareConfiguration(); >+ } >+ >+ public Image getImage(Object element) { >+ if(element instanceof IProject) >+ return PlatformUI.getWorkbench().getSharedImages().getImage( >+ org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); >+ >+ IResource resource = getResource((DiffNode)element); >+ >+ if(resource instanceof IFile) { >+ int kind = ((DiffNode)element).getKind(); >+ return config.getImage(PlatformUI.getWorkbench().getSharedImages().getImage( >+ ISharedImages.IMG_OBJ_FILE), Differencer.RIGHT +kind); >+ >+ } else if(resource instanceof IFolder) { >+ int kind = ((DiffNode)element).getKind(); >+ return config.getImage(PlatformUI.getWorkbench().getSharedImages().getImage( >+ ISharedImages.IMG_OBJ_FOLDER), Differencer.RIGHT +kind); >+ >+ } else if(resource instanceof IProject) { >+ return PlatformUI.getWorkbench().getSharedImages().getImage( >+ org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); >+ >+ } else { >+ return PlatformUI.getWorkbench().getSharedImages().getImage( >+ ISharedImages.IMG_OBJ_ELEMENT); >+ } >+ >+ } >+ >+ public String getText(Object element) { >+ if(element instanceof IProject) >+ return ((IProject)element).getName(); >+ >+ IResource resource = getResource((DiffNode)element); >+ >+ if(resource instanceof IFile) >+ return resource.getName(); >+ else if(resource instanceof IFolder) >+ return resource.getProjectRelativePath().toString(); >+ else if(resource instanceof IProject) >+ return resource.getName(); >+ else >+ return resource.getName(); >+ } >+ >+ public void addListener(ILabelProviderListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ // TODO Auto-generated method stub >+ return false; >+ } >+ >+ public void removeListener(ILabelProviderListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ private IResource getResource(DiffNode node) { >+ ITypedElement te = node.getLeft(); >+ if(te == null) >+ te = node.getRight(); >+ >+ if (te instanceof BufferedResourceNode) { >+ BufferedResourceNode bn = (BufferedResourceNode) te; >+ IResource resource = bn.getResource(); >+ return resource; >+ } >+ return null; >+ } >+ >+} >Index: compare/org/eclipse/compare/internal/Utilities.java >=================================================================== >--- compare/org/eclipse/compare/internal/Utilities.java (revision 5) >+++ compare/org/eclipse/compare/internal/Utilities.java (revision 6) >@@ -781,4 +781,13 @@ > }); > } > } >+ >+ public static IResource getResource(ITypedElement element) { >+ if (element instanceof BufferedResourceNode) { >+ BufferedResourceNode bn= (BufferedResourceNode) element; >+ return bn.getResource(); >+ } >+ return null; >+ >+ } > }
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 265032
: 128111