Java Code Examples for org.apache.wicket.ajax.AjaxRequestTarget

The following are top voted examples for showing how to use org.apache.wicket.ajax.AjaxRequestTarget. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gitplex-mit   File: TestFormBehavior.java   View source code 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
	String feedbackHtml;
	TestResult result = test();
	if (result.isSuccessful()) {
		feedbackHtml = String.format(
				"<div class='test-feedback alert alert-success'>%s</div>", 
				HtmlEscape.escapeHtml5(result.getMessage()));					
	} else {
		feedbackHtml = String.format(
				"<div class='test-feedback alert alert-danger'>%s</div>", 
				HtmlEscape.escapeHtml5(result.getMessage()));					
	} 
	feedbackHtml = StringUtils.replace(feedbackHtml, "\n", "<br>");
	target.appendJavaScript(String.format("var $button = $('#%s');"
			+ "$button.removeAttr('disabled');"
			+ "$button.val($button[0].prevValue);"
			+ "$button.html($button[0].prevHtml);"
			+ "$button.closest('form').append('%s');"
			+ "$button.removeClass('ajax-indicator');", 
			getComponent().getMarkupId(), JavaScriptEscape.escapeJavaScript(feedbackHtml)));
}
 
Example 2
Project: gitplex-mit   File: ProjectBlobPage.java   View source code 6 votes vote down vote up
@Override
public void onModeChange(AjaxRequestTarget target, Mode mode) {
	/*
	 * User might be changing blob name when adding a file, and onModeChange will be called. 
	 * In this case, we only need to re-create blob content
	 */
	if (mode != Mode.ADD || state.mode != Mode.ADD) {
		state.mode = mode;
		pushState(target);
		if (state.mode == Mode.VIEW || state.mode == Mode.EDIT || state.mode == Mode.ADD) {
			newBlobNavigator(target);
			newBlobOperations(target);
		}
	}			
	newBlobContent(target);
	resizeWindow(target);
}
 
Example 3
Project: gitplex-mit   File: RevisionSelector.java   View source code 6 votes vote down vote up
private void selectRevision(AjaxRequestTarget target, String revision) {
	try {
		if (projectModel.getObject().getRevCommit(revision, false) != null) {
			onSelect(target, revision);
		} else {
			feedbackMessage = "Can not find commit of revision " + revision + "";
			target.add(feedback);
		}
	} catch (Exception e) {
		// revision selector might be closed in onSelect handler
		if (findPage() != null) {
			feedbackMessage = Throwables.getRootCause(e).getMessage();
			target.add(feedback);
		} else {
			Throwables.propagate(e);
		}
	}
}
 
Example 4
Project: gitplex-mit   File: AffinalRevisionPicker.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ProjectPicker("projectPicker", new AffinalProjectsModel(projectId), projectId) {

		@Override
		protected void onSelect(AjaxRequestTarget target, Project project) {
			projectId = project.getId();
			revision = project.getDefaultBranch();
			newRevisionPicker(target);
			AffinalRevisionPicker.this.onSelect(target, project, revision);
		}
		
	});
	newRevisionPicker(null);
	
	setOutputMarkupId(true);
}
 
Example 5
Project: gitplex-mit   File: ReviewerChoice.java   View source code 6 votes vote down vote up
@Override
protected void onSelect(AjaxRequestTarget target, UserFacade user) {
	PullRequest request = requestModel.getObject();
	ReviewInvitation invitation = null;
	for(ReviewInvitation each: request.getReviewInvitations()) {
		if (each.getUser().equals(user)) {
			invitation = each;
			break;
		}
	}
	if (invitation == null) {
		invitation = new ReviewInvitation();
		invitation.setRequest(request);
		invitation.setUser(GitPlex.getInstance(UserManager.class).load(user.getId()));
		request.getReviewInvitations().add(invitation);
	}
	invitation.setType(ReviewInvitation.Type.MANUAL);
	invitation.setDate(new Date());

	request.clearQualityStatus();
	
	if (!request.isNew())
		GitPlex.getInstance(ReviewInvitationManager.class).invite(invitation);
}
 
Example 6
Project: gitplex-mit   File: AjaxActionTab.java   View source code 6 votes vote down vote up
@Override
public Component render(String componentId) {
	return new ActionTabLink(componentId, this) {

		@Override
		protected WebMarkupContainer newLink(String id, ActionTab tab) {
			return new AjaxLink<Void>("link") {

				@Override
				public void onClick(AjaxRequestTarget target) {
					selectTab(this);
				}
				
			};
		}
		
	};
}
 
