You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/03/30 17:43:47 UTC
[18/59] [abbrv] isis git commit: ISIS-720: mothballing scimpi
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
deleted file mode 100644
index 6b097bb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view;
-
-import org.apache.isis.viewer.scimpi.dispatcher.action.Attributes;
-
-public class SwfTag implements Snippet {
-
- public static final int END = 0;
- public static final int EMPTY = 1;
- public static final int START = 2;
- private final String tagName;
- private final int type;
- private final Attributes attributes;
- private final String lineNumbers;
- private final String path;
-
- public SwfTag(final String tagName, final Attributes attributes, final int type, final String lineNumbers, final String path) {
- this.tagName = tagName;
- this.attributes = attributes;
- this.type = type;
- this.lineNumbers = lineNumbers;
- this.path = path;
- }
-
- @Override
- public String getHtml() {
- return tagName;
- }
-
- public String getPath() {
- return path;
- }
-
- public int getType() {
- return type;
- }
-
- public String getName() {
- return tagName;
- }
-
- public Attributes getAttributes() {
- return attributes;
- }
-
- @Override
- public String errorAt() {
- return path + ":" + lineNumbers;
- }
-
- public String debug() {
- return path + ":" + lineNumbers + " - " + getAttributes();
- }
-
- @Override
- public String toString() {
- String t = null;
- switch (type) {
- case EMPTY:
- t = "empty";
- break;
- case START:
- t = "start";
- break;
- case END:
- t = "end";
- break;
- }
- return "SwfTag[name=" + tagName + ",path=" + path + ",line=" + lineNumbers + ",type=" + t + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
deleted file mode 100644
index 6b054b1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.scimpi.dispatcher.view;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class VersionNumber extends AbstractElementProcessor {
-
- private static final String MARKER = "Implementation-Build: ";
- private static final String FILE = "/META-INF/MANIFEST.MF";
- private String version;
-
- @Override
- public String getName() {
- return "version-number";
- }
-
- @Override
- public void process(final Request request) {
- if (version == null) {
- version = "0000"; // default revision number
- loadRevisonNumber(request.getContext());
- }
- request.appendHtml(version);
- }
-
- private void loadRevisonNumber(final RequestContext context) {
- BufferedReader reader;
- try {
- String file = FILE;
-
- file = context.findFile(FILE);
- reader = new BufferedReader(new InputStreamReader(context.openStream(file)));
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.startsWith(MARKER)) {
- version = line.substring(MARKER.length());
- break;
- }
- }
- reader.close();
- } catch (final IOException e) {
- throw new ScimpiException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
deleted file mode 100644
index 740de00..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
-
-public class ActionButton extends AbstractElementProcessor {
- private static final Logger LOG = LoggerFactory.getLogger(ActionButton.class);
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final static Where where = Where.ANYWHERE;
-
- @Override
- public void process(final Request request) {
- final String objectId = request.getOptionalProperty(OBJECT);
- final String methodName = request.getRequiredProperty(METHOD);
- final String forwardResultTo = request.getOptionalProperty(VIEW);
- final String forwardVoidTo = request.getOptionalProperty(VOID);
- final String forwardErrorTo = request.getOptionalProperty(ERROR);
- final String variable = request.getOptionalProperty(RESULT_NAME);
- final String scope = request.getOptionalProperty(SCOPE);
- final String buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
- String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- final String idName = request.getOptionalProperty(ID, methodName);
- final String className = request.getOptionalProperty(CLASS);
- final boolean showMessage = request.isRequested(SHOW_MESSAGE, false);
- final String completionMessage = request.getOptionalProperty(MESSAGE);
-
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
- final String version = request.getContext().mapVersion(object);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
-
- final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.processUtilCloseTag();
- final String[] parameters = parameterBlock.getParameters();
- final ObjectAdapter[] objectParameters;
-
- final ObjectAdapter target;
- if (false /*action.isContributed()*/) {
-// objectParameters= null;
-// System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
-// parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
-// target = action.realTarget(object);
-// if (!action.hasReturn() && resultOverride == null) {
-// resultOverride = parameters[0];
-// }
- } else {
- objectParameters = new ObjectAdapter[parameters.length];
- target = object;
- int i = 0;
- for (final ObjectActionParameter spec : action.getParameters()) {
- final ObjectSpecification type = spec.getSpecification();
- if (parameters[i] == null) {
- objectParameters[i] = null;
- } else if (type.getFacet(ParseableFacet.class) != null) {
- final ParseableFacet facet = type.getFacet(ParseableFacet.class);
- Localization localization = IsisContext.getLocalization();
- objectParameters[i] = facet.parseTextEntry(null, parameters[i], localization);
- } else {
- objectParameters[i] = MethodsUtils.findObject(request.getContext(), parameters[i]);
- }
- i++;
- }
- }
-
- if (MethodsUtils.isVisibleAndUsable(object, action, where) && MethodsUtils.canRunMethod(object, action, objectParameters).isAllowed()) {
- // TODO use the form creation mechanism as used in ActionForm
- write(request, target, action, parameters, version, forwardResultTo, forwardVoidTo, forwardErrorTo, variable, scope, buttonTitle, completionMessage, resultOverride, idName, className);
- }
-
- if (showMessage) {
- final Consent usable = action.isUsable(IsisContext.getAuthenticationSession(), object, where);
- if (usable.isVetoed()) {
- final String notUsable = usable.getReason();
- if (notUsable != null) {
- String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(request, title, notUsable, idName, className);
- }
- } else {
- final Consent valid = action.isProposedArgumentSetValid(object, objectParameters);
- final String notValid = valid.getReason();
- if (notValid != null) {
- String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(request, title, notValid, idName, className);
- }
- }
- }
-
- request.popBlockContent();
- }
-
- private void disabledButton(final Request request, final String buttonTitle, String message, String id, String className) {
- if (className == null) {
- className = "access";
- }
- request.appendHtml("<div id=\"" + id + "\" class=\"" + className + " disabled-form\">");
- request.appendHtml("<div class=\"button disabled\" title=\"");
- request.appendAsHtmlEncoded(message);
- request.appendHtml("\" >" + buttonTitle);
- request.appendHtml("</div>");
- request.appendHtml("</div>");
- }
-
- public static void write(
- final Request request,
- final ObjectAdapter object,
- final ObjectAction action,
- final String[] parameters,
- final String version,
- String forwardResultTo,
- String forwardVoidTo,
- String forwardErrorTo,
- final String variable,
- final String scope,
- String buttonTitle,
- final String completionMessage,
- final String resultOverride,
- final String idName,
- final String className) {
- final RequestContext context = request.getContext();
-
- buttonTitle = buttonTitle != null ? buttonTitle : action.getName();
-
- if (action.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- LOG.info("action not visible " + action.getName());
- return;
- }
- final Consent usable = action.isUsable(IsisContext.getAuthenticationSession(), object, where);
- if (usable.isVetoed()) {
- LOG.info("action not available: " + usable.getReason());
- return;
- }
-
- /*
- *
- * TODO this mechanism fails as it tries to process tags - which we dont
- * need! Also it calls action 'edit' (not 'action'). Field[] fields =
- * new Field[0]; HiddenField[] hiddenFields = new HiddenField[] { new
- * HiddenField("service", serviceId), new HiddenField("method",
- * methodName), new HiddenField("view", forwardToView), variable == null
- * ? null : new HiddenField("variable", variable), };
- * Form.createForm(request, buttonTitle, fields, hiddenFields, false);
- */
-
- final String objectId = context.mapObject(object, Scope.INTERACTION);
- final String idSegment = idName == null ? "" : ("id=\"" + idName + "\" ");
- final String classSegment = "class=\"" + (className == null ? "action in-line" : className) + "\"";
- request.appendHtml("\n<form " + idSegment + classSegment + " action=\"action.app\" method=\"post\">\n");
- if (objectId == null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + context.getVariable(RequestContext.RESULT) + "\" />\n");
- } else {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + StringEscapeUtils.escapeHtml(objectId) + "\" />\n");
- }
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VERSION + "\" value=\"" + version + "\" />\n");
- if (scope != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + SCOPE + "\" value=\"" + scope + "\" />\n");
- }
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + METHOD + "\" value=\"" + action.getId() + "\" />\n");
- if (forwardResultTo != null) {
- forwardResultTo = context.fullFilePath(forwardResultTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VIEW + "\" value=\"" + forwardResultTo + "\" />\n");
- }
- if (forwardErrorTo == null) {
- forwardErrorTo = request.getContext().getResourceFile();
- }
- forwardErrorTo = context.fullFilePath(forwardErrorTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + ERROR + "\" value=\"" + forwardErrorTo + "\" />\n");
- if (forwardVoidTo == null) {
- forwardVoidTo = request.getContext().getResourceFile();
- }
- forwardVoidTo = context.fullFilePath(forwardVoidTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VOID + "\" value=\"" + forwardVoidTo + "\" />\n");
- if (variable != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_NAME + "\" value=\"" + variable + "\" />\n");
- }
- if (resultOverride != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />\n");
- }
- if (completionMessage != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + MESSAGE + "\" value=\"" + completionMessage + "\" />\n");
- }
-
- for (int i = 0; i < parameters.length; i++) {
- request.appendHtml(" <input type=\"hidden\" name=\"param" + (i + 1) + "\" value=\"" + parameters[i] + "\" />\n");
- }
- request.appendHtml(request.getContext().interactionFields());
- request.appendHtml(" <input class=\"button\" type=\"submit\" value=\"" + buttonTitle + "\" name=\"execute\" title=\"" + action.getDescription() + "\" />");
- HelpLink.append(request, action.getDescription(), action.getHelp());
- request.appendHtml("\n</form>\n");
- }
-
- @Override
- public String getName() {
- return "action-button";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
deleted file mode 100644
index 2466726..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.util.List;
-
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class ActionContent implements BlockContent {
- private final ObjectAction action;
- private final String[] parameters;
- private int next;
-
- public ActionContent(final ObjectAction action) {
- this.action = action;
- this.parameters = new String[action.getParameterCount()];
- }
-
- public void setParameter(final String field, final String value) {
- int index;
- if (field == null) {
- index = next++;
- } else {
- index = Integer.valueOf(field).intValue() - 1;
- }
- if (index < 0 || index >= parameters.length) {
- throw new ScimpiException("Parameter numbers should be between 1 and " + parameters.length + ": " + index);
- }
- parameters[index] = value;
- }
-
- public ObjectAdapter[] getParameters(final Request request) {
- final ObjectAdapter[] params = new ObjectAdapter[parameters.length];
- final List<ObjectActionParameter> pars = action.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- final ObjectSpecification typ = pars.get(i).getSpecification();
- if (typ.getFacet(ParseableFacet.class) != null) {
- final ParseableFacet facet = typ.getFacet(ParseableFacet.class);
- Localization localization = IsisContext.getLocalization();
- params[i] = facet.parseTextEntry(null, parameters[i], localization);
- } else {
- params[i] = request.getContext().getMappedObject(parameters[i]);
- }
- }
- return params;
- }
-
- public String[] getParameters() {
- return parameters;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
deleted file mode 100644
index 469b99d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.FormState;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FieldFactory;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FormFieldBlock;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.HiddenInputField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.HtmlFormBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class ActionForm extends AbstractElementProcessor {
-
- // REVIEW: confirm this rendering context
- private final static Where where = Where.OBJECT_FORMS;
-
- @Override
- public void process(final Request request) {
- final CreateFormParameter parameters = new CreateFormParameter();
- parameters.objectId = request.getOptionalProperty(OBJECT);
- parameters.methodName = request.getRequiredProperty(METHOD);
- parameters.forwardResultTo = request.getOptionalProperty(VIEW);
- parameters.forwardVoidTo = request.getOptionalProperty(VOID);
- parameters.forwardErrorTo = request.getOptionalProperty(ERROR);
- parameters.cancelTo = request.getOptionalProperty(CANCEL_TO);
- parameters.showIcon = request.isRequested(SHOW_ICON, showIconByDefault());
- parameters.buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
- parameters.formTitle = request.getOptionalProperty(FORM_TITLE);
- parameters.labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
- parameters.formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
- parameters.resultName = request.getOptionalProperty(RESULT_NAME);
- parameters.resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- parameters.scope = request.getOptionalProperty(SCOPE);
- parameters.className = request.getOptionalProperty(CLASS, "action full");
- parameters.showMessage = request.isRequested(SHOW_MESSAGE, false);
- parameters.completionMessage = request.getOptionalProperty(MESSAGE);
- parameters.id = request.getOptionalProperty(ID, parameters.methodName);
- createForm(request, parameters);
- }
-
- public static void createForm(final Request request, final CreateFormParameter parameterObject) {
- createForm(request, parameterObject, false);
- }
-
- protected static void createForm(final Request request, final CreateFormParameter parameterObject, final boolean withoutProcessing) {
- final RequestContext context = request.getContext();
- final ObjectAdapter object = MethodsUtils.findObject(context, parameterObject.objectId);
- final String version = request.getContext().mapVersion(object);
- final ObjectAction action = MethodsUtils.findAction(object, parameterObject.methodName);
- // TODO how do we distinguish between overloaded methods?
-
- // REVIEW Is this useful?
- if (action.getParameterCount() == 0) {
- throw new ScimpiException("Action form can only be used for actions with parameters");
- }
- if (parameterObject.showMessage && MethodsUtils.isVisible(object, action, where)) {
- final String notUsable = MethodsUtils.isUsable(object, action, where);
- if (notUsable != null) {
- if (!withoutProcessing) {
- request.skipUntilClose();
- }
- request.appendHtml("<div class=\"" + parameterObject.className + "-message\" >");
- request.appendAsHtmlEncoded(notUsable);
- request.appendHtml("</div>");
- return;
- }
- }
- if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
- if (!withoutProcessing) {
- request.skipUntilClose();
- }
- return;
- }
- final String objectId = context.mapObject(object, Scope.INTERACTION);
- final String errorView = context.fullFilePath(parameterObject.forwardErrorTo == null ? context.getResourceFile() : parameterObject.forwardErrorTo);
- final String voidView = context.fullFilePath(parameterObject.forwardVoidTo == null ? context.getResourceFile() : parameterObject.forwardVoidTo);
- if (false /* action.isContributed() && !action.hasReturn() && parameterObject.resultOverride == null */) {
- parameterObject.resultOverride = objectId;
- }
- final HiddenInputField[] hiddenFields = new HiddenInputField[] { new HiddenInputField("_" + OBJECT, objectId), new HiddenInputField("_" + VERSION, version), new HiddenInputField("_" + FORM_ID, parameterObject.formId), new HiddenInputField("_" + METHOD, parameterObject.methodName),
- parameterObject.forwardResultTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(parameterObject.forwardResultTo)), new HiddenInputField("_" + VOID, voidView), new HiddenInputField("_" + ERROR, errorView),
- parameterObject.completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, parameterObject.completionMessage), parameterObject.scope == null ? null : new HiddenInputField("_" + SCOPE, parameterObject.scope),
- parameterObject.resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, parameterObject.resultOverride), parameterObject.resultName == null ? null : new HiddenInputField("_" + RESULT_NAME, parameterObject.resultName),
- parameterObject.resultName == null ? null : new HiddenInputField(RequestContext.RESULT, (String) request.getContext().getVariable(RequestContext.RESULT)) };
-
- // TODO when the block contains a selector tag it doesn't disable it if
- // the field cannot be edited!!!
- final FormFieldBlock containedBlock = new FormFieldBlock() {
- @Override
- public boolean isNullable(final String name) {
- final int index = Integer.parseInt(name.substring(5)) - 1;
- final ObjectActionParameter param = action.getParameters().get(index);
- return param.isOptional();
- }
- };
- request.setBlockContent(containedBlock);
- if (!withoutProcessing) {
- request.processUtilCloseTag();
- }
-
- final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
-
- // TODO the list of included fields should be considered in the next
- // method (see EditObject)
- final InputField[] formFields = createFields(action, object);
- containedBlock.hideExcludedParameters(formFields);
- containedBlock.setUpValues(formFields);
- initializeFields(context, object, action, formFields);
- setDefaults(context, object, action, formFields, entryState, parameterObject.showIcon);
- String errors = null;
- if (entryState != null && entryState.isForForm(parameterObject.formId)) {
- copyEntryState(context, object, action, formFields, entryState);
- errors = entryState.getError();
- }
- overrideWithHtml(context, containedBlock, formFields);
-
- String formTitle;
- if (parameterObject.formTitle == null) {
- formTitle = action.getName();
- } else {
- formTitle = parameterObject.formTitle;
- }
-
- String buttonTitle = parameterObject.buttonTitle;
- if (buttonTitle == null) {
- buttonTitle = action.getName();
- } else if (buttonTitle.equals("")) {
- buttonTitle = "Ok";
- }
-
- HtmlFormBuilder.createForm(request, ActionAction.ACTION + ".app", hiddenFields, formFields, parameterObject.className,
- parameterObject.id, formTitle, parameterObject.labelDelimiter, action.getDescription(), action.getHelp(), buttonTitle, errors, parameterObject.cancelTo);
-
- request.popBlockContent();
- }
-
- private static InputField[] createFields(final ObjectAction action, final ObjectAdapter object) {
- final int parameterCount = action.getParameterCount();
- final InputField[] fields = new InputField[parameterCount];
- for (int i = 0; i < fields.length; i++) {
- fields[i] = new InputField(ActionAction.parameterName(i));
- }
- return fields;
- }
-
- private static void initializeFields(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) {
- final List<ObjectActionParameter> parameters = action.getParameters();
- for (int i = 0; i < fields.length; i++) {
- final InputField field = fields[i];
- final ObjectActionParameter param = parameters.get(i);
- if (false /*action.isContributed() && i == 0*/) {
- // fields[i].setValue(context.mapObject(object,
- // Scope.INTERACTION));
- fields[i].setType(InputField.REFERENCE);
- fields[i].setHidden(true);
- } else {
-
- fields[i].setHelpReference("xxxhelp");
- final ObjectAdapter[] optionsForParameter = action.getChoices(object)[i];
- FieldFactory.initializeField(context, object, param, optionsForParameter, !param.isOptional(), field);
- }
- }
- }
-
- /**
- * Sets up the fields with their initial values
- *
- * @param showIcon
- */
- private static void setDefaults(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState, final boolean showIcon) {
- final ObjectAdapter[] defaultValues = action.getDefaults(object);
- if (defaultValues == null) {
- return;
- }
-
- for (int i = 0; i < fields.length; i++) {
- final InputField field = fields[i];
- final ObjectAdapter defaultValue = defaultValues[i];
-
- final String title = defaultValue == null ? "" : defaultValue.titleString();
- if (field.getType() == InputField.REFERENCE) {
- final ObjectSpecification objectSpecification = action.getParameters().get(i).getSpecification();
- if (defaultValue != null) {
- final String imageSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
- final String html = imageSegment + title;
- final String value = context.mapObject(defaultValue, Scope.INTERACTION);
- field.setValue(value);
- field.setHtml(html);
- }
- } else {
- field.setValue(title);
- }
- }
- }
-
- private static void copyEntryState(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState) {
-
- for (final InputField field : fields) {
- final FieldEditState fieldState = entryState.getField(field.getName());
- if (fieldState != null) {
- if (field.isEditable()) {
- String entry;
- entry = fieldState.getEntry();
- field.setValue(entry);
- }
-
- field.setErrorText(fieldState.getError());
- }
- }
- }
-
- private static void overrideWithHtml(final RequestContext context, final FormFieldBlock containedBlock, final InputField[] formFields) {
- for (int i = 0; i < formFields.length; i++) {
- final String id = ActionAction.parameterName(i);
- if (containedBlock.hasContent(id)) {
- final String content = containedBlock.getContent(id);
- if (content != null) {
- formFields[i].setHtml(content);
- formFields[i].setType(InputField.HTML);
- }
- }
- }
- }
-
- @Override
- public String getName() {
- return "action-form";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
deleted file mode 100644
index 520e2bc..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.net.URLEncoder;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
-
-public class ActionLink extends AbstractElementProcessor {
-
- // REVIEW: confirm this rendering context
- private final Where where = Where.OBJECT_FORMS;
-
- @Override
- public void process(final Request request) {
- String objectId = request.getOptionalProperty(OBJECT);
- final String method = request.getOptionalProperty(METHOD);
- final String forwardResultTo = request.getOptionalProperty(VIEW);
- final String forwardVoidTo = request.getOptionalProperty(VOID);
- String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
-
- final String resultName = request.getOptionalProperty(RESULT_NAME);
- final String resultNameSegment = resultName == null ? "" : "&" + RESULT_NAME + "=" + resultName;
- final String scope = request.getOptionalProperty(SCOPE);
- final String scopeSegment = scope == null ? "" : "&" + SCOPE + "=" + scope;
- final String confirm = request.getOptionalProperty(CONFIRM);
- final String completionMessage = request.getOptionalProperty(MESSAGE);
- final String idName = request.getOptionalProperty(ID, method);
- final String className = request.getOptionalProperty(CLASS);
-
-
- // TODO need a mechanism for globally dealing with encoding; then use
- // the new encode method
- final String confirmSegment = confirm == null ? "" : "&" + "_" + CONFIRM + "=" + URLEncoder.encode(confirm);
- final String messageSegment = completionMessage == null ? "" : "&" + "_" + MESSAGE + "=" + URLEncoder.encode(completionMessage);
-
- final RequestContext context = request.getContext();
- final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
- final String version = context.mapVersion(object);
- final ObjectAction action = MethodsUtils.findAction(object, method);
-
- final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String text = request.popBuffer();
-
- final String[] parameters = parameterBlock.getParameters();
- final String target;
- /*
- if (action.isContributed()) {
- System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
- parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
- target = request.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
- if (!action.hasReturn() && resultOverride == null) {
- resultOverride = parameters[0];
- }
- } else {
- target = StringEscapeUtils.escapeHtml(request.getContext().mapObject(object, Scope.INTERACTION));
- }
- */
-
- final ObjectAdapter[] objectParameters;
-
- // TODO copied from ActionButton
- //final ObjectAdapter target;
- if (false /*action.isContributed() */) {
-// objectParameters= null;
-// System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
-// parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
-// target = request.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
-// if (!action.hasReturn() && resultOverride == null) {
-// resultOverride = parameters[0];
-// }
- } else {
- objectParameters = new ObjectAdapter[parameters.length];
- // target = object;
- target = StringEscapeUtils.escapeHtml(request.getContext().mapObject(object, Scope.INTERACTION));
- int i = 0;
- for (final ObjectActionParameter spec : action.getParameters()) {
- final ObjectSpecification type = spec.getSpecification();
- if (parameters[i] == null) {
- objectParameters[i] = null;
- } else if (type.getFacet(ParseableFacet.class) != null) {
- final ParseableFacet facet = type.getFacet(ParseableFacet.class);
- Localization localization = IsisContext.getLocalization();
- objectParameters[i] = facet.parseTextEntry(null, parameters[i], localization);
- } else {
- objectParameters[i] = MethodsUtils.findObject(request.getContext(), parameters[i]);
- }
- i++;
- }
- }
-
- if (MethodsUtils.isVisibleAndUsable(object, action, where) && MethodsUtils.canRunMethod(object, action, objectParameters).isAllowed()) {
- writeLink(request, idName, className, target, version, method, forwardResultTo, forwardVoidTo, resultNameSegment, resultOverride, scopeSegment,
- confirmSegment, messageSegment, context, action, parameters, text);
- }
- request.popBlockContent();
- }
-
- public static void writeLink(
- final Request request,
- final String idName,
- final String className,
- final String objectId,
- final String version,
- final String method,
- final String forwardResultTo,
- final String forwardVoidTo,
- final String resultNameSegment,
- final String resultOverride,
- final String scopeSegment,
- final String confirmSegment,
- final String messageSegment,
- final RequestContext context,
- final ObjectAction action,
- final String[] parameters,
- String text) {
- text = text == null || text.trim().equals("") ? action.getName() : text;
-
- String parameterSegment = "";
- for (int i = 0; i < parameters.length; i++) {
- parameterSegment += "¶m" + (i + 1) + "=" + parameters[i];
- }
-
- final String idSegment = idName == null ? "" : ("id=\"" + idName + "\" ");
- final String classSegment = "class=\"" + (className == null ? "action in-line" : className) + "\"";
- final String interactionParamters = context.encodedInteractionParameters();
- final String forwardResultSegment = forwardResultTo == null ? "" : "&" + "_" + VIEW + "=" + context.fullFilePath(forwardResultTo);
- final String resultOverrideSegment = resultOverride == null ? "" : "&" + "_" + RESULT_OVERRIDE + "=" + resultOverride;
- final String voidView = context.fullFilePath(forwardVoidTo == null ? context.getResourceFile() : forwardVoidTo);
- final String forwardVoidSegment = "&" + "_" + VOID + "=" + voidView;
- request.appendHtml("<a " + idSegment + classSegment + " href=\"action.app?" + "_" + OBJECT + "=" + objectId + "&" + "_" + VERSION + "=" + version
- + "&" + "_" + METHOD + "=" + method + resultOverrideSegment + forwardResultSegment + forwardVoidSegment + resultNameSegment
- + parameterSegment + scopeSegment + confirmSegment + messageSegment + interactionParamters + "\">");
- request.appendHtml(text);
- request.appendHtml("</a>");
- HelpLink.append(request, action.getDescription(), action.getHelp());
- }
-
- @Override
- public String getName() {
- return "action-link";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java
deleted file mode 100644
index 2628449..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-public class CreateFormParameter {
- public String methodName;
- public String forwardResultTo;
- public String forwardVoidTo;
- public String forwardErrorTo;
- public String buttonTitle;
- public String formTitle;
- public String formId;
- public String resultName;
- public String scope;
- public String objectId;
- public String description;
- public String helpReference;
- public String className;
- public String id;
- public String resultOverride;
- public boolean showMessage;
- public boolean showIcon;
- public String completionMessage;
- public String cancelTo;
- public String labelDelimiter;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
deleted file mode 100644
index 21cff4e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.filter.Filters;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-
-public class Methods extends AbstractElementProcessor {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final static Where where = Where.ANYWHERE;
-
- @Override
- public void process(final Request request) {
- String objectId = request.getOptionalProperty(OBJECT);
- final String view = request.getOptionalProperty(VIEW, "_generic_action." + Dispatcher.EXTENSION);
- final String cancelTo = request.getOptionalProperty(CANCEL_TO);
- final boolean showForms = request.isRequested(FORMS, false);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
- if (objectId == null) {
- objectId = request.getContext().mapObject(object, null);
- }
-
- final InclusionList inclusionList = new InclusionList();
- request.setBlockContent(inclusionList);
- request.processUtilCloseTag();
-
- request.appendHtml("<div class=\"actions\">");
- if (inclusionList.includes("edit") && !object.getSpecification().isService()) {
- request.appendHtml("<div class=\"action\">");
- request.appendHtml("<a class=\"button\" href=\"_generic_edit." + Dispatcher.EXTENSION + "?_result=" + objectId + "\">Edit...</a>");
- request.appendHtml("</div>");
- }
- writeMethods(request, objectId, object, showForms, inclusionList, view, "_generic.shtml?_result=" + objectId);
- request.popBlockContent();
- request.appendHtml("</div>");
- }
-
- public static void writeMethods(
- final Request request,
- final String objectId,
- final ObjectAdapter adapter,
- final boolean showForms,
- final InclusionList inclusionList,
- final String view,
- final String cancelTo) {
- List<ObjectAction> actions = adapter.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- // TODO determine if system is set up to display exploration methods
- if (true) {
- actions = adapter.getSpecification().getObjectActions(ActionType.EXPLORATION, Contributed.INCLUDED, Filters.<ObjectAction>any());
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- }
- // TODO determine if system is set up to display debug methods
- if (true) {
- actions = adapter.getSpecification().getObjectActions(ActionType.DEBUG, Contributed.INCLUDED, Filters.<ObjectAction>any());
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- }
- }
-
- private static void writeMethods(
- final Request request,
- final ObjectAdapter adapter,
- List<ObjectAction> actions,
- final String objectId,
- final boolean showForms,
- final InclusionList inclusionList,
- final String view,
- final String cancelTo) {
- actions = inclusionList.includedActions(actions);
- for (int j = 0; j < actions.size(); j++) {
- final ObjectAction action = actions.get(j);
- if (false /* action instanceof ObjectActionSet */) {
-// request.appendHtml("<div class=\"actions\">");
-// writeMethods(request, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
-// request.appendHtml("</div>");
- } else if (false /*action.isContributed()*/) {
-// if (action.getParameterCount() == 1 && adapter.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
-// if (objectId != null) {
-// final ObjectAdapter target = request.getContext().getMappedObject(objectId);
-// final ObjectAdapter realTarget = action.realTarget(target);
-// final String realTargetId = request.getContext().mapObject(realTarget, Scope.INTERACTION);
-// writeMethod(request, adapter, new String[] { objectId }, action, realTargetId, showForms, view, cancelTo);
-// } else {
-// request.appendHtml("<div class=\"action\">");
-// request.appendAsHtmlEncoded(action.getName());
-// request.appendHtml("???</div>");
-// }
-// } else if (!adapter.getSpecification().isService()) {
-// writeMethod(request, adapter, new String[0], action, objectId, showForms, view, cancelTo);
-// }
- } else {
- writeMethod(request, adapter, new String[0], action, objectId, showForms, view, cancelTo);
- }
- }
- }
-
- private static void writeMethod(
- final Request request,
- final ObjectAdapter adapter,
- final String[] parameters,
- final ObjectAction action,
- final String objectId,
- final boolean showForms,
- final String view,
- final String cancelTo) {
- // if (action.isVisible(IsisContext.getSession(), null) &&
- // action.isVisible(IsisContext.getSession(), adapter))
- // {
- if (action.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isAllowed()) {
- request.appendHtml("<div class=\"action\">");
- if (IsisContext.getSession() == null) {
- request.appendHtml("<span class=\"disabled\" title=\"no user logged in\">");
- request.appendAsHtmlEncoded(action.getName());
- request.appendHtml("</span>");
- /*
- * } else if (action.isUsable(IsisContext.getSession(),
- * null).isVetoed()) {
- * request.appendHtml("<span class=\"disabled\" title=\"" +
- * action.isUsable(IsisContext.getSession(), null).getReason() +
- * "\">"); request.appendHtml(action.getName());
- * request.appendHtml("</span>");
- */} else if (action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
- request.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).getReason() + "\">");
- request.appendAsHtmlEncoded(action.getName());
- request.appendHtml("</span>");
- } else {
- final String version = request.getContext().mapVersion(adapter);
- if (action.getParameterCount() == 0 || (false /*action.isContributed() && action.getParameterCount() == 1*/ )) {
- ActionButton.write(request, adapter, action, parameters, version, "_generic." + Dispatcher.EXTENSION, null, null, null, null, null, null, null, null, null);
- } else if (showForms) {
- final CreateFormParameter params = new CreateFormParameter();
- params.objectId = objectId;
- params.methodName = action.getId();
- params.forwardResultTo = "_generic." + Dispatcher.EXTENSION;
- params.buttonTitle = "OK";
- params.formTitle = action.getName();
- ActionForm.createForm(request, params, true);
- } else {
- request.appendHtml("<a class=\"button\" href=\"" + view + "?_result=" + objectId + "&_" + VERSION + "=" + version + "&_" + METHOD + "=" + action.getId());
- if (cancelTo != null) {
- request.appendHtml("&_cancel-to=");
- request.appendAsHtmlEncoded("cancel-to=\"" + cancelTo + "\"");
- }
- request.appendHtml("\" title=\"" + action.getDescription() + "\">");
- request.appendAsHtmlEncoded(action.getName() + "...");
- request.appendHtml("</a>");
- }
- }
- request.appendHtml("</div>");
- }
- }
-
- @Override
- public String getName() {
- return "methods";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
deleted file mode 100644
index 69be5c5..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class Parameter extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final BlockContent blockContent = request.getBlockContent();
- if (!(blockContent instanceof ActionContent)) {
- throw new TagOrderException(request);
- }
-
- final String field = request.getOptionalProperty(PARAMETER_NUMBER);
- final String value = request.getRequiredProperty(VALUE);
- final ActionContent block = (ActionContent) blockContent;
- block.setParameter(field, value);
- }
-
- @Override
- public String getName() {
- return "parameter";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
deleted file mode 100644
index 9610457..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-
-public class RunAction extends AbstractElementProcessor {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final Where where = Where.ANYWHERE;
-
- @Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
-
- final String objectId = request.getOptionalProperty(OBJECT);
- final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
-
- final String methodName = request.getRequiredProperty(METHOD);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
-
- final String variableName = request.getOptionalProperty(RESULT_NAME);
- final String scopeName = request.getOptionalProperty(SCOPE);
-
- final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.processUtilCloseTag();
- final ObjectAdapter[] parameters = parameterBlock.getParameters(request);
-
- if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
- throw new ForbiddenException(action, ForbiddenException.VISIBLE_AND_USABLE);
- }
-
- // swap null parameter of the object's type to run a contributed method
- if (false /*action.isContributed()*/) {
- final List<ObjectActionParameter> parameterSpecs = action.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- if (parameters[i] == null && object.getSpecification().isOfType(parameterSpecs.get(i).getSpecification())) {
- parameters[i] = object;
- break;
- }
- }
- }
-
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
- MethodsUtils.runMethod(context, action, object, parameters, variableName, scope);
- request.popBlockContent();
- }
-
- @Override
- public String getName() {
- return "run-action";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
deleted file mode 100644
index 2a621f1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-
-public class Services extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final boolean showForms = request.isRequested(FORMS, false);
- final String view = request.getOptionalProperty(VIEW, "_generic_action." + Dispatcher.EXTENSION);
- final String cancelTo = request.getOptionalProperty(CANCEL_TO);
-
- final InclusionList inclusionList = new InclusionList();
- request.setBlockContent(inclusionList);
- request.processUtilCloseTag();
-
- final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
- for (final ObjectAdapter adapter : serviceAdapters) {
- final String serviceId = request.getContext().mapObject(adapter, Scope.REQUEST);
- request.appendHtml("<div class=\"actions\">");
- request.appendHtml("<h3>");
- request.appendAsHtmlEncoded(adapter.titleString());
- request.appendHtml("</h3>");
- Methods.writeMethods(request, serviceId, adapter, showForms, inclusionList, view, cancelTo);
- request.appendHtml("</div>");
- }
- request.popBlockContent();
- }
-
- @Override
- public String getName() {
- return "services";
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
deleted file mode 100644
index 1002c9f..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.scimpi.dispatcher.view.collection;
-
-import java.util.Iterator;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
-
-public class Collection extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
-
- ObjectAdapter collection;
-
- final String field = request.getOptionalProperty(FIELD);
- if (field != null) {
- final String id = request.getOptionalProperty(OBJECT);
- final ObjectAdapter object = context.getMappedObjectOrResult(id);
- final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
- if (!objectField.isOneToManyAssociation()) {
- throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
- }
- ResolveFieldUtil.resolveField(object, objectField);
- collection = objectField.get(object);
- } else {
- final String id = request.getOptionalProperty(COLLECTION);
- collection = context.getMappedObjectOrResult(id);
- }
-
- final RepeatMarker marker = request.createMarker();
-
- final String variable = request.getOptionalProperty(ELEMENT_NAME);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
- final String rowClassesList = request.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
- String[] rowClasses = new String[0];
- if (rowClassesList != null) {
- rowClasses = rowClassesList.split("[,|/]");
- }
-
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- if (facet.size(collection) == 0) {
- request.skipUntilClose();
- } else {
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- int row = 0;
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- context.addVariable("row", "" + (row + 1), Scope.REQUEST);
- if (rowClassesList != null) {
- context.addVariable("row-class", rowClasses[row % rowClasses.length], Scope.REQUEST);
- }
- context.addVariable(variable, context.mapObject(element, scope), scope);
- marker.repeat();
- request.processUtilCloseTag();
- row++;
- }
- }
- }
-
- @Override
- public String getName() {
- return COLLECTION;
- }
-
-}