Search in sources :

Example 21 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class DashboardControl method addAvailabilityChart.

/**
 * Add availability chart widget to dashboard
 */
public void addAvailabilityChart() {
    DashboardElement e = new DashboardElement(DashboardElement.AVAILABLITY_CHART, DEFAULT_AVAILABILITY_CHART_CONFIG);
    addElement(e);
}
Also used : DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 22 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class DashboardControl method addBarChart.

/**
 * Add bar chart widget to dashboard
 */
public void addBarChart() {
    DashboardElement e = new DashboardElement(DashboardElement.BAR_CHART, DEFAULT_CHART_CONFIG);
    addElement(e);
}
Also used : DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 23 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class ImportDashboard method run.

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

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document dom = db.parse(dlg.getImportFile());
            Element root = dom.getDocumentElement();
            if (// $NON-NLS-1$
            !root.getNodeName().equals("dashboard"))
                throw new Exception(Messages.get().ImportDashboard_InvalidFile);
            root.normalize();
            List<DashboardElement> dashboardElements = new ArrayList<DashboardElement>();
            // $NON-NLS-1$
            NodeList elementsRoot = root.getElementsByTagName("elements");
            for (int i = 0; i < elementsRoot.getLength(); i++) {
                if (elementsRoot.item(i).getNodeType() != Node.ELEMENT_NODE)
                    continue;
                // $NON-NLS-1$
                NodeList elements = ((Element) elementsRoot.item(i)).getElementsByTagName("dashboardElement");
                for (int j = 0; j < elements.getLength(); j++) {
                    Element e = (Element) elements.item(j);
                    // $NON-NLS-1$ //$NON-NLS-2$
                    DashboardElement de = new DashboardElement(getNodeValueAsInt(e, "type", 0), getNodeValueAsXml(e, "element"));
                    // $NON-NLS-1$
                    de.setLayout(getNodeValueAsXml(e, "layout"));
                    dashboardElements.add(de);
                }
            }
            root.normalize();
            objectName = dlg.getObjectName();
            if (doIdMapping(display, session, dashboardElements, root)) {
                NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, objectName, parentId);
                final long objectId = session.createObject(cd);
                NXCObjectModificationData md = new NXCObjectModificationData(objectId);
                // $NON-NLS-1$
                md.setColumnCount(getNodeValueAsInt(root, "columns", 1));
                // $NON-NLS-1$
                md.setObjectFlags(getNodeValueAsInt(root, "options", 0));
                md.setDashboardElements(dashboardElements);
                session.modifyObject(md);
            }
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().ImportDashboard_Error, dlg.getObjectName());
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) DashboardElement(org.netxms.client.dashboards.DashboardElement) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) DashboardElement(org.netxms.client.dashboards.DashboardElement) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DocumentBuilder(javax.xml.parsers.DocumentBuilder) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ImportDashboardDialog(org.netxms.ui.eclipse.dashboard.dialogs.ImportDashboardDialog) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Display(org.eclipse.swt.widgets.Display)

Aggregations

DashboardElement (org.netxms.client.dashboards.DashboardElement)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 NXCSession (org.netxms.client.NXCSession)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 DashboardElementConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1