# HG changeset patch # Parent 76169055da30b46b42220edb92943f2236656f7a #196526 - add a wizard for simplified EJB timer diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/AbstractMethodGenerator.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/AbstractMethodGenerator.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/AbstractMethodGenerator.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/AbstractMethodGenerator.java @@ -64,6 +64,7 @@ import org.netbeans.modules.j2ee.ejbcore._RetoucheUtil; import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileSystem; import org.openide.util.Parameters; /** @@ -93,6 +94,7 @@ commonInterface = className; } FileObject fileObject = _RetoucheUtil.resolveFileObjectForClass(ejbClassFileObject, commonInterface); + System.err.println(fileObject); addMethod(methodModel, fileObject, commonInterface); } diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/BusinessMethodGenerator.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/BusinessMethodGenerator.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/BusinessMethodGenerator.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/BusinessMethodGenerator.java @@ -144,13 +144,16 @@ addMethodToInterface(methodModelCopy, remote); } - // ejb class, add 'public' modifier, 'Override' annotation if required - List annotations; + // ejb class + // add all specified annothations and join Override if has local, remote interfaces + List annotations = new ArrayList(); + if (!methodModel.getAnnotations().isEmpty()) { + annotations.addAll(methodModel.getAnnotations()); + } if ((generateLocal && local != null) || (generateRemote && remote != null)) { - annotations = Collections.singletonList(MethodModel.Annotation.create("java.lang.Override")); //NOI18N - } else { - annotations = Collections.emptyList(); + annotations.add(MethodModel.Annotation.create("java.lang.Override")); //NOI18N } + // add 'public' modifier MethodModel methodModelCopy = MethodModel.create( methodModel.getName(), methodModel.getReturnType(), diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/codegeneration/SessionGenerator.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/codegeneration/SessionGenerator.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/codegeneration/SessionGenerator.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/codegeneration/SessionGenerator.java @@ -47,9 +47,12 @@ import org.netbeans.modules.j2ee.core.api.support.java.GenerationUtils; import org.netbeans.modules.j2ee.ejbcore.EjbGenerationUtil; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; +import javax.lang.model.element.Modifier; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.project.JavaProjectConstants; import org.netbeans.api.java.project.classpath.ProjectClassPathModifier; @@ -63,11 +66,15 @@ import org.netbeans.api.project.libraries.Library; import org.netbeans.api.project.libraries.LibraryManager; import org.netbeans.modules.j2ee.common.J2eeProjectCapabilities; +import org.netbeans.modules.j2ee.common.method.MethodModel; import org.netbeans.modules.j2ee.dd.api.ejb.AssemblyDescriptor; import org.netbeans.modules.j2ee.dd.api.ejb.ContainerTransaction; +import org.netbeans.modules.j2ee.ejbcore.action.BusinessMethodGenerator; +import org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session.TimerOptions; import org.netbeans.modules.j2ee.ejbcore.naming.EJBNameOptions; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; /** * Generator of Session EJBs for EJB 2.1 and 3.0 @@ -103,6 +110,7 @@ private final boolean isSimplified; // private final boolean hasBusinessInterface; private final boolean isXmlBased; + private final TimerOptions timerOptions; // EJB naming options private final EJBNameOptions ejbNameOptions; @@ -120,12 +128,12 @@ private final Map templateParameters; public static SessionGenerator create(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal, - String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased) { - return new SessionGenerator(wizardTargetName, pkg, hasRemote, hasLocal, sessionType, isSimplified, hasBusinessInterface, isXmlBased, false); + String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, TimerOptions timerOptions) { + return new SessionGenerator(wizardTargetName, pkg, hasRemote, hasLocal, sessionType, isSimplified, hasBusinessInterface, isXmlBased, timerOptions, false); } protected SessionGenerator(String wizardTargetName, FileObject pkg, boolean hasRemote, boolean hasLocal, - String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, boolean isTest) { + String sessionType, boolean isSimplified, boolean hasBusinessInterface, boolean isXmlBased, TimerOptions timerOptions, boolean isTest) { this.pkg = pkg; this.remotePkg = pkg; this.hasRemote = hasRemote; @@ -149,6 +157,8 @@ this.templateParameters.put("package", packageName); this.templateParameters.put("localInterface", packageNameWithDot + localName); this.templateParameters.put("remoteInterface", packageNameWithDot + remoteName); + // set timer options if available + this.timerOptions = timerOptions; if (isTest) { // set date, time and user to values used in goldenfiles this.templateParameters.put("date", "{date}"); @@ -260,6 +270,12 @@ if (hasLocal) { GenerationUtils.createClass(EJB30_LOCAL, pkg, localName, null, templateParameters); } + + // fill up the session bean with the timer method if needed + if (timerOptions != null) { + generateTimerMethodForBean(ejbClassFO, "myTimer", timerOptions); + } + return ejbClassFO; } @@ -318,6 +334,25 @@ private void generateEJB30Xml() throws IOException { throw new UnsupportedOperationException("Method not implemented yet."); } + + private void generateTimerMethodForBean(FileObject bean, String methodName, TimerOptions timerOptions) { + try { + MethodModel method = MethodModel.create( + methodName, + "void", // NOI18N + "System.out.println(\"Timer event: \" + new java.util.Date());", // NOI18N + Collections.emptyList(), + Collections.emptyList(), + Collections.emptySet(), + Collections.singletonList(MethodModel.Annotation.create("javax.ejb.Schedule")) // NOI18N + ); + + BusinessMethodGenerator generator = BusinessMethodGenerator.create(packageNameWithDot + ejbClassName, bean); + generator.generate(method, hasLocal, hasRemote); + } catch (IOException ex) { + Logger.getLogger(SessionGenerator.class.getName()).log(Level.SEVERE, null, ex); + } + } //TODO: RETOUCHE WS // /** diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle.properties @@ -56,6 +56,7 @@ # wizard templates Templates/J2EE/Session=Session Bean +Templates/J2EE/TimerSession=Timer Session Bean LBL_Remote=Remote @@ -70,6 +71,7 @@ LBL_Singleton=Singleton LBL_SessionEJBWizardTitle=Session Bean +LBL_TimerSessionEJBWizardTitle=Timer Session Bean LBL_Interface=Create Interface\: LBL_EJB_Name=EJB Name: @@ -95,3 +97,18 @@ ERR_NoRemoteInterfaceProjectMaven=There is no suitable project available into which \ Remote interface could be stored. An open Maven based Java Class Library project is required. LBL_In_Project=Remote in project: +LBL_Schedule=Method schedule: +LBL_ScheduleSecondLabel=second +LBL_ScheduleMinuteLabel=minute +LBL_ScheduleHourLabel=hour +LBL_ScheduleMonthLabel=month +LBL_ScheduleYearLabel=year +LBL_ScheduleDayOfWeekLabel=dayOfWeek +LBL_ScheduleDayOfMonthLabel=dayOfMonth +MN_ScheduleSecond=e +MN_ScheduleMinute=m +MN_ScheduleHour=u +MN_ScheduleMonth=t +MN_ScheduleYear=y +MN_ScheduleDayOfWeek=w +MN_ScheduleDayOfMonth=d diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizard.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizard.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizard.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizard.java @@ -55,6 +55,7 @@ import org.netbeans.api.project.SourceGroup; import org.netbeans.modules.j2ee.api.ejbjar.EjbJar; import org.netbeans.spi.project.ui.templates.support.Templates; +import org.openide.WizardDescriptor.Panel; import org.openide.filesystems.FileObject; import org.netbeans.modules.j2ee.core.api.support.SourceGroups; import org.netbeans.modules.j2ee.core.api.support.wizard.Wizards; @@ -75,14 +76,24 @@ private int index = 0; private SessionEJBWizardDescriptor ejbPanel; private WizardDescriptor wiz; + private TimerOptions timerOptions; + private String resourceWizardName; - public static SessionEJBWizard create () { - return new SessionEJBWizard (); + public SessionEJBWizard(String resourceWizardName, TimerOptions timerOptions) { + this.resourceWizardName = resourceWizardName; + this.timerOptions = timerOptions; } - public String name () { - return NbBundle.getMessage (SessionEJBWizard.class, - "LBL_SessionEJBWizardTitle"); + public static SessionEJBWizard createSession() { + return new SessionEJBWizard("LBL_SessionEJBWizardTitle", null); //NOI18N + } + + public static SessionEJBWizard createTimerSession() { + return new SessionEJBWizard("LBL_TimerSessionEJBWizardTitle", new TimerOptions()); //NOI18N + } + + public String name() { + return NbBundle.getMessage (SessionEJBWizard.class, resourceWizardName); } public void uninitialize(WizardDescriptor wiz) { @@ -92,7 +103,7 @@ wiz = wizardDescriptor; Project project = Templates.getProject(wiz); SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project); - ejbPanel = new SessionEJBWizardDescriptor(project); + ejbPanel = new SessionEJBWizardDescriptor(project, timerOptions); WizardDescriptor.Panel wizardDescriptorPanel = new MultiTargetChooserPanel(project, sourceGroups, ejbPanel, true); panels = new WizardDescriptor.Panel[] {wizardDescriptorPanel}; @@ -113,7 +124,8 @@ ejbPanel.getSessionType(), isSimplified, true, // TODO: UI - add checkbox for creation of business interface - !isSimplified // TODO: UI - add checkbox for option XML (not annotation) usage + !isSimplified, // TODO: UI - add checkbox for option XML (not annotation) usage + ejbPanel.getTimerOptions() ); FileObject result = null; try { diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardDescriptor.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardDescriptor.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardDescriptor.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardDescriptor.java @@ -65,6 +65,7 @@ private SessionEJBWizardPanel wizardPanel; private final EJBNameOptions ejbNames; private final Project project; + private final TimerOptions timerOptions; //TODO: RETOUCHE // private boolean isWaitingForScan = false; @@ -72,8 +73,9 @@ private WizardDescriptor wizardDescriptor; - public SessionEJBWizardDescriptor(Project project) { + public SessionEJBWizardDescriptor(Project project, TimerOptions timerOptions) { this.ejbNames = new EJBNameOptions(); + this.timerOptions = timerOptions; this.project = project; } @@ -83,7 +85,7 @@ public java.awt.Component getComponent() { if (wizardPanel == null) { - wizardPanel = new SessionEJBWizardPanel(project, this); + wizardPanel = new SessionEJBWizardPanel(project, this, timerOptions); // add listener to events which could cause valid status to change } return wizardPanel; @@ -191,6 +193,10 @@ public String getSessionType() { return wizardPanel.getSessionType(); } + + public TimerOptions getTimerOptions() { + return wizardPanel.getTimerOptions(); + } public boolean isFinishPanel() { return isValid(); diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.form b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.form --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.form +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.form @@ -20,44 +20,36 @@ + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + @@ -67,13 +59,18 @@ - - - - - - + + + + + + + + + + + @@ -202,5 +199,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.java --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.java +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/SessionEJBWizardPanel.java @@ -78,12 +78,14 @@ private final ChangeListener listener; private final Project project; private ComboBoxModel projectsList; + private final TimerOptions timerOptions; /** Creates new form SingleEJBWizardPanel */ - public SessionEJBWizardPanel(Project project, ChangeListener changeListener) { + public SessionEJBWizardPanel(Project project, ChangeListener changeListener, TimerOptions timerOptions) { this.listener = changeListener; this.project = project; + this.timerOptions = timerOptions; initComponents(); J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project); @@ -93,7 +95,19 @@ remoteCheckBox.setVisible(false); remoteCheckBox.setEnabled(false); } + // enable Schedule section if Timer Session EJB, disable otherwise + if (this.timerOptions == null) { + schedulePanel.setVisible(false); + schedulePanel.setEnabled(false); + } else { + statefulButton.setEnabled(false); + statefulButton.setVisible(false); + } } else { + // hide whole Schedule section + schedulePanel.setVisible(false); + schedulePanel.setEnabled(false); + // hide singleton radio button singletonButton.setVisible(false); singletonButton.setEnabled(false); localCheckBox.setSelected(true); @@ -199,6 +213,22 @@ localCheckBox = new javax.swing.JCheckBox(); singletonButton = new javax.swing.JRadioButton(); inProjectCombo = new javax.swing.JComboBox(); + schedulePanel = new javax.swing.JPanel(); + scheduleLabel = new javax.swing.JLabel(); + scheduleSecondLabel = new javax.swing.JLabel(); + scheduleSecondTextField = new javax.swing.JTextField(); + scheduleMinuteLabel = new javax.swing.JLabel(); + scheduleMinuteTextField = new javax.swing.JTextField(); + scheduleHourLabel = new javax.swing.JLabel(); + scheduleHourTextField = new javax.swing.JTextField(); + scheduleMonthLabel = new javax.swing.JLabel(); + scheduleMonthTextField = new javax.swing.JTextField(); + scheduleYearLabel = new javax.swing.JLabel(); + scheduleYearTextField = new javax.swing.JTextField(); + scheduleDayOfWeekLabel = new javax.swing.JLabel(); + scheduleDayOfWeekTextField = new javax.swing.JTextField(); + scheduleDayOfMonthLabel = new javax.swing.JLabel(); + scheduleDayOfMonthTextField = new javax.swing.JTextField(); org.openide.awt.Mnemonics.setLocalizedText(sessionTypeLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_SessionType")); // NOI18N @@ -223,33 +253,137 @@ singletonButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_Singleton").charAt(0)); singletonButton.setText(org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Singleton")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(scheduleLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_Schedule")); // NOI18N + + scheduleSecondLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleSecond").charAt(0)); + scheduleSecondLabel.setLabelFor(scheduleSecondTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleSecondLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleSecondLabel")); // NOI18N + + scheduleSecondTextField.setText("0"); // NOI18N + + scheduleMinuteLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleMinute").charAt(0)); + scheduleMinuteLabel.setLabelFor(scheduleMinuteTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleMinuteLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleMinuteLabel")); // NOI18N + + scheduleMinuteTextField.setText("*"); // NOI18N + + scheduleHourLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleHour").charAt(0)); + scheduleHourLabel.setLabelFor(scheduleHourTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleHourLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleHourLabel")); // NOI18N + + scheduleHourTextField.setText("9-17"); // NOI18N + + scheduleMonthLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleMonth").charAt(0)); + scheduleMonthLabel.setLabelFor(scheduleMonthTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleMonthLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleMonthLabel")); // NOI18N + + scheduleMonthTextField.setText("*"); // NOI18N + + scheduleYearLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleYear").charAt(0)); + scheduleYearLabel.setLabelFor(scheduleYearTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleYearLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleYearLabel")); // NOI18N + + scheduleYearTextField.setText("*"); // NOI18N + + scheduleDayOfWeekLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleDayOfWeek").charAt(0)); + scheduleDayOfWeekLabel.setLabelFor(scheduleDayOfWeekTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleDayOfWeekLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleDayOfWeekLabel")); // NOI18N + + scheduleDayOfWeekTextField.setText("Mon-Fri"); // NOI18N + + scheduleDayOfMonthLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle").getString("MN_ScheduleDayOfMonth").charAt(0)); + scheduleDayOfMonthLabel.setLabelFor(scheduleDayOfMonthTextField); + org.openide.awt.Mnemonics.setLocalizedText(scheduleDayOfMonthLabel, org.openide.util.NbBundle.getMessage(SessionEJBWizardPanel.class, "LBL_ScheduleDayOfMonthLabel")); // NOI18N + + scheduleDayOfMonthTextField.setText("*"); // NOI18N + + org.jdesktop.layout.GroupLayout schedulePanelLayout = new org.jdesktop.layout.GroupLayout(schedulePanel); + schedulePanel.setLayout(schedulePanelLayout); + schedulePanelLayout.setHorizontalGroup( + schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(schedulePanelLayout.createSequentialGroup() + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(scheduleLabel) + .add(schedulePanelLayout.createSequentialGroup() + .addContainerGap() + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(scheduleSecondLabel) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, schedulePanelLayout.createSequentialGroup() + .add(scheduleHourLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(scheduleHourTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(org.jdesktop.layout.GroupLayout.LEADING, schedulePanelLayout.createSequentialGroup() + .add(scheduleMinuteLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(scheduleSecondTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleMinuteTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))) + .add(18, 18, 18) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(scheduleMonthLabel) + .add(scheduleYearLabel) + .add(scheduleDayOfWeekLabel) + .add(scheduleDayOfMonthLabel)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(scheduleYearTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleDayOfWeekTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleDayOfMonthTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleMonthTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(12, Short.MAX_VALUE)) + ); + schedulePanelLayout.setVerticalGroup( + schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(schedulePanelLayout.createSequentialGroup() + .add(scheduleLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(scheduleSecondLabel) + .add(scheduleSecondTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleMonthLabel) + .add(scheduleMonthTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(scheduleMinuteLabel) + .add(scheduleMinuteTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleYearLabel) + .add(scheduleYearTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(scheduleHourLabel) + .add(scheduleHourTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(scheduleDayOfWeekLabel) + .add(scheduleDayOfWeekTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(schedulePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(scheduleDayOfMonthLabel) + .add(scheduleDayOfMonthTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + ); + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(sessionTypeLabel) .add(layout.createSequentialGroup() + .addContainerGap() + .add(statelessButton)) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(statefulButton)) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(singletonButton)) + .add(interfaceLabel) + .add(schedulePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(layout.createSequentialGroup() + .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(sessionTypeLabel) - .add(layout.createSequentialGroup() - .addContainerGap() - .add(statelessButton)) - .add(layout.createSequentialGroup() - .addContainerGap() - .add(statefulButton)) - .add(layout.createSequentialGroup() - .addContainerGap() - .add(singletonButton)) - .add(interfaceLabel) - .add(layout.createSequentialGroup() - .addContainerGap() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(remoteCheckBox) - .add(6, 6, 6) - .add(inProjectCombo, 0, 129, Short.MAX_VALUE)) - .add(layout.createSequentialGroup() - .add(localCheckBox) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 152, Short.MAX_VALUE))))) + .add(remoteCheckBox) + .add(localCheckBox)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(inProjectCombo, 0, 232, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( @@ -264,12 +398,16 @@ .add(singletonButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(interfaceLabel) - .add(0, 0, 0) - .add(localCheckBox) - .add(0, 0, 0) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(remoteCheckBox) - .add(inProjectCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(layout.createSequentialGroup() + .add(localCheckBox) + .add(2, 2, 2) + .add(remoteCheckBox)) + .add(inProjectCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(24, 24, 24) + .add(schedulePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) ); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/Bundle"); // NOI18N @@ -289,6 +427,22 @@ private javax.swing.JLabel interfaceLabel; private javax.swing.JCheckBox localCheckBox; private javax.swing.JCheckBox remoteCheckBox; + private javax.swing.JLabel scheduleDayOfMonthLabel; + private javax.swing.JTextField scheduleDayOfMonthTextField; + private javax.swing.JLabel scheduleDayOfWeekLabel; + private javax.swing.JTextField scheduleDayOfWeekTextField; + private javax.swing.JLabel scheduleHourLabel; + private javax.swing.JTextField scheduleHourTextField; + private javax.swing.JLabel scheduleLabel; + private javax.swing.JLabel scheduleMinuteLabel; + private javax.swing.JTextField scheduleMinuteTextField; + private javax.swing.JLabel scheduleMonthLabel; + private javax.swing.JTextField scheduleMonthTextField; + private javax.swing.JPanel schedulePanel; + private javax.swing.JLabel scheduleSecondLabel; + private javax.swing.JTextField scheduleSecondTextField; + private javax.swing.JLabel scheduleYearLabel; + private javax.swing.JTextField scheduleYearTextField; private javax.swing.ButtonGroup sessionStateButtons; private javax.swing.JLabel sessionTypeLabel; private javax.swing.JRadioButton singletonButton; @@ -316,6 +470,21 @@ return localCheckBox.isSelected(); } + public TimerOptions getTimerOptions() { + if (timerOptions == null) { + return null; + } else { + timerOptions.setSecond(scheduleSecondTextField.getText()); + timerOptions.setMinute(scheduleMinuteTextField.getText()); + timerOptions.setHour(scheduleHourTextField.getText()); + timerOptions.setMonth(scheduleMonthTextField.getText()); + timerOptions.setYear(scheduleYearTextField.getText()); + timerOptions.setDayOfWeek(scheduleDayOfWeekTextField.getText()); + timerOptions.setDayOfMonth(scheduleDayOfMonthTextField.getText()); + return timerOptions; + } + } + public Project getRemoteInterfaceProject() { if (projectsList == null) { return null; diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/TimerOptions.java b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/TimerOptions.java new file mode 100644 --- /dev/null +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/session/TimerOptions.java @@ -0,0 +1,128 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.ejbcore.ejb.wizard.session; + +/** + * + * @author Martin Fousek + */ +public final class TimerOptions { + + private String second; + private String minute; + private String hour; + private String dayOfMonth; + private String month; + private String dayOfWeek; + private String year; + + public TimerOptions(String second, String minute, String hour, String dayOfMonth, String month, String dayOfWeek, String year) { + this.second = second; + this.minute = minute; + this.hour = hour; + this.dayOfMonth = dayOfMonth; + this.month = month; + this.dayOfWeek = dayOfWeek; + this.year = year; + } + + public TimerOptions() { + } + + public String getDayOfMonth() { + return dayOfMonth; + } + + public String getDayOfWeek() { + return dayOfWeek; + } + + public String getHour() { + return hour; + } + + public String getMinute() { + return minute; + } + + public String getMonth() { + return month; + } + + public String getSecond() { + return second; + } + + public String getYear() { + return year; + } + + public void setDayOfMonth(String dayOfMonth) { + this.dayOfMonth = dayOfMonth; + } + + public void setDayOfWeek(String dayOfWeek) { + this.dayOfWeek = dayOfWeek; + } + + public void setHour(String hour) { + this.hour = hour; + } + + public void setMinute(String minute) { + this.minute = minute; + } + + public void setMonth(String month) { + this.month = month; + } + + public void setSecond(String second) { + this.second = second; + } + + public void setYear(String year) { + this.year = year; + } + +} diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/TimerSessionEJB.html b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/TimerSessionEJB.html new file mode 100644 --- /dev/null +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/TimerSessionEJB.html @@ -0,0 +1,51 @@ + + + + + + + +Creates a example of Session Enterprise JavaBean (EJB) component with used +Schedule annotation at sample method. This template creates the Java classes +for a single session bean and registers the bean in the EJB module's DD. + diff --git a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/layer.xml b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/layer.xml --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/layer.xml +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/resources/layer.xml @@ -270,13 +270,23 @@ - + + + + + + + + + + +