Java源码示例:com.vaadin.event.Action

示例1
private void setActionsForEachHalfHour(Map<CalendarDateRange, Set<Action>> actionMap,
                                       ZonedDateTime start, ZonedDateTime end, Action.Handler actionHandler) {

    ZonedDateTime actionTime = start;
    while (actionTime.isBefore(end)) {

        ZonedDateTime endTime = actionTime.plus(30, ChronoUnit.MINUTES);

        CalendarDateRange range = new CalendarDateRange(actionTime, endTime);

        Action[] actions = actionHandler.getActions(range, this);
        if (actions != null) {
            Set<Action> actionSet = new LinkedHashSet<>(Arrays.asList(actions));
            actionMap.put(range, actionSet);
        }

        actionTime = endTime;
    }
}
 
示例2
@Override
public Action[] getActions(Object target, Object sender) {
    // The target should be a CalendarDateRage for the
    // entire day from midnight to midnight.
    if (!(target instanceof CalendarDateRange))
        return null;
    CalendarDateRange dateRange = (CalendarDateRange) target;

    // The sender is the Calendar object
    if (!(sender instanceof Calendar))
        return null;
    Calendar calendar = (Calendar) sender;

    // List all the events on the requested day
    List<CalendarEvent> events = calendar.getEvents(dateRange.getStart(), dateRange.getEnd());

    if (events.size() == 0)
        return new Action[]{addEventAction};
    else
        return new Action[]{addEventAction, copyEventAction, deleteEventAction};
}
 
示例3
@Override
public void handleAction(Action action, Object sender, Object target) {
    TabSheetBehaviour tabSheetBehaviour = tabSheet.getTabSheetBehaviour();
    if (initialized) {
        if (closeCurrentTab == action) {
            tabSheetBehaviour.closeTab((com.vaadin.ui.Component) target);
        } else if (closeOtherTabs == action) {
            tabSheetBehaviour.closeOtherTabs((com.vaadin.ui.Component) target);
        } else if (closeAllTabs == action) {
            tabSheetBehaviour.closeAllTabs();
        } else if (showInfo == action) {
            showInfo(target);
        } else if (analyzeLayout == action) {
            analyzeLayout(target);
        } else if (saveSettings == action) {
            saveSettings(target);
        } else if (restoreToDefaults == action) {
            restoreToDefaults(target);
        }
    }
}
 
示例4
@Override
public com.vaadin.event.Action[] getActions(Object target, Object sender) {
    if (!initialized) {
        Messages messages = beanLocator.get(Messages.NAME);

        saveSettingsAction = new com.vaadin.event.Action(messages.getMainMessage("actions.saveSettings"));
        restoreToDefaultsAction = new com.vaadin.event.Action(messages.getMainMessage("actions.restoreToDefaults"));
        analyzeAction = new com.vaadin.event.Action(messages.getMainMessage("actions.analyzeLayout"));

        initialized = true;
    }

    List<Action> actions = new ArrayList<>(3);

    ClientConfig clientConfig = getClientConfig();
    if (clientConfig.getManualScreenSettingsSaving()) {
        actions.add(saveSettingsAction);
        actions.add(restoreToDefaultsAction);
    }
    if (clientConfig.getLayoutAnalyzerEnabled()) {
        actions.add(analyzeAction);
    }

    return actions.toArray(new com.vaadin.event.Action[0]);
}
 
示例5
@Override
public void onTabContextMenu(int tabIndex) {
    Tab tab = getTab(tabIndex);
    if (tab != null) {
        Set<Action> actions = getActions(CubaMainTabSheet.this.getActionTarget(tab));

        if (!actions.isEmpty()) {
            actionMapper = new KeyMapper<>();

            List<ClientAction> actionsList = new ArrayList<>(actions.size());
            for (Action action : actions) {
                ClientAction clientAction = new ClientAction(action.getCaption());
                clientAction.setActionId(actionMapper.key(action));
                actionsList.add(clientAction);
            }

            ClientAction[] clientActions = actionsList.toArray(new ClientAction[actions.size()]);

            getRpcProxy(CubaMainTabSheetClientRpc.class).showTabContextMenu(tabIndex, clientActions);
        }
    }
}
 
