Java Code Examples for org.apache.wicket.request.mapper.parameter.PageParameters

The following are top voted examples for showing how to use org.apache.wicket.request.mapper.parameter.PageParameters. 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: vlo-curation   File: VloBasePage.java   View source code 7 votes vote down vote up
/**
 * Sets the theme from the page parameters if applicable. An present but
 * empty theme value will reset the theme (by unsetting the style).
 *
 * @param parameters page parameters to process
 * @see VloWebAppParameters#THEME
 * @see Session#setStyle(java.lang.String)
 */
private void processTheme(PageParameters parameters) {
    final StringValue themeValue = parameters.get(VloWebAppParameters.THEME);
    if (!themeValue.isNull()) {
        if (themeValue.isEmpty()) {
            // empty string resets theme
            logger.debug("Resetting theme");
            Session.get().setStyle(null);
        } else {
            // theme found, set it as style in the session
            final String theme = themeValue.toString().toLowerCase();
            logger.debug("Setting theme to {}", theme);
            Session.get().setStyle(theme);
        }

        /*
         * Remove theme parameter to prevent it from interfering with 
         * further processing, specifically the parameters check in 
         * the simple page search
         */
        parameters.remove(VloWebAppParameters.THEME, themeValue.toString());
    }
}
 
Example 2
Project: gitplex-mit   File: CommitDetailPage.java   View source code 6 votes vote down vote up
public static PageParameters paramsOf(Project project, State state) {
	PageParameters params = paramsOf(project);
	params.set(PARAM_REVISION, state.revision);
	if (state.compareWith != null)
		params.set(PARAM_COMPARE_WITH, state.compareWith);
	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.set(PARAM_PATH_FILTER, state.pathFilter);
	if (state.blameFile != null)
		params.set(PARAM_BLAME_FILE, state.blameFile);
	if (state.commentId != null)
		params.set(PARAM_COMMENT, state.commentId);
	if (state.mark != null)
		params.set(PARAM_MARK, state.mark.toString());
	return params;
}
 
Example 3
Project: gitplex-mit   File: CommitDetailPage.java   View source code 6 votes vote down vote up
public State(PageParameters params) {
	List<String> revisionSegments = new ArrayList<>();
	String segment = params.get(PARAM_REVISION).toString();
	if (segment.length() != 0)
		revisionSegments.add(segment);
	for (int i=0; i<params.getIndexedCount(); i++) {
		segment = params.get(i).toString();
		if (segment.length() != 0)
			revisionSegments.add(segment);
	}
	
	revision = Joiner.on("/").join(revisionSegments);
	compareWith = params.get(PARAM_COMPARE_WITH).toString();
	whitespaceOption = WhitespaceOption.ofNullableName(params.get(PARAM_WHITESPACE_OPTION).toString());
	pathFilter = params.get(PARAM_PATH_FILTER).toString();
	blameFile = params.get(PARAM_BLAME_FILE).toString();
	commentId = params.get(PARAM_COMMENT).toOptionalLong();
	mark = MarkPos.fromString(params.get(PARAM_MARK).toString());
}
 
Example 4
Project: gitplex-mit   File: SearchOption.java   View source code 6 votes vote down vote up
public SearchOption(PageParameters params) {
	String value = params.get(PARAM_STATUS).toString();
	if (value != null)
		status = Status.valueOf(value);
	
	submitterName = params.get(PARAM_SUBMITTER).toString();
	
	targetBranch = params.get(PARAM_BRANCH).toString();
	title = params.get(PARAM_TITLE).toString();
	
	value = params.get(PARAM_BEGIN_DATE).toString();
	if (value != null)
		beginDate = new Date(Long.valueOf(value));
	
	value = params.get(PARAM_END_DATE).toString();
	if (value != null)
		endDate = new Date(Long.valueOf(value));
}
 
