org.apache.wicket.request.IRequestParameters Java Examples

The following examples show how to use org.apache.wicket.request.IRequestParameters. 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: WebSession.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
private void redirectHash(Room r, Runnable nullAction) {
	if (r != null) {
		String url = cm.getServerUrl(r, baseUrl -> {
			PageParameters params = new PageParameters();
			IRequestParameters reqParams = RequestCycle.get().getRequest().getQueryParameters();
			reqParams.getParameterNames().forEach(name -> {
				params.add(name, reqParams.getParameterValue(name));
			});
			return Application.urlForPage(HashPage.class
					, params
					, baseUrl);
		});
		if (url == null) {
			nullAction.run();
		} else {
			throw new RedirectToUrlException(url);
		}
	}
}
 
Example #2
Source File: BratAnnotationEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
/**
 * Extract offset information from the current request. These are either offsets of an existing
 * selected annotations or offsets contained in the request for the creation of a new
 * annotation.
 */
private Offsets getOffsetsFromRequest(IRequestParameters request, CAS aCas, VID aVid)
    throws  IOException
{
    if (aVid.isNotSet() || aVid.isSynthetic()) {
        // Create new span annotation - in this case we get the offset information from the
        // request
        String offsets = request.getParameterValue(PARAM_OFFSETS).toString();
        
        OffsetsList offsetLists = JSONUtil.getObjectMapper().readValue(offsets,
                OffsetsList.class);

        int annotationBegin = getModelObject().getWindowBeginOffset()
                + offsetLists.get(0).getBegin();
        int annotationEnd = getModelObject().getWindowBeginOffset()
                + offsetLists.get(offsetLists.size() - 1).getEnd();
        return new Offsets(annotationBegin, annotationEnd);
    }
    else {
        // Edit existing span annotation - in this case we look up the offsets in the CAS
        // Let's not trust the client in this case.
        AnnotationFS fs = WebAnnoCasUtil.selectAnnotationByAddr(aCas, aVid.getId());
        return new Offsets(fs.getBegin(), fs.getEnd());
    }
}
 
Example #3
Source File: BratAnnotationEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
private ArcAnnotationResponse actionArc(AjaxRequestTarget aTarget, IRequestParameters request,
        CAS aCas, VID paramId)
    throws IOException, AnnotationException
{
    AnnotationFS originFs = selectAnnotationByAddr(aCas,
            request.getParameterValue(PARAM_ORIGIN_SPAN_ID).toInt());
    AnnotationFS targetFs = selectAnnotationByAddr(aCas,
            request.getParameterValue(PARAM_TARGET_SPAN_ID).toInt());

    AnnotatorState state = getModelObject();
    Selection selection = state.getSelection();
    selection.selectArc(paramId, originFs, targetFs);

    if (selection.getAnnotation().isNotSet()) {
        // Create new annotation
        getActionHandler().actionCreateOrUpdate(aTarget, aCas);
    }
    else {
        getActionHandler().actionSelect(aTarget);
    }

    return new ArcAnnotationResponse();
}
 
Example #4
Source File: BasePanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get the Rubric request parameters
 *
 * @return A map with key and value of those parameters
 */
protected HashMap<String, String> getRubricParameters(final String entityId) {
	final HashMap<String, String> list = new HashMap<String, String>();

	String entity = RubricsConstants.RBCS_PREFIX;
	if (entityId != null && !entityId.isEmpty()) {
		entity += entityId + "-";
	}
	final String startsWith = entity;

	final IRequestParameters parameters = RequestCycle.get().getRequest().getPostParameters();
	parameters.getParameterNames().forEach((value) -> {
		if (value.startsWith(startsWith)) {
			list.put(value, parameters.getParameterValue(value).toString());
		}
	});

	return list;
}
 
Example #5
Source File: BasePanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get the Rubric request parameters
 *
 * @return A map with key and value of those parameters
 */
protected HashMap<String, String> getRubricParameters(final String entityId) {
	final HashMap<String, String> list = new HashMap<String, String>();

	String entity = RubricsConstants.RBCS_PREFIX;
	if (entityId != null && !entityId.isEmpty()) {
		entity += entityId + "-";
	}
	final String startsWith = entity;

	final IRequestParameters parameters = RequestCycle.get().getRequest().getPostParameters();
	parameters.getParameterNames().forEach((value) -> {
		if (value.startsWith(startsWith)) {
			list.put(value, parameters.getParameterValue(value).toString());
		}
	});

	return list;
}
 
Example #6
Source File: BlameMessageBehavior.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
	IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
	
	String tooltipId = params.getParameterValue("tooltip").toString();
	String commitHash = params.getParameterValue("commit").toString();
	RevCommit commit = getProject().getRevCommit(commitHash, true);
	String authoring;
	if (commit.getAuthorIdent() != null) {
		authoring = commit.getAuthorIdent().getName();
		if (commit.getCommitterIdent() != null)
			authoring += " " + DateUtils.formatAge(commit.getCommitterIdent().getWhen());
		authoring = "'" + JavaScriptEscape.escapeJavaScript(authoring) + "'";
	} else {
		authoring = "undefined";
	}
	String message = JavaScriptEscape.escapeJavaScript(commit.getFullMessage());
	String script = String.format("onedev.server.blameMessage.show('%s', %s, '%s');", tooltipId, authoring, message); 
	target.appendJavaScript(script);
}
 
Example #7
Source File: BratAnnotationEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
private void actionOpenContextMenu(AjaxRequestTarget aTarget, IRequestParameters request,
        CAS aCas, VID paramId)
{
    List<IMenuItem> items = contextMenu.getItemList();
    items.clear();
    
    if (getModelObject().getSelection().isSpan()) {
        items.add(new LambdaMenuItem("Link to ...",
            _target -> actionArcRightClick(_target, paramId)));
    }
    
    extensionRegistry.generateContextMenuItems(items);
    
    if (!items.isEmpty()) {
        contextMenu.onOpen(aTarget);
    }
}
 
Example #8
Source File: PdfAnnotationEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
private void getAnnotations(AjaxRequestTarget aTarget, IRequestParameters aParams)
{
    page = aParams.getParameterValue("page").toInt();
    if (pageOffsetCache.containsKey(page)) {
        pageOffset = pageOffsetCache.get(page);
    } else {
        // get page offsets, if possible for the from previous to next page
        int begin = pdfExtractFile.getPageOffset(page > 1 ? page - 1 : page).getBegin();
        int end = pdfExtractFile.getPageOffset(page < pdfExtractFile.getMaxPageNumber()
            ? page + 1 : page).getEnd();
        List<Offset> offsets = new ArrayList<>();
        offsets.add(new Offset(begin, begin));
        offsets.add(new Offset(end + 1, end + 1));
        offsets =
            PdfAnnoRenderer.convertToDocumentOffsets(offsets, documentModel, pdfExtractFile);
        int newBegin = offsets.stream().mapToInt(Offset::getBegin).min().getAsInt();
        int newEnd = offsets.stream().mapToInt(Offset::getEnd).max().getAsInt();
        pageOffset = new Offset(newBegin, newEnd);
        pageOffsetCache.put(page, pageOffset);
    }
    renderPdfAnnoModel(aTarget);
}
 
Example #9
Source File: PdfAnnotationEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
private void deleteRecommendation(
    AjaxRequestTarget aTarget, IRequestParameters aParams, CAS aCas)
{
    try {
        VID paramId = VID.parseOptional(aParams.getParameterValue("id").toString());
        if (paramId.isSynthetic()) {
            getModelObject().clearArmedSlot();
            Offset offset = new Offset(aParams);
            Offset docOffset =
                PdfAnnoRenderer.convertToDocumentOffset(offset, documentModel, pdfExtractFile);
            if (docOffset.getBegin() > -1 && docOffset.getEnd() > -1) {
                extensionRegistry.fireAction(getActionHandler(), getModelObject(), aTarget,
                    aCas, paramId, "doAction");
            } else {
                handleError("Unable to delete recommendation: No match was found", aTarget);
            }
        }
    }
    catch (AnnotationException | IOException e)
    {
        handleError("Unable to delete recommendation", e, aTarget);
    }
}
 
Example #10
Source File: ApplyEditorChangesBehavior.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    if (actionActive)
        return;
    actionActive = true;
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String json = params.getParameterValue(JSON_VAR).toString("[]");
    List<OArchitectOClass> classes;
    classes = JsonUtil.fromJSON(json);
    try {
        addClassesToSchema(classes);
        target.prependJavaScript("app.executeCallback({apply: true}); " +
                "app.checksAboutClassesChanges(function() {app.saveEditorConfig(mxUtils.getXml(OArchitectUtil.getEditorXmlNode(app.editor.graph)),null);}); ");
    } catch (Exception ex) {
        LOG.error("Can't apply editor changes: ", ex);
        target.prependJavaScript("app.executeCallback({apply: false});");
    }
    actionActive = false;
}
 
