Search in sources :

Example 11 with DciSummaryTableDescriptor

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

the class SummaryTableManager method createSummaryTable.

/**
 * Create new loyalty program
 */
private void createSummaryTable(boolean isTableSource) {
    // $NON-NLS-1$ //$NON-NLS-2$
    DciSummaryTable t = new DciSummaryTable("", "", isTableSource);
    PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
    if (dlg != null) {
        dlg.getShell().setText(Messages.get().SummaryTableManager_TitleCreate);
        dlg.open();
        if (t.getId() != 0) {
            // was saved to server
            DciSummaryTableDescriptor d = new DciSummaryTableDescriptor(t);
            descriptors.put(d.getId(), d);
            viewer.setInput(descriptors.values().toArray());
            viewer.setSelection(new StructuredSelection(d));
        }
    }
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 12 with DciSummaryTableDescriptor

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

the class SummaryTablesCache method reload.

/**
 * Reload tables from server
 */
private void reload() {
    try {
        List<DciSummaryTableDescriptor> list = session.listDciSummaryTables();
        synchronized (tables) {
            tables.clear();
            for (DciSummaryTableDescriptor d : list) {
                tables.put(d.getId(), d);
            }
        }
        SourceProvider p = SourceProvider.getInstance(display);
        if (p != null) {
            p.update();
        }
    } catch (Exception e) {
        Activator.logError("Exception in SummaryTablesCache.reload()", e);
    }
}
Also used : SourceProvider(org.netxms.ui.eclipse.datacollection.SourceProvider) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 13 with DciSummaryTableDescriptor

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

the class SelectSummaryTableDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    dialogArea.setLayout(layout);
    new Label(dialogArea, SWT.NONE).setText(Messages.get().SelectSummaryTableDialog_Label);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DciSummaryTableDescriptor) element).getTitle();
        }
    });
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            DciSummaryTableDescriptor s1 = (DciSummaryTableDescriptor) e1;
            DciSummaryTableDescriptor s2 = (DciSummaryTableDescriptor) e2;
            return s1.getTitle().compareToIgnoreCase(s2.getTitle());
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            SelectSummaryTableDialog.this.okPressed();
        }
    });
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 300;
    gd.widthHint = 400;
    viewer.getControl().setLayoutData(gd);
    viewer.setInput(SummaryTablesCache.getInstance().getTables());
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

DciSummaryTableDescriptor (org.netxms.client.datacollection.DciSummaryTableDescriptor)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)3 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 UUID (java.util.UUID)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1