You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by rm...@apache.org on 2010/11/28 21:25:57 UTC
svn commit: r1039939 - in /incubator/isis/trunk/viewer/dnd/src/main:
java/org/apache/isis/viewer/dnd/calendar/
java/org/apache/isis/viewer/dnd/field/
java/org/apache/isis/viewer/dnd/view/look/
java/org/apache/isis/viewer/dnd/view/look/linux/ resources/...
Author: rmatthews
Date: Sun Nov 28 20:25:56 2010
New Revision: 1039939
URL: http://svn.apache.org/viewvc?rev=1039939&view=rev
Log:
Copied across Dave's template and Date popup from the NOF repo.
Added:
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/button1.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/button2.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/button3.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/button4.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/day2.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadedown.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadeup.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/highlight2.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthdown.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthup.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/yeardown.png (with props)
incubator/isis/trunk/viewer/dnd/src/main/resources/images/yearup.png (with props)
Modified:
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/calendar/CalendarView.java
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DateFieldSpecification.java
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePicker.java
incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
Modified: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/calendar/CalendarView.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/calendar/CalendarView.java?rev=1039939&r1=1039938&r2=1039939&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/calendar/CalendarView.java (original)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/calendar/CalendarView.java Sun Nov 28 20:25:56 2010
@@ -20,11 +20,10 @@
package org.apache.isis.viewer.dnd.calendar;
-import org.apache.log4j.Logger;
import org.apache.isis.viewer.dnd.drawing.Bounds;
import org.apache.isis.viewer.dnd.drawing.Location;
import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.field.DatePicker;
+import org.apache.isis.viewer.dnd.field.DatePickerControl;
import org.apache.isis.viewer.dnd.toolbar.ToolbarView;
import org.apache.isis.viewer.dnd.view.Content;
import org.apache.isis.viewer.dnd.view.FocusManager;
@@ -35,6 +34,7 @@ import org.apache.isis.viewer.dnd.view.c
import org.apache.isis.viewer.dnd.view.content.NullContent;
import org.apache.isis.viewer.dnd.view.control.AbstractButtonAction;
import org.apache.isis.viewer.dnd.view.control.Button;
+import org.apache.log4j.Logger;
public class CalendarView extends CompositeView {
@@ -164,7 +164,7 @@ public class CalendarView extends Compos
toolbarView.addView(new Button(new AbstractButtonAction("Date") {
public void execute(Workspace workspace, View view, Location at) {
Content content = new NullContent() {};
- view = new DatePicker(content);
+ view = DatePickerControl.getPicker(content);
calendar.today();
getViewManager().setOverlayView(view);
}
Modified: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DateFieldSpecification.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DateFieldSpecification.java?rev=1039939&r1=1039938&r2=1039939&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DateFieldSpecification.java (original)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DateFieldSpecification.java Sun Nov 28 20:25:56 2010
@@ -47,7 +47,7 @@ public class DateFieldSpecification exte
return new OpenDropDownBorder(field) {
@Override
protected View createDropDownView() {
- return new DatePicker(content);
+ return DatePickerControl.getPicker(content);
}
@Override
Modified: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePicker.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePicker.java?rev=1039939&r1=1039938&r2=1039939&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePicker.java (original)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePicker.java Sun Nov 28 20:25:56 2010
@@ -16,366 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-
package org.apache.isis.viewer.dnd.field;
-import java.awt.event.KeyEvent;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.progmodel.facets.value.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.Location;
-import org.apache.isis.viewer.dnd.drawing.Shape;
import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-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.View;
-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 DatePicker extends AbstractView {
- private static class Button {
- private char key;
- private int period;
- private int increment;
-
- public Button(char key, int period, int increment) {
- this.key = key;
- this.period = period;
- this.increment = increment;
- }
-
- public void adjustDate(Calendar date) {
- date.add(period, increment);
- }
-
- public String getLabel() {
- return "" + key;
- }
- }
-
- private static final Button[] buttons = new Button[] {
- new Button('W', Calendar.WEEK_OF_YEAR, 1 ),
- new Button('F', Calendar.WEEK_OF_YEAR, 2),
- new Button('M', Calendar.MONTH, 1),
- new Button('Q', Calendar.MONTH, 3),
- new Button('Y', Calendar.YEAR, 1),
- new Button('D', Calendar.YEAR, 10),
-
- new Button('w', Calendar.WEEK_OF_YEAR, -1),
- new Button('f', Calendar.WEEK_OF_YEAR, -2),
- new Button('m', Calendar.MONTH, -1),
- new Button('q', Calendar.MONTH, -3),
- new Button('y', Calendar.YEAR, -1),
- new Button('d', Calendar.YEAR, -10)
- };
- private static final int ROWS = 7;
- private static final int COLUMNS = 7;
- private static final int PADDING = 5;
- private final Calendar date;
- private Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- private int labelWidth = style.stringWidth("XXX 0000") * 4 / 3;
- private int cellWidth = style.stringWidth("00") * 8 / 5;
- private int cellHeight = style.getLineHeight() * 4 / 3;
- private int headerHeight = style.getLineHeight() + PADDING * 2;
- private int firstRowBaseline = headerHeight + style.getLineHeight();
- private int calendarHeight = cellHeight * ROWS;
- private int controlWidth = style.charWidth('W') + 4;
- private int controlHeight = style.getLineHeight() * 11 / 10 + controlWidth + 4 + PADDING * 2;
- private int mouseOverButton = -1;
- private int mouseOverRow = -1;
- private int mouseOverColumn;
- private Calendar currentDate;
- private final Calendar today;
- private final DateFormat monthFormat = new SimpleDateFormat("MMM");
- private final DateFormat dayFormat = new SimpleDateFormat("EEE");
- private boolean isEditable;
-
-
- public DatePicker(Content content) {
- super(content);
-
- isEditable = content instanceof FieldContent && ((FieldContent) content).isEditable().isAllowed();
-
- today = Calendar.getInstance();
- clearTime(today);
-
- date = Calendar.getInstance();
- ObjectAdapter dateAdapter = ((TextParseableContent) getContent()).getAdapter();
- if (dateAdapter != null) {
- DateValueFacet facet = dateAdapter.getSpecification().getFacet(DateValueFacet.class);
- currentDate = Calendar.getInstance();
- Date dateValue = facet.dateValue(dateAdapter);
- currentDate.setTime(dateValue);
- clearTime(currentDate);
- date.setTime(dateValue);
- }
- clearTime(date);
- date.add(Calendar.DAY_OF_MONTH, -21);
- roundDownDate();
- }
-
- private void roundDownDate() {
- date.add(Calendar.DAY_OF_MONTH, date.getFirstDayOfWeek() - date.get(Calendar.DAY_OF_WEEK));
- }
-
- private void clearTime(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(Size availableSpace) {
- return new Size(labelWidth + COLUMNS * cellWidth + 2, headerHeight + calendarHeight + controlHeight + 2);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- int width = getSize().getWidth();
- int height = getSize().getHeight();
- Color secondaryTextColor = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
- Color mainTextColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+public interface DatePicker {
- drawBackground(canvas, width, height);
- drawDaysOfWeek(canvas, secondaryTextColor);
- if (isEditable) {
- drawDayMarker(canvas);
- }
- drawMonthsAndWeeks(canvas, secondaryTextColor);
- drawDays(canvas, mainTextColor);
- drawControls(canvas, width);
- }
+ public abstract Size getRequiredSize(Size availableSpace);
- private void drawBackground(final Canvas canvas, int width, int height) {
- canvas.drawSolidRectangle(0, 0, width - 1, headerHeight, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
- canvas.drawSolidRectangle(0, 0, labelWidth, height - 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
- canvas.drawSolidRectangle(labelWidth, headerHeight, width - labelWidth - 1, height - cellHeight - 1, Toolkit
- .getColor(ColorsAndFonts.COLOR_WINDOW));
- canvas.drawRectangle(0, 0, width - 1, height - 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
- }
+ public abstract void draw(final Canvas canvas);
- private void drawDaysOfWeek(final Canvas canvas, final Color textColor) {
- Calendar d = Calendar.getInstance();
- d.setTime(date.getTime());
- int x = labelWidth + cellWidth / 2;
- int y = PADDING + style.getAscent();
- for (int column = 0; column < 7; column++) {
- String day = dayFormat.format(d.getTime()).substring(0,1);
- canvas.drawText(day, x - style.stringWidth(day) / 2, y, textColor, style);
- x += cellWidth;
- d.add(Calendar.DAY_OF_MONTH, 1);
- }
- }
-
- private void drawDayMarker(final Canvas canvas) {
- if (mouseOverColumn >= 0 && mouseOverColumn < COLUMNS && mouseOverRow >= 0 && mouseOverRow < ROWS) {
- canvas.drawRectangle(labelWidth + mouseOverColumn * cellWidth, headerHeight + mouseOverRow * cellHeight, cellWidth,
- cellHeight, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3));
- }
- }
-
- private int drawMonthsAndWeeks(final Canvas canvas, Color color) {
- Calendar d = Calendar.getInstance();
- d.setTime(date.getTime());
- int y = firstRowBaseline;
- String lastMonth = "";
- for (int row = 0; row < ROWS; row++) {
- int x = labelWidth;
- String month = monthFormat.format(d.getTime()) + " " + d.get(Calendar.YEAR);
- if (!month.equals(lastMonth)) {
- canvas.drawText(month, x - style.stringWidth(month) - PADDING, y, color, style);
- lastMonth = month;
- } else {
- String week = "wk " + (d.get(Calendar.WEEK_OF_YEAR));
- canvas.drawText(week == null ? "*" : week, x - style.stringWidth(week) - PADDING, y, color, style);
- }
- d.add(Calendar.DAY_OF_MONTH, 7);
- y += cellHeight;
- }
- return y;
- }
-
- private int drawDays(final Canvas canvas, Color mainTextColor) {
- Calendar d = Calendar.getInstance();
- d.setTime(date.getTime());
- int y = firstRowBaseline;
- for (int row = 0; row < ROWS; row++) {
- int x = labelWidth;
- for (int column = 0; column < COLUMNS; column++) {
- String day = "" + d.get(Calendar.DAY_OF_MONTH);
- if (currentDate != null && currentDate.equals(d)) {
- canvas.drawSolidRectangle(x, headerHeight + row * cellHeight, cellWidth, cellHeight, Toolkit
- .getColor(ColorsAndFonts.COLOR_PRIMARY2));
- }
- if (today.getTime().equals(d.getTime())) {
- canvas.drawRectangle(x, headerHeight + row * cellHeight, cellWidth, cellHeight, Toolkit
- .getColor(ColorsAndFonts.COLOR_SECONDARY2));
- }
- canvas.drawText(day, x - PADDING / 2 + cellWidth - style.stringWidth(day), y, mainTextColor, style);
- x += cellWidth;
- d.add(Calendar.DAY_OF_MONTH, 1);
- }
- y += cellHeight;
- }
- return y;
- }
-
- private void drawControls(final Canvas canvas, int width) {
- int x = labelWidth + PADDING;
- int y = headerHeight + calendarHeight + PADDING;
-
- int spaceTaken = width - labelWidth - 2 * PADDING - 6 * controlWidth;
- int spaceBetween = spaceTaken / 5;
- int adjustment = spaceTaken - 5 * spaceBetween - 2;
-
- for (int i = 0; i < buttons.length / 2; i++) {
- drawControl(canvas, x, y, controlWidth, controlHeight - PADDING * 2, buttons[i].getLabel(), i);
- x += controlWidth + spaceBetween + (i == 3 ? adjustment : 0);
- }
- }
-
- private void drawControl(
- final Canvas canvas,
- final int x,
- final int y,
- final int width,
- final int height,
- final String label,
- int over) {
- if (Toolkit.debug) {
- canvas.drawRectangle(x - 2, y, width + 4, height, Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_VIEW));
- }
- Color color = Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2);
-
- int arrowHeight = width / 2;
- Shape upArrow = new Shape(0, arrowHeight);
- upArrow.addVector(arrowHeight, -arrowHeight);
- upArrow.addVector(arrowHeight, arrowHeight);
- if (mouseOverButton == over + 6) {
- canvas.drawSolidShape(upArrow, x, y + 2, color);
- } else {
- canvas.drawShape(upArrow, x, y + 2, color);
- }
-
- Shape downArrow = new Shape(0, 0);
- downArrow.addVector(arrowHeight, arrowHeight);
- downArrow.addVector(arrowHeight, -arrowHeight);
- if (mouseOverButton == over) {
- canvas.drawSolidShape(downArrow, x, y + height - 4 - arrowHeight, color);
- } else {
- canvas.drawShape(downArrow, x, y + height - 4 - arrowHeight, color);
- }
- int charWidth = style.stringWidth(label);
- canvas.drawText(label, x + width / 2 - charWidth / 2, y + 2 + arrowHeight + style.getAscent(), color, style);
-
- }
-
- public void mouseMoved(Location location) {
- int over = overButton(location);
- if (over == -1) {
- mouseOverButton = -1;
- int col = column(location);
- int row = row(location);
- if (col != mouseOverColumn || row != mouseOverRow) {
- if (isEditable) {
- mouseOverColumn = col;
- mouseOverRow = row;
- }
- markDamaged();
- }
- } else if (over != mouseOverButton) {
- mouseOverButton = over;
- markDamaged();
- }
- }
-
- public void exited() {
- mouseOverButton = -1;
- super.exited();
- }
-
- private int overButton(Location location) {
- int x = location.getX();
- int y = location.getY();
- int verticalBoundary = headerHeight + calendarHeight + PADDING;
- int height = controlHeight - PADDING * 2;
- if (x > labelWidth && y > verticalBoundary && y < verticalBoundary + height) {
- int column = (x - labelWidth) / ((getSize().getWidth() - labelWidth) / 6);
- if (y <= verticalBoundary + height / 2 ) {
- column += 6;
- }
- return column;
- } else {
- return -1;
- }
- }
-
- @Override
- public void firstClick(final Click click) {
- if (mouseOverButton != -1) {
- buttons[mouseOverButton].adjustDate(date);
- roundDownDate();
- markDamaged();
- return;
- }
-
- if (isEditable) {
- Location location = click.getLocation();
- int col = column(location);
- int row = row(location);
- if (col >= 0 && col < COLUMNS && row >= 0 && row < ROWS) {
- date.add(Calendar.DAY_OF_MONTH, row * 7 + col);
- Content content = getContent();
- DateValueFacet facet = content.getSpecification().getFacet(DateValueFacet.class);
- ObjectAdapter value = facet.createValue(date.getTime());
- ((TextParseableContent) content).parseTextEntry(value.titleString());
- ((TextParseableContent) content).entryComplete();
- View view = getView();
- /*
- if (content.isObject()) {
- ((ObjectContent) content).setObject(value);
- }
- */
- //content.
- getView().refresh();
-
- //content.
- }
- }
- getViewManager().clearOverlayView();
- }
-
- private int row(Location location) {
- return (location.getY() - headerHeight) / cellHeight;
- }
-
- private int column(Location location) {
- return (location.getX() - labelWidth) / cellWidth;
- }
-
- public void keyPressed(KeyboardAction key) {
- if (isEditable && key.getKeyCode() == KeyEvent.VK_ESCAPE) {
- getViewManager().clearOverlayView();
- } else {
- super.keyPressed(key);
- }
- }
}
-
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java Sun Nov 28 20:25:56 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.field;
+
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.Look;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.look.LookFactory;
+import org.apache.isis.viewer.dnd.view.look.linux.LinuxDatePicker;
+import org.apache.isis.viewer.dnd.view.look.linux.LinuxLook;
+
+
+public class DatePickerControl {
+
+ private static final Look LINUX_LOOK = new LinuxLook();
+
+ public static View getPicker(Content content) {
+ Look look = LookFactory.getInstalledLook();
+ if (look.getClass().isInstance(LINUX_LOOK)) {
+ return new LinuxDatePicker(content);
+ }
+ return new SimpleDatePicker(content);
+ }
+
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/DatePickerControl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java Sun Nov 28 20:25:56 2010
@@ -0,0 +1,394 @@
+/*
+ * 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.field;
+
+import java.awt.event.KeyEvent;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.progmodel.facets.value.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.Location;
+import org.apache.isis.viewer.dnd.drawing.Shape;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+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 SimpleDatePicker extends AbstractView implements DatePicker {
+ private static class Button {
+ private char key;
+ private int period;
+ private int increment;
+
+ public Button(char key, int period, int increment) {
+ this.key = key;
+ this.period = period;
+ this.increment = increment;
+ }
+
+ public void adjustDate(Calendar date) {
+ date.add(period, increment);
+ }
+
+ public String getLabel() {
+ return "" + key;
+ }
+ }
+
+ private static final Button[] buttons = new Button[] {
+ new Button('W', Calendar.WEEK_OF_YEAR, 1 ),
+ new Button('F', Calendar.WEEK_OF_YEAR, 2),
+ new Button('M', Calendar.MONTH, 1),
+ new Button('Q', Calendar.MONTH, 3),
+ new Button('Y', Calendar.YEAR, 1),
+ new Button('D', Calendar.YEAR, 10),
+
+ new Button('w', Calendar.WEEK_OF_YEAR, -1),
+ new Button('f', Calendar.WEEK_OF_YEAR, -2),
+ new Button('m', Calendar.MONTH, -1),
+ new Button('q', Calendar.MONTH, -3),
+ new Button('y', Calendar.YEAR, -1),
+ new Button('d', Calendar.YEAR, -10)
+ };
+ private static final int ROWS = 7;
+ private static final int COLUMNS = 7;
+ private static final int PADDING = 5;
+ private final Calendar date;
+ private Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
+ private int labelWidth = style.stringWidth("XXX 0000") * 4 / 3;
+ private int cellWidth = style.stringWidth("00") * 8 / 5;
+ private int cellHeight = style.getLineHeight() * 4 / 3;
+ private int headerHeight = style.getLineHeight() + PADDING * 2;
+ private int firstRowBaseline = headerHeight + style.getLineHeight();
+ private int calendarHeight = cellHeight * ROWS;
+ private int controlWidth = style.charWidth('W') + 4;
+ private int controlHeight = style.getLineHeight() * 11 / 10 + controlWidth + 4 + PADDING * 2;
+ private int mouseOverButton = -1;
+ private int mouseOverRow = -1;
+ private int mouseOverColumn;
+ private Calendar currentDate;
+ private final Calendar today;
+ private final DateFormat monthFormat = new SimpleDateFormat("MMM");
+ private final DateFormat dayFormat = new SimpleDateFormat("EEE");
+ private boolean isEditable;
+
+
+ public SimpleDatePicker(Content content) {
+ super(content);
+
+ isEditable = content instanceof FieldContent && ((FieldContent) content).isEditable().isAllowed();
+
+ today = Calendar.getInstance();
+ clearTime(today);
+
+ date = Calendar.getInstance();
+ ObjectAdapter dateAdapter = ((TextParseableContent) getContent()).getAdapter();
+ if (dateAdapter != null) {
+ DateValueFacet facet = dateAdapter.getSpecification().getFacet(DateValueFacet.class);
+ currentDate = Calendar.getInstance();
+ Date dateValue = facet.dateValue(dateAdapter);
+ currentDate.setTime(dateValue);
+ clearTime(currentDate);
+ date.setTime(dateValue);
+ }
+ clearTime(date);
+ date.add(Calendar.DAY_OF_MONTH, -21);
+ roundDownDate();
+ }
+
+ private void roundDownDate() {
+ date.add(Calendar.DAY_OF_MONTH, date.getFirstDayOfWeek() - date.get(Calendar.DAY_OF_WEEK));
+ }
+
+ private void clearTime(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);
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#getRequiredSize(org.nakedobjects.plugins.dnd.drawing.Size)
+ */
+ @Override
+ public Size getRequiredSize(Size availableSpace) {
+ return new Size(labelWidth + COLUMNS * cellWidth + 2, headerHeight + calendarHeight + controlHeight + 2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#draw(org.nakedobjects.plugins.dnd.drawing.Canvas)
+ */
+ @Override
+ public void draw(final Canvas canvas) {
+ int width = getSize().getWidth();
+ int height = getSize().getHeight();
+
+ Color secondaryTextColor = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
+ Color mainTextColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
+
+ drawBackground(canvas, width, height);
+ drawDaysOfWeek(canvas, secondaryTextColor);
+ if (isEditable) {
+ drawDayMarker(canvas);
+ }
+ drawMonthsAndWeeks(canvas, secondaryTextColor);
+ drawDays(canvas, mainTextColor);
+ drawControls(canvas, width);
+ }
+
+ private void drawBackground(final Canvas canvas, int width, int height) {
+ canvas.drawSolidRectangle(0, 0, width - 1, headerHeight, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ canvas.drawSolidRectangle(0, 0, labelWidth, height - 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ canvas.drawSolidRectangle(labelWidth, headerHeight, width - labelWidth - 1, height - cellHeight - 1, Toolkit
+ .getColor(ColorsAndFonts.COLOR_WINDOW));
+ canvas.drawRectangle(0, 0, width - 1, height - 1, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1));
+ }
+
+ private void drawDaysOfWeek(final Canvas canvas, final Color textColor) {
+ Calendar d = Calendar.getInstance();
+ d.setTime(date.getTime());
+ int x = labelWidth + cellWidth / 2;
+ int y = PADDING + style.getAscent();
+ for (int column = 0; column < 7; column++) {
+ String day = dayFormat.format(d.getTime()).substring(0,1);
+ canvas.drawText(day, x - style.stringWidth(day) / 2, y, textColor, style);
+ x += cellWidth;
+ d.add(Calendar.DAY_OF_MONTH, 1);
+ }
+ }
+
+ private void drawDayMarker(final Canvas canvas) {
+ if (mouseOverColumn >= 0 && mouseOverColumn < COLUMNS && mouseOverRow >= 0 && mouseOverRow < ROWS) {
+ canvas.drawRectangle(labelWidth + mouseOverColumn * cellWidth, headerHeight + mouseOverRow * cellHeight, cellWidth,
+ cellHeight, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3));
+ }
+ }
+
+ private int drawMonthsAndWeeks(final Canvas canvas, Color color) {
+ Calendar d = Calendar.getInstance();
+ d.setTime(date.getTime());
+ int y = firstRowBaseline;
+ String lastMonth = "";
+ for (int row = 0; row < ROWS; row++) {
+ int x = labelWidth;
+ String month = monthFormat.format(d.getTime()) + " " + d.get(Calendar.YEAR);
+ if (!month.equals(lastMonth)) {
+ canvas.drawText(month, x - style.stringWidth(month) - PADDING, y, color, style);
+ lastMonth = month;
+ } else {
+ String week = "wk " + (d.get(Calendar.WEEK_OF_YEAR));
+ canvas.drawText(week == null ? "*" : week, x - style.stringWidth(week) - PADDING, y, color, style);
+ }
+ d.add(Calendar.DAY_OF_MONTH, 7);
+ y += cellHeight;
+ }
+ return y;
+ }
+
+ private int drawDays(final Canvas canvas, Color mainTextColor) {
+ Calendar d = Calendar.getInstance();
+ d.setTime(date.getTime());
+ int y = firstRowBaseline;
+ for (int row = 0; row < ROWS; row++) {
+ int x = labelWidth;
+ for (int column = 0; column < COLUMNS; column++) {
+ String day = "" + d.get(Calendar.DAY_OF_MONTH);
+ if (currentDate != null && currentDate.equals(d)) {
+ canvas.drawSolidRectangle(x, headerHeight + row * cellHeight, cellWidth, cellHeight, Toolkit
+ .getColor(ColorsAndFonts.COLOR_PRIMARY2));
+ }
+ if (today.getTime().equals(d.getTime())) {
+ canvas.drawRectangle(x, headerHeight + row * cellHeight, cellWidth, cellHeight, Toolkit
+ .getColor(ColorsAndFonts.COLOR_SECONDARY2));
+ }
+ canvas.drawText(day, x - PADDING / 2 + cellWidth - style.stringWidth(day), y, mainTextColor, style);
+ x += cellWidth;
+ d.add(Calendar.DAY_OF_MONTH, 1);
+ }
+ y += cellHeight;
+ }
+ return y;
+ }
+
+ private void drawControls(final Canvas canvas, int width) {
+ int x = labelWidth + PADDING;
+ int y = headerHeight + calendarHeight + PADDING;
+
+ int spaceTaken = width - labelWidth - 2 * PADDING - 6 * controlWidth;
+ int spaceBetween = spaceTaken / 5;
+ int adjustment = spaceTaken - 5 * spaceBetween - 2;
+
+ for (int i = 0; i < buttons.length / 2; i++) {
+ drawControl(canvas, x, y, controlWidth, controlHeight - PADDING * 2, buttons[i].getLabel(), i);
+ x += controlWidth + spaceBetween + (i == 3 ? adjustment : 0);
+ }
+ }
+
+ private void drawControl(
+ final Canvas canvas,
+ final int x,
+ final int y,
+ final int width,
+ final int height,
+ final String label,
+ int over) {
+ if (Toolkit.debug) {
+ canvas.drawRectangle(x - 2, y, width + 4, height, Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_VIEW));
+ }
+ Color color = Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2);
+
+ int arrowHeight = width / 2;
+ Shape upArrow = new Shape(0, arrowHeight);
+ upArrow.addVector(arrowHeight, -arrowHeight);
+ upArrow.addVector(arrowHeight, arrowHeight);
+ if (mouseOverButton == over + 6) {
+ canvas.drawSolidShape(upArrow, x, y + 2, color);
+ } else {
+ canvas.drawShape(upArrow, x, y + 2, color);
+ }
+
+ Shape downArrow = new Shape(0, 0);
+ downArrow.addVector(arrowHeight, arrowHeight);
+ downArrow.addVector(arrowHeight, -arrowHeight);
+ if (mouseOverButton == over) {
+ canvas.drawSolidShape(downArrow, x, y + height - 4 - arrowHeight, color);
+ } else {
+ canvas.drawShape(downArrow, x, y + height - 4 - arrowHeight, color);
+ }
+ int charWidth = style.stringWidth(label);
+ canvas.drawText(label, x + width / 2 - charWidth / 2, y + 2 + arrowHeight + style.getAscent(), color, style);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#mouseMoved(org.nakedobjects.plugins.dnd.drawing.Location)
+ */
+ public void mouseMoved(Location location) {
+ int over = overButton(location);
+ if (over == -1) {
+ mouseOverButton = -1;
+ int col = column(location);
+ int row = row(location);
+ if (col != mouseOverColumn || row != mouseOverRow) {
+ if (isEditable) {
+ mouseOverColumn = col;
+ mouseOverRow = row;
+ }
+ markDamaged();
+ }
+ } else if (over != mouseOverButton) {
+ mouseOverButton = over;
+ markDamaged();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#exited()
+ */
+ public void exited() {
+ mouseOverButton = -1;
+ super.exited();
+ }
+
+ private int overButton(Location location) {
+ int x = location.getX();
+ int y = location.getY();
+ int verticalBoundary = headerHeight + calendarHeight + PADDING;
+ int height = controlHeight - PADDING * 2;
+ if (x > labelWidth && y > verticalBoundary && y < verticalBoundary + height) {
+ int column = (x - labelWidth) / ((getSize().getWidth() - labelWidth) / 6);
+ if (y <= verticalBoundary + height / 2 ) {
+ column += 6;
+ }
+ return column;
+ } else {
+ return -1;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#firstClick(org.nakedobjects.plugins.dnd.view.Click)
+ */
+ @Override
+ public void firstClick(final Click click) {
+ if (mouseOverButton != -1) {
+ buttons[mouseOverButton].adjustDate(date);
+ roundDownDate();
+ markDamaged();
+ return;
+ }
+
+ if (isEditable) {
+ Location location = click.getLocation();
+ int col = column(location);
+ int row = row(location);
+ if (col >= 0 && col < COLUMNS && row >= 0 && row < ROWS) {
+ date.add(Calendar.DAY_OF_MONTH, row * 7 + col);
+ Content content = getContent();
+ DateValueFacet facet = content.getSpecification().getFacet(DateValueFacet.class);
+ ObjectAdapter value = facet.createValue(date.getTime());
+ ((TextParseableContent) content).parseTextEntry(value.titleString());
+ ((TextParseableContent) content).entryComplete();
+ /*
+ if (content.isObject()) {
+ ((ObjectContent) content).setObject(value);
+ }
+ */
+ //content.
+ getView().refresh();
+
+ //content.
+ }
+ }
+ getViewManager().clearOverlayView();
+ }
+
+ private int row(Location location) {
+ return (location.getY() - headerHeight) / cellHeight;
+ }
+
+ private int column(Location location) {
+ return (location.getX() - labelWidth) / cellWidth;
+ }
+
+ /* (non-Javadoc)
+ * @see org.nakedobjects.plugins.dnd.field.DatePicker#keyPressed(org.nakedobjects.plugins.dnd.view.KeyboardAction)
+ */
+ public void keyPressed(KeyboardAction key) {
+ if (isEditable && key.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ getViewManager().clearOverlayView();
+ } else {
+ super.keyPressed(key);
+ }
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/field/SimpleDatePicker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java?rev=1039939&r1=1039938&r2=1039939&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java (original)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java Sun Nov 28 20:25:56 2010
@@ -26,6 +26,7 @@ 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;
@@ -34,6 +35,7 @@ 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;
@@ -42,6 +44,7 @@ public class LookFactory {
looks.add(SIMPLE_LOOK);
looks.add(LINE_LOOK);
looks.add(SWING_LOOK);
+ looks.add(LINUX_LOOK);
String className = Properties.getString("look");
if (className != null) {
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java Sun Nov 28 20:25:56 2010
@@ -0,0 +1,71 @@
+/*
+ * 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;
+ }
+
+ public void draw(Canvas canvas, Size size, boolean isDisabled, boolean isDefault, boolean hasFocus, boolean isOver, boolean isPressed, 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);
+ }
+
+ public Size getMaximumSize(String text) {
+ final int buttonWidth = TEXT_PADDING + Toolkit.getText(ColorsAndFonts.TEXT_CONTROL).stringWidth(text) + TEXT_PADDING;
+ return new Size(buttonWidth, buttonHeight);
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/Button3DStyleRender.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java Sun Nov 28 20:25:56 2010
@@ -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 {
+
+
+ public void draw(Canvas canvas, int width, int height, boolean isDisabled, boolean isOver, 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);
+
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CloseWindow3DRender.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java Sun Nov 28 20:25:56 2010
@@ -0,0 +1,144 @@
+/*
+ * 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.DebugString;
+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.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 + View.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;
+
+ public void debugDetails(final DebugString debug) {
+ debug.appendln("titlebar ", top - titlebarHeight);
+ }
+
+ public void layoutControls(final Size size, View[] controls) {
+ int x = size.getWidth() - right - (WindowControl.WIDTH + View.HPADDING) * controls.length;
+ final int y = LINE_THICKNESS + View.VPADDING;
+
+ for (int i = 0; i < controls.length; i++) {
+ controls[i].setSize(controls[i].getRequiredSize(new Size()));
+ controls[i].setLocation(new Location(x, y));
+ x += controls[i].getSize().getWidth() + View.HPADDING;
+ }
+ }
+
+ public void draw(final Canvas canvas, Size s, boolean hasFocus, final ViewState state, View[] controls, 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()) {
+ 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);
+
+ int controlWidth = View.HPADDING + (WindowControl.WIDTH + View.HPADDING) * controls.length;
+ String text = TextUtils.limitText(title, TITLE_STYLE, width - controlWidth - LINE_THICKNESS * 2 - 2);
+ canvas.drawText(text, x + View.HPADDING, baseline, titleBarTextColor, TITLE_STYLE);
+
+ final Color white = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
+ final int hatchX = View.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);
+
+ }
+
+ public void drawTransientMarker(Canvas canvas, 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);
+ }
+
+ }
+
+ public void getRequiredSize(Size size, String title, View[] controls) {
+ final int width = left + View.HPADDING + TITLE_STYLE.stringWidth(title) + View.HPADDING + controls.length
+ * (WindowControl.WIDTH + View.HPADDING) + View.HPADDING + right;
+ // size.extendWidth(getLeft() + getRight());
+ size.ensureWidth(width);
+ }
+
+ public int getLeft() {
+ return left;
+ }
+
+ public int getRight() {
+ return right;
+ }
+
+ public int getTop() {
+ return top;
+ }
+
+ public int getBottom() {
+ return bottom;
+ }
+
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/CustomStyleWindowBorder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java Sun Nov 28 20:25:56 2010
@@ -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 {
+
+ public void draw(Canvas canvas, int width, int height, boolean isDisabled, boolean isOver, 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));
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/IconizeWindow3DRender.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java Sun Nov 28 20:25:56 2010
@@ -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.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.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 int cellWidth = day_img.getWidth();
+ private int cellHeight = day_img.getHeight();
+ private final Calendar date;
+ private Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
+ private Calendar currentDate;
+ private final Calendar today;
+ private 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(Content content) {
+ super(content);
+
+ isEditable = content instanceof FieldContent && ((FieldContent) content).isEditable().isAllowed();
+
+ today = Calendar.getInstance();
+ clearTime(today);
+
+ date = Calendar.getInstance();
+ ObjectAdapter dateAdapter = ((TextParseableContent) getContent()).getAdapter();
+ if (dateAdapter != null) {
+ DateValueFacet facet = dateAdapter.getSpecification().getFacet(DateValueFacet.class);
+ currentDate = Calendar.getInstance();
+ 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(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(Size availableSpace) {
+ return new Size(225,270);
+ }
+
+ @Override
+ public void draw(final Canvas canvas) {
+ int width = getSize().getWidth();
+ int height = getSize().getHeight();
+
+ Color textColor = Toolkit.getColor(ColorsAndFonts.COLOR_WHITE);
+
+ drawBackground(canvas, width, height, textColor);
+ drawDaysOfWeek(canvas, textColor);
+ drawControls(canvas, width);
+ }
+
+ private void drawBackground(final Canvas canvas, int width, int height, 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;
+ 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(int x, int y) {
+ int mouseX = mouseLocation.getX();
+ 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, 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);
+ }
+
+ public void mouseMoved(Location location) {
+ mouseLocation = location;
+ if (location.getX() > 0 && location.getY() > 0) {
+ markDamaged();
+ }
+ }
+
+ public void exited() {
+ mouseOver(-1, -1);
+ super.exited();
+ }
+
+ @Override
+ public void firstClick(final Click click) {
+ int x = click.getLocation().getX();
+ 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) {
+ Location location = click.getLocation();
+ Date selectedDate = getSelectedDate(location);
+ if (selectedDate != null) {
+ date.setTime(selectedDate);
+ Content content = getContent();
+ DateValueFacet facet = content.getSpecification().getFacet(DateValueFacet.class);
+ ObjectAdapter value = facet.createValue(date.getTime());
+ ((TextParseableContent) content).parseTextEntry(value.titleString());
+ ((TextParseableContent) content).entryComplete();
+ getView().refresh();
+ }
+ }
+ getViewManager().clearOverlayView();
+ }
+
+ private Date getSelectedDate(Location location) {
+ int x,y=0;
+ 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;
+ }
+
+ public void keyPressed(KeyboardAction key) {
+ if (isEditable && key.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ getViewManager().clearOverlayView();
+ } else {
+ super.keyPressed(key);
+ }
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxDatePicker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java Sun Nov 28 20:25:56 2010
@@ -0,0 +1,42 @@
+/*
+ * 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 {
+
+ public void install() {
+ Button.setButtonRender(new Button3DStyleRender());
+ AbstractWindowBorder.setBorderRenderer(new CustomStyleWindowBorder());
+ CloseWindowControl.setRender(new CloseWindow3DRender());
+ ResizeWindowControl.setRender(new ResizeWindow3DRender());
+ IconizeWindowControl.setRender(new IconizeWindow3DRender());
+ }
+
+ public String getName() {
+ return "Linux";
+ }
+
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/LinuxLook.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java?rev=1039939&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java (added)
+++ incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java Sun Nov 28 20:25:56 2010
@@ -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.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 {
+
+ public void draw(Canvas canvas, int width, int height, boolean isDisabled, boolean isOver, 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));
+
+ }
+}
Propchange: incubator/isis/trunk/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/view/look/linux/ResizeWindow3DRender.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button1.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/button1.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button1.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button2.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/button2.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button2.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button3.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/button3.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button3.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button4.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/button4.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/button4.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/day2.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/day2.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/day2.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadedown.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadedown.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadedown.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadeup.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadeup.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/decadeup.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/highlight2.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/highlight2.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/highlight2.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthdown.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthdown.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthdown.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthup.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthup.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/monthup.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/yeardown.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/yeardown.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/yeardown.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/isis/trunk/viewer/dnd/src/main/resources/images/yearup.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/dnd/src/main/resources/images/yearup.png?rev=1039939&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/isis/trunk/viewer/dnd/src/main/resources/images/yearup.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream