com.vaadin.ui.UI Java Examples

The following examples show how to use com.vaadin.ui.UI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TargetTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private void openConfirmationWindowForAssignments(final Target target,
        final List<DistributionSet> distributionSets) {

    final String confirmationMessage = getConfirmationMessage(target, distributionSets);
    final String caption = getI18n().getMessage(CAPTION_ENTITY_ASSIGN_ACTION_CONFIRMBOX);
    final String okLabel = getI18n().getMessage(UIMessageIdProvider.BUTTON_OK);
    final String cancelLabel = getI18n().getMessage(UIMessageIdProvider.BUTTON_CANCEL);

    confirmDialog = new ConfirmationDialog(caption, confirmationMessage, okLabel, cancelLabel, ok -> {
        if (ok && isMaintenanceWindowValid(maintenanceWindowLayout, getNotification())) {
            saveAllAssignments(Collections.singletonList(target), distributionSets, managementUIState,
                    actionTypeOptionGroupLayout, maintenanceWindowLayout, deploymentManagement, getNotification(),
                    getEventBus(), getI18n(), this);
        }
    }, createAssignmentTab(actionTypeOptionGroupLayout, maintenanceWindowLayout, saveButtonToggle(), getI18n(),
            uiProperties), UIComponentIdProvider.DIST_SET_TO_TARGET_ASSIGNMENT_CONFIRM_ID);

    UI.getCurrent().addWindow(confirmDialog.getWindow());
    confirmDialog.getWindow().bringToFront();
}
 
Example #2
Source File: ActionHistoryGrid.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Show confirmation window and if ok then only, force quit action.
 *
 * @param actionId
 *            as Id if the action needs to be forced.
 */
private void confirmAndForceQuitAction(final Long actionId) {
    /* Display the confirmation */
    final ConfirmationDialog confirmDialog = new ConfirmationDialog(
            i18n.getMessage("caption.forcequit.action.confirmbox"),
            i18n.getMessage("message.forcequit.action.confirm"), i18n.getMessage(UIMessageIdProvider.BUTTON_OK),
            i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), ok -> {
                if (!ok) {
                    return;
                }
                final boolean cancelResult = forceQuitActiveAction(actionId);
                if (cancelResult) {
                    populateAndUpdateTargetDetails(selectedTarget);
                    notification.displaySuccess(i18n.getMessage("message.forcequit.action.success"));
                } else {
                    notification.displayValidationError(i18n.getMessage("message.forcequit.action.failed"));
                }
            }, FontAwesome.WARNING, UIComponentIdProvider.CONFIRMATION_POPUP_ID, null);
    UI.getCurrent().addWindow(confirmDialog.getWindow());

    confirmDialog.getWindow().bringToFront();
}
 
Example #3
Source File: ContextMenu.java    From context-menu with Apache License 2.0 6 votes vote down vote up
@Override
public void beforeClientResponse(boolean initial) {
    super.beforeClientResponse(initial);
    UI uI = getUI();
    if (uI != null && uI.getConnectorTracker().isDirty(this)) {

        /*
         * This should also be used by MenuBar, upgrading it from Vaadin 6
         * to Vaadin 7 communication mechanism. Thus to be moved e.g. to the
         * AbstractMenu.
         */
        ContextMenuState menuSharedState = getState();
        itemById = new HashMap<>();
        menuSharedState.menuItems = convertItemsToState(getItems(),
                itemById);
    }
}
 
Example #4
Source File: UrlTools.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void replaceState(String navigationState, UI ui) {
    checkNotNullArgument(navigationState, "Navigation state cannot be null");

    if (headless()) {
        log.debug("Unable to replace navigation state in headless mode");
        return;
    }

    String state = !navigationState.isEmpty()
            ? "#" + navigationState
            : "";

    Page page = ui.getPage();
    if (!state.isEmpty()) {
        page.replaceState(state);
    } else {
        page.replaceState(getEmptyFragmentUri(page));
    }
}
 
Example #5
Source File: ComponentListPresenter.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void postInitView() {
    super.postInitView();

    view.getPopupActionHandlers().setMassActionHandler(new DefaultMassEditActionHandler(this) {
        @Override
        protected void onSelectExtra(String id) {
            if (ViewItemAction.MAIL_ACTION.equals(id)) {
                UI.getCurrent().addWindow(new MailFormWindow());
            }
        }

        @Override
        protected String getReportTitle() {
            return UserUIContext.getMessage(ComponentI18nEnum.LIST);
        }

        @Override
        protected Class<?> getReportModelClassType() {
            return SimpleComponent.class;
        }
    });
}
 
