mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
applying Michael Scharf's patch for 163844 plus a modification to handle the case where Display.getCurrent() returns null.
This commit is contained in:
parent
3cbae9bf2a
commit
4d68ac7d71
1 changed files with 35 additions and 16 deletions
|
@ -210,10 +210,13 @@ public class UniversalFileTransferUtility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RemoteFileIOException e)
|
catch (final RemoteFileIOException e)
|
||||||
{
|
{
|
||||||
SystemMessageDialog dlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), e.getSystemMessage());
|
runInDisplayThread(new Runnable() {
|
||||||
dlg.open();
|
public void run() {
|
||||||
|
SystemMessageDialog dlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), e.getSystemMessage());
|
||||||
|
dlg.open();
|
||||||
|
}});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2004,15 +2007,15 @@ public class UniversalFileTransferUtility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String checkForCollision(IRemoteFile targetFolder, String oldName)
|
protected static String checkForCollision(final IRemoteFile targetFolder, String oldName)
|
||||||
{
|
{
|
||||||
String newName = oldName;
|
final String[] newName = new String[]{oldName};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
|
||||||
IRemoteFile targetFileOrFolder = ss.getRemoteFileObject(targetFolder, oldName);
|
final IRemoteFile targetFileOrFolder = ss.getRemoteFileObject(targetFolder, oldName);
|
||||||
|
|
||||||
//RSEUIPlugin.logInfo("CHECKING FOR COLLISION ON '"+srcFileOrFolder.getAbsolutePath() + "' IN '" +targetFolder.getAbsolutePath()+"'");
|
//RSEUIPlugin.logInfo("CHECKING FOR COLLISION ON '"+srcFileOrFolder.getAbsolutePath() + "' IN '" +targetFolder.getAbsolutePath()+"'");
|
||||||
//RSEUIPlugin.logInfo("...TARGET FILE: '"+tgtFileOrFolder.getAbsolutePath()+"'");
|
//RSEUIPlugin.logInfo("...TARGET FILE: '"+tgtFileOrFolder.getAbsolutePath()+"'");
|
||||||
|
@ -2020,18 +2023,21 @@ public class UniversalFileTransferUtility
|
||||||
if (targetFileOrFolder.exists())
|
if (targetFileOrFolder.exists())
|
||||||
{
|
{
|
||||||
//monitor.setVisible(false); wish we could!
|
//monitor.setVisible(false); wish we could!
|
||||||
|
|
||||||
// we no longer have to set the validator here... the common rename dialog we all now use queries the input
|
// we no longer have to set the validator here... the common rename dialog we all now use queries the input
|
||||||
// object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
|
// object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
|
||||||
ValidatorFileUniqueName validator = null; // new ValidatorFileUniqueName(shell, targetFolder, srcFileOrFolder.isDirectory());
|
runInDisplayThread(new Runnable() {
|
||||||
//SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
|
public void run() {
|
||||||
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(SystemBasePlugin.getActiveWorkbenchShell(), true, targetFileOrFolder, validator); // true => copy-collision-mode
|
ValidatorFileUniqueName validator = null; // new ValidatorFileUniqueName(shell, targetFolder, srcFileOrFolder.isDirectory());
|
||||||
|
//SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
|
||||||
|
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(SystemBasePlugin.getActiveWorkbenchShell(), true, targetFileOrFolder, validator); // true => copy-collision-mode
|
||||||
|
|
||||||
dlg.open();
|
dlg.open();
|
||||||
if (!dlg.wasCancelled())
|
if (!dlg.wasCancelled())
|
||||||
newName = dlg.getNewName();
|
newName[0] = dlg.getNewName();
|
||||||
else
|
else
|
||||||
newName = null;
|
newName[0] = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
|
@ -2039,6 +2045,19 @@ public class UniversalFileTransferUtility
|
||||||
SystemBasePlugin.logError("SystemCopyRemoteFileAction.checkForCollision()", e);
|
SystemBasePlugin.logError("SystemCopyRemoteFileAction.checkForCollision()", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newName;
|
return newName[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void runInDisplayThread(Runnable runnable) {
|
||||||
|
Display display = Display.getCurrent();
|
||||||
|
if (display == null)
|
||||||
|
display = Display.getDefault();
|
||||||
|
if(Thread.currentThread()==display.getThread()) {
|
||||||
|
// if we are in the display thread we can call the method directly
|
||||||
|
runnable.run();
|
||||||
|
} else {
|
||||||
|
// we execute it in the Display Thread but we wait for the result...
|
||||||
|
display.syncExec(runnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue