Search in sources :

Example 1 with NetworkMap

use of org.netxms.client.objects.NetworkMap 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;
            }
        }
    };
}
Also used : TemplateRoot(org.netxms.client.objects.TemplateRoot) DashboardGroup(org.netxms.client.objects.DashboardGroup) Node(org.netxms.client.objects.Node) DashboardRoot(org.netxms.client.objects.DashboardRoot) ArrayList(java.util.ArrayList) NetworkMapGroup(org.netxms.client.objects.NetworkMapGroup) Dashboard(org.netxms.client.objects.Dashboard) Template(org.netxms.client.objects.Template) SubtreeType(org.netxms.ui.eclipse.objectbrowser.api.SubtreeType) Rack(org.netxms.client.objects.Rack) Container(org.netxms.client.objects.Container) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) MobileDevice(org.netxms.client.objects.MobileDevice) TemplateGroup(org.netxms.client.objects.TemplateGroup) PolicyRoot(org.netxms.client.objects.PolicyRoot) ObjectActionValidator(org.netxms.ui.eclipse.objectbrowser.api.ObjectActionValidator) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) Condition(org.netxms.client.objects.Condition) PolicyGroup(org.netxms.client.objects.PolicyGroup) Cluster(org.netxms.client.objects.Cluster) NetworkMapRoot(org.netxms.client.objects.NetworkMapRoot) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ServiceRoot(org.netxms.client.objects.ServiceRoot) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) BusinessService(org.netxms.client.objects.BusinessService) AgentPolicy(org.netxms.client.objects.AgentPolicy) CoreException(org.eclipse.core.runtime.CoreException) AbstractObject(org.netxms.client.objects.AbstractObject) Subnet(org.netxms.client.objects.Subnet) NetworkMap(org.netxms.client.objects.NetworkMap) Sensor(org.netxms.client.objects.Sensor)

Example 2 with NetworkMap

use of org.netxms.client.objects.NetworkMap in project netxms by netxms.

the class MapSeedNodes method createContents.

/* (non-Javadoc)
    * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    if (object == null || !(object instanceof NetworkMap))
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    viewer = new TableViewer(dialogArea, SWT.BORDER);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        /* (non-Javadoc)
          * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
          */
        @Override
        public String getText(Object element) {
            return ((AbstractObject) element).getObjectName();
        }
    });
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    seedNodes = new HashSet<AbstractObject>(session.findMultipleObjects(((NetworkMap) object).getSeedObjectIds(), false));
    viewer.setInput(seedNodes);
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText("Add...");
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
            dlg.enableMultiSelection(true);
            if (dlg.open() == Window.OK) {
                List<AbstractObject> selected = dlg.getSelectedObjects();
                if (selected.size() > 0) {
                    seedNodes.addAll(selected);
                    viewer.setInput(seedNodes);
                    isModified = true;
                }
            }
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText("Delete");
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (selection.size() > 0) {
                seedNodes.removeAll(selection.toList());
                viewer.setInput(seedNodes);
                isModified = true;
            }
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    return dialogArea;
}
Also used : NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) List(java.util.List) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) NetworkMap(org.netxms.client.objects.NetworkMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with NetworkMap

use of org.netxms.client.objects.NetworkMap in project netxms by netxms.

the class MapAppearance method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    if (// Paranoid check
    object == null)
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    // Image
    image = new ImageSelector(dialogArea, SWT.NONE);
    image.setLabel(Messages.get().MapAppearance_Image);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    image.setLayoutData(gd);
    image.setImageGuid(object.getImage(), false);
    // Submap
    if (!(object instanceof NetworkMap)) {
        drillDownObject = new ObjectSelector(dialogArea, SWT.NONE, true);
        drillDownObject.setLabel("Drill-down object");
        drillDownObject.setObjectClass(AbstractObject.class);
        drillDownObject.setObjectId(object.getDrillDownObjectId());
        drillDownObject.setClassFilter(ObjectSelectionDialog.createDashboardAndNetworkMapSelectionFilter());
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        drillDownObject.setLayoutData(gd);
    }
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ImageSelector(org.netxms.ui.eclipse.imagelibrary.widgets.ImageSelector) NetworkMap(org.netxms.client.objects.NetworkMap)

Example 4 with NetworkMap

use of org.netxms.client.objects.NetworkMap 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;
}
Also used : Chassis(org.netxms.client.objects.Chassis) DashboardGroup(org.netxms.client.objects.DashboardGroup) ServiceCheck(org.netxms.client.objects.ServiceCheck) TemplateRoot(org.netxms.client.objects.TemplateRoot) DashboardRoot(org.netxms.client.objects.DashboardRoot) AbstractNode(org.netxms.client.objects.AbstractNode) Node(org.netxms.client.objects.Node) NetworkMapGroup(org.netxms.client.objects.NetworkMapGroup) Dashboard(org.netxms.client.objects.Dashboard) AgentPolicyConfig(org.netxms.client.objects.AgentPolicyConfig) Template(org.netxms.client.objects.Template) Rack(org.netxms.client.objects.Rack) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) Container(org.netxms.client.objects.Container) MobileDevice(org.netxms.client.objects.MobileDevice) TemplateGroup(org.netxms.client.objects.TemplateGroup) PolicyRoot(org.netxms.client.objects.PolicyRoot) Condition(org.netxms.client.objects.Condition) PolicyGroup(org.netxms.client.objects.PolicyGroup) Zone(org.netxms.client.objects.Zone) AccessPoint(org.netxms.client.objects.AccessPoint) VPNConnector(org.netxms.client.objects.VPNConnector) Cluster(org.netxms.client.objects.Cluster) NetworkMapRoot(org.netxms.client.objects.NetworkMapRoot) EntireNetwork(org.netxms.client.objects.EntireNetwork) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) ServiceRoot(org.netxms.client.objects.ServiceRoot) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) BusinessService(org.netxms.client.objects.BusinessService) AgentPolicy(org.netxms.client.objects.AgentPolicy) AbstractObject(org.netxms.client.objects.AbstractObject) GenericObject(org.netxms.client.objects.GenericObject) AgentPolicyLogParser(org.netxms.client.objects.AgentPolicyLogParser) NetworkService(org.netxms.client.objects.NetworkService) NodeLink(org.netxms.client.objects.NodeLink) Subnet(org.netxms.client.objects.Subnet) Interface(org.netxms.client.objects.Interface) NetworkMap(org.netxms.client.objects.NetworkMap) Sensor(org.netxms.client.objects.Sensor)

