org.apache.wicket.RuntimeConfigurationType Java Examples

The following examples show how to use org.apache.wicket.RuntimeConfigurationType. 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: ServerSideJs.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBeforeRender() {

    final boolean deploymentMode = Application.get().getConfigurationType() == RuntimeConfigurationType.DEPLOYMENT;

    addOrReplace(new Label("jsInclude", new StringBuilder()
        .append("<script type=\"text/javascript\">")
        .append("var ctx = {").append("\n")
        .append("  url: document.URL,\n")
        .append("  live: ").append(deploymentMode).append(",\n")
        .append("  page: '").append(getPage().getClass().getSimpleName()).append("',\n")
        .append("  root: '").append(getWicketUtil().getHttpServletRequest().getContextPath()).append("',\n")
        .append("  resources: {\n")
        .append("     areYouSure: '").append(getLocalizer().getString("areYouSure", this)).append("',\n")
        .append("     yes: '").append(getLocalizer().getString("yes", this)).append("',\n")
        .append("     no: '").append(getLocalizer().getString("no", this)).append("',\n")
        .append("     wishlistTagsInfo: '").append(getLocalizer().getString("wishlistTagsInfo", this)).append("',\n")
        .append("     wishlistTagLinkOffInfo: '").append(getLocalizer().getString("wishlistTagLinkOffInfo", this)).append("',\n")
        .append("     wishlistTagLinkOnInfo: '").append(getLocalizer().getString("wishlistTagLinkOnInfo", this)).append("'\n")
        .append("  }\n")
        .append("}\n")
        .append("</script>").toString()).setEscapeModelStrings(false));

    super.onBeforeRender();
}
 
Example #2
Source File: Application.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
public static String getString(String key, final Locale loc, String... _params) {
	if (!exists()) {
		ThreadContext.setApplication(org.apache.wicket.Application.get(appName));
	}
	String[] params = _params;
	if ((params == null || params.length == 0) && STRINGS_WITH_APP.contains(key)) {
		params = new String[]{getApplicationName()};
	}
	Localizer l = get().getResourceSettings().getLocalizer();
	String value = l.getStringIgnoreSettings(key, null, null, loc, null, "[Missing]");
	if (params != null && params.length > 0) {
		final MessageFormat format = new MessageFormat(value, loc);
		value = format.format(params);
	}
	if (RuntimeConfigurationType.DEVELOPMENT == get().getConfigurationType()) {
		value += String.format(" [%s]", key);
	}
	return value;
}
 
Example #3
Source File: AbstractWebPage.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
private void determineStatefulComponentOnDev() {

        if (Application.get().getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT && !isPageStateless()) {

            final List<String> statefulComponentIds = new ArrayList<>();
            this.visitChildren(Component.class, (object, objectIVisit) -> {
                if (!object.isStateless()) {
                    statefulComponentIds.add(object.getId());
                }
            });
            LOG.warn("[DEV] Page {} is stateful because of the following components: {}", getClass().getCanonicalName(), statefulComponentIds);

        }
    }
 
Example #4
Source File: MavenArtifactNotifierApplication.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
	super.init();
	
	if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
		getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
	}
	
	if (RuntimeConfigurationType.DEPLOYMENT.equals(getConfigurationType())) {
		addResourceReplacement(JQueryResourceReference.get(),
				new UrlResourceReference(Url.parse("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")));
	}
}
 
Example #5
Source File: WicketApplication.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Own solution: uses development parameter of servlet context init parameter (see context.xml or server.xml).
 * @return DEVELOPMENT, if development variable of servlet context is set to "true" otherwise DEPLOYMENT.
 * @see org.apache.wicket.protocol.http.WebApplication#getConfigurationType()
 */
@Override
public RuntimeConfigurationType getConfigurationType()
{
  if (isDevelopmentSystem() == true) {
    return RuntimeConfigurationType.DEVELOPMENT;
  }
  return RuntimeConfigurationType.DEPLOYMENT;
}
 
Example #6
Source File: Module.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy(OrienteerWebApplication app, ODatabaseDocument db) {
	super.onDestroy(app, db);
	app.getDebugSettings()
			.setDevelopmentUtilitiesEnabled(app.getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT);
	app.getComponentInitializationListeners().remove(this);
	WicketConsolePage.setWicketConsolePageImplementation(null);
	app.unmountPackage("org.orienteer.devutils.web");
	app.unmount("/devutils/"+LiveSessionsPage.class.getSimpleName());
	app.unmount("/wicket-console");
	app.unregisterWidgets("org.orienteer.devutils.component.widget");
}
 
Example #7
Source File: HTMLValidatorConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	if (RuntimeConfigurationType.DEVELOPMENT == webApplication.getConfigurationType()) {
		webApplication.getMarkupSettings().setStripWicketTags(true);
		webApplication.getRequestCycleSettings().addResponseFilter(new HtmlValidationResponseFilter());
	}
}
 
