use of com.vaadin.event.Action.Handler in project Activiti by Activiti.
the class SubTaskComponent method initAddSubTaskPanelKeyboardActions.
protected void initAddSubTaskPanelKeyboardActions() {
addSubTaskPanel.addActionHandler(new Handler() {
public void handleAction(Action action, Object sender, Object target) {
if ("escape".equals(action.getCaption())) {
resetAddButton();
} else if ("enter".equals(action.getCaption())) {
if (newTaskTextField != null && newTaskTextField.getValue() != null && !"".equals(newTaskTextField.getValue().toString())) {
LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();
// save task
Task newTask = taskService.newTask();
newTask.setParentTaskId(parentTask.getId());
if (parentTask.getAssignee() != null) {
newTask.setAssignee(parentTask.getAssignee());
} else {
newTask.setAssignee(loggedInUser.getId());
}
if (parentTask.getOwner() != null) {
newTask.setOwner(parentTask.getOwner());
} else {
newTask.setOwner(loggedInUser.getId());
}
newTask.setName(newTaskTextField.getValue().toString());
taskService.saveTask(newTask);
// Reset the add button to its original state
resetAddButton();
// refresh sub tasks section
refreshSubTasks();
}
}
}
public Action[] getActions(Object target, Object sender) {
return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null), new ShortcutAction("escape", ShortcutAction.KeyCode.ESCAPE, null) };
}
});
}
use of com.vaadin.event.Action.Handler in project Activiti by Activiti.
the class TaskEventsPanel method addInputField.
protected void addInputField() {
HorizontalLayout layout = new HorizontalLayout();
layout.setSpacing(true);
layout.setWidth(100, UNITS_PERCENTAGE);
addComponent(layout);
// Hack: actionHandlers can only be attached to panels or windows
Panel textFieldPanel = new Panel();
textFieldPanel.addStyleName(Reindeer.PANEL_LIGHT);
textFieldPanel.setContent(new VerticalLayout());
textFieldPanel.setWidth(100, UNITS_PERCENTAGE);
layout.addComponent(textFieldPanel);
layout.setExpandRatio(textFieldPanel, 1.0f);
commentInputField = new TextField();
commentInputField.setWidth(100, UNITS_PERCENTAGE);
textFieldPanel.addComponent(commentInputField);
// Hack to catch keyboard 'enter'
textFieldPanel.addActionHandler(new Handler() {
public void handleAction(Action action, Object sender, Object target) {
addNewComment(commentInputField.getValue().toString());
}
public Action[] getActions(Object target, Object sender) {
return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) };
}
});
addCommentButton = new Button(i18nManager.getMessage(Messages.TASK_ADD_COMMENT));
layout.addComponent(addCommentButton);
layout.setComponentAlignment(addCommentButton, Alignment.MIDDLE_LEFT);
addCommentButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
addNewComment(commentInputField.getValue().toString());
}
});
}
Aggregations