Example #6
Source File: UploadProgressInfoWindow.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
UploadProgressInfoWindow(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState,
        final VaadinMessageSource i18n) {
    this.artifactUploadState = artifactUploadState;
    this.i18n = i18n;

    setPopupProperties();
    createStatusPopupHeaderComponents();

    mainLayout = new VerticalLayout();
    mainLayout.setSpacing(Boolean.TRUE);
    mainLayout.setSizeUndefined();
    setPopupSizeInMinMode();

    uploads = getGridContainer();
    grid = createGrid();
    setGridColumnProperties();

    mainLayout.addComponents(getCaptionLayout(), grid);
    mainLayout.setExpandRatio(grid, 1.0F);
    setContent(mainLayout);
    eventBus.subscribe(this);
    ui = UI.getCurrent();
}
 
Example #7
Source File: ComplianceCheckPageItemRendererClickListenerTest.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Click politician test.
 */
@Test
public void clickPoliticianTest() {
	final ComplianceCheckPageItemRendererClickListener listener = new ComplianceCheckPageItemRendererClickListener();
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
	Mockito.when(event.getItem()).thenReturn(new PoliticianComplianceCheckImpl(new ViewRiksdagenPolitician().withPersonId("personid"), null, null, null));
		
	listener.click(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo("politician/personid");
}
 
Example #8
Source File: ArtifactDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
    if (softwareModuleEvent.getEventType() == BaseEntityEventType.SELECTED_ENTITY) {
        UI.getCurrent().access(() -> {
            if (softwareModuleEvent.getEntity() != null) {
                populateArtifactDetails(softwareModuleEvent.getEntity());
            } else {
                populateArtifactDetails(null, null);
            }
        });
    }
    if (isArtifactChangedEvent(softwareModuleEvent) && areEntityIdsNotEmpty(softwareModuleEvent)) {
        UI.getCurrent().access(() -> findSelectedSoftwareModule().ifPresent(selectedSoftwareModule -> {
            if (hasSelectedSoftwareModuleChanged(softwareModuleEvent.getEntityIds(), selectedSoftwareModule)) {
                populateArtifactDetails(selectedSoftwareModule);
            }
        }));
    }
}
 
Example #9
Source File: MainLayout.java    From designer-tutorials with Apache License 2.0 6 votes vote down vote up
public MainLayout() {
    Navigator navigator = new Navigator(UI.getCurrent(), contentPanel);
    navigator.addView(StatsView.VIEW_NAME, StatsView.class);
    navigator.addView(PluginsView.VIEW_NAME, PluginsView.class);
    navigator.addView(PermissionsView.VIEW_NAME, PermissionsView.class);

    menuButton1.addClickListener(event -> doNavigate(StatsView.VIEW_NAME));
    menuButton2
            .addClickListener(event -> doNavigate(PluginsView.VIEW_NAME));
    menuButton3.addClickListener(
            event -> doNavigate(PermissionsView.VIEW_NAME));

    if (navigator.getState().isEmpty()) {
        navigator.navigateTo(StatsView.VIEW_NAME);
    } else {
        navigator.navigateTo(navigator.getState());
    }
}
 
Example #10
Source File: DistributionSetTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void openConfirmationWindowForAssignment(final String distributionNameToAssign,
        final SoftwareModuleIdName[] softwareModules) {
    final String confirmQuestion = createConfirmationMessageForAssignment(distributionNameToAssign,
            softwareModules);
    final ConfirmationDialog confirmDialog = createConfirmationWindowForAssignment(confirmQuestion);
    UI.getCurrent().addWindow(confirmDialog.getWindow());
    confirmDialog.getWindow().bringToFront();
}
 
Example #11
Source File: TargetTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@EventBusListenerMethod(scope = EventScope.UI)
void addOrEditEvent(final TargetAddUpdateWindowEvent targetUIEvent) {
    if (BaseEntityEventType.UPDATED_ENTITY != targetUIEvent.getEventType()) {
        return;
    }
    UI.getCurrent().access(() -> updateTarget(targetUIEvent.getEntity()));
}
 
Example #12
Source File: JPAUtils.java    From XACML with MIT License 5 votes vote down vote up
private static void buildFunctionMaps() {
	mapDatatype2Function = new HashMap<Datatype, List<FunctionDefinition>>();
	mapID2Function = new HashMap<String, FunctionDefinition>();
	JPAContainer<FunctionDefinition> functions = ((XacmlAdminUI)UI.getCurrent()).getFunctionDefinitions();
	for (Object id : functions.getItemIds()) {
		FunctionDefinition value = functions.getItem(id).getEntity();
		mapID2Function.put(value.getXacmlid(), value);
		if (mapDatatype2Function.containsKey(value.getDatatypeBean()) == false) {
			mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
		}
		mapDatatype2Function.get(value.getDatatypeBean()).add(value);
	}
}
 
