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 2016/05/21 07:10:16 UTC
[15/56] [abbrv] [partial] isis git commit: ISIS-1335: deleting the
mothballed directory.
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionContent.java
deleted file mode 100644
index 6dd01b4..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionContent.java
+++ /dev/null
@@ -1,41 +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.dnd.view.action;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.viewer.dnd.view.Content;
-
-public interface ActionContent extends Content {
- public Consent disabled();
-
- public ObjectAdapter execute();
-
- public String getActionName();
-
- public int getNoParameters();
-
- public ParameterContent getParameterContent(final int index);
-
- public ObjectAdapter getParameterObject(final int index);
-
- @Override
- public String getDescription();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionHelper.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionHelper.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionHelper.java
deleted file mode 100644
index e82c631..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ActionHelper.java
+++ /dev/null
@@ -1,169 +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.dnd.view.action;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-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.metamodel.spec.feature.OneToOneActionParameter;
-import org.apache.isis.core.metamodel.spec.feature.ParseableEntryActionParameter;
-
-public class ActionHelper {
-
- public static ActionHelper createInstance(final ObjectAdapter target, final ObjectAction action) {
- final int numberParameters = action.getParameterCount();
- final ObjectAdapter[] parameters = new ObjectAdapter[numberParameters];
- final List<ObjectActionParameter> parameterSpecs = action.getParameters();
- ObjectAdapter[] defaultValues;
- ObjectAdapter[][] options;
-
- // action choices most be old or new syntax - cannot be mixed
-
- defaultValues = new ObjectAdapter[parameterSpecs.size()];
- options = new ObjectAdapter[parameterSpecs.size()][];
-
- for (int i = 0; i < parameterSpecs.size(); i++) {
- defaultValues[i] = parameterSpecs.get(i).getDefault(target);
- options[i] = parameterSpecs.get(i).getChoices(target, null);
- }
-
- if (!hasValues(defaultValues) && !hasValues(options)) {
- // fall back to old method
-
- defaultValues = action.getDefaults(target);
- options = action.getChoices(target);
- }
-
- for (int i = 0; i < parameterSpecs.size(); i++) {
- if (defaultValues[i] != null) {
- parameters[i] = defaultValues[i];
- } else {
- parameters[i] = null; // PersistorUtil.createValueInstance(noap.getSpecification());
- }
- }
-
- /*
- * int[] maxLength = action.getParameterMaxLengths(); int[]
- * typicalLength = action.getParameterTypicalLengths(); int[] noLines =
- * action.getParameterNoLines(); boolean[] canWrap =
- * action.canParametersWrap();
- */
- return new ActionHelper(target, action, parameters, defaultValues, options);
- }
-
- private final ObjectAction action;
- private final ObjectAdapter[] parameters;
- private final ObjectAdapter target;
- private final ObjectAdapter[][] options;
-
- private ActionHelper(final ObjectAdapter target, final ObjectAction action, final ObjectAdapter[] parameters, final ObjectAdapter[] defaultValues, final ObjectAdapter[][] options) {
- this.target = target;
- this.action = action;
- this.parameters = parameters;
- this.options = options;
- }
-
- public ParameterContent[] createParameters() {
- final ParameterContent[] parameterContents = new ParameterContent[parameters.length];
- for (int i = 0; i < parameters.length; i++) {
- final List<ObjectActionParameter> parameters2 = action.getParameters();
- final ObjectAdapter adapter = parameters[i];
- final ObjectSpecification specification = parameters2.get(i).getSpecification();
- if (specification.isParseable()) {
- final ParseableEntryActionParameter parseableEntryActionParameter = (ParseableEntryActionParameter) parameters2.get(i);
- parameterContents[i] = new TextParseableParameterImpl(parseableEntryActionParameter, adapter, options[i], i, this);
- } else {
- parameterContents[i] = new ObjectParameterImpl((OneToOneActionParameter) parameters2.get(i), adapter, options[i], i, this);
- }
- }
-
- return parameterContents;
- }
-
- public Consent disabled() {
- // REVIEW this is no good as it lumps all the parameters together; I
- // need to know which parameter is
- // disabled!
- return action.isProposedArgumentSetValid(target, parameters);
- }
-
- public String getName() {
- return action.getName();
- }
-
- public String getDescription() {
- return action.getDescription();
- }
-
- public String getHelp() {
- return action.getHelp();
- }
-
- public ObjectAdapter getParameter(final int index) {
- return parameters[index];
- }
-
- public ObjectAdapter getTarget() {
- return target;
- //return action.realTarget(target);
- }
-
- public ObjectAdapter invoke() {
- return action.execute(target, parameters);
- }
-
- public void setParameter(final int index, final ObjectAdapter parameter) {
- this.parameters[index] = parameter;
- }
-
- public String title() {
- return getTarget().titleString();
- }
-
- public String getIconName() {
- return getTarget().getIconName();
- }
-
- private static boolean hasValues(final ObjectAdapter[] values) {
- if (values != null) {
- for (final ObjectAdapter adapter : values) {
- if (adapter != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- private static boolean hasValues(final ObjectAdapter[][] values) {
- if (values != null) {
- for (final ObjectAdapter[] adapters : values) {
- if (hasValues(adapters)) {
- return true;
- }
- }
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/BackgroundWork.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/BackgroundWork.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/BackgroundWork.java
deleted file mode 100644
index ab47a4d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/BackgroundWork.java
+++ /dev/null
@@ -1,82 +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.dnd.view.action;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.exceptions.IsisApplicationException;
-import org.apache.isis.viewer.dnd.view.BackgroundTask;
-import org.apache.isis.viewer.dnd.view.View;
-
-public final class BackgroundWork {
- private static final Logger LOG = LoggerFactory.getLogger(BackgroundTask.class);
-
- private static class BackgroundThread extends Thread {
- private final View view;
- private final BackgroundTask task;
-
- public BackgroundThread(final View view, final BackgroundTask task) {
- super("nof-background");
- this.view = view;
- this.task = task;
- LOG.debug("creating background thread for task " + task);
- }
-
- @Override
- public void run() {
- try {
- view.getState().setActive();
- view.getFeedbackManager().setBusy(view, task);
- scheduleRepaint(view);
-
- LOG.debug("running background thread for task " + task);
- task.execute();
-
- } catch (final Throwable e) {
- if (!(e instanceof IsisApplicationException)) {
- final String message = "Error while running background task " + task.getName();
- LOG.error(message, e);
- }
- view.getFeedbackManager().showException(e);
-
- } finally {
- view.getState().setInactive();
- view.getFeedbackManager().clearBusy(view);
- scheduleRepaint(view);
- }
- }
-
- private static void scheduleRepaint(final View view) {
- view.markDamaged();
- view.getViewManager().scheduleRepaint();
- }
-
- }
-
- public static void runTaskInBackground(final View view, final BackgroundTask task) {
- final Thread t = new BackgroundThread(view, task);
- t.start();
- }
-
- private BackgroundWork() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/CollectionActionContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/CollectionActionContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/CollectionActionContent.java
deleted file mode 100644
index bce8242..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/CollectionActionContent.java
+++ /dev/null
@@ -1,145 +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.dnd.view.action;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.collection.AbstractCollectionContent;
-
-public class CollectionActionContent extends AbstractCollectionContent implements ActionContent {
- private final ActionHelper invocation;
- private final ParameterContent[] parameters;
-
- public CollectionActionContent(final ActionHelper invocation) {
- this.invocation = invocation;
- parameters = invocation.createParameters();
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("action", getActionName());
- debug.appendln("target", getAdapter());
- String parameterSet = "";
- for (final ParameterContent parameter : parameters) {
- parameterSet += parameter;
- }
- debug.appendln("parameters", parameterSet);
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public Consent disabled() {
- return invocation.disabled();
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- throw new NotYetImplementedException();
- }
-
- @Override
- public ObjectAdapter[] elements() {
- throw new NotYetImplementedException();
- }
-
- @Override
- public ObjectAdapter execute() {
- return invocation.invoke();
- }
-
- @Override
- public String getActionName() {
- return invocation.getName();
- }
-
- @Override
- public ObjectAdapter getCollection() {
- return invocation.getTarget();
- }
-
- @Override
- public String getDescription() {
- return invocation.getDescription();
- }
-
- @Override
- public String getHelp() {
- return invocation.getHelp();
- }
-
- @Override
- public String getIconName() {
- return getAdapter().getIconName();
- }
-
- @Override
- public String getId() {
- return invocation.getName();
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return invocation.getTarget();
- }
-
- @Override
- public int getNoParameters() {
- return parameters.length;
- }
-
- @Override
- public ParameterContent getParameterContent(final int index) {
- return parameters[index];
- }
-
- @Override
- public ObjectAdapter getParameterObject(final int index) {
- return invocation.getParameter(index);
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return getAdapter().getSpecification();
- }
-
- @Override
- public boolean isTransient() {
- return true;
- }
-
- @Override
- public String title() {
- return getAdapter().titleString();
- }
-
- @Override
- public String windowTitle() {
- return getActionName();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/DialoggedObjectOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/DialoggedObjectOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/DialoggedObjectOption.java
deleted file mode 100644
index cf98ad4..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/DialoggedObjectOption.java
+++ /dev/null
@@ -1,94 +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.dnd.view.action;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.BackgroundTask;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Placement;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-/**
- * Options for an underlying object determined dynamically by looking for
- * methods starting with action, veto and option for specifying the action,
- * vetoing the option and giving the option an name respectively.
- */
-public class DialoggedObjectOption extends AbstractObjectOption {
-
- // 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;
-
- public static DialoggedObjectOption createOption(final ObjectAction action, final ObjectAdapter object) {
- final int paramCount = action.getParameterCount();
- Assert.assertTrue("Only for actions taking one or more params", paramCount > 0);
- if (!action.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() || !action.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
- return null;
- }
-
- final DialoggedObjectOption option = new DialoggedObjectOption(action, object);
- return option;
- }
-
- private DialoggedObjectOption(final ObjectAction action, final ObjectAdapter target) {
- super(action, target, action.getName() + "...");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- BackgroundWork.runTaskInBackground(view, new BackgroundTask() {
- @Override
- public void execute() {
- final ActionHelper helper = ActionHelper.createInstance(target, action);
- Content content;
- if (target == null && action.getOnType().isService() || target != null && target.getSpecification().isNotCollection()) {
- content = new ObjectActionContent(helper);
- } else if (target.getSpecification().isParentedOrFreeCollection()) {
- content = new CollectionActionContent(helper);
- } else {
- throw new UnknownTypeException(target);
- }
- final View dialog = Toolkit.getViewFactory().createDialog(content);
- workspace.addDialog(dialog, new Placement(view));
- }
-
- @Override
- public String getDescription() {
- return "Preparing action " + getName() + " on " + view.getContent().getAdapter();
- }
-
- @Override
- public String getName() {
- return "Preparing action " + action.getName();
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ImmediateObjectOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ImmediateObjectOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ImmediateObjectOption.java
deleted file mode 100644
index 6ad233a..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ImmediateObjectOption.java
+++ /dev/null
@@ -1,100 +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.dnd.view.action;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.BackgroundTask;
-import org.apache.isis.viewer.dnd.view.Placement;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-/**
- * Options for an underlying object determined dynamically by looking for
- * methods starting with action, veto and option for specifying the action,
- * vetoing the option and giving the option an name respectively.
- */
-public class ImmediateObjectOption extends AbstractObjectOption {
-
- // 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;
-
- public static ImmediateObjectOption createOption(final ObjectAction action, final ObjectAdapter object) {
- Assert.assertTrue("Only suitable for 0 param methods", action.getParameterCount() == 0);
- if (!action.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
- return null;
- }
- final ImmediateObjectOption option = new ImmediateObjectOption(action, object);
- return option;
- }
-
- public static ImmediateObjectOption createServiceOption(final ObjectAction action, final ObjectAdapter object) {
- Assert.assertTrue("Only suitable for 1 param methods", action.getParameterCount() == 1);
- if (!action.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
- return null;
- }
- final ImmediateObjectOption option = new ImmediateObjectOption(action, object);
-
- return option;
- }
-
- private ImmediateObjectOption(final ObjectAction action, final ObjectAdapter target) {
- super(action, target, action.getName());
- }
-
- @Override
- protected Consent checkValid() {
- return action.isProposedArgumentSetValid(target, null);
- }
-
- // TODO this method is very similar to ActionDialogSpecification.execute()
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- BackgroundWork.runTaskInBackground(view, new BackgroundTask() {
- @Override
- public void execute() {
- ObjectAdapter result;
- result = action.execute(target, null);
- view.objectActionResult(result, new Placement(view));
- view.getViewManager().disposeUnneededViews();
- view.getFeedbackManager().showMessagesAndWarnings();
- }
-
- @Override
- public String getDescription() {
- return "Running action " + getName() + " on " + view.getContent().getAdapter();
- }
-
- @Override
- public String getName() {
- return "ObjectAction " + action.getName();
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectActionContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectActionContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectActionContent.java
deleted file mode 100644
index 42cd0f8..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectActionContent.java
+++ /dev/null
@@ -1,176 +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.dnd.view.action;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.viewer.dnd.view.content.AbstractObjectContent;
-
-/**
- * Links an action on an object to a view.
- */
-public class ObjectActionContent extends AbstractObjectContent implements ActionContent {
- private final ActionHelper actionHelper;
- private final ParameterContent[] parameters;
-
- public ObjectActionContent(final ActionHelper invocation) {
- this.actionHelper = invocation;
- parameters = invocation.createParameters();
- }
-
- @Override
- public Consent canClear() {
- return Veto.DEFAULT;
- }
-
- @Override
- public Consent canSet(final ObjectAdapter dragSource) {
- return Veto.DEFAULT;
- }
-
- @Override
- public void clear() {
- throw new IsisException("Invalid call");
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("action", getActionName());
- debug.appendln("target", getAdapter());
- String parameterSet = "";
- for (final ParameterContent parameter : parameters) {
- parameterSet += parameter;
- }
- debug.appendln("parameters", parameterSet);
- }
-
- @Override
- public Consent disabled() {
- return actionHelper.disabled();
- }
-
- @Override
- public ObjectAdapter execute() {
- return actionHelper.invoke();
- }
-
- @Override
- public String getActionName() {
- return actionHelper.getName();
- }
-
- @Override
- public String getIconName() {
- return actionHelper.getIconName();
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return actionHelper.getTarget();
- }
-
- @Override
- public int getNoParameters() {
- return parameters.length;
- }
-
- @Override
- public ObjectAdapter getObject() {
- return actionHelper.getTarget();
- }
-
- @Override
- public ParameterContent getParameterContent(final int index) {
- return parameters[index];
- }
-
- @Override
- public ObjectAdapter getParameterObject(final int index) {
- return actionHelper.getParameter(index);
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return getObject().getSpecification();
- }
-
- /**
- * Can't persist actions
- */
- @Override
- public boolean isPersistable() {
- return false;
- }
-
- @Override
- public boolean isObject() {
- return true;
- }
-
- @Override
- public boolean isTransient() {
- return true;
- }
-
- @Override
- public void setObject(final ObjectAdapter object) {
- throw new IsisException("Invalid call");
- }
-
- @Override
- public String title() {
- return actionHelper.title();
- }
-
- @Override
- public String windowTitle() {
- return getActionName();
- }
-
- @Override
- public String getId() {
- return actionHelper.getName();
- }
-
- @Override
- public String getDescription() {
- return actionHelper.getDescription();
- }
-
- @Override
- public String getHelp() {
- return actionHelper.getHelp();
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return null;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameter.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameter.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameter.java
deleted file mode 100644
index 9ebdf00..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameter.java
+++ /dev/null
@@ -1,31 +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.dnd.view.action;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-
-public interface ObjectParameter extends ParameterContent {
-
- Consent canSet(final ObjectAdapter dragSource);
-
- void setObject(final ObjectAdapter object);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameterImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameterImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameterImpl.java
deleted file mode 100644
index e1e40a7..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ObjectParameterImpl.java
+++ /dev/null
@@ -1,197 +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.dnd.view.action;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Allow;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneActionParameter;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.content.AbstractObjectContent;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-public class ObjectParameterImpl extends AbstractObjectContent implements ObjectParameter {
- private final ObjectAdapter adapter;
- private final ActionHelper invocation;
- private final int index;
- private final ObjectAdapter[] optionAdapters;
- private final OneToOneActionParameter objectActionParameter;
-
- public ObjectParameterImpl(final OneToOneActionParameter objectActionParameter, final ObjectAdapter adapter, final ObjectAdapter[] optionAdapters, final int i, final ActionHelper invocation) {
- this.objectActionParameter = objectActionParameter;
- this.optionAdapters = optionAdapters;
- this.index = i;
- this.invocation = invocation;
- this.adapter = adapter;
- }
-
- public ObjectParameterImpl(final ObjectParameterImpl content, final ObjectAdapter object) {
- objectActionParameter = content.objectActionParameter;
- optionAdapters = content.optionAdapters;
- index = content.index;
- invocation = content.invocation;
- this.adapter = object;
- }
-
- @Override
- public Consent canClear() {
- return Allow.DEFAULT;
- }
-
- @Override
- public Consent canSet(final ObjectAdapter dragSource) {
- if (dragSource.getSpecification().isOfType(getSpecification())) {
- // TODO: move logic into Facet
- return Allow.DEFAULT;
- } else {
- // TODO: move logic into Facet
- return new Veto(String.format("Object must be ", getSpecification().getShortIdentifier()));
- }
- }
-
- @Override
- public void clear() {
- setObject(null);
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("name", getParameterName());
- debug.appendln("required", isRequired());
- debug.appendln("object", adapter);
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return adapter;
- }
-
- @Override
- public ObjectAdapter getObject() {
- return adapter;
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return optionAdapters;
- }
-
- @Override
- public boolean isObject() {
- return true;
- }
-
- @Override
- public boolean isRequired() {
- return !objectActionParameter.isOptional();
- }
-
- @Override
- public boolean isPersistable() {
- return false;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return optionAdapters != null && optionAdapters.length > 0;
- }
-
- @Override
- public boolean isTransient() {
- return adapter != null && adapter.isTransient();
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- if (adapter != null) {
- options.add(new UserActionAbstract("Clear parameter") {
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- clear();
- view.getParent().invalidateContent();
- }
- });
-
- OptionFactory.addObjectMenuOptions(adapter, options);
- } else {
- OptionFactory.addCreateOptions(getSpecification(), options);
-
- }
-
- }
-
- @Override
- public void setObject(final ObjectAdapter object) {
- invocation.setParameter(index, object);
- }
-
- @Override
- public String title() {
- return adapter == null ? "" : adapter.titleString();
- }
-
- @Override
- public String toString() {
- final ToString toString = new ToString(this);
- toString.append("label", getParameterName());
- toString.append("required", isRequired());
- toString.append("spec", getSpecification().getFullIdentifier());
- toString.append("object", adapter == null ? "null" : adapter.titleString());
- return toString.toString();
- }
-
- @Override
- public String getParameterName() {
- return objectActionParameter.getName();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return objectActionParameter.getSpecification();
- }
-
- @Override
- public String getDescription() {
- final String title = adapter == null ? "" : ": " + adapter.titleString();
- final String name = getParameterName();
- final ObjectSpecification specification = objectActionParameter.getSpecification();
- final String specName = specification.getShortIdentifier();
- final String type = name.indexOf(specName) == -1 ? " (" + specName + ")" : "";
- return name + type + title + " " + objectActionParameter.getDescription();
- }
-
- @Override
- public String getHelp() {
- return invocation.getHelp();
- }
-
- @Override
- public String getId() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/OptionFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/OptionFactory.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/OptionFactory.java
deleted file mode 100644
index 55c9e56..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/OptionFactory.java
+++ /dev/null
@@ -1,84 +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.dnd.view.action;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.FreeStandingList;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.viewer.dnd.view.UserAction;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.option.DisposeObjectOption;
-
-public class OptionFactory {
-
- public static void addCreateOptions(final ObjectSpecification specification, final UserActionSet options) {
- // TODO do the same as addObjectMenuOptions and collect together all the
- // actions for all the types
- final List<ObjectAction> actions = specification.getServiceActionsReturning(ActionType.ALL);
- menuOptions(actions, null, options);
- }
-
- public static void addObjectMenuOptions(final ObjectAdapter adapter, final UserActionSet options) {
- if (adapter == null) {
- return;
- }
-
- final ObjectSpecification noSpec = adapter.getSpecification();
- menuOptions(noSpec.getObjectActions(Contributed.INCLUDED), adapter, options);
-
- // TODO: this looks like a bit of a hack; can we improve it by looking
- // at the facets?
- if (adapter.getObject() instanceof FreeStandingList) {
- return;
- }
- final Oid oid = adapter.getOid();
- if (oid != null && adapter.isTransient()) {
- return;
- }
- if (noSpec.isService()) {
- return;
- }
-
- options.add(new DisposeObjectOption());
- }
-
- private static void menuOptions(final List<ObjectAction> actions, final ObjectAdapter target, final UserActionSet menuOptionSet) {
- for (int i = 0; i < actions.size(); i++) {
- final UserAction option;
- final int noOfParameters = actions.get(i).getParameterCount();
- if (noOfParameters == 0) {
- option = ImmediateObjectOption.createOption(actions.get(i), target);
- } else if (false /*actions.get(i).isContributed() && noOfParameters == 1 && target != null && target.getSpecification().isOfType(actions.get(i).getParameters().get(0).getSpecification())*/) {
- option = ImmediateObjectOption.createServiceOption(actions.get(i), target);
- } else {
- option = DialoggedObjectOption.createOption(actions.get(i), target);
- }
- if (option != null) {
- menuOptionSet.add(option);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ParameterContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ParameterContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ParameterContent.java
deleted file mode 100644
index 11d02b0..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/ParameterContent.java
+++ /dev/null
@@ -1,29 +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.dnd.view.action;
-
-import org.apache.isis.viewer.dnd.view.Content;
-
-public interface ParameterContent extends Content {
-
- String getParameterName();
-
- boolean isRequired();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameter.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameter.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameter.java
deleted file mode 100644
index 3834146..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameter.java
+++ /dev/null
@@ -1,26 +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.dnd.view.action;
-
-import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
-
-public interface TextParseableParameter extends ParameterContent, TextParseableContent {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameterImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameterImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameterImpl.java
deleted file mode 100644
index 4bfe9bf..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/action/TextParseableParameterImpl.java
+++ /dev/null
@@ -1,228 +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.dnd.view.action;
-
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.util.AdapterUtils;
-import org.apache.isis.core.metamodel.consent.Allow;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.facets.object.parseable.InvalidEntryException;
-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.ParseableEntryActionParameter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.content.AbstractTextParsableContent;
-
-public class TextParseableParameterImpl extends AbstractTextParsableContent implements TextParseableParameter {
- private ObjectAdapter object;
- private final ObjectAdapter[] options;
- private final ParseableEntryActionParameter parameter;
- private final ActionHelper invocation;
- private final int index;
-
- public TextParseableParameterImpl(final ParseableEntryActionParameter objectActionParameters, final ObjectAdapter adapter, final ObjectAdapter[] options, final int i, final ActionHelper invocation) {
- this.parameter = objectActionParameters;
- this.options = options;
- index = i;
- this.invocation = invocation;
- object = adapter;
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("name", parameter.getName());
- debug.appendln("required", isRequired());
- debug.appendln("object", object);
- }
-
- @Override
- public void entryComplete() {
- }
-
- @Override
- public String getIconName() {
- return "";
- }
-
- @Override
- public Image getIconPicture(final int iconHeight) {
- return ImageFactory.getInstance().loadIcon("value", 12, null);
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return object;
- }
-
- @Override
- public int getNoLines() {
- return parameter.getNoLines();
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return options;
- }
-
- @Override
- public boolean isEmpty() {
- return object == null;
- }
-
- @Override
- public boolean isRequired() {
- return !parameter.isOptional();
- }
-
- @Override
- public Consent canClear() {
- return Allow.DEFAULT;
- }
-
- @Override
- public boolean canWrap() {
- return parameter.canWrap();
- }
-
- @Override
- public void clear() {
- object = null;
- }
-
- @Override
- public boolean isTransient() {
- return true;
- }
-
- @Override
- public boolean isTextParseable() {
- return true;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return options != null && options.length > 0;
- }
-
- @Override
- public String title() {
- return AdapterUtils.titleString(object);
- }
-
- @Override
- public String toString() {
- final ToString toString = new ToString(this);
- toString.append("object", object);
- return toString.toString();
- }
-
- @Override
- public String getParameterName() {
- return parameter.getName();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return parameter.getSpecification();
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- return null;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public String titleString(final ObjectAdapter value) {
- return titleString(value, parameter, parameter.getSpecification());
- }
-
- /**
- * @throws InvalidEntryException
- * - turns the parameter red if invalid.
- */
- @Override
- public void parseTextEntry(final String entryText) {
- object = parse(entryText);
- Localization localization = IsisContext.getLocalization();
- final String reason = parameter.isValid(object, AdapterUtils.unwrap(object), localization);
- if (reason != null) {
- throw new InvalidEntryException(reason);
- } else if (!parameter.isOptional() && object == null) {
- throw new InvalidEntryException("Mandatory parameter cannot be empty");
- }
- invocation.setParameter(index, object);
- }
-
- private ObjectAdapter parse(final String entryText) {
- final ObjectSpecification parameterSpecification = parameter.getSpecification();
- final ParseableFacet p = parameterSpecification.getFacet(ParseableFacet.class);
- try {
- Localization localization = IsisContext.getLocalization();
- return p.parseTextEntry(object, entryText, localization);
- } catch (final IllegalArgumentException ex) {
- throw new InvalidEntryException(ex.getMessage(), ex);
- }
- }
-
- @Override
- public String getDescription() {
- final String title = object == null ? "" : ": " + object.titleString();
- final String specification = getSpecification().getShortIdentifier();
- final String type = getParameterName().indexOf(specification) == -1 ? "" : " (" + specification + ")";
- return getParameterName() + type + title + " " + parameter.getDescription();
- }
-
- @Override
- public String getHelp() {
- return null;
- }
-
- @Override
- public String getId() {
- return null;
- }
-
- @Override
- public Consent isEditable() {
- return Allow.DEFAULT;
- }
-
- @Override
- public int getMaximumLength() {
- return parameter.getMaximumLength();
- }
-
- @Override
- public int getTypicalLineLength() {
- return parameter.getTypicalLineLength();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/axis/LabelAxis.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/axis/LabelAxis.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/axis/LabelAxis.java
deleted file mode 100644
index 4d61806..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/axis/LabelAxis.java
+++ /dev/null
@@ -1,45 +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.dnd.view.axis;
-
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-
-public class LabelAxis implements ViewAxis {
- private int width;
-
- public LabelAxis() {
- }
-
- public void accommodateWidth(final int width) {
- this.width = Math.max(this.width, width);
- }
-
- public int getWidth() {
- return width;
- }
-
- @Override
- public String toString() {
- final ToString str = new ToString(this);
- str.append("width", width);
- return str.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractBorder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractBorder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractBorder.java
deleted file mode 100644
index 3dab885..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractBorder.java
+++ /dev/null
@@ -1,289 +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.dnd.view.base;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.dnd.drawing.Bounds;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Padding;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Click;
-import org.apache.isis.viewer.dnd.view.ContentDrag;
-import org.apache.isis.viewer.dnd.view.DragEvent;
-import org.apache.isis.viewer.dnd.view.DragStart;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAreaType;
-
-public class AbstractBorder extends AbstractViewDecorator {
- protected int bottom;
- protected int left;
- private boolean onBorder;
- protected int right;
- protected int top;
-
- protected AbstractBorder(final View view) {
- super(view);
- }
-
- protected Bounds contentArea() {
- return new Bounds(getLeft(), getTop(), getSize().getWidth() - getLeft() - getRight(), getSize().getHeight() - getTop() - getBottom());
- }
-
- @Override
- public View dragFrom(final Location location) {
- location.subtract(getLeft(), getTop());
- return super.dragFrom(location);
- }
-
- @Override
- public void dragIn(final ContentDrag drag) {
- drag.subtract(getLeft(), getTop());
- super.dragIn(drag);
- }
-
- @Override
- public void dragOut(final ContentDrag drag) {
- drag.subtract(getLeft(), getTop());
- super.dragOut(drag);
- }
-
- @Override
- public DragEvent dragStart(final DragStart drag) {
- if (overContent(drag.getLocation())) {
- drag.subtract(getLeft(), getTop());
- return super.dragStart(drag);
- } else {
- return null;
- }
- }
-
- protected void clearBackground(final Canvas canvas, final Color color) {
- final Bounds bounds = getView().getBounds();
- canvas.drawSolidRectangle(0, 0, bounds.getWidth(), bounds.getHeight(), color);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- if (Toolkit.debug) {
- canvas.drawDebugOutline(new Bounds(getSize()), getBaseline(), Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_BORDER));
- }
- final int width = getSize().getWidth() - getRight();
- final int height = getSize().getHeight() - getBottom();
- final Canvas subcanvas = canvas.createSubcanvas(getLeft(), getTop(), width, height);
- wrappedView.draw(subcanvas);
- }
-
- @Override
- public void drop(final ContentDrag drag) {
- drag.subtract(getLeft(), getTop());
- super.drop(drag);
- }
-
- @Override
- public void firstClick(final Click click) {
- if (overContent(click.getLocation())) {
- click.subtract(getLeft(), getTop());
- wrappedView.firstClick(click);
- }
- }
-
- @Override
- public int getBaseline() {
- return wrappedView.getBaseline() + getTop();
- }
-
- protected int getBottom() {
- return bottom;
- }
-
- protected int getLeft() {
- return left;
- }
-
- @Override
- public Padding getPadding() {
- final Padding padding = wrappedView.getPadding();
- padding.extendTop(getTop());
- padding.extendLeft(getLeft());
- padding.extendBottom(getBottom());
- padding.extendRight(getRight());
-
- return padding;
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- availableSpace.contract(getLeft() + getRight(), getTop() + getBottom());
- final Size size = wrappedView.getRequiredSize(availableSpace);
- size.extend(getLeft() + getRight(), getTop() + getBottom());
- return size;
- }
-
- protected int getRight() {
- return right;
- }
-
- @Override
- public Size getSize() {
- final Size size = wrappedView.getSize();
- size.extend(getLeft() + getRight(), getTop() + getBottom());
-
- return size;
- }
-
- protected int getTop() {
- return top;
- }
-
- @Override
- protected void debugDetails(final DebugBuilder debug) {
- super.debugDetails(debug);
- debug.appendln("border", getTop() + "/" + getBottom() + " " + getLeft() + "/" + getRight() + " (top/bottom left/right)");
- debug.appendln("contents", contentArea());
- }
-
- protected boolean overBorder(final Location location) {
- return !contentArea().contains(location);
- }
-
- protected boolean overContent(final Location location) {
- return contentArea().contains(location);
- }
-
- protected boolean isOnBorder() {
- return onBorder;
- }
-
- @Override
- public View identify(final Location location) {
- getViewManager().getSpy().addTrace(this, "mouse location within border", location);
- getViewManager().getSpy().addTrace(this, "non border area", contentArea());
-
- if (overBorder(location)) {
- getViewManager().getSpy().addTrace(this, "over border area", contentArea());
- return getView();
- } else {
- location.add(-getLeft(), -getTop());
- return super.identify(location);
- }
-
- }
-
- @Override
- public void mouseDown(final Click click) {
- if (overContent(click.getLocation())) {
- click.subtract(getLeft(), getTop());
- wrappedView.mouseDown(click);
- }
- }
-
- @Override
- public void mouseMoved(final Location at) {
- final boolean on = overBorder(at);
- if (onBorder != on) {
- markDamaged();
- onBorder = on;
- }
-
- if (!on) {
- at.move(-getLeft(), -getTop());
- wrappedView.mouseMoved(at);
- }
- }
-
- @Override
- public void mouseUp(final Click click) {
- if (overContent(click.getLocation())) {
- click.subtract(getLeft(), getTop());
- wrappedView.mouseUp(click);
- }
- }
-
- @Override
- public void exited() {
- onBorder = false;
- super.exited();
- }
-
- @Override
- public View pickupContent(final Location location) {
- location.subtract(getLeft(), getTop());
- return super.pickupContent(location);
- }
-
- @Override
- public View pickupView(final Location location) {
- if (overBorder(location)) {
- return Toolkit.getViewFactory().createDragViewOutline(getView());
- } else {
- location.subtract(getLeft(), getTop());
- return super.pickupView(location);
- }
- }
-
- @Override
- public void secondClick(final Click click) {
- if (overContent(click.getLocation())) {
- click.subtract(getLeft(), getTop());
- wrappedView.secondClick(click);
- }
- }
-
- @Override
- public void setSize(final Size size) {
- final Size wrappedViewSize = new Size(size);
- wrappedViewSize.contract(getLeft() + getRight(), getTop() + getBottom());
- wrappedView.setSize(wrappedViewSize);
- }
-
- @Override
- public void setBounds(final Bounds bounds) {
- final Bounds wrappedViewBounds = new Bounds(bounds);
- wrappedViewBounds.contract(getLeft() + getRight(), getTop() + getBottom());
- wrappedView.setBounds(wrappedViewBounds);
- }
-
- @Override
- public void thirdClick(final Click click) {
- if (overContent(click.getLocation())) {
- click.subtract(getLeft(), getTop());
- wrappedView.thirdClick(click);
- }
- }
-
- @Override
- public ViewAreaType viewAreaType(final Location mouseLocation) {
- final Size size = wrappedView.getSize();
- final Bounds bounds = new Bounds(getLeft(), getTop(), size.getWidth(), size.getHeight());
-
- if (bounds.contains(mouseLocation)) {
- mouseLocation.subtract(getLeft(), getTop());
-
- return wrappedView.viewAreaType(mouseLocation);
- } else {
- return ViewAreaType.VIEW;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFieldSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFieldSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFieldSpecification.java
deleted file mode 100644
index 79e098f..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFieldSpecification.java
+++ /dev/null
@@ -1,56 +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.dnd.view.base;
-
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-
-public abstract class AbstractFieldSpecification implements ViewSpecification {
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isTextParseable() && requirement.isEditable();
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public boolean isReplaceable() {
- return true;
- }
-
- @Override
- public boolean isSubView() {
- return true;
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFocusManager.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFocusManager.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFocusManager.java
deleted file mode 100644
index 0262b9d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/base/AbstractFocusManager.java
+++ /dev/null
@@ -1,203 +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.dnd.view.base;
-
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.View;
-
-/**
- * Abstract focus manager that uses the set of views to move focus between from
- * the concrete subclass.
- *
- * @see #getChildViews()
- */
-public abstract class AbstractFocusManager implements FocusManager {
- // TODO container to go in subclass ??
- protected View container;
- protected View focus;
- private final View initialFocus;
-
- public AbstractFocusManager(final View container) {
- this(container, null);
- }
-
- public AbstractFocusManager(final View container, final View initalFocus) {
- Assert.assertNotNull(container);
- this.container = container;
- this.initialFocus = initalFocus;
- focus = initalFocus;
- }
-
- /**
- * Throws a ObjectAdapterRuntimeException if the specified view is available
- * to this focus manager.
- */
- private void checkCanFocusOn(final View view) {
- final View[] views = getChildViews();
- boolean valid = view == container.getView();
- for (int j = 0; valid == false && j < views.length; j++) {
- if (views[j] == view) {
- valid = true;
- }
- }
-
- if (!valid) {
- // throw new ObjectAdapterRuntimeException("No view " + view +
- // " to focus on in " +
- // container.getView());
- }
- }
-
- @Override
- public void focusFirstChildView() {
- final View[] views = getChildViews();
- for (final View view : views) {
- if (view.canFocus()) {
- setFocus(view);
- return;
- }
- }
- // no other focusable view; stick with the view we've got
- return;
- }
-
- @Override
- public void focusInitialChildView() {
- if (initialFocus == null) {
- focusFirstChildView();
- } else {
- setFocus(initialFocus);
- }
- }
-
- @Override
- public void focusLastChildView() {
- final View[] views = getChildViews();
- for (int j = views.length - 1; j > 0; j--) {
- if (views[j].canFocus()) {
- setFocus(views[j]);
- return;
- }
- }
- // no other focusable view; stick with the view we've got
- return;
- }
-
- @Override
- public void focusNextView() {
- final View[] views = getChildViews();
- for (int i = 0; i < views.length; i++) {
- if (testView(views, i)) {
- for (int j = i + 1; j < views.length; j++) {
- if (views[j].canFocus()) {
- setFocus(views[j]);
- return;
- }
- }
- for (int j = 0; j < i; j++) {
- if (views[j].canFocus()) {
- setFocus(views[j]);
- return;
- }
- }
- // no other focusable view; stick with the view we've got
- return;
- }
- }
-
- // throw new ObjectAdapterRuntimeException();
- }
-
- private boolean testView(final View[] views, final int i) {
- final View view = views[i];
- return view == focus;
- }
-
- @Override
- public void focusParentView() {
- container.getFocusManager().setFocus(container.getFocusManager().getFocus());
- }
-
- @Override
- public void focusPreviousView() {
- final View[] views = getChildViews();
- if (views.length > 1) {
- for (int i = 0; i < views.length; i++) {
- if (testView(views, i)) {
- for (int j = i - 1; j >= 0; j--) {
- if (views[j].canFocus()) {
- setFocus(views[j]);
- return;
- }
- }
- for (int j = views.length - 1; j > i; j--) {
- if (views[j].canFocus()) {
- setFocus(views[j]);
- return;
- }
- }
- // no other focusable view; stick with the view we've got
- return;
- }
- }
-
- // Don't move to any view
- // throw new
- // ObjectAdapterRuntimeException("Can't move to previous peer from "
- // + focus);
- }
- }
-
- protected abstract View[] getChildViews();
-
- @Override
- public View getFocus() {
- return focus;
- }
-
- @Override
- public void setFocus(final View view) {
- checkCanFocusOn(view);
-
- if (view != null && view.canFocus()) {
- if ((focus != null) && (focus != view)) {
- focus.focusLost();
- focus.markDamaged();
- }
-
- focus = view;
- focus.focusReceived();
-
- view.markDamaged();
- }
- }
-
- @Override
- public String toString() {
- final ToString str = new ToString(this);
- str.append("container", container);
- str.append("initialFocus", initialFocus);
- str.append("focus", focus);
- return str.toString();
- }
-
-}