EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.dialogs.parameters]

COVERAGE SUMMARY FOR SOURCE FILE [UpDownButtonsValidator.java]

nameclass, %method, %block, %line, %
UpDownButtonsValidator.java0%   (0/1)0%   (0/9)0%   (0/140)0%   (0/48)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UpDownButtonsValidator0%   (0/1)0%   (0/9)0%   (0/140)0%   (0/48)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
UpDownButtonsValidator (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getSingelton (): UpDownButtonsValidator 0%   (0/1)0%   (0/8)0%   (0/3)
setContents (CreateEditorContents): void 0%   (0/1)0%   (0/4)0%   (0/2)
validate (int, int): void 0%   (0/1)0%   (0/27)0%   (0/8)
validateInnerDeclaration (InnerDeclaration): void 0%   (0/1)0%   (0/19)0%   (0/7)
validateParameter (Parameter): void 0%   (0/1)0%   (0/13)0%   (0/3)
validateSelection (Object): void 0%   (0/1)0%   (0/43)0%   (0/14)
validdateDeclarationInnerDataType (InnerDeclaration, PalladioDataTypeDialog):... 0%   (0/1)0%   (0/20)0%   (0/7)

1package de.uka.ipd.sdq.pcm.dialogs.parameters;
2 
3import org.eclipse.core.runtime.Assert;
4import org.eclipse.emf.common.util.EList;
5 
6import de.uka.ipd.sdq.pcm.dialogs.Messages;
7import de.uka.ipd.sdq.pcm.dialogs.datatype.PalladioDataTypeDialog;
8import de.uka.ipd.sdq.pcm.repository.CompositeDataType;
9import de.uka.ipd.sdq.pcm.repository.InnerDeclaration;
10import de.uka.ipd.sdq.pcm.repository.Parameter;
11import de.uka.ipd.sdq.pcm.repository.Signature;
12 
13/**
14 * The Class place the validate methods for CompositeDataType and
15 * Parameters(Signature) editor area. The methods are used for validating of
16 * InnerDeclaration of CompositeDataType and signature parameters. Validating
17 * passes each Action (Delete, Up, Down) with call.
18 * 
19 * @author Roman Andrej
20 */
21public class UpDownButtonsValidator {
22 
23        private static UpDownButtonsValidator singelton = null;
24        private CreateEditorContents contents;
25        
26        private UpDownButtonsValidator() {
27        }
28        
29        public void validate(int elementIndex, int maxIndex) {
30                Assert.isNotNull(contents); 
31                
32                contents.setDownItemsEnabled(true);
33                contents.setUpItemsEnabled(true);
34                
35                if (elementIndex == 0)
36                        contents.setUpItemsEnabled(false);
37                if (elementIndex == maxIndex - 1)
38                        contents.setDownItemsEnabled(false);
39        }
40 
41        /** Validate selection from table viewer */
42        public void validateSelection(Object selection) {
43                if (selection == null) {
44                        contents.setDeleteItemsEnabled(false);
45                        contents.setDownItemsEnabled(false);
46                        contents.setUpItemsEnabled(false);
47                } else if (selection instanceof Parameter) {
48                        Parameter parameter = (Parameter) selection;
49                        UpDownButtonsValidator.getSingelton().validateParameter(parameter);
50                        contents.setDeleteItemsEnabled(true);
51                } else if (selection instanceof InnerDeclaration) {
52                        InnerDeclaration declaration = (InnerDeclaration) selection;
53                        UpDownButtonsValidator.getSingelton().validateInnerDeclaration(
54                                        declaration);
55                        contents.setDeleteItemsEnabled(true);
56                }
57        }
58        
59        /**
60         * Validate (Enabled/Unenabled) up-, down-button in the ParameterDialog.
61         * Call if selection instanceof Parameter.
62         */
63        public void validateParameter(Parameter parameter) {
64                EList<Parameter> parameters = ParametersUtil.getParametersOfSignature((Signature)parameter.eContainer());
65                validate(parameters.indexOf(parameter), parameters.size());
66        }
67        
68        /**
69         * Validate (Enabled/Unenabled) up-, down-button in the DataTypeDialog. Call
70         * if selection instanceof InnerDeclaration.
71         */
72        public void validateInnerDeclaration(InnerDeclaration declaration) {
73                if (declaration.eContainer() instanceof CompositeDataType) {
74                        CompositeDataType dataType = (CompositeDataType) declaration
75                                        .eContainer();
76                        EList<InnerDeclaration> declarations = dataType
77                                        .getInnerDeclaration_CompositeDataType();
78                        validate(declarations.indexOf(declaration), declarations.size());
79                }
80        }
81        
82        public boolean validdateDeclarationInnerDataType(InnerDeclaration declaration, PalladioDataTypeDialog dialog){
83                if (declaration.getDatatype_InnerDeclaration() == null) {
84                        dialog.setErrorMessage(Messages.DataTypeDialog_ErrorMsgInnerName);
85                        return false;
86                }
87                if (declaration.getEntityName().equals("")) {
88                        dialog.setErrorMessage(Messages.DataTypeDialog_ErrorMsgInnerName);
89                        return false;
90                }
91                return true;
92        }
93        
94        public static UpDownButtonsValidator getSingelton() {
95                if (singelton == null)
96                        singelton = new UpDownButtonsValidator();
97                return singelton;
98        }
99 
100        public void setContents(CreateEditorContents contents) {
101                this.contents = contents;
102        }
103}

[all classes][de.uka.ipd.sdq.pcm.dialogs.parameters]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov