List of usage examples for com.vaadin.event Action Action
public Action(String caption)
From source file:nz.co.senanque.vaadinsupport.tableeditor.TableEditorLayout.java
License:Apache License
public void afterPropertiesSet() throws Exception { if (getEditorWindow() != null) { // Only set up the editor window if it is there getEditorWindow().initialize(getFields()); getEditorWindow().addListener(new Listener() { private static final long serialVersionUID = -6498337136650101469L; public void componentEvent(Event event) { if (event instanceof DeleteEvent) { deleteObject((T) ((DeleteEvent) event).getObject()); return; }//from w ww. ja va 2 s. c o m if (event instanceof SaveEvent) { persistObject((T) ((SaveEvent) event).getObject()); return; } if (event instanceof CancelEvent) { cancelObject((T) ((CancelEvent) event).getObject()); return; } } }); table_1.addActionHandler(new Handler() { MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); private static final long serialVersionUID = -5923269974651895441L; Action add = new Action( messageSourceAccessor.getMessage("add.new.row.to.table", null, "add.new.row.to.table")); Action remove = new Action( messageSourceAccessor.getMessage("delete.this.row", null, "delete.this.row")); Action edit = new Action(messageSourceAccessor.getMessage("edit.this.row", null, "edit.this.row")); public Action[] getActions(Object target, Object sender) { List<Action> actions = new ArrayList<Action>(); if (getPermissionManager().hasPermission(getPermission())) { actions.add(add); actions.add(remove); actions.add(edit); } return actions.toArray(new Action[actions.size()]); } public void handleAction(Action action, Object sender, Object target) { if (action == add) { newRow(); } else if (action == remove) { T w = (T) getEditor().get((Serializable) target); deleteObject(w); } else if (action == edit) { editObject((Long) target, false); } } }); } table_1.setContainerDataSource(getContainer(), getColumns().toArray(new String[getColumns().size()]), getHeadings().toArray(new String[getHeadings().size()]), m_messageSource); }
From source file:org.accelerators.activiti.admin.ui.GroupTable.java
License:Open Source License
/** * Creates the group table//from w ww .java 2 s.co m */ @SuppressWarnings("serial") public GroupTable(AdminApp application) { // Set application reference this.app = application; // Maximize the table width and height setSizeFull(); setPageLength(size()); // Allow selecting items from the table. setSelectable(true); // Remove border // addStyleName(Reindeer.TABLE_BORDERLESS); // Send changes in selection immediately to server. setImmediate(true); // Disable null selection setNullSelectionAllowed(false); // Allow column to collapse setColumnCollapsingAllowed(true); // Allow reordering of columns setColumnReorderingAllowed(true); // Add table data source setContainerDataSource(app.getAdminService().getGroups()); // Set column headers setColumnHeader("id", "Id"); setColumnHeader("name", "Name"); setColumnHeader("type", "Type"); // Set column headers alignment setColumnAlignment("id", ALIGN_LEFT); setColumnAlignment("name", ALIGN_LEFT); setColumnAlignment("type", ALIGN_LEFT); // Define the names and data types of columns. setVisibleColumns(columnHeaders); // Add item click listener for double-click on table row addListener((ItemClickListener) this); // Context menu actions must be set here to use i18n support ACTION_EDIT = new Action(app.getMessage(Messages.Edit)); ACTION_DELETE = new Action(app.getMessage(Messages.Delete)); ACTIONS_UNMARKED = new Action[] { ACTION_EDIT, ACTION_DELETE }; ACTIONS_MARKED = new Action[] { ACTION_EDIT, ACTION_DELETE }; // Actions (a.k.a context menu) addActionHandler(new Action.Handler() { public Action[] getActions(Object target, Object sender) { if (markedRows.contains(target)) { return ACTIONS_MARKED; } else { return ACTIONS_UNMARKED; } } public void handleAction(Action action, Object sender, Object target) { if (ACTION_EDIT.equals(action)) { editGroup(target); } else if (ACTION_DELETE.equals(action)) { deleteGroup(target); } } }); }
From source file:org.accelerators.activiti.admin.ui.UserTable.java
License:Open Source License
/** * Create the user table/*from w ww .ja va 2s .co m*/ * * @param app */ @SuppressWarnings("serial") public UserTable(AdminApp application) { // Set application reference this.app = application; // Maximize the table width and height setSizeFull(); // Set infinite page length setPageLength(size()); // Remove border // addStyleName(Reindeer.TABLE_BORDERLESS); // Allow selecting items from the table. setSelectable(true); // Send changes in selection immediately to server. setImmediate(true); // Disable null selection setNullSelectionAllowed(false); // Allow column to collapse setColumnCollapsingAllowed(true); // Allow reordering of columns setColumnReorderingAllowed(true); // Add table data source setContainerDataSource(app.getAdminService().getUsers()); // Set column headers setColumnHeader("id", "Id"); setColumnHeader("email", "Email"); setColumnHeader("firstName", "First Name"); setColumnHeader("lastName", "Last Name"); // Set column headers alignment setColumnAlignment("id", ALIGN_LEFT); setColumnAlignment("email", ALIGN_LEFT); setColumnAlignment("firstName", ALIGN_LEFT); setColumnAlignment("lastName", ALIGN_LEFT); // Define the names and data types of columns. setVisibleColumns(columnHeaders); // Add table listener addListener((ItemClickListener) this); // Init actions must be set here to use i18n support ACTION_EDIT = new Action(app.getMessage(Messages.Edit)); ACTION_DELETE = new Action(app.getMessage(Messages.Delete)); ACTIONS_UNMARKED = new Action[] { ACTION_EDIT, ACTION_DELETE }; ACTIONS_MARKED = new Action[] { ACTION_EDIT, ACTION_DELETE }; // Actions (a.k.a context menu) addActionHandler(new Action.Handler() { public Action[] getActions(Object target, Object sender) { if (markedRows.contains(target)) { return ACTIONS_MARKED; } else { return ACTIONS_UNMARKED; } } public void handleAction(Action action, Object sender, Object target) { if (ACTION_EDIT.equals(action)) { editUser(target); } else if (ACTION_DELETE.equals(action)) { deleteUser(target); } } }); }
From source file:org.apache.ace.tageditor.ACETagEditorExtension.java
License:Apache License
/** * Creates a tag editor component for the given repository object. * //from www . j a va 2 s .com * @param object * the repository object to create the tag editor for, cannot be <code>null</code>. * @return a tag editor component, never <code>null</code>. */ private Component createTagEditor(final RepositoryObject object) { final Table table = new Table(); table.setWidth("100%"); table.addContainerProperty("Tag", TextField.class, null); table.addContainerProperty("Value", TextField.class, null); table.addContainerProperty("Remove", Button.class, null, "", null, Table.ALIGN_CENTER); table.setEditable(false); table.setColumnExpandRatio("Tag", 1.0f); table.setColumnExpandRatio("Value", 1.0f); table.setColumnExpandRatio("Remove", 0.2f); final Map<Object, TagTableEntry> idToKey = new HashMap<>(); Enumeration<String> keys = object.getTagKeys(); while (keys.hasMoreElements()) { String keyString = keys.nextElement(); String valueString = object.getTag(keyString); if ((valueString != null) && (valueString.trim().length() != 0)) { TagTableEntry tte = new TagTableEntry(object, keyString, valueString); idToKey.put(tte.addTo(table), tte); } } final TagTableEntry tte = new TagTableEntry(object); idToKey.put(tte.addTo(table), tte); tte.setListener(new TagTableEntry.ChangeListener() { private volatile TagTableEntry m_lastEntry = tte; public void changed(TagTableEntry entry) { TagTableEntry ntte = new TagTableEntry(object); idToKey.put(ntte.addTo(table), ntte); m_lastEntry.setListener(null); m_lastEntry = ntte; ntte.setListener(this); } }); table.addActionHandler(new Action.Handler() { final Action[] delete = new Action[] { new Action("delete") }; public void handleAction(Action action, Object sender, Object target) { idToKey.remove(target).removeFrom(table); } public Action[] getActions(Object target, Object sender) { return delete; } }); return table; }