Example #8
Source File: DocumentNamePanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private String getLabel()
{
    StringBuilder sb = new StringBuilder();

    AnnotatorState state = getModelObject();

    if (state.getUser() != null) {
        sb.append(state.getUser().getUsername());
        sb.append(": ");
    }
    
    if (state.getProject() != null) {
        sb.append(state.getProject().getName());
    }

    sb.append("/");

    if (state.getDocument() != null) {
        sb.append(state.getDocument().getName());
    }

    if (RuntimeConfigurationType.DEVELOPMENT.equals(getApplication().getConfigurationType())) {
        sb.append(" (");
        if (state.getProject() != null) {
            sb.append(state.getProject().getId());
        }
        sb.append("/");
        if (state.getDocument() != null) {
            sb.append(state.getDocument().getId());
        }
        sb.append(")");
    }

    return sb.toString();
}
 
Example #9
Source File: ApplicationPageBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
protected void onConfigure()
{
    super.onConfigure();

    // Do not cache pages in development mode - allows us to make changes to the HMTL without
    // having to reload the application
    if (RuntimeConfigurationType.DEVELOPMENT.equals(getApplication().getConfigurationType())) {
        getApplication().getMarkupSettings().getMarkupFactory().getMarkupCache().clear();
        getApplication().getResourceSettings()
                .setCachingStrategy(NoOpResourceCachingStrategy.INSTANCE);
    }
}
 
Example #10
Source File: ProjectDetailPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
public ProjectDetailPanel(String id, IModel<Project> aModel)
{
    super(id, aModel);
    
    projectModel = aModel;
    
    Form<Project> form = new Form<>("form", CompoundPropertyModel.of(aModel));
    add(form);
    
    TextField<String> projectNameTextField = new TextField<>("name");
    projectNameTextField.setRequired(true);
    projectNameTextField.add(new ProjectExistsValidator());
    projectNameTextField.add(new ProjectNameValidator());
    form.add(projectNameTextField);

    // If we run in development mode, then also show the ID of the project
    form.add(idLabel = new Label("id"));
    idLabel.setVisible(RuntimeConfigurationType.DEVELOPMENT
            .equals(getApplication().getConfigurationType()));

    form.add(new TextArea<String>("description").setOutputMarkupId(true));
    
    DropDownChoice<ScriptDirection> scriptDirection = new BootstrapSelect<>("scriptDirection");
    scriptDirection.setChoiceRenderer(new EnumChoiceRenderer<>(this));
    scriptDirection.setChoices(Arrays.asList(ScriptDirection.values()));
    form.add(scriptDirection);
    
    form.add(new CheckBox("disableExport").setOutputMarkupPlaceholderTag(true));

    form.add(new CheckBox("anonymousCuration").setOutputMarkupPlaceholderTag(true));

    form.add(projectTypes = makeProjectTypeChoice());
    
    form.add(new LambdaAjaxButton<>("save", this::actionSave));
}
 
Example #11
Source File: ApplicationHelper.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
private static WebApplication initApp(WebApplication app) {
	if (app != null) {
		try {
			app.getServletContext();
		} catch(IllegalStateException e) {
			app.setServletContext(new MockServletContext(app, null));
		}
		app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
		OMContextListener omcl = new OMContextListener();
		omcl.contextInitialized(new ServletContextEvent(app.getServletContext()));
		ThreadContext.setApplication(app);
		app.initApplication();
	}
	return app;
}
 
Example #12
Source File: OneWebApplication.java    From onedev with MIT License 5 votes vote down vote up
@Override
public RuntimeConfigurationType getConfigurationType() {
	if (Bootstrap.sandboxMode && !Bootstrap.prodMode)
		return RuntimeConfigurationType.DEVELOPMENT;
	else
		return RuntimeConfigurationType.DEPLOYMENT;
}
 
Example #13
Source File: WicketBootStandardWebApplication.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeConfigurationType getConfigurationType() {
	return generalSettingsProperties.getConfigurationType();
}
 
Example #14
Source File: WicketBootSecuredWebApplication.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeConfigurationType getConfigurationType() {
	return generalSettingsProperties.getConfigurationType();
}
 
Example #15
Source File: WicketApplicationBase.java    From webanno with Apache License 2.0 4 votes vote down vote up
protected void initStatelessChecker()
{
    if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
        getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
    }
}
 
Example #16
Source File: GeneralSettingsProperties.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
public RuntimeConfigurationType getConfigurationType() {
	return configurationType;
}
 
Example #17
Source File: GeneralSettingsProperties.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
public void setConfigurationType(RuntimeConfigurationType configurationType) {
	this.configurationType = configurationType;
}
 
Example #18
Source File: EtcdViewerApplication.java    From etcd-viewer with Apache License 2.0 3 votes vote down vote up
/**
 * @see org.apache.wicket.Application#init()
 */
@Override
public void init()
{
    super.init();

    getComponentInstantiationListeners().add(new GuiceComponentInjector(this, new RestModule()));

    if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT) {

        getResourceSettings().setUseMinifiedResources(false);
        getDebugSettings().setDevelopmentUtilitiesEnabled(true);

    } else {

        getResourceSettings().setUseMinifiedResources(true);
        getDebugSettings().setDevelopmentUtilitiesEnabled(false);

    }

    getMarkupSettings().setStripWicketTags(true);

    mountPage("/home", HomePage.class);
    mountPage("/etcd/#{cluster}", NavigationPage.class);
    mountPage("/registries", RegistriesPage.class);

    mountPage("/about", AboutPage.class);

    mountPage("/signin", AuthPage.class);

    // add your configuration here
}