use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.
the class IdMatchingDialog 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);
Label label = new Label(dialogArea, SWT.WRAP);
label.setText(Messages.get().IdMatchingDialog_HelpText);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 0;
label.setLayoutData(gd);
final String[] names = { Messages.get().IdMatchingDialog_ColumnOriginalID, Messages.get().IdMatchingDialog_ColumnName, Messages.get().IdMatchingDialog_ColumnMatchID, Messages.get().IdMatchingDialog_ColumnMatchName };
final int[] widths = { 100, 300, 80, 300 };
viewer = new SortableTreeViewer(dialogArea, names, widths, 0, SWT.UP, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
viewer.getTree().setLinesVisible(true);
viewer.getTree().setHeaderVisible(true);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
viewer.getControl().setLayoutData(gd);
viewer.setContentProvider(new IdMatchingContentProvider());
viewer.setLabelProvider(new IdMatchingLabelProvider());
viewer.setInput(new Object[] { objects, dcis });
viewer.expandAll();
createActions();
createPopupMenu();
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.
the class RepositoryManager 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();
}
});
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
}
});
final String[] columnNames = { "Name", "Version", "GUID" };
final int[] columnWidths = { 300, 120, 150 };
viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new RepositoryContentProvider(this));
viewer.setLabelProvider(new RepositoryLabelProvider());
// viewer.setComparator(new AgentFileComparator());
filter = new RepositoryFilter();
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);
}
}
});
viewer.getTree().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
// 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 (filterEnabled)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
refreshRepositoryList();
}
use of org.netxms.ui.eclipse.widgets.SortableTreeViewer 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();
}
use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.
the class AlarmDetails method createEventsSection.
/**
* Create events section
*/
private void createEventsSection() {
final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
section.setText(Messages.get().AlarmDetails_RelatedEvents);
final GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
section.setLayoutData(gd);
section.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
gd.grabExcessVerticalSpace = e.getState();
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
}
});
final Composite content = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
content.setLayout(layout);
section.setClient(content);
final String[] names = { Messages.get().AlarmDetails_Column_Severity, Messages.get().AlarmDetails_Column_Source, Messages.get().AlarmDetails_Column_Name, Messages.get().AlarmDetails_Column_Message, Messages.get().AlarmDetails_Column_Timestamp };
final int[] widths = { 130, 160, 160, 400, 150 };
eventViewer = new SortableTreeViewer(content, names, widths, EV_COLUMN_TIMESTAMP, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION);
eventViewer.setContentProvider(new EventTreeContentProvider());
eventViewer.setLabelProvider(new EventTreeLabelProvider());
eventViewer.setComparator(new EventTreeComparator());
eventViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
WidgetHelper.restoreTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
eventViewer.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
}
});
}
use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.
the class SummaryTableItemComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
// $NON-NLS-1$
final int column = (Integer) ((SortableTreeViewer) viewer).getTree().getSortColumn().getData("ID");
final DataType format = (column < formats.length) ? formats[column] : DataType.STRING;
final String value1 = getCellValue((TableRow) e1, column);
final String value2 = getCellValue((TableRow) e2, column);
int result;
switch(format) {
case INT32:
result = safeParseInt(value1) - safeParseInt(value2);
break;
case UINT32:
case COUNTER32:
case INT64:
case UINT64:
case COUNTER64:
result = Long.signum(safeParseLong(value1) - safeParseLong(value2));
break;
case FLOAT:
result = (int) Math.signum(safeParseDouble(value1) - safeParseDouble(value2));
break;
default:
result = value1.compareToIgnoreCase(value2);
break;
}
return (((SortableTreeViewer) viewer).getTree().getSortDirection() == SWT.UP) ? result : -result;
}
Aggregations