Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0b2fd29a26e667412cff2590d337f52f4dd95bde (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*******************************************************************************
 * Copyright (c) 2008, 2012 IONA Technologies PLC
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IONA Technologies PLC - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.ws.internal.cxf.ui.widgets;

import org.eclipse.jst.ws.internal.cxf.core.CXFCorePlugin;
import org.eclipse.jst.ws.internal.cxf.core.context.Java2WSPersistentContext;
import org.eclipse.jst.ws.internal.cxf.core.model.CXFPackage;
import org.eclipse.jst.ws.internal.cxf.core.utils.CXFModelUtils;
import org.eclipse.jst.ws.internal.cxf.ui.CXFUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;

public class AnnotationsComposite extends Composite {
    private Java2WSPersistentContext context = CXFCorePlugin.getDefault().getJava2WSContext();

    private Button generateWebMethodButton;
    private Button generateWebParamButton;
    private Button generateRequestWrapperButton;
    private Button generateResponseWrapperButton;
    private Button generateWebResultButton;

    private Button enableAPTButton;

    public AnnotationsComposite(Composite parent, int style) {
        super(parent, style);
        addControls();
    }

    private void addControls() {
        GridLayout preflayout = new GridLayout(1, true);
        this.setLayout(preflayout);

        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
        this.setLayoutData(gridData);

        Group jaxwsAnnotationsGroup = new Group(this, SWT.SHADOW_IN);
        jaxwsAnnotationsGroup.setText(CXFUIMessages.JAXWS_ANNOTATIONS_GROUP_LABEL);
        jaxwsAnnotationsGroup.setToolTipText(CXFUIMessages.JAXWS_ANNOTATIONS_GROUP_TOOLTIP);
        GridLayout gridLayout = new GridLayout(1, true);
        jaxwsAnnotationsGroup.setLayout(gridLayout);
        gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
        jaxwsAnnotationsGroup.setLayoutData(gridData);

        generateWebMethodButton = new Button(jaxwsAnnotationsGroup, SWT.CHECK);
        generateWebMethodButton.setText(CXFUIMessages.JAXWS_GENERATE_WEB_METHOD);
        generateWebMethodButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setGenerateWebMethodAnnotation(selected);
            }
        });
        generateWebMethodButton.setSelection(context.isGenerateWebMethodAnnotation());

        generateWebParamButton = new Button(jaxwsAnnotationsGroup, SWT.CHECK);
        generateWebParamButton.setText(CXFUIMessages.JAXWS_GENERATE_WEB_PARAM);
        generateWebParamButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setGenerateWebParamAnnotation(selected);
            }
        });
        generateWebParamButton.setSelection(context.isGenerateWebParamAnnotation());

        generateRequestWrapperButton = new Button(jaxwsAnnotationsGroup, SWT.CHECK);
        generateRequestWrapperButton.setText(CXFUIMessages.JAXWS_GENERATE_REQUEST_WRAPPER);
        generateRequestWrapperButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setGenerateRequestWrapperAnnotation(selected);
            }
        });
        generateRequestWrapperButton.setSelection(context.isGenerateRequestWrapperAnnotation());

        generateResponseWrapperButton = new Button(jaxwsAnnotationsGroup, SWT.CHECK);
        generateResponseWrapperButton.setText(CXFUIMessages.JAXWS_GENERATE_RESPONSE_WRAPPER);
        generateResponseWrapperButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setGenerateResponseWrapperAnnotation(selected);
            }
        });
        generateResponseWrapperButton.setSelection(context.isGenerateResponseWrapperAnnotation());

        generateWebResultButton = new Button(jaxwsAnnotationsGroup, SWT.CHECK);
        generateWebResultButton.setText(CXFUIMessages.JAXWS_GENERATE_WEB_RESULT);
        generateWebResultButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setGenerateWebResultAnnotation(selected);
            }
        });
        generateWebResultButton.setSelection(context.isGenerateWebResultAnnotation());

        Group annotationProcessingGroup = new Group(this, SWT.SHADOW_IN);
        annotationProcessingGroup.setText(CXFUIMessages.JAXWS_ANNOTATIONS_PROCESSING_GROUP_LABEL);
        annotationProcessingGroup.setToolTipText(CXFUIMessages.bind(
                CXFUIMessages.JAXWS_ENABLE_ANNOTATION_PROCESSING_TOOLTIP,
                context.getDefaultRuntimeType()));
        gridLayout = new GridLayout(1, true);
        annotationProcessingGroup.setLayout(gridLayout);
        gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
        annotationProcessingGroup.setLayoutData(gridData);

        enableAPTButton = new Button(annotationProcessingGroup, SWT.CHECK);
        enableAPTButton.setText(CXFUIMessages.JAXWS_ENABLE_ANNOTATION_PROCESSING);
        enableAPTButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                context.setAnnotationProcessingEnabled(selected);
            }
        });
        enableAPTButton.setSelection(context.isAnnotationProcessingEnabled());
    }

    public void setDefaults() {
        generateWebMethodButton.setSelection(CXFModelUtils.getDefaultBooleanValue(CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__GENERATE_WEB_METHOD_ANNOTATION));

        generateWebParamButton.setSelection(CXFModelUtils.getDefaultBooleanValue(CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__GENERATE_WEB_PARAM_ANNOTATION));

        generateRequestWrapperButton.setSelection(CXFModelUtils.getDefaultBooleanValue(
                CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__GENERATE_REQUEST_WRAPPER_ANNOTATION));

        generateResponseWrapperButton.setSelection(CXFModelUtils.getDefaultBooleanValue(
                CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__GENERATE_RESPONSE_WRAPPER_ANNOTATION));

        generateWebResultButton.setSelection(CXFModelUtils.getDefaultBooleanValue(
                CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__GENERATE_WEB_RESULT_ANNOTATION));

        enableAPTButton.setSelection(CXFModelUtils.getDefaultBooleanValue(CXFPackage.JAVA2_WS_CONTEXT,
                CXFPackage.JAVA2_WS_CONTEXT__ANNOTATION_PROCESSING_ENABLED));
    }

    public void storeValues() {
        context.setGenerateWebMethodAnnotation(generateWebMethodButton.getSelection());
        context.setGenerateWebParamAnnotation(generateWebParamButton.getSelection());
        context.setGenerateRequestWrapperAnnotation(generateRequestWrapperButton.getSelection());
        context.setGenerateResponseWrapperAnnotation(generateResponseWrapperButton.getSelection());
        context.setGenerateWebResultAnnotation(generateWebResultButton.getSelection());
        context.setAnnotationProcessingEnabled(enableAPTButton.getSelection());
    }
}

Back to the top