Example 5
Project: gitplex-mit   File: RequestDetailPage.java   View source code 6 votes vote down vote up
public RequestDetailPage(PageParameters params) {
	super(params);
	
	if (getProject().getDefaultBranch() == null) 
		throw new RestartResponseException(NoBranchesPage.class, paramsOf(getProject()));

	requestModel = new LoadableDetachableModel<PullRequest>() {

		@Override
		protected PullRequest load() {
			Long requestNumber = params.get(PARAM_REQUEST).toLong();
			PullRequest request = GitPlex.getInstance(PullRequestManager.class).find(getProject(), requestNumber);
			if (request == null)
				throw new EntityNotFoundException("Unable to find request #" + requestNumber + " in project " + getProject());
			return request;
		}

	};

	reviewUpdateId = requestModel.getObject().getLatestUpdate().getId();
}
 
Example 6
Project: gitplex-mit   File: RequestChangesPage.java   View source code 6 votes vote down vote up
public RequestChangesPage(PageParameters params) {
	super(params);

	state.commentId = params.get(PARAM_COMMENT).toOptionalLong();
	state.mark = MarkPos.fromString(params.get(PARAM_MARK).toString());
	
	state.oldCommit = params.get(PARAM_OLD_COMMIT).toString();
	state.newCommit = params.get(PARAM_NEW_COMMIT).toString();
	state.pathFilter = params.get(PARAM_PATH_FILTER).toString();
	state.blameFile = params.get(PARAM_BLAME_FILE).toString();
	state.whitespaceOption = WhitespaceOption.ofNullableName(params.get(PARAM_WHITESPACE_OPTION).toString());
	
	PullRequest request = getPullRequest();
	if (state.commentId != null) {
		CodeComment comment = GitPlex.getInstance(CodeCommentManager.class).load(state.commentId);
		if (state.oldCommit == null && state.newCommit == null) {
			String commentCommit = comment.getCommentPos().getCommit();
			if (commentCommit.equals(request.getBaseCommitHash())) {
				state.oldCommit = request.getBaseCommitHash();
				state.newCommit = request.getHeadCommitHash();
			} else if (comment.isCodeChanged()) {
				state.oldCommit = commentCommit;
				state.newCommit = request.getHeadCommitHash();
			} else {
				state.oldCommit = request.getBaseCommitHash();
				state.newCommit = commentCommit;
			}
		} else {
			if (state.oldCommit == null) 
				state.oldCommit = request.getBaseCommitHash();
			if (state.newCommit == null)
				state.newCommit = request.getHeadCommitHash();
		}
	} else {
		if (state.oldCommit == null) 
			state.oldCommit = request.getBaseCommitHash();
		if (state.newCommit == null)
			state.newCommit = request.getHeadCommitHash();
	}
}
 
Example 7
Project: gitplex-mit   File: RequestChangesPage.java   View source code 6 votes vote down vote up
public static PageParameters paramsOf(PullRequest request, State state) {
	PageParameters params = RequestDetailPage.paramsOf(request);

	if (state.oldCommit != null)
		params.set(PARAM_OLD_COMMIT, state.oldCommit);
	if (state.newCommit != null)
		params.set(PARAM_NEW_COMMIT, state.newCommit);
	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.set(PARAM_PATH_FILTER, state.pathFilter);
	if (state.blameFile != null)
		params.set(PARAM_BLAME_FILE, state.blameFile);
	if (state.commentId != null)
		params.set(PARAM_COMMENT, state.commentId);
	if (state.mark != null)
		params.set(PARAM_MARK, state.mark.toString());
	return params;
}
 
Example 8
Project: gitplex-mit   File: CodeCommentsPage.java   View source code 6 votes vote down vote up
public CodeCommentsPage(PageParameters params) {
	super(params);
	
	state = new State();
	state.userName = params.get(PARAM_USER).toString();
	state.unresolved = "yes".equals(params.get(PARAM_UNRESOLVED).toString());
	state.path = params.get(PARAM_PATH).toString();
	
	String value = params.get(PARAM_BEFORE).toString();
	if (value != null)
		state.before = new Date(Long.valueOf(value));
	
	value = params.get(PARAM_AFTER).toString();
	if (value != null)
		state.after = new Date(Long.valueOf(value));
}
 