Example 7
Project: gitplex-mit   File: SourceViewPanel.java   View source code 6 votes vote down vote up
@Override
protected WebMarkupContainer newOptions(String id) {
	sourceFormat = new SourceFormatPanel(id, null, new OptionChangeCallback() {
		
		@Override
		public void onOptioneChange(AjaxRequestTarget target) {
			String script = String.format("gitplex.server.sourceView.onTabSizeChange(%s);", sourceFormat.getTabSize());
			target.appendJavaScript(script);
		}
		
	}, new OptionChangeCallback() {

		@Override
		public void onOptioneChange(AjaxRequestTarget target) {
			String script = String.format("gitplex.server.sourceView.onLineWrapModeChange('%s');", sourceFormat.getLineWrapMode());
			target.appendJavaScript(script);
		}
		
	});
	return sourceFormat;
}
 
Example 8
Project: gitplex-mit   File: ProjectBlobPage.java   View source code 6 votes vote down vote up
@Override
protected void onPopState(AjaxRequestTarget target, Serializable data) {
	super.onPopState(target, data);

	State popState = (State) data;
	if (!popState.blobIdent.revision.equals(state.blobIdent.revision)) {
		state = popState;
		newSearchResult(target, null);
		onResolvedRevisionChange(target);
	} else {
		state = popState;
		newBlobNavigator(target);
		newBlobOperations(target);
		newBlobContent(target);
		resizeWindow(target);
	}
}
 
Example 9
Project: gitplex-mit   File: SelectToAddChoice.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	setOutputMarkupId(true);
	
	add(new AjaxFormComponentUpdatingBehavior("change") {

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			if (selection != null) {
				onSelect(target, selection);
				selection = null;
			}
			String script = String.format("$('#%s').select2('data', null);", getMarkupId());
			target.appendJavaScript(script);
		}
				
	});
}
 
Example 10
Project: gitplex-mit   File: AbstractSelect2Choice.java   View source code 6 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);

	if (event.getPayload() instanceof AjaxRequestTarget) {

		AjaxRequestTarget target = (AjaxRequestTarget) event.getPayload();

		if (target.getComponents().contains(this)) {

			// if this component is being repainted by ajax, directly, we
			// must destroy Select2 so it removes
			// its elements from DOM

			target.prependJavaScript(JQuery.execute("$('#%s').select2('destroy');", getJquerySafeMarkupId()));
		}
	}
}
 
Example 11
Project: gitplex-mit   File: ProjectBlobPage.java   View source code 6 votes vote down vote up
private void newBlobContent(@Nullable AjaxRequestTarget target) {
	PrioritizedComponentRenderer mostPrioritizedRenderer = null;
	for (BlobRendererContribution contribution: GitPlex.getExtensions(BlobRendererContribution.class)) {
		PrioritizedComponentRenderer renderer = contribution.getRenderer(this);
		if (renderer != null) {
			if (mostPrioritizedRenderer == null || mostPrioritizedRenderer.getPriority() > renderer.getPriority())
				mostPrioritizedRenderer = renderer;
		}
	}
	Component blobContent = Preconditions.checkNotNull(mostPrioritizedRenderer).render(BLOB_CONTENT_ID);
	if (target != null) {
		replace(blobContent);
		target.add(blobContent);
	} else {
		add(blobContent);
	}
}
 
Example 12
Project: gitplex-mit   File: CodeCommentPanel.java   View source code 6 votes vote down vote up
private WebMarkupContainer newAddReplyContainer() {
	WebMarkupContainer addReplyContainer = new Fragment("addReply", "addReplyFrag", this) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.getUser() != null);
		}
		
	};
	addReplyContainer.setOutputMarkupId(true);
	addReplyContainer.add(new AjaxLink<Void>("reply") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			onAddReply(target, false, null);
		}
		
	});
	return addReplyContainer;
}
 