Example #11
Source File: GetOClassesBehavior.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String json = params.getParameterValue(EXISTS_CLASSES_VAR).toString("[]");
    boolean classesList = params.getParameterValue(CLASSES_LIST_VAR).toBoolean(false);
    if (classesList) {
        target.appendJavaScript(String.format("app.executeCallback('%s');", getAllClassesAsJson()));
    } else {
        target.prependJavaScript(OArchitectJsUtils.switchPageScroll(true));
        widget.onModalWindowEvent(
                new OpenModalWindowEvent(
                        target,
                        createModalWindowTitle(),
                        id -> createPanel(id, new ListModel<>(JsonUtil.fromJSON(json)))
                )
        );
    }
}
 
Example #12
Source File: JPPFTableTree.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
protected void onEvent(final AjaxRequestTarget target) {
  final JPPFWebSession session = (JPPFWebSession) target.getPage().getSession();
  final TableTreeData data = session.getTableTreeData(type);
  final SelectionHandler selectionHandler = data.getSelectionHandler();
  final DefaultMutableTreeNode node = TreeTableUtils.findTreeNode((DefaultMutableTreeNode) data.getModel().getRoot(), uuid, selectionHandler.getFilter());
  if (node != null) {
    final IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    final TypedProperties props = new TypedProperties()
      .setBoolean("ctrl", params.getParameterValue("ctrl").toBoolean(false))
      .setBoolean("shift", params.getParameterValue("shift").toBoolean(false));
    final Page page = target.getPage();
    if (selectionHandler.handle(target, node, props) && (page instanceof TableTreeHolder)) {
      final TableTreeHolder holder = (TableTreeHolder) page;
      target.add(holder.getTableTree());
      target.add(holder.getToolbar());
    }
  }
}
 
Example #13
Source File: ManageEditorConfigBehavior.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    if (actionActive)
        return;
    actionActive = true;
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    try {
        ODocument document = model.getObject();
        document.field(OArchitectModule.CONFIG_OPROPERTY, params.getParameterValue(CONFIG_VAR));
        document.save();
        target.appendJavaScript("app.executeCallback({save: true});");
    } catch (Exception ex) {
        LOG.error("Can't save editor config to database: {}", ex);
        target.appendJavaScript("app.executeCallback({save: false});");
    }
    actionActive = false;
}
 
Example #14
Source File: ConceptFeatureEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
@Override
public String[] getInputAsArray()
{
    // If the web request includes the additional "identifier" parameter which is supposed
    // to contain the IRI of the selected item instead of its label, then we use that as the
    // value.
    WebRequest request = getWebRequest();
    IRequestParameters requestParameters = request.getRequestParameters();
    StringValue identifier = requestParameters
            .getParameterValue(getInputName() + ":identifier");
    
    if (!identifier.isEmpty()) {
        return new String[] { identifier.toString() };
    }
    
    return super.getInputAsArray();
}
 
Example #15
Source File: ExtendedClientProperties.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void read(IRequestParameters parameters) {
	super.read(parameters);
	String _url = parameters.getParameterValue("codebase").toString(OpenmeetingsVariables.getBaseUrl());
	StringBuilder sb = cleanUrl(_url);
	if (sb.charAt(sb.length() - 1) != '/') {
		sb.append('/');
	}
	baseUrl = sb.toString();
	codebase = sb.append("screenshare").toString();
	settings = parameters.getParameterValue("settings").toString("{}");
}
 
