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 2012/12/08 15:56:01 UTC
[25/53] [partial] ISIS-188: making structure of component viewers
consistent
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java
new file mode 100644
index 0000000..c00440a
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java
@@ -0,0 +1,29 @@
+/*
+ * 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.field;
+
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.viewer.dnd.view.ObjectContent;
+import org.apache.isis.viewer.dnd.view.content.FieldContent;
+
+public interface OneToOneField extends FieldContent, ObjectContent {
+ @Override
+ Consent isEditable();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java
new file mode 100644
index 0000000..b3fc8a7
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java
@@ -0,0 +1,211 @@
+/*
+ * 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.field;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.dnd.view.UserAction;
+import org.apache.isis.viewer.dnd.view.UserActionSet;
+import org.apache.isis.viewer.dnd.view.content.AbstractObjectContent;
+
+public class OneToOneFieldImpl extends AbstractObjectContent implements OneToOneField {
+ private static final UserAction CLEAR_ASSOCIATION = new ClearOneToOneAssociationOption();
+ private final ObjectField field;
+ private final ObjectAdapter adapter;
+
+ public OneToOneFieldImpl(final ObjectAdapter parentAdapter, final ObjectAdapter adapter, final OneToOneAssociation association) {
+ field = new ObjectField(parentAdapter, association);
+ this.adapter = adapter;
+ }
+
+ @Override
+ public Consent canClear() {
+ final ObjectAdapter parentAdapter = getParent();
+ final OneToOneAssociation association = getOneToOneAssociation();
+ // ObjectAdapter associatedObject = getObject();
+
+ final Consent isEditable = isEditable();
+ if (isEditable.isVetoed()) {
+ return isEditable;
+ }
+
+ final Consent consent = association.isAssociationValid(parentAdapter, null);
+ if (consent.isAllowed()) {
+ consent.setDescription("Clear the association to this object from '" + parentAdapter.titleString() + "'");
+ }
+ return consent;
+ }
+
+ @Override
+ public Consent canSet(final ObjectAdapter adapter) {
+ final ObjectSpecification targetType = getOneToOneAssociation().getSpecification();
+ final ObjectSpecification spec = adapter.getSpecification();
+
+ if (isEditable().isVetoed()) {
+ return isEditable();
+ }
+
+ if (!spec.isOfType(targetType)) {
+ // TODO: move logic into Facet
+ return new Veto(String.format("Can only drop objects of type %s", targetType.getSingularName()));
+ }
+
+ if (getParent().representsPersistent() && adapter.isTransient()) {
+ // TODO: move logic into Facet
+ return new Veto("Can't drop a non-persistent into this persistent object");
+ }
+
+ final Consent perm = getOneToOneAssociation().isAssociationValid(getParent(), adapter);
+ return perm;
+ }
+
+ @Override
+ public void clear() {
+ getOneToOneAssociation().clearAssociation(getParent());
+ }
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ field.debugDetails(debug);
+ debug.appendln("object", adapter);
+ }
+
+ @Override
+ public String getFieldName() {
+ return field.getName();
+ }
+
+ @Override
+ public ObjectAssociation getField() {
+ return field.getObjectAssociation();
+ }
+
+ @Override
+ public Consent isEditable() {
+ return getField().isUsable(IsisContext.getAuthenticationSession(), getParent(), where);
+ }
+
+ @Override
+ public ObjectAdapter getAdapter() {
+ return adapter;
+ }
+
+ @Override
+ public ObjectAdapter getObject() {
+ return adapter;
+ }
+
+ private OneToOneAssociation getOneToOneAssociation() {
+ return (OneToOneAssociation) getField();
+ }
+
+ @Override
+ public ObjectAdapter[] getOptions() {
+ return getOneToOneAssociation().getChoices(getParent());
+ }
+
+ @Override
+ public ObjectAdapter getParent() {
+ return field.getParent();
+ }
+
+ @Override
+ public ObjectSpecification getSpecification() {
+ return getOneToOneAssociation().getSpecification();
+ }
+
+ @Override
+ public boolean isMandatory() {
+ return getOneToOneAssociation().isMandatory();
+ }
+
+ @Override
+ public boolean isPersistable() {
+ return getObject() != null && super.isPersistable();
+ }
+
+ @Override
+ public boolean isObject() {
+ return true;
+ }
+
+ @Override
+ public boolean isOptionEnabled() {
+ return getOneToOneAssociation().hasChoices();
+ }
+
+ @Override
+ public boolean isTransient() {
+ return adapter != null && adapter.isTransient();
+ }
+
+ @Override
+ public void contentMenuOptions(final UserActionSet options) {
+ super.contentMenuOptions(options);
+ if (getObject() != null && !getOneToOneAssociation().isMandatory()) {
+ options.add(CLEAR_ASSOCIATION);
+ }
+ }
+
+ @Override
+ public void setObject(final ObjectAdapter object) {
+ getOneToOneAssociation().setAssociation(getParent(), object);
+ }
+
+ @Override
+ public String title() {
+ return adapter == null ? "" : adapter.titleString();
+ }
+
+ @Override
+ public String toString() {
+ return getObject() + "/" + getField();
+ }
+
+ @Override
+ public String windowTitle() {
+ return field.getName() + " for " + field.getParent().titleString();
+ }
+
+ @Override
+ public String getId() {
+ return getOneToOneAssociation().getName();
+ }
+
+ @Override
+ public String getDescription() {
+ final String name = getFieldName();
+ String type = getField().getSpecification().getSingularName();
+ type = name.indexOf(type) == -1 ? " (" + type + ")" : "";
+ final String description = getOneToOneAssociation().getDescription();
+ return name + type + " " + description;
+ }
+
+ @Override
+ public String getHelp() {
+ return getOneToOneAssociation().getHelp();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java
new file mode 100644
index 0000000..5cf5ae2
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java
@@ -0,0 +1,27 @@
+/*
+ * 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.field;
+
+import org.apache.isis.viewer.dnd.view.content.FieldContent;
+import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
+
+public interface TextParseableField extends TextParseableContent, FieldContent {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java
new file mode 100644
index 0000000..b08bec8
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java
@@ -0,0 +1,261 @@
+/*
+ * 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.field;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.facets.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
+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.facets.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.ObjectContent;
+import org.apache.isis.viewer.dnd.view.content.AbstractTextParsableContent;
+
+public class TextParseableFieldImpl extends AbstractTextParsableContent implements TextParseableField, ObjectContent {
+ private final ObjectField field;
+ private final ObjectAdapter parent;
+ private ObjectAdapter object;
+
+ public TextParseableFieldImpl(final ObjectAdapter parent, final ObjectAdapter object, final OneToOneAssociation association) {
+ field = new ObjectField(parent, association);
+ this.parent = parent;
+ this.object = object;
+ }
+
+ @Override
+ public Consent canDrop(final Content sourceContent) {
+ return Veto.DEFAULT;
+ }
+
+ @Override
+ public Consent canClear() {
+ return Allow.DEFAULT; // TODO is this flagged anywhere -
+ // getValueAssociation().canClear();
+ }
+
+ @Override
+ public boolean canWrap() {
+ return getValueAssociation().containsFacet(MultiLineFacet.class);
+ }
+
+ @Override
+ public void clear() {
+ }
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ field.debugDetails(debug);
+ debug.appendln("object", object);
+ }
+
+ @Override
+ public ObjectAdapter drop(final Content sourceContent) {
+ return null;
+ }
+
+ @Override
+ public void entryComplete() {
+ getValueAssociation().setAssociation(getParent(), object);
+ }
+
+ @Override
+ public String getDescription() {
+ final String title = object == null ? "" : ": " + object.titleString();
+ final String name = field.getName();
+ final ObjectSpecification specification = getSpecification();
+ final String type = name.indexOf(specification.getShortIdentifier()) == -1 ? "" : " (" + specification.getShortIdentifier() + ")";
+ final String description = getValueAssociation().getDescription();
+ return name + type + title + " " + description;
+ }
+
+ @Override
+ public String getHelp() {
+ return field.getHelp();
+ }
+
+ @Override
+ public String getFieldName() {
+ return field.getName();
+ }
+
+ @Override
+ public ObjectAssociation getField() {
+ return field.getObjectAssociation();
+ }
+
+ @Override
+ public String getIconName() {
+ return object == null ? "" : object.getIconName();
+ }
+
+ @Override
+ public ObjectAdapter getAdapter() {
+ return object;
+ }
+
+ @Override
+ public String getId() {
+ return field.getName();
+ }
+
+ @Override
+ public ObjectAdapter[] getOptions() {
+ return getValueAssociation().getChoices(getParent());
+ }
+
+ private OneToOneAssociation getValueAssociation() {
+ return (OneToOneAssociation) getField();
+ }
+
+ @Override
+ public int getMaximumLength() {
+ return maxLengthFacet().value();
+ }
+
+ @Override
+ public int getTypicalLineLength() {
+ final TypicalLengthFacet facet = field.getObjectAssociation().getFacet(TypicalLengthFacet.class);
+ return facet.value();
+ }
+
+ @Override
+ public int getNoLines() {
+ return multilineFacet().numberOfLines();
+ }
+
+ @Override
+ public ObjectAdapter getParent() {
+ return field.getParent();
+ }
+
+ @Override
+ public ObjectSpecification getSpecification() {
+ return getValueAssociation().getSpecification();
+ }
+
+ @Override
+ public Consent isEditable() {
+ return getValueAssociation().isUsable(IsisContext.getAuthenticationSession(), getParent(), Where.ANYWHERE);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return getField().isEmpty(getParent());
+ }
+
+ @Override
+ public boolean isMandatory() {
+ return getValueAssociation().isMandatory();
+ }
+
+ @Override
+ public boolean isOptionEnabled() {
+ return getValueAssociation().hasChoices();
+ }
+
+ @Override
+ public String titleString(final ObjectAdapter value) {
+ return titleString(value, field.getObjectAssociation(), field.getSpecification());
+ }
+
+ private ObjectAdapter validateAndParse(final String entryText) {
+ final ObjectAdapter newValue = parse(entryText);
+ final OneToOneAssociation objectAssociation = (OneToOneAssociation) field.getObjectAssociation();
+ final Consent valid = objectAssociation.isAssociationValid(parent, newValue);
+ if (valid.isVetoed()) {
+ throw new InvalidEntryException(valid.getReason());
+ }
+ return newValue;
+ }
+
+ private ObjectAdapter parse(final String entryText) {
+ final ObjectSpecification fieldSpecification = field.getSpecification();
+ final ParseableFacet p = fieldSpecification.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 void parseTextEntry(final String entryText) {
+ object = validateAndParse(entryText);
+ final Consent valid = ((OneToOneAssociation) getField()).isAssociationValid(getParent(), object);
+ if (valid.isVetoed()) {
+ throw new InvalidEntryException(valid.getReason());
+ }
+ if (getValueAssociation().isMandatory() && object == null) {
+ throw new InvalidEntryException("Mandatory field cannot be empty");
+ }
+ }
+
+ @Override
+ public String title() {
+ return field.getName();
+ }
+
+ @Override
+ public String toString() {
+ return (object == null ? "null" : object.titleString()) + "/" + getField();
+ }
+
+ @Override
+ public String windowTitle() {
+ return title();
+ }
+
+ private MaxLengthFacet maxLengthFacet() {
+ return getValueAssociation().getFacet(MaxLengthFacet.class);
+ }
+
+ private MultiLineFacet multilineFacet() {
+ return getValueAssociation().getFacet(MultiLineFacet.class);
+ }
+
+ @Override
+ public Consent canSet(final ObjectAdapter dragSource) {
+ return Veto.DEFAULT;
+ }
+
+ @Override
+ public ObjectAdapter getObject() {
+ return object;
+ }
+
+ @Override
+ public void setObject(final ObjectAdapter object) {
+ this.object = object;
+ ((OneToOneAssociation) field.getObjectAssociation()).setAssociation(getParent(), object);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
new file mode 100644
index 0000000..b1dfd03
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.look;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.viewer.dnd.util.Properties;
+import org.apache.isis.viewer.dnd.view.Look;
+import org.apache.isis.viewer.dnd.view.look.line.LineLook;
+import org.apache.isis.viewer.dnd.view.look.linux.LinuxLook;
+import org.apache.isis.viewer.dnd.view.look.simple.SimpleLook;
+import org.apache.isis.viewer.dnd.view.look.swing.SwingLook;
+
+public class LookFactory {
+ private static final Look SIMPLE_LOOK = new SimpleLook();
+ private static final LineLook LINE_LOOK = new LineLook();
+ private static final Look SWING_LOOK = new SwingLook();
+ private static final Look LINUX_LOOK = new LinuxLook();
+ private static final Look defaultLook = SIMPLE_LOOK;
+ private static List<Look> looks = new ArrayList<Look>();
+ private static Look installedLook;
+
+ public static void init() {
+ looks.add(SIMPLE_LOOK);
+ looks.add(LINE_LOOK);
+ looks.add(SWING_LOOK);
+ looks.add(LINUX_LOOK);
+
+ final String className = Properties.getString("look");
+ if (className != null) {
+ for (final Look look : looks) {
+ if (look.getClass().getName().equals(className)) {
+ setLook(look);
+ return;
+ }
+ }
+ }
+ setLook(defaultLook);
+ }
+
+ public static void setLook(final Look look) {
+ defaultLook.install();
+ look.install();
+ installedLook = look;
+
+ Properties.setStringOption("look", installedLook.getClass().getName());
+ }
+
+ public static Look getInstalledLook() {
+ return installedLook;
+ }
+
+ public static Iterable<Look> getAvailableLooks() {
+ return looks;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java
new file mode 100644
index 0000000..43be41d
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java
@@ -0,0 +1,63 @@
+/*
+ * 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.look.line;
+
+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.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.control.ButtonRender;
+
+public class ButtonLineStyleRender implements ButtonRender {
+ private static final int TEXT_PADDING = 12;
+ private static final Text style = Toolkit.getText(ColorsAndFonts.TEXT_CONTROL);
+ private final int buttonHeight;
+
+ public ButtonLineStyleRender() {
+ this.buttonHeight = 2 + style.getTextHeight() + 2;
+ }
+
+ @Override
+ public void draw(final Canvas canvas, final Size size, final boolean isDisabled, final boolean isDefault, final boolean hasFocus, final boolean isOver, final boolean isPressed, final String text) {
+ final int buttonWidth = TEXT_PADDING + style.stringWidth(text) + TEXT_PADDING;
+
+ final Color borderColor;
+ Color textColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ if (isDisabled) {
+ borderColor = textColor = Toolkit.getColor(ColorsAndFonts.COLOR_MENU_DISABLED);
+ } else if (isDefault) {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
+ } else if (isOver || hasFocus) {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ } else {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ }
+ canvas.drawRoundedRectangle(0, 0, buttonWidth, buttonHeight, 0, 0, borderColor);
+ canvas.drawText(text, TEXT_PADDING, buttonHeight / 2 + style.getMidPoint(), textColor, style);
+ }
+
+ @Override
+ public Size getMaximumSize(final String text) {
+ final int buttonWidth = TEXT_PADDING + Toolkit.getText(ColorsAndFonts.TEXT_CONTROL).stringWidth(text) + TEXT_PADDING;
+ return new Size(buttonWidth, buttonHeight);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java
new file mode 100644
index 0000000..b3e8123
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java
@@ -0,0 +1,39 @@
+/*
+ * 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.look.line;
+
+import org.apache.isis.viewer.dnd.view.Look;
+import org.apache.isis.viewer.dnd.view.control.Button;
+import org.apache.isis.viewer.dnd.view.window.AbstractWindowBorder;
+
+public class LineLook implements Look {
+
+ @Override
+ public void install() {
+ AbstractWindowBorder.setBorderRenderer(new LineStyleWindowBorder());
+ Button.setButtonRender(new ButtonLineStyleRender());
+ }
+
+ @Override
+ public String getName() {
+ return "Line";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineStyleWindowBorder.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineStyleWindowBorder.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineStyleWindowBorder.java
new file mode 100644
index 0000000..62da192
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineStyleWindowBorder.java
@@ -0,0 +1,99 @@
+/*
+ * 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.look.line;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.ViewConstants;
+import org.apache.isis.viewer.dnd.view.ViewState;
+import org.apache.isis.viewer.dnd.view.border.BorderDrawing;
+import org.apache.isis.viewer.dnd.view.text.TextUtils;
+import org.apache.isis.viewer.dnd.view.window.WindowControl;
+
+public class LineStyleWindowBorder implements BorderDrawing {
+ private final static Text TITLE_STYLE = Toolkit.getText(ColorsAndFonts.TEXT_TITLE_SMALL);
+ private final int titlebarHeight = Math.max(WindowControl.HEIGHT + ViewConstants.VPADDING + TITLE_STYLE.getDescent(), TITLE_STYLE.getTextHeight());
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ }
+
+ @Override
+ public void draw(final Canvas canvas, final Size s, final boolean hasFocus, final ViewState state, final View[] controls, final String title) {
+ final Color borderColor = hasFocus ? Toolkit.getColor(ColorsAndFonts.COLOR_BLACK) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1);
+ canvas.drawRectangle(0, 0, s.getWidth(), s.getHeight(), borderColor);
+ final int y = getTop();
+ canvas.drawLine(0, y, s.getWidth(), y, borderColor);
+ final int controlWidth = ViewConstants.HPADDING + (WindowControl.WIDTH + ViewConstants.HPADDING) * controls.length;
+ final String text = TextUtils.limitText(title, TITLE_STYLE, s.getWidth() - controlWidth - ViewConstants.VPADDING);
+ canvas.drawText(text, 6, TITLE_STYLE.getLineHeight(), borderColor, Toolkit.getText(ColorsAndFonts.TEXT_TITLE_SMALL));
+ }
+
+ // TODO transiency should be flagged elsewhere and dealt with in the draw
+ // method.
+ @Override
+ public void drawTransientMarker(final Canvas canvas, final Size size) {
+ }
+
+ @Override
+ public int getBottom() {
+ return 1;
+ }
+
+ @Override
+ public int getLeft() {
+ return 1;
+ }
+
+ @Override
+ public void getRequiredSize(final Size size, final String title, final View[] controls) {
+ final int width = getLeft() + ViewConstants.HPADDING + TITLE_STYLE.stringWidth(title) + ViewConstants.HPADDING + controls.length * (WindowControl.WIDTH + ViewConstants.HPADDING) + ViewConstants.HPADDING + getRight();
+ size.ensureWidth(width);
+ }
+
+ @Override
+ public int getRight() {
+ return 1;
+ }
+
+ @Override
+ public int getTop() {
+ return titlebarHeight + 5;
+ }
+
+ @Override
+ public void layoutControls(final Size size, final View[] controls) {
+ int x = size.getWidth() - 1 - (WindowControl.WIDTH + ViewConstants.HPADDING) * controls.length;
+ final int y = 2 + ViewConstants.VPADDING;
+ for (final View control : controls) {
+ control.setSize(control.getRequiredSize(new Size()));
+ control.setLocation(new Location(x, y));
+ x += control.getSize().getWidth() + ViewConstants.HPADDING;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java
new file mode 100644
index 0000000..db10d39
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java
@@ -0,0 +1,72 @@
+/*
+ * 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.look.linux;
+
+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.Image;
+import org.apache.isis.viewer.dnd.drawing.ImageFactory;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.control.ButtonRender;
+
+public class Button3DStyleRender implements ButtonRender {
+ private static final int TEXT_PADDING = 12;
+ private static final Text style = Toolkit.getText(ColorsAndFonts.TEXT_CONTROL);
+ private final int buttonHeight;
+ protected Image iconize = ImageFactory.getInstance().loadImage("button1.png");
+ protected Image resize = ImageFactory.getInstance().loadImage("button2.png");
+ protected Image close = ImageFactory.getInstance().loadImage("button3.png");
+ protected Image disabled = ImageFactory.getInstance().loadImage("button4.png");
+
+ public Button3DStyleRender() {
+ this.buttonHeight = 4 + style.getTextHeight() + 4;
+ }
+
+ @Override
+ public void draw(final Canvas canvas, final Size size, final boolean isDisabled, final boolean isDefault, final boolean hasFocus, final boolean isOver, final boolean isPressed, final String text) {
+ final int x = 0;
+ final int y = 0;
+
+ final int buttonWidth = TEXT_PADDING + style.stringWidth(text) + TEXT_PADDING;
+
+ canvas.drawSolidRectangle(x, y, buttonWidth, buttonHeight, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3));
+
+ final Color color = isDisabled ? Toolkit.getColor(ColorsAndFonts.COLOR_MENU_DISABLED) : Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ final Color border = isDisabled ? Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2);
+ canvas.drawRectangle(x, y, buttonWidth, buttonHeight, isOver & !isDisabled ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1) : Toolkit.getColor(ColorsAndFonts.COLOR_BLACK));
+ canvas.draw3DRectangle(x + 1, y + 1, buttonWidth - 2, buttonHeight - 2, border, !isPressed);
+ canvas.draw3DRectangle(x + 2, y + 2, buttonWidth - 4, buttonHeight - 4, border, !isPressed);
+ if (isDefault) {
+ canvas.drawRectangle(x + 3, y + 3, buttonWidth - 6, buttonHeight - 6, border);
+ }
+ if (hasFocus) {
+ canvas.drawRectangle(x + 3, y + 3, buttonWidth - 6, buttonHeight - 6, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
+ }
+ canvas.drawText(text, x + TEXT_PADDING, y + buttonHeight / 2 + style.getMidPoint(), color, style);
+ }
+
+ @Override
+ public Size getMaximumSize(final String text) {
+ final int buttonWidth = TEXT_PADDING + Toolkit.getText(ColorsAndFonts.TEXT_CONTROL).stringWidth(text) + TEXT_PADDING;
+ return new Size(buttonWidth, buttonHeight);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java
new file mode 100644
index 0000000..687192c
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java
@@ -0,0 +1,45 @@
+/*
+ * 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.look.linux;
+
+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.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.window.CloseWindowRender;
+
+public class CloseWindow3DRender implements CloseWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ canvas.drawRectangle(x - 1, y, width + 2, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
+ canvas.drawRectangle(x, y - 1, width + 2, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ final Color crossColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ canvas.drawLine(x + 4, y + 3, x + 10, y + 9, crossColor);
+ canvas.drawLine(x + 5, y + 3, x + 11, y + 9, crossColor);
+ canvas.drawLine(x + 3, y + 3, x + 9, y + 9, crossColor);
+ canvas.drawLine(x + 10, y + 3, x + 4, y + 9, crossColor);
+ canvas.drawLine(x + 11, y + 3, x + 5, y + 9, crossColor);
+ canvas.drawLine(x + 9, y + 3, x + 3, y + 9, crossColor);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java
new file mode 100644
index 0000000..2fffc82
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java
@@ -0,0 +1,148 @@
+/*
+ * 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.look.linux;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.DrawingUtil;
+import org.apache.isis.viewer.dnd.drawing.Image;
+import org.apache.isis.viewer.dnd.drawing.ImageFactory;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.ViewConstants;
+import org.apache.isis.viewer.dnd.view.ViewState;
+import org.apache.isis.viewer.dnd.view.border.BorderDrawing;
+import org.apache.isis.viewer.dnd.view.text.TextUtils;
+import org.apache.isis.viewer.dnd.view.window.WindowControl;
+
+public class CustomStyleWindowBorder implements BorderDrawing {
+ final protected static int LINE_THICKNESS = 5;
+ private final static Text TITLE_STYLE = Toolkit.getText(ColorsAndFonts.TEXT_TITLE_SMALL);
+
+ int titlebarHeight = Math.max(WindowControl.HEIGHT + ViewConstants.VPADDING + TITLE_STYLE.getDescent(), TITLE_STYLE.getTextHeight());
+ int baseline = LINE_THICKNESS + WindowControl.HEIGHT;
+ int left = LINE_THICKNESS;
+ int right = LINE_THICKNESS;
+ int top = LINE_THICKNESS + titlebarHeight;
+ int bottom = LINE_THICKNESS;
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ debug.appendln("titlebar ", top - titlebarHeight);
+ }
+
+ @Override
+ public void layoutControls(final Size size, final View[] controls) {
+ int x = size.getWidth() - right - (WindowControl.WIDTH + ViewConstants.HPADDING) * controls.length;
+ final int y = LINE_THICKNESS + ViewConstants.VPADDING;
+
+ for (final View control : controls) {
+ control.setSize(control.getRequiredSize(new Size()));
+ control.setLocation(new Location(x, y));
+ x += control.getSize().getWidth() + ViewConstants.HPADDING;
+ }
+ }
+
+ @Override
+ public void draw(final Canvas canvas, final Size s, final boolean hasFocus, final ViewState state, final View[] controls, final String title) {
+ final int x = left;
+ final int width = s.getWidth();
+ final int height = s.getHeight();
+
+ final Color titleBarBackgroundColor = hasFocus ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3);
+ final Color titleBarTextColor = hasFocus ? Toolkit.getColor(ColorsAndFonts.COLOR_BLACK) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1);
+ final Color borderColor = hasFocus ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1);
+
+ // slightly rounded grey border
+ canvas.drawRectangle(1, 0, width - 2, height, borderColor);
+ canvas.drawRectangle(0, 1, width, height - 2, borderColor);
+
+ for (int i = 2; i < left; i++) {
+ canvas.drawRectangle(i, i, width - 2 * i, height - 2 * i, borderColor);
+ }
+
+ if (state.isActive()) {
+ final Image busyImage = ImageFactory.getInstance().loadIcon("busy", 16, null);
+ canvas.drawImage(busyImage, width - right - 16 - 4, top + 4);
+ }
+
+ // title bar
+ canvas.drawSolidRectangle(left, LINE_THICKNESS, width - left - right, titlebarHeight, titleBarBackgroundColor);
+ final int y = LINE_THICKNESS + titlebarHeight - 1;
+ canvas.drawLine(x, y, width - right - 1, y, borderColor);
+
+ final int controlWidth = ViewConstants.HPADDING + (WindowControl.WIDTH + ViewConstants.HPADDING) * controls.length;
+ final String text = TextUtils.limitText(title, TITLE_STYLE, width - controlWidth - LINE_THICKNESS * 2 - 2);
+ canvas.drawText(text, x + ViewConstants.HPADDING, baseline, titleBarTextColor, TITLE_STYLE);
+
+ final Color white = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
+ final int hatchX = ViewConstants.HPADDING + TITLE_STYLE.stringWidth(title) + 10;
+ final int hatchWidth = controls[0].getLocation().getX() - hatchX - 10;
+ final int hatchY = LINE_THICKNESS + 2;
+ final int hatchHeight = titlebarHeight - 6;
+ DrawingUtil.drawHatching(canvas, hatchX, hatchY, hatchWidth, hatchHeight, borderColor, white);
+
+ }
+
+ @Override
+ public void drawTransientMarker(final Canvas canvas, final Size size) {
+ final int height = top - LINE_THICKNESS - 2;
+ final int x = size.getWidth() - 50;
+ final Image icon = ImageFactory.getInstance().loadIcon("transient", height, null);
+ if (icon == null) {
+ canvas.drawText("*", x, baseline, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK), Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ } else {
+ canvas.drawImage(icon, x, LINE_THICKNESS + 1, height, height);
+ }
+
+ }
+
+ @Override
+ public void getRequiredSize(final Size size, final String title, final View[] controls) {
+ final int width = left + ViewConstants.HPADDING + TITLE_STYLE.stringWidth(title) + ViewConstants.HPADDING + controls.length * (WindowControl.WIDTH + ViewConstants.HPADDING) + ViewConstants.HPADDING + right;
+ // size.extendWidth(getLeft() + getRight());
+ size.ensureWidth(width);
+ }
+
+ @Override
+ public int getLeft() {
+ return left;
+ }
+
+ @Override
+ public int getRight() {
+ return right;
+ }
+
+ @Override
+ public int getTop() {
+ return top;
+ }
+
+ @Override
+ public int getBottom() {
+ return bottom;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java
new file mode 100644
index 0000000..fff9f91
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java
@@ -0,0 +1,37 @@
+/*
+ * 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.look.linux;
+
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.window.IconizeWindowRender;
+
+public class IconizeWindow3DRender implements IconizeWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ canvas.drawRectangle(x - 1, y, width + 2, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
+ canvas.drawRectangle(x - 1, y - 1, width + 1, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ canvas.drawSolidRectangle(x + 3, y + 8, x + 8, 3, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java
new file mode 100644
index 0000000..b0ead97
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java
@@ -0,0 +1,257 @@
+/*
+ * 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.look.linux;
+
+import java.awt.event.KeyEvent;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.progmodel.facets.value.date.DateValueFacet;
+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.Image;
+import org.apache.isis.viewer.dnd.drawing.ImageFactory;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.field.DatePicker;
+import org.apache.isis.viewer.dnd.view.Click;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.KeyboardAction;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.base.AbstractView;
+import org.apache.isis.viewer.dnd.view.content.FieldContent;
+import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
+
+public class LinuxDatePicker extends AbstractView implements DatePicker {
+
+ protected Image calendarImage = ImageFactory.getInstance().loadImage("calendar2.png");
+ protected Image monthUp = ImageFactory.getInstance().loadImage("monthup.png");
+ protected Image monthDown = ImageFactory.getInstance().loadImage("monthdown.png");
+ protected Image yearUp = ImageFactory.getInstance().loadImage("yearup.png");
+ protected Image yearDown = ImageFactory.getInstance().loadImage("yeardown.png");
+ protected Image decadeUp = ImageFactory.getInstance().loadImage("decadeup.png");
+ protected Image decadeDown = ImageFactory.getInstance().loadImage("decadedown.png");
+ protected Image highlight = ImageFactory.getInstance().loadImage("highlight2.png");
+ protected Image day_img = ImageFactory.getInstance().loadImage("day2.png");
+
+ private static final int ROWS = 7;// Days
+ private static final int COLUMNS = 6;// Weeks
+ private final int CONTROL_VERTICAL_INSET = 17;
+ private final int CONTROL_VERTICAL_SPACING = monthUp.getWidth() + 5;
+ private final int CONTROL_HORIZONTAL_INSET = 215;
+ private final int CONTROL_HORIZONTAL_SPACING = monthUp.getHeight() + 5;
+ private final int cellWidth = day_img.getWidth();
+ private final int cellHeight = day_img.getHeight();
+ private final Calendar date;
+ private final Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
+ private Calendar currentDate;
+ private final Calendar today;
+ private final boolean isEditable;
+
+ String[] monthName = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
+
+ private Location mouseLocation = new Location(-1, -1);
+
+ public LinuxDatePicker(final Content content) {
+ super(content);
+
+ isEditable = content instanceof FieldContent && ((FieldContent) content).isEditable().isAllowed();
+
+ today = Calendar.getInstance();
+ clearTime(today);
+
+ date = Calendar.getInstance();
+ final ObjectAdapter dateAdapter = ((TextParseableContent) getContent()).getAdapter();
+ if (dateAdapter != null) {
+ final DateValueFacet facet = dateAdapter.getSpecification().getFacet(DateValueFacet.class);
+ currentDate = Calendar.getInstance();
+ final Date dateValue = facet.dateValue(dateAdapter);
+ currentDate.setTime(dateValue);
+ clearTime(currentDate);
+ date.setTime(dateValue);
+ }
+ clearTime(date);
+ date.add(Calendar.DAY_OF_MONTH, -21);
+ }
+
+ private void clearTime(final Calendar date) {
+ date.clear(Calendar.AM_PM);
+ date.clear(Calendar.HOUR);
+ date.clear(Calendar.HOUR_OF_DAY);
+ date.clear(Calendar.MINUTE);
+ date.clear(Calendar.SECOND);
+ date.clear(Calendar.MILLISECOND);
+ }
+
+ @Override
+ public Size getRequiredSize(final Size availableSpace) {
+ return new Size(225, 270);
+ }
+
+ @Override
+ public void draw(final Canvas canvas) {
+ final int width = getSize().getWidth();
+ final int height = getSize().getHeight();
+
+ final Color textColor = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
+
+ drawBackground(canvas, width, height, textColor);
+ drawDaysOfWeek(canvas, textColor);
+ drawControls(canvas, width);
+ }
+
+ private void drawBackground(final Canvas canvas, final int width, final int height, final Color text) {
+ canvas.drawImage(calendarImage, 0, 0);
+ canvas.drawText(monthName[today.get(Calendar.MONTH)], 26, 28, text, style);
+ canvas.drawText(Integer.toString(today.get(Calendar.YEAR)), 176, 28, text, style);
+ }
+
+ private void drawDaysOfWeek(final Canvas canvas, final Color textColor) {
+ int x, y = 0;
+ final Calendar cal = Calendar.getInstance();
+ cal.setTime(today.getTime());
+ cal.set(Calendar.DATE, 1);
+ cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK) + 1);
+ for (int week = 0; week < COLUMNS; week++) {
+ y = week * 21 + 60;
+ for (int d = 0; d < ROWS; d++) {
+ x = new Float(d * 22.5).intValue() + 40;
+ Image img = day_img;
+ if (cal.get(Calendar.MONTH) == today.get(Calendar.MONTH)) {
+ if (mouseOver(x, y)) {
+ img = highlight;
+ }
+ canvas.drawImage(img, x, y);
+ canvas.drawText(Integer.toString(cal.get(Calendar.DAY_OF_MONTH)), x + 4, y + 15, textColor, style);
+ }
+ cal.add(Calendar.DATE, +1);
+ }
+ }
+ }
+
+ private boolean mouseOver(final int x, final int y) {
+ final int mouseX = mouseLocation.getX();
+ final int mouseY = mouseLocation.getY();
+ if (mouseX > x && mouseX < x + cellWidth) {
+ if (mouseY > y && mouseY < y + cellHeight) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void drawControls(final Canvas canvas, final int width) {
+
+ canvas.drawImage(monthUp, CONTROL_VERTICAL_INSET, CONTROL_HORIZONTAL_INSET);
+ canvas.drawImage(monthDown, CONTROL_VERTICAL_INSET, CONTROL_HORIZONTAL_INSET + CONTROL_HORIZONTAL_SPACING);
+ canvas.drawImage(yearUp, CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING, CONTROL_HORIZONTAL_INSET);
+ canvas.drawImage(yearDown, CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING, CONTROL_HORIZONTAL_INSET + CONTROL_HORIZONTAL_SPACING);
+ canvas.drawImage(decadeUp, CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING), CONTROL_HORIZONTAL_INSET);
+ canvas.drawImage(decadeDown, CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING), CONTROL_HORIZONTAL_INSET + CONTROL_HORIZONTAL_SPACING);
+ }
+
+ @Override
+ public void mouseMoved(final Location location) {
+ mouseLocation = location;
+ if (location.getX() > 0 && location.getY() > 0) {
+ markDamaged();
+ }
+ }
+
+ @Override
+ public void exited() {
+ mouseOver(-1, -1);
+ super.exited();
+ }
+
+ @Override
+ public void firstClick(final Click click) {
+ final int x = click.getLocation().getX();
+ final int y = click.getLocation().getY();
+ if (y >= CONTROL_HORIZONTAL_INSET + CONTROL_HORIZONTAL_SPACING && y <= CONTROL_HORIZONTAL_INSET + (2 * CONTROL_HORIZONTAL_SPACING)) {
+ if (x <= CONTROL_VERTICAL_INSET + (3 * CONTROL_VERTICAL_SPACING) && x >= CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING)) {
+ today.add(Calendar.YEAR, -10);
+ } else if (x >= CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING && x <= CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING)) {
+ today.add(Calendar.YEAR, -1);
+ } else if (x >= CONTROL_VERTICAL_INSET && x <= CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING) {
+ today.add(Calendar.MONTH, -1);
+ }
+ markDamaged();
+ return;
+ }
+ if (y > CONTROL_HORIZONTAL_INSET && y <= CONTROL_HORIZONTAL_INSET + CONTROL_HORIZONTAL_SPACING) {
+ if (x <= CONTROL_VERTICAL_INSET + (3 * CONTROL_VERTICAL_SPACING) && x >= CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING)) {
+ today.add(Calendar.YEAR, 10);
+ } else if (x >= CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING && x <= CONTROL_VERTICAL_INSET + (2 * CONTROL_VERTICAL_SPACING)) {
+ today.add(Calendar.YEAR, 1);
+ } else if (x >= CONTROL_VERTICAL_INSET && x <= CONTROL_VERTICAL_INSET + CONTROL_VERTICAL_SPACING) {
+ today.add(Calendar.MONTH, 1);
+ }
+ markDamaged();
+ return;
+ }
+ if (isEditable) {
+ final Location location = click.getLocation();
+ final Date selectedDate = getSelectedDate(location);
+ if (selectedDate != null) {
+ date.setTime(selectedDate);
+ final Content content = getContent();
+ final DateValueFacet facet = content.getSpecification().getFacet(DateValueFacet.class);
+ final ObjectAdapter value = facet.createValue(date.getTime());
+ ((TextParseableContent) content).parseTextEntry(value.titleString());
+ ((TextParseableContent) content).entryComplete();
+ getView().refresh();
+ }
+ }
+ getViewManager().clearOverlayView();
+ }
+
+ private Date getSelectedDate(final Location location) {
+ int x, y = 0;
+ final Calendar cal = Calendar.getInstance();
+ cal.setTime(today.getTime());
+ cal.set(Calendar.DATE, 1);
+ cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK) + 1);
+ for (int week = 0; week < COLUMNS; week++) {
+ y = (week * 21) + 60;
+ for (int d = 0; d < ROWS; d++) {
+ x = new Float(d * 22.5).intValue() + 40;
+ if (location.getX() > x && location.getX() < x + cellWidth) {
+ if (location.getY() > y && location.getY() < y + cellHeight) {
+ return cal.getTime();// This is the selected date
+ }
+ }
+ cal.add(Calendar.DATE, +1);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void keyPressed(final KeyboardAction key) {
+ if (isEditable && key.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ getViewManager().clearOverlayView();
+ } else {
+ super.keyPressed(key);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java
new file mode 100644
index 0000000..564c012
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java
@@ -0,0 +1,44 @@
+/*
+ * 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.look.linux;
+
+import org.apache.isis.viewer.dnd.view.Look;
+import org.apache.isis.viewer.dnd.view.control.Button;
+import org.apache.isis.viewer.dnd.view.window.AbstractWindowBorder;
+import org.apache.isis.viewer.dnd.view.window.CloseWindowControl;
+import org.apache.isis.viewer.dnd.view.window.IconizeWindowControl;
+import org.apache.isis.viewer.dnd.view.window.ResizeWindowControl;
+
+public class LinuxLook implements Look {
+
+ @Override
+ public void install() {
+ Button.setButtonRender(new Button3DStyleRender());
+ AbstractWindowBorder.setBorderRenderer(new CustomStyleWindowBorder());
+ CloseWindowControl.setRender(new CloseWindow3DRender());
+ ResizeWindowControl.setRender(new ResizeWindow3DRender());
+ IconizeWindowControl.setRender(new IconizeWindow3DRender());
+ }
+
+ @Override
+ public String getName() {
+ return "Linux";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java
new file mode 100644
index 0000000..7a96abf
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java
@@ -0,0 +1,39 @@
+/*
+ * 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.look.linux;
+
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.window.ResizeWindowRender;
+
+public class ResizeWindow3DRender implements ResizeWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ canvas.drawRectangle(x - 1, y, width + 2, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
+ canvas.drawRectangle(x, y - 1, width, height + 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ canvas.drawSolidRectangle(width / 2 - 1, y + 2, 3, height - 4, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2));
+ canvas.drawSolidRectangle(x + 2, height / 2 - 1, width - 4, 3, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/CloseWindowSimpleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/CloseWindowSimpleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/CloseWindowSimpleRender.java
new file mode 100644
index 0000000..7f5e3ec
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/CloseWindowSimpleRender.java
@@ -0,0 +1,39 @@
+/*
+ * 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.look.simple;
+
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.view.window.CloseWindowRender;
+
+public class CloseWindowSimpleRender extends SimpleRender implements CloseWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ final Color color = color(isDisabled, isOver);
+ canvas.drawLine(x + 4, y + 3, x + 10, y + 9, color);
+ canvas.drawLine(x + 5, y + 3, x + 11, y + 9, color);
+ canvas.drawLine(x + 10, y + 3, x + 4, y + 9, color);
+ canvas.drawLine(x + 11, y + 3, x + 5, y + 9, color);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/IconizeWindowSimpleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/IconizeWindowSimpleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/IconizeWindowSimpleRender.java
new file mode 100644
index 0000000..0eebb3a
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/IconizeWindowSimpleRender.java
@@ -0,0 +1,37 @@
+/*
+ * 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.look.simple;
+
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.view.window.IconizeWindowRender;
+
+public class IconizeWindowSimpleRender extends SimpleRender implements IconizeWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ final Color color = color(isDisabled, isOver);
+ canvas.drawLine(x + 3, y + 8, x + 8, y + 8, color);
+ canvas.drawLine(x + 3, y + 9, x + 8, y + 9, color);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/ResizeWindowSimpleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/ResizeWindowSimpleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/ResizeWindowSimpleRender.java
new file mode 100644
index 0000000..48855ba
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/ResizeWindowSimpleRender.java
@@ -0,0 +1,38 @@
+/*
+ * 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.look.simple;
+
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.view.window.ResizeWindowRender;
+
+public class ResizeWindowSimpleRender extends SimpleRender implements ResizeWindowRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int width, final int height, final boolean isDisabled, final boolean isOver, final boolean isPressed) {
+ final int x = 0;
+ final int y = 0;
+
+ final Color color = color(isDisabled, isOver);
+ canvas.drawRectangle(x + 3, y + 2, 8, 8, color);
+ canvas.drawLine(x + 3, y + 3, x + 10, y + 3, color);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleButtonRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleButtonRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleButtonRender.java
new file mode 100644
index 0000000..8294390
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleButtonRender.java
@@ -0,0 +1,63 @@
+/*
+ * 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.look.simple;
+
+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.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.control.ButtonRender;
+
+public class SimpleButtonRender implements ButtonRender {
+ private static final int TEXT_PADDING = 12;
+ private static final Text style = Toolkit.getText(ColorsAndFonts.TEXT_CONTROL);
+ private final int buttonHeight;
+
+ public SimpleButtonRender() {
+ this.buttonHeight = 2 + style.getTextHeight() + 2;
+ }
+
+ @Override
+ public void draw(final Canvas canvas, final Size size, final boolean isDisabled, final boolean isDefault, final boolean hasFocus, final boolean isOver, final boolean isPressed, final String text) {
+ final int buttonWidth = TEXT_PADDING + style.stringWidth(text) + TEXT_PADDING;
+
+ final Color borderColor;
+ Color textColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ if (isDisabled) {
+ borderColor = textColor = Toolkit.getColor(ColorsAndFonts.COLOR_MENU_DISABLED);
+ } else if (isDefault) {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
+ } else if (isOver || hasFocus) {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ } else {
+ borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ }
+ canvas.drawRoundedRectangle(0, 0, buttonWidth, buttonHeight, 0, 0, borderColor);
+ canvas.drawText(text, TEXT_PADDING, buttonHeight / 2 + style.getMidPoint(), textColor, style);
+ }
+
+ @Override
+ public Size getMaximumSize(final String text) {
+ final int buttonWidth = TEXT_PADDING + Toolkit.getText(ColorsAndFonts.TEXT_CONTROL).stringWidth(text) + TEXT_PADDING;
+ return new Size(buttonWidth, buttonHeight);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleLook.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleLook.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleLook.java
new file mode 100644
index 0000000..a109c32
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleLook.java
@@ -0,0 +1,49 @@
+/*
+ * 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.look.simple;
+
+import org.apache.isis.viewer.dnd.view.Look;
+import org.apache.isis.viewer.dnd.view.border.ScrollBorder;
+import org.apache.isis.viewer.dnd.view.border.ViewResizeBorder;
+import org.apache.isis.viewer.dnd.view.control.Button;
+import org.apache.isis.viewer.dnd.view.window.AbstractWindowBorder;
+import org.apache.isis.viewer.dnd.view.window.CloseWindowControl;
+import org.apache.isis.viewer.dnd.view.window.IconizeWindowControl;
+import org.apache.isis.viewer.dnd.view.window.ResizeWindowControl;
+
+public class SimpleLook implements Look {
+
+ @Override
+ public void install() {
+ AbstractWindowBorder.setBorderRenderer(new SimpleStyleWindowBorder());
+ CloseWindowControl.setRender(new CloseWindowSimpleRender());
+ ResizeWindowControl.setRender(new ResizeWindowSimpleRender());
+ IconizeWindowControl.setRender(new IconizeWindowSimpleRender());
+ ViewResizeBorder.setRender(new SimpleResizeViewRender());
+ ScrollBorder.setRender(new SimpleScrollBarRender());
+ Button.setButtonRender(new SimpleButtonRender());
+ }
+
+ @Override
+ public String getName() {
+ return "Simple";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleRender.java
new file mode 100644
index 0000000..29e05c9
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleRender.java
@@ -0,0 +1,37 @@
+/*
+ * 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.look.simple;
+
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+
+class SimpleRender {
+ protected Color color(final boolean isDisabled, final boolean isOver) {
+ Color color;
+ if (isDisabled) {
+ color = Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3);
+ } else {
+ color = isOver ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2) : Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+ }
+ return color;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleResizeViewRender.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleResizeViewRender.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleResizeViewRender.java
new file mode 100644
index 0000000..42c4083
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/simple/SimpleResizeViewRender.java
@@ -0,0 +1,47 @@
+/*
+ * 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.look.simple;
+
+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.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.border.ResizeViewRender;
+
+public class SimpleResizeViewRender implements ResizeViewRender {
+
+ @Override
+ public void draw(final Canvas canvas, final int x, final int width, final int height, final boolean hasFocus) {
+ final Color secondary2 = Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2);
+ canvas.drawRectangle(x, 1, width, height - 1, secondary2);
+
+ int h1 = 30;
+ int h2 = 10;
+ if (height < h1 + h2 * 2) {
+ h1 = Math.min(0, height - h2 * 2);
+ } else {
+ h2 = (height - h1) / 2;
+ }
+
+ final Color color = hasFocus ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2) : secondary2;
+ canvas.drawSolidRectangle(x + 1, h2, width - 2, h1, color);
+ }
+
+}