Example 9
Project: gitplex-mit   File: CodeCommentsPage.java   View source code 6 votes vote down vote up
public static PageParameters paramsOf(PullRequest request, State state) {
	PageParameters params = RequestDetailPage.paramsOf(request);
	
	if (state.userName != null)
		params.add(PARAM_USER, state.userName);
	if (state.unresolved)
		params.add(PARAM_UNRESOLVED, "yes");
	if (state.path != null)
		params.add(PARAM_PATH, state.path);
	if (state.before != null)
		params.add(PARAM_BEFORE, state.before.getTime());
	if (state.after != null)
		params.add(PARAM_AFTER, state.after.getTime());
	
	return params;
}
 
Example 10
Project: gitplex-mit   File: ProjectBlobPage.java   View source code 6 votes vote down vote up
public static PageParameters paramsOf(Project project, State state) {
	PageParameters params = paramsOf(project);
	
	if (state.blobIdent.revision != null)
		params.set(PARAM_REVISION, state.blobIdent.revision);
	if (state.blobIdent.path != null)
		params.set(PARAM_PATH, state.blobIdent.path);
	if (state.mark != null)
		params.set(PARAM_MARK, state.mark.toString());
	if (state.requestId != null)
		params.set(PARAM_REQUEST, state.requestId);
	if (state.commentId != null)
		params.set(PARAM_COMMENT, state.commentId);
	if (state.mode != Mode.VIEW)
		params.set(PARAM_MODE, state.mode.name().toLowerCase());
	if (state.query != null)
		params.set(PARAM_QUERY, state.query);
	return params;
}
 
Example 11
Project: gitplex-mit   File: RevisionComparePage.java   View source code 6 votes vote down vote up
public static PageParameters paramsOf(Project project, State state) {
	PageParameters params = paramsOf(project);
	params.set(PARAM_LEFT, state.leftSide.toString());
	params.set(PARAM_RIGHT, state.rightSide.toString());
	params.set(PARAM_COMPARE_WITH_MERGE_BASE, state.compareWithMergeBase);
	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.set(PARAM_PATH_FILTER, state.pathFilter);
	if (state.blameFile != null)
		params.set(PARAM_BLAME_FILE, state.blameFile);
	if (state.mark != null)
		params.set(PARAM_MARK, state.mark.toString());
	if (state.tabPanel != null)
		params.set(PARAM_TAB, state.tabPanel.name());
	return params;
}
 
Example 12
Project: MasterStats   File: SummonerQueryForwardPage.java   View source code 6 votes vote down vote up
public SummonerQueryForwardPage(PageParameters parameters) {
    super(parameters, "Summoner Search", null);
    // get summoner name and region sent by the form
    String summonerName = parameters.get("summonerName").toString("");
    String regionName = parameters.get("region").toString("").toUpperCase();

    // insert data to error page
    add(new Label("summoner_name", summonerName));
    add(new Label("region", regionName));

    // check if summoner name and region are valid, if not return to show error page
    if (summonerName == null || summonerName.length() == 0) return;
    if (!EnumUtils.isValidEnum(RiotEndpoint.class, regionName)) return;

    // convert region name to RiotEndpoint object
    RiotEndpoint region = RiotEndpoint.valueOf(regionName);

    // generate the summoners statistic
    Pair<String, SummonerStatisticItem> summonerStatistic = PageDataProvider.generateSummonerStatistic(summonerName, region);
    // if statistic generation failed, return to show error page
    if (summonerStatistic == null) return;

    // forward to single summoner page with region and summoner key name
    throw new RestartResponseAtInterceptPageException(SingleSummonerPage.class, new PageParameters()
            .set(0, regionName).set(1, summonerStatistic.getKey()));
}
 
