mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
Bug 153270 - and some open line problems
This commit is contained in:
parent
6059a20125
commit
e2103b07ad
5 changed files with 141 additions and 7 deletions
|
@ -209,7 +209,7 @@ public class SystemRemoteFileLineOpenWithMenu extends SystemRemoteFileOpenWithMe
|
||||||
|
|
||||||
public static void handleGotoLine(IRemoteFile remoteFile, int line, int charStart, int charEnd)
|
public static void handleGotoLine(IRemoteFile remoteFile, int line, int charStart, int charEnd)
|
||||||
{
|
{
|
||||||
if (line > 0)
|
//if (line > 0)
|
||||||
{
|
{
|
||||||
IWorkbench desktop = PlatformUI.getWorkbench();
|
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||||
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||||
|
|
|
@ -2731,9 +2731,16 @@ public class SystemViewRemoteFileAdapter
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.OPEN_IN_SAME_PERSPECTIVE)
|
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.OPEN_IN_SAME_PERSPECTIVE)
|
||||||
{
|
{
|
||||||
DownloadJob oJob = new DownloadJob(editable);
|
if (isFileCached(editable, remoteFile))
|
||||||
oJob.schedule();
|
{
|
||||||
|
editable.openEditor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DownloadJob oJob = new DownloadJob(editable);
|
||||||
|
oJob.schedule();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2762,6 +2769,46 @@ public class SystemViewRemoteFileAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isFileCached(ISystemEditableRemoteObject editable, IRemoteFile remoteFile)
|
||||||
|
{
|
||||||
|
// DY: check if the file exists and is read-only (because it was previously opened
|
||||||
|
// in the system editor)
|
||||||
|
IFile file = editable.getLocalResource();
|
||||||
|
SystemIFileProperties properties = new SystemIFileProperties(file);
|
||||||
|
boolean newFile = !file.exists();
|
||||||
|
|
||||||
|
// detect whether there exists a temp copy already
|
||||||
|
if (!newFile && file.exists())
|
||||||
|
{
|
||||||
|
// we have a local copy of this file, so we need to compare timestamps
|
||||||
|
|
||||||
|
// get stored modification stamp
|
||||||
|
long storedModifiedStamp = properties.getRemoteFileTimeStamp();
|
||||||
|
|
||||||
|
// get updated remoteFile so we get the current remote timestamp
|
||||||
|
//remoteFile.markStale(true);
|
||||||
|
IRemoteFileSubSystem subsystem = remoteFile.getParentRemoteFileSubSystem();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
remoteFile = subsystem.getRemoteFileObject(remoteFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the remote modified stamp
|
||||||
|
long remoteModifiedStamp = remoteFile.getLastModified();
|
||||||
|
|
||||||
|
// get dirty flag
|
||||||
|
boolean dirty = properties.getDirty();
|
||||||
|
|
||||||
|
boolean remoteNewer = (storedModifiedStamp != remoteModifiedStamp);
|
||||||
|
return (!dirty && !remoteNewer);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canEdit(Object element)
|
public boolean canEdit(Object element)
|
||||||
{
|
{
|
||||||
IRemoteFile remoteFile = (IRemoteFile) element;
|
IRemoteFile remoteFile = (IRemoteFile) element;
|
||||||
|
|
|
@ -63,11 +63,13 @@ command: gmake.*
|
||||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||||
|
|
||||||
command: gcc\s.*
|
command: gcc\s.*
|
||||||
error file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
error file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||||
warning file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
warning file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||||
informational file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
informational file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*): warning: .*
|
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*): warning: .*
|
||||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||||
|
error file line pattern =([\w,\.,/,\\,\-,\+,(,)]*):(\d*): error: .*
|
||||||
|
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: [\w,.,/,\\,\-,\+,(,)]*: .*
|
||||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||||
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
||||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter;
|
||||||
import org.eclipse.rse.files.ui.actions.SystemRemoteFileLineOpenWithMenu;
|
import org.eclipse.rse.files.ui.actions.SystemRemoteFileLineOpenWithMenu;
|
||||||
import org.eclipse.rse.files.ui.resources.RemoteSourceLookupDirector;
|
import org.eclipse.rse.files.ui.resources.RemoteSourceLookupDirector;
|
||||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||||
|
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||||
import org.eclipse.rse.shells.ui.ShellResources;
|
import org.eclipse.rse.shells.ui.ShellResources;
|
||||||
import org.eclipse.rse.shells.ui.actions.SystemShowInShellViewAction;
|
import org.eclipse.rse.shells.ui.actions.SystemShowInShellViewAction;
|
||||||
import org.eclipse.rse.shells.ui.actions.SystemTerminateRemoveShellAction;
|
import org.eclipse.rse.shells.ui.actions.SystemTerminateRemoveShellAction;
|
||||||
|
@ -65,11 +66,16 @@ import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||||
import org.eclipse.rse.ui.view.SystemView;
|
import org.eclipse.rse.ui.view.SystemView;
|
||||||
import org.eclipse.rse.ui.view.SystemViewResources;
|
import org.eclipse.rse.ui.view.SystemViewResources;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
import org.eclipse.ui.IEditorDescriptor;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IEditorReference;
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
import org.eclipse.ui.IEditorRegistry;
|
||||||
|
import org.eclipse.ui.IFileEditorInput;
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
|
@ -556,10 +562,14 @@ implements ISystemViewElementAdapter, ISystemRemoteElementAdapter, ISystemOutpu
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
if (line > 0)
|
DelayedGotoLine dgoto = new DelayedGotoLine(file, line, output.getCharStart(), output.getCharEnd());
|
||||||
|
Display.getDefault().asyncExec(dgoto);
|
||||||
|
/*
|
||||||
|
//if (line > 0)
|
||||||
{
|
{
|
||||||
SystemRemoteFileLineOpenWithMenu.handleGotoLine(file, line, output.getCharStart(), output.getCharEnd());
|
SystemRemoteFileLineOpenWithMenu.handleGotoLine(file, line, output.getCharStart(), output.getCharEnd());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,6 +588,67 @@ implements ISystemViewElementAdapter, ISystemRemoteElementAdapter, ISystemOutpu
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DelayedGotoLine implements Runnable
|
||||||
|
{
|
||||||
|
private IRemoteFile _file;
|
||||||
|
private int _line;
|
||||||
|
private int _charStart;
|
||||||
|
private int _charEnd;
|
||||||
|
|
||||||
|
public DelayedGotoLine(IRemoteFile file, int line, int charStart, int charEnd)
|
||||||
|
{
|
||||||
|
_file = file;
|
||||||
|
_line = line;
|
||||||
|
_charStart = charStart;
|
||||||
|
_charEnd = charEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (checkEditorOpen())
|
||||||
|
{
|
||||||
|
SystemRemoteFileLineOpenWithMenu.handleGotoLine(_file, _line, _charStart, _charEnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Display.getDefault().asyncExec(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkEditorOpen()
|
||||||
|
{
|
||||||
|
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||||
|
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||||
|
IEditorPart editor = null;
|
||||||
|
String fileName = _file.getAbsolutePath();
|
||||||
|
IEditorReference[] editors = persp.getEditorReferences();
|
||||||
|
for (int i = 0; i < editors.length; i++)
|
||||||
|
{
|
||||||
|
IEditorReference ref = editors[i];
|
||||||
|
IEditorPart editorp = ref.getEditor(false);
|
||||||
|
if (editorp != null)
|
||||||
|
{
|
||||||
|
IEditorInput einput = editorp.getEditorInput();
|
||||||
|
if (einput instanceof IFileEditorInput)
|
||||||
|
{
|
||||||
|
IFileEditorInput input = (IFileEditorInput) einput;
|
||||||
|
IFile efile = input.getFile();
|
||||||
|
|
||||||
|
SystemIFileProperties properties = new SystemIFileProperties(efile);
|
||||||
|
String comparePath = properties.getRemoteFilePath();
|
||||||
|
|
||||||
|
if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/'))))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the associated subsystem for this line of remote output or remote command
|
* Returns the associated subsystem for this line of remote output or remote command
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,7 +76,21 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
|
||||||
output = new RemoteOutput(this, type);
|
output = new RemoteOutput(this, type);
|
||||||
}
|
}
|
||||||
output.setText(line.getName());
|
output.setText(line.getName());
|
||||||
output.setAbsolutePath(line.getSource());
|
|
||||||
|
String src = line.getSource();
|
||||||
|
int colonSep = src.indexOf(':');
|
||||||
|
// line numbers
|
||||||
|
if (colonSep > 0)
|
||||||
|
{
|
||||||
|
String lineNo = src.substring(colonSep + 1);
|
||||||
|
String file = src.substring(0, colonSep);
|
||||||
|
output.setAbsolutePath(file);
|
||||||
|
output.setLine(Integer.parseInt(lineNo));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output.setAbsolutePath(src);
|
||||||
|
}
|
||||||
|
|
||||||
addOutput(output);
|
addOutput(output);
|
||||||
outputs[i] = output;
|
outputs[i] = output;
|
||||||
|
|
Loading…
Add table
Reference in a new issue