use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SummaryTableGeneral method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (isApply)
setValid(false);
table.setMenuPath(menuPath.getText());
table.setTitle(title.getText());
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SummaryTableGeneral_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
synchronized (table) {
int id = session.modifyDciSummaryTable(table);
table.setId(id);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableGeneral_JobError;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
*/
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
SummaryTableGeneral.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class DataCollectionEditor method copyItems.
/**
* Copy items to another node
*/
private void copyItems(final boolean doMove) {
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeAndTemplateSelectionFilter(true));
if (dlg.open() != Window.OK)
return;
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<?> it = selection.iterator();
final long[] dciList = new long[selection.size()];
for (int i = 0; (i < dciList.length) && it.hasNext(); i++) dciList[i] = ((DataCollectionObject) it.next()).getId();
new ConsoleJob(Messages.get().DataCollectionEditor_CopyJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (AbstractObject o : dlg.getSelectedObjects(AbstractNode.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
for (AbstractObject o : dlg.getSelectedObjects(Template.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
for (AbstractObject o : dlg.getSelectedObjects(Cluster.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
for (AbstractObject o : dlg.getSelectedObjects(MobileDevice.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
for (AbstractObject o : dlg.getSelectedObjects(Sensor.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
if (doMove) {
for (long id : dciList) dciConfig.deleteObject(id);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(dciConfig.getItems());
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().DataCollectionEditor_CopyJob_Error + object.getObjectName();
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class DataCollectionEditor method deleteItems.
/**
* Delete currently selected DCIs
*/
private void deleteItems() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() <= 0)
return;
if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().DataCollectionEditor_DeleteConfirmTitle, Messages.get().DataCollectionEditor_DeleteConfirmText))
return;
new ConsoleJob(Messages.get().DataCollectionEditor_DeleteJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object dci : selection.toList()) {
dciConfig.deleteObject(((DataCollectionObject) dci).getId());
}
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(dciConfig.getItems());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().DataCollectionEditor_DeleteJob_Error + object.getObjectName();
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class DataCollectionEditor method setItemStatus.
/**
* Change status for selected items
*
* @param newStatus New status
*/
private void setItemStatus(final int newStatus) {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() <= 0)
return;
new ConsoleJob(Messages.get().DataCollectionEditor_ChStatusJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final long[] itemList = new long[selection.size()];
int pos = 0;
for (Object dci : selection.toList()) {
itemList[pos++] = ((DataCollectionObject) dci).getId();
}
dciConfig.setObjectStatus(itemList, newStatus);
runInUIThread(new Runnable() {
@Override
public void run() {
for (Object dci : selection.toList()) {
((DataCollectionObject) dci).setStatus(newStatus);
viewer.update(dci, null);
new DataCollectionObjectEditor((DataCollectionObject) dci).modify();
}
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().DataCollectionEditor_ChStatusJob_Error + object.getObjectName();
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class PackageManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final String[] names = { Messages.get().PackageManager_ColumnID, Messages.get().PackageManager_ColumnName, Messages.get().PackageManager_ColumnVersion, Messages.get().PackageManager_ColumnPlatform, Messages.get().PackageManager_ColumnFile, Messages.get().PackageManager_ColumnDescription };
final int[] widths = { 70, 120, 90, 120, 150, 400 };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PackageLabelProvider());
viewer.setComparator(new PackageComparator());
createActions();
contributeToActionBars();
createPopupMenu();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
actionDeploy.setEnabled(selection.size() == 1);
actionRemove.setEnabled(selection.size() > 0);
}
});
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().PackageManager_OpenDatabase, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
session.lockPackageDatabase();
} catch (NXCException e) {
// New versions may not require package DB lock
if (e.getErrorCode() != RCC.NOT_IMPLEMENTED)
throw e;
}
runInUIThread(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_OpenError;
}
}.start();
}
Aggregations