Example 13
Project: vlo-curation   File: FacetedSearchPage.java   View source code 6 votes vote down vote up
public FacetedSearchPage(PageParameters parameters, IModel<Boolean> simpleModeModel) {
    super(parameters);

    final QueryFacetsSelection selection = paramsConverter.fromParameters(parameters);
    final IModel<QueryFacetsSelection> queryModel = new Model<>(selection);

    setModel(queryModel);
    createModels();
    this.simpleModeModel = simpleModeModel;

    addComponents();

    // add Piwik tracking behavior
    if (piwikConfig.isEnabled()) {
        resultsHeader.add(AjaxPiwikTrackingBehavior.newEventTrackingBehavior(TRACKING_EVENT_TITLE));
    }
}
 
Example 14
Project: vlo-curation   File: ErrorPage.java   View source code 6 votes vote down vote up
public ErrorPage(PageParameters parameters) {
    super(parameters);
    this.errorType = getErrorType(parameters.get(PAGE_PARAMETER_RESPONSE_CODE).toString());

    final PageParameters queryParams = new PageParameters(parameters).remove(PAGE_PARAMETER_RESPONSE_CODE);
    final boolean hasQuery = !queryParams.get(VloWebAppParameters.QUERY).isEmpty() || !queryParams.get(VloWebAppParameters.FILTER_QUERY).isEmpty();
    add(new BookmarkablePageLink("searchPage", FacetedSearchPage.class, queryParams)
            .add(new Label("label", hasQuery ? "Return to query" : "Go to the search page"))
    );

    final IModel<String> errorDescriptionModel = new LoadableDetachableModel<String>() {
        @Override
        protected String load() {
            return getDescriptionForError(errorType);
        }
    };
    add(new Label("description", errorDescriptionModel) {
        @Override
        protected void onConfigure() {
            setVisible(errorDescriptionModel.getObject() != null);
        }

    }.setEscapeModelStrings(false));
}
 
Example 15
Project: singular-server   File: Menu.java   View source code 6 votes vote down vote up
private void buildMenus(MetronicMenu menu, BoxConfigurationData boxConfigurationMetadata,
                        ModuleEntity module, List<MenuItemConfig> subMenus) {
    MetronicMenuGroup group = new MetronicMenuGroup(DefaultIcons.LAYERS, boxConfigurationMetadata.getLabel());
    menu.addItem(group);
    final List<Pair<Component, ISupplier<String>>> itens = new ArrayList<>();

    for (MenuItemConfig t : subMenus) {
        PageParameters pageParameters = new PageParameters();
        pageParameters.add(MODULE_PARAM_NAME, module.getCod());
        pageParameters.add(MENU_PARAM_NAME, boxConfigurationMetadata.getLabel());
        pageParameters.add(ITEM_PARAM_NAME, t.name);

        MetronicMenuItem i = new ServerMenuItem(t.icon, t.name, t.pageClass, t.page, pageParameters);
        group.addItem(i);
        itens.add(Pair.of(i.getHelper(), t.counterSupplier));
    }
    menu.add(new AddContadoresBehaviour(itens));
    onBuildModuleGroup(group, menu);
}
 
Example 16
Project: wicket-stream-download-example   File: HomePageTmpFile.java   View source code 6 votes vote down vote up
public HomePageTmpFile(final PageParameters parameters) throws IOException {
	super(parameters);
	setVersioned(false);

	add(new DownloadLink("download", new LoadableDetachableModel<File>(){

		@Override
		protected File load() {
			Path p;
			try {
				p = Files.createTempFile("google", "html");
				Files.copy(WicketApplication.getInMemoryStream(), p, StandardCopyOption.REPLACE_EXISTING);
				return p.toFile();
			} catch (IOException e) {
				return null;
			}
			
		}
		
	}, Model.of("google.html")).setDeleteAfterDownload(true));
	
}
 
