forked from xuhuisheng/Activiti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Activiti/Activiti
- Loading branch information
Showing
15 changed files
with
571 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
modules/activiti-explorer/src/main/java/org/activiti/explorer/form/MonthFormType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.activiti.explorer.form; | ||
|
||
import org.activiti.engine.form.AbstractFormType; | ||
|
||
|
||
/** | ||
* @author Joram Barrez | ||
*/ | ||
public class MonthFormType extends AbstractFormType { | ||
|
||
public static final String TYPE_NAME = "month"; | ||
|
||
public String getName() { | ||
return TYPE_NAME; | ||
} | ||
|
||
@Override | ||
public Object convertFormValueToModelValue(String propertyValue) { | ||
Integer month = Integer.valueOf(propertyValue); | ||
return month; | ||
} | ||
|
||
@Override | ||
public String convertModelValueToFormValue(Object modelValue) { | ||
if (modelValue == null) { | ||
return null; | ||
} | ||
return modelValue.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...iviti-explorer/src/main/java/org/activiti/explorer/ui/form/MonthFormPropertyRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.activiti.explorer.ui.form; | ||
|
||
import java.util.Calendar; | ||
|
||
import org.activiti.engine.form.FormProperty; | ||
import org.activiti.explorer.ExplorerApp; | ||
import org.activiti.explorer.I18nManager; | ||
import org.activiti.explorer.Messages; | ||
import org.activiti.explorer.form.MonthFormType; | ||
|
||
import com.vaadin.ui.ComboBox; | ||
import com.vaadin.ui.Field; | ||
|
||
|
||
/** | ||
* @author Joram Barrez | ||
*/ | ||
public class MonthFormPropertyRenderer extends AbstractFormPropertyRenderer { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public MonthFormPropertyRenderer() { | ||
super(MonthFormType.class); | ||
} | ||
|
||
public Field getPropertyField(FormProperty formProperty) { | ||
ComboBox comboBox = new MonthCombobox(getPropertyLabel(formProperty)); | ||
comboBox.setRequired(formProperty.isRequired()); | ||
comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty))); | ||
comboBox.setEnabled(formProperty.isWritable()); | ||
|
||
// Fill combobox | ||
I18nManager i18nManager = ExplorerApp.get().getI18nManager(); | ||
for (int i=0; i<12; i++) { | ||
comboBox.addItem(i); | ||
comboBox.setItemCaption(i, i18nManager.getMessage(Messages.MONTH_PREFIX + i)); | ||
} | ||
|
||
// Select first | ||
comboBox.setNullSelectionAllowed(false); | ||
Calendar cal = Calendar.getInstance(); | ||
comboBox.select(cal.get(Calendar.MONTH)); | ||
|
||
return comboBox; | ||
} | ||
|
||
|
||
// See https://vaadin.com/forum/-/message_boards/view_message/142750 | ||
public class MonthCombobox extends ComboBox { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public MonthCombobox(String s) { | ||
super(s); | ||
pageLength = 20; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.