Search in sources :

Example 1 with ActionLabelProvider

use of org.netxms.ui.eclipse.actionmanager.views.helpers.ActionLabelProvider in project netxms by netxms.

the class ExportFileBuilder method createActionsSection.

/**
 * Create "Actions" section
 */
private void createActionsSection() {
    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Actions");
    TableWrapData td = new TableWrapData();
    td.align = TableWrapData.FILL;
    td.grabHorizontal = true;
    section.setLayoutData(td);
    Composite clientArea = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    section.setClient(clientArea);
    actionViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    toolkit.adapt(ruleViewer.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 200;
    gd.verticalSpan = 2;
    actionViewer.getTable().setLayoutData(gd);
    actionViewer.setContentProvider(new ArrayContentProvider());
    actionViewer.setLabelProvider(new ActionLabelProvider());
    actionViewer.setComparator(new ActionComparator());
    actionViewer.getTable().setSortDirection(SWT.UP);
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().ExportFileBuilder_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            addActions();
        }
    });
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
    linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkRemove.setLayoutData(gd);
    linkRemove.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeObjects(actionViewer, actions);
        }
    });
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ActionComparator(org.netxms.ui.eclipse.actionmanager.views.helpers.ActionComparator) Section(org.eclipse.ui.forms.widgets.Section) ActionLabelProvider(org.netxms.ui.eclipse.actionmanager.views.helpers.ActionLabelProvider) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 2 with ActionLabelProvider

use of org.netxms.ui.eclipse.actionmanager.views.helpers.ActionLabelProvider in project netxms by netxms.

the class ActionManager method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    parent.setLayout(new FillLayout());
    final String[] columnNames = { Messages.get().ActionManager_ColumnName, Messages.get().ActionManager_ColumnType, Messages.get().ActionManager_ColumnRcpt, Messages.get().ActionManager_ColumnSubj, Messages.get().ActionManager_ColumnData };
    final int[] columnWidths = { 150, 90, 100, 120, 200 };
    viewer = new SortableTableViewer(parent, columnNames, columnWidths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ActionLabelProvider());
    viewer.setComparator(new ActionComparator());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionEdit.setEnabled(selection.size() == 1);
                actionDelete.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            actionEdit.run();
        }
    });
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    session.addListener(this);
    refreshActionList();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) ActionComparator(org.netxms.ui.eclipse.actionmanager.views.helpers.ActionComparator) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ActionLabelProvider(org.netxms.ui.eclipse.actionmanager.views.helpers.ActionLabelProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ActionComparator (org.netxms.ui.eclipse.actionmanager.views.helpers.ActionComparator)2 ActionLabelProvider (org.netxms.ui.eclipse.actionmanager.views.helpers.ActionLabelProvider)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)1 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)1 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)1 Section (org.eclipse.ui.forms.widgets.Section)1 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)1