Search in sources :

Example 51 with NXCSession

use of org.netxms.client.NXCSession 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 52 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class MapOptions method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    int flags = 0;
    if ((checkIncludeEndNodes != null) && checkIncludeEndNodes.getSelection())
        flags |= NetworkMap.MF_SHOW_END_NODES;
    if (checkShowStatusIcon.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_ICON;
    if (checkShowStatusFrame.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_FRAME;
    if (checkShowStatusBkgnd.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_BKGND;
    if (checkCalculateStatus.getSelection())
        flags |= NetworkMap.MF_CALCULATE_STATUS;
    if (checkShowLinkDirection.getSelection())
        flags |= NetworkMap.MF_SHOW_LINK_DIRECTION;
    md.setObjectFlags(flags, 0x5F);
    md.setMapObjectDisplayMode(MapObjectDisplayMode.getByValue(objectDisplayMode.getSelectionIndex()));
    md.setConnectionRouting(routingAlgorithm.getSelectionIndex() + 1);
    if (radioColorCustom.getSelection()) {
        md.setLinkColor(ColorConverter.rgbToInt(linkColor.getColorValue()));
    } else {
        md.setLinkColor(-1);
    }
    if (checkCustomRadius != null) {
        if (checkCustomRadius.getSelection())
            md.setDiscoveryRadius(topologyRadius.getSelection());
        else
            md.setDiscoveryRadius(-1);
    }
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().MapOptions_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().MapOptions_JobError + object.getObjectName();
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        MapOptions.this.setValid(true);
                    }
                });
            }
        }
    }.start();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 53 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class CloneNetworkMap method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    if (source == null)
        return;
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CloneNetworkMap_NetworkMap);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateNetworkMap_JobName, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NETWORKMAP, dlg.getObjectName(), source.getParentIdList()[0]);
            NXCObjectModificationData md = new NXCObjectModificationData(0);
            source.prepareCopy(cd, md);
            long id = session.createObject(cd);
            md.setObjectId(id);
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateNetworkMap_JobError, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 54 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class DashboardPage method createContent.

/* (non-Javadoc)
    * @see org.netxms.webui.mobile.pages.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Composite createContent(Composite parent) {
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    Dashboard dashboard = (Dashboard) session.findObjectById(objectId, Dashboard.class);
    if (dashboard != null) {
        DashboardControl dbc = new DashboardControl(parent, SWT.NONE, dashboard, null, false);
        setTitle(dashboard.getObjectName());
        return dbc;
    } else {
        setTitle("[" + objectId + "]");
        return new Composite(parent, SWT.NONE);
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl) Dashboard(org.netxms.client.objects.Dashboard)

Example 55 with NXCSession

use of org.netxms.client.NXCSession 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)

Aggregations

NXCSession (org.netxms.client.NXCSession)248 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)167 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)163 AbstractObject (org.netxms.client.objects.AbstractObject)54 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)45 PartInitException (org.eclipse.ui.PartInitException)31 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 List (java.util.List)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 NXCException (org.netxms.client.NXCException)22 ArrayList (java.util.ArrayList)19 GridData (org.eclipse.swt.layout.GridData)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)17 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)15 AbstractNode (org.netxms.client.objects.AbstractNode)14 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 IOException (java.io.IOException)11 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10