Search in sources :

Example 56 with AbstractObject

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

the class MapLinkGeneral method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    object = (LinkEditor) getElement().getAdapter(LinkEditor.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    name = new LabeledText(dialogArea, SWT.NONE);
    name.setLabel(Messages.get().MapLinkGeneral_Name);
    name.setText(object.getName());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    name.setLayoutData(gd);
    connector1 = new LabeledText(dialogArea, SWT.NONE);
    connector1.setLabel(Messages.get().MapLinkGeneral_NameConn1);
    connector1.setText(object.getConnectorName1());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    connector1.setLayoutData(gd);
    connector2 = new LabeledText(dialogArea, SWT.NONE);
    connector2.setLabel(Messages.get().MapLinkGeneral_NameConn2);
    connector2.setText(object.getConnectorName2());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    connector2.setLayoutData(gd);
    final Group colorGroup = new Group(dialogArea, SWT.NONE);
    colorGroup.setText(Messages.get().MapLinkGeneral_Color);
    layout = new GridLayout();
    colorGroup.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    colorGroup.setLayoutData(gd);
    final SelectionListener listener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            color.setEnabled(radioColorCustom.getSelection());
            list.setEnabled(radioColorObject.getSelection());
            add.setEnabled(radioColorObject.getSelection());
            remove.setEnabled(radioColorObject.getSelection());
            checkUseThresholds.setEnabled(radioColorObject.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    };
    radioColorDefault = new Button(colorGroup, SWT.RADIO);
    radioColorDefault.setText(Messages.get().MapLinkGeneral_DefColor);
    radioColorDefault.setSelection((object.getColor() < 0) && (object.getStatusObject().size() == 0));
    radioColorDefault.addSelectionListener(listener);
    radioColorObject = new Button(colorGroup, SWT.RADIO);
    radioColorObject.setText(Messages.get().MapLinkGeneral_BasedOnObjStatus);
    radioColorObject.setSelection(object.getStatusObject().size() != 0);
    radioColorObject.addSelectionListener(listener);
    final Composite nodeSelectionGroup = new Composite(colorGroup, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    nodeSelectionGroup.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    nodeSelectionGroup.setLayoutData(gd);
    list = new List(nodeSelectionGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalSpan = 2;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    list.setLayoutData(gd);
    if (object.getStatusObject() != null) {
        for (int i = 0; i < object.getStatusObject().size(); i++) {
            final AbstractObject obj = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(object.getStatusObject().get(i));
            // $NON-NLS-1$ //$NON-NLS-2$
            list.add((obj != null) ? obj.getObjectName() : ("<" + Long.toString(object.getStatusObject().get(i)) + ">"));
        }
    }
    list.setEnabled(radioColorObject.getSelection());
    add = new Button(nodeSelectionGroup, SWT.PUSH);
    add.setText(Messages.get().MapLinkGeneral_Add);
    gd = new GridData();
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
    gd.verticalAlignment = SWT.TOP;
    add.setLayoutData(gd);
    add.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addObject();
        }
    });
    add.setEnabled(radioColorObject.getSelection());
    remove = new Button(nodeSelectionGroup, SWT.PUSH);
    remove.setText(Messages.get().MapLinkGeneral_Delete);
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
    gd.verticalAlignment = SWT.TOP;
    remove.setLayoutData(gd);
    remove.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeObject();
        }
    });
    remove.setEnabled(radioColorObject.getSelection());
    checkUseThresholds = new Button(nodeSelectionGroup, SWT.CHECK);
    checkUseThresholds.setText("Use active thresholds");
    checkUseThresholds.setEnabled(radioColorObject.getSelection());
    checkUseThresholds.setSelection(object.isUseActiveThresholds());
    gd = new GridData();
    gd.horizontalIndent = 17;
    checkUseThresholds.setLayoutData(gd);
    radioColorCustom = new Button(colorGroup, SWT.RADIO);
    radioColorCustom.setText(Messages.get().MapLinkGeneral_CustomColor);
    radioColorCustom.setSelection((object.getColor() >= 0) && (object.getStatusObject().size() == 0));
    radioColorCustom.addSelectionListener(listener);
    color = new ColorSelector(colorGroup);
    if (radioColorCustom.getSelection())
        color.setColorValue(ColorConverter.rgbFromInt(object.getColor()));
    else
        color.setEnabled(false);
    gd = new GridData();
    gd.horizontalIndent = 20;
    color.getButton().setLayoutData(gd);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    routingAlgorithm = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().MapLinkGeneral_RoutingAlg, gd);
    routingAlgorithm.add(Messages.get().MapLinkGeneral_MapDefault);
    routingAlgorithm.add(Messages.get().MapLinkGeneral_Direct);
    routingAlgorithm.add(Messages.get().MapLinkGeneral_Manhattan);
    routingAlgorithm.add(Messages.get().MapLinkGeneral_BendPoints);
    routingAlgorithm.select(object.getRoutingAlgorithm());
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) ColorSelector(org.eclipse.jface.preference.ColorSelector) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 57 with AbstractObject

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