示例6
@Override
public void performAction(int tabIndex, String actionKey) {
    Tab tab = getTab(tabIndex);
    if (tab != null) {
        if (actionMapper != null) {
            Action action = actionMapper.get(actionKey);
            Action.Handler[] handlers;

            if (actionHandlers != null) {
                handlers = actionHandlers.toArray(new Action.Handler[0]);
            } else {
                handlers = new Action.Handler[0];
            }

            for (Action.Handler handler : handlers) {
                handler.handleAction(action, this, CubaMainTabSheet.this.getActionTarget(tab));
            }

            // forget all painted actions after perform one
            actionMapper = null;
        }
    }
}
 
示例7
@Override
public void onWindowContextMenu() {
    Collection<Action> actions = getContextActions(CubaWindow.this);

    if (!actions.isEmpty()) {
        contextActionMapper = new KeyMapper<>();

        List<ClientAction> actionsList = new ArrayList<>(actions.size());
        for (Action action : actions) {
            ClientAction clientAction = new ClientAction(action.getCaption());
            clientAction.setActionId(contextActionMapper.key(action));
            actionsList.add(clientAction);
        }

        ClientAction[] clientActions = actionsList.toArray(new ClientAction[actions.size()]);

        getRpcProxy(CubaWindowClientRpc.class).showTabContextMenu(clientActions);
    }
}
 
示例8
private void setActionsForDay(Map<CalendarDateRange, Set<Action>> actionMap,
                              ZonedDateTime start, ZonedDateTime end, Action.Handler actionHandler) {

    CalendarDateRange range = new CalendarDateRange(start, end);
    Action[] actions = actionHandler.getActions(range, this);
    if (actions != null) {
        Set<Action> actionSet = new LinkedHashSet<>(Arrays.asList(actions));
        actionMap.put(range, actionSet);
    }
}
 
示例9
private List<CalendarState.Action> createActionsList(Map<CalendarDateRange, Set<Action>> actionMap) {

        if (actionMap.isEmpty()) {
            return null;
        }

        List<CalendarState.Action> calendarActions = new ArrayList<>();

        for (Entry<CalendarDateRange, Set<Action>> entry : actionMap.entrySet()) {

            CalendarDateRange range = entry.getKey();

            for (Action action : entry.getValue()) {
                String key = actionMapper.key(action);
                CalendarState.Action calendarAction = new CalendarState.Action();
                calendarAction.actionKey = key;
                calendarAction.caption = action.getCaption();
                setResource(key, action.getIcon());
                calendarAction.iconKey = key;
                calendarAction.startDate = ACTION_DATE_TIME_FORMAT.format(range.getStart());
                calendarAction.endDate = ACTION_DATE_TIME_FORMAT.format(range.getEnd());
                calendarActions.add(calendarAction);
            }
        }

        return calendarActions;
    }
 
示例10
@Override
public void actionOnEmptyCell(String actionKey, CalDate startDate, CalDate endDate) {

    Action action = actionMapper.get(actionKey);

    for (Action.Handler ah : actionHandlers) {
        ah.handleAction(action, Calendar.this,
                ZonedDateTime.of(startDate.y, startDate.m, startDate.d,
                        startDate.t.h, startDate.t.m, startDate.t.s, 0, getZoneId()));
    }

}
 
示例11
@Override
public void actionOnItem(String actionKey, CalDate startDate, CalDate endDate, int itemIndex) {

    Action action = actionMapper.get(actionKey);

    for (Action.Handler ah : actionHandlers) {
        ah.handleAction(action, Calendar.this, items.get(itemIndex));
    }
}
 
示例12
@Override
public void perform(final Folder folder) {
    App.getInstance().getWindowManager().showOptionDialog(
            messages.getMainMessage("dialogs.Confirmation"),
            messages.getMainMessage("folders.removeFolderConfirmation"),
            Frame.MessageType.CONFIRMATION,
            new com.haulmont.cuba.gui.components.Action[]{
                    new DialogAction(Type.YES).withHandler(event -> {
                        removeFolder(folder);
                        refreshFolders();
                    }),
                    new DialogAction(Type.NO, Status.PRIMARY)
            }
    );
}
 