Example 17
Project: vlo-curation   File: QueryFacetsSelectionParametersConverter.java   View source code 6 votes vote down vote up
@Override
public QueryFacetsSelection fromParameters(PageParameters params) {
    // Get query string from params
    final String query = params.get(QUERY).toOptionalString();

    final List<StringValue> facetSelectionTypes = params.getValues(FILTER_QUERY_TYPE);
    final List<StringValue> facetValues = params.getValues(FILTER_QUERY);
    final HashMap<String, FacetSelection> selection = Maps.newHashMapWithExpectedSize(facetValues.size());

    // Get selection type from params
    for (StringValue selectionType : facetSelectionTypes) {
        if (!selectionType.isEmpty()) {
            applySelectionTypeFromParameter(selectionType, selection);
        }
    }

    // Get facet selections from params
    for (StringValue facetValue : facetValues) {
        if (!facetValue.isEmpty()) {
            applyFacetValueFromParameter(facetValue, selection);
        }
    }

    return new QueryFacetsSelection(query, selection);
}
 
Example 18
Project: engerek   File: PageResourceWizard.java   View source code 6 votes vote down vote up
public PageResourceWizard(@NotNull PageParameters parameters) {
      getPageParameters().overwriteWith(parameters);						// to be available in the methods called within this constructor as well

configurationOnly = parameters.get(PARAM_CONFIG_ONLY).toBoolean();
readOnly = parameters.get(PARAM_READ_ONLY).toBoolean();

      editedResourceOid = getResourceOid();								// might be null at this moment

LOGGER.debug("Resource wizard called with oid={}, configOnly={}, readOnly={}", editedResourceOid, configurationOnly, readOnly);

modelRaw = createResourceModel(Arrays.asList(
		SelectorOptions.create(ResourceType.F_CONNECTOR_REF, GetOperationOptions.createResolve()),
		SelectorOptions.create(GetOperationOptions.createRaw())));
modelNoFetch = createResourceModel(Arrays.asList(
		SelectorOptions.create(ResourceType.F_CONNECTOR_REF, GetOperationOptions.createResolve()),
		SelectorOptions.create(GetOperationOptions.createNoFetch())));
modelFull = createResourceModel(null);

issuesModel = new ResourceWizardIssuesModel(modelFull, this);

initLayout();
  }
 
Example 19
Project: Unicorn   File: ExcelEventTypeCreator.java   View source code 6 votes vote down vote up
public ExcelEventTypeCreator(final PageParameters parameters) {

		super();
		this.excelEventTypeCreator = this;
		this.filePath = parameters.get("filePath").toString();
		this.eventTypeName = FileUtils.getFileNameWithoutExtension(this.filePath);
		final int index = this.filePath.lastIndexOf('.');
		final String fileExtension = this.filePath.substring(index + 1, this.filePath.length());
		if (fileExtension.contains("xls")) {
			this.fileNormalizer = new ExcelImporter();
		} else {
			this.fileNormalizer = new CSVImporter();
		}
		this.columnTitles = (ArrayList<String>) this.fileNormalizer.getColumnTitlesFromFile(this.filePath);

		this.buildMainlayout();
	}
 
Example 20
Project: engerek   File: PageAccountActivation.java   View source code 6 votes vote down vote up
private UserType loadUser(PageParameters params){
	String userOid = getOidFromParameter(params);
	if (userOid == null) {
		getSession().error(getString("PageAccountActivation.user.not found"));
		throw new RestartResponseException(PageLogin.class);
	}
	
	Task task = createAnonymousTask(LOAD_USER);
	OperationResult result = new OperationResult(LOAD_USER);
	
	return runPrivileged(new Producer<UserType>() {
		
		@Override
		public UserType run() {
			Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(UserType.F_LINK_REF, GetOperationOptions.createResolve());
			return WebModelServiceUtils.loadObject(UserType.class, userOid, options, PageAccountActivation.this, task, result).asObjectable();
		}
	});
	
	
}
 
