/** * Return the image used for the given node. * * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) */ public Image getImage(Object element) { if (element instanceof Alias) { Alias alias = (Alias) element; for (User user : alias.getUsers()) if (!user.getSessions().isEmpty()) return _activeAliasImage; return _inactiveAliasImage; } return _sessionImage; }
/** * Return the text to display * * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ public String getText(Object element) { if (element instanceof Alias) { Alias alias = (Alias) element; String label = alias.getName(); int numSessions = 0; for (User user : alias.getUsers()) numSessions += user.getConnections().size(); if (numSessions == 1) return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.single.Postfix") + ")"; if (numSessions > 1) return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.multiple.Postfix") + ")"; return label; } else if (element instanceof User) { User user = (User) element; return user.getUserName(); } else if (element instanceof SQLConnection) { SQLConnection connection = (SQLConnection) element; String label; if (connection.getDescription() == null) { SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss"); label = Messages.getString("ConnectionsView.ConnectedAlias.ConnectedSince") + ' ' + fmt.format(new Date(connection.getCreatedTime())); } else label = Messages.getString("ConnectionsView.ConnectedAlias.Connection") + ' ' + connection.getDescription(); if (connection.isPooled()) label += ' ' + Messages.getString("ConnectionsView.ConnectedAlias.Pooled"); return label; } return null; }