the class IPNeighbors method addSubnets.

/**
 * Add subnets connected by given node
 *
 * @param root
 * @param rootElementId
 */
private void addSubnets(AbstractObject root, long rootElementId) {
    for (long objectId : root.getParentIdList()) {
        AbstractObject object = session.findObjectById(objectId);
        if ((object != null) && (object instanceof Subnet)) {
            long elementId = mapPage.createElementId();
            mapPage.addElement(new NetworkMapObject(elementId, objectId));
            mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, rootElementId, elementId));
            addNodesFromSubnet((Subnet) object, elementId, root.getObjectId());
        }
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Subnet(org.netxms.client.objects.Subnet) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 58 with AbstractObject

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

the class IPNeighbors method addNodesFromSubnet.

/**
 * Add nodes connected to given subnet to map
 * @param subnet Subnet object
 * @param rootNodeId ID of map's root node (used to prevent recursion)
 */
private void addNodesFromSubnet(Subnet subnet, long subnetElementId, long rootNodeId) {
    Iterator<Long> it = subnet.getChildren();
    while (it.hasNext()) {
        long objectId = it.next();
        if (objectId != rootNodeId) {
            AbstractObject object = session.findObjectById(objectId);
            if ((object != null) && (object instanceof Node)) {
                long elementId = mapPage.createElementId();
                mapPage.addElement(new NetworkMapObject(elementId, objectId));
                mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, subnetElementId, elementId));
            }
        }
    }
    addDciToRequestList();
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 59 with AbstractObject

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

the class ObjectBrowser method setSelection.

/**
 * Set selection in the tree and in object details view.
 *
 * @param objectId ID of object to be selected
 * @param tabId tab ID to be selected or null if tab selection not needed
 */
public void setSelection(long objectId, String tabId) {
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final AbstractObject object = session.findObjectById(objectId);
    if (object != null) {
        objectTree.getTreeViewer().setSelection(new StructuredSelection(object), true);
        // $NON-NLS-1$
        CommandBridge.getInstance().execute("TabbedObjectView/changeObject", objectId);
        if (tabId != null) {
            // $NON-NLS-1$
            CommandBridge.getInstance().execute("TabbedObjectView/selectTab", tabId);
        }
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 60 with AbstractObject

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

the class ObjectBrowser method isValidObjectForMove.

/**
 * Check if given selection object is valid for move
 *
 * @return true if current selection object is valid for moving object
 */
public boolean isValidObjectForMove(TreeItem[] selection, int i, SubtreeType subtree) {
    if (selection[i].getParentItem() == null)
        return false;
    final AbstractObject currentObject = (AbstractObject) selection[i].getData();
    final AbstractObject parentObject = (AbstractObject) selection[i].getParentItem().getData();
    for (ObjectActionValidator v : actionValidators) {
        int result = v.isValidSelectionForMove(subtree, currentObject, parentObject);
        if (result == ObjectActionValidator.APPROVE)
            return true;
        if (result == ObjectActionValidator.REJECT)
            return false;
    }
    return false;
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) ObjectActionValidator(org.netxms.ui.eclipse.objectbrowser.api.ObjectActionValidator)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)216 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)55 NXCSession (org.netxms.client.NXCSession)51 AbstractNode (org.netxms.client.objects.AbstractNode)31 PartInitException (org.eclipse.ui.PartInitException)27 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)25 Cluster (org.netxms.client.objects.Cluster)22 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)22 ArrayList (java.util.ArrayList)20 Node (org.netxms.client.objects.Node)20 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)18 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)18 GridLayout (org.eclipse.swt.layout.GridLayout)15 Container (org.netxms.client.objects.Container)15 Interface (org.netxms.client.objects.Interface)12 Template (org.netxms.client.objects.Template)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Point (org.eclipse.swt.graphics.Point)11