Search in sources :

Example 1 with AgentFileComparator

use of org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileComparator in project netxms by netxms.

the class AgentFileManager method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    content.setLayout(new FormLayout());
    // Create filter area
    filterText = new FilterText(content, SWT.NONE);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    // $NON-NLS-1$
    String os = ((Node) session.findObjectById(objectId)).getSystemDescription();
    if (// if OS is windows don't show group and access rights columns //$NON-NLS-1$
    os.contains("Windows")) {
        final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner };
        final int[] columnWidths = { 300, 120, 150, 150, 150 };
        viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    } else {
        final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner, Messages.get().AgentFileManager_ColGroup, Messages.get().AgentFileManager_ColAccessRights };
        final int[] columnWidths = { 300, 120, 150, 150, 150, 150, 200 };
        viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    }
    WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new ViewAgentFilesProvider());
    viewer.setLabelProvider(new AgentFileLabelProvider());
    viewer.setComparator(new AgentFileComparator());
    filter = new AgentFileFilter();
    viewer.addFilter(filter);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionDelete.setEnabled(selection.size() > 0);
                actionCalculateFolderSize.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.getTree().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    enableDragSupport();
    enableDropSupport();
    enableInPlaceRename();
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterText);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    viewer.getTree().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    filterText.setCloseAction(actionShowFilter);
    // Set initial focus to filter input line
    if (initShowFilter)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
    refreshFileList();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewAgentFilesProvider(org.netxms.ui.eclipse.filemanager.views.helpers.ViewAgentFilesProvider) Node(org.netxms.client.objects.Node) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AgentFileComparator(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileComparator) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) FilterText(org.netxms.ui.eclipse.widgets.FilterText) AgentFileFilter(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileFilter) AgentFileLabelProvider(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileLabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Node (org.netxms.client.objects.Node)1 AgentFileComparator (org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileComparator)1 AgentFileFilter (org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileFilter)1 AgentFileLabelProvider (org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileLabelProvider)1 ViewAgentFilesProvider (org.netxms.ui.eclipse.filemanager.views.helpers.ViewAgentFilesProvider)1 FilterText (org.netxms.ui.eclipse.widgets.FilterText)1 SortableTreeViewer (org.netxms.ui.eclipse.widgets.SortableTreeViewer)1