Example 13
Project: gitplex-mit   File: SourceEditPanel.java   View source code 5 votes vote down vote up
@Override
protected WebMarkupContainer newEditOptions(String componentId) {
	sourceFormat = new SourceFormatPanel(componentId, new OptionChangeCallback() {

		@Override
		public void onOptioneChange(AjaxRequestTarget target) {
			String script = String.format("gitplex.server.sourceEdit.onIndentTypeChange('%s', '%s');", 
					sourceFormComponent.getMarkupId(), sourceFormat.getIndentType());
			target.appendJavaScript(script);
		}
		
	}, new OptionChangeCallback() {

		@Override
		public void onOptioneChange(AjaxRequestTarget target) {
			String script = String.format("gitplex.server.sourceEdit.onTabSizeChange('%s', %s);", 
					sourceFormComponent.getMarkupId(), sourceFormat.getTabSize());
			target.appendJavaScript(script);
		}
		
	}, new OptionChangeCallback() {
		
		@Override
		public void onOptioneChange(AjaxRequestTarget target) {
			String script = String.format("gitplex.server.sourceEdit.onLineWrapModeChange('%s', '%s');", 
					sourceFormComponent.getMarkupId(), sourceFormat.getLineWrapMode());
			target.appendJavaScript(script);
		}
		
	});	
	return sourceFormat;
}
 
Example 14
Project: gitplex-mit   File: TestFormBehavior.java   View source code 5 votes vote down vote up
public void requestTest(AjaxRequestTarget target) {
	target.appendJavaScript(String.format("var $button = $('#%s');"
			+ "$button.attr('disabled', 'disabled');"
			+ "$button[0].prevValue = $button.val();"
			+ "$button[0].prevHtml = $button.html();"
			+ "$button.val($button.val() + ' in progress...');"
			+ "$button.html($button.html() + ' in progress...');"
			+ "$button.addClass('ajax-indicator');"
			+ "$button.closest('form').children('.test-feedback').remove();", 
			getComponent().getMarkupId()));
	target.appendJavaScript(getCallbackScript());
}
 
Example 15
Project: gitplex-mit   File: ProjectBranchesPage.java   View source code 5 votes vote down vote up
@Override
protected void onPopState(AjaxRequestTarget target, Serializable data) {
	super.onPopState(target, data);
	baseBranch = (String) data;
	target.add(baseChoice);
	target.add(branchesContainer);
	target.add(noBranchesContainer);
	target.add(pagingNavigator);
}
 
Example 16
Project: gitplex-mit   File: RunTaskBehavior.java   View source code 5 votes vote down vote up
public void requestRun(AjaxRequestTarget target) {
	target.appendJavaScript(String.format(""
			+ "var $button = $('#%s');"
			+ "if ($button.length != 0) {"
			+ "$button.attr('disabled', 'disabled');"
			+ "$button[0].prevValue = $button.val();"
			+ "$button[0].prevHtml = $button.html();"
			+ "$button.val($button.val() + ' in progress...');"
			+ "$button.html($button.html() + ' in progress...');"
			+ "}",
			getComponent().getMarkupId()));
	target.appendJavaScript(getCallbackScript());
}
 
Example 17
Project: gitplex-mit   File: InfiniteScrollBehavior.java   View source code 5 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
	IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
	int page = params.getParameterValue("page").toInt();
	target.prependJavaScript(String.format("$('#%s .loading-indicator').remove();", 
			getComponent().getMarkupId()));
	
	appendPage(target, page);

	target.appendJavaScript(String.format("gitplex.infiniteScroll.check('%s');", 
			getComponent().getMarkupId()));
}
 
Example 18
Project: gitplex-mit   File: CommitDetailPage.java   View source code 5 votes vote down vote up
@Override
protected void onPopState(AjaxRequestTarget target, Serializable data) {
	super.onPopState(target, data);
	
	state = (State) data;
	newRevisionDiff(target);
}
 
Example 19
Project: gitplex-mit   File: InputChangeBehavior.java   View source code 5 votes vote down vote up
@Override
protected void onUpdate(AjaxRequestTarget target) {
	FormComponent<?> component = (FormComponent<?>) getComponent();

	// IE triggers "input" event when the focused on the search input even if nothing is 
	// input into search box yet. To work around this issue, we compare search string 
	// against previous value to only update the branches table if there is an actual 
	// change.
	String newInput = component.getInput();
	if (!Objects.equals(newInput, input)) {
		input = newInput;
		onInputChange(target);
	}
}
 
Example 20
Project: gitplex-mit   File: OnTypingDoneBehavior.java   View source code 5 votes vote down vote up
@Override
protected void onUpdate(AjaxRequestTarget target) {
	// IE triggers "input" event when the focused on the search input even if nothing is 
	// input into search box yet. To work around this issue, we compare search string 
	// against previous value to only update the branches table if there is an actual 
	// change.
	String newInput = ((FormComponent<?>)getComponent()).getInput();
	if (!Objects.equals(newInput, input)) {
		input = newInput;
		onTypingDone(target);
	}
}
 
