blob: 7fb80079d0362487c65406714f96fba7cf10a912 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright (c) 2004 - 2012 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:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.ui.internal.location;
import org.eclipse.emf.cdo.internal.location.BranchCheckoutSource;
import org.eclipse.emf.cdo.location.IRepositoryLocation;
import org.eclipse.emf.cdo.ui.shared.SharedIcons;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.graphics.Image;
/**
* @author Eike Stepper
*/
public class RepositoryLocationItemProvider extends ContainerItemProvider<IContainer<Object>>
{
public RepositoryLocationItemProvider()
{
}
public RepositoryLocationItemProvider(IElementFilter rootElementFilter)
{
super(rootElementFilter);
}
@Override
public Image getImage(Object obj)
{
if (obj instanceof IRepositoryLocation)
{
return SharedIcons.getImage(SharedIcons.OBJ_REPO);
}
if (obj instanceof BranchCheckoutSource)
{
return SharedIcons.getImage(SharedIcons.OBJ_BRANCH);
}
return super.getImage(obj);
}
@Override
protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
{
super.fillContextMenu(manager, selection);
if (selection.size() == 1)
{
Object obj = selection.getFirstElement();
if (obj instanceof IRepositoryLocation)
{
manager.add(new RemoveAction(obj));
}
}
}
/**
* @author Eike Stepper
*/
public static class RemoveAction extends LongRunningAction
{
private Object object;
public RemoveAction(Object object)
{
super("Remove");
this.object = object;
}
@Override
protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
if (object instanceof IRepositoryLocation)
{
IRepositoryLocation location = (IRepositoryLocation)object;
location.delete();
}
}
}
}
|