Java Code Examples for org.apache.wicket.markup.head.IHeaderResponse

The following examples show how to use org.apache.wicket.markup.head.IHeaderResponse. These examples are extracted from open source projects. 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 Project: inception   Source File: HtmlAnnotationEditor.java    License: Apache License 2.0 6 votes vote down vote up
private static void initAnnotatorJs(IHeaderResponse aResponse, WebComponent aContainer,
        StoreAdapter aAdapter)
{
    String callbackUrl = aAdapter.getCallbackUrl().toString();
    StringBuilder script = new StringBuilder();
    script.append(
            "var ann = $('#" + aContainer.getMarkupId() + "').annotator({readOnly: true});");
    script.append("ann.annotator('addPlugin', 'Store', {");
    script.append("    prefix: null,");
    script.append("    emulateJSON: true,");
    script.append("    emulateHTTP: true,");
    script.append("    urls: {");
    script.append("        read:    '" + callbackUrl + "',");
    script.append("        create:  '" + callbackUrl + "',");
    script.append("        update:  '" + callbackUrl + "',");
    script.append("        destroy: '" + callbackUrl + "',");
    script.append("        search:  '" + callbackUrl + "'");
    script.append("    }");
    script.append("});");
    // script.append("Wicket.$('" + vis.getMarkupId() + "').annotator = ann;");
    aResponse.render(OnDomReadyHeaderItem.forScript(script.toString()));
}
 
Example 2
Source Project: onedev   Source File: Select2Choice.java    License: MIT License 6 votes vote down vote up
@Override
protected void renderInitializationScript(IHeaderResponse response) {
	T value;
	if (getWebRequest().getRequestParameters().getParameterNames().contains(getInputName())) {
		convertInput();
		value = getConvertedInput();
	} else {
		value = getModelObject();
	}
	if (value != null) {

		JsonBuilder selection = new JsonBuilder();

		try {
			selection.object();
			getProvider().toJson(value, selection);
			selection.endObject();
		} catch (JSONException e) {
			throw new RuntimeException("Error converting model object to Json", e);
		}
		response.render(OnLoadHeaderItem.forScript(
				JQuery.execute("$('#%s').select2('data', %s);", getJquerySafeMarkupId(), selection.toJson())));
	} else {
		clearInput();
	}
}
 
Example 3
Source Project: onedev   Source File: InfiniteScrollBehavior.java    License: MIT License 6 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptReferenceHeaderItem.forReference(new InfiniteScrollResourceReference()));
	
	String itemSelector;
	if (getItemSelector() != null)
		itemSelector = "'"+JavaScriptEscape.escapeJavaScript(getItemSelector())+"'";
	else
		itemSelector = "undefined";
	
	// Run onload script as the container size might be adjusted in window resize event (which 
	// happens before onload). An example is the issue board columns
	String script = String.format("onedev.server.infiniteScroll.onLoad('%s', %s, %s, %s);", 
			component.getMarkupId(true), getCallbackFunction(explicit("offset"), explicit("count")), 
			pageSize, itemSelector);
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 4
Source Project: onedev   Source File: SourceLinesPage.java    License: MIT License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	Map<Day, Map<String, Integer>> lineIncrements = OneDev.getInstance(CommitInfoManager.class).getLineIncrements(getProject());
	Map<Integer, Map<String, Integer>> data = new HashMap<>();
	for (Map.Entry<Day, Map<String, Integer>> entry: lineIncrements.entrySet()) 
		data.put(entry.getKey().getValue(), entry.getValue());
	try {
		ObjectMapper mapper = OneDev.getInstance(ObjectMapper.class);
		String jsonOfData = mapper.writeValueAsString(data);
		String jsonOfDefaultBranch = mapper.writeValueAsString(getProject().getDefaultBranch());
		String script = String.format("onedev.server.stats.sourceLines.onDomReady(%s, %s);", 
				jsonOfData, jsonOfDefaultBranch);
		response.render(OnDomReadyHeaderItem.forScript(script));
	} catch (JsonProcessingException e) {
		throw new RuntimeException(e);
	}
}
 
