Beispiel #1
0
 private Object getParent(SelectionItem parentItem, CommandContext context) {
   Object parent = parentItem.getObject();
   if (parent == null) {
     parent = context.getParent();
   }
   return parent;
 }
Beispiel #2
0
 public CommandResult execute(CommandContext context, Selection selection) {
   Clipboard.get(context).set(context.getScreen(), selection, this);
   return new BatchResult(
       new UpdateCommandsResult(),
       new NotificationResult(context, this)
           .setArgs(selection.size())
           .setDefaultMessage("{0,choice,1#Item|1<{0} items} put into the clipboard"));
 }
Beispiel #3
0
  public boolean canPaste(
      ListScreen source, Selection selection, CommandContext context, SelectionItem parentItem) {

    CopyAndPaste dao = getDao(context.getScreen());
    Object parent = getParent(parentItem, context);

    for (SelectionItem item : selection) {
      if (!dao.canPasteCopy(item.getObject(), parent)) {
        return false;
      }
    }
    return true;
  }
Beispiel #4
0
 @Override
 public boolean isEnabled(CommandContext context, Selection selection) {
   if (selection.isEmpty()) {
     return false;
   }
   CopyAndPaste dao = getDao(context.getScreen());
   for (SelectionItem item : selection) {
     if (!dao.canCopy(item.getObject())) {
       return false;
     }
   }
   return true;
 }
Beispiel #5
0
  public void paste(
      ListScreen source,
      Selection selection,
      CommandContext context,
      SelectionItem parentItem,
      NotificationResult notification) {

    CopyAndPaste dao = getDao(context.getScreen());
    Object parent = getParent(parentItem, context);

    for (SelectionItem item : selection) {
      dao.pasteCopy(item.getObject(), parent);
    }

    notification.setDefaultMessage("{0,choice,1#Item has|1<{0} items have} been copied.");
  }