1 /*******************************************************************************
2 * Copyright (c) 2012 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.handlers
;
15 import java
.util
.Iterator
;
17 import org
.eclipse
.core
.expressions
.PropertyTester
;
18 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfExperimentElement
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceFolder
;
24 * <b><u>TracePropertyTester</u></b>
27 public class TracePropertyTester
extends PropertyTester
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 private static String isInTraceFolder
= "isInTraceFolder"; //$NON-NLS-1$
34 private static String isExperimentTrace
= "isExperimentTrace"; //$NON-NLS-1$
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
43 public TracePropertyTester() {
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
54 public boolean test(Object receiver
, String property
, Object
[] args
, Object expectedValue
) {
56 // Check if the selected elements are in the trace folder
57 if (isInTraceFolder
.equals(property
)) {
58 if (receiver
!= null && receiver
instanceof IStructuredSelection
) {
59 Iterator
<?
> iter
= ((IStructuredSelection
) receiver
).iterator();
60 while (iter
.hasNext()) {
61 Object item
= iter
.next();
62 if (item
instanceof TmfTraceElement
) {
63 TmfTraceElement trace
= (TmfTraceElement
) item
;
64 if (!(trace
.getParent() instanceof TmfTraceFolder
)) {
75 // Check if the parent of a trace element is an experiment
76 if (isExperimentTrace
.equals(property
)) {
77 if (receiver
!= null && receiver
instanceof TmfTraceElement
) {
78 TmfTraceElement trace
= (TmfTraceElement
) receiver
;
79 return trace
.getParent() instanceof TmfExperimentElement
;
This page took 0.033902 seconds and 6 git commands to generate.