use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class DashboardView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
selectionProvider = new IntermediateSelectionProvider();
getSite().setSelectionProvider(selectionProvider);
ConsoleJob job = new ConsoleJob(Messages.get().DashboardView_GetEffectiveRights, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
readOnly = ((dashboard.getEffectiveRights() & UserAccessRights.OBJECT_ACCESS_MODIFY) == 0);
}
@Override
protected String getErrorMessage() {
return Messages.get().DashboardView_GetEffectiveRightsError;
}
};
job.start();
// FIXME: rewrite waiting
try {
job.join();
} catch (InterruptedException e) {
}
parentComposite = parent;
dbc = new DashboardControl(parent, SWT.NONE, dashboard, this, selectionProvider, false);
if (!readOnly) {
dbcModifyListener = new DashboardModifyListener() {
@Override
public void save() {
actionSave.setEnabled(false);
firePropertyChange(PROP_DIRTY);
}
@Override
public void modify() {
actionSave.setEnabled(true);
firePropertyChange(PROP_DIRTY);
}
};
dbc.setModifyListener(dbcModifyListener);
}
activateContext();
createActions();
contributeToActionBars();
clientListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED && dashboard.getObjectId() == n.getSubCode()) {
parentComposite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
rebuildDashboard(true);
}
});
}
}
};
session.addListener(clientListener);
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class EventMonitorElement method dispose.
@Override
public void dispose() {
ConsoleJob job = new ConsoleJob(String.format("Unsuscribing from channel ", NXCSession.CHANNEL_EVENTS), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.unsubscribe(NXCSession.CHANNEL_EVENTS);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot unsubscribe from channel ", NXCSession.CHANNEL_EVENTS);
}
};
job.setUser(false);
job.setSystem(true);
job.start();
super.dispose();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AlarmCategoryList method deleteCategory.
/**
* Delete alarm category
*/
private void deleteCategory() {
final IStructuredSelection selection = (IStructuredSelection) getSelection();
if (selection.isEmpty())
return;
final String message = (selection.size() == 1) ? "Do you really wish to delete the selected category?" : "Do you really wish to delete the selected categories?";
if (!MessageDialogHelper.openQuestion(getShell(), "Confirm category deletion", message))
return;
new ConsoleJob("Delete alarm category database entries", viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : selection.toList()) session.deleteAlarmCategory(((AlarmCategory) o).getId());
}
@Override
protected String getErrorMessage() {
return "Cannot delete alarm category database entry";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class UploadFileToAgent method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
boolean canScheduleFileUpload = (session.getUserSystemRights() & UserAccessRights.SYSTEM_ACCESS_SCHEDULE_FILE_UPLOAD) > 0;
final StartServerToAgentFileUploadDialog dlg = new StartServerToAgentFileUploadDialog(shell, canScheduleFileUpload);
if (dlg.open() == Window.OK) {
final Long[] nodeIdList = nodes.toArray(new Long[nodes.size()]);
new ConsoleJob(Messages.get().UploadFileToAgent_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().UploadFileToAgent_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
boolean multipleFiles = dlg.getServerFiles().size() > 1;
for (ServerFile sf : dlg.getServerFiles()) {
String remoteFileName = dlg.getRemoteFileName();
if (!remoteFileName.isEmpty()) {
if (// $NON-NLS-1$ //$NON-NLS-2$
remoteFileName.endsWith("/") || remoteFileName.endsWith("\\")) {
remoteFileName += sf.getName();
} else if (multipleFiles) {
remoteFileName += "/" + sf.getName();
}
} else {
if (!dlg.isScheduled())
remoteFileName = null;
}
for (int i = 0; i < nodeIdList.length; i++) {
if (dlg.isScheduled()) {
ScheduledTask task = dlg.getScheduledTask();
// $NON-NLS-1$
String parameters = sf.getName() + "," + remoteFileName;
task.setParameters(parameters);
task.setObjectId(nodeIdList[i]);
session.addSchedule(task);
} else {
session.uploadFileToAgent(nodeIdList[i], sf.getName(), remoteFileName, dlg.isCreateJobOnHold());
}
}
}
}
}.start();
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AgentFileManager 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++) {
final AgentFile sf = (AgentFile) objects[i];
session.deleteAgentFile(objectId, sf.getFullName());
runInUIThread(new Runnable() {
@Override
public void run() {
sf.getParent().removeChield(sf);
viewer.refresh(sf.getParent());
}
});
}
}
}.start();
}
Aggregations