Example #16
Source File: BratAnnotationEditor.java    From webanno with Apache License 2.0 5 votes vote down vote up
private Object actionDoAction(AjaxRequestTarget aTarget, IRequestParameters request, CAS aCas,
        VID paramId)
    throws AnnotationException, IOException
{
    StringValue layerParam = request.getParameterValue(PARAM_SPAN_TYPE);
    
    if (!layerParam.isEmpty()) {
        long layerId = decodeTypeName(layerParam.toString());
        AnnotatorState state = getModelObject();
        AnnotationLayer layer = annotationService.getLayer(state.getProject(), layerId)
                .orElseThrow(() -> new AnnotationException("Layer with ID [" + layerId
                        + "] does not exist in project [" + state.getProject().getName() + "]("
                        + state.getProject().getId() + ")"));
        if (!StringUtils.isEmpty(layer.getOnClickJavascriptAction())) {
            // parse the action
            List<AnnotationFeature> features = annotationService.listSupportedFeatures(layer);
            AnnotationFS anno = selectAnnotationByAddr(aCas, paramId.getId());
            Map<String, Object> functionParams = OnClickActionParser.parse(layer, features,
                    getModelObject().getDocument(), anno);
            // define anonymous function, fill the body and immediately execute
            String js = String.format("(function ($PARAM){ %s })(%s)",
                    layer.getOnClickJavascriptAction(), JSONUtil.toJsonString(functionParams));
            aTarget.appendJavaScript(js);
        }
    }
    
    return null;
}
 
Example #17
Source File: BratAnnotationEditor.java    From webanno with Apache License 2.0 5 votes vote down vote up
private SpanAnnotationResponse actionSpan(AjaxRequestTarget aTarget, IRequestParameters request,
        CAS aCas, VID aSelectedAnnotation)
    throws IOException, AnnotationException
{
    // This is the span the user has marked in the browser in order to create a new slot-filler
    // annotation OR the span of an existing annotation which the user has selected.
    Offsets optUserSelectedSpan = getOffsetsFromRequest(request, aCas, aSelectedAnnotation);
    
    Offsets userSelectedSpan = optUserSelectedSpan;
    AnnotatorState state = getModelObject();
    Selection selection = state.getSelection();

    if (state.isSlotArmed()) {
        // When filling a slot, the current selection is *NOT* changed. The
        // Span annotation which owns the slot that is being filled remains
        // selected!
        getActionHandler().actionFillSlot(aTarget, aCas, userSelectedSpan.getBegin(),
                userSelectedSpan.getEnd(), aSelectedAnnotation);
    }
    else {
        if (!aSelectedAnnotation.isSynthetic()) {
            selection.selectSpan(aSelectedAnnotation, aCas, userSelectedSpan.getBegin(),
                    userSelectedSpan.getEnd());

            if (selection.getAnnotation().isNotSet()) {
                // Create new annotation
                getActionHandler().actionCreateOrUpdate(aTarget, aCas);
            }
            else {
                getActionHandler().actionSelect(aTarget);
            }
        }
    }
    
    return new SpanAnnotationResponse();
}
 
Example #18
Source File: AbstractBirtReportPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequest() {
	RequestCycle requestCycle = RequestCycle.get();
	IRequestParameters params = requestCycle.getRequest().getRequestParameters();
	String imageId = params.getParameterValue(RESOURCE_IMAGE_ID).toOptionalString();
	if(imageId!=null) {
		IResource resource = imageHandler.getBirtImageAsResource(imageId);
		if(resource!=null) {
			resource.respond(new Attributes(requestCycle.getRequest(), requestCycle.getResponse(), null));
		}
	}
}
 
Example #19
Source File: ContextMenu.java    From webanno with Apache License 2.0 5 votes vote down vote up
/**
 * Fired by a component that holds a {@link ContextMenuBehavior}
 *
 * @param target
 *            the {@link AjaxRequestTarget}
 */
public void onOpen(AjaxRequestTarget target)
{
    onContextMenu(target, null);

    final IRequestParameters request = getRequest().getPostParameters();

    int clientX = request.getParameterValue("clientX").toInt();
    int clientY = request.getParameterValue("clientY").toInt();

    target.add(this);
    target.appendJavaScript(String.format(
            "jQuery('%s').show().css({position:'fixed', left:'%dpx', top:'%dpx'});",
            JQueryWidget.getSelector(this), clientX, clientY));
}
 
