This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 196526
Collapse All | Expand All

(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/method/MethodModel.java (-7 / +10 lines)
Lines 46-52 Link Here
46
46
47
import com.sun.source.tree.ExpressionTree;
47
import com.sun.source.tree.ExpressionTree;
48
import java.util.Collections;
48
import java.util.Collections;
49
import java.util.HashMap;
49
import java.util.List;
50
import java.util.List;
51
import java.util.Map;
50
import java.util.Set;
52
import java.util.Set;
51
import javax.lang.model.element.Modifier;
53
import javax.lang.model.element.Modifier;
52
import org.openide.util.Parameters;
54
import org.openide.util.Parameters;
Lines 244-252 Link Here
244
    public static final class Annotation {
246
    public static final class Annotation {
245
247
246
        private final String type;
248
        private final String type;
247
        private final List<? extends ExpressionTree> arguments;
249
        private final Map<String, Object> arguments;
248
250
249
        private Annotation(String type, List<? extends ExpressionTree> arguments) {
251
        private Annotation(String type, Map<String, Object> arguments) {
250
            this.type = type;
252
            this.type = type;
251
            this.arguments = arguments;
253
            this.arguments = arguments;
252
        }
254
        }
Lines 269-284 Link Here
269
         * Creates new instance of a model of {@code Annotation}
271
         * Creates new instance of a model of {@code Annotation}
270
         *
272
         *
271
         * @param type name of annotation type, fully qualified name must be used
273
         * @param type name of annotation type, fully qualified name must be used
272
         * @param arguments {@code List} of annotation arguments, for generation them see {@code GenerationUtils} class
274
         * @param arguments {@code Map<String, String>} of annotation arguments, key of the map determines
275
         * argument name and the maps value implies argument value
273
         * @throws {@code NullPointerException} if any of the parameters is {@code null}
276
         * @throws {@code NullPointerException} if any of the parameters is {@code null}
274
         * @throws {@code IllegalArgumentException} if the parameter type is not fully qualified
277
         * @throws {@code IllegalArgumentException} if the parameter type is not fully qualified
275
         * name of valid annotation
278
         * name of valid annotation
276
         * @return immutable model of {@code Annotation}
279
         * @return immutable model of {@code Annotation}
277
         */
280
         */
278
        public static Annotation create(String type, List<? extends ExpressionTree> arguments) {
281
        public static Annotation create(String type, Map<String, String> arguments) {
279
            Parameters.notNull("type", type);    //NOI18N
282
            Parameters.notNull("type", type);    //NOI18N
280
            Parameters.notNull("arguments", arguments); //NOI18N
283
            Parameters.notNull("arguments", arguments); //NOI18N
281
            return new MethodModel.Annotation(type, arguments);
284
            return new MethodModel.Annotation(type, new HashMap<String, Object>(arguments));
282
        }
285
        }
283
286
284
        // <editor-fold defaultstate="collapsed" desc="Annotation's getters">
287
        // <editor-fold defaultstate="collapsed" desc="Annotation's getters">
Lines 287-299 Link Here
287
            return type;
290
            return type;
288
        }
291
        }
289
292
290
        public List<? extends ExpressionTree> getArguments() {
293
        public Map<String, Object> getArguments() {
291
            return arguments;
294
            return arguments;
292
        }
295
        }
293
296
294
        // </editor-fold>
297
        // </editor-fold>
295
    }
298
    }
296
    
299
297
    // <editor-fold defaultstate="collapsed" desc="MethodModel's getters">
300
    // <editor-fold defaultstate="collapsed" desc="MethodModel's getters">
298
    
301
    
299
    /**
302
    /**
(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/method/MethodModelSupport.java (-1 / +8 lines)
Lines 46-51 Link Here
46
46
47
import com.sun.source.tree.AnnotationTree;
47
import com.sun.source.tree.AnnotationTree;
48
import com.sun.source.tree.BlockTree;
48
import com.sun.source.tree.BlockTree;
49
import java.util.Map;
49
import javax.lang.model.type.ArrayType;
50
import javax.lang.model.type.ArrayType;
50
import org.netbeans.api.java.source.CompilationController;
51
import org.netbeans.api.java.source.CompilationController;
51
import com.sun.source.tree.ExpressionTree;
52
import com.sun.source.tree.ExpressionTree;
Lines 236-242 Link Here
236
                if (annotation.getArguments() == null) { 
237
                if (annotation.getArguments() == null) { 
237
                    annotationTree = genUtils.createAnnotation(annotation.getType());
238
                    annotationTree = genUtils.createAnnotation(annotation.getType());
238
                } else {
239
                } else {
239
                    annotationTree = genUtils.createAnnotation(annotation.getType(), annotation.getArguments());
240
                    List<ExpressionTree> annotationArgs = new ArrayList<ExpressionTree>();
241
                    Iterator it = annotation.getArguments().entrySet().iterator();
242
                    while (it.hasNext()) {
243
                        Map.Entry pairs = (Map.Entry)it.next();
244
                        annotationArgs.add(genUtils.createAnnotationArgument((String) pairs.getKey(),pairs.getValue()));
245
                    }
246
                    annotationTree = genUtils.createAnnotation(annotation.getType(), annotationArgs);
240
                }
247
                }
241
                annotationList.add(annotationTree);
248
                annotationList.add(annotationTree);
242
            }
249
            }
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/AbstractMethodGenerator.java (-1 / +11 lines)
Lines 47-54 Link Here
47
import com.sun.source.tree.ClassTree;
47
import com.sun.source.tree.ClassTree;
48
import com.sun.source.tree.MethodTree;
48
import com.sun.source.tree.MethodTree;
49
import java.io.IOException;
49
import java.io.IOException;
50
import java.util.Collections;
50
import java.util.HashMap;
51
import java.util.HashMap;
51
import java.util.Map;
52
import java.util.Map;
53
import java.util.concurrent.Future;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
52
import javax.lang.model.element.ElementKind;
56
import javax.lang.model.element.ElementKind;
53
import javax.lang.model.element.Modifier;
57
import javax.lang.model.element.Modifier;
54
import javax.lang.model.element.TypeElement;
58
import javax.lang.model.element.TypeElement;
Lines 128-134 Link Here
128
     * Returns map of EJB interface class names, where keys are appropriate constants from {@link EntityAndSession}
132
     * Returns map of EJB interface class names, where keys are appropriate constants from {@link EntityAndSession}
129
     */
133
     */
130
    protected Map<String, String> getInterfaces() throws IOException {
134
    protected Map<String, String> getInterfaces() throws IOException {
131
        return ejbModule.getMetadataModel().runReadAction(new MetadataModelAction<EjbJarMetadata, Map<String, String>>() {
135
        Future futureResult = ejbModule.getMetadataModel().runReadActionWhenReady(new MetadataModelAction<EjbJarMetadata, Map<String, String>>() {
132
            public Map<String, String> run(EjbJarMetadata metadata) throws Exception {
136
            public Map<String, String> run(EjbJarMetadata metadata) throws Exception {
133
                EntityAndSession ejb = (EntityAndSession) metadata.findByEjbClass(ejbClass);
137
                EntityAndSession ejb = (EntityAndSession) metadata.findByEjbClass(ejbClass);
134
                Map<String, String> result = new HashMap<String, String>();
138
                Map<String, String> result = new HashMap<String, String>();
Lines 141-146 Link Here
141
                return result;
145
                return result;
142
            }
146
            }
143
        });
147
        });
148
        try {
149
            return (Map<String, String>) futureResult.get();
150
        } catch (Exception ex) {
151
            Logger.getLogger(AbstractMethodGenerator.class.getName()).log(Level.WARNING, null, ex);
152
            return Collections.<String, String>emptyMap();
153
        }
144
    }
154
    }