示例13
@Override
public void removeActionHandler(Action.Handler actionHandler) {
    if (actionManager != null) {
        actionManager.removeActionHandler(actionHandler);
        markAsDirty();
    }
}
 
示例14
@Override
public void removeActionHandler(Action.Handler actionHandler) {
    if (actionManager != null) {
        actionManager.removeActionHandler(actionHandler);
        markAsDirty();
    }
}
 
示例15
@Override
protected void paintActions(PaintTarget target, Set<Action> actionSet) throws PaintException {
    super.paintActions(target, actionSet);

    if (shortcutActionManager != null) {
        shortcutActionManager.paintActions(null, target);
    }
}
 
示例16
@Override
public void removeActionHandler(Action.Handler actionHandler) {
    if (actionManager != null) {
        actionManager.removeActionHandler(actionHandler);
        markAsDirty();
    }
}
 
示例17
@Override
protected void paintActions(PaintTarget target, Set<Action> actionSet) throws PaintException {
    super.paintActions(target, actionSet);

    if (shortcutActionManager != null) {
        shortcutActionManager.paintActions(null, target);
    }
}
 
示例18
protected Set<Action> getActions(Component actionTarget) {
    Set<Action> actions = new LinkedHashSet<>();
    if (actionHandlers != null) {
        for (Action.Handler handler : actionHandlers) {
            Action[] as = handler.getActions(actionTarget, this);
            if (as != null) {
                Collections.addAll(actions, as);
            }
        }
    }
    return actions;
}
 
示例19
@Override
public void addActionHandler(Action.Handler actionHandler) {
    if (actionHandlers == null) {
        actionHandlers = new LinkedHashSet<>();
    }
    actionHandlers.add(actionHandler);
}
 
示例20
@Override
public void performContextMenuAction(String actionKey) {
    if (contextActionMapper != null) {
        Action action = contextActionMapper.get(actionKey);
        Action.Handler[] handlers = contextActionHandlers.toArray(new Action.Handler[0]);
        for (Action.Handler handler : handlers) {
            handler.handleAction(action, this, CubaWindow.this);
        }

        // forget all painted actions after perform one
        contextActionMapper = null;
    }
}
 
示例21
protected Collection<Action> getContextActions(Component actionTarget) {
    List<Action> actions = new ArrayList<>();
    if (contextActionHandlers != null) {
        for (Action.Handler handler : contextActionHandlers) {
            Action[] as = handler.getActions(actionTarget, this);
            if (as != null) {
                Collections.addAll(actions, as);
            }
        }
    }
    return actions;
}
 
示例22
@Override
public void handleAction(final Action action, final Object sender, final Object target) {
    if (!selectAllAction.equals(action)) {
        return;
    }
    table.selectAll();
    publishEvent();
}
 
示例23
@Override
public Action[] getActions(Object target, Object sender) {
	if (target == null) {
		return new Action[] {ADD_ATTRIBUTE};
	}
	return new Action[] {EDIT_ATTRIBUTE, CLONE_ATTRIBUTE, REMOVE_ATTRIBUTE};
}
 
示例24
@Override
public void handleAction(Action action, Object sender, Object target) {
	if (action instanceof Action.Handler) {
		((Action.Handler) action).handleAction(action, sender, target);
	}
	else if (action instanceof ButtonListener) {
		((ButtonListener) action).buttonClick(new ClickEvent((Component) sender) );
	}
	else {
		doHandleAction(action, sender, target);
	}
}
 
示例25
@Subscribe("showCommandLine")
public void onShowCommandLine(com.haulmont.cuba.gui.components.Action.ActionPerformedEvent event) {
    showCommandLine();
}
 