Example 5
Source Project: onedev   Source File: CodePropertyEditor.java    License: MIT License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new CodeSupportResourceReference()));

	CallbackParameter matchWith = CallbackParameter.explicit("matchWith");
	CallbackParameter line = CallbackParameter.explicit("line");
	CallbackParameter start = CallbackParameter.explicit("start");
	CallbackParameter end = CallbackParameter.explicit("end");
	String script = String.format(
			"onedev.server.codeSupport.onEditorDomReady('%s', '%s', %s);", 
			input.getMarkupId(), 
			getCode().language(), 
			behavior.getCallbackFunction(matchWith, line, start, end));
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 6
Source Project: onedev   Source File: MarkdownViewer.java    License: MIT License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new LozadResourceReference()));
	response.render(JavaScriptHeaderItem.forReference(new MarkdownResourceReference()));
	
	CharSequence taskCallback = taskBehavior.getCallbackFunction(
			explicit(SourcePositionTrackExtension.DATA_START_ATTRIBUTE), 
			explicit(TASK_CHECKED));
	
	CharSequence referenceCallback = referenceBehavior.getCallbackFunction(
			explicit(REFERENCE_TYPE), explicit(REFERENCE_ID));
	
	String script = String.format("onedev.server.markdown.onViewerDomReady('%s', %s, '%s', %s);", 
			getMarkupId(), 
			contentVersionSupport!=null?taskCallback:"undefined", 
			SourcePositionTrackExtension.DATA_START_ATTRIBUTE, 
			referenceCallback);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 7
Source Project: onedev   Source File: DropzoneField.java    License: MIT License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new DropzoneFieldResourceReference()));
	
	String script = String.format(
			"onedev.server.dropzone.onDomReady('%s', '%s', %s, %s, %s, %d);", 
			getMarkupId(), 
			uploadBehavior.getCallbackUrl(), 
			deleteBehavior.getCallbackFunction(CallbackParameter.explicit("name")),
			acceptedFiles!=null?"'" + acceptedFiles + "'":"null",				
			maxFiles!=0?maxFiles:"null",
			maxFilesize);
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 8
Source Project: onedev   Source File: ProjectBlobPage.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	response.render(JavaScriptHeaderItem.forReference(new ProjectBlobResourceReference()));
	
	String callback = ajaxBehavior.getCallbackFunction(explicit("action")).toString();
	String script = String.format("onedev.server.projectBlob.onDomReady(%s);", callback);
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 9
Source Project: inception   Source File: ConceptFeatureEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse)
{
    super.renderHead(aResponse);

    aResponse.render(forReference(KendoChoiceDescriptionScriptReference.get()));
}
 
Example 10
Source Project: inception   Source File: PropertyFeatureEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse)
{
    super.renderHead(aResponse);

    aResponse.render(forReference(KendoChoiceDescriptionScriptReference.get()));
}
 
Example 11
Source Project: inception   Source File: TutorialFooterPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void renderHead(IHeaderResponse aResponse) {
        aResponse.render(JavaScriptHeaderItem.forReference(WebAnnoJavascriptReference.get()));
        
        //TODO move it back to web jars after latest release
        aResponse.render(JavaScriptHeaderItem.forReference(EnjoyHintJsReference.get()));
//        aResponse.render(JavaScriptHeaderItem
//                .forReference(new WebjarsJavaScriptResourceReference("enjoyhint/current/enjoyhint.js")));

        // Loading resources for the tour guide feature for the new users
        aResponse.render(JavaScriptHeaderItem.forReference(
                new WebjarsJavaScriptResourceReference("enjoyhint/current/jquery.enjoyhint.js")));
        aResponse.render(CssHeaderItem.forReference(
                new WebjarsCssResourceReference("enjoyhint/current/jquery.enjoyhint.css")));
        aResponse.render(JavaScriptHeaderItem.forReference(new WebjarsJavaScriptResourceReference(
                "jquery.scrollTo/current/jquery.scrollTo.js")));
        aResponse.render(JavaScriptHeaderItem.forReference(
                new WebjarsJavaScriptResourceReference("kinetic/current/kinetic.min.js")));

        aResponse.render(JavaScriptHeaderItem.forReference(TutorialJavascriptReference.get()));
        // add top-margin to next button to fix label and buttons overlapping
        aResponse.render(CssHeaderItem.forCSS(
                ".enjoyhint_next_btn{\n" +
                "  margin-top: 8px;\n" +
                "}",
                "enjoyhint"));
        // check if the tutorial will need to be run
        aResponse.render(OnLoadHeaderItem
                .forScript("setContextPath('" + context.getContextPath() + "');\n" +
                           "runRoutines();"));
    }
 
