mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 15:45:25 +02:00
[187711] memento support + linking from remote object to editor
This commit is contained in:
parent
a11b162369
commit
15f2700e97
3 changed files with 92 additions and 54 deletions
|
@ -29,6 +29,7 @@ import org.eclipse.rse.core.filters.ISystemFilter;
|
|||
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
|
||||
import org.eclipse.rse.core.filters.ISystemFilterReference;
|
||||
import org.eclipse.rse.internal.files.ui.FileResources;
|
||||
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
|
||||
import org.eclipse.rse.internal.ui.view.SystemViewPart;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
|
@ -36,6 +37,7 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
|||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.view.ContextObject;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemTree;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.rse.ui.view.IViewLinker;
|
||||
|
@ -43,9 +45,12 @@ import org.eclipse.swt.widgets.Display;
|
|||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
|
||||
public class LinkWithSystemViewAction implements IViewActionDelegate {
|
||||
|
||||
|
@ -345,7 +350,56 @@ public class LinkWithSystemViewAction implements IViewActionDelegate {
|
|||
|
||||
public class ViewLinker implements IViewLinker
|
||||
{
|
||||
public void link(IEditorPart editor, ISystemTree systemTree)
|
||||
public void linkViewToEditor(Object remoteObject, IWorkbenchPage page)
|
||||
{
|
||||
Object obj = remoteObject;
|
||||
if (obj instanceof IAdaptable)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter)((IAdaptable)obj).getAdapter(ISystemRemoteElementAdapter.class);
|
||||
if (adapter != null)
|
||||
{
|
||||
|
||||
if (adapter.canEdit(obj))
|
||||
{
|
||||
IEditorReference[] editorRefs = page.getEditorReferences();
|
||||
for (int i = 0; i < editorRefs.length; i++)
|
||||
{
|
||||
IEditorReference editorRef = editorRefs[i];
|
||||
|
||||
IEditorPart editor = editorRef.getEditor(false);
|
||||
if (editor != null)
|
||||
{
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if (input instanceof FileEditorInput)
|
||||
{
|
||||
((FileEditorInput)input).getFile();
|
||||
IFile file = ((FileEditorInput)input).getFile();
|
||||
if (file.getProject().getName().equals(SystemRemoteEditManager.REMOTE_EDIT_PROJECT_NAME))
|
||||
{
|
||||
SystemIFileProperties properties = new SystemIFileProperties(file);
|
||||
String path = properties.getRemoteFilePath();
|
||||
if (path != null && path.equals(adapter.getAbsoluteName(obj)))
|
||||
{
|
||||
page.bringToTop(editor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void linkEditorToView(IEditorPart editor, ISystemTree systemTree)
|
||||
{
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if (input instanceof IFileEditorInput)
|
||||
|
@ -426,5 +480,9 @@ public class LinkWithSystemViewAction implements IViewActionDelegate {
|
|||
_action= action;
|
||||
_action.setChecked(_systemViewPart.isLinkingEnabled());
|
||||
}
|
||||
if (_systemViewPart.isLinkingEnabled() && !_action.isChecked()){ // if restored from memento
|
||||
_action.setChecked(true);
|
||||
_systemViewPart.setLinkingEnabled(true, _linker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ import org.eclipse.rse.ui.actions.SystemRefreshAllAction;
|
|||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.view.ContextObject;
|
||||
import org.eclipse.rse.ui.view.IRSEViewPart;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.rse.ui.view.IViewLinker;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
|
@ -111,9 +110,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IElementFactory;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
|
@ -127,7 +124,6 @@ import org.eclipse.ui.PartInitException;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.actions.ActionFactory;
|
||||
import org.eclipse.ui.part.CellEditorActionHandler;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.part.ISetSelectionTarget;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
|
@ -275,7 +271,7 @@ public class SystemViewPart
|
|||
return;
|
||||
|
||||
if (_viewLinker != null){
|
||||
_viewLinker.link(editor, systemView);
|
||||
_viewLinker.linkEditorToView(editor, systemView);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -573,54 +569,12 @@ public class SystemViewPart
|
|||
// link back to editor
|
||||
protected void linkToEditor(IStructuredSelection selection)
|
||||
{
|
||||
Object obj = selection.getFirstElement();
|
||||
if (obj instanceof IAdaptable)
|
||||
if (_viewLinker != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter)((IAdaptable)obj).getAdapter(ISystemRemoteElementAdapter.class);
|
||||
if (adapter != null)
|
||||
{
|
||||
|
||||
if (adapter.canEdit(obj))
|
||||
{
|
||||
IWorkbenchPage page = getSite().getPage();
|
||||
IEditorReference[] editorRefs = page.getEditorReferences();
|
||||
for (int i = 0; i < editorRefs.length; i++)
|
||||
{
|
||||
IEditorReference editorRef = editorRefs[i];
|
||||
|
||||
IEditorPart editor = editorRef.getEditor(false);
|
||||
if (editor != null)
|
||||
{
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if (input instanceof FileEditorInput)
|
||||
{
|
||||
((FileEditorInput)input).getFile();
|
||||
/** FIXME - can't couple this view to files ui
|
||||
IFile file = ((FileEditorInput)input).getFile();
|
||||
if (file.getProject().getName().equals(SystemRemoteEditManager.REMOTE_EDIT_PROJECT_NAME))
|
||||
{
|
||||
SystemIFileProperties properties = new SystemIFileProperties(file);
|
||||
String path = properties.getRemoteFilePath();
|
||||
if (path != null && path.equals(adapter.getAbsoluteName(obj)))
|
||||
{
|
||||
page.bringToTop(editor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Object obj = selection.getFirstElement();
|
||||
IWorkbenchPage page = getSite().getPage();
|
||||
_viewLinker.linkViewToEditor(obj, page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1888,6 +1842,23 @@ public class SystemViewPart
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String linkWithEditor = memento.getString(TAG_LINKWITHEDITOR);
|
||||
if (linkWithEditor != null)
|
||||
{
|
||||
if (linkWithEditor.equals("t")) //$NON-NLS-1$
|
||||
_isLinkingEnabled = true;
|
||||
else
|
||||
_isLinkingEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isLinkingEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.rse.ui.view;
|
||||
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
||||
public interface IViewLinker {
|
||||
|
||||
|
@ -22,5 +23,13 @@ public interface IViewLinker {
|
|||
* @param editor the active editor
|
||||
* @param systemTree the view to link
|
||||
*/
|
||||
public void link(IEditorPart editor, ISystemTree systemTree);
|
||||
public void linkEditorToView(IEditorPart editor, ISystemTree systemTree);
|
||||
|
||||
|
||||
/**
|
||||
* System View part calls link when using Link With Editor. Provider of action supplies this implementation.
|
||||
* @param editor the active editor
|
||||
* @param page the active workbench page
|
||||
*/
|
||||
public void linkViewToEditor(Object remoteObject, IWorkbenchPage page);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue