use of org.netxms.client.objects.Interface in project netxms by netxms.
the class Commands method onObjectChange.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#onObjectChange()
*/
@Override
protected void onObjectChange() {
commandBox.deleteAll(false);
if (getObject() instanceof AbstractNode) {
ObjectTool[] tools = ObjectToolsCache.getInstance().getTools();
for (final ObjectTool tool : tools) {
if (!tool.isVisibleInCommands() || !tool.isEnabled() || !tool.isApplicableForNode((AbstractNode) getObject()))
continue;
final Set<ObjectContext> nodes = new HashSet<ObjectContext>(1);
nodes.add(new ObjectContext((AbstractNode) getObject(), null));
if (!ObjectToolExecutor.isToolAllowed(tool, nodes))
continue;
final Action action = new Action(tool.getCommandDisplayName()) {
@Override
public void run() {
ObjectToolExecutor.execute(nodes, tool);
}
};
ImageDescriptor icon = ObjectToolsCache.getInstance().findIcon(tool.getId());
if (icon != null)
action.setImageDescriptor(icon);
commandBox.add(action, false);
}
} else if (getObject() instanceof Interface) {
commandBox.add(actionWakeup, false);
}
commandBox.rebuild();
}
use of org.netxms.client.objects.Interface 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.client.objects.Interface in project netxms by netxms.
the class InterfaceListComparator 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) {
final Interface iface1 = (Interface) e1;
final Interface iface2 = (Interface) e2;
// $NON-NLS-1$
final int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
int result;
switch(column) {
case InterfacesTab.COLUMN_8021X_BACKEND_STATE:
result = iface1.getDot1xBackendState() - iface2.getDot1xBackendState();
break;
case InterfacesTab.COLUMN_8021X_PAE_STATE:
result = iface1.getDot1xPaeState() - iface2.getDot1xPaeState();
break;
case InterfacesTab.COLUMN_ADMIN_STATE:
result = iface1.getAdminState() - iface2.getAdminState();
break;
case InterfacesTab.COLUMN_ALIAS:
result = NaturalOrderComparator.compare(iface1.getAlias(), iface2.getAlias());
break;
case InterfacesTab.COLUMN_DESCRIPTION:
result = NaturalOrderComparator.compare(iface1.getDescription(), iface2.getDescription());
break;
case InterfacesTab.COLUMN_EXPECTED_STATE:
result = iface1.getExpectedState() - iface2.getExpectedState();
break;
case InterfacesTab.COLUMN_ID:
result = Long.signum(iface1.getObjectId() - iface2.getObjectId());
break;
case InterfacesTab.COLUMN_INDEX:
result = iface1.getIfIndex() - iface2.getIfIndex();
break;
case InterfacesTab.COLUMN_MTU:
result = iface1.getMtu() - iface2.getMtu();
break;
case InterfacesTab.COLUMN_NAME:
result = NaturalOrderComparator.compare(iface1.getObjectName(), iface2.getObjectName());
break;
case InterfacesTab.COLUMN_OPER_STATE:
result = iface1.getOperState() - iface2.getOperState();
break;
case InterfacesTab.COLUMN_PORT:
result = iface1.getPort() - iface2.getPort();
break;
case InterfacesTab.COLUMN_SLOT:
result = iface1.getSlot() - iface2.getSlot();
break;
case InterfacesTab.COLUMN_SPEED:
result = Long.signum(iface1.getSpeed() - iface2.getSpeed());
break;
case InterfacesTab.COLUMN_STATUS:
result = iface1.getStatus().compareTo(iface2.getStatus());
break;
case InterfacesTab.COLUMN_TYPE:
result = iface1.getIfType() - iface2.getIfType();
break;
case InterfacesTab.COLUMN_MAC_ADDRESS:
result = iface1.getMacAddress().compareTo(iface2.getMacAddress());
break;
case InterfacesTab.COLUMN_IP_ADDRESS:
result = ComparatorHelper.compareInetAddresses(iface1.getFirstUnicastAddress(), iface2.getFirstUnicastAddress());
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Aggregations