Community
Participate
Working Groups
3.0 M1 We are rewritting the sync view and are using compare editors instead of embedding the text merge views into the view. I've implemented editor re-use so that you can browse changes and re-use non-dirty editors. The compare editor doesn't implement IReusableEditor hence I have to close a compare editor an open another to support the reuse case. A better solution would be to simply call CompareEditor.setInput. Dirty compare editors are kept open until saved.
IReusableEditor implemented for I20030624
20030625 I tried calling setInput and the open compare editor went blank and the new input was not shown. This is the code that re-uses the editor: private void openEditor() { CompareEditorInput input = getCompareInput(); if(input != null) { IEditorPart editor = reuseCompareEditor((SyncInfoCompareInput)input); if(editor != null && editor instanceof IReusableEditor) { ((IReusableEditor)editor).setInput(input); } else { CompareUI.openCompareEditor(input); } } }
I tried to reproduce the problem by using your code in the implementation of CompareUI.openCompareEditor as follows: public void openCompareEditor(CompareEditorInput input, IWorkbenchPage page) { if (compareResultOK(input)) { if (page == null) page= getActivePage(); if (page != null) { if (CompareEditor.fgCurrentCompareEditor instanceof IReusableEditor) { IReusableEditor e= (IReusableEditor) CompareEditor.fgCurrentCompareEditor; e.setInput(input); } else { try { page.openEditor(input, COMPARE_EDITOR); } catch (PartInitException e) { MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), e.getMessage()); //$NON-NLS-1$ } } } else { MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), //$NON-NLS-1$ Utilities.getString("CompareUIPlugin.noActiveWorkbenchPage")); //$NON-NLS-1$ } } } But this worked for me both on Windows and on Mac OS X. Will have to debug on the real plugin...
fix released for M2
The interesting line in your code, that was missing from mine, is: if(compareResultOK(input)) { ... } CompareResultOK() will end up running the prepareInput() in the progress monitor and creating the actual input. If this method isn't called the input is never *really* set in CompareEditor.setInput(). That was why it wasn't working with the code I submitted. How should a client of compare prime the input? Would it make sense to add a openCompareEditor() method that would a boolean indicating re-use? Then running the prepareInput would remain as is and clients won't have to figure out how to prepare the input before calling CompareEditor.setInput().
released to HEAD for N20030826: added new method to CompareUI: reuseCompareEditor(CompareEditorInput input, IReusableEditor editor) A boolean arg to openCompareEditor wasn't sufficient because it wouldn't be clear what CompareEditor to reuse.