use of org.apache.wicket.markup.html.panel.Fragment in project syncope by apache.
the class BinaryPDFPreviewer method preview.
@Override
public Component preview(final byte[] uploadedBytes) {
firstPage = null;
try (InputStream bais = new ByteArrayInputStream(uploadedBytes);
PDDocument document = PDDocument.load(bais, MemoryUsageSetting.setupTempFileOnly())) {
document.setResourceCache(new DefaultResourceCache() {
@Override
public void put(final COSObject indirect, final PDXObject xobject) throws IOException {
}
});
if (document.isEncrypted()) {
LOG.info("Document is encrypted, no preview is possible");
} else {
firstPage = new PDFRenderer(document).renderImageWithDPI(0, DPI, IMAGE_TYPE);
}
} catch (IOException e) {
LOG.error("While generating thumbnail from first page", e);
}
Fragment fragment;
if (firstPage == null) {
fragment = new Fragment("preview", "noPreviewFragment", this);
} else {
fragment = new Fragment("preview", "previewFragment", this);
fragment.add(new NonCachingImage("previewImage", new ThumbnailImageResource(firstPage)));
}
WebMarkupContainer previewContainer = new WebMarkupContainer("previewContainer");
previewContainer.setOutputMarkupId(true);
previewContainer.add(fragment);
return this.addOrReplace(previewContainer);
}
use of org.apache.wicket.markup.html.panel.Fragment in project syncope by apache.
the class AbstractMultiPanel method getPlusFragment.
private Fragment getPlusFragment(final IModel<List<INNER>> model, final String label) {
final IndicatorAjaxSubmitLink plus = new IndicatorAjaxSubmitLink("add") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
// Add current component
model.getObject().add(newModelObject());
if (model.getObject().size() == 1) {
form.addOrReplace(getDataFragment());
}
target.add(container);
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
SyncopeConsoleSession.get().error(getString(Constants.OPERATION_ERROR));
super.onError(target, form);
((BasePage) getPage()).getNotificationPanel().refresh(target);
}
};
final Fragment fragment = new Fragment("panelPlus", "fragmentPlus", AbstractMultiPanel.this);
fragment.addOrReplace(plus);
fragment.setRenderBodyOnly(true);
return fragment;
}
use of org.apache.wicket.markup.html.panel.Fragment in project openmeetings by apache.
the class RecordingExpiringTemplate method getSubjectFragment.
@Override
Fragment getSubjectFragment() {
Fragment f = new Fragment(COMP_ID, "subject", this);
Room room = roomDao.get(rec.getRoomId());
f.add(new OmTextLabel("prefix", getString("template.recording.expiring.subj.prefix", locale)), new OmTextLabel("room", room == null ? null : getString("template.recording.expiring.subj.room", locale, room.getName())).setVisible(room != null));
return f;
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class TicketPage method createMergePanel.
/**
* Adds a merge panel for the patchset to the markup container. The panel
* may just a message if the patchset can not be merged.
*
* @param c
* @param user
* @param repository
*/
protected Component createMergePanel(UserModel user, RepositoryModel repository) {
Patchset patchset = ticket.getCurrentPatchset();
if (patchset == null) {
// no patchset to merge
return new Label("mergePanel");
}
boolean allowMerge;
if (repository.requireApproval) {
// repository requires approval
allowMerge = ticket.isOpen() && ticket.isApproved(patchset);
} else {
// vetoes are binding
allowMerge = ticket.isOpen() && !ticket.isVetoed(patchset);
}
MergeStatus mergeStatus = JGitUtils.canMerge(getRepository(), patchset.tip, ticket.mergeTo, repository.mergeType);
if (allowMerge) {
if (MergeStatus.MERGEABLE == mergeStatus) {
// patchset can be cleanly merged to integration branch OR has already been merged
Fragment mergePanel = new Fragment("mergePanel", "mergeableFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetMergeable"), ticket.mergeTo)));
if (user.canPush(repository)) {
// user can merge locally
SimpleAjaxLink<String> mergeButton = new SimpleAjaxLink<String>("mergeButton", Model.of(getString("gb.merge"))) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
// ensure the patchset is still current AND not vetoed
Patchset patchset = ticket.getCurrentPatchset();
final TicketModel refreshedTicket = app().tickets().getTicket(getRepositoryModel(), ticket.number);
if (patchset.equals(refreshedTicket.getCurrentPatchset())) {
// patchset is current, check for recent veto
if (!refreshedTicket.isVetoed(patchset)) {
// patchset is not vetoed
// execute the merge using the ticket service
app().tickets().exec(new Runnable() {
@Override
public void run() {
PatchsetReceivePack rp = new PatchsetReceivePack(app().gitblit(), getRepository(), getRepositoryModel(), GitBlitWebSession.get().getUser());
MergeStatus result = rp.merge(refreshedTicket);
if (MergeStatus.MERGED == result) {
// notify participants and watchers
rp.sendAll();
} else {
// merge failure
String msg = MessageFormat.format("Failed to merge ticket {0,number,0}: {1}", ticket.number, result.name());
logger().error(msg);
GitBlitWebSession.get().cacheErrorMessage(msg);
}
}
});
} else {
// vetoed patchset
String msg = MessageFormat.format("Can not merge ticket {0,number,0}, patchset {1,number,0} has been vetoed!", ticket.number, patchset.number);
GitBlitWebSession.get().cacheErrorMessage(msg);
logger().error(msg);
}
} else {
// not current patchset
String msg = MessageFormat.format("Can not merge ticket {0,number,0}, the patchset has been updated!", ticket.number);
GitBlitWebSession.get().cacheErrorMessage(msg);
logger().error(msg);
}
redirectTo(TicketsPage.class, getPageParameters());
}
};
mergePanel.add(mergeButton);
Component instructions = getMergeInstructions(user, repository, "mergeMore", "gb.patchsetMergeableMore");
mergePanel.add(instructions);
} else {
mergePanel.add(new Label("mergeButton").setVisible(false));
mergePanel.add(new Label("mergeMore").setVisible(false));
}
return mergePanel;
} else if (MergeStatus.ALREADY_MERGED == mergeStatus) {
// patchset already merged
Fragment mergePanel = new Fragment("mergePanel", "alreadyMergedFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetAlreadyMerged"), ticket.mergeTo)));
return mergePanel;
} else if (MergeStatus.MISSING_INTEGRATION_BRANCH == mergeStatus) {
// target/integration branch is missing
Fragment mergePanel = new Fragment("mergePanel", "notMergeableFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetNotMergeable"), ticket.mergeTo)));
mergePanel.add(new Label("mergeMore", MessageFormat.format(getString("gb.missingIntegrationBranchMore"), ticket.mergeTo)));
return mergePanel;
} else {
// patchset can not be cleanly merged
Fragment mergePanel = new Fragment("mergePanel", "notMergeableFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetNotMergeable"), ticket.mergeTo)));
if (user.canPush(repository)) {
// user can merge locally
Component instructions = getMergeInstructions(user, repository, "mergeMore", "gb.patchsetNotMergeableMore");
mergePanel.add(instructions);
} else {
mergePanel.add(new Label("mergeMore").setVisible(false));
}
return mergePanel;
}
} else {
// merge not allowed
if (MergeStatus.ALREADY_MERGED == mergeStatus) {
// patchset already merged
Fragment mergePanel = new Fragment("mergePanel", "alreadyMergedFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetAlreadyMerged"), ticket.mergeTo)));
return mergePanel;
} else if (ticket.isVetoed(patchset)) {
// patchset has been vetoed
Fragment mergePanel = new Fragment("mergePanel", "vetoedFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetNotMergeable"), ticket.mergeTo)));
return mergePanel;
} else if (repository.requireApproval) {
// patchset has been not been approved for merge
Fragment mergePanel = new Fragment("mergePanel", "notApprovedFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetNotApproved"), ticket.mergeTo)));
mergePanel.add(new Label("mergeMore", MessageFormat.format(getString("gb.patchsetNotApprovedMore"), ticket.mergeTo)));
return mergePanel;
} else {
// other case
return new Label("mergePanel");
}
}
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class TicketsPage method milestoneList.
protected DataView<TicketMilestone> milestoneList(String wicketId, List<TicketMilestone> milestones, final boolean acceptingUpdates) {
ListDataProvider<TicketMilestone> milestonesDp = new ListDataProvider<TicketMilestone>(milestones);
DataView<TicketMilestone> milestonesList = new DataView<TicketMilestone>(wicketId, milestonesDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<TicketMilestone> item) {
Fragment entryPanel = new Fragment("entryPanel", "milestoneListFragment", this);
item.add(entryPanel);
final TicketMilestone tm = item.getModelObject();
String[] states;
if (tm.isOpen()) {
states = TicketsUI.openStatii;
} else {
states = TicketsUI.closedStatii;
}
PageParameters params = queryParameters(null, tm.name, states, null, null, true, 1);
entryPanel.add(new LinkPanel("milestoneName", null, tm.name, TicketsPage.class, params).setRenderBodyOnly(true));
String css;
String status = tm.status.name();
switch(tm.status) {
case Open:
if (tm.isOverdue()) {
css = "aui-lozenge aui-lozenge-subtle aui-lozenge-error";
status = "overdue";
} else {
css = "aui-lozenge aui-lozenge-subtle";
}
break;
default:
css = "aui-lozenge";
break;
}
Label stateLabel = new Label("milestoneState", status);
WicketUtils.setCssClass(stateLabel, css);
entryPanel.add(stateLabel);
if (tm.due == null) {
entryPanel.add(new Label("milestoneDue", getString("gb.notSpecified")));
} else {
entryPanel.add(WicketUtils.createDatestampLabel("milestoneDue", tm.due, getTimeZone(), getTimeUtils()));
}
if (acceptingUpdates) {
entryPanel.add(new LinkPanel("editMilestone", null, getString("gb.edit"), EditMilestonePage.class, WicketUtils.newObjectParameter(repositoryName, tm.name)));
} else {
entryPanel.add(new Label("editMilestone").setVisible(false));
}
if (tm.isOpen()) {
// re-load milestone with query results
TicketMilestone m = app().tickets().getMilestone(getRepositoryModel(), tm.name);
Fragment milestonePanel = new Fragment("milestonePanel", "openMilestoneFragment", this);
Label label = new Label("progress");
WicketUtils.setCssStyle(label, "width:" + m.getProgress() + "%;");
milestonePanel.add(label);
milestonePanel.add(new LinkPanel("openTickets", null, MessageFormat.format(getString("gb.nOpenTickets"), m.getOpenTickets()), TicketsPage.class, queryParameters(null, tm.name, TicketsUI.openStatii, null, null, true, 1)));
milestonePanel.add(new LinkPanel("closedTickets", null, MessageFormat.format(getString("gb.nClosedTickets"), m.getClosedTickets()), TicketsPage.class, queryParameters(null, tm.name, TicketsUI.closedStatii, null, null, true, 1)));
milestonePanel.add(new Label("totalTickets", MessageFormat.format(getString("gb.nTotalTickets"), m.getTotalTickets())));
entryPanel.add(milestonePanel);
} else {
entryPanel.add(new Label("milestonePanel").setVisible(false));
}
}
};
return milestonesList;
}
Aggregations