Example 21
Project: gitplex-mit   File: ConcreteListPropertyEditor.java   View source code 5 votes vote down vote up
private WebMarkupContainer addRow(final RepeatingView rows, Serializable element) {
	final WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
	row.setOutputMarkupId(true);
	rows.add(row);
	
	RepeatingView columns = new RepeatingView("properties");
	row.add(columns);
	
	for (PropertyContext<Serializable> propertyContext: propertyContexts) {
		WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
		column.add(AttributeAppender.append("class", " " + propertyContext.getPropertyName()));
		columns.add(column);
		
		Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
		PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
		column.add(propertyEditor);
		column.add(new FencedFeedbackPanel("feedback", propertyEditor));
	}
	
	row.add(new AjaxButton("deleteElement") {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			super.onSubmit(target, form);
			
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);

			if (rows.size() == 0) {
				WebMarkupContainer table = (WebMarkupContainer) ConcreteListPropertyEditor.this.get("listEditor");
				target.add(table.get("noElementsRow"));
			}
			send(ConcreteListPropertyEditor.this, Broadcast.BUBBLE, new EditorChanged(target));								
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 22
Project: gitplex-mit   File: MarkdownEditor.java   View source code 5 votes vote down vote up
public void insertUrl(AjaxRequestTarget target, boolean isImage, String url, 
		@Nullable String name, String replaceMessage) {
	String script = String.format("gitplex.server.markdown.insertUrl('%s', %s, '%s', %s, %s);",
			container.getMarkupId(), isImage, StringEscapeUtils.escapeEcmaScript(url), 
			name!=null?"'"+StringEscapeUtils.escapeEcmaScript(name)+"'":"undefined", 
			replaceMessage!=null?"'"+replaceMessage+"'":"undefined");
	target.appendJavaScript(script);
}
 
Example 23
Project: gitplex-mit   File: RequestChangesPage.java   View source code 5 votes vote down vote up
@Override
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
	if (comment != null) {
		state.commentId = comment.getId();
		state.mark = comment.getCommentPos();
	} else {
		state.commentId = null;
		state.mark = null;
	}
	onRegionChange();
	pushState(target);
}
 
Example 24
Project: gitplex-mit   File: RequestChangesPage.java   View source code 5 votes vote down vote up
@Override
protected void onPopState(AjaxRequestTarget target, Serializable data) {
	super.onPopState(target, data);

	state = (State) data;
	newRevisionDiff(target);
	onRegionChange();
}
 
Example 25
Project: gitplex-mit   File: CommitDetailPage.java   View source code 5 votes vote down vote up
@Override
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
	if (comment != null) {
		state.commentId = comment.getId();
		state.mark = comment.getCommentPos();
	} else {
		state.commentId = null;
		state.mark = null;
	}
	pushState(target);
}
 
Example 26
Project: gitplex-mit   File: FloatingPanel.java   View source code 5 votes vote down vote up
public FloatingPanel(AjaxRequestTarget target, AlignTarget alignTarget, AlignPlacement placement) {
	super(((BasePage)target.getPage()).getRootComponents().newChildId());
	
	BasePage page = (BasePage) target.getPage(); 
	page.getRootComponents().add(this);
	target.prependJavaScript(String.format("$('body').append(\"<div id='%s'></div>\");", getMarkupId()));
	target.add(this);

	this.alignTarget = alignTarget;
	this.placement = placement;
}
 
Example 27
Project: gitplex-mit   File: FloatingPanel.java   View source code 5 votes vote down vote up
public final void close() {
	AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
	if (target != null) {
		String script = String.format("gitplex.server.floating.close($('#%s'), false);", getMarkupId(true));
		target.appendJavaScript(script);
	} 
	if (getParent() != null)
		remove();
	onClosed();
}
 
Example 28
Project: gitplex-mit   File: ModalPanel.java   View source code 5 votes vote down vote up
public ModalPanel(AjaxRequestTarget target, Size size) {
	super(((BasePage)target.getPage()).getRootComponents().newChildId());
	
	this.size = size;
	
	BasePage page = (BasePage) target.getPage(); 
	page.getRootComponents().add(this);
	target.prependJavaScript(String.format("$('body').append(\"<div id='%s'></div>\");", getMarkupId()));
	target.add(this);
}
 