Example #20
Source File: AnnotationPage.java    From webanno with Apache License 2.0 5 votes vote down vote up
private UrlParametersReceivingBehavior createUrlFragmentBehavior()
{
    return new UrlParametersReceivingBehavior()
    {
        private static final long serialVersionUID = -3860933016636718816L;

        @Override
        protected void onParameterArrival(IRequestParameters aRequestParameters,
                AjaxRequestTarget aTarget)
        {
            StringValue project = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_ID);
            StringValue projectName =
                    aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_NAME);
            StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_ID);
            StringValue name = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_NAME);
            StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
            
            // nothing changed, do not check for project, because inception always opens 
            // on a project
            if (document.isEmpty() && name.isEmpty() && focus.isEmpty()) {
                return;
            }
            SourceDocument previousDoc = getModelObject().getDocument();
            handleParameters(project, projectName, document, name, focus, false);
            
            // url is from external link, not just paging through documents,
            // tabs may have changed depending on user rights
            if (previousDoc == null) {
                leftSidebar.refreshTabs(aTarget);
            }
            
            updateDocumentView(aTarget, previousDoc, focus);
        }
    };
}
 
Example #21
Source File: MainPage.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onParameterArrival(IRequestParameters params, AjaxRequestTarget target) {
	log.debug("MainPage::onParameterArrival");
	OmUrlFragment newf = getUrlFragment(params);
	if (newf != null) {
		uf = newf;
	}
	if (loaded && newf != null) {
		main.updateContents(newf, target, false);
	}
}
 
Example #22
Source File: GenerateJavaSourcesBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String json = params.getParameterValue(JSON_VAR).toString("[]");
    target.prependJavaScript(OArchitectJsUtils.switchPageScroll(true));
    widget.onModalWindowEvent(
            new OpenModalWindowEvent(
                    target,
                    new ResourceModel("widget.architect.editor.java.sources"),
                    id -> new JavaSourcesPanel(id, new ListModel<>(JsonUtil.fromJSON(json)))
            )
    );
}
 
Example #23
Source File: ExistsOClassBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String json = params.getParameterValue(EXISTS_CLASS_VAR).toString();
    String className = getClassNameFromJson(json);
    Boolean exists = false;
    if (!Strings.isNullOrEmpty(className)) {
        OSchema schema = OrienteerWebApplication.get().getDatabase().getMetadata().getSchema();
        exists = schema.existsClass(className);
    }
    target.appendJavaScript(String.format("app.executeCallback(%s);", exists.toString()));
}
 
Example #24
Source File: GetNewChangesBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String classesNamesJson = params.getParameterValue(CLASSES_NAMES_VAR).toString();
    String json = "";
    if (!Strings.isNullOrEmpty(classesNamesJson)) {
        List<OClass> classes = getClasses(toList(classesNamesJson));
        List<OArchitectOClass> architectClasses = toArchitectOClasses(classes);
        json = JsonUtil.toJSON(architectClasses);
    }
    target.appendJavaScript(String.format("; app.executeCallback('%s'); ", json));
}
 
Example #25
Source File: ColumnsOrderBehavior.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
	IRequestParameters request = RequestCycle.get().getRequest().getRequestParameters();
	int oldIndex = request.getParameterValue(OLD_INDEX).toInt();
	int newIndex = request.getParameterValue(NEW_INDEX).toInt();	
	onResponse(oldIndex, newIndex, target);
}
 
Example #26
Source File: PdfAnnotationEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
public void createSpanAnnotation(
    AjaxRequestTarget aTarget, IRequestParameters aParams, CAS aCas)
{
    if (pdfExtractFile == null && documentModel == null) {
        // in this case the user probably changed the document and accidentally
        // marked text in the old document. so do not create any annotation here.
        handleError("Unable to create span annotation: " 
            + "Did you accidentally marked text when switching documents?", aTarget);
        return;
    }
    
    try {
        Offset offset = new Offset(aParams);
        Offset docOffset = convertToDocumentOffset(offset, documentModel, pdfExtractFile);
        AnnotatorState state = getModelObject();
        if (docOffset.getBegin() > -1 && docOffset.getEnd() > -1) {
            if (state.isSlotArmed()) {
                // When filling a slot, the current selection is *NOT* changed. The
                // Span annotation which owns the slot that is being filled remains
                // selected!
                getActionHandler().actionFillSlot(aTarget, aCas, docOffset.getBegin(),
                        docOffset.getEnd(), NONE_ID);
            }
            else {
                state.getSelection().selectSpan(aCas, docOffset.getBegin(), docOffset.getEnd());
                getActionHandler().actionCreateOrUpdate(aTarget, aCas);
            }
        }
        else {
            handleError("Unable to create span annotation: No match was found", aTarget);
        }
    }
    catch (IOException | AnnotationException e) {
        handleError("Unable to create span annotation", e, aTarget);
    }
}
 
