1
/*******************************************************************************
2
* Copyright (c) 2008,2009 Red Hat, Inc.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.linuxtools.internal.oprofile.ui.model;
13
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
14
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot;
15
import org.eclipse.swt.graphics.Image;
18
* Convenience class for creating the UI model from the oprofile data model,
19
* via a single point of access.
21
public class UiModelRoot implements IUiModelElement {
22
private static UiModelRoot uiModelRoot = new UiModelRoot(); //singleton
23
private UiModelEvent[] events; //this node's children
24
private UiModelError rootError;
26
/** constructor, private for singleton use **/
27
protected UiModelRoot() {
33
* Get the instance of this ui model root.
34
* @return the ui model root object
36
public static UiModelRoot getDefault() {
41
* Kick off creating the UI model from the data model. Meant to
42
* be called from UI code. The refreshModel() method is called for
43
* the child elements from their constructor.
45
public void refreshModel() {
46
OpModelEvent dataModelEvents[] = getModelDataEvents();
51
if (dataModelEvents == null || dataModelEvents.length == 0) {
52
rootError = UiModelError.NO_SAMPLES_ERROR;
54
events = new UiModelEvent[dataModelEvents.length];
55
for (int i = 0; i < dataModelEvents.length; i++) {
56
events[i] = new UiModelEvent(dataModelEvents[i]);
61
protected OpModelEvent[] getModelDataEvents() {
62
OpModelRoot modelRoot = OpModelRoot.getDefault();
63
return modelRoot.getEvents();
66
/** IUiModelElement functions **/
67
public String getLabelText() {
71
public IUiModelElement[] getChildren() {
75
return new IUiModelElement[] { rootError };
78
public boolean hasChildren() {
82
public IUiModelElement getParent() {
86
public Image getLabelImage() {