145
    
155
    
146
    private static String findCommonInterface(final String className1, final String className2) throws IOException {
156
    private static String findCommonInterface(final String className1, final String className2) throws IOException {
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/BusinessMethodGenerator.java (-5 / +8 lines)
Lines 144-156 Link Here
144
            addMethodToInterface(methodModelCopy, remote);
144
            addMethodToInterface(methodModelCopy, remote);
145
        }
145
        }
146
        
146
        
147
        // ejb class, add 'public' modifier, 'Override' annotation if required
147
        // ejb class
148
        List<MethodModel.Annotation> annotations;
148
        // add all specified annothations and join Override if has local, remote interfaces
149
        List<MethodModel.Annotation> annotations = new ArrayList<MethodModel.Annotation>();
150
        if (!methodModel.getAnnotations().isEmpty()) {
151
            annotations.addAll(methodModel.getAnnotations());
152
        }
149
        if ((generateLocal && local != null) || (generateRemote && remote != null)) {
153
        if ((generateLocal && local != null) || (generateRemote && remote != null)) {
150
            annotations = Collections.singletonList(MethodModel.Annotation.create("java.lang.Override")); //NOI18N
154
            annotations.add(MethodModel.Annotation.create("java.lang.Override")); //NOI18N
151
        } else {
152
            annotations = Collections.<MethodModel.Annotation>emptyList();
153
        }
155
        }
156
        // add 'public' modifier
