use of org.netxms.ui.eclipse.objectmanager.dialogs.MaintanenceScheduleDialog in project netxms by netxms.
the class ScheduleMaintenance method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
final MaintanenceScheduleDialog dialog = new MaintanenceScheduleDialog(window.getShell());
if (dialog.open() != Window.OK)
return null;
final Object[] objects = ((IStructuredSelection) selection).toArray();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : objects) {
if (o instanceof AbstractObject) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskStart = new ScheduledTask("Maintenance.Enter", "", "", "", dialog.getStartDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskEnd = new ScheduledTask("Maintenance.Leave", "", "", "", dialog.getEndDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
session.addSchedule(taskStart);
session.addSchedule(taskEnd);
}
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SetObjectManagementState_JobError;
}
}.start();
return null;
}
Aggregations