Example 12
Source Project: onedev   Source File: ImageDiffPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new ImageDiffResourceReference()));
	String script = String.format("onedev.server.imageDiff.onDomReady('%s');", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 13
Source Project: onedev   Source File: InputAssistBehavior.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	response.render(JavaScriptHeaderItem.forReference(new InputAssistResourceReference()));
	
	String script = String.format("onedev.server.inputassist.onDomReady('%s', %s);", 
			getComponent().getMarkupId(true), 
			getCallbackFunction(explicit("type"), explicit("input"), explicit("caret")));
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 14
Source Project: onedev   Source File: OnTypingDoneBehavior.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	response.render(JavaScriptHeaderItem.forReference(new DoneEventsResourceReference()));
	String script = String.format(""
			+ "var $input = $('#%s');"
			+ "$input.doneEvents('input', function() {"
			+ "  $(this).trigger('donetyping');"
			+ "}, %s);",
			component.getMarkupId(true), timeout);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 15
Source Project: onedev   Source File: BlobViewPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new BlobViewResourceReference()));
	
	response.render(OnDomReadyHeaderItem.forScript(String.format("onedev.server.blobView.onDomReady('%s');", getMarkupId())));
}
 
Example 16
Source Project: onedev   Source File: ColorPicker.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new ColorPickerResourceReference()));
	
	String script = String.format("onedev.server.colorPicker.onDomReady('%s', %b);", 
			getMarkupId(true), allowEmpty);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 17
Source Project: onedev   Source File: CodePropertyViewer.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new CodeSupportResourceReference()));
	
	String script = String.format("onedev.server.codeSupport.onViewerDomReady('%s', '%s');", 
			input.getMarkupId(), language);
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 18
Source Project: onedev   Source File: FieldListEditPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new FieldListCssResourceReference()));
	validate();
	if (!getModelObject().equals(getConvertedInput())) {
		String script = String.format("onedev.server.form.markDirty($('#%s').closest('form'));", getMarkupId());
		response.render(OnDomReadyHeaderItem.forScript(script));
	}
}
 