Example 21
Project: engerek   File: PageSystemConfiguration.java   View source code 6 votes vote down vote up
@Override
protected void onBeforeRender() {
	super.onBeforeRender();

	if (!initialized) {
		PageParameters params = getPageParameters();
		StringValue val = params.get(SELECTED_TAB_INDEX);
		String value = null;
		if (val != null && !val.isNull()) {
			value = val.toString();
		}

		int index = StringUtils.isNumeric(value) ? Integer.parseInt(value) : CONFIGURATION_TAB_BASIC;
		getTabPanel().setSelectedTab(index);

		initialized = true;
	}
}
 
Example 22
Project: vlo-curation   File: QueryFacetsSelectionParametersConverterTest.java   View source code 6 votes vote down vote up
/**
 * Test of toParameters method, of class
 * QueryFacetsSelectionParametersConverter.
 */
@Test
public void testToParameters() {
    final String query = "query";
    final Map<String, FacetSelection> map = Maps.newHashMapWithExpectedSize(3);
    map.put("facet1", new FacetSelection(FacetSelectionType.OR, Arrays.asList("valueA", "valueB")));
    map.put("facet2", new FacetSelection(FacetSelectionType.AND, Collections.singleton("value:C")));
    map.put("facet3", new FacetSelection(FacetSelectionType.NOT_EMPTY));

    QueryFacetsSelection selection = new QueryFacetsSelection(query, map);
    PageParameters result = instance.toParameters(selection);

    assertThat(result.get("q"), equalTo(StringValue.valueOf("query")));

    final List<StringValue> fq = result.getValues("fq");
    assertNotNull(fq);
    assertThat(fq, hasItem(StringValue.valueOf("facet1:valueA")));
    assertThat(fq, hasItem(StringValue.valueOf("facet1:valueB")));
    assertThat(fq, hasItem(StringValue.valueOf("facet2:value:C")));

    final List<StringValue> fqType = result.getValues("fqType");
    assertNotNull(fqType);
    assertThat(fqType, hasItem(StringValue.valueOf("facet1:or")));
    //facet 2 is AND, which is default and should not be encoded
    assertThat(fqType, hasItem(StringValue.valueOf("facet3:not_empty")));
}
 
Example 23
Project: engerek   File: PageSelfRegistration.java   View source code 6 votes vote down vote up
public PageSelfRegistration(PageParameters pageParameters) {
	super();

	final String userOid = getOidFromParams(pageParameters);

	userModel = new LoadableModel<UserType>(false) {
		private static final long serialVersionUID = 1L;

		@Override
		protected UserType load() {
			return createUserModel(userOid);
		}
	};

	initLayout();

}
 
Example 24
Project: rotabuilder   File: CustomFooterPanel.java   View source code 5 votes vote down vote up
@Override
protected void onConfigure() {
    super.onConfigure();

    PageParameters parameters = getPage().getPageParameters();
    setVisible(parameters.get(PageParametersUtils.ISIS_NO_FOOTER_PARAMETER_NAME).isNull());
}
 
Example 25
Project: gitplex-mit   File: InfiniteScrollBehavior.java   View source code 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptReferenceHeaderItem.forReference(new InfiniteScrollResourceReference()));
	
	CharSequence url = RequestCycle.get().urlFor(new PackageResourceReference(
			InfiniteScrollBehavior.class, "ajax-indicator.gif"), new PageParameters());
	String script = String.format("gitplex.infiniteScroll.init('%s', %s, '%s', %s);", 
			component.getMarkupId(true), getCallbackFunction(explicit("page")), url, pageSize);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 26
Project: gitplex-mit   File: ModeUrlResourceReference.java   View source code 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	WebjarsJavaScriptResourceReference metaReference = new WebjarsJavaScriptResourceReference("codemirror/current/mode/meta.js");
	String modeBase = StringUtils.substringBeforeLast(RequestCycle.get().urlFor(metaReference, new PageParameters()).toString(), "/");
	dependencies.add(OnDomReadyHeaderItem.forScript("CodeMirror.modeURL = '" + modeBase + "/%N/%N.js';"));		
	return dependencies;
}
 
