org.apache.wicket.request.resource.PackageResourceReference Java Examples

The following examples show how to use org.apache.wicket.request.resource.PackageResourceReference. 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: SlidebarBehavior.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
@Override
    public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);

        response.render(CssHeaderItem.forReference(new PackageResourceReference(SlidebarBehavior.class, "slidebars.css")));
        response.render(CssHeaderItem.forUrl("css/slidebar.css"));
        response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(SlidebarBehavior.class, "slidebars.js")));

        Map<String, String> vars = new HashMap<String, String>();
//        vars.put("siteClose", "true");

        PackageTextTemplate template = new PackageTextTemplate(SlidebarBehavior.class, "slidebar-behavior.template.js");
//        template.interpolate(vars);

        response.render(OnDomReadyHeaderItem.forScript(template.getString()));
    }
 
Example #2
Source File: BundleAwareResourceReferenceFactory.java    From onedev with MIT License 5 votes vote down vote up
@Override
public ResourceReference create(Key key) {
	if (PackageResource.exists(key)) {
		return new PackageResourceReference(key);
	} else {
		for (ConcatResourceBundleReference<? extends IReferenceHeaderItem> bundle: bundles) {
			if (bundle.getScope().getName().equals(key.getScope())) {
				String bundleParentPath = getParentPath(bundle.getName());
				String relativePath;
				if (bundleParentPath != null)
					relativePath = PathUtils.relativize(bundleParentPath, key.getName());
				else
					relativePath = key.getName();
				for (IReferenceHeaderItem headerItem: bundle.getProvidedResources()) {
					String referenceParentPath = getParentPath(headerItem.getReference().getName());
					String possibleName;
					if (referenceParentPath != null)
						possibleName = PathUtils.resolve(referenceParentPath, relativePath);
					else
						possibleName = relativePath.toString();
					possibleName = PathUtils.normalizeDots(possibleName);
					if (possibleName != null) {
						Key possibleKey = new Key(headerItem.getReference().getScope().getName(), possibleName, 
								key.getLocale(), key.getStyle(), key.getVariation());
						if (PackageResource.exists(possibleKey)) {
							return new PackageResourceReference(possibleKey);
						}
					}
				}
			}
		}
		return null;
	}
}
 
Example #3
Source File: BasePage.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

       // add nextserver.js
	new NextServerJavaScriptContributor().renderHead(response);

       // add busy-indicator.js
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(BasePage.class, "busy-indicator.js")));

       if (isInternetExplorer()) {        	
           response.render(JavaScriptHeaderItem.forUrl("js/jquery.pngFix.js"));
           response.render(JavaScriptHeaderItem.forUrl("js/pngFix.js"));
       }
}
 
Example #4
Source File: JGrowlAjaxBehavior.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(JGrowlAjaxBehavior.class, "jquery.jgrowl.js")));
       response.render(CssHeaderItem.forReference(new PackageResourceReference(JGrowlAjaxBehavior.class, "jquery.jgrowl.css")));
       response.render(CssHeaderItem.forReference(new PackageResourceReference(JGrowlAjaxBehavior.class, "jgrowl.css")));

	String feedback = renderFeedback();
	if (!StringUtils.isEmpty(feedback)) {
		response.render(OnDomReadyHeaderItem.forScript(feedback));
	}
}
 
Example #5
Source File: PivotPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
       response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(PivotPanel.class, "pivot.js")));
       //response.render(CssHeaderItem.forReference(new PackageResourceReference(PivotPanel.class, "pivot.css")));
}
 
Example #6
Source File: DashboardPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
       response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(DashboardPanel.class, "dashboard.js")));       
       response.render(JavaScriptHeaderItem.forReference(HTML2CANVAS_JS));
       response.render(JavaScriptHeaderItem.forReference(JSPDF_JS));
       response.render(JavaScriptHeaderItem.forReference(NEXTCHARTS_JS));
}
 
Example #7
Source File: OpenFlashChart.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	//System.out.println("OpenFlashChart.onInitialize()");
	super.onInitialize();
	
	String swfURL = toAbsolutePath(urlFor(new PackageResourceReference(OpenFlashChart.class, "open-flash-chart.swf"), null).toString());
	
	// see http://ofc2dz.com/OFC2/downloads/ofc2Downloads.html
	// http://ofc2dz.com/OFC2/examples/MiscellaneousPatches.html (Passing the Char Parameter "ID" when saving images (23-Feb-2009))
	// for embedded charts in html pages we also put some randomness at the end (if we have charts from different dashboards id is chart1 for all)
	swfURL = swfURL.concat("?id=").concat(getMarkupId()).concat("&nocache=").concat(UUID.randomUUID().toString());;
	//System.out.println("swfURL = " + swfURL);
	swf = new SWFObject(swfURL, width, height, "9.0.0");
	add(swf);
}
 
