1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Polytechnique Montréal - Initial API and implementation
11 * Bernd Hufmann - Productification, enhancements and fixes
13 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.model
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.ProviderResource
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.LTTngUiPlugin
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.TraceControlConstants
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.Messages
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.subsystems
.TraceSubSystem
;
25 import org
.eclipse
.rse
.ui
.SystemMenuManager
;
26 import org
.eclipse
.rse
.ui
.view
.AbstractSystemViewAdapter
;
27 import org
.eclipse
.rse
.ui
.view
.ISystemRemoteElementAdapter
;
28 import org
.eclipse
.swt
.widgets
.Shell
;
29 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
32 * <b><u>ProviderResourceAdapter</u></b>
34 * This is the adapter which enables us to work with our remote provider resources.
37 public class ProviderResourceAdapter
extends AbstractSystemViewAdapter
implements ISystemRemoteElementAdapter
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 * Default Constructor.
49 public ProviderResourceAdapter() {
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#addActions(org.eclipse.rse.ui.SystemMenuManager, org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.swt.widgets.Shell, java.lang.String)
61 public void addActions(SystemMenuManager menu
, IStructuredSelection selection
, Shell parent
, String menuGroup
) {
66 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getImageDescriptor(java.lang.Object)
69 public ImageDescriptor
getImageDescriptor(Object element
) {
70 return LTTngUiPlugin
.getDefault().getImageDescriptor(LTTngUiPlugin
.ICON_ID_PROVIDER
);
75 * @see org.eclipse.rse.ui.view.ISystemViewElementAdapter#getText(java.lang.Object)
78 public String
getText(Object element
) {
79 return ((ProviderResource
) element
).getName();
84 * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
87 public String
getAbsoluteName(Object object
) {
88 ProviderResource provider
= (ProviderResource
) object
;
89 return Messages
.Lttng_Resource_Provider
+ "_" + provider
.getName(); //$NON-NLS-1$
94 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object)
97 public String
getType(Object element
) {
98 return Messages
.Lttng_Resource_Provider
;
103 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getParent(java.lang.Object)
106 public Object
getParent(Object element
) {
107 return null; // not really used, which is good because it is ambiguous
112 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IProgressMonitor)
115 public Object
[] getChildren(IAdaptable element
, IProgressMonitor monitor
) {
116 return ((ProviderResource
) element
).getTargets();
121 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyDescriptors()
124 protected IPropertyDescriptor
[] internalGetPropertyDescriptors() {
130 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyValue(java.lang.Object)
133 protected Object
internalGetPropertyValue(Object key
) {
139 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#canRename(java.lang.Object)
141 * Intercept of parent method to indicate these objects can be renamed using the RSE-supplied rename action.
144 public boolean canRename(Object element
) {
150 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showDelete(java.lang.Object)
153 public boolean showDelete(Object element
) {
159 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showRefresh(java.lang.Object)
162 public boolean showRefresh(Object element
) {
168 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showRename(java.lang.Object)
171 public boolean showRename(Object element
) {
175 // --------------------------------------
176 // ISystemRemoteElementAdapter methods...
177 // --------------------------------------
181 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
184 public String
getAbsoluteParentName(Object element
) {
185 return Messages
.Lttng_Resource_Root
; // not really applicable as we have no unique hierarchy
190 * @see org.eclipse.rse.core.subsystems.ISystemRemoteObjectMatchProvider#getSubSystemConfigurationId(java.lang.Object)
193 public String
getSubSystemConfigurationId(Object element
) {
194 return "org.eclipse.linuxtools.lttng.ui.tracecontrol.subsystems.TraceSubSystemConfiguration"; // as declared in extension in plugin.xml //$NON-NLS-1$
200 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
203 public String
getRemoteTypeCategory(Object element
) {
204 return TraceControlConstants
.Rse_Provider_Resource_Remote_Type_Category
; // Course grained. Same for all our remote resources.
210 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
213 public String
getRemoteType(Object element
) {
214 return TraceControlConstants
.Rse_Provider_Resource_Remote_Type
; // Fine grained. Unique to this resource type.
220 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
223 public String
getRemoteSubType(Object element
) {
224 return null; // Very fine grained. We don't use it.
230 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
233 public boolean refreshRemoteObject(Object oldElement
, Object newElement
) {
234 ProviderResource oldProvider
= (ProviderResource
) oldElement
;
235 ProviderResource newProvider
= (ProviderResource
) newElement
;
236 newProvider
.setName(oldProvider
.getName());
243 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
246 public String
[] getRemoteParentNamesInUse(Object element
, IProgressMonitor monitor
) throws Exception
{
247 TraceSubSystem ourSS
= (TraceSubSystem
) getSubSystem(element
);
248 ProviderResource
[] allProviders
= ourSS
.getAllProviders();
249 String
[] allNames
= new String
[allProviders
.length
];
250 for (int idx
= 0; idx
< allProviders
.length
; idx
++) {
251 allNames
[idx
] = allProviders
[idx
].getName();
253 return allNames
; // Return list of all team names
258 * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
261 public Object
getRemoteParent(Object element
, IProgressMonitor monitor
) throws Exception
{
267 * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(org.eclipse.core.runtime.IAdaptable)
270 public boolean hasChildren(IAdaptable element
) {
271 return ((((ProviderResource
) element
).getTargets() != null) && (((ProviderResource
) element
).getTargets().length
> 0));