Example #13
Source File: AbstractForm.java    From viritin with Apache License 2.0 5 votes vote down vote up
public Window openInModalPopup() {
    popup = new Window(getModalWindowTitle(), this);
    popup.setModal(true);
    UI.getCurrent().addWindow(popup);
    focusFirst();
    return popup;
}
 
Example #14
Source File: PIPManagement.java    From XACML with MIT License 5 votes vote down vote up
protected void cloneConfiguration(final EntityItem<PIPConfiguration> entity) {
	//
	// Sanity checks
	//
	if (entity == null || entity.getEntity() == null) {
		logger.warn("Cloning a null entity, the buttons were not reset. Resetting them.");
		this.setupButtons();
		return;
	}
	//
	// Clone it
	//
	PIPManagement.editConfiguration(this.container.createEntityItem(new PIPConfiguration(entity.getEntity(), ((XacmlAdminUI)UI.getCurrent()).getUserid())));
}
 
Example #15
Source File: AbstractDistributionSetDetails.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void showMetadata(final ClickEvent event) {
    final Optional<DistributionSet> ds = distributionSetManagement.get(getSelectedBaseEntityId());
    if (!ds.isPresent()) {
        uiNotification.displayWarning(getI18n().getMessage("distributionset.not.exists"));
        return;
    }
    UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds.get(), null));
}
 
Example #16
Source File: JPAUtils.java    From XACML with MIT License 5 votes vote down vote up
public static Datatype	findDatatype(String dt) {
	JPAContainer<Datatype> datatypes =  ((XacmlAdminUI)UI.getCurrent()).getDatatypes();
	
	for (Object id : datatypes.getItemIds()) {
		Datatype d = datatypes.getItem(id).getEntity();
		if (d.getIdentifer().stringValue().equals(dt)) {
			return d;
		}
	}		
	return null;
}
 
Example #17
Source File: VaadinScope.java    From jdal with Apache License 2.0 5 votes vote down vote up
public synchronized void detach(DetachEvent event) {
	UI ui = (UI) event.getConnector();
	if (log.isDebugEnabled())
		log.debug("UI [" + ui.getUIId() + "] detached, destroying scoped beans");
	
	removeBeans(ui);
	sessions.remove(ui);
	
}
 
Example #18
Source File: ArtifactDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void confirmAndDeleteArtifact(final Long id, final String fileName) {
    final ConfirmationDialog confirmDialog = new ConfirmationDialog(
            i18n.getMessage("caption.delete.artifact.confirmbox"),
            i18n.getMessage("message.delete.artifact", fileName), i18n.getMessage(UIMessageIdProvider.BUTTON_OK),
            i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), ok -> {
                if (ok) {
                    artifactManagement.delete(id);
                    uINotification.displaySuccess(i18n.getMessage("message.artifact.deleted", fileName));
                    final Optional<SoftwareModule> softwareModule = findSelectedSoftwareModule();
                    populateArtifactDetails(softwareModule.orElse(null));
                }
            });
    UI.getCurrent().addWindow(confirmDialog.getWindow());
    confirmDialog.getWindow().bringToFront();
}
 
Example #19
Source File: SecuredNavigator.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
@Override
public void navigateTo(String navigationState) {
					
	if (ViewToken.VALID_TOKENS.contains(navigationState)) {
		
		/* This method in class should be public
		 * private boolean isViewBeanNameValidForCurrentUI(String beanName)
		 * 
		 *  workaround
		 */													
		if ( viewProvider.getView(navigationState) == null ) {
           	
			/*
			 * Handle entering UI from bookmark
			 */
			String uriFragment = extractViewToken();
			if (uriFragment.equals(navigationState)) {
				
				super.navigateTo(ViewToken.HOME);
				
			} else {
				/*
            	 * View is probably @Secured
            	 */
				eventBus.publish(EventScope.UI, UI.getCurrent(), new AccessDeniedEvent(navigationState));
			}
           	            	
           } else {
           	super.navigateTo(navigationState);
           }
		
	} else {
		//invalid ViewToken
		super.navigateTo(ViewToken.HOME);
	}		
	
}
 
Example #20
Source File: SpringUIProvider.java    From jdal with Apache License 2.0 5 votes vote down vote up
@Override
public UI createInstance(UICreateEvent event) {
	ApplicationContext ctx = VaadinUtils.getApplicationContext();
	CurrentInstance.set(UIid.class, new UIid(event.getUiId()));
	UI ui = this.uiMapping.getUi(event.getRequest());
	
	if (ui == null)
		ui =  ctx.getBean(event.getUIClass());
	
	CurrentInstance.set(UIid.class, null);
	
	return ui;
}
 