154
        MethodModel methodModelCopy = MethodModel.create(
157
        MethodModel methodModelCopy = MethodModel.create(
155
                methodModel.getName(),
158
                methodModel.getName(),
156
                methodModel.getReturnType(),
159
                methodModel.getReturnType(),
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/codegeneration/SessionGenerator.java (-5 / +43 lines)
Lines 44-55 Link Here
44
44
45
package org.netbeans.modules.j2ee.ejbcore.api.codegeneration;
45
package org.netbeans.modules.j2ee.ejbcore.api.codegeneration;
46
46
47
import java.util.List;
48
import org.netbeans.modules.j2ee.common.method.MethodModel.Annotation;
47
import org.netbeans.modules.j2ee.core.api.support.java.GenerationUtils;
49
import org.netbeans.modules.j2ee.core.api.support.java.GenerationUtils;
48
import org.netbeans.modules.j2ee.ejbcore.EjbGenerationUtil;
50
import org.netbeans.modules.j2ee.ejbcore.EjbGenerationUtil;
49
import java.io.IOException;
51
import java.io.IOException;
52
import java.util.Collections;
50
import java.util.HashMap;
53
import java.util.HashMap;
51
import java.util.Map;
54
import java.util.Map;
55
import java.util.logging.Level;
52
import java.util.logging.Logger;
56
import java.util.logging.Logger;
57
import javax.lang.model.element.Modifier;
53
import org.netbeans.api.java.classpath.ClassPath;
58
import org.netbeans.api.java.classpath.ClassPath;
54
import org.netbeans.api.java.project.JavaProjectConstants;
59
import org.netbeans.api.java.project.JavaProjectConstants;
55
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
60
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
Lines 63-70 Link Here
63
import org.netbeans.api.project.libraries.Library;
68
import org.netbeans.api.project.libraries.Library;
64
import org.netbeans.api.project.libraries.LibraryManager;
69
import org.netbeans.api.project.libraries.LibraryManager;
65
import org.netbeans.modules.j2ee.common.J2eeProjectCapabilities;
70
import org.netbeans.modules.j2ee.common.J2eeProjectCapabilities;
71
import org.netbeans.modules.j2ee.common.method.MethodModel;
66
import org.netbeans.modules.j2ee.dd.api.ejb.AssemblyDescriptor;
72
import org.netbeans.modules.j2ee.dd.api.ejb.AssemblyDescriptor;
67
import org.netbeans.modules.j2ee.dd.api.ejb.ContainerTransaction;
73
import org.netbeans.modules.j2ee.dd.api.ejb.ContainerTransaction;
74
import org.netbeans.modules.j2ee.ejbcore.action.BusinessMethodGenerator;
75
import org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.TimerOptions;
68
import org.netbeans.modules.j2ee.ejbcore.naming.EJBNameOptions;
76
import org.netbeans.modules.j2ee.ejbcore.naming.EJBNameOptions;
69
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileObject;
70
import org.openide.filesystems.FileUtil;
78
import org.openide.filesystems.FileUtil;
Lines 103-108 Link Here
103
    private final boolean isSimplified;
111
    private final boolean isSimplified;
104
//    private final boolean hasBusinessInterface;
112
//    private final boolean hasBusinessInterface;
105
    private final boolean isXmlBased;
113
    private final boolean isXmlBased;
114
    private final TimerOptions timerOptions;
106
    
115
    
107
    // EJB naming options
116
    // EJB naming options
108
    private final EJBNameOptions ejbNameOptions;
117
    private final EJBNameOptions ejbNameOptions;
Lines 119-131 Link Here
119
128
120
    private final Map<String, String> templateParameters;
129
    private final Map<String, String> templateParameters;
121
130
122
    public static SessionGenerator create(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal, 
131
    public static SessionGenerator create(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal,
123
            String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased) {
132
            String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, TimerOptions timerOptions) {
124
        return new SessionGenerator(wizardTargetName, pkg, hasRemote, hasLocal, sessionType, isSimplified, hasBusinessInterface, isXmlBased, false);
133
        return new SessionGenerator(wizardTargetName, pkg, hasRemote, hasLocal, sessionType, isSimplified, hasBusinessInterface, isXmlBased, timerOptions, false);
125
    } 
134
    }
126
    
135
    
127
    protected SessionGenerator(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal, 
136
    protected SessionGenerator(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal, 
128
            String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, boolean isTest) {
137
            String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, TimerOptions timerOptions, boolean isTest) {
129
        this.pkg = pkg;
138
        this.pkg = pkg;
130
        this.remotePkg = pkg;
139
        this.remotePkg = pkg;
131
        this.hasRemote = hasRemote;
140
        this.hasRemote = hasRemote;
Lines 149-154 Link Here
149
        this.templateParameters.put("package", packageName);
158
        this.templateParameters.put("package", packageName);
150
        this.templateParameters.put("localInterface", packageNameWithDot + localName);
159
        this.templateParameters.put("localInterface", packageNameWithDot + localName);
151
        this.templateParameters.put("remoteInterface", packageNameWithDot + remoteName);
160
        this.templateParameters.put("remoteInterface", packageNameWithDot + remoteName);
161
        // set timer options if available
162
        this.timerOptions = timerOptions;
152
        if (isTest) {
163
        if (isTest) {
153
            // set date, time and user to values used in goldenfiles
164
            // set date, time and user to values used in goldenfiles
154
            this.templateParameters.put("date", "{date}");
165
            this.templateParameters.put("date", "{date}");
Lines 260-265 Link Here
260
        if (hasLocal) {
271
        if (hasLocal) {
261
            GenerationUtils.createClass(EJB30_LOCAL, pkg, localName, null, templateParameters);
272
            GenerationUtils.createClass(EJB30_LOCAL, pkg, localName, null, templateParameters);
262
        }
273
        }
274
275
        // fill up the session bean with the timer method if needed
276
        if (timerOptions != null) {
277
            generateTimerMethodForBean(ejbClassFO, "myTimer", timerOptions);
278
        }
279
263
        return ejbClassFO;
280
        return ejbClassFO;
264
    }
281
    }
265
282
Lines 318-323 Link Here
318
    private void generateEJB30Xml() throws IOException {
335
    private void generateEJB30Xml() throws IOException {
319
        throw new UnsupportedOperationException("Method not implemented yet.");
336
        throw new UnsupportedOperationException("Method not implemented yet.");
320
    }
337
    }
338
339
    private void generateTimerMethodForBean(FileObject bean, String methodName, TimerOptions timerOptions) {
340
        try {
341
            MethodModel.Annotation annotation = MethodModel.Annotation.create(
342
                    "javax.ejb.Schedule", timerOptions.getTimerOptionsAsMap()); // NOI18N
343
            MethodModel method = MethodModel.create(
344
                    methodName,
345
                    "void", // NOI18N
346
                    "System.out.println(\"Timer event: \" + new java.util.Date());", // NOI18N
347
                    Collections.<MethodModel.Variable>emptyList(),
348
                    Collections.<String>emptyList(),
349
                    Collections.<Modifier>emptySet(), 
350
                    Collections.singletonList(annotation)
351
                    );
352
353
                BusinessMethodGenerator generator = BusinessMethodGenerator.create(packageNameWithDot + ejbClassName, bean);
354
                generator.generate(method, hasLocal, hasRemote);
355
        } catch (IOException ex) {
356
            Logger.getLogger(SessionGenerator.class.getName()).log(Level.SEVERE, null, ex);
357
        }
358
    }
321
    
359
    
322
      //TODO: RETOUCHE WS
360
      //TODO: RETOUCHE WS
323
//    /**
361
//    /**
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties (+10 lines)
Lines 56-61 Link Here
56
56
57
# wizard templates
57
# wizard templates
58
Templates/J2EE/Session=Session Bean
58
Templates/J2EE/Session=Session Bean
59
Templates/J2EE/TimerSession=Timer Session Bean
59
60
60
LBL_Remote=Remote
61
LBL_Remote=Remote
61
62
Lines 70-75 Link Here
70
LBL_Singleton=Singleton
71
LBL_Singleton=Singleton
71
72
72
LBL_SessionEJBWizardTitle=Session Bean
73
LBL_SessionEJBWizardTitle=Session Bean
74
LBL_TimerSessionEJBWizardTitle=Timer Session Bean
73
75
74
LBL_Interface=Create Interface\:
76
LBL_Interface=Create Interface\:
75
LBL_EJB_Name=EJB Name:
77
LBL_EJB_Name=EJB Name:
Lines 95-97 Link Here
95
ERR_NoRemoteInterfaceProjectMaven=<html>There is no suitable project available into which \
97
ERR_NoRemoteInterfaceProjectMaven=<html>There is no suitable project available into which \
96
    Remote interface could be stored. An open Maven based Java Class Library project is required.
98
    Remote interface could be stored. An open Maven based Java Class Library project is required.
97
LBL_In_Project=Remote in project:
99
LBL_In_Project=Remote in project:
100
LBL_Schedule=Method schedule:
101
MN_Schedule=M
102
103
ERR_TO_ToMuchAttributes=Method schedule should have maximally ten attributes
104
ERR_TO_NotEnoughAttributes=At least one attribute should be specified in Method schedule
105
ERR_TO_InvalidAtributes=Invalid attributes for Method schedule: {0}
106
ERR_TO_UnparsableSchedule=Failed to parse Method schedule text
107
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizard.java (-9 / +19 lines)
Lines 58-64 Link Here
58
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
59
import org.netbeans.modules.j2ee.core.api.support.SourceGroups;
59
import org.netbeans.modules.j2ee.core.api.support.SourceGroups;
60
import org.netbeans.modules.j2ee.core.api.support.wizard.Wizards;
60
import org.netbeans.modules.j2ee.core.api.support.wizard.Wizards;
61
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
62
import org.netbeans.modules.j2ee.ejbcore.ejb.wizard.MultiTargetChooserPanel;
61
import org.netbeans.modules.j2ee.ejbcore.ejb.wizard.MultiTargetChooserPanel;
63
import org.openide.WizardDescriptor;
62
import org.openide.WizardDescriptor;
64
import org.openide.util.Exceptions;
63
import org.openide.util.Exceptions;
Lines 69-88 Link Here
69
 * @author Chris Webster
68
 * @author Chris Webster
70
 * @author Martin Adamek
69
 * @author Martin Adamek
71
 */
70
 */
72
public final class SessionEJBWizard implements WizardDescriptor.InstantiatingIterator{
71
public final class SessionEJBWizard implements WizardDescriptor.AsynchronousInstantiatingIterator {
73
72
74
    private WizardDescriptor.Panel[] panels;
73
    private WizardDescriptor.Panel[] panels;
75
    private int index = 0;
74
    private int index = 0;
76
    private SessionEJBWizardDescriptor ejbPanel;
75
    private SessionEJBWizardDescriptor ejbPanel;
77
    private WizardDescriptor wiz;
76
    private WizardDescriptor wiz;
77
    private TimerOptions timerOptions;
78
    private String resourceWizardName;
78
79
79
    public static SessionEJBWizard create () {
80
    public SessionEJBWizard(String resourceWizardName, TimerOptions timerOptions) {
80
        return new SessionEJBWizard ();
81
        this.resourceWizardName = resourceWizardName;
82
        this.timerOptions = timerOptions;
81
    }
83
    }
82
84
83
    public String name () {
85
    public static SessionEJBWizard createSession() {
84
    return NbBundle.getMessage (SessionEJBWizard.class,
86
        return new SessionEJBWizard("LBL_SessionEJBWizardTitle", null); //NOI18N
85
                     "LBL_SessionEJBWizardTitle");
87
    }
88
89
    public static SessionEJBWizard createTimerSession() {
90
        return new SessionEJBWizard("LBL_TimerSessionEJBWizardTitle", new TimerOptions()); //NOI18N
91
    }
92
93
    public String name() {
94
        return NbBundle.getMessage (SessionEJBWizard.class, resourceWizardName);
86
    }
95
    }
87
96
88
    public void uninitialize(WizardDescriptor wiz) {
97
    public void uninitialize(WizardDescriptor wiz) {
Lines 92-98 Link Here
92
        wiz = wizardDescriptor;
101
        wiz = wizardDescriptor;
93
        Project project = Templates.getProject(wiz);
102
        Project project = Templates.getProject(wiz);
94
        SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project);
103
        SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project);
95
        ejbPanel = new SessionEJBWizardDescriptor(project);
104
        ejbPanel = new SessionEJBWizardDescriptor(project, timerOptions);
96
        WizardDescriptor.Panel wizardDescriptorPanel = new MultiTargetChooserPanel(project, sourceGroups, ejbPanel, true);
105
        WizardDescriptor.Panel wizardDescriptorPanel = new MultiTargetChooserPanel(project, sourceGroups, ejbPanel, true);
97
106
98
        panels = new WizardDescriptor.Panel[] {wizardDescriptorPanel};
107
        panels = new WizardDescriptor.Panel[] {wizardDescriptorPanel};
Lines 113-119 Link Here
113
                ejbPanel.getSessionType(),
122
                ejbPanel.getSessionType(),
114
                isSimplified, 
123
                isSimplified, 
115
                true, // TODO: UI - add checkbox for creation of business interface
124
                true, // TODO: UI - add checkbox for creation of business interface
116
                !isSimplified // TODO: UI - add checkbox for option XML (not annotation) usage
125
                !isSimplified, // TODO: UI - add checkbox for option XML (not annotation) usage
126
                ejbPanel.getTimerOptions()
117
                );
127
                );
118
        FileObject result = null;
128
        FileObject result = null;
119
        try {
129
        try {
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardDescriptor.java (-2 / +15 lines)
Lines 65-70 Link Here
65
    private SessionEJBWizardPanel wizardPanel;
65
    private SessionEJBWizardPanel wizardPanel;
66
    private final EJBNameOptions ejbNames;
66
    private final EJBNameOptions ejbNames;
67
    private final Project project;
67
    private final Project project;
68
    private final TimerOptions timerOptions;
68
    //TODO: RETOUCHE
69
    //TODO: RETOUCHE
69
//    private boolean isWaitingForScan = false;
70
//    private boolean isWaitingForScan = false;
70
    
71
    
Lines 72-79 Link Here
72
73
73
    private WizardDescriptor wizardDescriptor;
74
    private WizardDescriptor wizardDescriptor;
74
75
75
    public SessionEJBWizardDescriptor(Project project) {
76
    public SessionEJBWizardDescriptor(Project project, TimerOptions timerOptions) {
76
        this.ejbNames = new EJBNameOptions();
77
        this.ejbNames = new EJBNameOptions();
78
        this.timerOptions = timerOptions;
77
        this.project = project;
79
        this.project = project;
78
    }
80
    }
79
    
81
    
Lines 83-89 Link Here
83
    
85
    
84
    public java.awt.Component getComponent() {
86
    public java.awt.Component getComponent() {
85
        if (wizardPanel == null) {
87
        if (wizardPanel == null) {
86
            wizardPanel = new SessionEJBWizardPanel(project, this);
88
            wizardPanel = new SessionEJBWizardPanel(project, this, timerOptions);
87
            // add listener to events which could cause valid status to change
89
            // add listener to events which could cause valid status to change
88
        }
90
        }
89
        return wizardPanel;
91
        return wizardPanel;
Lines 141-146 Link Here
141
            wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(SessionEJBWizardDescriptor.class, "ERR_CyclicDependency"));
143
            wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(SessionEJBWizardDescriptor.class, "ERR_CyclicDependency"));
142
            return false;
144
            return false;
143
        }
145
        }
146
        
147
        // check Schedule section if valid
148
        String timerOptionsError = wizardPanel.getTimerOptionsError();
149
        if (timerOptionsError != null) {
150
            wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, timerOptionsError);
151
            return false;
152
        }
144
153
145
        //TODO: RETOUCHE waitScanFinished
154
        //TODO: RETOUCHE waitScanFinished
146
//        if (JavaMetamodel.getManager().isScanInProgress()) {
155
//        if (JavaMetamodel.getManager().isScanInProgress()) {
Lines 191-196 Link Here
191
    public String getSessionType() {
200
    public String getSessionType() {
192
        return wizardPanel.getSessionType();
201
        return wizardPanel.getSessionType();
193
    }
202
    }
203
204
    public TimerOptions getTimerOptions() {
205
        return wizardPanel.getTimerOptions();
206
    }
194
    
207
    
195
    public boolean isFinishPanel() {
208
    public boolean isFinishPanel() {
196
        return isValid();
209
        return isValid();
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.form (-35 / +131 lines)
Lines 4-9 Link Here
4
  <NonVisualComponents>
4
  <NonVisualComponents>
5
    <Component class="javax.swing.ButtonGroup" name="sessionStateButtons">
5
    <Component class="javax.swing.ButtonGroup" name="sessionStateButtons">
6
    </Component>
6
    </Component>
7
    <Container class="javax.swing.JInternalFrame" name="jInternalFrame1">
8
      <Properties>
9
        <Property name="visible" type="boolean" value="true"/>
10
      </Properties>
11
12
      <Layout>
13
        <DimensionLayout dim="0">
14
          <Group type="103" groupAlignment="0" attributes="0">
15
              <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
16
          </Group>
17
        </DimensionLayout>
18
        <DimensionLayout dim="1">
19
          <Group type="103" groupAlignment="0" attributes="0">
20
              <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
21
          </Group>
22
        </DimensionLayout>
23
      </Layout>
24
    </Container>
7
  </NonVisualComponents>
25
  </NonVisualComponents>
8
  <AuxValues>
26
  <AuxValues>
9
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
27
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
Lines 20-63 Link Here
20
  <Layout>
38
  <Layout>
21
    <DimensionLayout dim="0">
39
    <DimensionLayout dim="0">
22
      <Group type="103" groupAlignment="0" attributes="0">
40
      <Group type="103" groupAlignment="0" attributes="0">
41
          <Component id="sessionTypeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
42
          <Group type="102" alignment="0" attributes="0">
43
              <EmptySpace min="-2" max="-2" attributes="0"/>
44
              <Component id="statelessButton" min="-2" max="-2" attributes="0"/>
45
          </Group>
46
          <Group type="102" alignment="0" attributes="0">
47
              <EmptySpace min="-2" max="-2" attributes="0"/>
48
              <Component id="statefulButton" min="-2" max="-2" attributes="0"/>
49
          </Group>
50
          <Group type="102" alignment="0" attributes="0">
51
              <EmptySpace max="-2" attributes="0"/>
52
              <Component id="singletonButton" min="-2" max="-2" attributes="0"/>
53
          </Group>
54
          <Component id="interfaceLabel" alignment="0" min="-2" max="-2" attributes="0"/>
23
          <Group type="102" attributes="0">
55
          <Group type="102" attributes="0">
56
              <EmptySpace max="-2" attributes="0"/>
24
              <Group type="103" groupAlignment="0" attributes="0">
57
              <Group type="103" groupAlignment="0" attributes="0">
25
                  <Component id="sessionTypeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
58
                  <Component id="remoteCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
26
                  <Group type="102" alignment="0" attributes="0">
59
                  <Component id="localCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
27
                      <EmptySpace min="-2" max="-2" attributes="0"/>
28
                      <Component id="statelessButton" min="-2" max="-2" attributes="0"/>
29
                  </Group>
30
                  <Group type="102" alignment="0" attributes="0">
31
                      <EmptySpace min="-2" max="-2" attributes="0"/>
32
                      <Component id="statefulButton" min="-2" max="-2" attributes="0"/>
33
                  </Group>
34
                  <Group type="102" alignment="0" attributes="0">
35
                      <EmptySpace max="-2" attributes="0"/>
36
                      <Component id="singletonButton" min="-2" max="-2" attributes="0"/>
37
                  </Group>
38
                  <Component id="interfaceLabel" alignment="0" min="-2" max="-2" attributes="0"/>
39
                  <Group type="102" attributes="0">
40
                      <EmptySpace max="-2" attributes="0"/>
41
                      <Group type="103" groupAlignment="0" attributes="0">
42
                          <Group type="102" alignment="0" attributes="0">
43
                              <Component id="remoteCheckBox" min="-2" max="-2" attributes="0"/>
44
                              <EmptySpace min="6" pref="6" max="-2" attributes="0"/>
45
                              <Component id="inProjectCombo" pref="131" max="32767" attributes="0"/>
46
                          </Group>
47
                          <Group type="102" attributes="0">
48
                              <Component id="localCheckBox" min="-2" max="-2" attributes="0"/>
49
                              <EmptySpace pref="155" max="32767" attributes="0"/>
50
                          </Group>
51
                      </Group>
52
                  </Group>
53
              </Group>
60
              </Group>
54
              <EmptySpace max="-2" attributes="0"/>
61
              <EmptySpace max="-2" attributes="0"/>
62
              <Component id="inProjectCombo" pref="234" max="32767" attributes="0"/>
63
              <EmptySpace max="-2" attributes="0"/>
55
          </Group>
64
          </Group>
65
          <Component id="schedulePanel" alignment="0" max="32767" attributes="0"/>
56
      </Group>
66
      </Group>
57
    </DimensionLayout>
67
    </DimensionLayout>
58
    <DimensionLayout dim="1">
68
    <DimensionLayout dim="1">
59
      <Group type="103" groupAlignment="0" attributes="0">
69
      <Group type="103" groupAlignment="0" attributes="0">
60
          <Group type="102" alignment="0" attributes="0">
70
          <Group type="102" attributes="0">
61
              <Component id="sessionTypeLabel" min="-2" max="-2" attributes="0"/>
71
              <Component id="sessionTypeLabel" min="-2" max="-2" attributes="0"/>
62
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
72
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
63
              <Component id="statelessButton" min="-2" max="-2" attributes="0"/>
73
              <Component id="statelessButton" min="-2" max="-2" attributes="0"/>
Lines 67-79 Link Here
67
              <Component id="singletonButton" min="-2" max="-2" attributes="0"/>
77
              <Component id="singletonButton" min="-2" max="-2" attributes="0"/>
68
              <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
78
              <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
69
              <Component id="interfaceLabel" min="-2" max="-2" attributes="0"/>
79
              <Component id="interfaceLabel" min="-2" max="-2" attributes="0"/>
70
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
80
              <EmptySpace max="-2" attributes="0"/>
71
              <Component id="localCheckBox" min="-2" max="-2" attributes="0"/>
81
              <Group type="103" groupAlignment="1" attributes="0">
72
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
82
                  <Group type="102" attributes="0">
73
              <Group type="103" groupAlignment="3" attributes="0">
83
                      <Component id="localCheckBox" min="-2" max="-2" attributes="0"/>
74
                  <Component id="remoteCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
84
                      <EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
75
                  <Component id="inProjectCombo" alignment="3" min="-2" max="-2" attributes="0"/>
85
                      <Component id="remoteCheckBox" min="-2" max="-2" attributes="0"/>
86
                  </Group>
87
                  <Component id="inProjectCombo" min="-2" pref="28" max="-2" attributes="0"/>
76
              </Group>
88
              </Group>
89
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
90
              <Component id="schedulePanel" min="-2" max="-2" attributes="0"/>
77
          </Group>
91
          </Group>
78
      </Group>
92
      </Group>
79
    </DimensionLayout>
93
    </DimensionLayout>
Lines 202-206 Link Here
202
    </Component>
216
    </Component>
203
    <Component class="javax.swing.JComboBox" name="inProjectCombo">
217
    <Component class="javax.swing.JComboBox" name="inProjectCombo">
204
    </Component>
218
    </Component>
219
    <Container class="javax.swing.JPanel" name="schedulePanel">
220
221
      <Layout>
222
        <DimensionLayout dim="0">
223
          <Group type="103" groupAlignment="0" attributes="0">
224
              <Group type="102" alignment="0" attributes="0">
225
                  <EmptySpace max="-2" attributes="0"/>
226
                  <Group type="103" groupAlignment="0" attributes="0">
227
                      <Component id="scheduleScrollPane" alignment="0" pref="333" max="32767" attributes="0"/>
228
                      <Group type="102" alignment="0" attributes="0">
229
                          <Component id="scheduleLabel" min="-2" max="-2" attributes="0"/>
230
                          <EmptySpace pref="206" max="32767" attributes="0"/>
231
                      </Group>
232
                  </Group>
233
              </Group>
234
          </Group>
235
        </DimensionLayout>
236
        <DimensionLayout dim="1">
237
          <Group type="103" groupAlignment="0" attributes="0">
238
              <Group type="102" alignment="0" attributes="0">
239
                  <Component id="scheduleLabel" min="-2" max="-2" attributes="0"/>
240
                  <EmptySpace max="-2" attributes="0"/>
241
                  <Component id="scheduleScrollPane" min="-2" max="-2" attributes="0"/>
242
                  <EmptySpace max="-2" attributes="0"/>
243
              </Group>
244
          </Group>
245
        </DimensionLayout>
246
      </Layout>
247
      <SubComponents>
248
        <Component class="javax.swing.JLabel" name="scheduleLabel">
249
          <Properties>
250
            <Property name="displayedMnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
251
              <ResourceString bundle="org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties" key="MN_Schedule" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
252
            </Property>
253
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
254
              <ComponentRef name="scheduleTextArea"/>
255
            </Property>
256
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
257
              <ResourceString bundle="org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties" key="LBL_Schedule" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
258
            </Property>
259
            <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
260
              <Color id="Default Cursor"/>
261
            </Property>
262
          </Properties>
263
          <AccessibilityProperties>
264
            <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
265
              <ResourceString bundle="org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties" key="LBL_Schedule" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
266
            </Property>
267
          </AccessibilityProperties>
268
          <AuxValues>
269
            <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="SessionEJBWizardPanel_scheduleLabel"/>
270
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
271
          </AuxValues>
272
        </Component>
273
        <Container class="javax.swing.JScrollPane" name="scheduleScrollPane">
274
          <AuxValues>
275
            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
276
          </AuxValues>
277
278
          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
279
          <SubComponents>
280
            <Component class="javax.swing.JTextArea" name="scheduleTextArea">
281
              <Properties>
282
                <Property name="columns" type="int" value="20"/>
283
                <Property name="lineWrap" type="boolean" value="true"/>
284
                <Property name="rows" type="int" value="4"/>
285
                <Property name="text" type="java.lang.String" value="minute=&quot;*&quot;, second=&quot;0&quot;, dayOfMonth=&quot;*&quot;, month=&quot;*&quot;, year=&quot;*&quot;, hour=&quot;9-17&quot;, dayOfWeek=&quot;Mon-Fri&quot;" noResource="true"/>
286
                <Property name="wrapStyleWord" type="boolean" value="true"/>
287
                <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
288
                  <Color id="Text Cursor"/>
289
                </Property>
290
              </Properties>
291
              <AccessibilityProperties>
292
                <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
293
                  <ResourceString bundle="org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties" key="LBL_Schedule" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
294
                </Property>
295
              </AccessibilityProperties>
296
            </Component>
297
          </SubComponents>
298
        </Container>
299
      </SubComponents>
300
    </Container>
205
  </SubComponents>
301
  </SubComponents>
206
</Form>
302
</Form>
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.java (-28 / +127 lines)
Lines 56-61 Link Here
56
import javax.swing.JList;
56
import javax.swing.JList;
57
import javax.swing.ListCellRenderer;
57
import javax.swing.ListCellRenderer;
58
import javax.swing.event.ChangeListener;
58
import javax.swing.event.ChangeListener;
59
import javax.swing.event.DocumentEvent;
60
import javax.swing.event.DocumentListener;
59
import org.netbeans.api.j2ee.core.Profile;
61
import org.netbeans.api.j2ee.core.Profile;
60
import org.netbeans.api.java.project.JavaProjectConstants;
62
import org.netbeans.api.java.project.JavaProjectConstants;
61
import org.netbeans.api.project.Project;
63
import org.netbeans.api.project.Project;
Lines 78-89 Link Here
78
    private final ChangeListener listener;
80
    private final ChangeListener listener;
79
    private final Project project;
81
    private final Project project;
80
    private ComboBoxModel projectsList;
82
    private ComboBoxModel projectsList;
83
    private final TimerOptions timerOptions;
81
84
82
85
83
    /** Creates new form SingleEJBWizardPanel */
86
    /** Creates new form SingleEJBWizardPanel */
84
    public SessionEJBWizardPanel(Project project, ChangeListener changeListener) {
87
    public SessionEJBWizardPanel(Project project, ChangeListener changeListener, TimerOptions timerOptions) {
85
        this.listener = changeListener;
88
        this.listener = changeListener;
86
        this.project = project;
89
        this.project = project;
90
        this.timerOptions = timerOptions;
87
        initComponents();
91
        initComponents();
88
92
89
        J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
93
        J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
Lines 93-99 Link Here
93
                remoteCheckBox.setVisible(false);
97
                remoteCheckBox.setVisible(false);
94
                remoteCheckBox.setEnabled(false);
98
                remoteCheckBox.setEnabled(false);
95
            }
99
            }
100
            // enable Schedule section if Timer Session EJB, disable otherwise
101
            if (this.timerOptions == null) {
102
                schedulePanel.setVisible(false);
103
                schedulePanel.setEnabled(false);
104
            }  else {
105
                statefulButton.setEnabled(false);
106
                statefulButton.setVisible(false);
107
            }
96
        } else {
108
        } else {
109
            // hide whole Schedule section
110
            schedulePanel.setVisible(false);
111
            schedulePanel.setEnabled(false);
112
            // hide singleton radio button
97
            singletonButton.setVisible(false);
113
            singletonButton.setVisible(false);
98
            singletonButton.setEnabled(false);
114
            singletonButton.setEnabled(false);
99
            localCheckBox.setSelected(true);
115
            localCheckBox.setSelected(true);
Lines 117-122 Link Here
117
                updateInProjectCombo(remoteCheckBox.isSelected());
133
                updateInProjectCombo(remoteCheckBox.isSelected());
118
            }
134
            }
119
        });
135
        });