Example 19
Source Project: onedev   Source File: BuildSpecEditPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new BuildSpecResourceReference()));
	String selection = BuildSpecRendererProvider.getSelection(context.getPosition());
	
	String script = String.format("onedev.server.buildSpec.onDomReady(%s, undefined, %s);", 
			selection!=null? "'" + JavaScriptEscape.escapeJavaScript(selection) + "'": "undefined", 
			deleteBehavior.getCallbackFunction(CallbackParameter.explicit("index")));
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 20
Source Project: onedev   Source File: MarkdownEditor.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new MarkdownResourceReference()));
	
	String encodedAttachmentSupport;
	if (getAttachmentSupport() != null) {
		encodedAttachmentSupport = Base64.encodeBase64String(SerializationUtils.serialize(getAttachmentSupport()));
		encodedAttachmentSupport = StringUtils.deleteWhitespace(encodedAttachmentSupport);
		encodedAttachmentSupport = StringEscapeUtils.escapeEcmaScript(encodedAttachmentSupport);
		encodedAttachmentSupport = "'" + encodedAttachmentSupport + "'";
	} else {
		encodedAttachmentSupport = "undefined";
	}
	String callback = ajaxBehavior.getCallbackFunction(explicit("action"), explicit("param1"), explicit("param2"), 
			explicit("param3")).toString();
	
	String autosaveKey = getAutosaveKey();
	if (autosaveKey != null)
		autosaveKey = "'" + JavaScriptEscape.escapeJavaScript(autosaveKey) + "'";
	else
		autosaveKey = "undefined";
	
	String script = String.format("onedev.server.markdown.onDomReady('%s', %s, %d, %s, %d, %b, %b, '%s', %s);", 
			container.getMarkupId(), 
			callback, 
			ATWHO_LIMIT, 
			encodedAttachmentSupport, 
			getAttachmentSupport()!=null?getAttachmentSupport().getAttachmentMaxSize():0,
			getUserMentionSupport() != null,
			getReferenceSupport() != null, 
			JavaScriptEscape.escapeJavaScript(ProjectNameValidator.PATTERN.pattern()),
			autosaveKey);
	response.render(OnDomReadyHeaderItem.forScript(script));
	
	script = String.format("onedev.server.markdown.onWindowLoad('%s');", container.getMarkupId());
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 21
Source Project: onedev   Source File: SourceFormComponent.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	String autosaveKey = JavaScriptEscape.escapeJavaScript(getContext().getAutosaveKey());
	PlanarRange mark = SourceRendererProvider.getRange(getContext().getPosition());
	String jsonOfMark;
	if (mark != null) {
		try {
			jsonOfMark = OneDev.getInstance(ObjectMapper.class).writeValueAsString(mark);
		} catch (JsonProcessingException e) {
			throw new RuntimeException(e);
		}
	} else {
		jsonOfMark = "undefined";
	}
	String script = String.format("onedev.server.sourceEdit.onDomReady("
			+ "'%s', '%s', %s, '%s', %s, '%s', %b, '%s');", 
			getMarkupId(), 
			JavaScriptEscape.escapeJavaScript(getContext().getNewPath()), 
			jsonOfMark,
			getSourceFormat().getIndentType(), 
			getSourceFormat().getTabSize(), 
			getSourceFormat().getLineWrapMode(), 
			getContext().getMode() == Mode.EDIT || getContext().getInitialNewPath() != null, 
			autosaveKey);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 22
Source Project: onedev   Source File: TestPage.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new TestResourceReference()));
	response.render(JavaScriptHeaderItem.forReference(new ScrollIntoViewResourceReference()));
	response.render(OnDomReadyHeaderItem.forScript("onedev.server.test.onDomReady();"));
}
 
Example 23
Source Project: onedev   Source File: BoardCardPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	CharSequence callback = ajaxBehavior.getCallbackFunction(CallbackParameter.explicit("issue"));
	String script = String.format("onedev.server.issueBoards.onCardDomReady('%s', %s);", 
			getMarkupId(), SecurityUtils.getUser()!=null?callback:"undefined");
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 24
Source Project: onedev   Source File: RevisionComparePage.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new RevisionCompareResourceReference()));
	response.render(OnDomReadyHeaderItem.forScript("onedev.server.revisionCompare.onDomReady();"));
}
 
Example 25
Source Project: onedev   Source File: BuildSingleChoice.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new BuildChoiceResourceReference()));
}
 
Example 26
Source Project: onedev   Source File: ProjectIssuesPage.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new ProjectIssuesCssResourceReference()));
}
 
Example 27
Source Project: onedev   Source File: ReviewListPanel.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new ReviewCssResourceReference()));
}
 
Example 28
Source Project: onedev   Source File: PullRequestChangesPage.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new PullRequestChangesResourceReference()));
}
 
Example 29
Source Project: inception   Source File: PdfAnnotationEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse)
{
    super.renderHead(aResponse);
}
 
Example 30
Source Project: onedev   Source File: NoCommitsPanel.java    License: MIT License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new NoCommitsCssResourceReference()));
}