Search in sources :

Example 1 with PackageLabelProvider

use of org.netxms.ui.eclipse.agentmanager.views.helpers.PackageLabelProvider in project netxms by netxms.

the class PackageManager method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    final String[] names = { Messages.get().PackageManager_ColumnID, Messages.get().PackageManager_ColumnName, Messages.get().PackageManager_ColumnVersion, Messages.get().PackageManager_ColumnPlatform, Messages.get().PackageManager_ColumnFile, Messages.get().PackageManager_ColumnDescription };
    final int[] widths = { 70, 120, 90, 120, 150, 400 };
    viewer = new SortableTableViewer(parent, names, widths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new PackageLabelProvider());
    viewer.setComparator(new PackageComparator());
    createActions();
    contributeToActionBars();
    createPopupMenu();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            actionDeploy.setEnabled(selection.size() == 1);
            actionRemove.setEnabled(selection.size() > 0);
        }
    });
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().PackageManager_OpenDatabase, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            try {
                session.lockPackageDatabase();
            } catch (NXCException e) {
                // New versions may not require package DB lock
                if (e.getErrorCode() != RCC.NOT_IMPLEMENTED)
                    throw e;
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    refresh();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().PackageManager_OpenError;
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) PackageComparator(org.netxms.ui.eclipse.agentmanager.views.helpers.PackageComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PackageLabelProvider(org.netxms.ui.eclipse.agentmanager.views.helpers.PackageLabelProvider) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

IOException (java.io.IOException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 PackageComparator (org.netxms.ui.eclipse.agentmanager.views.helpers.PackageComparator)1 PackageLabelProvider (org.netxms.ui.eclipse.agentmanager.views.helpers.PackageLabelProvider)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1