Search in sources :

Example 6 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.

the class DataSources method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (ChartConfig) getElement().getAdapter(ChartConfig.class);
    if (config instanceof GraphSettings)
        graphIsTemplate = ((GraphSettings) config).isTemplate();
    Composite dialogArea = new Composite(parent, SWT.NONE);
    dciList = new ArrayList<ChartDciConfig>();
    for (ChartDciConfig dci : config.getDciList()) dciList.add(new ChartDciConfig(dci));
    labelProvider = new DciListLabelProvider(dciList);
    labelProvider.resolveDciNames(dciList);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().DataSources_ColPosition, Messages.get().DataSources_ColNode, Messages.get().DataSources_ColParameter, Messages.get().DataSources_ColLabel, Messages.get().DataSources_ColColor };
    final int[] columnWidths = { 40, 130, 200, 150, 50 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(labelProvider);
    viewer.disableSorting();
    viewer.setInput(dciList.toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    gridData.horizontalSpan = 2;
    viewer.getControl().setLayoutData(gridData);
    /* buttons on left side */
    Composite leftButtons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginLeft = 0;
    leftButtons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.LEFT;
    leftButtons.setLayoutData(gridData);
    upButton = new Button(leftButtons, SWT.PUSH);
    upButton.setText(Messages.get().DataSources_Up);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    upButton.setLayoutData(rd);
    upButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    upButton.setEnabled(false);
    downButton = new Button(leftButtons, SWT.PUSH);
    downButton.setText(Messages.get().DataSources_Down);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    downButton.setLayoutData(rd);
    downButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    downButton.setEnabled(false);
    /* buttons on right side */
    Composite rightButtons = new Composite(dialogArea, SWT.NONE);
    buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    rightButtons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    rightButtons.setLayoutData(gridData);
    addButton = new Button(rightButtons, SWT.PUSH);
    addButton.setText(Messages.get().DataSources_Add);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            addItem();
        }
    });
    editButton = new Button(rightButtons, SWT.PUSH);
    editButton.setText(Messages.get().DataSources_Modify);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    editButton.setLayoutData(rd);
    editButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            editItem();
        }
    });
    editButton.setEnabled(false);
    deleteButton = new Button(rightButtons, SWT.PUSH);
    deleteButton.setText(Messages.get().DataSources_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteItems();
        }
    });
    deleteButton.setEnabled(false);
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editButton.notifyListeners(SWT.Selection, new Event());
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            editButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
            upButton.setEnabled(selection.size() == 1);
            downButton.setEnabled(selection.size() == 1);
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) GraphSettings(org.netxms.client.datacollection.GraphSettings) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DciListLabelProvider(org.netxms.ui.eclipse.perfview.propertypages.helpers.DciListLabelProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 7 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.

the class DataSources method addItem.

/**
 * Add new item
 */
private void addItem() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
    if (dlg.open() == Window.OK) {
        List<DciValue> selection = dlg.getSelection();
        List<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        for (DciValue item : selection) {
            ChartDciConfig dci = new ChartDciConfig(item);
            labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
            select.add(dci);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) DciValue(org.netxms.client.datacollection.DciValue) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)

Example 8 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.

the class TemplateDataSources method importItem.

/**
 * Import new item
 */
private void importItem() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
    if (dlg.open() == Window.OK) {
        List<DciValue> selection = dlg.getSelection();
        List<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        for (DciValue item : selection) {
            ChartDciConfig dci = new ChartDciConfig(item);
            select.add(dci);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) DciValue(org.netxms.client.datacollection.DciValue) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)

Example 9 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.

the class TemplateDataSources method addItem.

/**
 * Add new item
 */
private void addItem() {
    ChartDciConfig dci = new ChartDciConfig();
    DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, true);
    if (dlg.open() == Window.OK) {
        List<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        select.add(dci);
        select.add(dci);
        dciList.add(dci);
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : DataSourceEditDlg(org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 10 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.

the class TemplateDataSources method editItem.

/**
 * Edit selected item
 */
private void editItem() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    ChartDciConfig dci = (ChartDciConfig) selection.getFirstElement();
    if (dci == null)
        return;
    DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, true);
    if (dlg.open() == Window.OK) {
        viewer.update(dci, null);
    }
}
Also used : DataSourceEditDlg(org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 ArrayList (java.util.ArrayList)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 GraphSettings (org.netxms.client.datacollection.GraphSettings)4 DataSourceEditDlg (org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg)4 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)4 Date (java.util.Date)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)3 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 Color (org.eclipse.swt.graphics.Color)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowData (org.eclipse.swt.layout.RowData)3