Example #21
Source File: AbstractDistributionSetDetails.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onEdit(final ClickEvent event) {
    final Window newDistWindow = distributionAddUpdateWindowLayout
            .getWindowForUpdateDistributionSet(getSelectedBaseEntityId());
    UI.getCurrent().addWindow(newDistWindow);
    newDistWindow.setVisible(Boolean.TRUE);
}
 
Example #22
Source File: AbstractTagToken.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
protected void onBaseEntityEvent(final BaseUIEntityEvent<T> baseEntityEvent) {
    if (BaseEntityEventType.SELECTED_ENTITY != baseEntityEvent.getEventType()) {
        return;
    }
    UI.getCurrent().access(() -> {
        final T entity = baseEntityEvent.getEntity();
        if (entity != null) {
            selectedEntity = entity;
            repopulateTags();
        }
    });
}
 
Example #23
Source File: MultiFileUpload.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void resetPollIntervalIfNecessary() {
    if (savedPollInterval != null
            && getprogressBarsLayout().getComponentCount() == 0) {
        UI current = UI.getCurrent();
        current.setPollInterval(savedPollInterval);
        savedPollInterval = null;
    }
}
 
Example #24
Source File: JPAUtils.java    From XACML with MIT License 5 votes vote down vote up
public static Datatype	findDatatype(Identifier dt) {
	JPAContainer<Datatype> datatypes =  ((XacmlAdminUI)UI.getCurrent()).getDatatypes();
	
	for (Object id : datatypes.getItemIds()) {
		Datatype d = datatypes.getItem(id).getEntity();
		if (d.getIdentifer().equals(dt)) {
			return d;
		}
	}		
	return null;
}
 
Example #25
Source File: TargetTableHeader.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final BulkUploadPopupEvent event) {
    if (BulkUploadPopupEvent.MAXIMIMIZED == event) {
        targetBulkUpdateWindow.restoreComponentsValue();
        openBulkUploadWindow();
    } else if (BulkUploadPopupEvent.CLOSED == event) {
        UI.getCurrent().access(this::enableBulkUpload);
    }
}
 
Example #26
Source File: FilterManagementView.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final CustomFilterUIEvent custFilterUIEvent) {
    if (custFilterUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
        viewTargetFilterDetailLayout();
    } else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
        this.getUI().access(this::viewCreateTargetFilterLayout);
    } else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW
            || custFilterUIEvent == CustomFilterUIEvent.SHOW_FILTER_MANAGEMENT) {
        UI.getCurrent().access(this::viewListView);
    }
}
 
Example #27
Source File: AbstractTableDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Default implementation to handle an entity event.
 *
 * @param baseEntityEvent
 *            the event
 */
protected void onBaseEntityEvent(final BaseUIEntityEvent<T> baseEntityEvent) {
    final BaseEntityEventType eventType = baseEntityEvent.getEventType();
    if (BaseEntityEventType.SELECTED_ENTITY == eventType || BaseEntityEventType.UPDATED_ENTITY == eventType
            || BaseEntityEventType.REMOVE_ENTITY == eventType) {
        UI.getCurrent().access(() -> populateData(baseEntityEvent.getEntity()));
    } else if (BaseEntityEventType.MINIMIZED == eventType) {
        UI.getCurrent().access(() -> setVisible(true));
    } else if (BaseEntityEventType.MAXIMIZED == eventType) {
        UI.getCurrent().access(() -> setVisible(false));
    }
}
 
Example #28
Source File: TargetTableHeader.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void addNewItem(final ClickEvent event) {
    targetAddUpdateWindow.resetComponents();
    final Window addTargetWindow = targetAddUpdateWindow.createNewWindow();
    addTargetWindow.setCaption(i18n.getMessage("caption.create.new", i18n.getMessage("caption.target")));
    UI.getCurrent().addWindow(addTargetWindow);
    addTargetWindow.setVisible(Boolean.TRUE);
}
 
Example #29
Source File: RolloutListGrid.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles the RolloutEvent to refresh Grid.
 *
 */
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final RolloutEvent event) {
    switch (event) {
    case FILTER_BY_TEXT:
    case CREATE_ROLLOUT:
    case UPDATE_ROLLOUT:
    case SHOW_ROLLOUTS:
        refreshContainer();
        break;
    default:
        break;
    }
}
 
Example #30
Source File: SecuredNavigator.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
public SecuredNavigator(UI ui, ViewDisplay display, SpringViewProvider viewProvider, Security security, EventBus eventBus) {
	super(ui, display);		
	this.security = security;
	this.viewProvider = viewProvider;
	this.eventBus = eventBus;
	addProvider(this.viewProvider);
}