Example #27
Source File: PdfAnnotationEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
private void createRelationAnnotation(AjaxRequestTarget aTarget, IRequestParameters aParams,
        CAS aCas)
    throws IOException
{
    try {
        VID origin = VID.parseOptional(aParams.getParameterValue("origin").toString());
        VID target = VID.parseOptional(aParams.getParameterValue("target").toString());

        if (target.isNotSet()) {
            // relation drawing was not stopped over a target
            return;
        }

        if (origin.isSynthetic() || target.isSynthetic()) {
            throw new AnnotationException("Cannot create relations on suggestions");
        }

        AnnotationFS originFs = selectByAddr(aCas, AnnotationFS.class, origin.getId());
        AnnotationFS targetFs = selectByAddr(aCas, AnnotationFS.class, target.getId());

        AnnotatorState state = getModelObject();
        Selection selection = state.getSelection();
        selection.selectArc(VID.NONE_ID, originFs, targetFs);

        if (selection.getAnnotation().isNotSet()) {
            getActionHandler().actionCreateOrUpdate(aTarget, aCas);
        }
    }
    catch (AnnotationException | CASRuntimeException e)
    {
        handleError("Unable to create relation annotation", e, aTarget);
    }
    finally
    {
        // workaround to enable further creation of relations in PDFAnno
        // if existing annotations are not re-rendered after an attempt to create a relation.
        // it can happen that mouse will hang when leaving annotation knob while dragging
        renderPdfAnnoModel(aTarget);
    }
}
 
Example #28
Source File: PdfAnnotationEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
private void selectRelationAnnotation(
    AjaxRequestTarget aTarget, IRequestParameters aParams, CAS aCas)
{
    try {
        AnnotationFS originFs = selectByAddr(aCas, AnnotationFS.class,
                aParams.getParameterValue("origin").toInt());
        AnnotationFS targetFs = selectByAddr(aCas, AnnotationFS.class,
                aParams.getParameterValue("target").toInt());

        AnnotatorState state = getModelObject();
        Selection selection = state.getSelection();
        VID paramId = VID.parseOptional(aParams.getParameterValue("id").toString());

        // HACK: If an arc was clicked that represents a link feature, then
        // open the associated span annotation instead.
        if (paramId.isSlotSet()) {
            paramId = new VID(paramId.getId());
            selectSpanAnnotation(aTarget, paramId, aCas);
        }
        else {
            selection.selectArc(paramId, originFs, targetFs);

            if (selection.getAnnotation().isSet()) {
                getActionHandler().actionSelect(aTarget);
            }
        }
    }
    catch (Exception e) {
        handleError("Unable to select relation annotation", e, aTarget);
    }
}
 
Example #29
Source File: TextDiffPanel.java    From onedev with MIT License 5 votes vote down vote up
private Mark getMark(IRequestParameters params, String leftSideParam, 
		String beginLineParam, String beginCharParam, 
		String endLineParam, String endCharParam) {
	boolean leftSide = params.getParameterValue(leftSideParam).toBoolean();
	int beginLine = params.getParameterValue(beginLineParam).toInt();
	int beginChar = params.getParameterValue(beginCharParam).toInt();
	int endLine = params.getParameterValue(endLineParam).toInt();
	int endChar = params.getParameterValue(endCharParam).toInt();
	String commit = leftSide?getOldCommit().name():getNewCommit().name();
	return new Mark(commit, change.getPath(), new PlanarRange(beginLine, beginChar, endLine, endChar));
}
 
Example #30
Source File: SourceViewPanel.java    From onedev with MIT License 5 votes vote down vote up
private PlanarRange getMark(IRequestParameters params, String beginLineParam, String beginCharParam, 
		String endLineParam, String endCharParam) {
	int beginLine = params.getParameterValue(beginLineParam).toInt();
	int beginChar = params.getParameterValue(beginCharParam).toInt();
	int endLine = params.getParameterValue(endLineParam).toInt();
	int endChar = params.getParameterValue(endCharParam).toInt();
	PlanarRange mark = new PlanarRange();
	mark.fromRow = beginLine;
	mark.fromColumn = beginChar;
	mark.toRow = endLine;
	mark.toColumn = endChar;
	return mark;
}