Refs #1205 Shortcuts: CTRL-INSERT in table raised in another tab

This commit is contained in:
Yuriy Artamonov 2012-04-23 14:19:45 +00:00
parent 0d3898db93
commit 81c711d7d6
4 changed files with 55 additions and 132 deletions

View File

@ -951,11 +951,13 @@ public abstract class Table
final UIDL action = (UIDL) it.next();
final String key = action.getStringAttribute("key");
final String caption = action.getStringAttribute("caption");
actionMap.put(key + "_c", caption);
if (action.hasAttribute("icon")) {
// TODO need some uri handling ??
actionMap.put(key + "_i", client.translateVaadinUri(action
.getStringAttribute("icon")));
// if it is not shortcut action
if (!action.hasAttribute("kc")) {
actionMap.put(key + "_c", caption);
if (action.hasAttribute("icon")) {
// TODO need some uri handling ??
actionMap.put(key + "_i", client.translateVaadinUri(action.getStringAttribute("icon")));
}
}
}
}
@ -2064,7 +2066,7 @@ public abstract class Table
/*
* Returns columns as Action array for column select popup
*/
@Override
public Action[] getActions() {
if (clickedSelector == columnSelector) {
return getColumnSelectionActions();
@ -2077,18 +2079,19 @@ public abstract class Table
final Object[] cols = getActionColumns();
final Action[] actions = new Action[cols.length];
boolean oneColumnLeft = (collapsedColumns.size() >= (cols.length - 1)); // Indicates whether there is only one displayed column
// Indicates whether there is only one displayed column
boolean oneColumnLeft = (collapsedColumns.size() >= (cols.length - 1));
for (int i = 0; i < cols.length; i++) {
final String cid = (String) cols[i];
final HeaderCell c = getHeaderCell(cid);
final VisibleColumnAction a = createColumnAction(c
.getColKey());
final VisibleColumnAction a = createColumnAction(c.getColKey());
a.setCaption(c.getCaption());
if (!c.isEnabled()) {
a.setCollapsed(true);
}
else if (oneColumnLeft){ //Disable ability to collapse if it's the last not collapsed column
else if (oneColumnLeft){
//Disable ability to collapse if it's the last not collapsed column
a.setEnabled(false);
}
actions[i] = a;
@ -2120,10 +2123,12 @@ public abstract class Table
return new VisibleColumnAction(key);
}
@Override
public ApplicationConnection getClient() {
return client;
}
@Override
public String getPaintableId() {
return paintableId;
}
@ -3105,8 +3110,7 @@ public abstract class Table
final Action[] actions = new Action[actionKeys.length];
for (int i = 0; i < actions.length; i++) {
final String actionKey = actionKeys[i];
final TreeAction a = new TreeAction(this, String
.valueOf(rowKey), actionKey);
final TreeAction a = new TreeAction(this, String.valueOf(rowKey), actionKey);
a.setCaption(getActionCaption(actionKey));
a.setIconUrl(getActionIcon(actionKey));
actions[i] = a;

View File

@ -352,22 +352,8 @@ public class GroupTable extends Table implements GroupTableContainer {
target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);
// Actions
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
for (final Action a : actionSet) {
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
}
if (a.getIcon() != null) {
target.addAttribute("icon", a.getIcon());
}
target.addAttribute("key", actionMapper.key(a));
target.endTag("action");
}
target.endTag("actions");
}
paintActions(target, actionSet);
if (isColumnReorderingAllowed()) {
final String[] colorder = new String[visibleColumns.size()];
int i = 0;
@ -396,10 +382,6 @@ public class GroupTable extends Table implements GroupTableContainer {
if (getDropHandler() != null) {
getDropHandler().getAcceptCriterion().paint(target);
}
if (actionManager != null) {
actionManager.paintActions(null, target);
}
}
private Collection<?> allItemIds() {

View File

@ -51,7 +51,7 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
private boolean showTotalAggregation = true;
protected ActionManager actionManager;
protected ActionManager shortcutsManager = new ActionManager();
private List<CollapseListener> columnCollapseListeners = new ArrayList<CollapseListener>();
@ -147,8 +147,8 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
}
// Actions
if (actionManager != null) {
actionManager.handleActions(variables, this);
if (shortcutsManager != null) {
shortcutsManager.handleActions(variables, this);
}
}
@ -578,22 +578,8 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);
// Actions
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
for (final Action a : actionSet) {
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
}
if (a.getIcon() != null) {
target.addAttribute("icon", a.getIcon());
}
target.addAttribute("key", actionMapper.key(a));
target.endTag("action");
}
target.endTag("actions");
}
paintActions(target, actionSet);
if (isColumnReorderingAllowed()) {
final String[] colorder = new String[visibleColumns.size()];
int i = 0;
@ -611,10 +597,29 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
if (getDropHandler() != null) {
getDropHandler().getAcceptCriterion().paint(target);
}
}
if (actionManager != null) {
actionManager.paintActions(null, target);
protected void paintActions(PaintTarget target, Set<Action> actionSet) throws PaintException {
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
for (final Action a : actionSet) {
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
}
if (a.getIcon() != null) {
target.addAttribute("icon", a.getIcon());
}
target.addAttribute("key", actionMapper.key(a));
target.endTag("action");
}
target.endTag("actions");
}
// paint shortcut actions
shortcutsManager.paintActions(null, target);
}
protected void paintCollapsedColumns(PaintTarget target) throws PaintException {
@ -678,14 +683,12 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
protected void paintRowActions(PaintTarget target, Set actionSet, Object itemId) {
if (actionHandlers != null) {
final ArrayList keys = new ArrayList();
for (final Iterator ahi = actionHandlers.iterator(); ahi
.hasNext();) {
final Action[] aa = ((Action.Handler) ahi.next())
.getActions(itemId, this);
for (Action.Handler actionHandler : actionHandlers) {
final Action[] aa = (actionHandler).getActions(itemId, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
final String key = actionMapper.key(aa[ai]);
actionSet.add(aa[ai]);
for (Action anAa : aa) {
final String key = actionMapper.key(anAa);
actionSet.add(anAa);
keys.add(key);
}
}
@ -1099,17 +1102,15 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
@Override
public void addShortcutListener(ShortcutListener listener) {
if (listener.getKeyCode() != 13 || !(listener.getModifiers() == null || listener.getModifiers().length > 0)) {
super.addShortcutListener(listener);
shortcutsManager.addAction(listener);
} else
shortcutListeners.add(listener);
}
@Override
public void removeShortcutListener(ShortcutListener listener) {
if (shortcutListeners.contains(listener))
shortcutListeners.remove(listener);
else
super.removeShortcutListener(listener);
public void removeShortcutListener(ShortcutListener listener){
shortcutListeners.remove(listener);
shortcutsManager.removeAction(listener);
}
public boolean isAggregatable() {
@ -1197,51 +1198,6 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
super.setColumnCollapsed(propertyId, collapsed);
}
/*
* ACTIONS
*/
@Override
protected ActionManager getActionManager() {
if (actionManager == null) {
actionManager = new ActionManager(this);
}
return actionManager;
}
public <T extends Action & com.vaadin.event.Action.Listener> void addAction(
T action) {
getActionManager().addAction(action);
}
public <T extends Action & com.vaadin.event.Action.Listener> void removeAction(
T action) {
if (actionManager != null) {
actionManager.removeAction(action);
}
}
@Override
public void addActionHandler(Action.Handler actionHandler) {
getActionManager().addActionHandler(actionHandler);
}
@Override
public void removeActionHandler(Action.Handler actionHandler) {
if (actionManager != null) {
actionManager.removeActionHandler(actionHandler);
}
}
/**
* Removes all action handlers
*/
@Override
public void removeAllActionHandlers() {
if (actionManager != null) {
actionManager.removeAllActionHandlers();
}
}
public interface PagingProvider extends Serializable {
String firstCaption();
String prevCaption();

View File

@ -580,23 +580,8 @@ public class TreeTable extends Table implements Container.Hierarchical, TreeTabl
target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);
// Actions
if (!actions.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
for (final Object anActionSet : actions) {
final Action a = (Action) anActionSet;
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
}
if (a.getIcon() != null) {
target.addAttribute("icon", a.getIcon());
}
target.addAttribute("key", actionMapper.key(a));
target.endTag("action");
}
target.endTag("actions");
}
paintActions(target, actions);
if (isColumnCollapsingAllowed()) {
final String[] colorder = new String[visibleColumns.size()];
int i = 0;
@ -614,10 +599,6 @@ public class TreeTable extends Table implements Container.Hierarchical, TreeTabl
if (getDropHandler() != null) {
getDropHandler().getAcceptCriterion().paint(target);
}
if (actionManager != null) {
actionManager.paintActions(null, target);
}
}
protected Set<Object> getItemIdsInRange(Object startItemId, final int length) {