Example 27
Project: gitplex-mit   File: ArchiveResource.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(Project project, String revision, String format) {
	PageParameters params = new PageParameters();
	params.set(PARAM_DEPOT, project.getName());
	params.set(PARAM_REVISION, revision);
	params.set(PARAM_FORMAT, format);
	
	return params;
}
 
Example 28
Project: gitplex-mit   File: RawBlobResource.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(Project project, BlobIdent blobIdent) {
	PageParameters params = new PageParameters();
	params.set(PARAM_DEPOT, project.getName());
	params.set(PARAM_REVISION, blobIdent.revision);
	params.set(PARAM_PATH, blobIdent.path);
	
	return params;
}
 
Example 29
Project: gitplex-mit   File: AttachmentResource.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(Project project, String attachmentDirUUID, String attachmentName) {
	PageParameters params = new PageParameters();
	params.set(PARAM_DEPOT, project.getName());
	params.set(PARAM_UUID, attachmentDirUUID);
	params.set(PARAM_ATTACHMENT, attachmentName);
	final File attachmentFile = new File(getAttachmentDir(project, attachmentDirUUID), attachmentName);
	params.set("v", attachmentFile.lastModified());
	
	return params;
}
 
Example 30
Project: gitplex-mit   File: EmojiNodeRenderer.java   View source code 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 31
Project: gitplex-mit   File: TextDiffPanel.java   View source code 5 votes vote down vote up
private void appendBlame(StringBuilder builder, int oldLineNo, int newLineNo) {
	BlameCommit commit;
	if (newLineNo != -1)
		commit = Preconditions.checkNotNull(blameInfo.newBlame.get(newLineNo));
	else
		commit = Preconditions.checkNotNull(blameInfo.oldBlame.get(oldLineNo));
	if (diffMode == DiffViewMode.UNIFIED && !commit.getHash().equals(blameInfo.lastCommitHash)
			|| diffMode == DiffViewMode.SPLIT && newLineNo != -1 && !commit.getHash().equals(blameInfo.lastNewCommitHash)
			|| diffMode == DiffViewMode.SPLIT && oldLineNo != -1 && !commit.getHash().equals(blameInfo.lastOldCommitHash)) {
		CommitDetailPage.State state = new CommitDetailPage.State();
		state.revision = commit.getHash();
		state.whitespaceOption = change.getWhitespaceOption();
		PageParameters params = CommitDetailPage.paramsOf(projectModel.getObject(), state);
		String url = urlFor(CommitDetailPage.class, params).toString();
		if (diffMode == DiffViewMode.UNIFIED) {
			builder.append(String.format("<td class='blame noselect'><a class='hash' href='%s' data-hash='%s'>%s</a><span class='date'>%s</span><span class='author'>%s</span></td>", 
					url, commit.getHash(), GitUtils.abbreviateSHA(commit.getHash()), 
					DateUtils.formatDate(commit.getCommitter().getWhen()),
					HtmlEscape.escapeHtml5(commit.getAuthor().getName())));
		} else {
			builder.append(String.format("<td class='abbr blame noselect'><a class='hash' href='%s' data-hash='%s'>%s</a></td>", 
					url, commit.getHash(), GitUtils.abbreviateSHA(commit.getHash())));
		}
	} else {
		if (diffMode == DiffViewMode.UNIFIED) {
			builder.append("<td class='blame noselect'><div class='same-as-above'>...</div></td>");
		} else {
			builder.append("<td class='abbr blame noselect'><div class='same-as-above'>...</div></td>");
		}
	}
	blameInfo.lastCommitHash = commit.getHash();
	if (newLineNo != -1)
		blameInfo.lastNewCommitHash = commit.getHash();
	if (oldLineNo != -1)
		blameInfo.lastOldCommitHash = commit.getHash();
}
 
