use of org.netxms.ui.eclipse.filemanager.dialogs.CreateFolderDialog in project netxms by netxms.
the class AgentFileManager method createFolder.
/**
* Create new folder
*/
private void createFolder() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final Object[] objects = selection.toArray();
final AgentFile parentFolder = ((AgentFile) objects[0]).isDirectory() ? ((AgentFile) objects[0]) : ((AgentFile) objects[0]).getParent();
final CreateFolderDialog dlg = new CreateFolderDialog(getSite().getShell());
if (dlg.open() != Window.OK)
return;
final String newFolder = dlg.getNewName();
new ConsoleJob(Messages.get().AgentFileManager_CreatingFolder, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().AgentFileManager_FolderCreationError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NestedVerifyOverwrite verify = new NestedVerifyOverwrite(AgentFile.DIRECTORY, newFolder, true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.createFolderOnAgent(objectId, parentFolder.getFullName() + "/" + newFolder);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// do nothing
}
};
verify.run(viewer.getControl().getDisplay());
parentFolder.setChildren(session.listAgentFiles(parentFolder, parentFolder.getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(parentFolder, true);
}
});
}
}.start();
}
Aggregations