use of com.vaadin.ui.Button.ClickListener in project opennms by OpenNMS.
the class AlarmIdColumnLinkGenerator method generateCell.
@Override
public Object generateCell(final Table source, Object itemId, Object columnId) {
// no source
if (source == null)
return null;
Property<Integer> alarmIdProperty = source.getContainerProperty(itemId, alarmIdPropertyName);
final Integer alarmId = alarmIdProperty.getValue();
// no value
if (alarmId == null)
return null;
// create Link
Button button = new Button("" + alarmId);
button.setStyleName(BaseTheme.BUTTON_LINK);
button.addClickListener(new ClickListener() {
private static final long serialVersionUID = 3698209256202413810L;
@Override
public void buttonClick(ClickEvent event) {
// try if alarm is there, otherwise show information dialog
OnmsAlarm alarm = alarmDao.get(alarmId);
if (alarm == null) {
new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table.");
return;
}
// alarm still exists, show alarm details
final URI currentLocation = Page.getCurrent().getLocation();
final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath();
final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId;
LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment);
try {
source.getUI().addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() {
@Override
public String getLabel() {
return "Alarm Info " + alarmId;
}
}));
} catch (MalformedURLException e) {
LOG.error(e.getMessage(), e);
}
}
});
return button;
}
use of com.vaadin.ui.Button.ClickListener in project Activiti by Activiti.
the class TaskDetailPanel method initProcessLink.
protected void initProcessLink() {
if (task.getProcessInstanceId() != null) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
Button showProcessInstanceButton = new Button(i18nManager.getMessage(Messages.TASK_PART_OF_PROCESS, getProcessDisplayName(processDefinition)));
showProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
showProcessInstanceButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
viewManager.showMyProcessInstancesPage(task.getProcessInstanceId());
}
});
centralLayout.addComponent(showProcessInstanceButton);
addEmptySpace(centralLayout);
}
}
use of com.vaadin.ui.Button.ClickListener in project Activiti by Activiti.
the class TaskDetailPanel method initDescription.
protected void initDescription(HorizontalLayout layout) {
final CssLayout descriptionLayout = new CssLayout();
descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
layout.addComponent(descriptionLayout);
layout.setExpandRatio(descriptionLayout, 1.0f);
layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);
String descriptionText = null;
if (task.getDescription() != null && !"".equals(task.getDescription())) {
descriptionText = task.getDescription();
} else {
descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
}
final Label descriptionLabel = new Label(descriptionText);
descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
descriptionLayout.addComponent(descriptionLabel);
descriptionLayout.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
// layout for textarea + ok button
final VerticalLayout editLayout = new VerticalLayout();
editLayout.setSpacing(true);
// textarea
final TextArea descriptionTextArea = new TextArea();
descriptionTextArea.setNullRepresentation("");
descriptionTextArea.setWidth(100, UNITS_PERCENTAGE);
descriptionTextArea.setValue(task.getDescription());
editLayout.addComponent(descriptionTextArea);
// ok button
Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
editLayout.addComponent(okButton);
editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);
// replace
descriptionLayout.replaceComponent(descriptionLabel, editLayout);
// When OK is clicked -> update task data + ui
okButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
// Update data
task.setDescription(descriptionTextArea.getValue().toString());
taskService.saveTask(task);
// Update UI
descriptionLabel.setValue(task.getDescription());
descriptionLayout.replaceComponent(editLayout, descriptionLabel);
}
});
}
}
});
}
use of com.vaadin.ui.Button.ClickListener in project Activiti by Activiti.
the class TaskDetailPanel method initParentTaskLink.
protected void initParentTaskLink() {
if (task.getParentTaskId() != null) {
final Task parentTask = taskService.createTaskQuery().taskId(task.getParentTaskId()).singleResult();
Button showParentTaskButton = new Button(i18nManager.getMessage(Messages.TASK_SUBTASK_OF_PARENT_TASK, parentTask.getName()));
showParentTaskButton.addStyleName(Reindeer.BUTTON_LINK);
showParentTaskButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
viewManager.showTaskPage(parentTask.getId());
}
});
centralLayout.addComponent(showParentTaskButton);
addEmptySpace(centralLayout);
}
}
use of com.vaadin.ui.Button.ClickListener in project Activiti by Activiti.
the class TaskDetailPanel method initTaskForm.
protected void initTaskForm() {
// Check if task requires a form
TaskFormData formData = formService.getTaskFormData(task.getId());
if (formData != null && formData.getFormProperties() != null && !formData.getFormProperties().isEmpty()) {
taskForm = new FormPropertiesForm();
taskForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.TASK_COMPLETE));
taskForm.setCancelButtonCaption(i18nManager.getMessage(Messages.TASK_RESET_FORM));
taskForm.setFormHelp(i18nManager.getMessage(Messages.TASK_FORM_HELP));
taskForm.setFormProperties(formData.getFormProperties());
taskForm.addListener(new FormPropertiesEventListener() {
private static final long serialVersionUID = -3893467157397686736L;
@Override
protected void handleFormSubmit(FormPropertiesEvent event) {
Map<String, String> properties = event.getFormProperties();
formService.submitTaskFormData(task.getId(), properties);
notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
taskPage.refreshSelectNext();
}
@Override
protected void handleFormCancel(FormPropertiesEvent event) {
// Clear the form values
taskForm.clear();
}
});
// Only if current user is task's assignee
taskForm.setEnabled(isCurrentUserAssignee());
// Add component to page
centralLayout.addComponent(taskForm);
} else {
// Just add a button to complete the task
// TODO: perhaps move to a better place
CssLayout buttonLayout = new CssLayout();
buttonLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
buttonLayout.setWidth(100, UNITS_PERCENTAGE);
centralLayout.addComponent(buttonLayout);
completeButton = new Button(i18nManager.getMessage(Messages.TASK_COMPLETE));
completeButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
// If no owner, make assignee owner (will go into archived then)
if (task.getOwner() == null) {
task.setOwner(task.getAssignee());
taskService.setOwner(task.getId(), task.getAssignee());
}
taskService.complete(task.getId());
notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
taskPage.refreshSelectNext();
}
});
completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
buttonLayout.addComponent(completeButton);
}
}
Aggregations