Example #8
Source File: WicketRenderHeadUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private static void handleWicketResourceHandledJavascript() {
  // handle wicket resource handled javascript files
  final long startTime = WicketApplication.getStartTime();
  String name = null;
  String versionName = null;
  for (int i = 0; i < JAVASCRIPT_FILES_JAVA_DEF.length; i++) {
    name = JAVASCRIPT_FILES_JAVA_DEF[i][0] + ".js";
    versionName = JAVASCRIPT_FILES_JAVA_DEF[i][0] + "-version-" + startTime + ".js";
    WicketApplication.get().mountResource(versionName,
        new PackageResourceReference(WicketApplication.class, name));
    JAVASCRIPT_FILES_JAVA[i] = "wa/" + versionName;
  }
}
 
Example #9
Source File: TransactionRequestCycleListener.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isOurContent(RequestCycle cycle, IRequestHandler handler) {
	if(handler instanceof ResourceReferenceRequestHandler)
	{
		ResourceReferenceRequestHandler rrrHandler = (ResourceReferenceRequestHandler)handler;
		ResourceReference reference = rrrHandler.getResourceReference();
		return !(reference instanceof PackageResourceReference);
	}
	return true;
}
 
Example #10
Source File: WicketApplicationBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
protected void initLogoReference()
{
    Properties settings = SettingsUtil.getSettings();
    String logoValue = settings.getProperty(SettingsUtil.CFG_STYLE_LOGO);
    if (StringUtils.isNotBlank(logoValue) && new File(logoValue).canRead()) {
        getSharedResources().add("logo", new FileSystemResource(new File(logoValue)));
        mountResource("/assets/logo.png", new SharedResourceReference("logo"));
    }
    else {
        mountResource("/assets/logo.png", new PackageResourceReference(getLogoLocation()));
    }
}
 
Example #11
Source File: EmojiNodeRenderer.java    From onedev with MIT License 5 votes vote down vote up
private void render(EmojiNode node, NodeRendererContext context, HtmlWriter html) {
  	String emojiName = node.getText().toString();
  	String emojiUrl = null;
if (RequestCycle.get() != null) {
	String emojiCode = EmojiOnes.getInstance().all().get(emojiName);
	if (emojiCode != null) {
		emojiUrl = RequestCycle.get().urlFor(new PackageResourceReference(
				EmojiOnes.class, "icon/" + emojiCode + ".png"), new PageParameters()).toString();
	} 
}

if (emojiUrl != null) {
          ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, emojiUrl, null);
          html.attr("src", emojiUrl);
          html.attr("alt", "emoji " + emojiName);
          if (!attrImageSize.isEmpty()) 
          	html.attr("height", attrImageSize).attr("width", attrImageSize);
          if (!attrAlign.isEmpty()) 
          	html.attr("align", attrAlign);
          html.withAttr(resolvedLink);
          html.tagVoid("img");
} else {
          // output as text
          html.text(":");
          context.renderChildren(node);
          html.text(":");
}

  }
 
Example #12
Source File: GradebookNgApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void init() {
	super.init();

	// page mounting for bookmarkable URLs
	mountPage("/grades", GradebookPage.class);
	mountPage("/settings", SettingsPage.class);
	mountPage("/importexport", ImportExportPage.class);
	mountPage("/permissions", PermissionsPage.class);
	mountPage("/gradebook", StudentPage.class);
	mountPage("/accessdenied", AccessDeniedPage.class);
	mountPage("/error", ErrorPage.class);

	// remove the version number from the URL so that browser refreshes re-render the page
	getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);

	// Configure for Spring injection
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Add ResourceLoader that integrates with Sakai's Resource Loader
	getResourceSettings().getStringResourceLoaders().add(0, new GradebookNgStringResourceLoader());

	// Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);

	// Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);

	// Don't add any extra tags around a disabled link (default is <em></em>)
	getMarkupSettings().setDefaultBeforeDisabledLink(null);
	getMarkupSettings().setDefaultAfterDisabledLink(null);

	// On Wicket session timeout, redirect to main page
	// getApplicationSettings().setPageExpiredErrorPage(getHomePage());

	// Intercept any unexpected error stacktrace and take to our page
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
			return new RenderPageRequestHandler(new PageProvider(new ErrorPage(e)));
		}
	});

	// Disable Wicket's loading of jQuery - we load Sakai's preferred version in BasePage.java
	getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(GradebookNgApplication.class, "empty.js"));

	// cleanup the HTML
	getMarkupSettings().setStripWicketTags(true);
	getMarkupSettings().setStripComments(true);
	getMarkupSettings().setCompressWhitespace(true);
}
 
