use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager method refreshFileOrDirectory.
/**
* Refresh file list
*/
private void refreshFileOrDirectory() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final Object[] objects = selection.toArray();
new ConsoleJob("Reading remote directory", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
if (!((AgentFile) objects[i]).isDirectory())
objects[i] = ((AgentFile) objects[i]).getParent();
final AgentFile sf = ((AgentFile) objects[i]);
sf.setChildren(session.listAgentFiles(sf, sf.getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(sf);
}
});
}
}
@Override
protected String getErrorMessage() {
return "Cannot read remote directory";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager method calculateFolderSize.
/**
* Show file size
*/
private void calculateFolderSize() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final List<AgentFile> files = new ArrayList<AgentFile>(selection.size());
for (Object o : selection.toList()) files.add((AgentFile) o);
new ConsoleJob("Calculate folder size", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (AgentFile f : files) {
f.setFileInfo(session.getAgentFileInfo(f));
}
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.update(files.toArray(), null);
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot calculate folder size";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager method moveFile.
/**
* Move selected file
*/
private void moveFile(final AgentFile target, final AgentFile object) {
new ConsoleJob(Messages.get().AgentFileManager_MoveFile, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().AgentFileManager_MoveError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NestedVerifyOverwrite verify = new NestedVerifyOverwrite(object.getType(), object.getName(), true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.renameAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), false);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// $NON-NLS-1$
session.renameAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), true);
}
};
verify.run(viewer.getControl().getDisplay());
if (verify.isOkPressed()) {
target.setChildren(session.listAgentFiles(target, target.getFullName(), objectId));
object.getParent().setChildren(session.listAgentFiles(object.getParent(), object.getParent().getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(object.getParent(), true);
object.setParent(target);
viewer.refresh(object.getParent(), true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob 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();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager method copyFile.
/**
* Copy agent file
*
* @param target where the file will be moved
* @param object file being moved
*/
private void copyFile(final AgentFile target, final AgentFile object) {
new ConsoleJob("Copying file", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return "Cannot copy file";
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NestedVerifyOverwrite verify = new NestedVerifyOverwrite(object.getType(), object.getName(), true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.copyAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), false);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// $NON-NLS-1$
session.copyAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), true);
}
};
verify.run(viewer.getControl().getDisplay());
if (verify.isOkPressed()) {
target.setChildren(session.listAgentFiles(target, target.getFullName(), objectId));
object.getParent().setChildren(session.listAgentFiles(object.getParent(), object.getParent().getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(object.getParent(), true);
object.setParent(target);
viewer.refresh(target, true);
}
});
}
}
}.start();
}
Aggregations