blob: 4230539e6808322e56951ff383aec5abae316884 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Martin Fluegge - initial API and implementation
*/
package org.eclipse.emf.cdo.dawn.ui.views;
import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.ui.CDOItemProvider;
import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbenchPage;
/**
* @author Martin Fluegge
*/
public class DawnItemProvider extends CDOItemProvider
{
private final DawnExplorer dawnExplorer;
public DawnItemProvider(IWorkbenchPage page, DawnExplorer dawnExplorer, IElementFilter rootElementFilter)
{
super(page, rootElementFilter);
this.dawnExplorer = dawnExplorer;
}
@Override
public Object[] getChildren(Object element)
{
// if (element instanceof CDOView)
// {
// return ((CDOView)element).getRootResource().getContents().toArray();
// }
if (element instanceof CDOResourceFolder)
{
return ((CDOResourceFolder)element).getNodes().toArray();
}
if (element instanceof CDOSession)
{
CDOSession session = (CDOSession)element;
Object[] child = new Object[1];
child[0] = session.getView(dawnExplorer.getView().getViewID());
return child;
}
return super.getChildren(element);
}
@Override
public Image getImage(Object obj)
{
if (obj instanceof CDOResource)
{
CDOResource resource = (CDOResource)obj;
Image img = EditorDescriptionHelper.getImageForEditor(resource.getName());
if (img != null)
{
return img;
}
}
return super.getImage(obj);
}
}
|