Example 32
Project: gitplex-mit   File: CommitDetailPage.java   View source code 5 votes vote down vote up
public CommitDetailPage(PageParameters params) {
	super(params);
	
	state = new State(params);
	resolvedRevision = getProject().getRevCommit(state.revision).copy();
	if (state.compareWith != null)
		resolvedCompareWith = getProject().getRevCommit(state.compareWith).copy();
}
 
Example 33
Project: gitplex-mit   File: ProjectCommitsPage.java   View source code 5 votes vote down vote up
public ProjectCommitsPage(PageParameters params) {
	super(params);
	
	state.compareWith = params.get(PARAM_COMPARE_WITH).toString();
	state.query = params.get(PARAM_QUERY).toString();
	Integer page = params.get(PARAM_PAGE).toOptionalInteger();
	if (page != null)
		state.page = page.intValue();		
}
 
Example 34
Project: gitplex-mit   File: ProjectCommitsPage.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(Project project, State state) {
	PageParameters params = paramsOf(project);
	if (state.compareWith != null)
		params.set(PARAM_COMPARE_WITH, state.compareWith);
	if (state.query != null)
		params.set(PARAM_QUERY, state.query);
	if (state.page != 1)
		params.set(PARAM_PAGE, state.page);
	return params;
}
 
Example 35
Project: gitplex-mit   File: SearchOption.java   View source code 5 votes vote down vote up
public void fillPageParams(PageParameters params) {
	params.set(PARAM_STATUS, status.name());
	if (submitterName != null)
		params.set(PARAM_SUBMITTER, submitterName);
	if (targetBranch != null)
		params.set(PARAM_BRANCH, targetBranch);
	if (title != null)
		params.set(PARAM_TITLE, title);
	if (beginDate != null)
		params.set(PARAM_BEGIN_DATE, beginDate.getTime());
	if (endDate != null)
		params.set(PARAM_END_DATE, endDate.getTime());
}
 
Example 36
Project: gitplex-mit   File: SinceChangesLink.java   View source code 5 votes vote down vote up
@Override
public PageParameters getPageParameters() {
	PullRequest request = requestModel.getObject();
	RequestChangesPage.State state = new RequestChangesPage.State();
	state.oldCommit = oldCommitModel.getObject();
	state.newCommit = request.getHeadCommitHash();
	return RequestChangesPage.paramsOf(request, state);
}
 
Example 37
Project: gitplex-mit   File: MergePreviewPage.java   View source code 5 votes vote down vote up
public MergePreviewPage(PageParameters params) {
	super(params);

	state.pathFilter = params.get(PARAM_PATH_FILTER).toString();
	state.whitespaceOption = WhitespaceOption.ofNullableName(params.get(PARAM_WHITESPACE_OPTION).toString());
	state.blameFile = params.get(PARAM_BLAME_FILE).toString();
}
 
Example 38
Project: gitplex-mit   File: MergePreviewPage.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(PullRequest request, State state) {
	PageParameters params = RequestDetailPage.paramsOf(request);

	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.set(PARAM_PATH_FILTER, state.pathFilter);
	if (state.blameFile != null)
		params.set(PARAM_BLAME_FILE, state.blameFile);
		
	return params;
}
 
Example 39
Project: gitplex-mit   File: RequestChangesPage.java   View source code 5 votes vote down vote up
public static PageParameters paramsOf(CodeComment comment) {
	RequestChangesPage.State state = new RequestChangesPage.State();
	state.commentId = comment.getId();
	state.mark = comment.getCommentPos();
	state.pathFilter = comment.getCommentPos().getPath();
	return paramsOf(comment.getRequest(), state);
}
 
Example 40
Project: gitplex-mit   File: UnresolvedCodeCommentsPanel.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	PullRequest request = getModelObject();
	
	PageParameters params = CodeCommentsPage.paramsOf(request, getState());
	add(new ViewStateAwarePageLink<Void>("link", CodeCommentsPage.class, params));
}