Example 5 with NetworkMap

use of org.netxms.client.objects.NetworkMap in project netxms by netxms.

the class AbstractNetworkMapView method openDrillDownObject.

/**
 * Open drill-down object for currently selected object
 */
private void openDrillDownObject() {
    if (currentSelection == null)
        return;
    long objectId = 0;
    Object object = currentSelection.getFirstElement();
    if (object instanceof AbstractObject)
        objectId = (object instanceof NetworkMap) ? ((AbstractObject) object).getObjectId() : ((AbstractObject) object).getDrillDownObjectId();
    else if (object instanceof NetworkMapTextBox)
        objectId = ((NetworkMapTextBox) object).getDrillDownObjectId();
    if (objectId != 0) {
        Object test = session.findObjectById(objectId);
        if (test instanceof NetworkMap) {
            try {
                getSite().getPage().showView(PredefinedMap.ID, Long.toString(objectId), IWorkbenchPage.VIEW_ACTIVATE);
            } catch (PartInitException e) {
                MessageDialogHelper.openError(getSite().getShell(), Messages.get().AbstractNetworkMapView_Error, String.format("Cannot open drill-down object view: %s", e.getMessage()));
            }
        }
        if (test instanceof Dashboard) {
            try {
                getSite().getPage().showView("org.netxms.ui.eclipse.dashboard.views.DashboardView", Long.toString(objectId), IWorkbenchPage.VIEW_ACTIVATE);
            } catch (PartInitException e) {
                MessageDialogHelper.openError(getSite().getShell(), Messages.get().AbstractNetworkMapView_Error, String.format("Cannot open drill-down object view: %s", e.getMessage()));
            }
        }
    }
}
Also used : NetworkMapTextBox(org.netxms.client.maps.elements.NetworkMapTextBox) AbstractObject(org.netxms.client.objects.AbstractObject) Dashboard(org.netxms.client.objects.Dashboard) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) AbstractObject(org.netxms.client.objects.AbstractObject) PartInitException(org.eclipse.ui.PartInitException) NetworkMap(org.netxms.client.objects.NetworkMap)

Aggregations

NetworkMap (org.netxms.client.objects.NetworkMap)7 AbstractObject (org.netxms.client.objects.AbstractObject)5 Dashboard (org.netxms.client.objects.Dashboard)4 ArrayList (java.util.ArrayList)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 PartInitException (org.eclipse.ui.PartInitException)2 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)2 AgentPolicy (org.netxms.client.objects.AgentPolicy)2 BusinessService (org.netxms.client.objects.BusinessService)2 BusinessServiceRoot (org.netxms.client.objects.BusinessServiceRoot)2 Cluster (org.netxms.client.objects.Cluster)2 Condition (org.netxms.client.objects.Condition)2 Container (org.netxms.client.objects.Container)2 DashboardGroup (org.netxms.client.objects.DashboardGroup)2 DashboardRoot (org.netxms.client.objects.DashboardRoot)2 MobileDevice (org.netxms.client.objects.MobileDevice)2 NetworkMapGroup (org.netxms.client.objects.NetworkMapGroup)2 NetworkMapRoot (org.netxms.client.objects.NetworkMapRoot)2