use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager method doRename.
/**
* Do actual rename
*
* @param AgentFile
* @param newName
*/
private void doRename(final AgentFile agentFile, final String newName) {
new ConsoleJob("Rename file", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().AgentFileManager_RenameError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final NestedVerifyOverwrite verify = new NestedVerifyOverwrite(agentFile.getType(), newName, true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.renameAgentFile(objectId, agentFile.getFullName(), agentFile.getParent().getFullName() + "/" + newName, false);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// $NON-NLS-1$
session.renameAgentFile(objectId, agentFile.getFullName(), agentFile.getParent().getFullName() + "/" + newName, true);
}
};
verify.run(viewer.getControl().getDisplay());
if (verify.isOkPressed()) {
runInUIThread(new Runnable() {
@Override
public void run() {
if (verify.isOkPressed())
refreshFileOrDirectory();
agentFile.setName(newName);
viewer.refresh(agentFile, true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerFileManager method deleteFile.
/**
* Delete selected file
*/
private void deleteFile() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().ViewServerFile_DeleteConfirmation, Messages.get().ViewServerFile_DeletAck))
return;
final Object[] objects = selection.toArray();
new ConsoleJob(Messages.get().ViewServerFile_DeletFileFromServerJob, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().ViewServerFile_ErrorDeleteFileJob;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
session.deleteServerFile(((ServerFile) objects[i]).getName());
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerFileManager method refreshFileList.
/**
* Refresh file list
*/
private void refreshFileList() {
final Display display = viewer.getControl().getDisplay();
new ConsoleJob(Messages.get(display).SelectServerFileDialog_JobTitle, null, Activator.PLUGIN_ID, null, display) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
files = session.listServerFiles();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(files);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SelectServerFileDialog_JobError;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class LogViewer method getMoreData.
/**
* Get more data from server
*/
private void getMoreData() {
if (noData)
// we already know that there will be no more data
return;
new ConsoleJob(Messages.get().LogViewer_GetDataJob, this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected String getErrorMessage() {
return Messages.get().LogViewer_QueryError + logName;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Table data = logHandle.retrieveData(resultSet.getRowCount(), PAGE_SIZE);
runInUIThread(new Runnable() {
@Override
public void run() {
resultSet.addAll(data);
viewer.setInput(resultSet.getAllRows());
noData = (data.getRowCount() < PAGE_SIZE);
actionGetMoreData.setEnabled(!noData);
}
});
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ImageLibrary method editImage.
/**
* @param galleryItem
* @param name
* @param category
* @param fileName
*/
protected void editImage(final GalleryItem galleryItem, final String name, final String category, final String fileName) {
final LibraryImage image = (LibraryImage) galleryItem.getData();
new ConsoleJob(Messages.get().ImageLibrary_UpdateJob, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(final IProgressMonitor monitor) throws Exception {
if (fileName != null) {
verifyImageFile(fileName);
FileInputStream stream = null;
try {
final long fileSize = new File(fileName).length();
stream = new FileInputStream(fileName);
byte[] imageData = new byte[(int) fileSize];
stream.read(imageData);
image.setBinaryData(imageData);
} finally {
if (stream != null)
stream.close();
}
}
if (!image.isProtected()) {
image.setName(name);
image.setCategory(category);
}
session.modifyImage(image, new ProgressListener() {
private long prevDone = 0;
@Override
public void setTotalWorkAmount(long workTotal) {
monitor.beginTask(Messages.get(getDisplay()).ImageLibrary_UpdateImage, (int) workTotal);
}
@Override
public void markProgress(long workDone) {
monitor.worked((int) (workDone - prevDone));
prevDone = workDone;
}
});
ImageProvider.getInstance(display).syncMetaData();
refreshImages();
/* TODO: update single element */
monitor.done();
}
@Override
protected String getErrorMessage() {
return Messages.get().ImageLibrary_UpdateError;
}
}.start();
}
Aggregations