Example #13
Source File: GradebookNgApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void init() {
	super.init();

	// page mounting for bookmarkable URLs
	mountPage("/grades", GradebookPage.class);
	mountPage("/settings", SettingsPage.class);
	mountPage("/importexport", ImportExportPage.class);
	mountPage("/permissions", PermissionsPage.class);
	mountPage("/gradebook", StudentPage.class);
	mountPage("/accessdenied", AccessDeniedPage.class);
	mountPage("/error", ErrorPage.class);

	// remove the version number from the URL so that browser refreshes re-render the page
	getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);

	// Configure for Spring injection
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Add ResourceLoader that integrates with Sakai's Resource Loader
	getResourceSettings().getStringResourceLoaders().add(0, new GradebookNgStringResourceLoader());

	// Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);

	// Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);

	// Don't add any extra tags around a disabled link (default is <em></em>)
	getMarkupSettings().setDefaultBeforeDisabledLink(null);
	getMarkupSettings().setDefaultAfterDisabledLink(null);

	// On Wicket session timeout, redirect to main page
	// getApplicationSettings().setPageExpiredErrorPage(getHomePage());

	// Intercept any unexpected error stacktrace and take to our page
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
			return new RenderPageRequestHandler(new PageProvider(new ErrorPage(e)));
		}
	});

	// Disable Wicket's loading of jQuery - we load Sakai's preferred version in BasePage.java
	getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(GradebookNgApplication.class, "empty.js"));

	// cleanup the HTML
	getMarkupSettings().setStripWicketTags(true);
	getMarkupSettings().setStripComments(true);
	getMarkupSettings().setCompressWhitespace(true);
}
 
Example #14
Source File: OArchitectEditorWidget.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    response.render(CssReferenceHeaderItem.forReference(OARCHITECT_CSS));
    response.render(CssReferenceHeaderItem.forReference(MXGRAPH_CSS));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/OArchitectApplication.js")));
    response.render(JavaScriptHeaderItem.forScript(
            String.format("initMxGraph('%s');", "en"), null));
    response.render(JavaScriptHeaderItem.forReference(MXGRAPH_JS));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectEditor.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectBar.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOType.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectMessage.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectPopupMenu.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectValueContainer.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OClassEditModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OPropertyEditModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/behavior/OArchitectAction.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphConnectionConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphStyleConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectCommand.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectUtil.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOClass.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOProperty.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectConstants.js")));
    String locale = getOArchitectEditorLocale();
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class,
            String.format("js/util/locale/architect_%s.js", locale))));

    PackageResourceReference configXml = new PackageResourceReference(OArchitectEditorWidget.class, "js/OArchitectApplication.js");
    String configUrl = urlFor(configXml, null).toString();
    String baseUrl = configUrl.substring(0, configUrl.indexOf("js/OArchitectApplication"));
    TextTemplate configTemplate = new PackageTextTemplate(OArchitectEditorWidget.class, "config.tmpl.xml");
    Map<String, Object> params = CommonUtils.toMap("basePath", baseUrl);
    String config = configTemplate.asString(params);
    boolean canUpdate = canUserUpdateEditor();
    response.render(OnLoadHeaderItem.forScript(String.format("initOrienteerArchitect('%s', %s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s);",
            baseUrl,
            CommonUtils.escapeAndWrapAsJavaScriptString(config),
            locale,
            this.getMarkupId(),
            container.getMarkupId(),
            editor.getMarkupId(),
            sidebar.getMarkupId(),
            toolbar.getMarkupId(),
            outline.getMarkupId(),
            Boolean.toString(canUpdate))));
}
 
Example #15
Source File: SWFObject.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(SWFObject.class, "swfobject-2.2.js")));
	response.render(JavaScriptHeaderItem.forScript(getJavaScript(), null));
}
 
Example #16
Source File: OpenFlashChart.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(OpenFlashChart.class, "saveChartImage.js")));
}
 
Example #17
Source File: PathHit.java    From onedev with MIT License 4 votes vote down vote up
@Override
public Image renderIcon(String componentId) {
	return new NoAntiCacheImage(componentId, new PackageResourceReference(PathHit.class, "file.png"));
}
 
Example #18
Source File: PivotAreaPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(PivotAreaPanel.class, "pivot.js")));
}
 
Example #19
Source File: FileHit.java    From onedev with MIT License 4 votes vote down vote up
@Override
public Image renderIcon(String componentId) {
	return new NoAntiCacheImage(componentId, new PackageResourceReference(FileHit.class, "file.png"));
}
 
Example #20
Source File: ExtendedPalette.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(ExtendedPalette.class, "extendedpalette.js")));
}
 
Example #21
Source File: TextHit.java    From onedev with MIT License 4 votes vote down vote up
@Override
public Image renderIcon(String componentId) {
	return new NoAntiCacheImage(componentId, new PackageResourceReference(FileHit.class, "bullet.gif"));
}
 
Example #22
Source File: GitHubConnector.java    From onedev with MIT License 4 votes vote down vote up
@Override
public String getButtonImageUrl() {
	ResourceReference logo = new PackageResourceReference(GitHubConnector.class, "octocat.png");
	return RequestCycle.get().urlFor(logo, new PageParameters()).toString();
}
 
Example #23
Source File: UrlParametersReceivingBehavior.java    From webanno with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link HeaderItem} representing the JavaScript library used to read and write URL
 * fragment parameters.
 * 
 * @param scope
 *            the scope of the {@link PackageResourceReference}
 * @return
 */
protected static HeaderItem getJS(Class<?> scope)
{
    PackageResourceReference ref = new PackageResourceReference(scope, "urlfragment.js");
    return JavaScriptHeaderItem.forReference(ref, ref.getName());
}