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 119486 Details for
Bug 120602
[History View] Should have an Open With
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix v01
120602_20081204.txt (text/plain), 24.58 KB, created by
Szymon Brandys
on 2008-12-04 05:45:39 EST
(
hide
)
Description:
Fix v01
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2008-12-04 05:45:39 EST
Size:
24.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.cvs.ui >Index: src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java,v >retrieving revision 1.93 >diff -u -r1.93 CVSUIMessages.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 2 Dec 2008 10:25:50 -0000 1.93 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 4 Dec 2008 10:42:54 -0000 >@@ -1161,6 +1161,7 @@ > public static String CVSHistoryPage_CompareModeToggleAction; > public static String CVSHistoryPage_FilterHistoryTooltip; > public static String CVSHistoryPage_OpenAction; >+ public static String CVSHistoryPage_OpenWithMenu; > public static String CVSHistoryPage_GroupByDate; > public static String CVSHistoryPage_Today; > public static String CVSHistoryPage_Yesterday; >Index: src/org/eclipse/team/internal/ccvs/ui/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties,v >retrieving revision 1.547 >diff -u -r1.547 messages.properties >--- src/org/eclipse/team/internal/ccvs/ui/messages.properties 2 Dec 2008 10:25:50 -0000 1.547 >+++ src/org/eclipse/team/internal/ccvs/ui/messages.properties 4 Dec 2008 10:42:55 -0000 >@@ -1086,6 +1086,7 @@ > CVSHistoryTableProvider_base=<base> > CVSHistoryPage_LocalModeAction=Local Mode > CVSHistoryPage_OpenAction=&Open >+CVSHistoryPage_OpenWithMenu=Open &With > CVSHistoryPage_GroupByDate=Group Revisions by Date > CVSHistoryPage_Today=Today > CVSHistoryPage_Yesterday=Yesterday >Index: src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java,v >retrieving revision 1.108 >diff -u -r1.108 CVSHistoryPage.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java 30 Sep 2008 15:48:52 -0000 1.108 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java 4 Dec 2008 10:42:54 -0000 >@@ -61,8 +61,7 @@ > import org.eclipse.team.internal.core.history.LocalFileRevision; > import org.eclipse.team.internal.ui.TeamUIMessages; > import org.eclipse.team.internal.ui.Utils; >-import org.eclipse.team.internal.ui.actions.CompareRevisionAction; >-import org.eclipse.team.internal.ui.actions.OpenRevisionAction; >+import org.eclipse.team.internal.ui.actions.*; > import org.eclipse.team.internal.ui.history.*; > import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; > import org.eclipse.team.ui.history.*; >@@ -101,6 +100,7 @@ > > /* private */CompareRevisionAction compareAction; > /* private */OpenRevisionAction openAction; >+ private OpenWithMenu openWithMenu; > > private CVSHistoryFilterAction cvsHistoryFilter; > private IAction toggleTextAction; >@@ -529,6 +529,14 @@ > } > }); > >+ // Add 'Open With...' sub-menu >+ openWithMenu = new OpenWithMenu(this); >+ treeViewer.getTree().addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ openWithMenu.selectionChanged((IStructuredSelection) treeViewer.getSelection()); >+ } >+ }); >+ > treeViewer.addOpenListener(new IOpenListener() { > public void open(OpenEvent e) { > if (getSite() != null) { >@@ -839,6 +847,12 @@ > > if (file != null && !parentSite.isModal()){ > manager.add(openAction); >+ >+ MenuManager openWithSubmenu = new MenuManager( >+ CVSUIMessages.CVSHistoryPage_OpenWithMenu); >+ openWithSubmenu.add(openWithMenu); >+ manager.add(openWithSubmenu); >+ > manager.add(compareAction); > manager.add(new Separator("openCompare")); //$NON-NLS-1$ > } >#P org.eclipse.team.ui >Index: src/org/eclipse/team/internal/ui/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties,v >retrieving revision 1.247 >diff -u -r1.247 messages.properties >--- src/org/eclipse/team/internal/ui/messages.properties 2 Dec 2008 15:15:24 -0000 1.247 >+++ src/org/eclipse/team/internal/ui/messages.properties 4 Dec 2008 10:42:57 -0000 >@@ -454,6 +454,11 @@ > LocalHistoryPage_openRevision=Open Revision > LocalHistoryPage_CompareAction=&Compare > LocalHistoryPage_OpenAction=&Open >+LocalHistoryPage_OpenWithMenu=Open &With >+LocalHistoryPage_OpenWithMenu_Other=Other... >+LocalHistoryPage_OpenWithMenu_OtherDialogDescription=Choose the editor for opening {0}: >+LocalHistoryPage_OpenWithMenu_DefaultEditorDescription=&Default Editor >+LocalHistoryPage_OpenEditorError=A problem occurred while opening the editor > LocalHistoryPage_0=Local History ({0}) > LocalHistoryPage_1=Workspace File > LocalHistoryPage_GetContents=Get Contents >Index: src/org/eclipse/team/internal/ui/TeamUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java,v >retrieving revision 1.79 >diff -u -r1.79 TeamUIMessages.java >--- src/org/eclipse/team/internal/ui/TeamUIMessages.java 2 Dec 2008 15:15:24 -0000 1.79 >+++ src/org/eclipse/team/internal/ui/TeamUIMessages.java 4 Dec 2008 10:42:56 -0000 >@@ -159,6 +159,16 @@ > public static String LocalHistoryPage_NoRevisionsFound; > > public static String LocalHistoryPage_OpenAction; >+ >+ public static String LocalHistoryPage_OpenWithMenu; >+ >+ public static String LocalHistoryPage_OpenWithMenu_Other; >+ >+ public static String LocalHistoryPage_OpenWithMenu_OtherDialogDescription; >+ >+ public static String LocalHistoryPage_OpenWithMenu_DefaultEditorDescription; >+ >+ public static String LocalHistoryPage_OpenEditorError; > > public static String LocalHistoryPage_OverwriteMessage; > >Index: src/org/eclipse/team/internal/ui/Utils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java,v >retrieving revision 1.86 >diff -u -r1.86 Utils.java >--- src/org/eclipse/team/internal/ui/Utils.java 2 Dec 2008 10:25:53 -0000 1.86 >+++ src/org/eclipse/team/internal/ui/Utils.java 4 Dec 2008 10:42:57 -0000 >@@ -1069,27 +1069,51 @@ > } > } > >- public static IEditorPart openEditor(IWorkbenchPage page, FileRevisionEditorInput editorInput) throws PartInitException { >+ public static IEditorPart openEditor(IWorkbenchPage page, >+ FileRevisionEditorInput editorInput) throws PartInitException { > String id = getEditorId(editorInput); >+ return openEditor(page, editorInput, id); >+ } >+ >+ public static IEditorPart openEditor(IWorkbenchPage page, >+ FileRevisionEditorInput editorInput, String editorId) >+ throws PartInitException { > try { >- IEditorPart part= page.openEditor(editorInput, id, OpenStrategy.activateOnOpen()); >+ IEditorPart part = page.openEditor(editorInput, editorId, >+ OpenStrategy.activateOnOpen()); > // See bug 90582 for the reasons behind this discouraged access > if (part instanceof ErrorEditorPart) { > page.closeEditor(part, false); > part = null; > } > if (part == null) { >- throw new PartInitException(NLS.bind(TeamUIMessages.Utils_17, id)); >+ throw new PartInitException(NLS.bind(TeamUIMessages.Utils_17, >+ editorId)); > } > return part; > } catch (PartInitException e) { >- if (id.equals("org.eclipse.ui.DefaultTextEditor")) { //$NON-NLS-1$ >+ if (editorId.equals("org.eclipse.ui.DefaultTextEditor")) { //$NON-NLS-1$ > throw e; > } else { >- return page.openEditor(editorInput,"org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ >+ return page.openEditor(editorInput, >+ "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ > } > } > } >+ >+ public static IEditorDescriptor[] getEditors(IFileRevision revision) { >+ IEditorRegistry registry = PlatformUI.getWorkbench() >+ .getEditorRegistry(); >+ // so far only the revision name is used to find editors >+ return registry.getEditors(revision.getName()/*, getContentType(revision) */); >+ } >+ >+ public static IEditorDescriptor getDefaultEditor(IFileRevision revision) { >+ // so far only the revision name is used to find the default editor >+ IEditorRegistry registry = PlatformUI.getWorkbench() >+ .getEditorRegistry(); >+ return registry.getDefaultEditor(revision.getName()/*, getContentType(revision) */); >+ } > > private static String getEditorId(FileRevisionEditorInput editorInput) { > String id = getEditorId(editorInput.getFileRevision().getName(), getContentType(editorInput)); >Index: src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java,v >retrieving revision 1.34 >diff -u -r1.34 LocalHistoryPage.java >--- src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java 3 Sep 2008 13:57:39 -0000 1.34 >+++ src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java 4 Dec 2008 10:42:58 -0000 >@@ -42,8 +42,7 @@ > import org.eclipse.team.internal.core.history.LocalFileHistory; > import org.eclipse.team.internal.core.history.LocalFileRevision; > import org.eclipse.team.internal.ui.*; >-import org.eclipse.team.internal.ui.actions.CompareRevisionAction; >-import org.eclipse.team.internal.ui.actions.OpenRevisionAction; >+import org.eclipse.team.internal.ui.actions.*; > import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; > import org.eclipse.team.ui.history.*; > import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput; >@@ -85,6 +84,7 @@ > private Action getContentsAction; > private CompareRevisionAction compareAction; > private OpenRevisionAction openAction; >+ private OpenWithMenu openWithMenu; > > private HistoryResourceListener resourceListener; > >@@ -393,6 +393,14 @@ > openAction.selectionChanged((IStructuredSelection) treeViewer.getSelection()); > } > }); >+ >+ // Add 'Open With...' sub-menu >+ openWithMenu = new OpenWithMenu(this); >+ treeViewer.getTree().addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ openWithMenu.selectionChanged((IStructuredSelection) treeViewer.getSelection()); >+ } >+ }); > } > > treeViewer.addOpenListener(new IOpenListener() { >@@ -479,6 +487,12 @@ > if (file != null && !parentSite.isModal()){ > if (openAction != null) > manager.add(openAction); >+ if (openWithMenu != null) { >+ MenuManager openWithSubmenu = new MenuManager( >+ TeamUIMessages.LocalHistoryPage_OpenWithMenu); >+ openWithSubmenu.add(openWithMenu); >+ manager.add(openWithSubmenu); >+ } > if (compareAction != null) > manager.add(compareAction); > if (getContentsAction != null) { >Index: src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java >diff -N src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,408 @@ >+/******************************************************************************* >+ * 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ui.actions; >+ >+import java.util.*; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IStorage; >+import org.eclipse.core.runtime.*; >+import org.eclipse.jface.action.ContributionItem; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.team.core.history.IFileRevision; >+import org.eclipse.team.internal.ui.TeamUIMessages; >+import org.eclipse.team.internal.ui.Utils; >+import org.eclipse.team.internal.ui.history.AbstractHistoryCategory; >+import org.eclipse.team.internal.ui.history.FileRevisionEditorInput; >+import org.eclipse.team.ui.history.HistoryPage; >+import org.eclipse.ui.*; >+import org.eclipse.ui.dialogs.EditorSelectionDialog; >+import org.eclipse.ui.internal.WorkbenchPage; >+import org.eclipse.ui.part.FileEditorInput; >+import org.eclipse.ui.statushandlers.*; >+ >+import com.ibm.icu.text.Collator; >+ >+/** >+ * A menu for opening file revisions in the workbench. >+ * <p> >+ * An <code>OpenWithMenu</code> is used to populate a menu with "Open With" >+ * actions. One action is added for each editor which is applicable to the >+ * selected file. If the user selects one of these items, the corresponding >+ * editor is opened on the file. >+ * </p> >+ */ >+public class OpenWithMenu extends ContributionItem { >+ >+ private IStructuredSelection selection; >+ >+ private HistoryPage page; >+ >+ private IEditorRegistry registry = PlatformUI.getWorkbench() >+ .getEditorRegistry(); >+ >+ private static Hashtable imageCache = new Hashtable(11); >+ >+ /** >+ * The id of this action. >+ */ >+ public static final String ID = PlatformUI.PLUGIN_ID + ".OpenWithMenu";//$NON-NLS-1$ >+ >+ /** >+ * Match both the input and id, so that different types of editor can be >+ * opened on the same input. >+ */ >+ private static final int MATCH_BOTH = IWorkbenchPage.MATCH_INPUT >+ | IWorkbenchPage.MATCH_ID; >+ >+ /* >+ * Compares the labels from two IEditorDescriptor objects >+ */ >+ private static final Comparator comparer = new Comparator() { >+ private Collator collator = Collator.getInstance(); >+ >+ public int compare(Object arg0, Object arg1) { >+ String s1 = ((IEditorDescriptor) arg0).getLabel(); >+ String s2 = ((IEditorDescriptor) arg1).getLabel(); >+ return collator.compare(s1, s2); >+ } >+ }; >+ >+ /** >+ * Constructs a new instance of <code>OpenWithMenu</code>. >+ * >+ * @param page >+ * the page where the editor is opened if an item within the menu >+ * is selected >+ */ >+ public OpenWithMenu(HistoryPage page) { >+ super(ID); >+ this.page = page; >+ } >+ >+ /** >+ * Returns an image to show for the corresponding editor descriptor. >+ * >+ * @param editorDesc >+ * the editor descriptor, or null for the system editor >+ * @return the image or null >+ */ >+ private Image getImage(IEditorDescriptor editorDesc) { >+ ImageDescriptor imageDesc = getImageDescriptor(editorDesc); >+ if (imageDesc == null) { >+ return null; >+ } >+ Image image = (Image) imageCache.get(imageDesc); >+ if (image == null) { >+ image = imageDesc.createImage(); >+ imageCache.put(imageDesc, image); >+ } >+ return image; >+ } >+ >+ /** >+ * Returns the image descriptor for the given editor descriptor, or null if >+ * it has no image. >+ */ >+ private ImageDescriptor getImageDescriptor(IEditorDescriptor editorDesc) { >+ ImageDescriptor imageDesc = null; >+ if (editorDesc == null) { >+ imageDesc = registry >+ .getImageDescriptor(getFileRevision().getName()); >+ // TODO: is this case valid, and if so, what are the implications >+ // for content-type editor bindings? >+ } else { >+ imageDesc = editorDesc.getImageDescriptor(); >+ } >+ if (imageDesc == null) { >+ if (editorDesc.getId().equals( >+ IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)) { >+ imageDesc = registry >+ .getSystemExternalEditorImageDescriptor(getFileRevision() >+ .getName()); >+ } >+ } >+ return imageDesc; >+ } >+ >+ /** >+ * Creates the menu item for the editor descriptor. >+ * >+ * @param menu >+ * the menu to add the item to >+ * @param descriptor >+ * the editor descriptor, or null for the system editor >+ * @param preferredEditor >+ * the descriptor of the preferred editor, or <code>null</code> >+ */ >+ private MenuItem createMenuItem(Menu menu, >+ final IEditorDescriptor descriptor, >+ final IEditorDescriptor preferredEditor) { >+ // XXX: Would be better to use bold here, but SWT does not support it. >+ final MenuItem menuItem = new MenuItem(menu, SWT.RADIO); >+ boolean isPreferred = preferredEditor != null >+ && descriptor.getId().equals(preferredEditor.getId()); >+ menuItem.setSelection(isPreferred); >+ menuItem.setText(descriptor.getLabel()); >+ Image image = getImage(descriptor); >+ if (image != null) { >+ menuItem.setImage(image); >+ } >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ switch (event.type) { >+ case SWT.Selection: >+ if (menuItem.getSelection()) { >+ openEditor(descriptor, false); >+ } >+ break; >+ } >+ } >+ }; >+ menuItem.addListener(SWT.Selection, listener); >+ return menuItem; >+ } >+ >+ /** >+ * Creates the Other... menu item >+ * >+ * @param menu >+ * the menu to add the item to >+ */ >+ private void createOtherMenuItem(final Menu menu) { >+ final IFileRevision fileResource = getFileRevision(); >+ if (fileResource == null) { >+ return; >+ } >+ new MenuItem(menu, SWT.SEPARATOR); >+ final MenuItem menuItem = new MenuItem(menu, SWT.PUSH); >+ menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_Other); >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ switch (event.type) { >+ case SWT.Selection: >+ EditorSelectionDialog dialog = new EditorSelectionDialog( >+ menu.getShell()); >+ dialog >+ .setMessage(NLS >+ .bind( >+ TeamUIMessages.LocalHistoryPage_OpenWithMenu_OtherDialogDescription, >+ fileResource.getName())); >+ if (dialog.open() == Window.OK) { >+ IEditorDescriptor editor = dialog.getSelectedEditor(); >+ if (editor != null) { >+ openEditor(editor, editor.isOpenExternal()); >+ } >+ } >+ break; >+ } >+ } >+ }; >+ menuItem.addListener(SWT.Selection, listener); >+ } >+ >+ public void fill(Menu menu, int index) { >+ final IFileRevision fileRevision = getFileRevision(); >+ if (fileRevision == null) { >+ return; >+ } >+ >+ IEditorDescriptor defaultTextEditor = registry >+ .findEditor("org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ >+ IEditorDescriptor preferredEditor = Utils >+ .getDefaultEditor(fileRevision); >+ >+ Object[] editors = Utils.getEditors(fileRevision); >+ Collections.sort(Arrays.asList(editors), comparer); >+ boolean defaultFound = false; >+ >+ // Check that we don't add it twice. This is possible >+ // if the same editor goes to two mappings. >+ ArrayList alreadyMapped = new ArrayList(); >+ >+ for (int i = 0; i < editors.length; i++) { >+ IEditorDescriptor editor = (IEditorDescriptor) editors[i]; >+ if (!alreadyMapped.contains(editor)) { >+ createMenuItem(menu, editor, preferredEditor); >+ if (defaultTextEditor != null >+ && editor.getId().equals(defaultTextEditor.getId())) { >+ defaultFound = true; >+ } >+ alreadyMapped.add(editor); >+ } >+ } >+ >+ // Only add a separator if there is something to separate >+ if (editors.length > 0) { >+ new MenuItem(menu, SWT.SEPARATOR); >+ } >+ >+ // Add default editor. Check it if it is saved as the preference. >+ if (!defaultFound && defaultTextEditor != null) { >+ createMenuItem(menu, defaultTextEditor, preferredEditor); >+ } >+ >+ // TODO : We might perhaps enable inplace and system external editors menu items >+ /*// Add system editor >+ IEditorDescriptor descriptor = registry >+ .findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); >+ final MenuItem systemEditorMenuItem = createMenuItem(menu, descriptor, >+ preferredEditor); >+ systemEditorMenuItem.setEnabled(false); >+ >+ // Add system in-place editor >+ descriptor = registry >+ .findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID); >+ >+ final MenuItem inPlaceEditorMenuItem = (descriptor != null) ? createMenuItem( >+ menu, descriptor, preferredEditor) >+ : null; >+ if (inPlaceEditorMenuItem != null) >+ inPlaceEditorMenuItem.setEnabled(false); >+ >+ Job job = new Job("updateOpenWithMenu") { //$NON-NLS-1$ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ final boolean isFile = fileRevision.getStorage(monitor) instanceof IFile; >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ if (inPlaceEditorMenuItem != null >+ && !inPlaceEditorMenuItem.isDisposed()) >+ inPlaceEditorMenuItem.setEnabled(isFile); >+ if (!systemEditorMenuItem.isDisposed()) >+ systemEditorMenuItem.setEnabled(isFile); >+ } >+ }); >+ return Status.OK_STATUS; >+ } catch (CoreException e) { >+ return new Status(IStatus.WARNING, TeamUIPlugin.ID, null, e); >+ } >+ }; >+ }; >+ job.setSystem(true); >+ job.schedule();*/ >+ >+ createDefaultMenuItem(menu, fileRevision); >+ >+ // add Other... menu item >+ createOtherMenuItem(menu); >+ } >+ >+ public void createDefaultMenuItem(Menu menu, final IFileRevision revision) { >+ final MenuItem menuItem = new MenuItem(menu, SWT.RADIO); >+ menuItem.setSelection(Utils.getDefaultEditor(revision) == null); >+ menuItem >+ .setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription); >+ >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ switch (event.type) { >+ case SWT.Selection: >+ if (menuItem.getSelection()) { >+ openEditor(Utils.getDefaultEditor(revision), false); >+ } >+ break; >+ } >+ } >+ }; >+ >+ menuItem.addListener(SWT.Selection, listener); >+ } >+ >+ /** >+ * Opens the given editor on the selected file revision. >+ */ >+ protected void openEditor(IEditorDescriptor editorDescriptor, >+ boolean openUsingDescriptor) { >+ IFileRevision fileRevision = getFileRevision(); >+ if (fileRevision == null) { >+ return; >+ } >+ try { >+ IProgressMonitor monitor = new NullProgressMonitor(); >+ IStorage storage = fileRevision.getStorage(monitor); >+ boolean isFile = storage instanceof IFile; >+ >+ if (openUsingDescriptor) { >+ // discouraged access to open system editors >+ ((WorkbenchPage) (page.getSite().getPage())) >+ .openEditorFromDescriptor(isFile ? new FileEditorInput( >+ (IFile) storage) >+ : (IEditorInput) FileRevisionEditorInput >+ .createEditorInputFor(fileRevision, >+ monitor), editorDescriptor, >+ true, null); >+ } else { >+ String editorId = editorDescriptor == null ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID >+ : editorDescriptor.getId(); >+ page.getSite().getPage().openEditor( >+ isFile ? new FileEditorInput((IFile) storage) >+ : (IEditorInput) FileRevisionEditorInput >+ .createEditorInputFor(fileRevision, >+ monitor), editorId, true, >+ MATCH_BOTH); >+ } >+ } catch (PartInitException e) { >+ StatusAdapter sA = new StatusAdapter(e.getStatus()); >+ sA.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, >+ TeamUIMessages.LocalHistoryPage_OpenEditorError); >+ StatusManager.getManager().handle(sA, StatusManager.SHOW); >+ } catch (CoreException e) { >+ StatusAdapter sA = new StatusAdapter(e.getStatus()); >+ sA.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, >+ TeamUIMessages.LocalHistoryPage_OpenEditorError); >+ StatusManager.getManager().handle(sA, StatusManager.LOG); >+ } >+ } >+ >+ private IFileRevision getFileRevision() { >+ IStructuredSelection structSel = selection; >+ >+ IFileRevision revision = null; >+ >+ if (structSel == null) >+ return null; >+ >+ Object[] objArray = structSel.toArray(); >+ >+ for (int i = 0; i < objArray.length; i++) { >+ Object tempRevision = objArray[i]; >+ // If not a revision, don't try opening >+ if (tempRevision instanceof AbstractHistoryCategory) >+ continue; >+ >+ revision = (IFileRevision) tempRevision; >+ } >+ return revision; >+ } >+ >+ /* >+ * (non-Javadoc) Returns whether this menu is dynamic. >+ */ >+ public boolean isDynamic() { >+ return true; >+ } >+ >+ public void selectionChanged(IStructuredSelection selection) { >+ if (selection instanceof IStructuredSelection) { >+ this.selection = selection; >+ } else { >+ this.selection = StructuredSelection.EMPTY; >+ } >+ } >+}
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 120602
: 119486