use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class DashboardBrowser method getFullPath.
/**
* Get full path to current position in object tree
*
* @return
*/
private String getFullPath() {
StringBuilder sb = new StringBuilder();
for (AbstractObject o : containerPath) {
sb.append('/');
sb.append(o.getObjectName());
}
if (currentParent != null) {
sb.append('/');
sb.append(currentParent.getObjectName());
}
return sb.toString();
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class AlarmsFragment method handleItemSelection.
/**
* Handles menu item selection for both Option and Context menus
* @param item Menu item to handle
* @return true if menu has been properly handled
*/
private boolean handleItemSelection(MenuItem item) {
switch(item.getItemId()) {
case R.id.sort_severity_asc:
setNewSort(item, AlarmListAdapter.SORT_SEVERITY_ASC);
return true;
case R.id.sort_severity_desc:
setNewSort(item, AlarmListAdapter.SORT_SEVERITY_DESC);
return true;
case R.id.sort_date_asc:
setNewSort(item, AlarmListAdapter.SORT_DATE_ASC);
return true;
case R.id.sort_date_desc:
setNewSort(item, AlarmListAdapter.SORT_DATE_DESC);
return true;
case R.id.sort_name_asc:
setNewSort(item, AlarmListAdapter.SORT_NAME_ASC);
return true;
case R.id.sort_name_desc:
setNewSort(item, AlarmListAdapter.SORT_NAME_DESC);
return true;
case R.id.selectall:
selectAll(true);
return true;
case R.id.unselectall:
selectAll(false);
return true;
case R.id.acknowledge:
adapter.doAction(AlarmListAdapter.ACKNOWLEDGE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.sticky_acknowledge:
adapter.doAction(AlarmListAdapter.STICKY_ACKNOWLEDGE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.resolve:
adapter.doAction(AlarmListAdapter.RESOLVE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.terminate:
adapter.doAction(AlarmListAdapter.TERMINATE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.viewlastvalues:
if (service != null) {
Alarm al = (Alarm) adapter.getItem(lastPosition);
if (al != null) {
AbstractObject object = service.findObjectById(al.getSourceObjectId());
if (object != null) {
Intent newIntent = new Intent(getActivity(), NodeInfoFragment.class);
newIntent.putExtra("objectId", object.getObjectId());
newIntent.putExtra("tabId", NodeInfoFragment.TAB_LAST_VALUES_ID);
startActivity(newIntent);
}
}
}
return true;
}
return false;
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class ActivityListAdapter method getView.
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ActivityListElement view = null;
if (position >= 0 && position < getCount()) {
if (convertView == null) {
view = new ActivityListElement(context, imageId[position], textId[position]);
view.setLayoutParams(new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
} else {
view = (ActivityListElement) convertView;
}
Drawable infoLayer = null;
switch(activityId[position]) {
case HomeScreen.ACTIVITY_ALARMS:
if (numAlarms > 0)
infoLayer = parent.getResources().getDrawable(numAlarms >= MAX_ALARMS ? alarmId[0] : alarmId[numAlarms]);
break;
case HomeScreen.ACTIVITY_NODES:
case HomeScreen.ACTIVITY_ENTIRENETWORK:
case HomeScreen.ACTIVITY_DASHBOARDS:
if (topNodes != null) {
AbstractObject obj = topNodes.get(activityId[position]);
if (obj != null) {
switch(obj.getStatus()) {
case WARNING:
case MINOR:
case MAJOR:
case CRITICAL:
infoLayer = parent.getResources().getDrawable(statusImageId[obj.getStatus().getValue()]);
break;
case NORMAL:
case UNKNOWN:
case UNMANAGED:
case DISABLED:
case TESTING:
default:
break;
}
}
}
break;
}
Drawable[] layers;
if (infoLayer != null) {
layers = new Drawable[2];
layers[1] = infoLayer;
} else
layers = new Drawable[1];
layers[0] = parent.getResources().getDrawable(imageId[position]);
ImageView objectIcon = (ImageView) view.getChildAt(0);
LayerDrawable drawable = new LayerDrawable(layers);
if (layers.length > 1)
drawable.setLayerInset(1, layers[0].getIntrinsicWidth() - layers[1].getIntrinsicWidth(), layers[0].getIntrinsicHeight() - layers[1].getIntrinsicHeight(), 0, 0);
objectIcon.setImageDrawable(drawable);
}
return view;
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class ObjectListAdapter method getView.
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView objectName;
TextView objectStatusText;
LinearLayout view, texts;
ImageView objectIcon;
Resources r = context.getResources();
if (convertView == null) {
// new object, create fields
objectName = new TextView(context);
objectName.setPadding(5, 2, 5, 2);
objectName.setTextColor(r.getColor(R.color.text_color));
objectName.setTextSize(TypedValue.COMPLEX_UNIT_PX, objectName.getTextSize() * 1.1f);
objectStatusText = new TextView(context);
objectStatusText.setPadding(5, 2, 5, 2);
objectStatusText.setTextColor(r.getColor(R.color.text_color));
objectIcon = new ImageView(context);
objectIcon.setPadding(5, 5, 5, 2);
texts = new LinearLayout(context);
texts.setOrientation(LinearLayout.VERTICAL);
texts.addView(objectName);
texts.addView(objectStatusText);
view = new LinearLayout(context);
view.addView(objectIcon);
view.addView(texts);
} else {
// get reference to existing object
view = (LinearLayout) convertView;
objectIcon = (ImageView) view.getChildAt(0);
texts = (LinearLayout) view.getChildAt(1);
objectName = (TextView) texts.getChildAt(0);
objectStatusText = (TextView) texts.getChildAt(1);
}
// set fields in view
ObjectStatus objectStatus;
int objectIconId = R.drawable.object_unknown;
AbstractObject object = objectList.get(position);
if (object == null) {
objectName.setText(r.getString(R.string.node_unknown));
objectStatusText.setText(r.getString(R.string.status_unknown));
objectStatus = ObjectStatus.UNKNOWN;
} else {
objectName.setText(object.getObjectName());
objectStatusText.setText(statusTextId[object.getStatus().getValue()]);
objectStatus = object.getStatus();
switch(object.getObjectClass()) {
case AbstractObject.OBJECT_CONTAINER:
objectIconId = R.drawable.object_container;
break;
case AbstractObject.OBJECT_NODE:
objectIconId = R.drawable.object_node;
break;
case AbstractObject.OBJECT_CLUSTER:
objectIconId = R.drawable.object_cluster;
break;
case AbstractObject.OBJECT_DASHBOARD:
objectIconId = R.drawable.dashboard;
break;
case AbstractObject.OBJECT_MOBILEDEVICE:
objectIconId = R.drawable.object_mobiledevice;
break;
case AbstractObject.OBJECT_SUBNET:
objectIconId = R.drawable.object_subnet;
break;
case AbstractObject.OBJECT_ZONE:
objectIconId = R.drawable.object_zone;
break;
}
}
Drawable[] layers = new Drawable[2];
layers[0] = parent.getResources().getDrawable(objectIconId);
layers[1] = parent.getResources().getDrawable(ObjectListAdapter.statusImageId[objectStatus.getValue()]);
LayerDrawable drawable = new LayerDrawable(layers);
drawable.setLayerInset(1, layers[0].getIntrinsicWidth() - layers[1].getIntrinsicWidth(), layers[0].getIntrinsicHeight() - layers[1].getIntrinsicHeight(), 0, 0);
objectIcon.setImageDrawable(drawable);
return view;
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class AlarmToolTip method createToolTipContentArea.
/* (non-Javadoc)
* @see org.eclipse.jface.window.ToolTip#createToolTipContentArea(org.eclipse.swt.widgets.Event, org.eclipse.swt.widgets.Composite)
*/
@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
final Composite content = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
content.setLayout(layout);
CLabel alarmSeverity = new CLabel(content, SWT.NONE);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.TOP;
alarmSeverity.setLayoutData(gd);
Label sep = new Label(content, SWT.VERTICAL | SWT.SEPARATOR);
gd = new GridData();
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalSpan = 3;
sep.setLayoutData(gd);
Text alarmText = new Text(content, SWT.MULTI);
alarmText.setEditable(false);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.verticalSpan = 3;
alarmText.setLayoutData(gd);
CLabel alarmState = new CLabel(content, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.TOP;
alarmState.setLayoutData(gd);
CLabel alarmSource = new CLabel(content, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.TOP;
alarmSource.setLayoutData(gd);
alarmSeverity.setImage(StatusDisplayInfo.getStatusImage(alarm.getCurrentSeverity()));
alarmSeverity.setText(StatusDisplayInfo.getStatusText(alarm.getCurrentSeverity()));
int state = alarm.getState();
if ((state == Alarm.STATE_ACKNOWLEDGED) && alarm.isSticky())
state = Alarm.STATE_TERMINATED + 1;
final Image image = Activator.getImageDescriptor(stateImage[state]).createImage();
alarmState.setImage(image);
alarmState.setText(stateText[alarm.getState()]);
AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(alarm.getSourceObjectId());
alarmSource.setImage((object != null) ? wbLabelProvider.getImage(object) : SharedIcons.IMG_UNKNOWN_OBJECT);
// $NON-NLS-1$ //$NON-NLS-2$
alarmSource.setText((object != null) ? object.getObjectName() : ("[" + Long.toString(alarm.getSourceObjectId()) + "]"));
alarmText.setText(alarm.getMessage());
content.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
wbLabelProvider.dispose();
image.dispose();
}
});
return content;
}
Aggregations