Example 29
Project: gitplex-mit   File: ModalPanel.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	WebMarkupContainer dialog = new WebMarkupContainer("dialog");
	add(dialog);
	
	dialog.add(newContent(CONTENT_ID));
	
	if (size == Size.LARGE)
		dialog.add(AttributeAppender.append("class", "modal-lg"));
	else if (size == Size.SMALL)
		dialog.add(AttributeAppender.append("class", "modal-sm"));
	
	add(new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			ModalPanel.this.remove();
			onClosed();
		}
		
		@Override
		public void renderHead(Component component, IHeaderResponse response) {
			super.renderHead(component, response);

			response.render(JavaScriptHeaderItem.forReference(new ModalResourceReference()));
			
			String script = String.format("gitplex.server.modal.onDomReady('%s', %s);", 
					getMarkupId(true), getCallbackFunction());
			response.render(OnDomReadyHeaderItem.forScript(script));
		}

	});
	
	setOutputMarkupId(true);
}
 
Example 30
Project: gitplex-mit   File: ProjectBlobPage.java   View source code 5 votes vote down vote up
@Override
public void onSelect(AjaxRequestTarget target, BlobIdent blobIdent, @Nullable TokenPosition tokenPos) {
	state.mark = TextRange.of(tokenPos);
	if (!blobIdent.revision.equals(state.blobIdent.revision)) {
		state.blobIdent = blobIdent;
		state.mode = Mode.VIEW;
		state.commentId = null;
		state.requestId = null;
		newSearchResult(target, null);
		onResolvedRevisionChange(target);
	} else {
		if (!Objects.equal(state.blobIdent.path, blobIdent.path) 
				|| state.mark != null && !(get(BLOB_CONTENT_ID) instanceof Markable)) {
			state.blobIdent.path = blobIdent.path;
			state.blobIdent.mode = blobIdent.mode;
			state.mode = Mode.VIEW;
			state.commentId = null;
			newBlobNavigator(target);
			newBlobOperations(target);
			newBlobContent(target);
			resizeWindow(target);
			GitPlex.getInstance(WebSocketManager.class).onRegionChange(this);
		} else if (state.mark != null) {
			// This logic is added for performance reason, we do not want to 
			// reload the file if go to different mark positions in same file
			((Markable)get(BLOB_CONTENT_ID)).mark(target, state.mark);
		}
	}
	pushState(target);
}
 
Example 31
Project: gitplex-mit   File: RequestChangesPage.java   View source code 5 votes vote down vote up
@Override
public void onAddComment(AjaxRequestTarget target, MarkPos mark) {
	state.commentId = null;
	state.mark = mark;
	pushState(target);
	onRegionChange();
}
 
Example 32
Project: gitplex-mit   File: SourceViewPanel.java   View source code 5 votes vote down vote up
private void onCommentDeleted(AjaxRequestTarget target, CodeComment comment) {
	clearComment(target);
	String script = String.format("gitplex.server.sourceView.onCommentDeleted(%s);", 
			getJsonOfComment(comment));
	target.appendJavaScript(script);
	context.onCommentOpened(target, null);
}
 
Example 33
Project: gitplex-mit   File: ConfirmDeleteProjectModal.java   View source code 5 votes vote down vote up
@Override
protected void doDelete(AjaxRequestTarget target) {
	Project project = getProject();
	
	GitPlex.getInstance(ProjectManager.class).delete(project);
	getSession().success("Repository has been deleted");
	
	onDeleted(target);
}
 
Example 34
Project: gitplex-mit   File: RevisionComparePage.java   View source code 5 votes vote down vote up
@Override
protected void onPopState(AjaxRequestTarget target, Serializable data) {
	super.onPopState(target, data);
	
	state = (State) data;
	GitPlex.getInstance(WebSocketManager.class).onRegionChange(this);
	
	newTabPanel(target);
	target.add(tabbable);
}
 