示例26
@Override
public void handleAction(Action action, Object sender, Object target) {
    if (action == addEventAction) {
        // Check that the click was not done on an event
        if (target instanceof Date) {
            Date date = (Date) target;
            TimeEntry timeEntry = metadata.create(TimeEntry.class);
            timeEntry.setDate(date);
            editTimeEntry(timeEntry);
        } else {
            notifications.create()
                    .withType(Notifications.NotificationType.WARNING)
                    .withCaption(messages.getMessage(getClass(), "cantAddTimeEntry"))
                    .show();
        }
    } else if (action == copyEventAction) {
        // Check that the click was not done on an event
        if (target instanceof TimeEntryCalendarEventAdapter) {
            TimeEntry copiedEntry = metadata.getTools().copy(((TimeEntryCalendarEventAdapter) target).getTimeEntry());
            copiedEntry.setId(uuidSource.createUuid());
            copiedEntry.setStatus(TimeEntryStatus.NEW);

            CommitContext context = new CommitContext();
            context.getCommitInstances().add(copiedEntry);
            Set<Entity> entities = dataManager.commit(context);
            dataSource.changeEventTimeEntity((TimeEntry) entities.iterator().next());
        }
    } else if (action == deleteEventAction) {
        // Check if the action was clicked on top of an event
        if (target instanceof HolidayCalendarEventAdapter) {
            notifications.create()
                    .withType(Notifications.NotificationType.WARNING)
                    .withCaption(messages.getMessage(getClass(), "cantDeleteHoliday"))
                    .show();
        } else if (target instanceof TimeEntryCalendarEventAdapter) {
            TimeEntryCalendarEventAdapter event = (TimeEntryCalendarEventAdapter) target;
            new EventRemoveAction("eventRemove", dialogs, event).actionPerform(null);
        } else {
            notifications.create()
                    .withType(Notifications.NotificationType.WARNING)
                    .withCaption(messages.getMessage(getClass(), "cantDeleteTimeEntry"))
                    .show();
        }
    }
}
 
示例27
@Override
public Action[] getActions(Object target, Object sender) {
    if (!initialized) {
        Messages messages = AppBeans.get(Messages.NAME);

        closeAllTabs = new com.vaadin.event.Action(messages.getMainMessage("actions.closeAllTabs"));
        closeOtherTabs = new com.vaadin.event.Action(messages.getMainMessage("actions.closeOtherTabs"));
        closeCurrentTab = new com.vaadin.event.Action(messages.getMainMessage("actions.closeCurrentTab"));
        showInfo = new com.vaadin.event.Action(messages.getMainMessage("actions.showInfo"));
        analyzeLayout = new com.vaadin.event.Action(messages.getMainMessage("actions.analyzeLayout"));
        saveSettings = new com.vaadin.event.Action(messages.getMainMessage("actions.saveSettings"));
        restoreToDefaults = new com.vaadin.event.Action(messages.getMainMessage("actions.restoreToDefaults"));

        initialized = true;
    }

    List<Action> actions = new ArrayList<>(5);
    actions.add(closeCurrentTab);
    actions.add(closeOtherTabs);
    actions.add(closeAllTabs);

    if (target != null) {
        Configuration configuration = AppBeans.get(Configuration.NAME);
        ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
        if (clientConfig.getManualScreenSettingsSaving()) {
            actions.add(saveSettings);
            actions.add(restoreToDefaults);
        }

        UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
        UserSession userSession = sessionSource.getUserSession();
        if (userSession.isSpecificPermitted(ShowInfoAction.ACTION_PERMISSION) &&
                findEditor((Layout) target) != null) {
            actions.add(showInfo);
        }
        if (clientConfig.getLayoutAnalyzerEnabled()) {
            actions.add(analyzeLayout);
        }
    }

    return actions.toArray(new Action[0]);
}
 
示例28
protected Action.Handler createTabSheetActionHandler(HasTabSheetBehaviour tabSheet) {
    return new MainTabSheetActionHandler(tabSheet);
}
 
示例29
@Override
public void addActionHandler(Action.Handler actionHandler) {
    getActionManager().addActionHandler(actionHandler);
    markAsDirty();
}
 
示例30
@Override
public void addActionHandler(Action.Handler actionHandler) {
    getActionManager().addActionHandler(actionHandler);
    markAsDirty();
}