use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class IdMatchingDialog method mapNode.
/**
* Map node
*
* @param data
*/
private void mapNode(ObjectIdMatchingData data) {
Set<Integer> classFilter;
switch(data.objectClass) {
case AbstractObject.OBJECT_NODE:
case AbstractObject.OBJECT_CLUSTER:
classFilter = ObjectSelectionDialog.createNodeSelectionFilter(false);
showFilterToolTip = true;
break;
case AbstractObject.OBJECT_CONTAINER:
classFilter = ObjectSelectionDialog.createContainerSelectionFilter();
showFilterToolTip = false;
break;
case AbstractObject.OBJECT_ZONE:
classFilter = ObjectSelectionDialog.createZoneSelectionFilter();
showFilterToolTip = true;
break;
case AbstractObject.OBJECT_DASHBOARD:
classFilter = new HashSet<Integer>(2);
classFilter.add(AbstractObject.OBJECT_DASHBOARD);
classFilter.add(AbstractObject.OBJECT_DASHBOARDROOT);
break;
default:
classFilter = null;
break;
}
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, classFilter);
dlg.showFilterToolTip(showFilterToolTip);
if (dlg.open() == Window.OK) {
AbstractObject object = dlg.getSelectedObjects().get(0);
if (ImportDashboard.isCompatibleClasses(object.getObjectClass(), data.objectClass)) {
data.dstId = object.getObjectId();
data.dstName = object.getObjectName();
updateDciMapping(data);
viewer.update(data, null);
} else {
MessageDialogHelper.openWarning(getShell(), Messages.get().IdMatchingDialog_Warning, Messages.get().IdMatchingDialog_ClassMismatch);
}
}
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class TableColumns method queryColumns.
/**
* Query columns from agent
*/
private void queryColumns() {
if (!MessageDialogHelper.openQuestion(getShell(), "Warning", "Current column definition will be replaced by definition provided by agent. Continue?"))
return;
AbstractObject object = ConsoleSharedData.getSession().findObjectById(dci.getNodeId());
if ((editor.getSourceNode() == 0) && ((object instanceof Template) || (object instanceof Cluster))) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
if (dlg.open() != Window.OK)
return;
object = dlg.getSelectedObjects().get(0);
}
updateColumnsFromAgent(dci.getName(), true, object);
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog 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.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class PackageManager method deployPackage.
/**
* Deploy package on managed nodes
*/
private void deployPackage() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() != Window.OK)
return;
final Set<Long> objects = new HashSet<Long>();
for (AbstractObject o : dlg.getSelectedObjects()) {
objects.add(o.getObjectId());
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {
private PackageDeploymentMonitor monitor = null;
@Override
public void statusUpdate(long nodeId, int status, String message) {
if (monitor != null)
monitor.viewStatusUpdate(nodeId, status, message);
}
@Override
public void deploymentStarted() {
final Object sync = new Object();
synchronized (sync) {
runInUIThread(new Runnable() {
@Override
public void run() {
try {
monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
monitor.setPackageId(pkg.getId());
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
}
synchronized (sync) {
sync.notify();
}
}
});
try {
sync.wait();
} catch (InterruptedException e) {
}
}
}
@Override
public void deploymentComplete() {
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
}
});
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DepStartError;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class ObjectConditionEditor method selectObject.
/**
* Select object
*/
private void selectObject() {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, null);
dlg.enableMultiSelection(false);
if (dlg.open() == Window.OK) {
AbstractObject[] objects = dlg.getSelectedObjects(AbstractObject.class);
if (objects.length > 0) {
objectId = objects[0].getObjectId();
objectName.setText(objects[0].getObjectName());
objectName.setImage(labelProvider.getImage(objects[0]));
} else {
objectId = 0;
objectName.setText(EMPTY_SELECTION_TEXT);
objectName.setImage(null);
}
}
}
Aggregations