136
        scheduleTextArea.getDocument().addDocumentListener(new DocumentListener() {
137
            public void insertUpdate(DocumentEvent e) {
138
                listener.stateChanged(null);
139
            }
140
            public void removeUpdate(DocumentEvent e) {
141
                listener.stateChanged(null);
142
            }
143
            public void changedUpdate(DocumentEvent e) {
144
                listener.stateChanged(null);
145
            }
146
        });
120
        updateInProjectCombo(false);
147
        updateInProjectCombo(false);
121
    }
148
    }
122
149
Lines 191-196 Link Here
191
    private void initComponents() {
218
    private void initComponents() {
192
219
193
        sessionStateButtons = new javax.swing.ButtonGroup();
220
        sessionStateButtons = new javax.swing.ButtonGroup();
221
        jInternalFrame1 = new javax.swing.JInternalFrame();
194
        sessionTypeLabel = new javax.swing.JLabel();
222
        sessionTypeLabel = new javax.swing.JLabel();
195
        statelessButton = new javax.swing.JRadioButton();
223
        statelessButton = new javax.swing.JRadioButton();
196
        statefulButton = new javax.swing.JRadioButton();
224
        statefulButton = new javax.swing.JRadioButton();
Lines 199-204 Link Here
199
        localCheckBox = new javax.swing.JCheckBox();
227
        localCheckBox = new javax.swing.JCheckBox();
200
        singletonButton = new javax.swing.JRadioButton();
228
        singletonButton = new javax.swing.JRadioButton();
201
        inProjectCombo = new javax.swing.JComboBox();
229
        inProjectCombo = new javax.swing.JComboBox();
230
        schedulePanel = new javax.swing.JPanel();
231
        scheduleLabel = new javax.swing.JLabel();
232
        scheduleScrollPane = new javax.swing.JScrollPane();
233
        scheduleTextArea = new javax.swing.JTextArea();
234
235
        jInternalFrame1.setVisible(true);
236
237
        org.jdesktop.layout.GroupLayout jInternalFrame1Layout = new org.jdesktop.layout.GroupLayout(jInternalFrame1.getContentPane());
238
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
239
        jInternalFrame1Layout.setHorizontalGroup(
240
            jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
241
            .add(0, 0, Short.MAX_VALUE)
242
        );
243
        jInternalFrame1Layout.setVerticalGroup(
244
            jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
245
            .add(0, 0, Short.MAX_VALUE)
246
        );
202
247
203
        org.openide.awt.Mnemonics.setLocalizedText(sessionTypeLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_SessionType")); // NOI18N
248
        org.openide.awt.Mnemonics.setLocalizedText(sessionTypeLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_SessionType")); // NOI18N
204
249
Lines 223-256 Link Here
223
        singletonButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_Singleton").charAt(0));
268
        singletonButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_Singleton").charAt(0));
224
        singletonButton.setText(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Singleton")); // NOI18N
269
        singletonButton.setText(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Singleton")); // NOI18N
225
270
271
        scheduleLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_Schedule").charAt(0));
272
        scheduleLabel.setLabelFor(scheduleTextArea);
273
        scheduleLabel.setText(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Schedule")); // NOI18N
274
        scheduleLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
275
276
        scheduleTextArea.setColumns(20);
277
        scheduleTextArea.setLineWrap(true);
278
        scheduleTextArea.setRows(4);
279
        scheduleTextArea.setText("minute=\"*\", second=\"0\", dayOfMonth=\"*\", month=\"*\", year=\"*\", hour=\"9-17\", dayOfWeek=\"Mon-Fri\""); // NOI18N
280
        scheduleTextArea.setWrapStyleWord(true);
281
        scheduleTextArea.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
282
        scheduleScrollPane.setViewportView(scheduleTextArea);
283
        scheduleTextArea.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Schedule")); // NOI18N
284
285
        org.jdesktop.layout.GroupLayout schedulePanelLayout = new org.jdesktop.layout.GroupLayout(schedulePanel);
286
        schedulePanel.setLayout(schedulePanelLayout);
287
        schedulePanelLayout.setHorizontalGroup(
288
            schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
289
            .add(schedulePanelLayout.createSequentialGroup()
290
                .addContainerGap()
291
                .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
292
                    .add(scheduleScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
293
                    .add(schedulePanelLayout.createSequentialGroup()
294
                        .add(scheduleLabel)
295
                        .addContainerGap(206, Short.MAX_VALUE))))
296
        );
297
        schedulePanelLayout.setVerticalGroup(
298
            schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
299
            .add(schedulePanelLayout.createSequentialGroup()
300
                .add(scheduleLabel)
301
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
302
                .add(scheduleScrollPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
303
                .addContainerGap())
304
        );
305
306
        scheduleLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Schedule")); // NOI18N
307
226
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
308
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
227
        this.setLayout(layout);
309
        this.setLayout(layout);
228
        layout.setHorizontalGroup(
310
        layout.setHorizontalGroup(
229
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
311
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
312
            .add(sessionTypeLabel)
230
            .add(layout.createSequentialGroup()
313
            .add(layout.createSequentialGroup()
314
                .addContainerGap()
315
                .add(statelessButton))
316
            .add(layout.createSequentialGroup()
317
                .addContainerGap()
318
                .add(statefulButton))
319
            .add(layout.createSequentialGroup()
320
                .addContainerGap()
321
                .add(singletonButton))
322
            .add(interfaceLabel)
323
            .add(layout.createSequentialGroup()
324
                .addContainerGap()
231
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
325
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
232
                    .add(sessionTypeLabel)
326
                    .add(remoteCheckBox)
233
                    .add(layout.createSequentialGroup()
327
                    .add(localCheckBox))
234
                        .addContainerGap()
328
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
235
                        .add(statelessButton))
329
                .add(inProjectCombo, 0, 234, Short.MAX_VALUE)
236
                    .add(layout.createSequentialGroup()
237
                        .addContainerGap()
238
                        .add(statefulButton))
239
                    .add(layout.createSequentialGroup()
240
                        .addContainerGap()
241
                        .add(singletonButton))
242
                    .add(interfaceLabel)
243
                    .add(layout.createSequentialGroup()
244
                        .addContainerGap()
245
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
246
                            .add(layout.createSequentialGroup()
247
                                .add(remoteCheckBox)
248
                                .add(6, 6, 6)
249
                                .add(inProjectCombo, 0, 129, Short.MAX_VALUE))
250
                            .add(layout.createSequentialGroup()
251
                                .add(localCheckBox)
252
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 152, Short.MAX_VALUE)))))
253
                .addContainerGap())
330
                .addContainerGap())
331
            .add(schedulePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
254
        );
332
        );
255
        layout.setVerticalGroup(
333
        layout.setVerticalGroup(
256
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
334
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
Lines 264-275 Link Here
264
                .add(singletonButton)
342
                .add(singletonButton)
265
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
343
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
266
                .add(interfaceLabel)
344
                .add(interfaceLabel)
267
                .add(0, 0, 0)
345
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
268
                .add(localCheckBox)
346
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
269
                .add(0, 0, 0)
347
                    .add(layout.createSequentialGroup()
270
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
348
                        .add(localCheckBox)
271
                    .add(remoteCheckBox)
349
                        .add(2, 2, 2)
272
                    .add(inProjectCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
350
                        .add(remoteCheckBox))
351
                    .add(inProjectCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
352
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
353
                .add(schedulePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
273
        );
354
        );
274
355
275
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle"); // NOI18N
356
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle"); // NOI18N
Lines 287-294 Link Here
287
    // Variables declaration - do not modify//GEN-BEGIN:variables
368
    // Variables declaration - do not modify//GEN-BEGIN:variables
288
    private javax.swing.JComboBox inProjectCombo;
369
    private javax.swing.JComboBox inProjectCombo;
289
    private javax.swing.JLabel interfaceLabel;
370
    private javax.swing.JLabel interfaceLabel;
371
    private javax.swing.JInternalFrame jInternalFrame1;
290
    private javax.swing.JCheckBox localCheckBox;
372
    private javax.swing.JCheckBox localCheckBox;
291
    private javax.swing.JCheckBox remoteCheckBox;
373
    private javax.swing.JCheckBox remoteCheckBox;
374
    private javax.swing.JLabel scheduleLabel;
375
    private javax.swing.JPanel schedulePanel;
376
    private javax.swing.JScrollPane scheduleScrollPane;
377
    private javax.swing.JTextArea scheduleTextArea;
292
    private javax.swing.ButtonGroup sessionStateButtons;
378
    private javax.swing.ButtonGroup sessionStateButtons;
293
    private javax.swing.JLabel sessionTypeLabel;
379
    private javax.swing.JLabel sessionTypeLabel;
294
    private javax.swing.JRadioButton singletonButton;
380
    private javax.swing.JRadioButton singletonButton;
Lines 316-321 Link Here
316
        return localCheckBox.isSelected();
402
        return localCheckBox.isSelected();
317
    }
403
    }
318
404
405
    public TimerOptions getTimerOptions() {
406
        if (timerOptions == null) {
407
            return null;
408
        } else {
409
            timerOptions.setTimerOptions(scheduleTextArea.getText());            
410
            return timerOptions;
411
        }
412
    }
413
    
414
    public String getTimerOptionsError() {
415
        return TimerOptions.validate(scheduleTextArea.getText());
416
    }
417
    
319
    public Project getRemoteInterfaceProject() {
418
    public Project getRemoteInterfaceProject() {
320
        if (projectsList == null) {
419
        if (projectsList == null) {
321
            return null;
420
            return null;
(-)58788128ca1f (+172 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session;
44
45
import java.util.ArrayList;
46
import java.util.Arrays;
47
import java.util.HashMap;
48
import java.util.HashSet;
49
import java.util.List;
50
import java.util.Map;
51
import java.util.Set;
52
import org.openide.util.NbBundle;
53
54
/**
55
 * Class which is holding information for creation of {@code @Schedule} annotation
56
 * 
57
 * @author Martin Fousek
58
 */
59
public final class TimerOptions {
60
61
    private Map<String, String> timerOptions = new HashMap<String, String>();
62
    private static Set<String> scheduleAttributes = new HashSet<String>(
63
            Arrays.asList("second", "minute", "hour", "dayOfMonth", "month", 
64
            "dayOfWeek", "year", "info", "persistent", "timezone") //NOI18N
65
        );
66
67
    /**
68
     * Get {@code Map} with entries of {@code @Schedule} annotation
69
     * @return {@code Map} of entries
70
     */
71
    public Map<String, String> getTimerOptionsAsMap() {
72
        return timerOptions;
73
    }
74
75
    /**
76
     * Set values into {@code Map} of {@code @Schedule} annotation entries, if valid
77
     * @param scheduleString {@code String} which will be parsed for all attributes,
78
     * the value of {@code TimerOption} change just in case of valid scheduleString
79
     */
80
    public void setTimerOptions(String scheduleString) {
81
        if (validate(scheduleString) == null) {
82
            String[] sections = splitScheduleSections(omitNewLines(scheduleString));
83
            parseSectionsIntoMap(sections, timerOptions);
84
        }
85
    }
86
    
87
    /**
88
     * Check if given scheduleString can be successfully parsed for annotation attributes
89
     * @param scheduleString input string for parsing
90
     * @return {@code String} with error message, {@code null} otherwise
91
     */
92
    public static String validate(String scheduleString) {
93
        String[] sections = splitScheduleSections(omitNewLines(scheduleString));
94
        
95
        Map<String, String> actualSchedule = new HashMap<String, String>();
96
        if (!parseSectionsIntoMap(sections, actualSchedule)) {
97
            return NbBundle.getMessage(TimerOptions.class, "ERR_TO_UnparsableSchedule"); //NOI18N
98
        }
99
        
100
        if (actualSchedule.isEmpty()) {
101
            return NbBundle.getMessage(TimerOptions.class, "ERR_TO_NotEnoughAttributes"); //NOI18N
102
        }
103
        else if (actualSchedule.size() > 10) {
104
            return NbBundle.getMessage(TimerOptions.class, "ERR_TO_ToMuchAttributes"); //NOI18N
105
        }
106
        else {
107
            String invalidAttributesString = invalidAttributes(actualSchedule.keySet());
108
            if (invalidAttributesString != null) {
109
                return NbBundle.getMessage(TimerOptions.class, "ERR_TO_InvalidAtributes", invalidAttributesString); //NOI18N
110
            } 
111
        }
112
        return null;       
113
    }
114
    
115
    private static String omitNewLines(String string) {
116
        return string.replaceAll("\n", ""); //NOI18N
117
    }
118
    
119
    private static String[] splitScheduleSections(String scheduleValue) {
120
        String[] sections = scheduleValue.split(","); //NOI18N
121
        List<String> finalSections = new ArrayList<String>();
122
        StringBuilder sb = new StringBuilder();
123
        for (int i = 0; i < sections.length; i++) {            
124
            sb.append(sections[i]);
125
            if (getCountOfQuotes(sb.toString()) < 2) {
126
                sb.append(","); //NOI18N
127
                continue;
128
            }
129
            finalSections.add(sb.toString());
130
            sb = new StringBuilder();
131
        }
132
        
133
        return finalSections.toArray(new String[finalSections.size()]);
134
    }
135
    
136
    private static int getCountOfQuotes(String string) {
137
        int count = string.split("\"").length - 1; //NOI18N
138
        if (string.endsWith("\"") || string.startsWith("\"")) //NOI18N
139
            return count + 1;
140
        else 
141
            return count;
142
    }
143
    
144
    private static boolean parseSectionsIntoMap(String[] sections, Map<String, String> map) {
145
        for (String section : sections) {
146
            String[] row = section.split("="); //NOI18N
147
            if (row.length != 2) {
148
                return false;
149
            } else {
150
                map.put(row[0].trim(), row[1].trim().replaceAll("\"", "")); //NOI18N
151
            }
152
        }
153
        return true;
154
    }
155
    
156
    private static String invalidAttributes(Set<String> actualAttributes) {
157
        Set<String> copy = new HashSet<String>(actualAttributes);
158
        copy.removeAll(scheduleAttributes);
159
        
160
        if (copy.isEmpty()) {
161
            return null;
162
        } else {
163
            StringBuilder invalidAttributes = new StringBuilder();
164
            for (String attribute : copy) {
165
                invalidAttributes.append(attribute).append(", "); //NOI18N
166
            }
167
            return invalidAttributes.substring(0, invalidAttributes.length() - 2);
168
        }
169
    }
170
    
171
172
}
(-)58788128ca1f (+51 lines)
Added Link Here
1
<!--
2
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
4
Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
6
7
The contents of this file are subject to the terms of either the GNU
8
General Public License Version 2 only ("GPL") or the Common
9
Development and Distribution License("CDDL") (collectively, the
10
"License"). You may not use this file except in compliance with the
11
License. You can obtain a copy of the License at
12
http://www.netbeans.org/cddl-gplv2.html
13
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
14
specific language governing permissions and limitations under the
15
License.  When distributing the software, include this License Header
16
Notice in each file and include the License file at
17
nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
18
particular file as subject to the "Classpath" exception as provided
19
by Sun in the GPL Version 2 section of the License file that
20
accompanied this code. If applicable, add the following below the
21
License Header, with the fields enclosed by brackets [] replaced by
22
your own identifying information:
23
"Portions Copyrighted [year] [name of copyright owner]"
24
25
Contributor(s):
26
27
The Original Software is NetBeans. The Initial Developer of the Original
28
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
29
Microsystems, Inc. All Rights Reserved.
30
31
If you wish your version of this file to be governed by only the CDDL
32
or only the GPL Version 2, indicate your decision by adding
33
"[Contributor] elects to include this software in this distribution
34
under the [CDDL or GPL Version 2] license." If you do not indicate a
35
single choice of license, a recipient has the option to distribute
36
your version of this file under either the CDDL, the GPL Version 2 or
37
to extend the choice of license to its licensees as provided above.
38
However, if you add GPL Version 2 code and therefore, elected the GPL
39
Version 2 license, then the option applies only if the new code is
40
made subject to such option by the copyright holder.
41
-->
42
43
<html>
44
<head>
45
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
46
</head>
47
<BODY>
48
Creates a example of Session Enterprise JavaBean (EJB) component with used
49
Schedule annotation at sample method. This template creates the Java classes
50
for a single session bean and registers the bean in the EJB module's DD.
51
</BODY></HTML>
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/layer.xml (-1 / +11 lines)
Lines 270-282 Link Here
270
            <file name="Session">
270
            <file name="Session">
271
                <attr name="position" intvalue="100"/>
271
                <attr name="position" intvalue="100"/>
272
                <attr name="template" boolvalue="true"/>
272
                <attr name="template" boolvalue="true"/>
273
                <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.SessionEJBWizard.create"/>
273
                <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.SessionEJBWizard.createSession"/>
274
                <attr name="templateCategory" stringvalue="ejb-types"/>
274
                <attr name="templateCategory" stringvalue="ejb-types"/>
275
                <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/j2ee/ejbcore/resources/SessionEJB.html"/>
275
                <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/j2ee/ejbcore/resources/SessionEJB.html"/>
276
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.Bundle"/>
276
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.Bundle"/>
277
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
277
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
278
            </file>
278
            </file>
279
279
280
            <file name="TimerSession">
281
                <attr name="position" intvalue="120"/>
282
                <attr name="template" boolvalue="true"/>
283
                <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.SessionEJBWizard.createTimerSession"/>
284
                <attr name="templateCategory" stringvalue="ejb-types_3_1"/>
285
                <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/j2ee/ejbcore/resources/TimerSessionEJB.html"/>
286
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.Bundle"/>
287
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
288
            </file>
289
280
            <file name="Message">
290
            <file name="Message">
281
                <attr name="position" intvalue="400"/>
291
                <attr name="position" intvalue="400"/>
282
                <attr name="template" boolvalue="true"/>
292
                <attr name="template" boolvalue="true"/>

Return to bug 196526