Example 35
Project: gitplex-mit   File: CodeCommentPanel.java   View source code 5 votes vote down vote up
private void onStatusChanged(AjaxRequestTarget target, Fragment fragment, CodeCommentStatusChange statusChange) {
	WebMarkupContainer activityContainer = newActivityContainer(activitiesView.newChildId(), statusChange);
	activitiesView.add(activityContainer);

	String script = String.format("$('#%s .add-reply').before('<div id=\"%s\"></div>');", 
			CodeCommentPanel.this.getMarkupId(), activityContainer.getMarkupId());
	target.prependJavaScript(script);
	target.add(activityContainer);

	WebMarkupContainer addReplyContainer = newAddReplyContainer();
	fragment.replaceWith(addReplyContainer);
	target.add(addReplyContainer);
}
 
Example 36
Project: gitplex-mit   File: CodeCommentPanel.java   View source code 5 votes vote down vote up
private void onReplyAdded(AjaxRequestTarget target, Fragment fragment, @Nullable CodeCommentReply reply) {
	if (reply != null) {
		WebMarkupContainer activityContainer = newActivityContainer(activitiesView.newChildId(), reply);
		activitiesView.add(activityContainer);

		String script = String.format("$('#%s .add-reply').before('<div id=\"%s\"></div>');", 
				CodeCommentPanel.this.getMarkupId(), activityContainer.getMarkupId());
		target.prependJavaScript(script);
		target.add(activityContainer);
	}
	
	WebMarkupContainer addReplyContainer = newAddReplyContainer();
	fragment.replaceWith(addReplyContainer);
	target.add(addReplyContainer);
}
 
Example 37
Project: gitplex-mit   File: ProjectPicker.java   View source code 5 votes vote down vote up
@Override
protected Component newContent(String id, FloatingPanel dropdown) {
	return new ProjectSelector(id, projectsModel, currentProjectId) {

		@Override
		protected void onSelect(AjaxRequestTarget target, Project project) {
			dropdown.close();
			target.add(ProjectPicker.this);
			ProjectPicker.this.onSelect(target, project);
		}

	};
}
 
Example 38
Project: gitplex-mit   File: RevisionDiffPanel.java   View source code 5 votes vote down vote up
private void onCommentDeleted(AjaxRequestTarget target, CodeComment comment) {
	clearComment(target);
	SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
	if (sourceAware != null)
		sourceAware.onCommentDeleted(target, comment);
	((CommentSupport)markSupport).onCommentOpened(target, null);
	target.appendJavaScript("gitplex.server.revisionDiff.reposition();");
	MarkPos mark = getMark();
	if (mark != null) {
		sourceAware = getSourceAware(mark.getPath());
		if (sourceAware != null) {
			sourceAware.mark(target, mark);
		}
	}
}
 
Example 39
Project: gitplex-mit   File: BlobDiffPanel.java   View source code 5 votes vote down vote up
@Override
public void onCommentDeleted(AjaxRequestTarget target, CodeComment comment) {
	Component content = get(CONTENT_ID);
	if (content instanceof SourceAware) {
		SourceAware sourceAware = (SourceAware) content;
		sourceAware.onCommentDeleted(target, comment);
	}
}
 
Example 40
Project: gitplex-mit   File: SearchResultPanel.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void onActiveIndexChange(AjaxRequestTarget target) {
	Component hitsContainer = blobsView.get(activeBlobIndex).get(HITS_ID);
	if (!hitsContainer.isVisibilityAllowed()) {
		hitsContainer.setVisibilityAllowed(true);
		target.add(hitsContainer);
		target.add(blobsView.get(activeBlobIndex).get(EXPAND_LINK_ID));
	} 

	String activeLinkId = getMarkupId() + "-" + activeBlobIndex; 
	if (activeHitIndex != -1)
		activeLinkId += "-" + activeHitIndex;

	String script = String.format(""
			+ "$('#%s').find('.selectable').removeClass('active');"
			+ "$('#%s').addClass('active');"
			+ "$('#%s>.search-result>.body').scrollIntoView('a.selectable.active', 25, 25);", 
			getMarkupId(), activeLinkId, getMarkupId());
	target.appendJavaScript(script);
	
	target.add(prevMatchLink);
	target.add(nextMatchLink);
	
	MatchedBlob activeBlob = blobs.get(activeBlobIndex);
	
	QueryHit hit;
	if (activeHitIndex != -1)
		hit = activeBlob.getHits().get(activeHitIndex);
	else 
		hit = new FileHit(activeBlob.getBlobPath(), null);
	
	BlobIdent selected = new BlobIdent(context.getBlobIdent().revision, hit.getBlobPath(), 
			FileMode.REGULAR_FILE.getBits());
	context.onSelect(target, selected, hit.getTokenPos());
}