use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ResponsibleUsers method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
final NXCSession session = ConsoleSharedData.getSession();
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
userList = session.findUserDBObjectsByIds(object.getResponsibleUsers());
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
Composite dialogArea = new Composite(parent, SWT.NONE);
dialogArea.setLayout(new GridLayout());
final String[] columnNames = { "Login Name" };
final int[] columnWidths = { 150 };
userTable = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userTable.setContentProvider(new ArrayContentProvider());
userTable.setLabelProvider(new ResponsibleUsersLabelProvider());
userTable.setComparator(new ResponsibleUsersComparator());
userTable.setInput(userList.toArray());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userTable.getControl().setLayoutData(gd);
Composite buttons = new Composite(dialogArea, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText("Add...");
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) userList.add(user);
userTable.setInput(userList.toArray());
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText("Delete");
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) userTable.getSelection();
Iterator<AbstractUserObject> it = selection.iterator();
while (it.hasNext()) {
AbstractUserObject element = it.next();
userList.remove(element);
}
userTable.setInput(userList.toArray());
}
});
userTable.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
deleteButton.setEnabled(!selection.isEmpty());
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class RackPassiveElements method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
rack = (Rack) getElement().getAdapter(Rack.class);
if (// Paranoid check
rack == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { "Name", "Type", "Position", "Orientation" };
final int[] columnWidths = { 150, 100, 70, 30 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new RackPassiveElementLabelProvider());
viewer.setComparator(new RackPassiveElementComparator());
passiveElements = new PassiveRackElementGroup(rack.getPassiveElements());
viewer.setInput(passiveElements.getElements());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText("&Add...");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
RackPassiveElementEditDialog dlg = new RackPassiveElementEditDialog(getShell(), null);
if (dlg.open() == Window.OK) {
passiveElements.add(dlg.getElement());
viewer.setInput(passiveElements.getElements());
isModified = true;
}
}
});
editButton = new Button(buttons, SWT.PUSH);
editButton.setText("&Edit...");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() == 1) {
RackPassiveElementEditDialog dlg = new RackPassiveElementEditDialog(getShell(), (PassiveRackElement) selection.getFirstElement());
if (dlg.open() == Window.OK) {
viewer.setInput(passiveElements.getElements());
isModified = true;
}
}
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText("&Delete...");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
passiveElements.getElements().removeAll(selection.toList());
viewer.setInput(passiveElements.getElements());
isModified = true;
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class NodesTab method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
final String[] names = { Messages.get().NodesTab_ColId, Messages.get().NodesTab_ColName, Messages.get().NodesTab_ColPrimaryIP, Messages.get().NodesTab_ColRack, Messages.get().NodesTab_ColPlatform, Messages.get().NodesTab_ColAgentVersion, Messages.get().NodesTab_ColSysDescr, Messages.get().NodesTab_ColStatus };
final int[] widths = { 60, 150, 100, 150, 150, 100, 300, 100 };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setLabelProvider(new NodeListLabelProvider());
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new NodeListComparator());
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "NodeTable.V2");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "NodeTable.V2");
}
});
createActions();
createPopupMenu();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class InterfacesTab method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$ //$NON-NLS-2$
showFilter = safeCast(settings.get("InterfacesTab.showFilter"), settings.getBoolean("InterfacesTab.showFilter"), showFilter);
// $NON-NLS-1$ //$NON-NLS-2$
hideSubInterfaces = safeCast(settings.get("InterfacesTab.hideSubInterfaces"), settings.getBoolean("InterfacesTab.hideSubInterfaces"), hideSubInterfaces);
// Create interface area
interfacesArea = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
interfacesArea.setLayout(formLayout);
// Create filter
filterText = new FilterText(interfacesArea, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
settings.put("InterfacesTab.showFilter", showFilter);
// $NON-NLS-1$
settings.put("InterfacesTab.hideSubInterfaces", hideSubInterfaces);
}
});
Action action = new Action() {
@Override
public void run() {
enableFilter(false);
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.show_filter");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.show_filter.state");
state.setValue(false);
service.refreshElements(command.getId(), null);
}
};
setFilterCloseAction(action);
// Check/uncheck menu items
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.show_filter");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.show_filter.state");
state.setValue(showFilter);
service.refreshElements(command.getId(), null);
// $NON-NLS-1$
command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces");
// $NON-NLS-1$
state = command.getState("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces.state");
state.setValue(hideSubInterfaces);
service.refreshElements(command.getId(), null);
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
final String[] names = { Messages.get().InterfacesTab_ColId, Messages.get().InterfacesTab_ColName, Messages.get().InterfacesTab_Alias, Messages.get().InterfacesTab_ColIfType, Messages.get().InterfacesTab_ColIfIndex, Messages.get().InterfacesTab_ColSlot, Messages.get().InterfacesTab_ColPort, Messages.get().InterfacesTab_MTU, Messages.get().InterfacesTab_Speed, Messages.get().InterfacesTab_ColDescription, Messages.get().InterfacesTab_ColMacAddr, Messages.get().InterfacesTab_ColIpAddr, Messages.get().InterfacesTab_ColPeerNode, Messages.get().InterfacesTab_ColPeerMAC, Messages.get().InterfacesTab_ColPeerIP, Messages.get().InterfacesTab_PeerDiscoveryProtocol, Messages.get().InterfacesTab_ColAdminState, Messages.get().InterfacesTab_ColOperState, Messages.get().InterfacesTab_ColExpState, Messages.get().InterfacesTab_ColStatus, Messages.get().InterfacesTab_Col8021xPAE, Messages.get().InterfacesTab_Col8021xBackend };
final int[] widths = { 60, 150, 150, 150, 70, 70, 70, 70, 90, 150, 100, 90, 150, 100, 90, 80, 80, 80, 80, 80, 80, 80 };
viewer = new SortableTableViewer(interfacesArea, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
labelProvider = new InterfaceListLabelProvider();
viewer.setLabelProvider(labelProvider);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new InterfaceListComparator());
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
filter = new InterfacesTabFilter();
filter.setHideSubInterfaces(hideSubInterfaces);
viewer.addFilter(filter);
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "InterfaceTable.V4");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "InterfaceTable.V4");
}
});
// Setup layout
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText, 0, SWT.BOTTOM);
fd.bottom = new FormAttachment(100, 0);
fd.right = new FormAttachment(100, 0);
viewer.getControl().setLayoutData(fd);
createActions();
createPopupMenu();
// Set initial focus to filter input line
if (showFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED) {
AbstractObject object = (AbstractObject) n.getObject();
if ((object != null) && (object instanceof Interface) && (getObject() != null) && object.isDirectChildOf(getObject().getObjectId())) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
}
};
ConsoleSharedData.getSession().addListener(sessionListener);
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class TableToolResults method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
viewer = new SortableTableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new TableContentProvider());
viewer.setLabelProvider(new TableLabelProvider());
createActions();
contributeToActionBars();
createPopupMenu();
}
Aggregations