use of org.netxms.client.objects.DashboardGroup in project netxms by netxms.
the class ObjectBrowser method registerActionValidators.
/**
* Register object action validators
*/
private void registerActionValidators() {
List<ActionValidatorData> list = new ArrayList<ActionValidatorData>();
// Read all registered extensions and create validators
final IExtensionRegistry reg = Platform.getExtensionRegistry();
// $NON-NLS-1$
IConfigurationElement[] elements = reg.getConfigurationElementsFor("org.netxms.ui.eclipse.objectbrowser.objectActionValidators");
for (int i = 0; i < elements.length; i++) {
try {
final ActionValidatorData v = new ActionValidatorData();
// $NON-NLS-1$
v.validator = (ObjectActionValidator) elements[i].createExecutableExtension("class");
// $NON-NLS-1$
v.priority = safeParseInt(elements[i].getAttribute("priority"));
list.add(v);
} catch (CoreException e) {
e.printStackTrace();
}
}
// Sort handlers by priority
Collections.sort(list, new Comparator<ActionValidatorData>() {
@Override
public int compare(ActionValidatorData arg0, ActionValidatorData arg1) {
return arg0.priority - arg1.priority;
}
});
actionValidators = new ObjectActionValidator[list.size() + 1];
int i = 0;
for (ActionValidatorData v : list) actionValidators[i++] = v.validator;
// Default validator
actionValidators[i] = new ObjectActionValidator() {
@Override
public int isValidSelectionForMove(SubtreeType subtree, AbstractObject currentObject, AbstractObject parentObject) {
switch(subtree) {
case INFRASTRUCTURE:
return ((currentObject instanceof Node) || (currentObject instanceof Cluster) || (currentObject instanceof Subnet) || (currentObject instanceof Condition) || (currentObject instanceof Rack) || (currentObject instanceof MobileDevice) || (currentObject instanceof Container) || (currentObject instanceof Sensor)) && ((parentObject instanceof Container) || (parentObject instanceof ServiceRoot)) ? APPROVE : REJECT;
case TEMPLATES:
return ((currentObject instanceof Template) || (currentObject instanceof TemplateGroup)) && ((parentObject instanceof TemplateGroup) || (parentObject instanceof TemplateRoot)) ? APPROVE : REJECT;
case BUSINESS_SERVICES:
return (currentObject instanceof BusinessService) && ((parentObject instanceof BusinessService) || (parentObject instanceof BusinessServiceRoot)) ? APPROVE : REJECT;
case MAPS:
return ((currentObject instanceof NetworkMap) || (currentObject instanceof NetworkMapGroup)) && ((parentObject instanceof NetworkMapGroup) || (parentObject instanceof NetworkMapRoot)) ? APPROVE : REJECT;
case DASHBOARDS:
return (((currentObject instanceof Dashboard) || (currentObject instanceof DashboardGroup)) && ((parentObject instanceof DashboardRoot) || (parentObject instanceof DashboardGroup) || (parentObject instanceof Dashboard))) ? APPROVE : REJECT;
case POLICIES:
return ((currentObject instanceof AgentPolicy) || (currentObject instanceof PolicyGroup)) && ((parentObject instanceof PolicyGroup) || (parentObject instanceof PolicyRoot)) ? APPROVE : REJECT;
default:
return REJECT;
}
}
};
}
use of org.netxms.client.objects.DashboardGroup in project netxms by netxms.
the class NXCSession method createObjectFromMessage.
/**
* Create object from message
*
* @param msg Source NXCP message
* @return NetXMS object
*/
private AbstractObject createObjectFromMessage(NXCPMessage msg) {
final int objectClass = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_CLASS);
AbstractObject object = createCustomObjectFromMessage(objectClass, msg);
if (object != null)
return object;
switch(objectClass) {
case AbstractObject.OBJECT_ACCESSPOINT:
object = new AccessPoint(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY:
object = new AgentPolicy(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
object = new AgentPolicyConfig(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
object = new AgentPolicyLogParser(msg, this);
break;
case AbstractObject.OBJECT_BUSINESSSERVICE:
object = new BusinessService(msg, this);
break;
case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
object = new BusinessServiceRoot(msg, this);
break;
case AbstractObject.OBJECT_CHASSIS:
object = new Chassis(msg, this);
break;
case AbstractObject.OBJECT_CLUSTER:
object = new Cluster(msg, this);
break;
case AbstractObject.OBJECT_CONDITION:
object = new Condition(msg, this);
break;
case AbstractObject.OBJECT_CONTAINER:
object = new Container(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARDGROUP:
object = new DashboardGroup(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARD:
object = new Dashboard(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARDROOT:
object = new DashboardRoot(msg, this);
break;
case AbstractObject.OBJECT_INTERFACE:
object = new Interface(msg, this);
break;
case AbstractObject.OBJECT_MOBILEDEVICE:
object = new MobileDevice(msg, this);
break;
case AbstractObject.OBJECT_NETWORK:
object = new EntireNetwork(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAP:
object = new NetworkMap(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAPGROUP:
object = new NetworkMapGroup(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAPROOT:
object = new NetworkMapRoot(msg, this);
break;
case AbstractObject.OBJECT_NETWORKSERVICE:
object = new NetworkService(msg, this);
break;
case AbstractObject.OBJECT_NODE:
object = new Node(msg, this);
break;
case AbstractObject.OBJECT_NODELINK:
object = new NodeLink(msg, this);
break;
case AbstractObject.OBJECT_POLICYGROUP:
object = new PolicyGroup(msg, this);
break;
case AbstractObject.OBJECT_POLICYROOT:
object = new PolicyRoot(msg, this);
break;
case AbstractObject.OBJECT_RACK:
object = new Rack(msg, this);
break;
case AbstractObject.OBJECT_SENSOR:
object = new Sensor(msg, this);
break;
case AbstractObject.OBJECT_SERVICEROOT:
object = new ServiceRoot(msg, this);
break;
case AbstractObject.OBJECT_SLMCHECK:
object = new ServiceCheck(msg, this);
break;
case AbstractObject.OBJECT_SUBNET:
object = new Subnet(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATE:
object = new Template(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATEGROUP:
object = new TemplateGroup(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATEROOT:
object = new TemplateRoot(msg, this);
break;
case AbstractObject.OBJECT_VPNCONNECTOR:
object = new VPNConnector(msg, this);
break;
case AbstractObject.OBJECT_ZONE:
object = new Zone(msg, this);
break;
default:
object = new GenericObject(msg, this);
break;
}
return object;
}
use of org.netxms.client.objects.DashboardGroup in project netxms by netxms.
the class ObjectTree method enableDropSupport.
/**
* Enable drop support in object tree
*/
public // SubtreeType infrastructure
void enableDropSupport(// SubtreeType infrastructure
final ObjectBrowser obj) {
final Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
objectTree.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new ViewerDropAdapter(objectTree) {
int operation = 0;
@Override
public boolean performDrop(Object data) {
TreeSelection selection = (TreeSelection) data;
List<?> movableSelection = selection.toList();
for (int i = 0; i < movableSelection.size(); i++) {
AbstractObject movableObject = (AbstractObject) movableSelection.get(i);
TreePath path = selection.getPaths()[0];
AbstractObject parent = (AbstractObject) path.getSegment(path.getSegmentCount() - 2);
obj.performObjectMove((AbstractObject) getCurrentTarget(), parent, movableObject, operation == DND.DROP_MOVE ? true : false);
}
return true;
}
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
this.operation = operation;
if ((target == null) || !LocalSelectionTransfer.getTransfer().isSupportedType(transferType))
return false;
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
if (selection.isEmpty())
return false;
for (final Object object : selection.toList()) {
SubtreeType subtree = null;
if ((object instanceof AbstractObject)) {
if (obj.isValidSelectionForMove(SubtreeType.INFRASTRUCTURE))
subtree = SubtreeType.INFRASTRUCTURE;
else if (obj.isValidSelectionForMove(SubtreeType.TEMPLATES))
subtree = SubtreeType.TEMPLATES;
else if (obj.isValidSelectionForMove(SubtreeType.BUSINESS_SERVICES))
subtree = SubtreeType.BUSINESS_SERVICES;
else if (obj.isValidSelectionForMove(SubtreeType.DASHBOARDS))
subtree = SubtreeType.DASHBOARDS;
else if (obj.isValidSelectionForMove(SubtreeType.MAPS))
subtree = SubtreeType.MAPS;
else if (obj.isValidSelectionForMove(SubtreeType.POLICIES))
subtree = SubtreeType.POLICIES;
}
if (subtree == null)
return false;
Set<Integer> filter;
switch(subtree) {
case INFRASTRUCTURE:
filter = ObjectSelectionDialog.createContainerSelectionFilter();
break;
case TEMPLATES:
filter = ObjectSelectionDialog.createTemplateGroupSelectionFilter();
break;
case BUSINESS_SERVICES:
filter = ObjectSelectionDialog.createBusinessServiceSelectionFilter();
break;
case DASHBOARDS:
if (object instanceof DashboardGroup)
filter = ObjectSelectionDialog.createDashboardGroupSelectionFilter();
else
filter = ObjectSelectionDialog.createDashboardSelectionFilter();
break;
case MAPS:
filter = ObjectSelectionDialog.createNetworkMapGroupsSelectionFilter();
break;
case POLICIES:
filter = ObjectSelectionDialog.createPolicyGroupSelectionFilter();
break;
default:
filter = null;
break;
}
if ((filter == null) || !filter.contains(((AbstractObject) target).getObjectClass()) || target.equals(object))
return false;
}
return true;
}
});
}
Aggregations